我正在从雅虎财经收集纳斯达克数据。 我知道使用 yfinance 从雅虎财经下载数据。 我可以获得 Adj Close 数据,但我不知道如何访问下载数据的日期元素。
我试着这样约会 enter image description here
错误信息如下 enter image description here
很抱歉我无法直接向您展示图片 由于堆栈溢出的策略。
你能给我建议吗?
答案 0 :(得分:0)
试试这个
获取股票数据的代码:
import yfinance as yf
import pandas as pd
tickers = ["VOO","VGK","VPL"] #Subtitute for the tickers you want
df =yf.download(tickers, start = "2021-02-01" , end = "2021-02-04")
如果要按日期过滤,可以使用 .loc["2020-01-01"] 或指定范围。
示例:
df.loc["2021-02-02":"2021-02-04"]
要导出到 excel,您可以使用:
df.to_excel("output.xlsx")