我目前正在使用Alpha-Vantage以1分钟的间隔获取财务数据。
amd=ts.get_intraday(symbol=symbol, outputsize='full', interval=interval)
amd=pd.DataFrame(amd[0])
amd.drop(amd.index[-1])我得到了以下输出
...
2020-03-02 09:37:00 46.1000 46.1265 45.7427 45.7427 701690.0
2020-03-02 09:36:00 46.0700 46.0700 45.9300 46.0500 725661.0
2020-03-02 09:35:00 46.1100 46.1100 46.1100 46.1100 484583.0
2020-03-02 09:34:00 46.7500 46.8000 46.3000 46.3447 614596.0
2020-03-02 09:33:00 46.9642 47.2300 46.6800 46.7400 528517.0
2020-03-02 09:32:00 47.6100 47.6100 46.7000 46.9800 770555.0
2020-03-02 09:31:00 47.4000 47.6800 47.1000 47.5500 3504998.0
2020-02-28 16:00:00 45.1500 45.5300 45.1400 45.4700 895713.0
2020-02-28 15:59:00 45.0900 45.1600 45.0100 45.1500 411553.0
2020-02-28 15:58:00 44.8750 45.0900 44.8400 45.0800 434739.0
2020-02-28 15:57:00 44.8400 44.9100 44.8100 44.8560 327619.0
2020-02-28 15:56:00 44.7500 44.9100 44.6800 44.8450 363272.0
2020-02-28 15:55:00 44.4800 44.7700 44.4604 44.7400 305512.0
...如你所见,日期从2月28日跳到3月2日,这是理所当然的。但是,在matplotlib中绘制它时...
amd['4. close'].plot()
plt.title('AMD')
plt.show() ...我得到了下面的图,其中mathplotlib compensates for the lack of data in weekends and at closed market通过从一个数据点到另一个数据点绘制一条直线。
如何获得类似于雅虎财经或谷歌财经股票图表的结果,其中忽略了未命中的数据(as in this example
发布于 2020-03-13 07:53:30
就用这个吧。好了。
import pandas as pd
import datetime
import pandas_datareader.data as web
start=datetime.datetime(2019,3,12)
end=datetime.datetime(2020,3,12)
df=web.DataReader('IBM','yahoo',start,end)
print(df)结果:
2020-01-30 135.356583
2020-01-31 142.244659
2020-02-03 144.758408
2020-02-04 147.569061
2020-02-05 154.714447
2020-02-06 155.139999
2020-02-07 153.410004
2020-02-10 154.429993
2020-02-11 153.479996
2020-02-12 155.309998
2020-02-13 154.309998
2020-02-14 150.699997
2020-02-18 151.100006
2020-02-19 150.860001
2020-02-20 151.220001
2020-02-21 149.839996
2020-02-24 146.429993
2020-02-25 141.710007
2020-02-26 139.750000
2020-02-27 133.110001
2020-02-28 130.149994
2020-03-02 134.300003
2020-03-03 128.899994
2020-03-04 134.220001
2020-03-05 129.550003
2020-03-06 127.730003
2020-03-09 117.809998
2020-03-10 124.769997
2020-03-11 117.970001
2020-03-12 102.809998

看看这个。
https://pandas-datareader.readthedocs.io/en/latest/remote_data.html#quandl
https://stackoverflow.com/questions/60495025
复制相似问题