matthewgilbert / pdblp

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

override to ref history #36

Closed superbobstar closed 6 years ago

superbobstar commented 6 years ago

Hi When I try to override ref_hist it errors out when you try to combine overrides with bulk reference data. I think that the overrides are not being combined with the dates.

con.ref_hist(['BAC US EQUITY'] ,['DDIS_AMT_OUTSTANDING'], dates=df1['Quarter'],
             [('DDIS_CURRENCY','USD')] ,date_field="DDIS_HISTORY_OVERRIDE")
matthewgilbert commented 6 years ago

Please post a reproducible minimal example causing the error with con.debug = True set.

superbobstar commented 6 years ago

Hi, thanks for getting back so fast. this code is really helpfull and the only one that handles ref data with dates.
Here is a good example. It runs fine when using the dates only however when I include the override statement it errors. Below the line i tested running it without the date_field override and it is interesting how it combines them.

con.ref_hist(['BAC US EQUITY'], ['DDIS_AMT_OUTSTANDING'] ,dates=['2016Q1','2016Q2'],
             [('DDIS_CURRENCY','USD')], date_field="DDIS_HISTORY_OVERRIDE")

  File "<ipython-input-82-e14b4b16b2ac>", line 4
    ,[('DDIS_CURRENCY','USD')]
SyntaxError: non-keyword arg after keyword arg
con.ref_hist(['BAC US EQUITY'], ['DDIS_AMT_OUTSTANDING'] , [('DDIS_CURRENCY', 'USD')])
DEBUG:root:Sending Request:
 ReferenceDataRequest = {
    securities[] = {
        "BAC US EQUITY"
    }
    fields[] = {
        "DDIS_AMT_OUTSTANDING"
    }
    overrides[] = {
        overrides = {
            fieldId = "REFERENCE_DATE"
            value = "('DDIS_CURRENCY', 'USD')"
        }
    }
}

DEBUG:root:Message Received:
 ReferenceDataResponse = {
    securityData[] = {
        securityData = {
            security = "BAC US EQUITY"
            eidData[] = {
            }
            fieldExceptions[] = {
            }
            sequenceNumber = 0
            fieldData = {
                DDIS_AMT_OUTSTANDING = 202631594.904144
            }
        }
    }
}
Out[85]: 
                   date                 field         ticker         value
0  (DDIS_CURRENCY, USD)  DDIS_AMT_OUTSTANDING  BAC US EQUITY  2.026316e+08
matthewgilbert commented 6 years ago

SyntaxError: non-keyword arg after keyword arg is indicating the problem. This has nothing to do with pdblp but is related to the fact that this is not valid python syntax. You need to place keyword arguments after non keyword arguments.

con.ref_hist(['BAC US EQUITY'], ['DDIS_AMT_OUTSTANDING'] ,dates=['2016Q1','2016Q2'],
             ovrds=[('DDIS_CURRENCY','USD')], date_field="DDIS_HISTORY_OVERRIDE")

As an aside, when filing issues please look into formatting your messages appropriately.

superbobstar commented 6 years ago

Thank you!