How to get historical price data of GOV BOND(EXPIRED/MATURED) like JP10504214C9 more efficiently

It seems to work below code but is there more efficiently codes like historical_function in workspace API?

###

import refinitiv.data as rd
import refinitiv.data.content.ipa.financial_contracts as rdf
from refinitiv.data.content.ipa.financial_contracts import bond
rd.open_session()

import pandas as pd
from datetime import datetime, timedelta

start_date = "2007-11-01"
end_date = "2007-12-31"

start_dt = datetime.strptime(start_date, "%Y-%m-%d")
end_dt = datetime.strptime(end_date, "%Y-%m-%d")

all_data = []

current_date = start_dt
while current_date <= end_dt:
response = rdf.Definitions(
universe=[
bond.Definition(instrument_code="JP10504214C9"),
],
pricing_parameters=bond.PricingParameters(
market_data_date=current_date.strftime("%Y-%m-%d"),
price_side=bond.PriceSide.MID
),
fields=[
"InstrumentDescription",
"MarketDataDate",
"Price"
]
).get_data()

if response.data.df is not None:
all_data.append(response.data.df)

current_date += timedelta(days=1) # Increment by 1 day

combined_df = pd.concat(all_data, ignore_index=True)
rd.close_session()

Answers

  • Hello @kunitaka.tsukamoto

    Unfortunately, there does not seem to be a better way to do this. The Bond Analytics calculates the information and it does so for a particular point in time. So there does seem to be an option to specify a date range.

    I tried using the get_history and get_data, but the pricing and timeseries data does not exist for these instruments.