File size: 1,240 Bytes
4b1c03a
 
 
a628d0e
4b1c03a
38188b4
4b1c03a
 
 
 
 
 
76ac193
38188b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import plotly.graph_objs as go
from main import CryptoCrew
import asyncio

st.title("Crypto Analyst")

crypto = st.text_input("Enter the cryptocurrency you want to analyze:")

if st.button("Analyze"):
    with st.spinner("Analyzing... This may take a few minutes."):
        crypto_crew = CryptoCrew(crypto)
        result = asyncio.run(crypto_crew.run_async())

    # Display summary
    st.subheader("Analysis Summary")
    st.write(result["summary"])

    # Visualize sentiment
    st.subheader("Sentiment Analysis")
    sentiment_data = result["sentiment"]
    sentiment_categories = list(sentiment_data.keys())
    sentiment_values = [1 if v == "Positive" else (-1 if v == "Negative" else 0) for v in sentiment_data.values()]
    colors = ['red' if v < 0 else 'green' if v > 0 else 'gray' for v in sentiment_values]

    fig = go.Figure(data=[go.Bar(
        x=sentiment_categories,
        y=sentiment_values,
        marker_color=colors
    )])

    fig.update_layout(
        title="Sentiment Analysis",
        xaxis_title="Category",
        yaxis_title="Sentiment (Negative to Positive)",
        yaxis=dict(tickvals=[-1, 0, 1], ticktext=["Negative", "Neutral", "Positive"])
    )

    st.plotly_chart(fig)