我正在尝试使用get_attributes请求字段,但是对于不适用的任何内容,它都会返回FieldError(例如,请求以非股息支付的股票除息日期)。
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)
答案 0 :(得分:1)
您可以使用以下几行试用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
答案 1 :(得分:1)
我发现以下覆盖:
LocalTerminal.get_reference_data(tk, flds, ignore_field_error=1, ignore_security_error=1)
然后将输出生成为nan或nat