RollingAssetSwap#

class sigtech.framework.strategies.structure_basket_strategies.RollingAssetSwap deprecated

Deprecated class for Rolling asset swap strategy.

action_datetimes(start_dt=None, end_dt=None, include_all_valuations=False)

Obtain a list of tz-aware datetimes for which an action on the strategy occurs in the range [start_dt, end_dt].

This includes all underlying strategy actions.

Parameters
  • start_dt – Start datetime (optional).

  • end_dt – End datetime (optional).

  • include_all_valuations – All valuation points are included in the list (optional, default is False).

Returns

Datetime.

add_break_point(dt)

Add decision that stops all further processing.

Parameters

dt – Stop datetime.

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
  • historypd.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.

add_fx_spot_trade(dt: datetime.datetime, over: str, under: str, notional: float, use_trading_manager_calendar: bool = True, execution_dt: Optional[datetime.datetime] = None)

Do an FX spot trade - will pay notional in under currency minus strike amount in over currency on the same day.

Parameters
  • dt – Reference datetime.

  • over – Over currency.

  • under – Under currency.

  • notional – Notional.

  • use_trading_manager_calendar – If true, the trading manager calendar is used.

  • execution_dt – Execution datetime (optional).

add_margin_cleanup(dt, instrument_class)

Add a process to clean up the margin at the specified datetime.

Parameters
  • dt – Reference datetime.

  • instrument_class – Type of instrument.

See also MarginCleanupProcessor for more details.

Background

When taking on exposure to e.g. a Future, an additional Margin instrument is introduced which is always worth 1 in a given currency. It represents the cumulative strike on a future, i.e. a future bought at 95 would be represented as a buy of a Future instrument and a short position of 95 of Margin.

Example of Margin cleanup process

Day 1

Researcher seeks 50% exposure to CLZ15 COMDTY which currently trades at USD 100.00.

Order is generated which collapses into:
  • +5 units to CLZ15 COMDTY

  • -5 * 100 = USD -500.00 to USD Margin instrument

Strategy NAV: USD 1000.00

Day 2

Market for CLZ15 COMDTY moves to USD 105.00.

Position table before Margin cleanup:

Position table at start of Day 2#

Instrument

Units

Price in USD

Exposure

USD Cash

1000

1.00

1000.00

CLZ15 COMDTY

5

105.00

525.00

USD Margin

-500

1.00

-500.00

The Margin cleanup process does the following:
  • margin_real = future_units * future_price_T_2 + margin_units * price_margin_T_2 = USD 25.00

  • Add margin_real to the Cash instrument

  • Subtract margin_real from the USD Margin instrument

Position table after Margin cleanup:

Position table at start of Day 2#

Instrument

Units

Price in USD

Exposure

USD Cash

1025

1.00

1025.00

CLZ15 COMDTY

5

105.00

525.00

USD Margin

-525

1.00

-525.00

Strategy NAV: USD 1025.00

Day 3

Market for CLZ15 COMDTY moves down to USD 102.50. Researcher seeks to increase exposure to 80% based on price from Day 2.

Order is generated which collapses into:
  • +2.81 (1025 * 0.8 / 105 - 5) units to CLZ15 COMDTY

  • -2.81 * 102.5 = USD -288.03 to USD Margin instrument

Position table before Margin cleanup:

Position table at start of Day 2#

Instrument

Units

Price in USD

Exposure

USD Cash

1025

1.00

1025.00

CLZ15 COMDTY

7.81

102.50

800.53

USD Margin

-813.03

1.00

-813.03

The Margin cleanup process does the following (same as in Day 2):
  • margin_real = USD -12.50

  • Add margin_real to the Cash instrument

  • Subtract margin_real from the USD Margin instrument

Position table after Margin cleanup:

Position table at start of Day 2#

Instrument

Units

Price in USD

Exposure

USD Cash

1012.5

1.00

1012.50

CLZ15 COMDTY

7.81

102.50

800.53

USD Margin

-800.53

1.00

-800.53

Strategy NAV: USD 1012.50

add_method(dt: Union[datetime.date, datetime.datetime], method: object, *args: Any, use_trading_manager_calendar: Optional[bool] = True, priority: Optional[int] = None, **kwargs: Any) None

Add method processor.

