BondBase#
-
class sigtech.framework.instruments.bonds.BondBase
Baseclasses:
TradableInstrument
Subclasses:
GovernmentBond
Bond base class holding all relevant bond information. Note that
calc_type
is based on TechHackers Guide, but only ex-dividend accrual conventions are picked from there. It is planned to use BBG calc type in the future.Bonds are assumed to have par amount of 100 when defining redemption amount or computing price.
-
property available_data_points
The data points available for this instrument
-
property available_history_fields
Combined fields available for history retrieval -> clean/dirty prices + calculated fields.
-
calc_type: Optional[int]
-
coupon: float
-
coupon_frequency: Literal['ANNUAL', 'SEMI_ANNUAL', 'QUARTERLY']
-
coupon_type: Literal['FIXED', 'FLOATING', 'ZERO_COUPON', 'INDEX_LINKED']
-
day_count: Literal['ACT/ACT', 'ACT/360', 'ACT/365F', '30/360', '30E/360', 'ACT/365_NL', 'ACT/366']
-
days_to_settle: Optional[int]
-
db_history_end_date: Optional[date]
-
description: Optional[str]
-
property dirty_fields
Field identifier for dirty quoted prices.
-
property expiry_date
Date contract expires, or last date on which we can trade.
-
property extra_fields
Extra fields one wants to compute in the history -> order is important, check
retrieve_history()
!
-
first_coupon_date: date
-
first_settle_date: Optional[date]
-
int_acc_date: date
-
isin: Optional[str]
-
issue_date: date
-
issuer: str
-
maturity_date: date
-
redemption_amount: float
-
series_number: Optional[str]
-
property settlement_type
Type of settlement, e.g. ‘Cash’ or ‘Physical’.
-
property size_type
Type of trade size for tradable instrument, either units or notional.
-
tax_withholding: Optional[float]
-
property valuation_time
Valuation time for the instrument.
-
accrued_interest(d)
Accrued interest given a settlement date.
- Parameters:
d – Settlement date.
- Returns:
Accrued interest.
-
accrued_interests(ds)
Accrued interest given a list of settlement dates.
- Parameters:
ds – List of settlement dates.
- Returns:
List of accrued interests.
-
asw_spread(trade_date, clean_price=None, index_tenor=None, discount_curve_name=None, forecasting_curve_name=None)
Calculates bond asset swap spread with regards to the input discount and forecasting curve. (Standard swap market ones are taken by default, but can be overwritten). Swap assumes to start on the bond settlement day, which is also used as the floating leg accrual start and the corresponding IBOR rate setting (at the standard reset lag). Floating rate is taken to be the standard swap market frequency, but can be overwritten. The spread is given in basis points (23 means 23 basis points)
- Parameters:
trade_date – date on which the asset swap spread is calculated
clean_price – optional - clean price with usual bond conventions (100 for par bond)
index_tenor – optional - floating index frequency (e.g. ‘3M’ or ‘6M’)
discount_curve_name – optional: swap discounting curve
forecasting_curve_name – optional: floating index forecasting curve
- Returns:
-
asw_spreads(trade_dates=None, index_tenor=None, discount_curve_name=None, forecasting_curve_name=None)
Calculates bond asset swap spread with regards to the input discount and forecasting curve for the given set of trade_dates. If not dates are given, the maximal available series of asw-spreads is returned (from the latest of bond history start and forecasting curve history start to the last bond trade date with settlement prior to maturity) Standard swap market curves are taken by default, but can be overwritten. Swaps assume to start on the bond settlement day, which is also used as the floating leg accrual start and the corresponding IBOR rate setting (at the standard reset lag). Floating rate is taken to be the standard swap market frequency, but can be overwritten. The spread is given in basis points (23 means 23 basis points)
- Parameters:
trade_dates – dates on which the asset swap spread is calculated. All history dates if None
index_tenor – optional - floating index frequency (e.g. ‘3M’ or ‘6M’)
discount_curve_name – optional: swap discounting curve
forecasting_curve_name – optional: floating index forecasting curve
- Returns:
-
bond_dependency()
Returns a Dependency object suitable for this Bond
-
bond_info() deprecated
Bond info summary, required by
BondMixin
.
-
bond_px(settlement_date, yield_)
Clean bond price.
- Parameters:
settlement_date – Settlement date.
yield – Quoted yield.
- Returns:
Clean bond price.
-
calendar_schedule()
This is when we expect data to arrive.
-
carry_roll_down(d: date, dates: Union[str, date, list[Union[str, datetime.date]]], clean_price: float = None, discount_curve_name: str = None, repo_rate: Union[float, list[float]] = 0.00035, otr_bond_yields: DataFrame = None)
Compute carry and roll-down of bond by moving the valuation date forward to the requested dates, keeping discount curve constant, i.e. discount_factor(from_original_date, for_x_number_of_days) equals discount_factor(from_the_forward_date, for_x_number_of_days), and keeping the z-spread to that curve constant as well
- Parameters:
d – valuation date
dates – string/date or a list of strings/dates for which the carry/roll-down is needed
clean_price – optional - clean price with usual bond conventions (100 for par bond)
discount_curve_name – optional: discounting curve (swap market standard one is used if None is provided)
repo_rate – optional: repo rate (or list of repo rates - one per horizon). Absolute (0.01 means 1%)
otr_bond_yields – optional: DataFrame of two columns of the ref bonds - first columns maturities of reference bonds, and second column - their yields. If omitted, the default OTR bonds yields curve is used.
'disable'
or'no'
would disable computation of yield roll-down altogether
- Returns:
DataFrame of 6 columns -
carry
- cumulative cashflows from d to date,roll_down
- change in bond pv, and the same numbers scaled by bond DV01. Additional 2 columns are yield carry (based on the input repo rate) and yield roll down, based on the input on-the-run bonds yields ford
(or the default OTR yields curve)
-
cashflows(d: date)
Returns the cashflows incurred from a given date to the maturity of the bond.
- Parameters:
d – The date from which to return cashflows
- Returns:
List of cashflows (coupons + redemption)
-
dv01(settlement_date, yield_, expiry_date=None)
DV01, i.e. derivative of bond price with respect to yield. Scaling unit of yield change is 1, i.e. if change in bond value per 1 basis point change in yield is needed, the value should be multiplied by 0.0001.
- Parameters:
settlement_date – Settlement date.
yield – Yield quote.
expiry_date – Expiry date (optional).
- Returns:
Dollar duration.
-
dv01s(settlement_dates, yields_, expiry_date=None)
DV01, i.e. derivative of bond price with respect to yield, for a list of settlement dates and yield quotes. Scaling unit of yield change is 1, i.e. if change in bond value per 1 basis point change in yield is needed, the value should be multiplied by 0.0001.
- Parameters:
settlement_dates – List of settlement dates.
yields – List of yield quotes.
expiry_date – Expiry date (optional).
- Returns:
List of dollar durations.
-
ex_div_date(d)
Ex-dividend date given a trade date.
- Parameters:
d – Trade date.
- Returns:
Ex-dividend date.
-
ex_div_dates(ds)
Ex-dividend dates given a list of trade dates.
- Parameters:
ds – Trade dates.
- Returns:
Ex-dividend dates.
-
forward_price(settlement, horizon, price, repo_rate)
Forward price.
- Parameters:
settlement – Settlement date.
horizon – Forward date.
price – Bond price.
repo_rate – Repo rate in percentage.
- Returns:
Forward price.
-
forward_prices(settlements, horizons, prices, repo_rates)
Forward price for a list of settlement dates, forward dates, prices and repo rates.
- Parameters:
settlements – List of settlement dates.
horizons – List of forward dates.
prices – List of bond prices.
repo_rates – List of repo rates in percentage.
- Returns:
List of forward prices.
-
history_limits()
Get reduced history limits, if they were set by the
set_history_limits
function.- Returns:
Dictionary of history
start_date
andend_date
overrides
-
last_proper_trade_date()
Last date on which bond can be traded to settle before the maturity.
-
matching_swap(trade_date=None, start_date=None)
Returns a receiver spot starting swap (start date is usually 2BD after
trade_date
) with IBOR rate (+ asset swap spread) based floating leg that matches the bond’s maturity, ccy and coupon (as fixed rate).- Parameters:
trade_date – Swap trade date, if NA or before the bond’s issue date - defaults to the bond’s issue date.
start_date – Swap start date, if NA - defaults to swap spot date (usually 2BD after swap trade date).
-
modified_duration(settlement_date, yield_, expiry_date=None)
Modified duration.
- Parameters:
settlement_date – Settlement date.
yield – Yield quote.
expiry_date – Expiry date (optional).
- Returns:
Modified duration.
-
modified_durations(settlement_dates, yields_, expiry_date=None)
Modified duration for a list of settlement dates and yield quotes.
- Parameters:
settlement_dates – List of settlement dates.
yields – List of yield quotes.
expiry_date – Expiry date (optional).
- Returns:
List of modified durations.
-
next_cashflow(d: date)
Returns the next cashflow after a given date.
- Parameters:
d – The date after which to return next cashflow
- Returns:
numpy.array() representing cashflow in a form of [payment dtm.date(), coupon amount] or empty numpy.array() if there are no cashflows after the date d
-
set_history_limits(start_date=None, end_date=None, reset_all=False)
Truncate bond history by supplied
start_date
andend_date
(to speed uphistory()
call, if history outside is not needed). If history already has been pre-cached, and new limits are inside, they are ignored, unlessreset_all
is set toTrue
. Ifstart_date
orend_date
isNone
, they are also ignored.- Parameters:
start_date – Date for history to start (or last business day before, when data was available). Optional,
None
by default.end_date – Last date for history (or last business day prior). Optional,
None
by default.reset_all – Boolean flag, telling if the parameters should be set even if they don’t add any new available data. (e.g.
start_date=None
would be ignored ifreset_all=False
, but previously setstart_date
will be deleted ifreset_all=True
). Optional,False
by default.
- Returns:
no return, function modifies bond internally.
-
settlement_date(d)
Settlement date given a trade date.
- Parameters:
d – Trade date.
- Returns:
Settlement date.
-
settlement_dates(ds)
Settlement dates given a list of trade dates.
- Parameters:
ds – Trade dates.
- Returns:
Settlement dates.
-
sizing_price(sizing_dt, ccy=None, execution_dt=None)
Price on given valuation date.
-
validate()
Perform validation checks on the instrument.
-
ytm(settlement_date, price, expiry_date=None, yield_quote=None)
Yield to maturity.
- Parameters:
settlement_date – Settlement date.
price – Bond price.
expiry_date – Expiry date (optional).
yield_quote – Yield quote (optional).
- Returns:
Yield to maturity.
-
ytms(settlement_dates, prices, expiry_date=None, yield_quote=None)
Yield to maturity for a list of settlement dates and prices.
- Parameters:
settlement_dates – List of settlement dates.
prices – List of bond prices.
expiry_date – Expiry date (optional).
yield_quote – Yield quote (optional).
- Returns:
List of yield to maturity.
-
z_spread(trade_date, clean_price=None, settlement_date=None, curve_name=None, day_count=None, frequency=None)
Calculates bond z-spread with regards to the input discount curve. Bond day count and frequency taken by d efault, but can be overwritten for different bonds comparison. Settlement date can be overwritten if non standard, and clean price input can be changed from the historic one in the database. The spread is given in basis points (23 means 23 basis points)
- Parameters:
trade_date – date on which the Z-spread is calculated
clean_price – optional - clean price with usual bond conventions (100 for par bond)
settlement_date – optional - bond settlement date
curve_name – curve to which the Z-spread is to be calculated
day_count – optional - the one used in bond is taken by default
frequency – optional - the one used in bond is taken by default
- Returns:
-
z_spreads(trade_dates=None, curve_name=None, day_count=None, frequency=None)
Calculates bond z-spread with regards to the input discount curve for the given set of trade_dates. If not dates are given, the maximal available series of z-spreads is returned (from the latest of bond history start and curve history start to the last bond trade date with settlement prior to maturity). Bond day count and frequency taken by default, but can be overwritten for different bonds comparison. The spread is given in basis points (23 means 23 basis points)
- Parameters:
trade_dates – dates for which z-spread is to be calculated. All history dates if None
curve_name – optional - discount curve to which z-spread is calculated
day_count – optional - bond day_count override for z-spread
frequency – optional - bond frequency override for z-spread
- Returns:
Series of z-spreads for all input or available dates