OptionsStrategyBase

OptionsStrategyBase#

class sigtech.framework.strategies.options_strategy_base.OptionsStrategyBase

Baseclasses: DailyStrategy

Subclasses: RollingOptionsStrategyBase, OptionsStrategy, StraddleOptionStrategy, StrangleOptionStrategy, SpreadOptionsStrategy, ButterflyOptionsStrategy

Base strategy class for trading options in a single options group.

It provides access to common option trading actions and analytics.

force_target_quantity: Optional[bool]
greek_neutral_nav_scale: Optional[float]
property groups

Groups this group belongs to.

property holidays

List of holiday calendars for this group.

is_imm_maturity: Optional[bool]
maturity: Union[date, str]
net_target_quantity: Optional[bool]
order_type: Optional[Literal['group', 'split', 'auto']]
price_listed_as_model: Optional[Literal['VolSurface', 'VolFromPrice']]
strike_type: Optional[Literal['Delta', 'Price', 'Premium', 'DN', 'DEFAULT', 'SPOT', 'FWD', 'Relative']]
t0_option_selection: Optional[bool]
target_maturity_weekday: FR: 4>]]
target_quantity: Optional[float]
target_type: Optional[Literal['Delta', 'Vega', 'Gamma', 'Theta', 'PV', 'Fixed', 'StrikeNotional', 'SpotNotional', 'StrikeNotionalAsProportionOfNAV', 'SpotNotionalAsProportionOfNAV', 'PVAsProportionOfNAV']]
use_first_entry_date: Optional[bool]
close_out_options(dt: datetime, group_name: str = None)

Action to close out the options in the strategy. This can be filtered based on the option group.

Parameters:
  • dt – Datetime of close out action.

  • group_name – String name of the option group to close out. If not specified, all options are closed.

greeks(fields=None, dates=None, dollar_greeks: Optional[bool] = False, include_future_positions: Optional[bool] = False, intraday: Optional[bool] = False, start_date: Optional[date] = None, end_date: Optional[date] = None, data_points: Optional[list] = None, net_greeks: Optional[bool] = True)

Information on the greeks for the options held in the strategy.

Parameters:
  • fields – List of greeks fields to output. If set to None, then Delta, Gamma and Vega are returned.

  • dates – dates/datetimes for which the greeks are computed. By default, the whole history dates at portfolio value time (23:59) are used.

  • dollar_greeks – provide dollar greeks, defaults to False.

  • include_future_positions – Boolean flag to include positions not yet traded (to get rough estimate of how much greeks will be needed in total to hedge overall position, once traded), defaults to False.

  • intraday – Boolean flag to get intraday greeks, defaults to False.

  • start_date – Start date - used if later than default start date, only if dates are not passed (optional).

  • end_date – End date - used if earlier than default end date, only if dates are not passed (optional).

  • data_points – Use data points induced valuations for intraday greeks. intraday is set to True internally, if data_points not empty (optional).

  • net_greeks – Boolean flag to net greek values, defaults to True.

Returns:

pandas DataFrame.

metrics(fields=None, dates=None, dollar_greeks: Optional[bool] = False, include_future_positions: Optional[bool] = False, intraday: Optional[bool] = False, start_date: Optional[date] = None, end_date: Optional[date] = None, data_points: Optional[list] = None, net_greeks: Optional[bool] = True)

Collection of risk-based metrics for the options held in the strategy.

Parameters:
  • fields – List of fields to output. The default list is [‘NPV’, ‘Delta’, ‘Gamma’, ‘Vega’, ‘Theta’, ‘ImpliedVolatility’].

  • dates – dates/datetimes for which the greeks are computed. By default, the whole history dates at portfolio value time (23:59) are used.

  • dollar_greeks – provide dollar greeks, defaults to False.

  • include_future_positions – Boolean flag to include positions not yet traded (to get rough estimate of how much greeks will be needed in total to hedge overall position, once traded), defaults to False.

  • intraday – Boolean flag to get intraday greeks, defaults to False.

  • start_date – Start date - used if later than default start date, only if dates are not passed (optional).

  • end_date – End date - used if earlier than default end date, only if dates are not passed (optional).

  • data_points – Use data points induced valuations for intraday greeks. intraday is set to True internally, if data_points not empty (optional).

  • net_greeks – Boolean flag to net greek values, defaults to True.

Returns:

