Dec-10-2022, 04:59 PM
(Dec-09-2022, 07:50 PM)astral_travel Wrote: 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:
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()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
I've spotted and error in your code...
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 # this call is passing the path and file name to your function. Should this not be a symbol name? symbol_tracker("/home/tal/investing/Ticker.csv")... which may or may not fix things; untested.
I don't use Pandas, so I'm unsure about the code from this point down.
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein