@support Thanks for the detailed answer, that seems to be it, here is the final code:

import xarray as xr import qnt.stats as qns import qnt.output as qnout import qnt.data as qndata # single-stock trading data = qndata.futures.load_data(min_date="2005-01-01", assets=["F_ES"]) # attempting an optimal (unrealistic) long-only strategy # by looking at future prices, and investing only if there will be profit next_price_open = data.sel(field="open").shift(time=-1) next2_price_open = data.sel(field="open").shift(time=-2) weights = xr.where(next_price_open < next2_price_open, 1.0, 0.0) # sell short when optimal: # weights = xr.where(next_price_open > next2_price_open, -1.0, weights) weights = qnout.clean(weights, data) qnout.check(weights, data) qnout.write(weights) stats = qns.calc_stat( data, weights, # ignoring slippage for simplicity slippage_factor=0, roll_slippage_factor=0) stats.loc[:, "equity"].plot.step();