PlotWrapper#

class sigtech.framework.strategies.components.plot_wrapper.PlotWrapper

Interface to produce various plots for a strategy.

tree(dt: Optional[datetime.datetime] = None, truncate_string: Optional[int] = 20, tzinfo: Optional[pytz.tzinfo.BaseTzInfo] = None, flatten: Optional[bool] = False, unit_type: Optional[str] = 'MODEL', flatten_strategy_orders: Optional[bool] = False)

Generate a Javascript interactive plot of the strategies contents for a specified datetime.

The unit type refers to the type of quantity shown, with the options:

  • 'MODEL' - Use the internal model units.

  • 'TRADE' - Trade size, the units types vary between instruments and given by their position_type property.

Parameters
  • dt – Datetime for plot, if no times is provided the portfolio for the calculation end time is shown.

  • truncate_string – Length to truncate strategy names.

  • tzinfo – Timezone for time display (optional, the default takes the environment’s display timezone).

  • flatten – Boolean flag to flatten the strategies and merge the positions.

  • unit_type – Units used for quantity, defaults to 'MODEL'.

  • flatten_strategy_orders – Boolean flag to flatten only the strategy orders and merge the positions.

portfolio_table(dts: Optional[Union[str, datetime.datetime, list[datetime.datetime]]] = None, tzinfo: Optional[pytz.tzinfo.BaseTzInfo] = None, flatten: Optional[bool] = False, start_dt: Optional[datetime.datetime] = None, end_dt: Optional[datetime.datetime] = None, unit_type: Optional[str] = 'MODEL', as_df: bool = False, str_format: bool = True, flatten_strategy_orders: bool = False)

Generate a html table of the portfolio over a range of dates.

If no times are provided the portfolio for the calculation end time is shown.

To prevent display lag the number of times is limited to 100.

Options for the dts, as a string, include:

  • 'VALUATION_PTS' - Valuation points.

  • 'ACTION_PTS' - Every point where the strategy simulation performs an action on any level.

  • 'TOP_ORDER_PTS' - Points where the strategy enters and executes top level orders.

  • 'TOP_POSITION_CHG_PTS' - Points where the strategy’s top level holdings change.

  • 'EXECUTION_PTS' - Points where orders are executed.

  • 'HOLDING_CHG_PTS' - Points where the strategy’s top level holdings change (excluding orders).

The unit type refers to the type of quantity shown, with the options:

  • 'MODEL' - Use the internal model units

  • 'TRADE' - Trade size, the units types vary between instruments and given by their position_type property.

Parameters
  • dts – Datetime, iterable of Datetimes or String to identify times to include.

  • tzinfo – Timezone for time display (optional, the default takes the environment’s display timezone).

  • flatten – Boolean flag to flatten the strategies and merge the positions.

  • start_dt – Datetime for which times before are removed.

  • end_dt – Datetime for which times after are removed.

  • unit_type – Units used for quantity, defaults to 'MODEL'.

  • as_df – If set to True, return a DataFrame instead of an IPython object.

  • str_format – If set to False, and a DataFrame is returned, do not perform any string formatting.

  • flatten_strategy_orders – Boolean flag to flatten only the strategy orders and merge the positions.

Returns

IPython HTML object or pandas DataFrame.

timeline()

Generate an interactive representation of the strategy timeline.

performance(fallback: bool = False, aum: Optional[float] = None, profit_metrics_only: Optional[bool] = False)

Generate an interactive strategy widget that provides performance information.

Parameters
  • fallback – Flag to determine if we should use the previous visualisation.

  • aum – (Optional) Representative Assets Under Management value in units of the strategy currency. If passed, the strategy history is considered relative to this constant AUM level. E.g. Returns = (history[t+1] - history[t]) / aum.

  • profit_metrics_only – Flag to determine metrics using the currency P&L rather than percentage returns.

Returns