Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    General Code/Help
    2
    2
    1679
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      scottz1 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        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

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors