refactor: Replace nested expanders with cleaner trade display layout
This commit is contained in:
parent
1506deff0d
commit
84378e32f8
@ -882,29 +882,7 @@ def trading_plan_page():
|
|||||||
winning_trades = 0
|
winning_trades = 0
|
||||||
total_trades = len(plan_trades)
|
total_trades = len(plan_trades)
|
||||||
|
|
||||||
for trade in plan_trades:
|
# Display trade statistics first
|
||||||
with st.expander(f"{trade['ticker']} - {trade['entry_date']}"):
|
|
||||||
col1, col2 = st.columns(2)
|
|
||||||
with col1:
|
|
||||||
st.write(f"**Entry:** ${trade['entry_price']:.2f}")
|
|
||||||
st.write(f"**Shares:** {trade['shares']}")
|
|
||||||
st.write(f"**Direction:** {trade['direction']}")
|
|
||||||
if trade['strategy']:
|
|
||||||
st.write(f"**Strategy:** {trade['strategy']}")
|
|
||||||
|
|
||||||
with col2:
|
|
||||||
if trade['exit_price']:
|
|
||||||
pl = (trade['exit_price'] - trade['entry_price']) * trade['shares']
|
|
||||||
total_pl += pl
|
|
||||||
if pl > 0:
|
|
||||||
winning_trades += 1
|
|
||||||
st.write(f"**Exit:** ${trade['exit_price']:.2f}")
|
|
||||||
st.write(f"**P/L:** ${pl:.2f}")
|
|
||||||
st.write(f"**Exit Date:** {trade['exit_date']}")
|
|
||||||
else:
|
|
||||||
st.write("**Status:** Open")
|
|
||||||
|
|
||||||
# Display trade statistics
|
|
||||||
st.markdown("#### Trade Statistics")
|
st.markdown("#### Trade Statistics")
|
||||||
col1, col2 = st.columns(2)
|
col1, col2 = st.columns(2)
|
||||||
with col1:
|
with col1:
|
||||||
@ -917,6 +895,33 @@ def trading_plan_page():
|
|||||||
st.write(f"**Total P/L:** ${total_pl:.2f}")
|
st.write(f"**Total P/L:** ${total_pl:.2f}")
|
||||||
if total_trades > 0:
|
if total_trades > 0:
|
||||||
st.write(f"**Average P/L per Trade:** ${total_pl/total_trades:.2f}")
|
st.write(f"**Average P/L per Trade:** ${total_pl/total_trades:.2f}")
|
||||||
|
|
||||||
|
# Display trades in a table format instead of nested expanders
|
||||||
|
st.markdown("#### Individual Trades")
|
||||||
|
for trade in plan_trades:
|
||||||
|
st.markdown("---")
|
||||||
|
cols = st.columns(3)
|
||||||
|
with cols[0]:
|
||||||
|
st.write(f"**{trade['ticker']} - {trade['entry_date']}**")
|
||||||
|
st.write(f"**Direction:** {trade['direction']}")
|
||||||
|
if trade['strategy']:
|
||||||
|
st.write(f"**Strategy:** {trade['strategy']}")
|
||||||
|
|
||||||
|
with cols[1]:
|
||||||
|
st.write(f"**Entry:** ${trade['entry_price']:.2f}")
|
||||||
|
st.write(f"**Shares:** {trade['shares']}")
|
||||||
|
|
||||||
|
with cols[2]:
|
||||||
|
if trade['exit_price']:
|
||||||
|
pl = (trade['exit_price'] - trade['entry_price']) * trade['shares']
|
||||||
|
total_pl += pl
|
||||||
|
if pl > 0:
|
||||||
|
winning_trades += 1
|
||||||
|
st.write(f"**Exit:** ${trade['exit_price']:.2f}")
|
||||||
|
st.write(f"**P/L:** ${pl:.2f}")
|
||||||
|
st.write(f"**Exit Date:** {trade['exit_date']}")
|
||||||
|
else:
|
||||||
|
st.write("**Status:** Open")
|
||||||
else:
|
else:
|
||||||
st.info("No trades linked to this plan")
|
st.info("No trades linked to this plan")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user