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:
- 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.
- The BT built-in datafeed for InfluxData (also a timeseries db). InfluxData offers the "TickStack" Edition for free. Has anyone tried it with Backtrader?
- 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.
-
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__
orstart
), which may include the name of the file holding the db (forsqlite
for example), and the starting and ending dates. If you were usingarctic
it could also use things liketimeframe
andcompression
to select specific stores - That you fill the
lines
(usuallyopen
,high
,low
,volume
and maybeopeninterest
) during_load
- That you override