Summary
Background: I have 2 sets of columns wherein i am pulling stock data continuously. The columns are meant for different category of stocks.
Problem statement: Since i need to run a while loop, once the 1st loop is over for both columns, the next loops starts to append the stock price below the existing value whereas i expect it to replace the existing value rather than append.
Steps to reproduce
Code snippet:
import streamlit as st
import yfinance as yf
st.set_page_config(page_title="Test", layout='wide')
tech_list1 = ['BTC-USD']
etf_list1 = ['ETH-USD']
with tech_ticker:
for index, val in enumerate(tech_list1):
st.write(val)
with etf_ticker:
for index, val in enumerate(etf_list1):
st.write(val)
while True:
with tech_price:
numbers = st.empty()
with numbers.container():
for index, val_stock in enumerate(tech_list1):
stock_ticker = yf.Ticker(val_stock)
stock_price = stock_ticker.info['regularMarketPrice']
st.write(": ", stock_price)
with etf_price:
numbers = st.empty()
with numbers.container():
for index, val_etf in enumerate(etf_list1):
stock_etf_ticker = yf.Ticker(val_etf)
stock_etf_price = stock_etf_ticker.info['regularMarketPrice']
st.write(": ", stock_etf_price)
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
I expect the output to show the current_stock price in front of it’s respective name where after running 1 loop, the stock price starts to append below the existing price.
Actual behavior:
after running 1 loop, the stock price starts to append below the existing price.
Debug info
- Streamlit version: (1.11.1)
- Python version: (3.8`)
- Using Conda? NO
- OS version: Windows 10
- Browser version: Microsoft Edge