GovernmentBondSwap
GovernmentBondSwap#
-
class sigtech.framework.instruments.bonds.GovernmentBondSwap
Representation of a bond trading in swap format.
-
contract_name: str
-
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.
-
add_custom_history(history: pandas.core.series.Series, field: str = 'LastPrice', data_point: Optional[sigtech.framework.infra.data_adapter.common.DataPoint] = None)
Add custom history data for this object. If multiple, conflicting custom histories are added only the last addition will be returned from
history
.- Parameters
history –
pd.Series
of custom history with index as tz-naive,pd.DatetimeIndex
dates.field – Name of history field to overwrite.
data_point – Optional
DataPoint
to specify timing of custom history.
-
after_history_func()
-
property alias: Optional[str]
Return an alias string used to represent the instrument in the portfolio table or other widgets.
-
property allowed_clean_sparse_fields
List of fields that are allowed to have
na
values on clean history.
-
property asset_description: str
String representing the underlying asset, or None if no assets exist.
-
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
-
property available_data_points
The data points available for this instrument
-
available_data_providers(entitled_only=True) Optional[List[str]]
Available data providers for this object. Bool to return entitled providers only
-
property available_history_fields
Combined fields available for history retrieval -> clean/dirty prices + calculated fields.
-
property base_name
Primary name used to identify the object.
-
property bbg_ticker: str
Ticker for Bloomberg data vendor.
-
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.
-
cache_history(fields: list, data_point: sigtech.framework.infra.data_adapter.common.DataPoint, start_dt: Optional[datetime.datetime] = None, end_dt: Optional[datetime.datetime] = None, **kwargs)
Ensure history data is cached
-
property cache_name: str
Cache name of this object.
-
calendar_schedule()
This is when we expect data to arrive.
-
carry_roll_down(d: datetime.date, dates: Union[str, datetime.date, list[Union[str, datetime.date]]], clean_price: Optional[float] = None, discount_curve_name: Optional[str] = None, repo_rate: Union[float, list[float]] = 0.00035, otr_bond_yields: Optional[pandas.core.frame.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: datetime.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)
-
property class_name
Class name of this object.
-
property class_short_name
Short name of the object class.
-
clear_cached_data()
Clear all the cached data of the object.
-
clone_object(params=None)
Return a clone of the object with amended parameters.
- Parameters
params – Optional dictionary of parameters to override.
- Returns
New object.
-
compute_dependencies(root_dependency: Optional[sigtech.framework.internal.infra.mu.graph.registry.factory.Dependency] = None)
Compute these dependencies - triggers MDS requests
-
static convert_dtypes(clz)
Class decorator to convert classes’ BaseType into variable annotations (PEP-526), and to generate __aliases__ based on BaseType.db_name when required.
-
data_available(d: Optional[datetime.date] = None) bool
Method to indicate if pricing data is available for a given date.
- Parameters
d – Date of interest (optional), if not provided it will take as of date of the environment.
-
data_df(data_point: Optional[sigtech.framework.infra.data_adapter.common.DataPoint] = None, multi_index: bool = False, drop_nan_cols: bool = False, pretty_print=False) pandas.core.frame.DataFrame
Return a DataFrame containing all data available for this object.
- Parameters
data_point – Optional data point used to load the object history.
multi_index – If set to True, rows are uniquely indexed by a multi index (if applicable). Default is False.
drop_nan_cols – If set to True, all-NaN columns are dropped. Default is False.
pretty_print – If set to True, formatting is added to columns names and data values. Rates will be represented as percentage number instead of decimal number (e.g. 3.5 instead of 0.035).
- Returns
pandas DataFrame.
-
data_dict()
Return the object attributes in a dict.
-
property data_format
Return the data format associated with sparse history, i.e.
ROWISE
orCOLUMNAR
.
-
property data_point
Field used when retrieving history.
-
property data_source
Data provider of the instrument.
-
property data_source_all: Optional[list[str]]
Available data points for this object.
-
data_validation(sparse_series)
Additional data checks can be implemented in sub classes here.
-
property default_data_point
Default data point for this object.
-
dependencies(input_dependency: Optional[sigtech.framework.internal.infra.mu.graph.registry.factory.Dependency] = None, valuation_currency: Optional[str] = None, use_start: bool = True) list[sigtech.framework.internal.infra.mu.graph.registry.factory.Dependency]
Returns a list of Dependency
- Parameters
input_dependency – A Dependency object representing the root of the dependency tree to be returned.
valuation_currency – If supplied, include the dependencies required to output the data in this currency.
use_start – If False, return only dependencies required to calculate an earliest start date - self.start_date will be None in this case.
- Returns
List of Dependency objects representing the current level in the dependency tree.
-
property dependency_type
Should return GraphNodeType. Return None to autodetect based on result of dependencies()
-
property dirty_fields
Field identifier for dirty quoted prices.
-
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.
-
property env: sigtech.framework.config.config.ConfiguredEnvironment
Return the configured environment.
-
env_date_change(old_env_dt: datetime.datetime, new_env_dt: datetime.datetime, live_data_update=None)
Routine called after the environment date is changed.
- Parameters
old_env_dt – Old datetime (tz aware).
new_env_dt – New datetime (tz aware).
live_data_update – Live streaming data associated with the environment date change.
-
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.
-
exchange() Any
Object for exchange (or substitute, e.g.
'OTCLN'
) on which instrument trades.
-
property exchange_code: str
Exchange code for traded instruments belonging to this instrument.
-
property expiry_date
Date contract expires, or last date on which we can trade.
-
property expiry_dt: datetime.datetime
Datetime when the contract expires, or last datetime at which we can trade.
-
property extra_fields
Extra fields one wants to compute in the history -> order is important, check
retrieve_history()
!
-
finalize_for_comparison()
Method to call to ensure all data dict values are finalized prior to doing object comparisons.
-
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.
-
classmethod from_dictionary(dct: dict[str, Any], cache: bool = True, identifier: Optional[sigtech.framework.infra.data_adapter.identifier.Identifier] = None, env: Optional[sigtech.framework.config.config.ConfiguredEnvironment] = None, **kwargs)
Factory method to create object using data dictionary
-
get_bond_repo()
Generate a government bond repo from the current bond instrument.
-
get_bond_swap()
Generate a government bond swap from the current bond instrument.
-
classmethod get_names(sort_by_group: Optional[bool] = False, include_db: Optional[bool] = True, include_local: Optional[bool] = True, include_children: Optional[bool] = False, ignore_unmapped: Optional[bool] = True) list[str]
Return an ordered list of object names associated with the class.
- Parameters
sort_by_group – If set, the list is first ordered by sector/group, if applies, e.g. commodity or index futures (default is False).
include_db – If set, include objects available from the database (default is True).
include_local – If set, include objects available in the local environment (default is True).
include_children – If set, include objects available from child classes (default is False).
ignore_unmapped – If set, ignore errors due to unmapped database objects (default is True).
- Returns
List of object names.
-
group() any
Group of this object.
-
has_preloaded_history(fields=None, data_point=None)
Check if the object has preloaded history.
-
history(field: str = None, adjust_for_delay: bool = False, date_index: bool = False, data_point: Optional[sigtech.framework.infra.data_adapter.common.DataPoint] = None, datetime_index: bool = False) pandas.core.series.Series
Method to retrieve time series for objects overlaid by history schedule and publication delay (optional). If the given field does not exist, an empty series will be returned.
- Parameters
field – Optional - Returns time series for field - defaults to prime history field.
adjust_for_delay – Optional - Returns adjusted index if there is a publication delay.
date_index – Optional - Convert the timestamp index to dates.
data_point – data point to retrieve - from self.available_data_points
datetime_index – Optional - if True, populate the time and UTC timezone information in the index.
- Returns
pd.Series
.
-
history_dates()
Return all the dates we should have actual history values.
-
history_dates_actual()
Return all the dates we have actual history values.
-
history_dates_eventual()
Return all the dates we will eventually have history values.
-
history_df(fields: list[str] = None, data_point: sigtech.framework.infra.data_adapter.common.DataPoint = None, multicolumn: bool = None) deprecated
Return the object history dataframe.
- Parameters
fields – list of fields. If not supplied, self.history_fields will be used
data_point – optional data point used to load the object history.
multicolumn – Deprecated input. This will be removed in future releases.
- Returns
pd.DataFrame
.
-
history_end_date() datetime.date
Eventual history end date, truncated to the as of date - the day on which history should end.
-
history_end_date_actual()
The last date we have an actual value for.
-
history_end_date_eventual() datetime.date
Last date for which data will be available - typically
date.max
if no end date set.
-
history_end_timestamp() pandas._libs.tslibs.timestamps.Timestamp
- Returns
First timestamp for which data should be available
-
property history_fields: list[str]
The fields of history retrieved for this instrument.
-
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
-
history_schedule() sigtech.framework.schedules.schedule.Schedule
Object describing dates on which history is available and the corresponding delivery times.
- Returns
History schedule instance for the instrument.
-
history_start_date() datetime.date
First date for which data should be available.
-
history_start_timestamp() pandas._libs.tslibs.timestamps.Timestamp
- Returns
First timestamp for which data should be available
-
property identifier: sigtech.framework.infra.data_adapter.identifier.Identifier
Return the object identifier.
-
info() dict
Return a dictionary with useful object information.
-
property input_parameters
Values of initial input parameters entered when creating the instance.
-
property instrument_type: str
- Returns
Classification using class name of instruments.
-
property internal_id
Ticker - i.e. part of name determining content of the class. For types with saved reference data - ticker will be
self._ticker
. For software types - ticker should be calculated.
-
intraday_history(field=None, period=None, start_dt=None, end_dt=None, daily_timeseries_time=None, daily_timeseries_tz=None, filter_by_trading_sessions=False, timezone=None, convert_yield_to_price=True)
Retrieve intraday history for this instrument as a Series.
- Parameters
field – field name in self.intraday_history_fields.
period – a dtm.timedelta giving the desired periodicity of the data.
start_dt – optional tz-aware dtm.datetime giving a desired start point.
end_dt – optional tz-aware dtm.datetime giving a desired end point.
daily_timeseries_time – if supplied, the intraday data will be down-sampled to daily data snapped at this time.
daily_timeseries_tz – timezone for the above. Optional, if not supplied defaults to self.valuation_tzinfo
filter_by_trading_sessions – If
False ``(default), return all available data. If ``True
return data during the main trading session. If a string/list(string), return data during the trading session(s) of that name according toself.group().session_data()
. See intraday_trading_sessions() for list of sessions.timezone – set the timezone of the returned series to this value
convert_yield_to_price – applies yield to price conversion for yield quoted futures, e.g. AUD bond futures
- Returns
A (possibly sparse) pd.Series with a DateTimeIndex. Times should be tz-aware UTC.
-
intraday_history_df(fields=None, period=None, start_dt=None, end_dt=None, daily_timeseries_time=None, daily_timeseries_tz=None, filter_by_trading_sessions=False, timezone=None, convert_yield_to_price=True)
Retrieve intraday history for this instrument as a dataframe.
- Parameters
fields – a list of field names all in self.intraday_history_fields.
period – a dtm.timedelta giving the desired periodicity of the data.
start_dt – optional tz-aware dtm.datetime giving a desired start point.
end_dt – optional tz-aware dtm.datetime giving a desired end point.
daily_timeseries_time – if supplied, the intraday data will be down-sampled to daily data snapped at this time.
daily_timeseries_tz – timezone for the above. Optional, if not supplied defaults to self.valuation_tzinfo
filter_by_trading_sessions – If
False ``(default), return all available data. If ``True
return data during the main trading session. If a string/list(string), return data during the trading session(s) of that name according toself.group().session_data()
timezone – set the timezone of the returned dataframe to this value
convert_yield_to_price – applies yield to price conversion for yield quoted futures, e.g. AUD bond futures
- Returns
A (possibly sparse) pd.DataFrame with a DateTimeIndex. Times should be tz-unaware UTC.
-
property intraday_history_fields: list[str]
The intraday fields of history retrieved for this instrument.
-
intraday_trading_sessions()
Gets ths list of trading sessions available as per the Copp-Clarke session data for this product group
-
is_cash() bool
Return True if the instrument represents a cash/margin amount.
-
is_exchange_traded() bool
Return True if this instrument is traded on an exchange.
-
is_expandable() bool
Return True if the instrument can be expressed in terms of a portfolio of other instruments.
-
is_margin() bool
Check if the instrument represents a margin amount.
-
is_margin_accountable() bool
Check if an artificial margin is created to account for price changes in instruments that do not require immediate payment, but have a nominal value, e.g. futures. The actual P&L is computed through this artificial margin for such instruments.
-
is_notional_exposure_calc_needed() bool
Check if the notional exposure weight should be computed and included in the interactive portfolio table, e.g. for options, FX forwards, IR swaps.
-
is_option() bool
Return True if the instrument is an option.
-
is_otc() bool
Is this instrument OTC traded?
-
is_strategy() bool
Return True if this object is a strategy.
-
property is_unmapped
Check if the object is not mapped.
-
last_proper_trade_date()
Last date on which bond can be traded to settle before the maturity.
-
property live_supported: bool
Flag for live supported objects.
-
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.
-
property name
Primary name by which the
FrameworkObject
is identified. If reference information (or e.g. corresponding time series) are stored in the DB, then this name will be used.
-
next_cashflow(d: datetime.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
-
order_class() Any
Return the order class for timeline processing.
-
property order_rounding
The value to which the units should be rounded to when calculating target units. Eg, 1000 would round to the nearest thousand :return: order rounding factor
-
property position_type: str
Display trade type.
-
positions_to_units(position, dt)
Strategy scaling function: convert positions to number of units.
- Parameters
position – Number of positions.
dt – Input scaling date.
- Returns
Number of units.
-
positions_to_units_multiplier(dt)
Strategy scaling function: multiplier to convert positions to number of units.
- Parameters
dt – Input scaling date.
- Returns
multiplier
-
property prime_history_field: str
The main history field returned by default.
-
property prime_intraday_history_field
The main intraday history field returned by default.
-
classmethod print_add_trade_kwargs()
Print the keyword arguments for the
Strategy
add_trade
method.
-
print_dependencies(root_dependency: Optional[sigtech.framework.internal.infra.mu.graph.registry.factory.Dependency] = None, resolve_future_dependencies: bool = True, fields: Optional[list] = None)
Pretty print dependency tree :param root_dependency: starting dependency of the tree. :param resolve_future_dependencies: resolve future dependencies before printing. If ‘false’ nothing get printed. :param fields: additional fields to extract from dependencies object. Default fields are
product_type
,currency
,frequency
anddata_source
. To get the list of available fields for an object you can use thedata_dict()
method.
-
property product_type
Return the
product_type
property of this object.
-
publication_delay() str
Publication delay of data for this instrument.
-
realign_history(series)
Realign history series to proper business days.
- Parameters
series – Input series.
- Returns
Realigned history series.
-
rounded_units(units, dt, to_trade=True)
The number of units allowed to trade for a specified target number of units, at the provided time.
This should be overwritten for instrument specific rounding logic.
The ‘to_trade’ flag switches between the use case of rounding the position for trade execution or for analysis The trading case can be different because the position is held for an extended time, while in the case of analysis you can consider the instantaneous amount of rounding allowed. An example of this applied is for the strategies where the underlying positions change over time.
- Parameters
units – Target number of units.
dt – Datetime.
to_trade – Boolean flag to switch between allowed to open for an extended time (True) or at that instant.
-
static schedule_stub(country)
Schedule stub.
-
property sector
Sector used on BBG, or the class ID for SIG instruments.
-
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.
-
set_preloaded_history(data) None
Set the preloaded history of the object.
- Parameters
data – History data.
-
set_sparse_history(data) None
Set the sparse history of the object.
- Parameters
data – History data.
-
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.
-
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.
-
sizing_price(sizing_dt, ccy=None, execution_dt=None)
Price on given valuation date.
-
static sort_key_static(name)
Convert a name to the sort key as of Portfolio Presentation Guidelines for performance reasons.
- Parameters
name – Input name.
- Returns
Tuple (sort key, length of sort key, input name).
-
property supplementary_fields: list[str]
Additional fields available for the group.
-
textual_representation()
Return a printable representation of this object.
-
trade_line(units, dt, rounded_units=True)
Trade entry containing information about units and string representation.
- Parameters
units – Number of units.
dt – Size date.
rounded_units – If True, use rounded units to get positions (optional True by default).
- Returns
Scaled units and trade description.
-
property trade_name: str
String identifier used for order/trade generation.
-
trade_price(trade_dt: datetime.datetime, trade_sign: float, include_trading_costs: Optional[bool] = True, transaction_type: Optional[str] = None, currency: Optional[str] = None, cache_trade_date: Optional[bool] = True) float
Price Traded - gives either bid or ask depending on trade type.
- Parameters
trade_dt – Trading datetime
trade_sign – Integer/float to determine if it is a buy or sell
include_trading_costs – If True will apply trading cost adjustment otherwise ignores it
transaction_type – String identifier to indicate type of transaction, e.g. ‘outright’, ‘roll’
currency – Currency string stub
cache_trade_date – Optional parameter to cache trading dates of instrument
- Returns
Trade/fill price
-
trade_price_adjustment(d: datetime.datetime, include_trading_costs: Optional[bool] = True, transaction_type: Optional[str] = None, cache_trade_date: Optional[bool] = True) float
Trade price adjustment (TPA) formula:
\[TPA_t = \alpha * S_t^{Mid} + \beta\]- Parameters
d – Trading date
include_trading_costs – If True will apply trading cost adjustment otherwise ignores it
transaction_type – String identifier to indicate type of transaction, e.g. ‘outright’, ‘roll’
cache_trade_date – Optional parameter to cache trading dates of instrument
- Returns
Trade price adjustment
-
trade_price_adjustment_add(d: datetime.datetime, transaction_type: Optional[str] = None, cache_trade_date: Optional[bool] = True) float
Absolute adjustment to the mid price value in the trade price adjustment.
- Parameters
d – Trade date
transaction_type – String identifier to indicate type of transaction, e.g. ‘outright’, ‘roll’
cache_trade_date – Optional parameter to cache trading dates of instrument
-
trade_price_adjustment_multiply(d: datetime.datetime, transaction_type: Optional[str] = None, cache_trade_date: Optional[bool] = True) float
Multiplier to the mid price value in the trade price adjustment
- Parameters
d – Trade date
transaction_type – String identifier to indicate type of transaction, e.g. ‘outright’, ‘roll’
cache_trade_date – Optional parameter to cache trading dates of instrument
-
trade_price_ask(trade_dt: datetime.datetime, include_trading_costs: Optional[bool] = True, transaction_type: Optional[str] = None, currency: Optional[str] = None, cache_trade_date: Optional[bool] = True) float
Ask price at a point in time.
- Parameters
trade_dt – Trading datetime
include_trading_costs – If True will apply trading cost adjustment otherwise ignores it
transaction_type – String identifier to indicate type of transaction, e.g. ‘outright’, ‘roll’
currency – Currency string stub
cache_trade_date – Optional parameter to cache trading dates of instrument
- Returns
Ask trade price
-
trade_price_bid(trade_dt: datetime.datetime, include_trading_costs: Optional[bool] = True, transaction_type: Optional[str] = None, currency: Optional[str] = None, cache_trade_date: Optional[bool] = True) float
Bid price at a point in time.
- Parameters
trade_dt – Trading datetime
include_trading_costs – If True will apply trading cost adjustment otherwise ignores it
transaction_type – String identifier to indicate type of transaction, e.g. ‘outright’, ‘roll’
currency – Currency string stub
cache_trade_date – Optional parameter to cache trading dates of instrument
- Returns
Bid trade price
-
trade_schedule() sigtech.framework.schedules.schedule.Schedule
Schedule giving trade dates + last time at which we can trade for that date (i.e. notice time for funds).
- Returns
Trade schedule instance for the instrument.
-
units_to_positions(units, dt)
Strategy scaling function: convert number of units to positions.
- Parameters
units – Number of units.
dt – Input scaling date.
- Returns
Number of positions.
-
validate()
Perform validation checks on the instrument.
-
valuation_dt(d: datetime.date) datetime.datetime
Valuation dt - datetime for a given valuation date.
-
valuation_point() str
Valuation Point - from this we can infer the field, time and timezone for the valuation.
-
valuation_price(dt: datetime.datetime, ccy: Optional[str] = None) float
Price on given valuation date.
- Parameters
dt – Input valuation date
ccy – Currency string identifier
- Returns
Valuation price for given input date
dt
-
valuation_price_base(dt: Union[datetime.datetime, datetime.date]) float
Return the price in base currency on a given valuation date.
- Parameters
dt – Input date/datetime.
- Returns
float.
-
valuation_price_history(ccy: Optional[str] = None, field: Optional[str] = None, history_fill: Optional[bool] = None) pandas.core.frame.DataFrame
Return a history of valuation (available for each weekday) prices.
- Parameters
ccy – Currency string identifier.
field – History field.
history_fill – Should gaps in history be forward filled?
- Returns
Valuation history.
-
valuation_price_series(dts: list[datetime.datetime], ccy: Optional[str] = None, intraday_data: Optional[bool] = True) pandas.core.series.Series
Series of prices at the gives date-times.
- Parameters
dts – List of date times
ccy – Currency string identifier
intraday_data – Use intraday data (optional, default True).
- Returns
Valuation price series
-
property valuation_time
Valuation time for the instrument.
-
property valuation_tzinfo
Valuation timezone info.
-
wait_for_live_data(period: Optional[Union[datetime.datetime, str]] = None)
Waits until live data is collected up to and including env.asofdatetime :param period: period of the live intraday data to wait for (defaults to 1 minute)
-
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
-
country: Literal['US', 'DE', 'GB', 'JP', 'FR', 'IT', 'ES', 'BE', 'CA', 'SE', 'NO']
-
coupon: float
-
coupon_type: Literal['FIXED', 'FLOATING', 'ZERO_COUPON', 'INDEX_LINKED']
-
coupon_frequency: Literal['ANNUAL', 'SEMI_ANNUAL', 'QUARTERLY']
-
issue_date: dtm.date
-
issuer: str
-
maturity_date: dtm.date
-
first_coupon_date: dtm.date
-
int_acc_date: dtm.date
-
redemption_amount: float
-
day_count: Literal['ACT/ACT', 'ACT/360', 'ACT/365F', '30/360', '30E/360', 'ACT/365_NL', 'ACT/366']
-
isin: Optional[str]
-
description: Optional[str]
-
days_to_settle: Optional[int]
-
first_settle_date: Optional[dtm.date]
-
series_number: Optional[str]
-
calc_type: Optional[int]
-
db_history_end_date: Optional[dtm.date]
-
tax_withholding: Optional[float]
-
activity_fields: Optional[list[str]]
-
group_name: Optional[str]
-
currency: str
-
ticker: Optional[str]
-
db_ticker: Optional[str]
-
db_sector: Optional[str]
-
price_factor: Optional[float]
-
use_price_factor: Optional[bool]
-
intraday_times: Optional[list]
-
intraday_tz_str: Optional[str]
-
instrument_id: Optional[int]