File size: 2,052 Bytes
415516b
 
 
 
 
fcf5fa3
415516b
fcf5fa3
bd2ad8f
fcf5fa3
bd2ad8f
fcf5fa3
c8c6b46
fcf5fa3
 
bd2ad8f
fcf5fa3
 
b5fc454
fcf5fa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bd2ad8f
fcf5fa3
 
 
 
 
 
 
 
 
 
 
bd2ad8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import streamlit as st
from aggregator import get_articles_sentiment

st.title("Real time financial news fast sentiment")

st.subheader("Using finTinyBert")

with st.form("my_form"):

    ticker = st.text_input("Insert the company ticker")

    submitted = st.form_submit_button("Submit")
    
    col1, col2 = st.columns(2)
    if submitted:
    
        st.write("You chose", ticker)
    
        with st.spinner("Waiting for APIs"):
            results = get_articles_sentiment(ticker, "Andreagus/fin_tinyBert_32")
        
        with col1:
            st.text("Benzinga news provider")
            if results['bezinga']['bezinga_articles'] == 0:
                st.text('Benzinga returned 0 articles')
            else:
                st.json(results['benzinga'], 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("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'])