AlphaVantage获取股票数据并保存为csv

key请到官网免费申请,需要科学上网

import pandas as pd
from alpha_vantage.timeseries import TimeSeries

ts = TimeSeries(key=’’, output_format=‘pandas’)
data, meta_data = ts.get_intraday(symbol=‘MSFT’,interval=‘1min’, outputsize=‘full’)

pf = pd.DataFrame(index=data,columns=[‘date’,‘open’,‘high’,‘low’,‘close’,‘volume’])
pf.to_csv("./Test_1.csv", encoding=“utf-8-sig”)

你可能感兴趣的:(量化投资)