DeltaHedgingStrategy#
-
class sigtech.framework.strategies.delta_hedging_strategy.DeltaHedgingStrategy
Baseclasses:
DailyStrategy
A Delta hedging strategy. This strategy wraps an option strategy inheriting from
OptionsStrategyBase
and performs trading of a hedging instrument to match the delta for options from one group.See also
sigtech.framework.strategies.single_options_strategy_base.OptionsStrategyBase.
The delta hedging parameters used are:
option_strategy_name
: Name for the option strategy to match delta for.option_group_name
: Name of group to hedge delta for. If left blank and the option strategy has one group, this is taken from the strategy.include_option_strategy
: Flag to indicate if a position should be included in the option strategy.delta_multiplier
: Multiplier of delta to trade, -1 (i.e. 100% hedged) by default.hedging_instrument_type
: Instrument type to hedge with, the mapping is given below. Accepted value are'FXSPOT'
,'ETF'
,'FUTURE'
,'UNDERLYING'
,'UNDERLYING_SPOT_START'
, or'ROLLING_FX_FWD'
. If'UNDERLYING'
is chosen, the hedging instrument is the option underlying (for options on futures).hedging_frequency
: Frequency of delta hedging, default is'1BD'
.delta_threshold
: Minimal amount of required position update required to trigger placing a trade. Set to 0 by default.rebalance_hedge_on_roll
: Ignore thehedging_frequency
and only rebalance the hedge on roll days.custom_hedge_dates
: Ignore thehedging_frequency
and only rebalance the hedge this list of dates. This list is not adjusted in any way so please ensure a date is included to put on the initial hedge.fractional_delta_threshold
: IfTrue
, then thedelta_threshold
value is considered as a fractional deviation, else the absolute value of the difference in the delta values are compared (default is False).max_absolute_delta
: Maximal allowed hedged delta at any moment in time. Not used by default, and currently supported only for non-fx related hedges. If hedging instrument is'UNDERLYING'
, then the limit is per underlyingsize_at_execution
: Flag used to specify if delta decision, sizing, and execution should happen within a very short period of time. This serves as a proxy to a real time data, when we have access only to one data point a day, and results in today rather than yesterday delta being hedged. Default isFalse
, as the sizing, decision, and execution times are set around the group valuation time, and might happen at or after the market close, which could be a problem for a production strategy.
The following are the instruments used for delta hedging (if enabled), unless instrument type is
'FXSPOT'
(OPTION_DELTA_HEDGING_INSTRUMENTS
dictionary):Underlying
Instrument Type
Instrument Name
SPX INDEX
ETF
SPY UP EQUITY STRATEGY
SPX INDEX
FUTURE
USD ES INDEX LONG FRONT RF STRATEGY
NKY INDEX
FUTURE
JPY NK INDEX LONG FRONT RF STRATEGY
SX5E INDEX
FUTURE
EUR VG INDEX LONG FRONT RF STRATEGY
To use another hedging underlying, or key, the
DeltaHedgingStrategy.OPTION_DELTA_HEDGING_INSTRUMENTS
dictionary should be updated:import sigtech.framework as sig sig.DeltaHedgingStrategy.OPTION_DELTA_HEDGING_INSTRUMENTS['NEW INDEX']={ 'FUTURE': 'NEW ROLLING FUTURE STRATEGY', }
A rolling forward strategy can be used to hedge fx exposure. This is enabled by creating a strategy and updating the dictionary. For example:
import datetime as dtm import sigtech.framework as sig rolling_fwd = sig.RollingFXForwardStrategy( currency='USD', long_currency='EUR', forward_tenor='3M_IMM', start_date=dtm.date(2010, 1, 4) ) sig.DeltaHedgingStrategy.OPTION_DELTA_HEDGING_INSTRUMENTS['EURUSD CURNCY'] = {'ROLLING_FX_FWD': rolling_fwd}
Example usage:
import datetime as dtm import sigtech.framework as sig start_date = dtm.date(2019, 1, 4) end_date = dtm.date(2020, 12, 31) group = sig.obj.get('SPX INDEX OTC OPTION GROUP') rc = sig.RollingOptionStrategy( currency=group.underlying_obj.currency, start_date=start_date, end_date=end_date, group_name=group.name, option_type='Call', maturity='3M', rolling_frequencies=['1M'], strike_type='SPOT', strike='SPOT+10%', target_quantity=1 ) dhs = sig.DeltaHedgingStrategy( start_date=start_date, end_date=end_date, option_strategy_name=rc.name, delta_multiplier=-1, include_option_strategy=True, hedging_instrument_type='FUTURE', hedging_frequency='1BD', )
-
currency: Optional[str]
-
custom_hedge_dates: Optional[list[datetime.date]]
-
delta_multiplier: Optional[float]
-
delta_threshold: Optional[float]
-
fractional_delta_threshold: Optional[bool]
-
hedging_frequency: Optional[str]
-
hedging_instrument_type: Literal['FXSPOT', 'FUTURE', 'ETF', 'UNDERLYING', 'ROLLING_FX_FWD', 'UNDERLYING_SPOT_START']
-
include_option_strategy: Optional[bool]
-
intraday_end_time: Optional[time]
-
intraday_start_time: Optional[time]
-
intraday_timezone: Optional[str]
-
max_absolute_delta: Optional[float]
-
OPTION_DELTA_HEDGING_INSTRUMENTS = {'NKY INDEX': {'FUTURE': <function nk_index_front>}, 'SPX INDEX': {'ETF': <function spy_equity_rs>, 'FUTURE': <function es_index_front>}, 'SX5E INDEX': {'FUTURE': <function vg_index_front>}}
-
option_group_name: Optional[str]
-
option_strategy: Optional[Strategy]
-
option_strategy_name: Optional[str]
-
rebalance_hedge_on_roll: Optional[bool]
-
size_at_execution: Optional[bool]
-
AVAILABLE_REBALANCE_FREQS
Subclasses:
ScheduleFrequenciesWithIntraday
alias of
ScheduleFrequencies
-
classmethod get_hedging_instrument(underlying_name, instrument_type)
Return the hedging instrument.
- Parameters:
underlying_name – Name of the underlying.
instrument_type – Type of instrument, e.g.
'FUTURE'
.
-
greeks(fields=None, dates=None, dollar_greeks: Optional[bool] = False, include_future_positions: Optional[bool] = False, start_date: Optional[date] = None, end_date: Optional[date] = None, data_points: Optional[list] = None)
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.
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 toTrue
internally, ifdata_points
not empty (optional).
- Returns:
pandas DataFrame.
-
hedge_option_delta(dt)
Hedge option delta.
- Parameters:
dt – Reference datetime.
- Returns:
Delta.
-
hedging_schedule()
Hedging schedule information.
-
metrics(fields=None, dates=None, dollar_greeks: Optional[bool] = False, include_future_positions: Optional[bool] = False, start_date: Optional[date] = None, end_date: Optional[date] = None, data_points: Optional[list] = None)
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'
,'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.
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 toTrue
internally, ifdata_points
not empty (optional).
- 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).
-
pnl_explain(fields=None, data_point=None, start_date=None, end_date=None)
A breakdown of the actual pnl and greeks pnl over time for a list of fields.
- Parameters:
fields – Input fields (optional).
data_point – Input data point (optional).
start_date – Start date - used if later than default start date (optional).
end_date – End date - used if earlier than default end date (optional).
- Returns:
pandas DataFrame.
-
portfolio_greeks(fields=None, dates=None, dollar_greeks: Optional[bool] = False, include_future_positions: 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 instruments held in the strategy.
-
schedule_information()
Schedule information for the strategy.
-
size_dt_from_decision_dt(decision_dt)
Return the previous strategy data point to the valuation date where the decision datetime falls in.
- Parameters:
decision_dt – Decision datetime.
- Returns:
Datetime.
-
strategy_initialization(dt)
Initial decision run on the start date of the strategy.
- Parameters:
dt – Reference datetime.
-
trade_delta(dt)
Set a position in the hedging instrument to match the delta.
delta_threshold
refers to fractional deviation iffractional_delta_threshold
is True and the simple difference between hedged and underlying delta otherwise.- Parameters:
dt – Reference datetime.
- Returns:
Delta.
-
trade_delta_per_underlying(dt)
Set a position in the hedging instrument to match the delta.
delta_threshold
refers to fractional deviation iffractional_delta_threshold
is True and the simple difference between hedged and underlying delta otherwise.- Parameters:
dt – Reference datetime.
- Returns:
Delta.
-
trade_delta_per_underlying_spot_start(dt)
Set a position in the hedging instrument to match the delta.
delta_threshold
refers to fractional deviation iffractional_delta_threshold
is True and the simple difference between hedged and underlying delta otherwise.- Parameters:
dt – Reference datetime.
- Returns:
Delta.
-
trade_fx_delta(dt)
Perform an fx spot conversion to match the delta.
- Parameters:
dt – Reference datetime.
- Returns:
Delta.
-
trade_fx_delta_with_rolling_fwd(dt)
Set a position in the rolling forward to match the forward delta (delta threshold is forward delta).
- Parameters:
dt – Reference datetime.
- Returns:
Delta.