fix: Handle missing trade direction by inferring from exit price
This commit is contained in:
parent
731b4e9e2d
commit
6d29558752
@ -465,7 +465,13 @@ def trading_journal_page():
|
|||||||
# Show buy trades
|
# Show buy trades
|
||||||
st.subheader("Buy Orders")
|
st.subheader("Buy Orders")
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
if trade.get('direction', '').lower() == 'buy': # Check direction field instead of order_type
|
# Infer direction if not set
|
||||||
|
if 'direction' not in trade or not trade['direction']:
|
||||||
|
is_buy = trade.get('exit_price') is None
|
||||||
|
else:
|
||||||
|
is_buy = trade.get('direction', '').lower() == 'buy'
|
||||||
|
|
||||||
|
if is_buy:
|
||||||
col1, col2, col3 = st.columns(3)
|
col1, col2, col3 = st.columns(3)
|
||||||
with col1:
|
with col1:
|
||||||
st.text(f"Date: {format_datetime(trade['entry_date'])}")
|
st.text(f"Date: {format_datetime(trade['entry_date'])}")
|
||||||
@ -485,7 +491,13 @@ def trading_journal_page():
|
|||||||
# Show sell trades
|
# Show sell trades
|
||||||
st.subheader("Sell Orders")
|
st.subheader("Sell Orders")
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
if trade.get('direction', '').lower() == 'sell': # Check direction field instead of order_type
|
# Infer direction if not set
|
||||||
|
if 'direction' not in trade or not trade['direction']:
|
||||||
|
is_sell = trade.get('exit_price') is not None
|
||||||
|
else:
|
||||||
|
is_sell = trade.get('direction', '').lower() == 'sell'
|
||||||
|
|
||||||
|
if is_sell:
|
||||||
col1, col2 = st.columns(2)
|
col1, col2 = st.columns(2)
|
||||||
with col1:
|
with col1:
|
||||||
st.text(f"Date: {format_datetime(trade['entry_date'])}")
|
st.text(f"Date: {format_datetime(trade['entry_date'])}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user