This repository has been archived on 2026-01-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
resources/stockapp/sample/get_yh_kline.py

16 lines
322 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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")