Hi
I have been trying to write a simple example with both single pass and multi pass just to understand them better. But I can't get them to produce the same result. Here is what I use:
single pass version:
import xarray as xr
import qnt.ta as qnta
import qnt.data as qndata
data = qndata.futures_load_data(min_date='2006-01-01', max_date='2007-01-01', assets= ['F_ES'])
close = data.sel(field='close')
close_one_day_ago = qnta.shift(close, periods=1)
_open = data.sel(field='open')
open_one_day_ago = qnta.shift(_open, periods=1)
weights = xr.where(open_one_day_ago < close_one_day_ago, 1, 0)
The result looks like the following.
multi pass version:
import xarray as xr
import qnt.ta as qnta
import qnt.backtester as qnbt
import qnt.data as qndata
def load_data(period):
return qndata.futures_load_data(tail=period, assets=['F_ES'])
def strategy(data):
close = data.sel(field='close')
close_one_day_ago = qnta.shift(close, periods=1)
_open = data.sel(field='open')
open_one_day_ago = qnta.shift(_open, periods=1)
weights = xr.where(open_one_day_ago < close_one_day_ago, 1, 0)
return weights
weights = qnbt.backtest(
competition_type= 'futures',
load_data= load_data,
lookback_period= 365,
start_date= '2006-01-01',
end_date= '2007-01-01',
strategy= strategy
)
The result look like the following.
Any help/hint/suggestion is greatly appreciated.