trendmanagement / Tmqr-framework-2

3 stars 0 forks source link

Alex Consolidated Task #99

Open spickering-git opened 6 years ago

spickering-git commented 6 years ago

1) https://github.com/trendmanagement/Tmqr-framework-2/issues/96 The last comment on this issue re: risk free rate. Can please let me know how we will address.

2) iqfeed data integrity check you were going to possibly add a data check here https://github.com/trendmanagement/Tmqr-framework-2/blob/d8f04a9ec8a5a6f038c91a458c331999bc4ae961/tmqrscripts/data/run_iqfeed_updates.py#L201 And we also need a check at the database level. Let me know if you want me to work on this one.

3) you were going to come up with a simple log consolidator.

4) Model and realtime comparison in a notebook dashboard format

alexveden commented 6 years ago

iqfeed data integrity check

Done, in today commit.

alexveden commented 6 years ago

Model and realtime comparison in a notebook dashboard format

I've implemented some fixes to add an ability to compare real-time and SmartCampaign positions.

Here is a sample notebook: https://10.0.1.2:8888/notebooks/smart_campaign_generation/ES_SmartCampaign_RelStrength_V5_real_payoff.ipynb#Plot-real-payoff-diagram-of-Smart-Campaign

How it works:

  1. Loads the deployed smart campaign or just uses smart campaign which defined in the notebook.
  2. Calculates smart campaign structure at the 'analysis date'
  3. If the account name is specified - loads the account money and risk params to calculate the rounded size of the opened positions. Otherwise, uses fractional weights of the smart campaign.

image

Notes

  1. It still works with the only single instrument. Multi-instrument campaigns still might be the problem. Implementing this is possible, but connected with some performance issues. (To filter instruments I need to perform thousands of DB calls to build campaign position at specific date)
  2. CampaignReport(CAMPAIGN_NAME, datasource) is irrelevant for Smart Campaigns, because it doesn't take into account the dynamic alpha changes. It might be used just for actual exposure estimation of alphas. Settlement PnL and Model PnLs are inaccurate.
  3. Real account positions and SmartCampaign positions might be irrelevant because equity of the account might have a different value.
spickering-git commented 6 years ago

@alexveden Please make an option to run iqfeed collection in delayed mode to poll history to maintain delayed data up to date

We also need to fill the 'contract_bars' collection in tmldb_v2, Please advise me when you will be making this change. When the 'contract_bars' collection is being filled:

CQG is being turned off Dec 31

spickering-git commented 6 years ago

@alexveden We need to be able to generate payoff for multi-instrument campaign to have comparison to realtime for reconciling.

I think we should do this by simply filter for the instruments right at the top level of requesting for the payoff. This would make it simple to generate a payoff for each instrument in the multi-instrument campaign. When performing:

def load_campaign(self, campaign_name, date=None, ticker=None, campaign_dict=None, account_name=None ):
....
acct = exc_mgr.account_load(account_name) #pass ticker in here and filter

We would be able to filter for alphas that are associated with a specified instrument. When I was testing I saw the campaign is queried from 'campaigns' and not 'campaigns_smart' so there isn't a product field to narrow the alpha query.

@nikolas-joyce suggested that we just take position from accounts_positions or accounts_positions_archive. That way positions are rounded for money management.

What is the best approach to make the payoff work for multi instrument campaigns? Is there a quick way to make this work?

alexveden commented 6 years ago

So, I think we can take the ideas of multiproduct reconciliation from https://github.com/trendmanagement/tmqrexo_alexveden/blob/new_mongo/backtester/reports/campaign_real_compare_report.py#L181

and merge them with

https://github.com/trendmanagement/tmqrexo_alexveden/blob/new_mongo/backtester/reports/payoffs.py#L95