PositionsWrapper

PositionsWrapper#

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

Interface to access positions of a strategy.

data(dt: datetime)

Return position dictionary for the strategy.

Parameters:

dt – Datetime for positions.

Returns:

Dictionary of positions.

get_bottom_level_positions(dt: datetime)

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

Parameters:

dt – Datetime for positions.

Returns:

Dictionary of positions.

get_cash_valuation(dt: 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, 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.

get_exposure_weight(dt: datetime, bottom_level: bool = False, label: 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.

get_future_bottom_level_positions(dt: datetime)

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

Parameters:

dt – Datetime for positions.

Returns:

Dictionary of positions.

get_future_instrument_units(dt: datetime, name: str, execution_limit_dt: 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_positions(dt: datetime)

Get instrument positions held or ordered by the strategy.

Parameters:

dt – Datetime for positions.

Returns:

Dictionary of positions.

get_instrument_units(dt: 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.

iterate_bottom_cash(dt: 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.

iterate_bottom_instruments(dt: 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_cash_positions(dt: 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)

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

Parameters:

dt – Datetime for positions.

Returns:

Iterable of instruments.

orders_alive(dt: datetime)

Return list of orders alive for the strategy.

Parameters:

dt – Datetime for positions.

Returns:

List of orders alive.

split_strategy_orders(dt: 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.

valuation(dt: datetime, ccy: str)

Valuation of the strategy holdings in the specified currency.

Parameters:
  • dt – Valuation datetime.

  • ccy – Valuation currency.

Returns:

Valuation result.