From ebe3c700c91b24f9c953c8e82b63ca3742dc03bc Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sat, 9 Mar 2024 05:45:04 -0800 Subject: [PATCH] Add live trading profit and difference between live trading and backtest profits to report --- trade_report.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/trade_report.py b/trade_report.py index 566a871..9b1376f 100644 --- a/trade_report.py +++ b/trade_report.py @@ -44,7 +44,14 @@ for _, backtest in backtest_data.iterrows(): close_price = round(spread['Close'], 2) backtest_info[(entry_time, spread_type)] = (short_strike, long_strike, open_price, close_price) -print(f'**Backtest Profit**: {round(backtest_profit(trade_date), 2)}\n') +trade_profits = [100 * (info[2] - info[3]) for info in trade_info.values()] +profit = sum(trade_profits) +print(f'**Profit**: {round(profit, 2)}') + +profit_backtest = backtest_profit(trade_date) +print(f'**Backtest Profit**: {round(profit_backtest, 2)}') + +print(f'**Difference**: {round(profit - profit_backtest, 2)}\n') open_differences = [backtest_info[key][2] - trade_info[key][2] for key in trade_info] average_open_difference = sum(open_differences) / len(open_differences) if open_differences else 0