def add_children_to_stack_and_child_id_to_parent(
        self,
        parent_stack: orderStackData,
        child_stack: orderStackData,
        parent_order: Order,
        list_of_child_orders: listOfOrders,
    ):

        parent_log = parent_order.log_with_attributes(self.log)

        list_of_child_ids = put_children_on_stack(
            child_stack=child_stack,
            list_of_child_orders=list_of_child_orders,
            parent_log=parent_log,
            parent_order=parent_order,
        )
        if len(list_of_child_ids) == 0:
            return None

        success_or_failure = add_children_to_parent_or_rollback_children(
            child_stack=child_stack,
            parent_order=parent_order,
            parent_log=parent_log,
            parent_stack=parent_stack,
            list_of_child_ids=list_of_child_ids,
        )

        if success_or_failure is success:
            log_successful_adding(
                list_of_child_orders=list_of_child_orders,
                list_of_child_ids=list_of_child_ids,
                parent_order=parent_order,
                parent_log=parent_log,
            )
Esempio n. 2
0
    def _put_order_on_stack_and_get_order_id(self, order: Order) -> int:
        order_has_existing_id = not order.order_id is no_order_id
        if order_has_existing_id:
            log = order.log_with_attributes(self.log)
            log.warn(
                "Order %s already has order ID will be ignored and allocated a new ID!"
                % str(order))

        order_to_add = copy(order)
        order_id = self._get_next_order_id()
        order_to_add.order_id = order_id

        self._put_order_on_stack_no_checking(order_to_add)

        return order_id