Parameters
  • dt – Reference datetime.

  • method – Method to add. This needs to have a time as a first input.

  • use_trading_manager_calendar – If true, the Trading manager calendar is used.

  • priority – Optional integer priority value. Lower values have a higher priority and are run first. These values should be between 41 and 89. The default method priority is 50.

add_position_directly(dt: Union[datetime.date, datetime.datetime], instrument_name: str, units: float, unit_type: Optional[str] = 'MODEL')

Add a position to the holdings directly.

Parameters
  • dt – Reference date or datetime.

  • instrument_name – Instrument name string.

  • units – Additional relative units for allocation to instrument_name.

  • unit_type – Units used for quantity ('MODEL', 'TRADE'). Optional, if None uses default unit type from the strategy: 'MODEL'. See Strategy for more details.

add_position_target(dt: Union[datetime.date, datetime.datetime], instrument_name: str, units: float, execution_dt: Optional[datetime.datetime] = None, size_date: Optional[Union[datetime.date, datetime.datetime]] = None, transaction_type: Optional[str] = 'outright', transaction_priority: Optional[int] = 20, payment_currency: Optional[str] = None, use_trading_manager_calendar: Optional[bool] = None, unit_type: Optional[str] = None, sizing_method: Optional[str] = None, incomplete_order_callback: Optional[collections.abc.Callable] = None, incomplete_order_callback_kwargs: Optional[dict] = None) None

This function will schedule a decision on the queue. Further downstream it triggers an order in the timeline at the decision datetime and a position entry/change at the execution datetime.

Parameters
  • dt – decision datetime.

  • instrument_name – instrument name string.

  • units – target units for allocation to instrument_name.

  • execution_dt – desired execution datetime to achieve target weight - defaults to instrument’s valuation point - must be after decision datetime.

  • size_date – reference date used in model weight to unit calculation - always before decision datetime.

  • transaction_type – type of trade (for example outright, roll, etc.) - impacts transaction costs.

  • transaction_priority – determines priority in the decision queue if more than one decision is scheduled at the same time.

  • payment_currency – cash currency that is used to execute trade.

  • use_trading_manager_calendar – Include trading manager calendar in decision time. If not supplied, defaults to False if execution_dt is supplied as a datetime, otherwise True.

  • unit_type – Units used for quantity ('MODEL', 'TRADE', 'PV01', 'WEIGHT'). Optional, if None uses default unit type from the strategy: 'MODEL'. See Strategy for more details.

  • sizing_method – Name of method of instrument or strategy to compute the size based on custom units, or a callable. Optional, None by default. See Strategy for more details.

  • incomplete_order_callback – function that will be called if the trade pricer is unable to execute the desired number of units

  • incomplete_order_callback_kwargs – additional arguments to be passed to the callback

Returns

None.

add_trade(dt: Union[datetime.date, datetime.datetime], instrument_name: Union[str, type], units: float, execution_dt: Optional[datetime.datetime] = None, transaction_type: Optional[str] = 'outright', transaction_priority: Optional[int] = 20, payment_currency: Optional[str] = None, unit_type: Optional[str] = None, sizing_method: Optional[str] = None, use_trading_manager_calendar: Optional[bool] = None, incomplete_order_callback: Optional[collections.abc.Callable] = None, incomplete_order_callback_kwargs: Optional[dict] = None, **kwargs)

This function will schedule a decision on the queue. Further downstream it triggers an order in the timeline at the decision datetime and a position entry/change at the execution datetime.

Parameters
  • dt – Decision datetime.

  • instrument_name – Instrument class (for OTC trading) or instrument name string.

  • units – Additional relative units for allocation to instrument_name.

  • execution_dt – Desired execution datetime to achieve target weight - defaults to instrument’s valuation point - must be after decision datetime.

  • transaction_type – Type of trade (for example outright, roll, etc.) - impacts transaction costs.

  • transaction_priority – Determines priority in the decision queue if more than one decision is scheduled at the same time.

  • payment_currency – Cash currency that is used to execute trade.

  • unit_type – Units used for quantity ('MODEL', 'TRADE', 'PV01', 'WEIGHT'). Optional, if None uses default unit type from the strategy: 'MODEL'. See Strategy for more details.

  • sizing_method – Name of method of instrument or strategy to compute the size based on custom units, or a callable. Optional, None by default. See Strategy for more details.

  • use_trading_manager_calendar – Include trading manager calendar in decision time. If not supplied, defaults to False if execution_dt is supplied as a datetime, otherwise True.

  • incomplete_order_callback – function that will be called if the trade pricer is unable to execute the desired number of units

  • incomplete_order_callback_kwargs – additional arguments to be passed to the callback

