Skip to content

how to set up a stop loss rule

cloudcell edited this page Jul 22, 2016 · 7 revisions

Q: what if an order wouldn't cancel the other, what would the prefix be ? (or any prefix as you like, it just have to make sense with the rule it goes along with?)

A (based on an answer by Joshua Ulrich): the label can be anything. It doesn't have to make sense with the rule it belongs to, but doing that helps if you look at the order book.


Q: how do I set up a stop loss rule ?

A: (based on an answer by Brian Peterson) the basic process works something like this... (I'm going to pattern this discussion off luxor.5.ordersets for easy reference) (I thought we could stay within the confines of the include file but we can't this time)

the basic process works something like this... (I'm going to pattern this discussion off luxor.5.ordersets for easy reference)

first, you need to define an orderset name for all the orders you want to link together all your related orders: entry, normal exit, stop exit, need to share the same orderset. You'll also want to chain your stop-loss or arbitrary (non-signal) take profit orders to the entry order.

  • so, in the luxor 5 demo, the entry is 'EnterLONG', and the orderset is 'ocolong'
  • so the chained stop and takeprofit order share the orderset, and include:  type='chain', parent='EnterLONG',

Q: is the orderset critical? only if you want oco behaviour for multiple resting orders, no?

A: if you don't want oco, you don't need ordersets. if you don't want orders enetered after an entry for things like takeprofit or stops, you don't need chains


Q: Is the initial (luxor1) example just has dummy stoploss parameters? A: yes


Also, this might help https://github.com/cloudcell/quantstrat/wiki/order-attributes-and-types