File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
src/quant_research_starter Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -190,15 +190,21 @@ def run_with_progress(self, weight_scheme="rank"):
190190 )
191191 returns .append (ret )
192192
193- results = pd .DataFrame ({"returns" : returns }, index = idx [1 :])
194- results ["portfolio_value" ] = (
195- self .initial_capital * (1 + results ["returns" ]).cumprod ()
193+ results_df = pd .DataFrame ({"returns" : returns }, index = idx [1 :])
194+ results_df ["portfolio_value" ] = (
195+ self .initial_capital * (1 + results_df ["returns" ]).cumprod ()
196196 )
197- results ["final_value" ] = results ["portfolio_value" ].iloc [- 1 ]
198- results ["total_return" ] = results ["final_value" ] / self .initial_capital - 1
199-
200- return results
201-
197+ final_value = results_df ["portfolio_value" ].iloc [- 1 ]
198+ total_return = final_value / self .initial_capital - 1
199+
200+ # Return a dictionary matching the original structure
201+ return {
202+ "returns" : results_df ["returns" ],
203+ "portfolio_value" : results_df ["portfolio_value" ],
204+ "final_value" : final_value ,
205+ "total_return" : total_return ,
206+ # Add other keys as needed to match the original structure
207+ }
202208 VectorizedBacktest .run = run_with_progress
203209
204210 backtest = VectorizedBacktest (
You can’t perform that action at this time.
0 commit comments