quantiacs-python icon indicating copy to clipboard operation
quantiacs-python copied to clipboard

Trading systems get raw OHLC data which does not incorporate adjustments for rollovers

Open rmldj opened this issue 7 years ago • 0 comments

I wanted to generate continuous future data by applying rollovers for future contracts same as quantiacs using quantiacs data myself. I wanted to check this with data generated for trading systems using quantiacsToolbox.runts(...).

To my surprise I found that the trading system gets raw data not corrected for rollovers.

Here is the code which exhibits the problem:

import numpy as np

def mySettings():
    settings = {}
    settings['markets'] = [ 'F_DL' ]
    settings['beginInSample'] = '20180410'
    settings['endInSample'] = '20180423'
    settings['lookback'] = 10
    return settings

def myTradingSystem(DATE, OPEN, HIGH, LOW, CLOSE, settings):
    print np.c_[DATE, CLOSE[:,0]]
    return np.array([1.0]), settings

if __name__ == '__main__':
    import quantiacsToolbox
    results = quantiacsToolbox.runts(__file__, plotEquity=False)

The relevant part of the output is

Loading Data...
Done! 
Evaluating Trading System
[[20180410.    28840.]
 [20180411.    28800.]
 [20180412.    28800.]
 [20180413.    28840.]
 [20180416.    28880.]
 [20180417.    29840.]
 [20180418.    29880.]
 [20180419.    29960.]
 [20180420.    29800.]
 [20180423.    30160.]]

while the relevant snippet of F_DL.txt is

20180413,28800.0000,28860.0000,28780.0000,28840.0000,91,3496,0,0,0.0000
20180416,28820.0000,28880.0000,28820.0000,28880.0000,82,3457,201805,201805,0.0000
20180417,29720.0000,30140.0000,29660.0000,29840.0000,337,3949,0,0,860.0000
20180418,29800.0000,29960.0000,29660.0000,29880.0000,247,3968,0,0,0.0000
20180419,29940.0000,30280.0000,29860.0000,29960.0000,357,3986,0,0,0.0000
20180420,29940.0000,30200.0000,29780.0000,29800.0000,277,3919,0,0,0.0000
20180423,29940.0000,30260.0000,29860.0000,30160.0000,192,3972,0,0,0.0000

As can be seen, the trading system gets just raw close data. In particular on 20180416 it gets 28880 while I believe it should have gotten 29740=28880+860.

I installed the quantiacs toolbox using pip very recently.

rmldj avatar Apr 30 '18 10:04 rmldj