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:

alternatives