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

Using database as datafeed



  • I'm new to Backtrader and would like to store a few years of daily data for 7000 stocks locally in a database and then test strategies across all stocks. So about 400 MB. Preliminary research suggest these options:

    1. Marketstore: (see https://community.backtrader.com/topic/1120/marketstore-new-data-feed-complete-code-example) Advantage: MS is open source, designed for time series. I'm not sure if the sample is complete because the thread sort of dropped off.
    2. The BT built-in datafeed for InfluxData (also a timeseries db). InfluxData offers the "TickStack" Edition for free. Has anyone tried it with Backtrader?
    3. SQLite. Advantage: open source and I'm familiar. Has anyone tried using either PandasData or AbstractDataBase datafeeds as a wrapper around a relational database?

    Any tips would be very welcome.


  • administrators

    The InfluxData was a contribution by one of the users.

    Wrapping a relational database (or for the sake of it, wrapping anything), simply requires:

    • That you override AbstractDatabase
    • That you translate the parameters to the data feed to a query (during __init__ or start), which may include the name of the file holding the db (for sqlite for example), and the starting and ending dates. If you were using arctic it could also use things like timeframe and compression to select specific stores
    • That you fill the lines (usually open, high, low, volume and maybe openinterest) during _load

    See: Docs - Binary Data Feed Development


Log in to reply
 

});