How to download new stock data#

1import mplfinance as mpl
2import yfinance as yf
3
4from src.utils import init_notebook
1init_notebook()
1data_folder = "data/raw_data"
1# change these to the stock you want to download
2stock_name = "AAPL"
3start = "2019-01-01"
4end = "2021-12-31"
1df = yf.download(stock_name, start, end)
2print(f"{df.shape = }")
[*********************100%%**********************]  1 of 1 completed
df.shape = (756, 6)
1# plot the data to verify your needs
2mpl.plot(df, type="candle", style="yahoo")
/home/runner/.cache/pypoetry/virtualenvs/stock-analysis-DF-fhKMw-py3.10/lib/python3.10/site-packages/mplfinance/_arg_validators.py:84: UserWarning: 

 ================================================================= 

   WARNING: YOU ARE PLOTTING SO MUCH DATA THAT IT MAY NOT BE
            POSSIBLE TO SEE DETAILS (Candles, Ohlc-Bars, Etc.)
   For more information see:
   - https://github.com/matplotlib/mplfinance/wiki/Plotting-Too-Much-Data
   
   TO SILENCE THIS WARNING, set `type='line'` in `mpf.plot()`
   OR set kwarg `warn_too_much_data=N` where N is an integer 
   LARGER than the number of data points you want to plot.

 ================================================================ 
  warnings.warn('\n\n ================================================================= '+
../_images/ef0692c52974451356b3b52e3ab3170e98e044c7614a8bda962e451971c76073.png
1df.to_csv(f"{data_folder}/{stock_name}.csv")