Reputation: 9
I'm trying to get all data from the last 10 minutes for any given stock. My code has worked in previous code, but it's not working now.
I think the problem is probably to do with a bad interval or date, but I can't see any problems. At first I suspected it's just because I was trying to run it when stock markets were closed, but it won't work even today.
Is it just that it thinks I'm using the NYSE, so I need to set a param saying I'm in London?
ticker = str(input("Input the symbol to predict: \n").upper())
start = datetime.now() - timedelta(minutes = 10)
end = datetime.now()
try:
data = yf.download(tickers = ticker, start = start, end = end, interval = "1m")
print("Data collection successful, beginning plotting...")
except:
print("Failure in download")
df = pd.DataFrame(data)
This is my console log:
Input the symbol to predict:
^GSPC
[*********************100%%**********************] 1 of 1 completed
1 Failed download:
['^GSPC']: YFChartError("%ticker%: Data doesn't exist for startDate = 1725282425, endDate = 1725283025")
Data collection successful, beginning plotting...
Traceback (most recent call last):
File "c:\6thForm\machines\patternaiRUN.py", line 53, in <module>
img = image.load_img(img_path, target_size = (224,224))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTJC2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\keras\src\utils\image_utils.py", line 235, in load_img
with open(path, "rb") as f:
^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:/6thForm/machines/prediction graph.png'
(Note that the errors that occur after the failed download are due to the lack of data.)
Upvotes: 1
Views: 216
Reputation: 1987
Don't worry - there's no bug in your code! The stock market will be closed on 2 November 2024 for Labor Day, a United States federal holiday. As such, there will be no new yfinance data even though it is no longer the weekend. Your code should work just fine after the stock markets open back up again tomorrow.
Upvotes: 1