StopLossStrategy#
-
class sigtech.framework.strategies.stop_strategy.StopLossStrategy
Baseclasses:
StopStrategy
StopLossStrategy - wrapper for constituent instrument/strategy with a triggered stop loss.
Keyword arguments:
instrument_name
: Name of instrument/strategy to trade.trigger_type
: Type of trigger to use, string options are listed below.valuation_lag
: Time window between decision time and valuation, defaults to1BD
.trigger_level
: Level used by the trigger.trigger_method
: Optional method to use as close out trigger, takes (dt, valuation, strategy, ).trigger_params
: Optional parameters to use in trigger method.trade_date
: Date to set initial value and determine start date.limit_period
: Time window to trigger close out once exceeded, defaults toNone
.initial_units
: Units of underlier to trade, defaults to1
.initial_cash
: Cash to include, defaults to0
.automatic_closeout
: Activate automatic closeout of the stop strategy if held by a strategy, defaults toTrue
.
The trigger types available are:
'FIXED_PCT_LOSS'
- Trigger close if percentage loss exceeds level from trade date.'FIXED_ABS_LOSS'
- Trigger close if absolute on one unit loss exceeds level from trade date.'TRAILING_PCT_LOSS'
- Trigger close if percentage loss exceeds level from high.'TRAILING_ABS_LOSS'
- Trigger close if absolute loss on one unit exceeds level from high.'METHOD'
- Trigger close using custom trigger method.
Example object creation:
import datetime as dtm future = env.object.get('ESZ19 INDEX') sl = sig.StopLossStrategy( currency='USD', trade_date=dtm.date(2019,9,1), instrument_name=future.name, trigger_type='FIXED_PCT_LOSS', trigger_level=0.01, )
Alternatively, a strategy wrapper can be generated to trade a specified object using the helper method:
sl = sig.StopLossStrategy.get_for_trade(future, dtm.date(2019,9,1))
-
TRIGGER_METHOD = {'FIXED_ABS_LOSS': <function fixed_abs_loss_trigger>, 'FIXED_PCT_LOSS': <function fixed_pct_loss_trigger>, 'TRAILING_ABS_LOSS': <function trailing_abs_loss_trigger>, 'TRAILING_PCT_LOSS': <function trailing_pct_loss_trigger>}
-
trigger_type: Optional[Literal['FIXED_PCT_LOSS', 'FIXED_ABS_LOSS', 'TRAILING_PCT_LOSS', 'TRAILING_ABS_LOSS', 'METHOD']]