def split_spread_order(self): """ :param self: :return: list of contract orders, will be original order if not a spread order """ if len(self.contract_id) == 1: # not a spread trade return [self] list_of_derived_broker_orders = [] original_as_dict = self.as_dict() for contractid, trade_qty, fill, fill_price in zip( self.contract_id, self.trade, self.fill, self.filled_price): new_order_as_dict = copy(original_as_dict) new_tradeable_object = contractTradeableObject( self.strategy_name, self.instrument_code, contractid) new_key = new_tradeable_object.key new_order_as_dict['key'] = new_key new_order_as_dict['trade'] = trade_qty new_order_as_dict['fill'] = fill new_order_as_dict['filled_price'] = fill_price new_order_as_dict['order_id'] = no_order_id new_order = brokerOrder.from_dict(new_order_as_dict) new_order.split_order(self.order_id) list_of_derived_broker_orders.append(new_order) return list_of_derived_broker_orders
def get_list_of_order_ids_for_strategy_and_contract( self, strategy_name, contract_object): instrument_code = contract_object.instrument_code contract_id = contract_object.date_str tradeable_object = contractTradeableObject(strategy_name, instrument_code, contract_id) object_key = tradeable_object.key result_dict = self._mongo.collection.find(dict(key=object_key)) list_oforder_id = [result["order_id"] for result in result_dict] alt_key = tradeable_object.alt_key result_dict = self._mongo.collection.find(dict(key=alt_key)) alt_list_oforder_id = [result["order_id"] for result in result_dict] list_oforder_id = list_oforder_id + alt_list_oforder_id return list_oforder_id