Hello, my problem is if I add a key to the buttons, the “DuplicateWidgetID” Error disappears, but the informations doesnt refresh, like I want them too. If I do it without key, it works at least once, but when I click a button the second time, the whole site refreshes. I want only the informations to refresh, every time I click a button.
def showAdditionalInformations(symbol22):
apiURL = f'https://api.polygon.io/v1/meta/symbols/{symbol22}/company?&apiKey={apiKey}'
response = requests.get(apiURL)
additionalData = response.json()
name.header(additionalData['name'])
description.write(additionalData['description'])
country.write("County: " + additionalData['country'].upper())
industry.write("Industry: " + additionalData['industry'])
sector.write("Sector: " + additionalData['sector'])
marketcap.write("Maketcap: $" + str( additionalData['marketcap'] ))
ceo.write("CEO: " + additionalData['ceo'])
employees.write("Employees: " + str(additionalData['employees']))
corrHeader.header("Correlate with similar stocks:")
result = []
count = 0
for i in additionalData['similar']:
key = i+"_"+str(random.randint(1,9999))
a = corrButton[count].button(i, key)
result.append( a )
if result[count]:
stock_symbol.text_input("Stock Symbol", i)
showAdditionalInformations(i)
count+=1
st.write("Similar stocks: " + str(additionalData['similar']))