Search code examples
pythonpandasquantitative-financealgorithmic-trading

Trying to find the structure of QuantRocket's 'prices' dataframe for Moonshot


I'm trying to use QuantRocket's Moonshot backtester with a separate datasource, and I need to know what format the prices dataframe is in so I can create my own.

I tried to run a QuantRocket trial, but I'm not able to get historical prices because I don't have a paid Interactive Brokers account, so it's basically unusable.

Any insight would be greatly appreciated.


Solution

  • You can see many example DataFrames in QuantRocket's usage guide. The index is a Multiindex of Field and Date, the columns are ConIds (contract IDs):

    >>> prices.head()
    ConId              13857203   13905344   13905462   13905522   13905624   \
    Field Date
    Close 2017-01-04    11150.0     3853.0     4889.0     4321.0     2712.0
          2017-01-05    11065.0     3910.0     4927.0     4299.0     2681.0
          2017-01-06    11105.0     3918.0     4965.0     4266.0     2672.5
          2017-01-10    11210.0     3886.0     4965.0     4227.0     2640.0
          2017-01-11    11115.0     3860.0     4970.0     4208.0     2652.0
    ...
    Volume 2018-01-29   685800.0  2996700.0  1000600.0  1339000.0  6499600.0
           2018-01-30   641700.0  2686100.0  1421900.0  1709900.0  7039800.0
           2018-01-31   603400.0  3179000.0  1517100.0  1471000.0  5855500.0
           2018-02-01   447300.0  3300900.0  1295800.0  1329600.0  5540600.0
           2018-02-02   510200.0  4739800.0  2060500.0  1145200.0  5585300.0