DynamicOptionsStrategy#
-
class sigtech.framework.strategies.rolling_options_baskets.DynamicOptionsStrategy
Baseclasses:
RollingOptionsStrategyBase
Strategy trading a custom basket of options.
The options traded must be from the option groups specified by
group_name
input.Parameters are the same as in the base
RollingOptionsStrategyBase
.Additional attributes:
trade_dictionary
(dict): Dictionary of date, option basket pairs.basket_creation_method
(object): Method to call to determine options to trade.basket_creation_kwargs
(dict): Extra key word arguments for basket_creation_method. If the basket_creation_method has the parameters strike and maturity, these can be passed adding:basket_creation_kwargs
= {'strike'
:'SPOT'
,'maturity'
:'2M'
}group_name
(string): Name of the option group to trades options for.
The options traded can be passed in as a dictionary to trade_dictionary. The keys determine the trade dates.
For example:
import datetime as dtm fx_option_group = sig.obj.get('EURUSD OTC OPTION GROUP') trade_dictionary = {dtm.date(2010, 4, 7): { fx_option_group.get_option('Call', 1.3, dtm.date(2010, 4, 6), dtm.date(2011, 4, 6)) : 1, fx_option_group.get_option('Put', 1.3, dtm.date(2010, 4, 6), dtm.date(2011, 4, 6)) : -1 } } strat = sig.DynamicOptionsStrategy( currency=fx_option_group.over, start_date=dtm.date(2010, 1, 6), group_name=fx_option_group.name, end_date=dtm.date(2012, 1, 20), trade_dictionary=trade_dictionary ) strat.history()
Alternatively, a basket_creation_method function can be passed in which gets called on each roll dates and provides a dictionary or tuple of options to trade. The method should take the strategy, decision time and positions as input and provide a dictionary of options. Any additional parameters can be passed in as a dictionary to basket_creation_kwargs.
For example:
import datetime as dtm import numpy as np import pandas as pd def basket_creation_method(strategy, dt, positions, **additional_parameters): signal = additional_parameters['signal'] option_group = additional_parameters['option_group'] strike = additional_parameters['strike'] maturity = additional_parameters['maturity'] size_date = dt.date() d = pd.Timestamp(dt.date()) if d in signal.index: opt_type = 'Call' if signal.loc[d] >= 0 else 'Put' opt = option_group.get_option(start_date=size_date, option_type=opt_type, strike=strike, maturity=maturity) return {opt: 100} else: return {} index = sig.obj.get("SPX INDEX") spx_option_name = sig.obj.get('SPX INDEX OTC OPTION GROUP') signal = np.sign(index.history().pct_change()).dropna().loc['2022-01-01':'2022-03-05'] signal = signal[signal.shift() != signal] bc_params = {'signal': signal, 'option_group': spx_option_name, 'strike': 'SPOT', 'maturity': '2M'} strat = sig.DynamicOptionsStrategy( currency='USD', start_date=dtm.date(2022,1,1), group_name=spx_option_name.name, end_date=dtm.date(2022, 3, 5), rolling_frequencies=['1BD',], basket_creation_method=basket_creation_method, basket_creation_kwargs=bc_params ) strat.history()
-
basket_creation_kwargs: Optional[dict]
-
basket_creation_method: Optional[object]
-
close_out_at_roll: Optional[bool]
-
group_name: str
-
maturity: Optional[Union[str, date]]
-
property rolling_table
Builds the strategy’s rolling table.
- Returns:
Built rolling table as a pandas DataFrame.
-
trade_dictionary: Optional[dict]
-
option_dependencies(input_dependency, valuation_currency, data_points)
Option Dependencies
-
roll_options(dt)
Set option positions.
- Parameters:
dt – Decision datetime.