trading-quant/test.py
2024-06-07 10:55:50 +08:00

27 lines
503 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
import monitors
import monitors.vegas
# monitors.vegas.run('1d')
import yfinance as yf
import pandas as pd
# 定义股票代码例如苹果公司的股票代码为AAPL
ticker = 'AAPL'
# 下载日线数据
data = yf.download(ticker, interval='1d', period='2y') # 过去一年的数据
# 打印数据
print(data)
# 如果需要将时间格式转换为可读格式
data.index = pd.to_datetime(data.index)
# 打印前几行数据
print(data.head())