yfinance

How to deal with multi-level column names downloaded with yfinance?

依然范特西╮ 提交于 2020-08-12 21:21:17
问题 I have a list of tickers ( tickerStrings ) that I to download all at once. When I try to use pandas' read_csv it doesn't read the csv file in the way it does when I download the data from yfinance. I usually access my data by ticker like this: data['AAPL'] or data['AAPL'].Close , but when I read the data from the csv file it does not let me do that. if path.exists(data_file): data = pd.read_csv(data_file, low_memory=False) data = pd.DataFrame(data) print(data.head()) else: data = yf.download

How to add a column in multilevel Dataframe using pandas and yfinance?

妖精的绣舞 提交于 2020-08-09 08:47:54
问题 I have the below code: import yfinance as yf import pandas as pd import datetime as dt end=dt.datetime.today() start=end-dt.timedelta(59) tickers=['WBA', 'HD'] ohlcv={} df=pd.DataFrame df = yf.download(tickers,group_by=tickers,start=start,end=end,interval='5m') df['h-l']=abs(df.High-df.Low) df['h-pc']=abs (df.High-df['Adj Close'].shift(1)) df['l-pc']=abs(df.Low-df['Adj Close'].shift(1)) df['tr']=df[['h-l','h-pc','l-pc']].max(axis=1) df['atr']=df['tr'].rolling(window=n, min_periods=n).mean()

How to add a column in multilevel Dataframe using pandas and yfinance?

南楼画角 提交于 2020-08-09 08:45:26
问题 I have the below code: import yfinance as yf import pandas as pd import datetime as dt end=dt.datetime.today() start=end-dt.timedelta(59) tickers=['WBA', 'HD'] ohlcv={} df=pd.DataFrame df = yf.download(tickers,group_by=tickers,start=start,end=end,interval='5m') df['h-l']=abs(df.High-df.Low) df['h-pc']=abs (df.High-df['Adj Close'].shift(1)) df['l-pc']=abs(df.Low-df['Adj Close'].shift(1)) df['tr']=df[['h-l','h-pc','l-pc']].max(axis=1) df['atr']=df['tr'].rolling(window=n, min_periods=n).mean()