feat: Add direction field to TradeEntry and update trades table schema
This commit is contained in:
parent
b9116a55a2
commit
77a067a22e
@ -262,10 +262,11 @@ def create_trades_table():
|
||||
entry_date DateTime,
|
||||
shares UInt32,
|
||||
entry_price Float64,
|
||||
target_price Float64,
|
||||
stop_loss Float64,
|
||||
strategy String,
|
||||
target_price Nullable(Float64),
|
||||
stop_loss Nullable(Float64),
|
||||
strategy Nullable(String),
|
||||
order_type String,
|
||||
direction String,
|
||||
followed_rules Nullable(UInt8),
|
||||
entry_reason Nullable(String),
|
||||
exit_price Nullable(Float64),
|
||||
@ -335,7 +336,7 @@ def add_trade(trade: TradeEntry):
|
||||
query = f"""
|
||||
INSERT INTO stock_db.trades (
|
||||
id, position_id, ticker, entry_date, shares, entry_price, target_price, stop_loss,
|
||||
strategy, order_type, followed_rules, entry_reason, exit_price, exit_date,
|
||||
strategy, order_type, direction, followed_rules, entry_reason, exit_price, exit_date,
|
||||
exit_reason, notes
|
||||
) VALUES (
|
||||
{generate_id()},
|
||||
@ -344,10 +345,11 @@ def add_trade(trade: TradeEntry):
|
||||
'{trade.entry_date.strftime('%Y-%m-%d %H:%M:%S')}',
|
||||
{trade.shares},
|
||||
{trade.entry_price},
|
||||
{trade.target_price},
|
||||
{trade.stop_loss},
|
||||
'{trade.strategy}',
|
||||
{trade.target_price if trade.target_price else 'NULL'},
|
||||
{trade.stop_loss if trade.stop_loss else 'NULL'},
|
||||
{f"'{trade.strategy}'" if trade.strategy else 'NULL'},
|
||||
'{trade.order_type}',
|
||||
'{trade.direction}',
|
||||
{1 if trade.followed_rules else 0},
|
||||
{f"'{trade.entry_reason}'" if trade.entry_reason else 'NULL'},
|
||||
{trade.exit_price if trade.exit_price else 'NULL'},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user