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

Is there some ways to add and drop data dynamicly?

  • Hi everyone:
    I backtest and trade futures ,because I want to backtest the real future contracts,so,now,I have to add more than 5000+ data,it lows the speed.
    can I develop a function to add data just when the future contract have real data and begin to trade?
    can I develop a function to drop data after the future contract having no data and expired?
    Is there anynone having any idea?
    Than you very much!

    in this picture,I let the relathionship of some key classes in backtrader becoming more obvious.
    in order to speed up,add the need data and drop unnecessary data,maybe a good way!

  • you can have a look at or and implements your own datafeeds, it's very simple, especially for backtest, i think it's no more than load data in _load()

    but if you want live trading, you have to deal with disconnection and reconnection and backfill the data properly

    besides, 5000+ is not big, I am backtesting with more than 900k datas around 2min

Log in to reply