Update trade report following changes made to backtest and trade tables
This commit is contained in:
parent
3aed5afc94
commit
e64357bcd4
@ -1,14 +1,21 @@
|
|||||||
from database.backtest import backtest_results
|
from database.backtest import backtest_results
|
||||||
from database.procedures import backtest_profit, most_recent_trade_date
|
from database.procedures import backtest_profit, most_recent_trade_date
|
||||||
from database.trades import trades
|
from database.trades import trades
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
symbol = 'SPX'
|
||||||
|
strategy = '10 Delta Iron Condor'
|
||||||
|
|
||||||
trade_date = most_recent_trade_date()
|
trade_date = most_recent_trade_date()
|
||||||
print(f'Trade Date: {trade_date}')
|
print(f'Trade Date: {trade_date}')
|
||||||
|
|
||||||
trade_data = trades(trade_date)
|
trade_data = trades(trade_date)
|
||||||
|
|
||||||
|
traded_entry_times = set()
|
||||||
for _, trade in trade_data.iterrows():
|
for _, trade in trade_data.iterrows():
|
||||||
print(f'Entry Time: {trade["Strategy"][-8:]}')
|
entry_time = str(trade["Entry Time"])[-8:]
|
||||||
|
print(f'Entry Time: {entry_time}')
|
||||||
|
traded_entry_times.add(entry_time)
|
||||||
|
|
||||||
spreads = trade['Spreads']
|
spreads = trade['Spreads']
|
||||||
for spread in spreads:
|
for spread in spreads:
|
||||||
@ -23,24 +30,23 @@ for _, trade in trade_data.iterrows():
|
|||||||
print(f' Long Strike: {long_leg["Strike"]}, Type: {long_leg["Type"]}')
|
print(f' Long Strike: {long_leg["Strike"]}, Type: {long_leg["Type"]}')
|
||||||
print(f' Opening Price: {open_price}')
|
print(f' Opening Price: {open_price}')
|
||||||
|
|
||||||
traded_strategies = set(trade["Strategy"] for _, trade in trade_data.iterrows())
|
backtest_data = backtest_results(symbol, strategy, trade_date)
|
||||||
|
|
||||||
backtest_data = backtest_results(date = trade_date)
|
|
||||||
|
|
||||||
for _, backtest in backtest_data.iterrows():
|
for _, backtest in backtest_data.iterrows():
|
||||||
if backtest["Strategy"] in traded_strategies:
|
entry_time = str(backtest["Entry Time"])[-8:]
|
||||||
print(f'Backtest Entry Time: {backtest["Strategy"][-8:]}')
|
if entry_time in traded_entry_times:
|
||||||
|
print(f'Backtest Entry Time: {entry_time}')
|
||||||
|
|
||||||
spreads = backtest['Spreads']
|
spreads = backtest['Spreads']
|
||||||
for spread in spreads:
|
for spread in spreads:
|
||||||
legs = spread['legs']
|
legs = spread['Legs']
|
||||||
open_price = spread['open']
|
open_price = spread['Open']
|
||||||
|
|
||||||
short_leg = legs[0]
|
short_leg = legs[0]
|
||||||
long_leg = legs[1]
|
long_leg = legs[1]
|
||||||
|
|
||||||
print(f' Backtest Short Strike: {short_leg["strike"]}, Type: {short_leg["type"]}')
|
print(f' Backtest Short Strike: {short_leg["Strike"]}, Type: {short_leg["Type"]}')
|
||||||
print(f' Backtest Long Strike: {long_leg["strike"]}, Type: {long_leg["type"]}')
|
print(f' Backtest Long Strike: {long_leg["Strike"]}, Type: {long_leg["Type"]}')
|
||||||
print(f' Backtest Opening Price: {open_price}')
|
print(f' Backtest Opening Price: {open_price}')
|
||||||
|
|
||||||
print(f'Backtest Profit: {backtest_profit(trade_date)}')
|
print(f'Backtest Profit: {backtest_profit(datetime.combine(trade_date, datetime.min.time()))}')
|
Loading…
Reference in New Issue
Block a user