For the keyword arguments specific to each type of OTC instrument, please call the print_add_trade_kwargs() method on the respective instrument class, e.g. FXForward.print_add_trade_kwargs().

Returns

None.

after_build_func()
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 analytics

Return an AnalyticsWrapper interface for strategy analytics.

ann01_series()

Return the modified duration timeseries.

property asset_description: str

String representing the underlying asset, or None if no assets exist.

property available_data_points: Optional[list[sigtech.framework.infra.data_adapter.common.DataPoint]]

Available data points for this object.

available_data_providers(entitled_only=True) Optional[List[str]]

Available data providers for this object. Bool to return entitled providers only

property base_name

Primary name used to identify the object.

bd_schedule()

Business days schedule for the strategy.

bond_field_series(field)

Timeseries of a field of the underlying bond.

Parameters

field – History field.

Returns

pandas Series.

build(progress=False) None

Build the strategy timeline.

Parameters

progress – Add a progress bar (default is False).

property built

Check if this strategy has already been built.

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.

calculation_end_date()

Adjusted end date for any calculations.

calculation_end_dt()

Valuation dt on the last day.

calculation_start_date()

Adjusted start date for any calculations.

calculation_start_dt()

Adjusted start dt for any calculations.

calendar_schedule()

Return the schedule for every business day for this strategy.

carry_roll_down(d: datetime.date, dates: Union[str, datetime.date, list[Union[str, datetime.date]]])

Compute carry and roll-down of underlying instruments and sum for the structure basket by moving the valuation date forward to the requested dates. Alternatively call carry_roll_down methods on each of the underlying separately (e.g. on Bond, Swap, etc.) to specify additional parameters.

Parameters
  • d – Valuation date.

  • dates – String/date or a list of strings/dates for which the carry/roll-down is needed.

Returns

pd.DataFrame

cash_weight_remaining(dt, positions)

Evaluate the remaining notional weight (assuming no leverage).

Parameters
  • dt – Reference datetime.

  • positions – Strategy positions.

Returns

Remaining notional weight.

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.

clear_caches()

Clear the cached attributes and history for the strategy.

clone_object(params: Optional[dict] = None)

Return a clone of the strategy with amended parameters.

Parameters

params – New kwargs in dict format.

Returns

Clone of the strategy with amended parameters.

clone_strategy(params: dict = None, allow_unregistered: bool = True) deprecated

Return a clone of the strategy with amended parameters.

Parameters
  • params – New kwargs in dict format.

  • allow_unregistered – Whether or not to allow unregistered classes (optional, default is True).

Returns

Clone of the strategy with amended parameters.

compare_inputs(other, keys_only=False)

Return the differences in initial settings between two strategies.

Parameters
  • other – Strategy to compare with.

  • keys_only – Return only the keys of the different settings (optional, default is False).

Returns

DictDiff.

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 or COLUMNAR.

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.

decision_dt_from_date(d, use_trading_manager_calendar=True)

Returns UTC datetime for the given date d by appending _decision_time. If _decision_time is not specified it defaults to the business start time of the TradingManager (trader). Input date is adjusted forward to a trader business date if needed.

Parameters
  • d – Input date.

  • use_trading_manager_calendar – If true, the trading manager calendar is used.

Returns

Datetime.

decision_dt_from_execution_dt(execution_dt)

Return the latest acceptable decision datetime for the given execution datetime. If needed, the decision datetime is rolled back to a valid trader business day.

Parameters

execution_dt – Execution datetime.

Returns

Datetime.

property decision_start_date

First (local) decision date of the strategy.

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

Dependency type

direction_id_long()

String name for long direction in strategy name.

direction_id_short()

String name for short direction in strategy name.

property dynamic_config

Load an associated configuration object from the object register.

earliest_start_date()

Earliest possible date where all dependencies can be computed.

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.

execution_dt_from_date(instrument, d)

Return the valuation point of the instrument for the given input date. If needed, the date is adjusted forward to a valid business day for the instrument.

Parameters
  • d – Input datetime.

  • instrument – Target instrument object to be traded.

Returns

Datetime.

execution_dt_from_datetime(instrument, dt)

