AnalyticsWrapper

AnalyticsWrapper#

class sigtech.framework.strategies.components.analytics_wrapper.AnalyticsWrapper

Interface for strategy analytics.

approximate_rounding_impact(initial_aum=None, include_costs=None)

Approximate the percentage impact of position rounding vs the model strategy.

It is only an approximation due to deviations in the cash returns that would be held and trades are treated as outright executions. The deviations in return also don’t compound.

Parameters:
  • initial_aum – Initial AUM of the strategy to model (optional).

  • include_costs – Include trading costs (optional).

Returns:

Timeseries of estimated rounded return divided by the model return for every datetime.

approximate_rounding_summary(lower_aum_log10=4, upper_aum_log10=8, steps=5, include_costs=None)

Evaluate an approximate summary of the impact of sizing on the strategies returns.

It is only an approximation due to deviations in the cash returns that would be held and trades are treated as outright executions. The deviations in return also don’t compound.

Returns a summary of the correlation and deviation in returns between the rounded strategy and the model.

Parameters:
  • lower_aum_log10 – Lower aum range log 10 (default: 4).

  • upper_aum_log10 – Upper aum range log 10 (default: 8).

  • steps – Upper number of steps toe take (default: 5).

  • include_costs – Include trading costs.

Returns:

DataFrame of summary.

cash_turnover(tzinfo: Optional[BaseTzInfo] = None)

Calculate cash turnover series

Parameters:

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

Returns:

Pandas series

excess_return_history(start=None, end=None)

Excess return version of strategy as time series.

Parameters:
  • start – Start date.

  • end – End date.

Returns:

pandas Series.

intraday_turnover(levels=100, group_by_instrument_type=True, tzinfo: Optional[BaseTzInfo] = None)

Calculate the turnover of the strategy - all time points will be included

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

  • group_by_instrument_type – Group results by type of instrument (optional, default is True).

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

Returns:

pandas DataFrame.

pnl_breakdown(levels=0, start_date=None, end_date=None, ccy=None, period=None, loc_label=False, implied_costs=False, filter_negligible=False, intraday_analytics=False, intraday_data=None, label=None, tzinfo: Optional[BaseTzInfo] = None)

Run a breakdown of the daily pnl contributions and collect to give rolling/total pnl result. :param levels: Reference level. :param start_date: Start date (optional). :param end_date: End date (optional). :param ccy: Currency identifier (optional). :param period: Input period (optional). :param loc_label: Add path column labels (optional, default is False). :param implied_costs: Separate transaction costs and slippage down to the level specified (optional, default is False). :param filter_negligible: Do not return negligible weights (optional, default is False). :param intraday_analytics: if true provide PnL/weights at every action datetime, else provide daily data as per the history schedule (optional, default is False. If True, then intraday_data will also be set to True). :param intraday_data: if true use intraday data for valuations (optional, default False if strategy is a DailyStrategy, True otherwise). Please note that setting this to False may lead to slippage numbers as only daily valuations will be used in the case of intraday strategies or daily strategies with different valuation times being used in the same multilevel strategy. :param label: Grouping labels. The options are listed by sig.list_labels (optional). :param tzinfo: Timezone for time display (optional, the default takes the environment’s display timezone). :return: pnl breakdown.

relative_attribution(benchmark_strategy, mapping=None, benchmark_mapping=None, valuation_points=False, tzinfo: Optional[BaseTzInfo] = None)

Evaluate a Brinson attribution relative to a benchmark strategy.

Parameters:
  • benchmark_strategy – Benchmark strategy object.

  • mapping – Dictionary of category labels for positions in strategy.

  • benchmark_mapping – Dictionary of category labels for positions in benchmark.

  • valuation_points – Boolean flag, if True the attribution is given at valuation on each day.

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

Returns:

DataFrame of cumulative profit for each element given in strategy currency.

total_return_valuation_history(start=None, end=None, ccy=None)

Total return version of strategy as time series plus optional spot currency conversion.

Parameters:
  • start – Start date.

  • end – End date.

  • ccy – Currency identifier.

Returns:

pandas Series.

trades_statistics()

Compute the following statistics on trades: * trade count * win count * loss count * win/loss ratio * win probability * Kelly Criteria return: a dataframe

turnover(levels=100, group_by_instrument_type=True)

Calculate the turnover of the strategy, grouped by date

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

  • group_by_instrument_type – Group results by type of instrument (optional, default is True).

Returns:

pandas DataFrame.

turnover_stats(levels=100, group_by_instrument_type=True, start=None, end=None)

Calculate the strategy’s turnover by year per given level in the strategy.

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

  • group_by_instrument_type – Group results by type of instrument (optional, default is True).

  • start – Start date (optional).

  • end – End date (optional).

Returns:

pandas DataFrame.