Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple tickers, with price values in one market event #200

Closed
mhallsmoore opened this issue Apr 17, 2017 · 3 comments
Closed

Multiple tickers, with price values in one market event #200

mhallsmoore opened this issue Apr 17, 2017 · 3 comments

Comments

@mhallsmoore
Copy link
Owner

A common pattern that I've found in carrying out strategy development, particularly with equity portfolios involving many tickers, is that the AbstractStrategy-derived strategy class must keep a tally of all current prices of each ticker it is interested in. This is particularly problematic for equity portfolios consisting of 30+ tickers.

In particular, for some of my strategies, it must wait to carry out any strategy logic until all ticker closing prices for a particular day have arrived. This means the receipt of N MarketEvent objects.

Rather than sending each individual ticker in a separate market event it might be better to instead create a DailyMarketEvent object (or similar) that provides bar information for all interested tickers in one go, thus reducing the need for boilerplate code living within the strategy class itself that keeps track of prices.

Let me know what you think of this and I'll code up a test to see how it works in practice.

@ryankennedyio
Copy link
Contributor

I think the computational complexity is equivalent either way (i.e. same amount of 'work' must be done), it's just a question of whether the logic should be in the strategy or the event loop.

One thing I know that would help us out with the event loop speed is ensuring that update_portfolio() and statistics.update() only get called at the next timestep, rather than at every new bar.

I think there might be an opportunity to do two birds with one stone there.

@femtotrader
Copy link
Contributor

@enriqueromualdez
Copy link

enriqueromualdez commented Aug 7, 2017

Hey all,

Attempting to figure this out now. I am a bit lost on the best approach as so far, what I've come up with might not exactly be the most efficient way of doing things. Is it possible to combineBarEvents into a single BarEvent? Maybe as a list which contains BarEvents that share the same timestamp that can then be iterated over by _run_sessions()?

The problem I see with this approach is of course the fact that _run_sessions() will prioritize whichever Ticker comes up first from the BarEvent list. In order to avoid the Tickers obtaining any priority, wouldn't it make sense to use some multi-threading in order to run calculate_signals() on all Tickers simultaneously?

Thoughts? Ideas?

This was referenced Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants