如何为Python中tia.bbg的LocalTerminal参考数据请求添加覆盖参数?
Hey there! I get that you're looking to replicate your Excel BDP function (with that BEST_FPERIOD_OVERRIDE parameter) in Python using the tia.bbg library. Let's break this down simply.
In your Excel formula:
=BDP("IBM US Equity","BEST_EBITDA","BEST_FPERIOD_OVERRIDE","1FY")
The last two arguments are the override field and its value. In tia.bbg's LocalTerminal.get_reference_data() method, you can pass these overrides using the overrides parameter, which accepts a dictionary of field-value pairs.
Here's the adjusted Python code that matches your Excel function exactly:
from tia.bbg import LocalTerminal # Set up your override as a key-value pair in a dictionary overrides = {"BEST_FPERIOD_OVERRIDE": "1FY"} # Include the overrides parameter in your request resp = LocalTerminal.get_reference_data("IBM US Equity", "BEST_EBITDA", overrides=overrides) # To view the results, you can convert the response to a DataFrame print(resp.as_frame())
A quick note: If you ever need to add multiple overrides later, just expand the dictionary with additional key-value pairs, like:
overrides = { "BEST_FPERIOD_OVERRIDE": "1FY", "ANOTHER_OVERRIDE_FIELD": "DESIRED_VALUE" }
This should give you the same result as your original Excel BDP call.
内容的提问来源于stack exchange,提问作者jason

