Geek7 commited on
Commit
6578daf
·
verified ·
1 Parent(s): b26d5d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -2,6 +2,9 @@ import pandas as pd
2
  import numpy as np
3
  import yfinance as yf
4
  import streamlit as st
 
 
 
5
 
6
  # Function to fetch historical stock data using yfinance
7
  def fetch_stock_data(ticker, start_date, end_date):
@@ -201,6 +204,17 @@ def main():
201
  start_date = st.date_input('Start Date', pd.to_datetime('2020-01-01'))
202
  end_date = st.date_input('End Date', pd.to_datetime('2022-01-01'))
203
 
 
 
 
 
 
 
 
 
 
 
 
204
  if st.button('Detect Patterns'):
205
  stock_data = fetch_stock_data(ticker, start_date, end_date)
206
  stock_data = detect_head_shoulder(stock_data)
 
2
  import numpy as np
3
  import yfinance as yf
4
  import streamlit as st
5
+ from datetime import datetime, timedelta
6
+ import pytz
7
+
8
 
9
  # Function to fetch historical stock data using yfinance
10
  def fetch_stock_data(ticker, start_date, end_date):
 
204
  start_date = st.date_input('Start Date', pd.to_datetime('2020-01-01'))
205
  end_date = st.date_input('End Date', pd.to_datetime('2022-01-01'))
206
 
207
+ preferred_timezone = st.timezone_input('Select Preferred Timezone', pytz.UTC)
208
+
209
+ start_datetime = st.time_input('Select Start Time', datetime(2022, 1, 1, 0, 0))
210
+ end_datetime = st.time_input('Select End Time', datetime(2022, 1, 1, 23, 59))
211
+
212
+ start_datetime = datetime.combine(start_date, start_datetime.time())
213
+ end_datetime = datetime.combine(end_date, end_datetime.time())
214
+
215
+ start_datetime = preferred_timezone.localize(start_datetime)
216
+ end_datetime = preferred_timezone.localize(end_datetime)
217
+
218
  if st.button('Detect Patterns'):
219
  stock_data = fetch_stock_data(ticker, start_date, end_date)
220
  stock_data = detect_head_shoulder(stock_data)