But it gives you following sugegstion, LOL

回答: ChatGPT gives a thumb up to this三心三意2025-08-20 06:02:27

Key nits (easy fixes/notes):

  1. Function/name mismatch – you use ['Close'] but the function is called get_adj_close_data.

    • If you truly want adjusted prices (usually better for returns): change to ['Adj Close'] (or rename the function).

  2. Month-end pick – your groupby(...).tail(1) works; resample('M').last() is a common alternative. Either is fine.

  3. Benchmark total return – you already noted this: ^GSPC is price index (no dividends). Beta/vol are fine, but long-run return comps will be lower than total return.

  4. Excel save – you create the workbook but don’t save it. Add something like wb.save('beta_report.xlsx') (and optionally wb.close()).

  5. Column formatting – your ranges match the output layout:

    • B (beta), C (rho), F (vol ratio) → 0.0000

    • D (sigma_s), E (sigma_m) → 0.0000% (those are decimals; percent format is appropriate)

  6. Type hintslist[str] needs Python 3.9+. For broader compatibility: from typing import List then tickers: List[str].

  7. Data gaps/NaNs – pandas’ corr skips NaNs pairwise, so you’re fine. Just be aware early months can be sparse for some tickers.

  8. yf.download end date – yfinance usually treats end as inclusive for daily data, but behavior can vary; your 5y+15d window gives enough buffer either way.

所有跟帖: 

请您先登陆,再发跟帖!