Python Bloomberg API pdblp intraday request

前端 未结 2 1983
醉话见心
醉话见心 2020-12-11 07:04

pdblp allows daily historical Bloomberg requests via:

con = pdblp.BCon(debug=False)
con = start()
df = con.bdh([\'SPY Equity\'], \'PX_LAST\', \'20150103\', \         


        
2条回答
  •  醉梦人生
    2020-12-11 07:13

    Have you looked at the intraday request python example? You need to specify the timing in your request.

    def sendIntradayTickRequest(session, options):
    refDataService = session.getService("//blp/refdata")
    request = refDataService.createRequest("IntradayTickRequest")
    
    # only one security/eventType per request
    request.set("security", options.security)
    
    # Add fields to request
    eventTypes = request.getElement("eventTypes")
    for event in options.events:
        eventTypes.appendValue(event)
    
    # All times are in GMT
    if not options.startDateTime or not options.endDateTime:
        tradedOn = getPreviousTradingDate()
        if tradedOn:
            startTime = datetime.datetime.combine(tradedOn,
                                                  datetime.time(15, 30))
            request.set("startDateTime", startTime)
            endTime = datetime.datetime.combine(tradedOn,
                                                datetime.time(15, 35))
            request.set("endDateTime", endTime)
    else:
        if options.startDateTime and options.endDateTime:
            request.set("startDateTime", options.startDateTime)
            request.set("endDateTime", options.endDateTime)
    
    if options.conditionCodes:
        request.set("includeConditionCodes", True)
    
    print "Sending Request:", request
    session.sendRequest(request)
    

    I'm not exactly sure what you're trying to do, if you want historical intra-day then use the above and add the parameters for intra-day timing in your request. Then parse the output. However, if you're looking to do some function based on the live feed, the way I've done it is to set a cron job on the python script that grabs the rate/security every X minutes and save it into a database. Not sure if you're looking to do a real-time function, or just pull historicals.

    IntradayTickRequests are not currently supported in pdblp, but if you don't want to use the main api, within pdblp try this and it should work:

    df3 = con.bdib('SPY Equity', '2015-06-19T09:30:00', '2015-06-19T15:30:00', eventType='TRADE', interval=15)
    df3.head()
    

    Let me know if I misread your question.

提交回复
热议问题