Return the earliest execution point of the instrument after the input decision datetime.

Parameters
  • dt – Input datetime.

  • instrument – Target instrument object to be traded.

Returns

Datetime.

property execution_time

Execution time for orders created by this strategy. If execution_time_input is not given, this defaults to 4pm.

property execution_tzinfo

Timezone for the execution time for the orders created by this strategy. If execution_timezone_input is not provided, this defaults to Europe/London.

expanded_section_slice(dt, section_level=1, flatten_level=100, scale_unit=1.0, separate=False)

Return a portfolio slice for a given datetime and section.

Parameters
  • dt – Reference datetime.

  • section_level – Section level (optional, default is 1).

  • flatten_level – Flatten level (optional, default is STRATEGY_MAX_TREE_LEVEL).

  • scale_unit – Scale unit (optional, default is 1.0).

  • separate – Strategy orders can be split (optional, default is False).

Returns

PortfolioTree.

expanded_slice(dt, level=100, order_only=False, scale_unit=1.0, separate=False)

Return an expanded portfolio slice for a given datetime and level.

Parameters
  • dt – Reference datetime.

  • level – Reference level (optional, default is STRATEGY_MAX_TREE_LEVEL).

  • order_only – Include the orders only (optional, default is False).

  • scale_unit – Scale unit (optional, default is 1.0).

  • separate – Strategy orders can be split (optional, default is False).

Returns

PortfolioTree.

expanded_slice_t(dt, timeline=None, level=100, order_only=False, scale_unit=1.0, separate=False)

Return an expanded portfolio slice for a given datetime, timeline and level.

Parameters
  • dt – Reference datetime.

  • timeline – Reference timeline (optional).

  • level – Reference level (optional, default is STRATEGY_MAX_TREE_LEVEL).

  • order_only – Include the orders only (optional, default is False).

  • scale_unit – Scale unit (optional, default is 1.0).

  • separate – Strategy orders can be split (optional, default is False).

Returns

PortfolioTree.

expanded_timeline(full_timeline=False)

Return strategy timeline - expanded.

Parameters

full_timeline – Include the positions changes (not just the order execution points).

Returns

Tree timeline.

property expiry_date: datetime.date

Date when the 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.

finalize_for_comparison()

Method to call to ensure all data dict values are finalized prior to doing object comparisons.

property first_entry_date

First date to use for trading.

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_exposure_weight(instrument, quantity, size_dt)

Evaluate the notional exposure for a specified instrument, quantity and date.

Parameters
  • instrument – Input instrument.

  • quantity – Input quantity.

  • size_dt – Input date.

Returns

Exposure weight.

classmethod get_names(sort_by_group: Optional[bool] = False, include_db: Optional[bool] = False, include_local: Optional[bool] = True, include_children: Optional[bool] = True, 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 (ignored for strategies).

  • 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 True).

  • ignore_unmapped – If set, ignore errors due to unmapped database objects (default is True).

Returns

List of object names.

get_weight(dt, instrument_name, positions, size_date=None, execution_dt=None)

Get the actual weight for the desired instrument.

Parameters
  • dt – Reference datetime.

  • instrument_name – Instrument identifier.

  • positions – Strategy positions.

  • size_date – Size date for weight calculation (optional).

  • execution_dt – Execution date (optional).

Returns

Actual weight.

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_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

html_report()

Abstract method to add a custom html report to the strategy. This can be viewed when deployed.

The method should return a html string.

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 inspect

Return an InspectWrapper interface to inspect positions and actions of a strategy.

instrument_execution_dt_from_datetime(instrument, dt)

Return the earliest execution point of the instrument after the input decision datetime.

Parameters
  • dt – Input datetime.

  • instrument – Target instrument object to be traded.

Returns

Datetime.

property instrument_type

Classification using class name of strategies.

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 to self.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 to self.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

The intraday fields of history available for this strategy.

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.

is_total_return()

Check if this strategy is total return or excess return.

property is_unmapped

Check if the object is not mapped.

property live_supported: bool

Flag for live supported objects.

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.

netted_trade_price(dt, trade_sign, include_trading_costs=True, transaction_type=None, currency=None)

Netted version of the trading price for this strategy on a given day.

Parameters
  • dt – Reference 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 the type of transaction, e.g. ‘outright’, ‘roll’.

  • currency – Currency string stub.

