使用彭博API pybbg,每分钟将实时股票数据抓取到excel表格中

2024-05-13 13:54:48 发布

您现在位置:Python中文网/ 问答频道 /正文

这段代码使用bloombergapi从过去的两点(本例中是1995年到今天)正确地获取SP500数据。数据被发送到一个CSV excel文件。你知道吗

trading_days = bbg.bdh('SPY US Equity', 'PX_LAST', start_date='19950101', end_date=(date.today()).strftime('%Y%m%d'), periodselection='DAILY') #grabs every trading data going back to SPY from 1/1/1995 through today.

我如何在未来的五分钟内检索当前的实时SP500数据?这应该在将来做,而不是过去。。。你知道吗

我想过做这样的事?你知道吗

trading_days = bbg.bdh('SPY US Equity', 'PX_LAST', start_date=(date.today()).strftime('%Y%m%d'), end_date=(date.today()).strftime('%Y%m%d'), periodselection='MINUTE' , period=1)

我必须每五分钟运行一次相同的代码吗?你知道吗


Tags: 数据代码todaydatedayssp500lastus