Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intraday can't resolve if datarange has no tickers #63

Open
gflores87 opened this issue Apr 22, 2019 · 2 comments
Open

Intraday can't resolve if datarange has no tickers #63

gflores87 opened this issue Apr 22, 2019 · 2 comments
Labels

Comments

@gflores87
Copy link

gflores87 commented Apr 22, 2019

Code Sample, a copy-pastable example if possible

equity = con.bdib('SPX Index', '2019-04-19T01:00:00', '2019-04-22T21:00:00', 'TRADE', 1)

Problem description

As of April 22nd at 8:03EST, the request for the intraday trade prints for SPX Index is empty. There's nothing wrong with that, the issue here is that the code won't return an empty dataset. Instead it will crash. Specifically, it will crash trying to execute this line from file pdblp.py, method bdib:

data = pd.DataFrame(data).set_index('time').sort_index().loc[:, flds]

Error raised:

KeyError: 'time'

This is the content from debug = True

pdblp.pdblp:INFO:Sending Request:
IntradayBarRequest = {
    security = "SPX Index"
    eventType = TRADE
    interval = 1
    startDateTime = 2019-04-19T01:00:00
    endDateTime = 2019-04-22T21:00:00
}

pdblp.pdblp:INFO:Event Type: 'RESPONSE'
pdblp.pdblp:INFO:Message Received:
IntradayBarResponse = {
    barData = {
        eidData[] = {
        }
        barTickData[] = {
        }
    }
}

Expected Output

equity = []

Version Information

0.1.8

@matthewgilbert
Copy link
Owner

Yes this looks like a bug. Another issue with this is that IntradayBarRequest can set overrides to update the number of fields returned so by selecting with the preset flds = ['open', 'high', 'low', 'close', 'volume', 'numEvents'] these extra fields would be ignored.

@gflores87
Copy link
Author

gflores87 commented Apr 22, 2019

Appreciate the feedback. I took the liberty to change my code for bdib to this:

        if len(data) == 0:
            data = pd.DataFrame()
        else:
            data = pd.DataFrame(data).set_index('time').sort_index().loc[:, flds]
        return data

this way, it won't crash on an empty data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants