import streamlit as st from aggregator import get_articles_sentiment st.title("Real time financial news fast sentiment") model_to_use = "" model_selected = st.radio("Choose your model", ["fin_distilBert", "fin_tinyBert", "fin_miniLM"]) ticker = st.text_input("Insert the company ticker") col1, col2 = st.columns(2) if model_selected != None and ticker: st.write("You chose", model_selected) if model_selected == "fin_distilBert": model_to_use = "Andreagus/fin_distilbert_16" if model_selected == "fin_tinyBert": model_to_use = "Andreagus/fin_tinyBert_32" if model_selected == "fin_miniLM12": model_to_use = "Andreagus/fin_miniLM_16" with st.spinner("Loading the model"): results = get_articles_sentiment(ticker, model_to_use) with col1: st.text("Bezinga news provider") if results['bezinga']['bezinga_articles'] == 0: st.text('Bezinga returned 0 articles') else: st.json(results['bezinga'], expanded=False) st.text("finhub news provider") if results['finhub']['finhub_articles'] == 0: st.text('finhub returned 0 articles') else: st.json(results['finhub'], expanded=False) st.text("marketaux news provider") if results['marketaux']['marketaux_articles'] == 0: st.text('marketaux returned 0 articles') else: st.json(results['marketaux'], expanded=False) st.text("Newsapi news provider") if results['newsapi']['newsapi_articles'] == 0: st.text('newsapi returned 0 articles') else: st.json(results['newsapi'], expanded=False) st.text('Newsdata news provider') if results['newsdata']['newsdata_articles'] == 0: st.text('newsdata returned 0 articles') else: st.json(results['newsdata'], expanded=False) st.text("Vantage news provider") if results['vantage']['vantage_articles'] == 0: st.text('vantage returned 0 articles') else: st.json(results['vantage'], expanded=False) with col2: st.text("Summary results") st.metric("Total articles", results['total_articles']) st.metric("Total positive articles", results['total_positives']) st.metric("Total negative articles", results['total_negatives'])