2017-04-21 170 views
1

https://www.bloomberg.com/professional/support/api-library/如果您看下的BLPAPI Core Developer Guide,本指南将向您显示一个非常简单的BDS()转换。TIA彭博公式转换Excel公式 - BDS()批量数据

我试图获取细分市场数据。这是Excel公式我想转换: BDS("MSFT","PG_REVENUE","PG_HIERARCHY_LEVEL=1","NUMBER_OF_PERIODS=-11","REVERSE_PERIOD_ORDER=N","PRODUCT_GEO_OVERRIDE=P","FUND_PER","FQ")

这里是我的代码:

from tia.bbg import LocalTerminal 

ticker=['MSFT US Equity'] 
overrides=["PG_HIERARCHY_LEVEL=1","PRODUCT_GEO_OVERRIDE=P",'FUND_PER','FQ'] 

resp = LocalTerminal.get_reference_data(ticker,"PG_REVENUE",overrides) 
a=resp.as_map() 

看来不管我投入overrides变量。我得到相同的输出。

defaultdict(<type 'dict'>, {'MSFT US Equity': {'PG_REVENUE':        Metric Name Product Geographic Hierarchy Level \ 
0    More Personal Computing         1 
1 Productivity and Business Processes         1 
2      Intelligent Cloud         1 
3     Corporate and other         1 
4       Commercial         1 
5        Commercial Other         2 
6       Commercial Licensing         2 
7     Devices and Consumers         1 
8         D & C Other         2 
9         D & C Hardware         2 
10        D & C Licensing         2 

    Period 1 Value Period 2 Value Period 3 Value Period 4 Value \ 
0  4.046000e+04 4.316000e+04 3.840700e+04 -2.424536e-14 
1  2.648700e+04 2.643000e+04 2.697200e+04 -2.424536e-14 
2  2.504200e+04 2.371500e+04 2.173200e+04 -2.424536e-14 
3 -6.669000e+03 2.750000e+02 -2.780000e+02 4.030000e+02 
4 -2.424536e-14 -2.424536e-14 -2.424536e-14 4.534600e+04 
5 -2.424536e-14 -2.424536e-14 -2.424536e-14 5.660000e+03 
6 -2.424536e-14 -2.424536e-14 -2.424536e-14 3.968600e+04 
7 -2.424536e-14 -2.424536e-14 -2.424536e-14 3.210000e+04 
8 -2.424536e-14 -2.424536e-14 -2.424536e-14 6.618000e+03 
9 -2.424536e-14 -2.424536e-14 -2.424536e-14 6.461000e+03 
10 -2.424536e-14 -2.424536e-14 -2.424536e-14 1.902100e+04 

    Period 5 Value 
0 -2.424536e-14 
1 -2.424536e-14 
2 -2.424536e-14 
3 -4.850000e+02 
4  4.177000e+04 
5  4.644000e+03 
6  3.712600e+04 
7  3.243800e+04 
8  6.203000e+03 
9  6.740000e+03 
10 1.949500e+04 }}) 

我不知道如何按季度获得产出。

+1

你有没有试着用' 'FUND_PER = FQ'',而不是'' FUND_PER”, 'FQ' '? – assylias

+0

@assylias。是的,我有。 – jason

回答