The New Version of Quantiacs is now Live!

import xarray as xrimport qnt.ta as qnta
import qnt.backtester as qnbt
import qnt.data as qndata
import qnt.output as qnout
def load_data(period):
return qndata.futures_load_data(
assets = ['F_AD','F_BO','F_BP','F_C'],
tail = period)
def strategy(data):
close = data.sel(field='close')
sma_long = qnta.sma(close, 200).isel(time=-1)
sma_short = qnta.sma(close, 10).isel(time=-1)
return xr.where(sma_short > sma_long, 1, -1)
weights = qnbt.backtest(
competition_type = "futures",
load_data = load_data,
lookback_period = 365,
test_period = 16 * 365,
strategy = strategy)
qnout.write(weights)
import xarray as xrimport qnt.ta as qnta
import qnt.data as qndata
import qnt.output as qnout
data = qndata.futures_load_data(
assets = ['F_AD','F_BO','F_BP','F_C'],
tail = 16 * 365)
close = data.sel(field='close')
sma_long = qnta.sma(close, 200)
sma_short = qnta.sma(close, 20)
weights = xr.where(sma_short > sma_long, 1, -1)
weights = qnout.clean(weights, data)
qnout.check(weights, data)qnout.write(weights)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store