Returns

Trade price.

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 order_transform

Retrieve timeline order transform - This sets the OrderTransform which manipulates placed orders.

property plot

Return a PlotWrapper interface to produce plots for the strategy.

property positions

Return a PositionsWrapper interface for strategy position calculations.

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.

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 and data_source. To get the list of available fields for an object you can use the data_dict() method.

property product_type

Return the product_type property of this object.

publication_delay() str

Publication delay of data for this instrument.

push_process(process)

Add a given process to the strategy queue.

Parameters

process – Input process.

realign_history(series)

Realign history series to proper business days.

Parameters

series – Input series.

Returns

Realigned history series.

roll_adjusted_yield()

Return the underlying bonds yields adjusted by the roll pick up (i.e. difference between rolled out bonds yield, and rolled in bond yield for each roll date).

rolling_schedule()

Return roll schedule.

rounded_units(units, dt, to_trade=True)

If rounding is enabled only whole strategy units can be traded.

This is to be sure that the expanded positions are all tradable regardless of later increases or closing of underlying positions.

For the instantaneous value we look at the possible rounded constituents and the maximum allowed contained position.

Note: This estimate is only an approximation since it may assume fractional holdings in positions.

For an example,

Consider a sub-strategy that holds 100 future contracts at time T. It then closes out one contract to have 99 at T+1.

A strategy wants to trade 0.01 units of this sub-strategy at T. For that instant the rounded_units can allow 0.01 units. However, if it were executed the position wouldn’t be valid at T+1.

To allow arbitrary sub-strategy behaviour only whole strategy units can be traded.

Parameters
  • units – Number of units.

  • dt – Reference datetime.

  • to_trade – Cast the number of units to lower round (default is True).

Returns

Rounded units.

schedule_information()

Return the schedule information for this group.

property sector

Sector used on BBG, or the class ID for SIG instruments.

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.

shaken_timeline(full_timeline=False)

Return strategy timeline - shaken.

Parameters

full_timeline – Include the positions changes (not just the order execution points).

Returns

Tree timeline.

short_version(use_db=True)

Short version of this strategy.

Parameters

use_db – The strategy is loaded from a database (optional, default is True).

Returns

Strategy.

size_date_from_date(d)

Return the previous strategy data point as a datetime to the valuation date.

Parameters

d – Valuation date.

Returns

Datetime.

size_date_from_decision_dt(decision_dt)

Returns the previous strategy data point to the valuation date where the decision datetime falls in.

Parameters

decision_dt – Decision datetime.

Returns

Datetime.

size_dt_from_date(d)

Returns the previous strategy data point as a date to the valuation date.

Parameters

d – Valuation date.

Returns

Datetime.

size_dt_from_decision_dt(decision_dt)

Return the previous strategy data point to the valuation date where the decision datetime falls in.

Parameters

decision_dt – Decision datetime.

Returns

Datetime.

property size_time

Time point used to calculate the sizing. This is used to imply the correct data point. If not supplied, the close time from the trading manager is used.

property size_type

Type of trade size, either units or notional.

property size_tzinfo

Timezone of the time point used to calculate the sizing. This is used to imply the correct data point. If not supplied, the default timezone from the trading manager is used.

sizing_price(sizing_dt: datetime.datetime, ccy: Optional[str] = None, execution_dt: Optional[datetime.datetime] = None) float

On the base class this is just the valuation price, but can be overwritten in derived classes For specific instrument, price on sizing date (eg T-1), isn’t necessarily the best approximation for today’s price if the market doesn’t move.

For instance, for bonds, if coupon is to be paid on Settlement(T), then today’s price would be approximately yesterday price - coupon.

Parameters
  • sizing_dt – Sizing datetime

  • ccy – Currency string identifier

  • execution_dt – Execution datetime

Returns

Sizing price used in weight to model unit calculations

slice(dt)

Return a flat top-level slice for a given datetime.

Parameters

dt – Reference datetime.

Returns

Portfolio.

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).

starting_currency()

The currency we start with in the wallet on the first day.

strategy_dt_list(dts, start_dt=None, end_dt=None, build=True, tzinfo=None)

List of strategy datetimes.

Parameters
  • dts – Valuation datetimes.

  • start_dt – Start datetime (optional).

  • end_dt – End datetime (optional).

  • build – Boolean flag to build the strategy first (optional, default is True).

