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

Is backtrader possible to backtest for HFT?



  • Newbie here, and fortunately found backtrader. My question is whether backtrader can be used directly in HFT or need to be edit to suit the HFT?


  • administrators

    HFT is just a name which says you want to trade fast. Backtesting doesn't imply speed but simply verification.

    You are probably referring to something like bid/ask backtesting and although some workarounds have been put in place by people, there is no direct support for it.

    If you mean something else, you may want to elaborate on exactly what.



  • Thank you for reply! I notice that there have been some discussion on the "Escape from OHLC Land", and we can build our own class that store the data we want. But when building strategy using buy, the error

    'Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst' object has no attribute 'close'

    shows up, and I notice that buy(data=None, size=None, price=None, plimit=None, exectype=None, valid=None, tradeid=0, oco=None, trailamount=None, trailpercent=None, parent=None, transmit=True, **kwargs), but when I set buy(price = self.data.BP1[0]), where BP1 is the data I specified in my own data feed, it also gives me the same error. So how to deal with such problem?


  • administrators

    The broker needs a data feed with the standard OHLC componets for the price matching logic. Your data feed obviously doesn't have a close