refactor: Improve portfolio display with unique keys and entry date
This commit is contained in:
parent
efe69a2dbb
commit
470cb88da6
@ -632,8 +632,9 @@ def trading_system_page():
|
|||||||
positions = st.session_state.portfolio.get_position_summary()
|
positions = st.session_state.portfolio.get_position_summary()
|
||||||
if positions:
|
if positions:
|
||||||
st.subheader("Current Positions")
|
st.subheader("Current Positions")
|
||||||
for pos in positions:
|
# Add a counter to make unique keys
|
||||||
with st.expander(f"{pos['symbol']} Position"):
|
for i, pos in enumerate(positions):
|
||||||
|
with st.expander(f"{pos['symbol']} Position - {format_datetime(pos['entry_date'])}"):
|
||||||
col1, col2 = st.columns(2)
|
col1, col2 = st.columns(2)
|
||||||
with col1:
|
with col1:
|
||||||
st.metric("Entry Price", f"${pos['entry_price']:.2f}")
|
st.metric("Entry Price", f"${pos['entry_price']:.2f}")
|
||||||
@ -645,7 +646,7 @@ def trading_system_page():
|
|||||||
st.metric("Target", f"${pos['target_price']:.2f}")
|
st.metric("Target", f"${pos['target_price']:.2f}")
|
||||||
st.metric("Risk/Reward", f"{pos['risk_reward_ratio']:.2f}")
|
st.metric("Risk/Reward", f"{pos['risk_reward_ratio']:.2f}")
|
||||||
|
|
||||||
if st.button(f"Remove {pos['symbol']}", key=f"remove_{pos['symbol']}"):
|
if st.button(f"Remove {pos['symbol']}", key=f"remove_{pos['symbol']}_{i}"):
|
||||||
st.session_state.portfolio.remove_position(pos['symbol'])
|
st.session_state.portfolio.remove_position(pos['symbol'])
|
||||||
st.experimental_rerun()
|
st.experimental_rerun()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user