Dec-09-2022, 07:50 PM
i'm trying to download stock data from yahoo! finance....
in anyway - i'm trying to have a symbol to download by loading the symbol/tickers from a file....
i know my code is awful, but i'll be glad to receive help:
i'll be glad for assistance with this...
thanks
in anyway - i'm trying to have a symbol to download by loading the symbol/tickers from a file....
i know my code is awful, but i'll be glad to receive help:
import yfinance as yf import pandas as pd import plotly.graph_objects as go def symbol_tracker(symbol): with open("/home/tal/investing/Ticker.csv", "r") as file: for line in file: if line != "\n": yf.download(symbol, start='1900-01-01') else: print("end of data") return line symbol_tracker("/home/tal/investing/Ticker.csv") def symbol_saver(df): pass fig = go.Figure(go.Candlestick(x=df.index, open=df['Open'], high=df['High'], low=df['Low'], close=df['Close'])) fig.show()
Output:1 Failed download:
- /HOME/TAL/INVESTING/TICKER.CSV: No data found for this date range, symbol may be delisted
[*********************100%***********************] 1 of 1 completed
1 Failed download:
- /HOME/TAL/INVESTING/TICKER.CSV: No data found for this date range, symbol may be delisted
Traceback (most recent call last):
File "/home/tal/PycharmProjects/pythonProject2/experiment2.py", line 16, in <module>
symbol_tracker("/home/tal/investing/Ticker.csv")
File "/home/tal/PycharmProjects/pythonProject2/experiment2.py", line 10, in symbol_tracker
yf.download(symbol, start='1900-01-01')
File "/home/tal/PycharmProjects/pythonProject1/venv/lib/python3.8/site-packages/yfinance/multi.py", line 118, in download
_time.sleep(0.01)
KeyboardInterrupt
Process finished with exit code 130 (interrupted by signal 2: SIGINT)
one additional element i need basically is saving the data onto csv files with having the name of files by their tickers...i'll be glad for assistance with this...
thanks