StopTrigger

StopTrigger#

class sigtech.framework.strategies.trade_wrappers.StopTrigger

Baseclasses: TradeWrappers

A class adding stop trigger to any trade in a strategy :param kwargs: Additional StopStrategy parameters.

Main kwargs: 1. trigger_type: Type of trigger to use, string options are listed below (Optional). Default = ‘FIXED_PCT_LOSS’. 2. trigger_level: Level used by the trigger (Optional). Default = 0. 3. trigger_method: Optional method to use as close out trigger, takes (dt, valuation, strategy, ) (Optional). 4. trigger_params: Optional parameters to use in trigger method (Optional).

See also StopStrategy for more details.

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)): 500,
    fx_option_group.get_option('Put', 1.3, dtm.date(2010, 4, 6), dtm.date(2011, 4, 6)): -500
}
}

trigger_kwargs = {'trigger_type': 'FIXED_PCT_PROFIT', 'trigger_level': 0.05, 'valuation_lag': '2BD'}
stop = sig.StopTrigger(kwargs=trigger_kwargs)

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,
    trade_wrapper=stop
)
strat.build()
add_wrapper(strategy, dt: Union[date, datetime], instrument: Instrument)

Either find the StopStrategy related to instrument in position for date dt or creates one. :param strategy: Strategy to trade within - used to match total return and cost settings. :param dt: Date to trade and register initial value. :param instrument: Instrument/Strategy object to wrap.