From 64e632d9a203f81dbd1ada41492fea5aa1c1c69d Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sun, 17 Mar 2024 04:56:57 -0700 Subject: [PATCH] Add fees and commissions to trade report --- trade_report.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/trade_report.py b/trade_report.py index 9b1376f..75eae52 100644 --- a/trade_report.py +++ b/trade_report.py @@ -3,6 +3,7 @@ from database.procedures import backtest_profit, most_recent_trade_date from database.trades import trades symbol = 'SPX' +fees_and_commissions = 3.19 # IBKR fees and commissions for a single spread trade. trade_date = most_recent_trade_date() print(f'# {trade_date.strftime("%B %d, %Y")}\n') @@ -44,8 +45,9 @@ 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) -trade_profits = [100 * (info[2] - info[3]) for info in trade_info.values()] -profit = sum(trade_profits) +trade_profits = [100 * (info[2] - info[3]) - fees_and_commissions for info in trade_info.values()] +stopped_out_spreads = sum(1 for info in trade_info.values() if info[5] is not None) +profit = sum(trade_profits) - (stopped_out_spreads * fees_and_commissions) print(f'**Profit**: {round(profit, 2)}') profit_backtest = backtest_profit(trade_date)