qb = QuantBook()
eurusd = qb.AddForex("EURUSD")

startTime = datetime(2020,2,5,17,40)
history = qb.History(eurusd.Symbol,
                     startTime - timedelta(minutes = 120),
                     startTime + timedelta(minutes = 20),
                     Resolution.Minute)

history.set_index(np.array([i for i in range (-120, 20)]), inplace = True)

print(history.shape[0])
history

output: a normal dataframe from -120 to 19 with size 140 with no strange values

159665_1634894853.jpg

Hello,

I have troubles regarding the indicators in research notebooks.

I am researching on EUR/USD data by generating random timepoints and looking at data 120mn before that timepoint (known data to use for prediction) and 20mn after that timepoint (data to predict).

However, I sometime run across trouble where I have good quality historical data for a timeframe (AKA no NaN, no missing values and so on). The example above illustrate this.

But when I fetch the sma indicator, and try to apply it to the 20mn after my timepoint (to evaluate the future trend), there are discrepencies in my row number output. I have to start initiating the indicator before my start point so it can warm up, however sometimes it results in this:

for i in range (20):

    smaDf = qb.Indicator(SimpleMovingAverage(5),
                                eurusd.Symbol, 
                                startTime - timedelta(minutes = i),   
                                startTime + timedelta(minutes = 20),
                                Resolution.Minute)
                                
    print(str(i) + "\t" + str(smaDf.shape[0]))

output: the dataframe size does not increment for a while, then catch up

159665_1634895575.jpg

If someone has any advices or explainations, I'd be glad to read them.  

Note that the startpoint I used was randomly found in my work, but it happens in all years, months and daytimes whith consistent historical data.

Author