def are_all_orders_cancelled_after_timeout(
            self,
            list_of_broker_orders: listOfOrders,
            wait_time_seconds: int = 60) -> listOfOrders:

        timer = quickTimer(wait_time_seconds)
        while timer.unfinished:
            list_of_broker_orders = self.list_of_orders_not_yet_cancelled(
                list_of_broker_orders)
            if len(list_of_broker_orders) == 0:
                break

        return list_of_broker_orders
Exemplo n.º 2
0
    def check_all_orders_cancelled_with_timeout(self,
                                                list_of_broker_orders,
                                                wait_time_seconds=60):

        timer = quickTimer(wait_time_seconds)
        result = failure
        while timer.unfinished:
            list_of_broker_orders = self.check_all_orders_cancelled(
                list_of_broker_orders)
            if len(list_of_broker_orders) == 0:
                result = success
                break

        return result
Exemplo n.º 3
0
    def wait_for_valid_bid_and_ask_and_return_current_tick(
            self, wait_time_seconds=10):
        waiting = True
        timer = quickTimer(wait_time_seconds)
        while waiting:
            if timer.finished:
                return missing_data
            last_bid = self.bid()
            last_ask = self.ask()
            last_bid_is_valid = not np.isnan(last_bid)
            last_ask_is_valid = not np.isnan(last_ask)

            if last_bid_is_valid and last_ask_is_valid:
                break

        return self.current_tick()
Exemplo n.º 4
0
    def wait_for_valid_bid_and_ask_and_return_current_tick(
            self, wait_time_seconds: int = 10) -> oneTick:
        waiting = True
        timer = quickTimer(wait_time_seconds)
        while waiting:
            if timer.finished:
                return missing_data
            self.refresh()
            last_bid = self.bid()
            last_ask = self.ask()
            last_bid_is_valid = not np.isnan(last_bid)
            last_ask_is_valid = not np.isnan(last_ask)

            if last_bid_is_valid and last_ask_is_valid:
                break

        current_tick = self.current_tick(require_refresh=False)

        return current_tick
def cancel_order(data, broker_order_with_controls):
    log = broker_order_with_controls.order.log_with_attributes(data.log)
    data_broker = data
    data_broker.cancel_order_given_control_object(broker_order_with_controls)

    # Wait for cancel. It's vitual we do this since if a fill comes in before we finish it will screw
    #   everyting up...
    timer = quickTimer(seconds = 600)
    not_cancelled = True
    while not_cancelled:
        is_cancelled = data_broker.check_order_is_cancelled_given_control_object(broker_order_with_controls)
        if is_cancelled:
            log.msg("Cancelled order")
            break
        if timer.finished():
            log.critical("Ran out of time to cancel order - may cause weird behaviour!")
            break


    return broker_order_with_controls
Exemplo n.º 6
0
def cancel_order(data: dataBlob,
                 broker_order_with_controls: orderWithControls) -> orderWithControls:

    log = broker_order_with_controls.order.log_with_attributes(data.log)
    data_broker = dataBroker(data)
    data_broker.cancel_order_given_control_object(broker_order_with_controls)

    # Wait for cancel. It's vitual we do this since if a fill comes in before we finish it will screw
    #   everything up...
    timer = quickTimer(seconds=CANCEL_WAIT_TIME)
    not_cancelled = True
    while not_cancelled:
        is_cancelled = data_broker.check_order_is_cancelled_given_control_object(
            broker_order_with_controls)
        if is_cancelled:
            log.msg("Cancelled order")
            break
        if timer.finished:
            log.warn("Ran out of time to cancel order - may cause weird behaviour!")
            break

    return broker_order_with_controls