How to translate a BDS excel-formula to XBBG API for Python

0 votes

I have the following Bloomberg BDS excel-formula: (";" is substituted with "," due to different settings in excel)

=@BSD(”TSLA US Equity”;”CHAIN_TICKERS”;”CHAIN_EXP_DT_OVRD=20210917”;”CHAIN_PUT_CALL_TYPE_OVRD=CALL”;”CHAIN_POINTS_OVRD=1000”)

In this instance, from this I get a list of all call option tickers for tickers, with expiration on 17/09/2021 (DDMMYYYY) for TSLA.

When trying to translate it to the XBBG API for Bloomberg, I have done the following (based on earlier helpful advice from SO'er):

import xbbg as blp
df = blp.bds(['TSLA US Equity'],
['CHAIN_TICKERS'],
CHAIN_EXP_DT_OVRD='CHAIN_EXP_DT_OVRD=20210917',
CHAIN_PUT_CALL_TYPE_OVRD='CHAIN_PUT_CALL_TYPE_OVRD=CALL',
CHAIN_POINTS_OVRD='CHAIN_POINTS_OVRD=1000')

But I only get a single data point returned, not the entire list.

What am I doing wrong?

Mar 30, 2022 in Database by Edureka
• 13,670 points
1,902 views

1 answer to this question.

0 votes

The parameters are improperly specified by you. Because the function doesn't recognise the CHAIN POINTS OVRD value, it defaults to 1, resulting in a dataframe with only one value.

The override name becomes the parameter name (no quotes) in the bds call with xbbg. The date override in this example can be a datetime value, whereas the chain points override can be an integer.

from xbbg import blp
from datetime import datetime

df = blp.bds('TSLA US Equity',
             'CHAIN_TICKERS',
             CHAIN_EXP_DT_OVRD=datetime(2021,9,17),
             CHAIN_PUT_CALL_TYPE_OVRD='CALL',
             CHAIN_POINTS_OVRD=1000)

print(df)

Output:

                                ticker
TSLA US Equity     TSLA US 09/17/21 C1
TSLA US Equity     TSLA US 09/17/21 C2
TSLA US Equity     TSLA US 09/17/21 C3
TSLA US Equity     TSLA US 09/17/21 C4
TSLA US Equity     TSLA US 09/17/21 C5
...                                ...
TSLA US Equity  TSLA US 09/17/21 C1600
TSLA US Equity  TSLA US 09/17/21 C1625
TSLA US Equity  TSLA US 09/17/21 C1650
TSLA US Equity  TSLA US 09/17/21 C1675
TSLA US Equity  TSLA US 09/17/21 C1700
answered Apr 1, 2022 by gaurav
• 23,260 points

Related Questions In Database

0 votes
0 answers
0 votes
1 answer

How to schedule a job for SQL query to run daily?

down voteaccepted Expand the SQL Server Agent node ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,830 points
9,795 views
0 votes
2 answers
0 votes
1 answer

I have to build a school website How can i connect databases to the instance (ec2) and what is the best AMI for my webserver INAWS ???

Hi@Trinu, I don't think your database is depends ...READ MORE

answered May 4, 2020 in Database by MD
• 95,440 points
680 views
0 votes
1 answer

How to schedule a job for sql query to run daily?

Hii, To schedule a job for sql query ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,880 points
3,696 views
0 votes
1 answer

Convert a number to a letter in C# for use in Microsoft Excel [duplicate]

If you are familiar with using formulas ...READ MORE

answered Feb 23, 2022 in Database by gaurav
• 23,260 points
596 views
0 votes
1 answer
0 votes
1 answer

Excel formula to remove comma, spaces, period and add a text

The steps to accomplish this are as ...READ MORE

answered Mar 15, 2022 in Database by gaurav
• 23,260 points
1,829 views
0 votes
1 answer

How to open a password protected excel file using python?

I recently came upon a Python package ...READ MORE

answered Apr 6, 2022 in Database by gaurav
• 23,260 points
8,990 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP