Add live trading profit and difference between live trading and backtest profits to report

This commit is contained in:
moshferatu 2024-03-09 05:45:04 -08:00
parent 6f8aaa0c74
commit ebe3c700c9

View File

@ -44,7 +44,14 @@ for _, backtest in backtest_data.iterrows():
close_price = round(spread['Close'], 2) close_price = round(spread['Close'], 2)
backtest_info[(entry_time, spread_type)] = (short_strike, long_strike, open_price, close_price) 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] 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 average_open_difference = sum(open_differences) / len(open_differences) if open_differences else 0