matthewgilbert / pdblp

pandas wrapper for Bloomberg Open API
MIT License
241 stars 68 forks source link

Currency Override, BBG issus or pdblp? #43

Closed nicktids closed 6 years ago

nicktids commented 6 years ago

I'm Trying to download Multiple time series all in the same USD \

for a quick reference I'm going to show SPY US Equity in USD and EUR I think it might be a Bloomberg API issue but can you also check before I go query with them.

con.bdh('SPY US Equity', 'PX_LAST',
                '20150629', '20150630', ovrds=[('Currency', 'USD')])
con.bdh('SPY US Equity', 'PX_LAST',
                '20150629', '20150630', ovrds=[('Currency', 'EUR')])

#Output  USD
DEBUG:root:Sending Request:
 HistoricalDataRequest = {
    securities[] = {
        "SPY US Equity"
    }
    fields[] = {
        "PX_LAST"
    }
    startDate = "20150629"
    endDate = "20150630"
    overrides[] = {
        overrides = {
            fieldId = "Currency"
            value = "USD"
        }
    }
}

DEBUG:root:Message Received:
 HistoricalDataResponse = {
    securityData = {
        security = "SPY US Equity"
        eidData[] = {
        }
        sequenceNumber = 0
        fieldExceptions[] = {
        }
        fieldData[] = {
            fieldData = {
                date = 2015-06-29
                PX_LAST = 205.420000
            }
            fieldData = {
                date = 2015-06-30
                PX_LAST = 205.850000
            }
        }
    }
}

# Output EUR
DEBUG:root:Sending Request:
 HistoricalDataRequest = {
    securities[] = {
        "SPY US Equity"
    }
    fields[] = {
        "PX_LAST"
    }
    startDate = "20150629"
    endDate = "20150630"
    overrides[] = {
        overrides = {
            fieldId = "Currency"
            value = "EUR"
        }
    }
}

DEBUG:root:Message Received:
 HistoricalDataResponse = {
    securityData = {
        security = "SPY US Equity"
        eidData[] = {
        }
        sequenceNumber = 0
        fieldExceptions[] = {
        }
        fieldData[] = {
            fieldData = {
                date = 2015-06-29
                PX_LAST = 205.420000
            }
            fieldData = {
                date = 2015-06-30
                PX_LAST = 205.850000
            }
        }
    }
}

Problem description

I would expect the Values to change as the I change the override currency. I have confirmed that the API works in Excel, but do not have the experience to see why it is not working here.

I'm going to have to pull the currency of the tickers I want and download the FX cross to manually fix, but would be great if you could have a look. This is I think the only BBG python API wrapper that is currently active on github so keep up the excellent work.

Expected Output

To return differen values USD or EUR but just get the same data frame

ticker SPY US Equity
Date value
2015-06-29 205.42
2015-06-30 205.85

Version Information

[paste the output of pdblp.__version__ here below this line] '0.1.5'

matthewgilbert commented 6 years ago

Can you try using elms instead of ovrds and currency instead of Currency

con.bdh('SPY US Equity', 'PX_LAST',  '20150629', '20150630',
        elms=[('currency', 'EUR')])

and see if that resolves the issue? From the Services & schemas reference guide I believe this is a field to be set not an override (not really sure how/why blpapi differentiates these). I can't test this at the moment but believe it should resolve your issue.

nicktids commented 6 years ago

Wow super fast reply and fixed.

I tried elms as well but had the capital letter so threw an error.

Would be a good little one to add to the wiki as you don't have elms on the wiki page, I only saw to try it as I saw an issue logged with it.

matthewgilbert commented 6 years ago

@nicktids yes agreed it would be good to add to https://matthewgilbert.github.io/pdblp/tutorial.html. Happy to accept a pull request, otherwise will try and get around to it at some point when I have some spare time.