matthewgilbert / pdblp

pandas wrapper for Bloomberg Open API
MIT License
240 stars 69 forks source link

ref not working when providing valid isin #69

Closed gflores87 closed 4 years ago

gflores87 commented 4 years ago

Code Sample, a copy-pastable example if possible

import pandas as pd
import pdblp

tickers = 'CA7392397054 ISIN'
con = pdblp.BCon(debug=True, port=8194, timeout=20000)
con.start()
short_names = con.ref(tickers, 'ID_EXCH_SYMBOL')

Problem description

The code above resolves to a ValueError: Unknow security CA7392397054 ISIN

pdblp.pdblp:INFO:Sending Request:
ReferenceDataRequest = {
    securities[] = {
        "CA7392397054 ISIN"
    }
    fields[] = {
        "ID_EXCH_SYMBOL"
    }
    overrides[] = {
    }
}
pdblp.pdblp:INFO:Event Type: 'RESPONSE'
pdblp.pdblp:INFO:Message Received:
ReferenceDataResponse = {
    securityData[] = {
        securityData = {
            security = "CA7392397054 ISIN"
            eidData[] = {
            }
            securityError = {
                source = "3113::bbdbd15"
                code = 3
                category = "BAD_SEC"
                message = "Unknown/Invalid Security  [nid:3113] "
                subcategory = "INVALID_SECURITY"
            }
            fieldExceptions[] = {
            }
            sequenceNumber = 0
            fieldData = {
            }
        }

Expected Output

if we do a bdp in excel (bdp("CA7392397054 ISIN","ID_EXCH_SYMBOL"), it returns POW.PR.F

Version Information

0.1.8

matthewgilbert commented 4 years ago

The backend Bloomberg services that the Excel API and the python API rely on are not the same. That message clearly indicates the error, which is returned by blpapi. pdblp is just a wrapper around blpapi. I would contact Bloomberg support.

oalexandere commented 4 years ago

You should to use: tickers = '/isin/CA7392397054' If you send tickers = 'Some ticker' to bloomberg api (blpapi) it automatically translates to '/ticker/Some ticker'. If you specify ticker as '/isin/CA7392397054' blpapi do not translate it and uses as is. Other examples:

See the doc BLPAPI Core Developer Guide (page 13 about Topic) from https://www.bloomberg.com/professional/support/api-library/

Topic: In the case of “//blp/mktdata,” the topic value consists of an optional topic prefix followed by an instrument identifier. For example, “/cusip/097023105” and “/sedol1/2108601” include the topic prefix, whereas “IBM US Equity” omits the topic prefix. If the topic prefix is not specified, the defaultTopicPrefix of the SessionOptions object is used, which is “/ticker” by default. Therefore, if using a ticker, such as IBM, the security string would be “IBM US Equity,” with the “/ticker” topic prefix is implied. Note: The topic’s form may be different for different subscription services.

gflores87 commented 4 years ago

You should to use: tickers = '/isin/CA7392397054' If you send tickers = 'Some ticker' to bloomberg api (blpapi) it automatically translates to '/ticker/Some ticker'. If you specify ticker as '/isin/CA7392397054' blpapi do not translate it and uses as is. Other examples:

  • '/cusip/097023105'
  • '/sedol1/2108601'

See the doc BLPAPI Core Developer Guide (page 13 about Topic) from https://www.bloomberg.com/professional/support/api-library/

Topic: In the case of “//blp/mktdata,” the topic value consists of an optional topic prefix followed by an instrument identifier. For example, “/cusip/097023105” and “/sedol1/2108601” include the topic prefix, whereas “IBM US Equity” omits the topic prefix. If the topic prefix is not specified, the defaultTopicPrefix of the SessionOptions object is used, which is “/ticker” by default. Therefore, if using a ticker, such as IBM, the security string would be “IBM US Equity,” with the “/ticker” topic prefix is implied. Note: The topic’s form may be different for different subscription services.

thank you so much!

dpsugasa commented 3 years ago

extremely pleased to find this. It has bothered me for years.