File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1212 brokerOrderType ,
1313 market_order_type ,
1414 limit_order_type ,
15- brokerOrder ,
15+ stop_loss_order_type
1616)
1717from sysexecution .tick_data import tickerObject
1818from sysexecution .orders .contract_orders import contractOrder
@@ -105,7 +105,7 @@ def get_and_submit_broker_order_for_contract_order(
105105 ## We want to preserve these otherwise there is a danger they will dynamically change
106106 collected_prices = copy (collected_prices )
107107
108- if order_type == limit_order_type :
108+ if order_type == limit_order_type or order_type == stop_loss_order_type :
109109 limit_price = self .set_limit_price (
110110 contract_order = contract_order ,
111111 collected_prices = collected_prices ,
Original file line number Diff line number Diff line change 11from sysexecution .algos .algo import Algo , limit_price_from_input , limit_order_type
22from sysexecution .order_stacks .broker_order_stack import orderWithControls
3+ from sysexecution .orders .broker_orders import stop_loss_order_type
34
45
56class algoLimit (Algo ):
@@ -32,3 +33,26 @@ def manage_trade(
3233 self , broker_order_with_controls : orderWithControls
3334 ) -> orderWithControls :
3435 raise Exception ("Limit order shouldn't be managed" )
36+
37+
38+ class algoStopLoss (algoLimit ):
39+ """
40+ Submit a limit order which is a stop loss
41+ """
42+
43+ def submit_trade (self ) -> orderWithControls :
44+ contract_order = self .contract_order
45+ self .data .log .debug (
46+ "Submitting stop loss order for %s, limit price %f"
47+ % (str (contract_order ), contract_order .limit_price )
48+ )
49+ broker_order_with_controls = (
50+ self .get_and_submit_broker_order_for_contract_order (
51+ contract_order ,
52+ order_type = stop_loss_order_type ,
53+ input_limit_price = contract_order .limit_price ,
54+ limit_price_from = limit_price_from_input ,
55+ )
56+ )
57+
58+ return broker_order_with_controls
You can’t perform that action at this time.
0 commit comments