Getting Bid/Ask along with ohlc in next()



  • Hi All,
    As per the backtrader framework out strategies order would be triggered from strategies next call which gets called as my be set up based on timeframe/compression and resampling/replaying.

    While this is okay for backtesting for real life orders I am trying to get top bid and ask price as well into the next(), however it would not be a line. These would be two standalone float keeping the latest values.

    This should happen irrespective of --rtbar enabled or not which means real time data should always be subscribed and it will keep on updating bid and ask as received and whenever next is called we need to be able to reference these variables in next.

    uses: to be used to decide the limit prices for orders. Also would be would be used to see if market is trading in extreme conditions (when the spread of bid ask increases drastically compared).

    I am looking to implement this from IB perspective.

    Could you please help what would be optimal way to do this with pointers as to which class should own these variables and how to make it available in next.

    Thanks in advance.



  • could anyone point me if store can be assessed from strategies next() call.


  • administrators

    It was not meant so, but there are 2 options:

    1 Generic

    • You pass the created store as an argument to your strategy

    2 IBData specific

    • It has an attribute named ib which is the *store. You can then do: self.data0.ib.xxxxx for example

Log in to reply
 

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