File tree Expand file tree Collapse file tree 4 files changed +18
-8
lines changed
Expand file tree Collapse file tree 4 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 44 LimitOrder as ibLimitOrder ,
55 Trade as ibTrade ,
66 Order as ibOrder ,
7+ StopOrder as ibStopOrder
78)
89
910from syscore .exceptions import missingContract
2728 snap_mid_type ,
2829 snap_prim_type ,
2930 adaptive_mkt_type ,
31+ stop_loss_order_type
3032)
3133
3234from sysobjects .contracts import futuresContract
@@ -148,6 +150,13 @@ def _build_ib_order(
148150 return missing_order
149151 else :
150152 ib_order = ibLimitOrder (ib_BS_str , ib_qty , limit_price )
153+ elif order_type is stop_loss_order_type :
154+ if limit_price is None :
155+ self .log .critical ("Need to have limit price with limit order!" )
156+ return missing_order
157+ else :
158+ ib_order = ibStopOrder (ib_BS_str , ib_qty , limit_price )
159+
151160 elif order_type is snap_mkt_type :
152161 ## auxPrice is the offset so this will submit an order buy at the best offer, etc
153162 ## Works like a market order but works for instruments with no streaming data
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ def get_list_of_broker_orders_with_account_id(
144144
145145 :return: list of brokerOrder objects
146146 """
147- list_of_control_objects = self ._get_list_of_broker_control_orders (
147+ list_of_control_objects = self .get_list_of_broker_control_orders (
148148 account_id = account_id
149149 )
150150 order_list = [
@@ -158,7 +158,7 @@ def get_list_of_broker_orders_with_account_id(
158158 def _get_dict_of_broker_control_orders (
159159 self , account_id : str = arg_not_supplied
160160 ) -> dict :
161- control_order_list = self ._get_list_of_broker_control_orders (
161+ control_order_list = self .get_list_of_broker_control_orders (
162162 account_id = account_id
163163 )
164164 dict_of_control_orders = dict (
@@ -169,7 +169,7 @@ def _get_dict_of_broker_control_orders(
169169 )
170170 return dict_of_control_orders
171171
172- def _get_list_of_broker_control_orders (
172+ def get_list_of_broker_control_orders (
173173 self , account_id : str = arg_not_supplied
174174 ) -> list :
175175 """
Original file line number Diff line number Diff line change @@ -40,9 +40,10 @@ def allowed_types(self):
4040 "snap_mid" ,
4141 "snap_prim" ,
4242 "adaptive_mkt" ,
43+ "stop_loss"
4344 ]
4445
45-
46+ stop_loss_order_type = brokerOrderType ( "stop_loss" )
4647market_order_type = brokerOrderType ("market" )
4748limit_order_type = brokerOrderType ("limit" )
4849
Original file line number Diff line number Diff line change @@ -642,13 +642,13 @@ def get_raw_estimated_instrument_weights(self) -> pd.DataFrame:
642642
643643 # these will probably be annual
644644 optimiser = self .calculation_of_raw_instrument_weights ()
645- weights_of_instruments_with_weights = optimiser .weights ()
645+ instrument_weights = optimiser .weights ()
646646
647- instrument_weights = self ._add_zero_weights_to_instrument_weights_df (
648- weights_of_instruments_with_weights
647+ instrument_weights_with_zeros = self ._add_zero_weights_to_instrument_weights_df (
648+ instrument_weights
649649 )
650650
651- return instrument_weights
651+ return instrument_weights_with_zeros
652652
653653 def fit_periods (self ):
654654 # FIXME, NO GUARANTEE THIS OBJECT HAS AN ESTIMATOR UNLESS IT INHERITS FROM
You can’t perform that action at this time.
0 commit comments