tia bbg python - 覆盖“#N/A 字段不适用”

tia bbg python - Overriding "#N/A Field Not Applicable"

我正在尝试使用 get_attributes 请求字段,但它 returns 任何不适用的字段错误(例如,请求非股息支付股票的除息日)。

FieldError: (BRK/B US Equity, DVD_EX_DT, BAD_FLD, Field not applicable to security) 

是否已经有针对这种情况的覆盖,或者我是否必须遍历每个自动收报机然后合并?

import tia.bbg.datamgr as dm
mgr = dm.BbgDataManager()
sids_index = mgr[TICKERS]
bloomberg_fields =  ['BEST_DIV_YLD',  # Forward Dividend Yield
                     'DVD_EX_DT',  # Ex-Dividend Date
                     'EXPECTED_REPORT_DT',  # Next Earnings Call Date
                     'GROSS_MARGIN',  # Gross Margin
                     'OPER_MARGIN',  # Operating Margin
                     'PROF_MARGIN']  # Profit Margin
df_data = sids_index.get_attributes(bloomberg_fields, OVERRIDE)

您可以使用以下行试用 xbbg 包:

from xbbg import blp

blp.bdp(
    tickers=[
        'BRK/B US Equity', 'C US Equity'
    ],
    flds=[
        'Best_Div_Yld', 'DVD_Ex_Dt', 'Expected_Report_Dt',
        'Gross_Margin', 'Oper_Margin', 'Prof_Margin',
    ]
)

输出:

             ticker               field       value
0   BRK/B US Equity        Best_Div_Yld         -  
1   BRK/B US Equity           DVD_Ex_Dt         NaN
2   BRK/B US Equity  Expected_Report_Dt  2019-02-25
3   BRK/B US Equity        Gross_Margin       18.37
4   BRK/B US Equity         Oper_Margin       10.86
5   BRK/B US Equity         Prof_Margin       18.56
6       C US Equity        Best_Div_Yld        2.96
7       C US Equity           DVD_Ex_Dt  2018-11-02
8       C US Equity  Expected_Report_Dt  2019-01-14
9       C US Equity        Gross_Margin         NaN
10      C US Equity         Oper_Margin       31.86
11      C US Equity         Prof_Margin       -7.73

我发现了以下覆盖:

LocalTerminal.get_reference_data(tk, flds, ignore_field_error=1, ignore_security_error=1)

然后将输出生成为 nan 或 nat