2017-08-08 163 views
-2

我想在python中使用BDS公式提取bloomberg數據,並且我已經下載了pybbg庫。我想包括幾個覆蓋,但我得到一個錯誤。我試圖提取的是使用excel API插件完成的:= BDS(「SUBC NO Equity」,「PG_REVENUE」,「PRODUCT_GEO_OVERRIDE = G」,「FUND_PER = Q」= 對於一個覆蓋,以下代碼工作https://github.com/kyuni22/pybbg):彭博API,pybbg

import unittest 
import datetime 
import pybg 

class TestPybbg(unittest.TestCase): 
    def test_bds(self): 
     tester = pybbg.Pybbg() 
     data = tester.bds('SUBC NO Equity','PG_REVENUE',overrides={'FUND_PER': 'Q'}) 
     print(data) 

if __name__ == '__main__': 
    unittest.main() 

跟隨誤差出現,如果公司不具備這個水平的細節:

Traceback (most recent call last): 
    File "C:/Users/bloomberg/.spyder-py3/temp.py", line 23, in test_bds_override 
    data = tester.bds('AKSO NO Equity','PG_REVENUE',overrides={'PRODUCT_GEO_OVERRIDE':'G','FUND_PER':'Q'}) 
    File "C:\Users\bloomberg\AppData\Local\Continuum\Miniconda3\envs\work\lib\site-packages\pybbg-0.0.1-py3.6.egg\pybbg\pybbg_k.py", line 295, in bds 
    fieldData = securityData.getValue(i).getElement("fieldData").getElement(field) 
    File "C:\Users\bloomberg\AppData\Local\Continuum\Miniconda3\envs\work\lib\site-packages\blpapi\element.py", line 347, in getElement 
    _ExceptionUtil.raiseOnError(res[0]) 
    File "C:\Users\bloomberg\AppData\Local\Continuum\Miniconda3\envs\work\lib\site-packages\blpapi\exception.py", line 145, in raiseOnError 
    _ExceptionUtil.raiseException(errorCode, description) 
    File "C:\Users\bloomberg\AppData\Local\Continuum\Miniconda3\envs\work\lib\site-packages\blpapi\exception.py", line 137, in raiseException 
    raise errorClass(description, errorCode) 
blpapi.exception.NotFoundException: Attempt to access unavailable sub-element 'PG_REVENUE' of element 'fieldData'. (0x0006000d) 
+0

錯誤是什麼? – user3080953

+0

如果數據不可用,則會出現以下錯誤: – larsmr

回答

0

我想通了,如果你添加下面的公式可以包括幾個替代:

data = tester.bds('SUBC NO Equity','PG_REVENUE',overrides={'PRODUCT_GEO_OVERRIDE':'G','FUND_PER':'Q'})