feat: Add shares field to watchlist items and update prefill functionality
This commit is contained in:
parent
73b51c7ba6
commit
d0b8e294db
@ -202,7 +202,8 @@ def trading_system_page():
|
||||
'ticker': ticker,
|
||||
'entry_price': float(entry_price),
|
||||
'target_price': float(target_price),
|
||||
'stop_loss': float(position['stop_loss'])
|
||||
'stop_loss': float(position['stop_loss']),
|
||||
'shares': recommended_shares
|
||||
}
|
||||
st.success("Details saved! Switch to Watch Lists tab to complete adding to your watch list.")
|
||||
|
||||
@ -247,6 +248,10 @@ def trading_system_page():
|
||||
value=float(prefill.get('entry_price', 0.0)),
|
||||
min_value=0.0,
|
||||
step=0.01)
|
||||
shares = st.number_input("Shares",
|
||||
value=int(prefill.get('shares', 0)),
|
||||
min_value=0,
|
||||
step=1)
|
||||
with col2:
|
||||
target_price = st.number_input("Target Price",
|
||||
value=float(prefill.get('target_price', 0.0)),
|
||||
@ -267,6 +272,7 @@ def trading_system_page():
|
||||
entry_price=entry_price,
|
||||
target_price=target_price,
|
||||
stop_loss=stop_loss,
|
||||
shares=shares,
|
||||
notes=notes
|
||||
)
|
||||
|
||||
@ -302,7 +308,7 @@ def trading_system_page():
|
||||
if items:
|
||||
for item in items:
|
||||
with st.container():
|
||||
col1, col2, col3, col4, col5 = st.columns([2, 2, 2, 2, 1])
|
||||
col1, col2, col3, col4, col5, col6 = st.columns([2, 2, 2, 2, 1, 1])
|
||||
with col1:
|
||||
st.write(f"**{item.ticker}**")
|
||||
with col2:
|
||||
@ -312,6 +318,8 @@ def trading_system_page():
|
||||
with col4:
|
||||
st.write(f"Stop: ${item.stop_loss:.2f}")
|
||||
with col5:
|
||||
st.write(f"Shares: {item.shares:,}")
|
||||
with col6:
|
||||
if st.button("Remove", key=f"remove_{item.id}"):
|
||||
if remove_from_watchlist(item.id):
|
||||
st.rerun()
|
||||
|
||||
@ -32,6 +32,7 @@ def ensure_tables_exist():
|
||||
entry_price Float64,
|
||||
target_price Float64,
|
||||
stop_loss Float64,
|
||||
shares Int32,
|
||||
notes String,
|
||||
created_at DateTime
|
||||
)
|
||||
@ -45,6 +46,7 @@ class WatchlistItem:
|
||||
entry_price: float
|
||||
target_price: float
|
||||
stop_loss: float
|
||||
shares: Optional[int] = None
|
||||
notes: Optional[str] = None
|
||||
watchlist_id: Optional[int] = None
|
||||
id: Optional[int] = None
|
||||
@ -81,6 +83,7 @@ def add_to_watchlist(watchlist_id: int, item: WatchlistItem) -> bool:
|
||||
item.entry_price,
|
||||
item.target_price,
|
||||
item.stop_loss,
|
||||
item.shares or 0,
|
||||
item.notes or '',
|
||||
datetime.now()
|
||||
)]
|
||||
@ -90,7 +93,7 @@ def add_to_watchlist(watchlist_id: int, item: WatchlistItem) -> bool:
|
||||
data,
|
||||
column_names=[
|
||||
'id', 'watchlist_id', 'ticker', 'entry_price',
|
||||
'target_price', 'stop_loss', 'notes', 'created_at'
|
||||
'target_price', 'stop_loss', 'shares', 'notes', 'created_at'
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user