netflypsb commited on
Commit
af65542
·
verified ·
1 Parent(s): 7fa5fbe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import yfinance as yf
3
+ import pandas as pd
4
+ import pandas_ta as ta
5
+ import matplotlib.pyplot as plt
6
+
7
+ # Streamlit interface setup
8
+ st.title("Breakout Trading Analysis Tool")
9
+ ticker = st.text_input("Enter Stock Ticker:", value="AAPL")
10
+ timeframe = st.selectbox("Select Time Frame:", options=["1d", "1wk", "1mo"], index=0)
11
+ analyze_button = st.button("Analyze Breakout Points")
12
+
13
+ if analyze_button:
14
+ # Fetching the stock data
15
+ stock_data = yf.download(ticker, period="1y", interval=timeframe)
16
+
17
+ # Calculating technical indicators for breakout identification (e.g., moving averages)
18
+ stock_data['SMA50'] = ta.sma(stock_data['Close'], length=50)
19
+ stock_data['SMA200'] = ta.sma(stock_data['Close'], length=200)
20
+
21
+ # Example breakout logic: SMA50 crossing above SMA200
22
+ crossover_points = stock_data[(stock_data['SMA50'] > stock_data['SMA200']) & (stock_data['SMA50'].shift(1) < stock_data['SMA200'].shift(1))]
23
+
24
+ # Plotting
25
+ plt.figure(figsize=(10, 6))
26
+ plt.plot(stock_data['Close'], label='Close Price', color='skyblue')
27
+ plt.plot(stock_data['SMA50'], label='50-Day SMA', color='green')
28
+ plt.plot(stock_data['SMA200'], label='200-Day SMA', color='red')
29
+ plt.scatter(crossover_points.index, crossover_points['Close'], color='magenta', label='Breakout Points', zorder=5)
30
+ plt.title(f"{ticker} Breakout Points Analysis")
31
+ plt.legend()
32
+
33
+ # Display plot in Streamlit
34
+ st.pyplot(plt)