16 lines
322 B
Python
16 lines
322 B
Python
import yfinance as yf
|
||
import pandas as pd
|
||
|
||
# 获取AAPL的股票数据
|
||
stock = yf.Ticker("AAPL")
|
||
|
||
# 获取过去十年的日K线数据(前复权)
|
||
hist_data = stock.history(period="10y", auto_adjust=False)
|
||
|
||
# 打印数据前几行
|
||
print(hist_data.head())
|
||
|
||
# 保存到CSV文件
|
||
hist_data.to_csv("AAPL_10year_data.csv")
|
||
|