IoannisTr commited on
Commit
a58e386
1 Parent(s): b99cb6c

Update stocks.py

Browse files
Files changed (1) hide show
  1. stocks.py +11 -7
stocks.py CHANGED
@@ -1,7 +1,5 @@
1
- #from asyncio.windows_events import NULL
2
  from configparser import ParsingError
3
  from logging import raiseExceptions
4
- #from sympy import comp
5
  import yfinance as yf
6
  import requests
7
  import pandas as pd
@@ -53,7 +51,7 @@ class Stock_Data(object):
53
  '''
54
  This method will get the current price only if the market is open.
55
  '''
56
- current_price = None #NULL
57
  if self.status_getter(Ticker) == "Open":
58
  current_price = float(soup.find("bg-quote", class_="value").text.replace(',',''))
59
  return current_price
@@ -79,9 +77,15 @@ class Stock_Data(object):
79
  '''
80
  data = yf.download(tickers = str(Ticker), period = "2y", interval = "1d")
81
  df = pd.DataFrame(data)
82
- # If the user wants to run the model to have a General Prediction of stocks with data of the last 2 years , uncomment the 2 lines below
83
- # data = yf.download(tickers = str(Ticker),period = "2y", interval = "1d") #period = "2y", interval = "1d"
84
- # df = pd.DataFrame(data)
 
 
 
 
 
 
85
  return df
86
 
87
 
@@ -111,7 +115,7 @@ class Stock_Data(object):
111
  if counter <= 17:
112
  ticker = company_ticker
113
  title = art.text.strip()
114
- if title is None:#NULL:
115
  break
116
  rows.append([ticker, title])
117
  counter = counter + 1
 
 
1
  from configparser import ParsingError
2
  from logging import raiseExceptions
 
3
  import yfinance as yf
4
  import requests
5
  import pandas as pd
 
51
  '''
52
  This method will get the current price only if the market is open.
53
  '''
54
+ current_price = None
55
  if self.status_getter(Ticker) == "Open":
56
  current_price = float(soup.find("bg-quote", class_="value").text.replace(',',''))
57
  return current_price
 
77
  '''
78
  data = yf.download(tickers = str(Ticker), period = "2y", interval = "1d")
79
  df = pd.DataFrame(data)
80
+
81
+ # Prediction in the data we evaluate the model
82
+ # If the user wants to run the model with the data that has been evaluated and predicted for , uncomment the 2 lines below ( Rows 111-112 )
83
+ # Setting the start = 2022-08-26 and end = 2020-08-26 Yahoo Finance will return data from 25-8-2020 to 25-8-2022 (2 years period).
84
+ # In those data our model has been evaluated.
85
+
86
+ #data = yf.download(tickers = str(Ticker),end="2022-08-26", start="2020-08-26")
87
+ #df = pd.DataFrame(data)
88
+
89
  return df
90
 
91
 
 
115
  if counter <= 17:
116
  ticker = company_ticker
117
  title = art.text.strip()
118
+ if title is None:
119
  break
120
  rows.append([ticker, title])
121
  counter = counter + 1