netflypsb commited on
Commit
40973df
·
verified ·
1 Parent(s): cb0b64a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yfinance as yf
2
+ import pandas as pd
3
+ import plotly.graph_objects as go
4
+ import streamlit as st
5
+
6
+ # Modify the interface to place input fields in a sidebar
7
+ sidebar = st.sidebar
8
+ symbol = sidebar.text_input("Enter stock symbol:", "AAPL")
9
+ period = sidebar.selectbox("Select period:", ["1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max"])
10
+
11
+ # Continue with the spell as before
12
+ data = yf.download(symbol, period=period)
13
+
14
+ data['Local Max'] = data['Close'][(data['Close'].shift(1) < data['Close']) & (data['Close'].shift(-1) < data['Close'])]
15
+ data['Local Min'] = data['Close'][(data['Close'].shift(1) > data['Close']) & (data['Close'].shift(-1) > data['Close'])]
16
+
17
+ fig = go.Figure()
18
+ fig.add_trace(go.Scatter(x=data.index, y=data['Close'], name='Close'))
19
+ fig.add_trace(go.Scatter(x=data['Local Max'].dropna().index, y=data['Local Max'].dropna(), mode='markers', name='Resistance'))
20
+ fig.add_trace(go.Scatter(x=data['Local Min'].dropna().index, y=data['Local Min'].dropna(), mode='markers', name='Support'))
21
+
22
+ table_data = pd.concat([data['Local Max'].dropna(), data['Local Min'].dropna()]).sort_index()
23
+ st.write(table_data.to_frame(name="Level"))
24
+
25
+ st.plotly_chart(fig)