Benjamin Consolvo commited on
Commit
0f500af
·
1 Parent(s): e77df83

show number of shares in table

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -585,9 +585,16 @@ def main():
585
  with st.expander("View Detailed Holdings"):
586
  holdings = app.alpaca.getHoldings() # Use self.alpaca instead of app.alpaca
587
  if holdings:
588
- detailed_holdings = pd.DataFrame(
589
- [{"Ticker": ticker, "Amount (USD)": round(value)} for ticker, value in holdings.items()]
590
- )
 
 
 
 
 
 
 
591
  st.table(detailed_holdings)
592
  else:
593
  st.info("No holdings to display.")
 
585
  with st.expander("View Detailed Holdings"):
586
  holdings = app.alpaca.getHoldings() # Use self.alpaca instead of app.alpaca
587
  if holdings:
588
+ # Get positions to access both market value and quantity
589
+ positions = app.alpaca.alpaca.list_positions()
590
+ positions_data = []
591
+ for position in positions:
592
+ positions_data.append({
593
+ "Ticker": position.symbol,
594
+ "Shares": float(position.qty),
595
+ "Amount (USD)": round(float(position.market_value))
596
+ })
597
+ detailed_holdings = pd.DataFrame(positions_data)
598
  st.table(detailed_holdings)
599
  else:
600
  st.info("No holdings to display.")