Beispiel #1
0
    def simulate_order_execution(self, exchange, symbol, timeframe,
                                 new_candle):
        """

        :param exchange:
        :param symbol:
        :param timeframe:
        :param new_candle:
        :return:
        """
        previous_candle = self.get_current_candle(exchange, symbol, timeframe)
        orders = selectors.get_orders(exchange, symbol)

        if previous_candle[2] == new_candle[2]:
            return

        for o in orders:
            # skip inactive orders
            if not o.is_active:
                continue

            if ((o.price >= previous_candle[2]) and
                (o.price <= new_candle[2])) or ((o.price <= previous_candle[2])
                                                and
                                                (o.price >= new_candle[2])):
                o.execute()
Beispiel #2
0
    def simulate_order_execution(self, exchange: str, symbol: str, timeframe: str, new_candle: np.ndarray) -> None:
        previous_candle = self.get_current_candle(exchange, symbol, timeframe)
        orders = selectors.get_orders(exchange, symbol)

        if previous_candle[2] == new_candle[2]:
            return

        for o in orders:
            # skip inactive orders
            if not o.is_active:
                continue

            if ((o.price >= previous_candle[2]) and (o.price <= new_candle[2])) or (
                    (o.price <= previous_candle[2]) and (o.price >= new_candle[2])):
                o.execute()