For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Adding data after cerebro.run()



  • Hello Backtrader Community,

    I have a strategy that I create manual entries with using a charting application and GUI. I sling entries to BackTrader via ZeroMQ which runs in a separate thread and creates the entries. Once the position is live, the BackTrader script manages the position the stop loss. It works really well using the timer function which is called every second to check or new orders received via ZeroMQ.

    I'm running on IQFeed 1 minute data and using our FIX interface we developed for our firm with BackTrader.

    The only downside is I have to add the universe of 400 symbols to my script and then break it up into 4 smaller scripts, 100 on each symbols, so that each next() event is proficient. I run the 4 scripts in parallel concurrently and it works really well, just I'm using a lot of CPU and bandwidth.

    What I'm looking for is a way to add symbols on an as-needed basis so that I can create orders on symbols that have not been added via cerebro.adddata() when the script starts. This way, I can run a single smaller script and it just adds symbols as it receives entry orders for them. At the end of session, it clears the list and starts fresh the following session. The price/volume bars are not a concern since I have a separate method that pulls in price bars outside of self.datas as a workaround.

    For example, if I add data for SPY and QQQ when the script starts and then I receive an order for EWZ, which was not added using .adddata() when the script started, it will of course throw errors for self.getpositionbyname('EWZ) if I try to create an order object on this instance.

    Can .adddata() be called during .run() ?

    Any other suggestions?


  • administrators

    @ard9000 said in Adding data after cerebro.run():

    Adding data after cerebro.run()

    Not after.

    @ard9000 said in Adding data after cerebro.run():

    Can .adddata() be called during .run() ?

    Not during.

    Any other suggestions?

    Yes.

    @ard9000 said in Adding data after cerebro.run():

    our FIX interface we developed for our firm with BackTrader.

    You are a firm, pay to get something done which fits your needs instead of being cheap.


Log in to reply
 

});