Add fees and commissions to trade report

This commit is contained in:
moshferatu 2024-03-17 04:56:57 -07:00
parent ebe3c700c9
commit 64e632d9a2

View File

@ -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)