PositionsWrapper#

class sigtech.framework.strategies.components.positions_wrapper.PositionsWrapper

Interface to access positions of a strategy.

get_cash_valuation(dt: datetime.datetime, exclude_offset: bool = False)

Return value of cash positions in a strategy at a given time.

Parameters
  • dt – Datetime for cash holdings retrieval.

  • exclude_offset – exclude margin valuation offset positions, defaults to False.

Returns

Cash valuation in strategy currency.

get_cash_value(dt: datetime.datetime, name: str)

Return cash held by the strategy at a given time.

Parameters
  • dt – Datetime for cash holdings retrieval.

  • name – Cash name i.e 'USD CASH'.

Returns

Cash amount.

valuation(dt: datetime.datetime, ccy: str)

Valuation of the strategy holdings in the specified currency.

Parameters
  • dt – Valuation datetime.

  • ccy – Valuation currency.

Returns

Valuation result.

data(dt: datetime.datetime)

Return position dictionary for the strategy.

Parameters

dt – Datetime for positions.

Returns

Dictionary of positions.

orders_alive(dt: datetime.datetime)

Return list of orders alive for the strategy.

Parameters

dt – Datetime for positions.

Returns

List of orders alive.

split_strategy_orders(dt: datetime.datetime, parent=None)

Separate strategy order positions from actual.

Parameters
  • dt – Datetime for positions.

  • parent – Parent timeline.

Returns

Tuple containing current_positions, current_cash, sub_timeline.

get_instrument_units(dt: datetime.datetime, name: str)

Obtain number of units in the given name position of the strategy - whether cash or instruments.

Parameters
  • dt – Datetime for positions.

  • name – Name to compute the units for.

Returns

Units in requested name.

get_future_positions(dt: datetime.datetime)

Get instrument positions held or ordered by the strategy.

Parameters

dt – Datetime for positions.

Returns

Dictionary of positions.

get_future_instrument_units(dt: datetime.datetime, name: str, execution_limit_dt: Optional[datetime.datetime] = None)

Get instrument positions held or ordered by the strategy.

Parameters
  • dt – Datetime for positions.

  • name – Name to compute the units for.

  • execution_limit_dt – Execution datetime to limit contributing orders, ignored if None.

Returns

Dictionary of positions.

get_future_bottom_level_positions(dt: datetime.datetime)

Get instrument positions held or ordered by the strategy on the lowest level.

Parameters

dt – Datetime for positions.

Returns

Dictionary of positions.

get_bottom_level_positions(dt: datetime.datetime)

Get instrument positions held by the strategy on the lowest level.

Parameters

dt – Datetime for positions.

Returns

Dictionary of positions.

iterate_cash_positions(dt: datetime.datetime)

Iterate over all the cash in the strategy positions at a given time.

Parameters

dt – Datetime for positions.

Returns

Iterable of cash positions.

iterate_instruments(dt: datetime.datetime)

Iterate over all the instruments in the strategy positions at a given time.

Parameters

dt – Datetime for positions.

Returns

Iterable of instruments.

iterate_bottom_instruments(dt: datetime.datetime)

Iterate over all the instruments in the strategy lowest level positions at a given time.

Parameters

dt – Datetime for positions.

Returns

Iterable of instruments.

iterate_bottom_cash(dt: datetime.datetime)

Iterate over all the cash in the strategy lowest level positions at a given time.

Parameters

dt – Datetime for positions.

Returns

Iterable of cash.

get_exposure_weight(dt: datetime.datetime, bottom_level: bool = False, label: Optional[str] = None) dict

Retrieve a dict of instrument weights for a specified datetime.

Parameters
  • dt – Datetime for weights.

  • bottom_level – If True weights are returned for the bottom level. Default is False.

  • label – Grouping label to apply (default is None).

Returns

dict of instrument weights.