Created
June 24, 2026 01:29
-
-
Save quantra-go-algo/6d8c9f7e5c4db2b991100144fc796012 to your computer and use it in GitHub Desktop.
guardrailed-llm-agent — Step 2: Getting the Data Right (snippet 1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import yfinance as yf | |
| import pandas as pd, numpy as np | |
| # auto_adjust=True ensures prices are split- and dividend-adjusted. | |
| # AAPL split 7-for-1 in 2014 and 4-for-1 in 2020. Without adjustment, | |
| # those days show fake -86% and -75% returns that corrupt every feature. | |
| df = yf.download(SYMBOL, start=START, auto_adjust=True, progress=False) | |
| if isinstance(df.columns, pd.MultiIndex): | |
| df = df.droplevel(-1, axis=1) # flatten multi-level columns | |
| df.index = pd.to_datetime(df.index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment