Python Bloomberg API request does not return result
Asked Answered
E

1

10

I am attempting to install the Bloomberg API. I have followed all instructions and can run code without producing any errors. However it doesn't produce any useful output which makes me think something went wrong with the install. I've been trying this for four days and am banging my head against my keyboard! Hopefully someone has encountered this and can clue me in.

I'm using "IntradayTickExample" which is available here:

https://github.com/msitt/blpapi-python/blob/master/examples/IntradayTickExample.py

The output looks like this:

IntradayTickExample
Connecting to localhost:8194

12OCT2018_16:37:35.207 7780:22292 WARN blpapi_platformcontroller.cpp:347 
blpapi.session.platformcontroller.{1} Connectivity restored.
Sending Request: IntradayTickRequest = {
    security = "IBM US Equity"
    eventTypes[] = {
        TRADE
    }
    startDateTime = 2008-08-11T15:30:00.000
    endDateTime = 2008-08-11T15:35:00.000
}

Processing Response
IntradayTickResponse = {
    tickData = {
        eidData[] = {
        }
        tickData[] = {
        }
    }
}

TIME                            TYPE    VALUE           SIZE    CC
----                            ----    -----           ----    --


------------------
(program exited with code: 0)

Any ideas?

Eggnog answered 12/10, 2018 at 20:49 Comment(1)
Apologies if this is an obvious question, but since you're not receiving any other help, have you confirmed that tick frequency is short enough to return a value within a five-minute time window? It seems odd that Bloomberg would provide an example that returns zero data but equally it seems odd that the code doesn't seem to work. I tried to find the default interval for the tick data but couldn't find anything solid. However, if the default frequency is, say hourly, then it's perhaps not surprising to receive no ticks between 15:30 and 15:35.Kershaw
F
5

Bloomberg limits the amount of tick history you can download to the most 10 recent days. Running a similar example to what you linked to will return data provided this is in the correct range (ran as of 2018-10-24).

import blpapi
HOST = "localhost"
PORT = 8194

def main():
    sessionOptions = blpapi.SessionOptions()
    sessionOptions.setServerHost(HOST)
    sessionOptions.setServerPort(PORT)

    session = blpapi.Session(sessionOptions)

    if not session.start():
        print("Failed to start session.")
        return

    session.openService("//blp/refdata")
    refDataService = session.getService("//blp/refdata")

    request1 = refDataService.createRequest("IntradayTickRequest")
    request1.set("security", "IBM US Equity")
    request1.getElement("eventTypes").appendValue("TRADE")
    request1.set("startDateTime", "2008-08-11T15:30:00.000")
    request1.set("endDateTime", "2008-08-11T15:35:00.000")

    request2 = refDataService.createRequest("IntradayTickRequest")
    request2.set("security", "IBM US Equity")
    request2.getElement("eventTypes").appendValue("TRADE")
    request2.set("startDateTime", "2018-10-23T15:30:00.000")
    request2.set("endDateTime", "2018-10-23T15:30:01.000")

    session.sendRequest(request1)
    session.sendRequest(request2)

    while True:
        ev = session.nextEvent(500)
        if ev.eventType() == blpapi.Event.TIMEOUT:
            break
        for msg in ev:
            print(msg)

Running this you can see that data is obtained in the second example, since the date range is set appropriately.

main()
SessionConnectionUp = {
    server = "localhost:8194"
}

SessionStarted = {
    initialEndpoints[] = {
        initialEndpoints = {
            address = "localhost:8194"
        }
    }
}

ServiceOpened = {
    serviceName = "//blp/refdata"
}

IntradayTickResponse = {
    tickData = {
        eidData[] = {
        }
        tickData[] = {
        }
    }
}

IntradayTickResponse = {
    tickData = {
        eidData[] = {
        }
        tickData[] = {
            tickData = {
                time = 2018-10-23T15:30:00.000+00:00
                type = TRADE
                value = 129.510000
                size = 100
            }
            tickData = {
                time = 2018-10-23T15:30:00.000+00:00
                type = TRADE
                value = 129.510000
                size = 300
            }
            tickData = {
                time = 2018-10-23T15:30:00.000+00:00
                type = TRADE
                value = 129.525000
                size = 100
            }
            tickData = {
                time = 2018-10-23T15:30:01.000+00:00
                type = TRADE
                value = 129.510000
                size = 100
            }
            tickData = {
                time = 2018-10-23T15:30:01.000+00:00
                type = TRADE
                value = 129.510000
                size = 100
            }
            tickData = {
                time = 2018-10-23T15:30:01.000+00:00
                type = TRADE
                value = 129.510000
                size = 200
            }
        }
    }
}
Fishmonger answered 24/10, 2018 at 4:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.