Spaces:
Runtime error
Runtime error
Update stocks.py
Browse files
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
|
| 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 |
-
|
| 83 |
-
#
|
| 84 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 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
|