Skip to content

Commit 17a7b6d

Browse files
fix: fixed suggestions
Co-authored-by: Copilot <[email protected]>
1 parent ccf7d8f commit 17a7b6d

File tree

1 file changed

+14
-8
lines changed
  • src/quant_research_starter

1 file changed

+14
-8
lines changed

src/quant_research_starter/cli.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)