forked from iamjigyanshu/FinLit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
64 lines (54 loc) · 1.86 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
import yfinance as yf
import plotly.graph_objects as go
st.title('FinLit 🔥')
DATE_COLUMN = 'date/time'
DATA_URL = ('https://s3-us-west-2.amazonaws.com/'
'streamlit-demo-data/uber-raw-data-sep14.csv.gz')
# @st.cache
# def load_data(nrows):
# data = pd.read_csv(DATA_URL, nrows=nrows)
# lowercase = lambda x: str(x).lower()
# data.rename(lowercase, axis='columns', inplace=True)
# data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
# return data
stock_tickers = pd.read_csv('s&p500.csv')
MMM = yf.Ticker(stock_tickers['Symbol'][0])
df = MMM.history(period = 'max')
df.reset_index(inplace=True)
data_load_state = st.text('Loading data...')
#data = load_data(10000)
data_load_state.text("Done!")
# if st.checkbox('Show raw data'):
# st.subheader('Raw data')
# st.write(data)
fig = go.Figure([go.Scatter(x=df['Date'], y=df['High'])])
fig.update_xaxes(
rangeslider_visible=True,
rangeselector=dict(
buttons=list([
dict(count=1, label="1m", step="month",
stepmode="backward"),
dict(count=6, label="6m", step="month",
stepmode="backward"),
dict(count=1, label="YTD", step="year",
stepmode="todate"),
dict(count=1, label="1y", step="year",
stepmode="backward"),
dict(step="all")
])
)
)
st.plotly_chart(fig, use_container_width=True)
# st.subheader('Number of pickups by hour')
# hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0,24))[0]
# st.bar_chart()
# Some number in the range 0-23
# hour_to_filter = st.slider('hour', 0, 23, 17)
# filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
#
# st.subheader('Map of all pickups at %s:00' % hour_to_filter)
# st.map(filtered_data)