Returns

list.

strategy_extension(from_dt: datetime.datetime, to_dt: datetime.datetime)

Update the strategy contents for an expanded history. It should be replaced if a short run’s process initialization is not equivalent to continuing the strategy.

Parameters
  • from_dt – Start datetime for history expansion.

  • to_dt – End datetime for history expansion.

strategy_initialization(dt)

Initial decision run on the start date of the strategy.

Parameters

dt – Reference datetime.

strategy_order_execution_dt_from_datetime(strategy, dt)

Return the earliest execution point of the strategy after the input decision datetime.

Parameters
  • dt – Input datetime.

  • strategy – Target strategy object to be traded.

Returns

Datetime.

property strategy_timeline

Retrieve the strategy timeline and, if missing, create the strategy timeline.

suggested_next_run_time(asof=None)

Suggested next time to run the strategy to capture the next actions.

This defaults to the decision time on each business day.

Parameters

asof – Input as-of-date.

Returns

Datetime.

property supplementary_fields: list[str]

Additional fields available for the group.

textual_representation()

Return a printable representation of this object.

property timeline_holdings

Build the strategy and return the holdings.

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

Traded price for a strategy.

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 the 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_price_override()

Mechanism to manually override trading price calculations.

trade_schedule()

Return the trading schedule for this strategy.

tree(timeline, end_dt, full_timeline=False)

Return a tree timeline.

Parameters
  • timeline – Input timeline.

  • end_dt – End datetime.

  • full_timeline – Include the positions changes (not just the order execution points).

Returns

Tree timeline.

tree_slice(dt, separate=False)

Return a portfolio slice for a given datetime.

Parameters
  • dt – Reference datetime.

  • separate – Strategy orders can be split (optional, default is False).

Returns

PortfolioTree.

tree_timeline(full_timeline=False)

Return strategy timeline - tree.

Parameters

full_timeline – Include the positions changes (not just the order execution points).

Returns

Tree timeline.

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()

Validate strategy instrument.

valuation_dt(d: datetime.date) datetime.datetime

Valuation dt - datetime for a given valuation date.

valuation_point()

The time strategy is valued.

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

Time point used as for valuations in this strategy. If the valuation_time_input is not given, it is set to 23:59:59.

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)

yield_series(adjusted=True)

Return the yield timeseries.

Parameters

adjusted – If False, the underlying bonds yield to maturity timeseries is returned. If True, the yields are adjusted by the roll pick up (i.e. difference between rolled out bonds yield, and rolled in bond yield).

Returns

Yield timeseries.

notional: Optional[float]
unit_type: Optional[str]
rolling_frequencies: Optional[list]
trade_out_end: Optional[bool]
currency: Optional[str]
country: str
tenor: str
roll_offset: Optional[int]
roll_offset_from_data_start: Optional[bool]
run_type: Optional[str]
is_repo: Optional[bool]
repo_source: Optional[str]
raw_otr_series: Optional[pd.Series]
reduce_bond_histories: Optional[bool]
decision_time_input: Optional[dtm.time]
decision_timezone_input: Optional[str]
size_time_input: Optional[dtm.time]
size_timezone_input: Optional[str]
execution_time_input: Optional[dtm.time]
execution_timezone_input: Optional[str]
total_return: Optional[bool]
include_trading_costs: Optional[bool]
direction: Optional[Literal['long', 'short']]
order_type: Optional[Literal['group', 'split', 'auto']]
proforma_ticker: Optional[str]
additional_initial_holdings: Optional[list[Union[tuple[str, float], tuple[str, float, str]]]]
set_weight_from_initial_cash: Optional[bool]
set_weight_from_sizing_quantity: Optional[bool]
use_long_cash: Optional[bool]
record_fx_trades: Optional[bool]
default_sizing_method: Optional[Union[Callable, str]]
trade_wrapper: Optional[StopTrigger]
initial_cash: Optional[float]
strategy_sizing_quantity: Optional[float]
start_date: Optional[dtm.date]
end_date: Optional[dtm.date]
start_dt: Optional[dtm.datetime]
end_dt: Optional[dtm.datetime]
ramp_up_period_end: Optional[dtm.date]
description: Optional[str]
strategy_status: Optional[str]
strategy_label: Optional[str]
valuation_time_input: Optional[dtm.time]
valuation_timezone_input: Optional[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]