Add and Remove Feeds on the Fly



  • Is it possible to add and remove feeds once the strategy has started executing (e.g. because you are tracking an index and equities get added / removed over time)?

    Thank you for the help!



  • To elaborate a bit more on my strategy, I was planning to create a custom 'live' feed to represent the index. That would get Cerebro started and running.

    On the first go I would add all the original components of the index as individual feeds with their own indicators and signals.

    Then as time advances with repeated calls to start() I would check the index composition to add or remove equities (and their indicators and signals).

    Does it make sense? Is there a better way?


  • administrators

    Adding and removing feeds is not a supported scenario.

    But nothing prevents a feed from switching to delivering data from a different underlying source. The challenge being: the indicators wouldn't be in sync due to the expected gap in prices.

    A probably non-realistic approach would be to have all potential components of the index running from the start, with indicators running on all of them.

    Non-realistic if the universe of potential components of the index is 5000 and the index has 30 assets.

    With different numbers it might be doable



  • Thanks for the reply. I imagine that for backtesting purposes we can circumvent that because, looking backwards, index composition is deterministic. I have seen that adding feeds with different start and end dates is properly sequenced by Cerebro. An extra parameter feed (e.g. "sp50" "0" or "1") would validate whether the equity is in the index or not, and leveraging both prenext() and next() would allow me to start backtesting even though not all feeds have started (being careful to check 0-length lines to avoid exceptions). That would do.



  • The total number of feeds would be around 1500... a matter of metal and memory I guess. Thanks for developing this awesome piece of software! :)


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.