I tried to implement backtest in research notebook. After couple hours work, I still have difficulty to pass variable between two functions.
I am wondering whether anyone has better way to deal with it.
Thanks.
I tried to implement backtest in research notebook. After couple hours work, I still have difficulty to pass variable between two functions.
I am wondering whether anyone has better way to deal with it.
Thanks.
I have a research notebook where I ran into the same problem.
I cloned it from the one that sweeps multiple parameters,,,
I solved that part by just using data instead of transposing it...
Like so...
# this runs a backtest unique to the values in 'param_1' and 'param_2'
algo_obj = TradingAlgorithm(initialize=initialize, handle_data=handle_data,
data_frequency='daily',capital_base=45000,instant_fill=True)
# compute the performance stats for this backtest run and then append to a dataframe
# that is accumulating all of the backtest performance stats
perf_algo = algo_obj.run(data)
#perf_algo = algo_obj.run(data.transpose(2,1,0))
perf_returns = perf_algo.returns
perf_stats_df = perf_stats( perf_returns ).T
If this doesn't work for you, I can share my notebook.
I was trying to find the effect of changing the start date on an algo, so it sweeps starting date params.
That does work, but I'd have to clean it up.
alan