DataFrame of requested greeks (or NPV/ImpliedVolatility) per each day. The greeks are aggregated per underlying groups (second level column indexing is by group name). The NPV is for the whole strategy (second level index for NPV is the strategy name).

option_position_greeks(dt: datetime, field: str, dollar_greeks: Optional[bool] = False, size_date: Optional[Union[date, datetime]] = None, include_expiring: Optional[bool] = False, group_name: Optional[str] = None, split_by_underlying: Optional[bool] = False, intraday: Optional[bool] = False, include_future_positions: Optional[bool] = False, net_greeks: Optional[bool] = True)

Calculate the value of a specified greek for the options held in the strategy.

Parameters:
  • dt – datetime of point to calculate for.

  • field – Greek field.

  • dollar_greeks – provide dollar greeks, defaults to False

  • size_date – date/datetime override to use for greek calculation

  • include_expiring – Boolean flag to include options that expire of the day, defaults to False.

  • group_name – Name of the options group required. If None, a dictionary is returned.

  • split_by_underlying – Boolean flag to return dictionary indexed by options underlyings, e.g. different expiry futures, defaults to False.

  • intraday – Boolean flag to get intraday greeks, defaults to False.

  • include_future_positions – Boolean flag to include positions not yet traded (to get rough estimate of how much greeks will be needed in total to hedge overall position, once traded), defaults to False.

  • net_greeks – Boolean flag to net greek values, defaults to True.

Returns:

float, if group_name specified, otherwise dictionary indexed by group name.

output_option_execution_diagnostics(dt, positions=None)

Output diagnostics for executed option orders at a given datetime.

Parameters:
  • dt – Datetime to get diagnostics for.

  • positions

Returns:

Dataframe of diagnostics.

output_option_position_diagnostics(dt, positions=None)

Output T and T-1 diagnostics for option positions held at a given datetime.

Parameters:
  • dt – Datetime to get diagnostics for (T).

  • positions

Returns:

Dataframe of diagnostics.

portfolio_greeks(fields=None, dates=None, dollar_greeks: Optional[bool] = False, include_future_positions: Optional[bool] = False, intraday: Optional[bool] = False, start_date: Optional[date] = None, end_date: Optional[date] = None, data_points: Optional[list] = None) deprecated

Deprecated method returning information on the greeks for the options held in the strategy.

risk_matrix(value_date: date, shift_type: str = 'spot', num_steps: int = 5, max_shift_bps: float = 500.0, delta_from_base: bool = False) DataFrame

Get change in greeks for spot or implied vol shift.

Parameters:
  • value_date – Valuation date.

  • shift_type – (Optional) ‘spot’ or ‘vol’ shift, ‘spot’ by default.

  • num_steps – (Optional) number of scenarios to calculate for each positive and negative side, 5 by default.

  • max_shift_bps – (Optional) shift amount in bps for maximum scenario.

  • delta_from_base – (Optional) return metrics for new scenario (‘False’) or to return change from base case (‘True’).

Returns:

risk matrix DataFrame.

risk_scenario(shift_bps: float, shift_type: str = 'spot', delta_from_base: bool = False) DataFrame

Get time series of changes in greeks for spot or implied vol shift for specified shift.

Parameters:
  • shift_bps – Shift amount in bps for maximum scenario.

  • shift_type – (Optional) ‘spot’ or ‘vol’ shift, ‘spot’ by default.

  • delta_from_base – (Optional) return metrics for new scenario (‘False’) or to return change from base case (‘True’).

Returns:

risk scenario DataFrame.

schedule_information()

Return the schedule information for this group.

set_option_positions(dt, options: tuple, target_quantity: float = None, target_type: str = None, risk_size_date=None) None

Set ratio on position on a basket of options to achieve risk target.

When using risk targeting this method can be used to only trade one option group at a time.

Parameters:
  • dt – Decision datetime.

  • options – Tuple of (option object, value) pairs.

  • target_quantity – Target risk quantity, if None is passed no risk target is applied.

  • target_type – Type of risk target, options are 'Vega', 'Delta', 'Gamma', 'Theta', 'PV', 'Fixed', 'StrikeNotional', 'SpotNotional', 'StrikeNotionalAsProportionOfNAV', or 'SpotNotionalAsProportionOfNAV'.

  • risk_size_date – Date override to use for the risk sizing calculation.