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,
|
entry_date DateTime,
|
||||||
shares UInt32,
|
shares UInt32,
|
||||||
entry_price Float64,
|
entry_price Float64,
|
||||||
target_price Float64,
|
target_price Nullable(Float64),
|
||||||
stop_loss Float64,
|
stop_loss Nullable(Float64),
|
||||||
strategy String,
|
strategy Nullable(String),
|
||||||
order_type String,
|
order_type String,
|
||||||
|
direction String,
|
||||||
followed_rules Nullable(UInt8),
|
followed_rules Nullable(UInt8),
|
||||||
entry_reason Nullable(String),
|
entry_reason Nullable(String),
|
||||||
exit_price Nullable(Float64),
|
exit_price Nullable(Float64),
|
||||||
@ -335,7 +336,7 @@ def add_trade(trade: TradeEntry):
|
|||||||
query = f"""
|
query = f"""
|
||||||
INSERT INTO stock_db.trades (
|
INSERT INTO stock_db.trades (
|
||||||
id, position_id, ticker, entry_date, shares, entry_price, target_price, stop_loss,
|
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
|
exit_reason, notes
|
||||||
) VALUES (
|
) VALUES (
|
||||||
{generate_id()},
|
{generate_id()},
|
||||||
@ -344,10 +345,11 @@ def add_trade(trade: TradeEntry):
|
|||||||
'{trade.entry_date.strftime('%Y-%m-%d %H:%M:%S')}',
|
'{trade.entry_date.strftime('%Y-%m-%d %H:%M:%S')}',
|
||||||
{trade.shares},
|
{trade.shares},
|
||||||
{trade.entry_price},
|
{trade.entry_price},
|
||||||
{trade.target_price},
|
{trade.target_price if trade.target_price else 'NULL'},
|
||||||
{trade.stop_loss},
|
{trade.stop_loss if trade.stop_loss else 'NULL'},
|
||||||
'{trade.strategy}',
|
{f"'{trade.strategy}'" if trade.strategy else 'NULL'},
|
||||||
'{trade.order_type}',
|
'{trade.order_type}',
|
||||||
|
'{trade.direction}',
|
||||||
{1 if trade.followed_rules else 0},
|
{1 if trade.followed_rules else 0},
|
||||||
{f"'{trade.entry_reason}'" if trade.entry_reason else 'NULL'},
|
{f"'{trade.entry_reason}'" if trade.entry_reason else 'NULL'},
|
||||||
{trade.exit_price if trade.exit_price else 'NULL'},
|
{trade.exit_price if trade.exit_price else 'NULL'},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user