yfinance_notes
Table of Contents
convert daily ohlcv data to monthly
code snippet:
def daily_ohlcv_to_month_end_ohlcv(daily): monthly = daily.resample("ME").agg( { "Open": "first", "High": "max", "Low": "min", "Close": "last", "Adj Close": "last", "Volume": "sum", } ) return monthly
used it in https://github.com/KamarajuKusumanchi/market_data_processor/blob/master/tests/src/utils/test_yfinance_utils.py → test_daily_ohlc_to_month_end_ohlc()
See also:
- https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.resample.html - documentation on pandas.DataFrame.resample
- https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects - DateOffset objects
- tags | “Frequency String”
- ISO8601 has a way to represent durations - https://en.wikipedia.org/wiki/ISO_8601#Durations
- used it in https://github.com/KamarajuKusumanchi/market_data_processor/blob/master/tests/src/utils/test_yfinance_utils.py → test_daily_ohlc_to_month_end_ohlc()
links I came across
- repo of yfinance - https://github.com/ranaroussi/yfinance
alternatives
- yahooquery
- yahoofinancials - the biggest difference from yfinance is that all the downloaded data is returned as JSON
- yahoo_earnings_calendar - a small library to download the earnings calendar.
yfinance_notes.txt · Last modified: 2024/07/23 00:22 by raju