-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_components.py
53 lines (47 loc) · 1.75 KB
/
ui_components.py
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
import streamlit as st
# Function to display dropdown for selecting crypto
def select_crypto():
# Top 20 cryptocurrencies (based on market capitalization)
crypto_options = {
'Bitcoin': 'bitcoin',
'Ethereum': 'ethereum',
'Tether': 'tether',
'BNB': 'binancecoin',
'XRP': 'ripple',
'Cardano': 'cardano',
'Dogecoin': 'dogecoin',
'Polygon': 'matic-network',
'Solana': 'solana',
'Polkadot': 'polkadot',
'Litecoin': 'litecoin',
'Avalanche': 'avalanche-2',
'Chainlink': 'chainlink',
'Uniswap': 'uniswap',
'Cosmos': 'cosmos',
'Toncoin': 'toncoin',
'Stellar': 'stellar',
'Monero': 'monero',
'Ethereum Classic': 'ethereum-classic',
'Internet Computer': 'internet-computer'
}
selected_crypto = st.selectbox("Choose a Cryptocurrency:", list(crypto_options.keys()))
return crypto_options[selected_crypto]
# Function to display dropdown for selecting currency
def select_currency():
# Restricting to INR and USD
currency_options = ['usd', 'inr']
return st.selectbox("Choose a Currency:", currency_options)
# Function to display a refresh button
def refresh_button():
return st.button("Refresh Price")
# Function to show historical data graph
def display_historical_graph(prices, currency='usd'):
import pandas as pd
import matplotlib.pyplot as plt
if prices:
df = pd.DataFrame(prices, columns=['Timestamp', 'Price'])
df['Date'] = pd.to_datetime(df['Timestamp'], unit='ms')
df.set_index('Date', inplace=True)
# Plotting the graph
st.write("### Historical Price Data")
st.line_chart(df['Price'])