Пример #1
0
 def fill_fetch_order(order, market):
     return Order(market, order.get('id'),
                  Analyser.extract_type(order, market),
                  Analyser.extract_start_amount(order, market),
                  Analyser.extract_remaining_amount_order(order, market),
                  Analyser.extract_price2(order, market),
                  Analyser.extract_status_order(order, market))
Пример #2
0
    def test_extract_no_good_order(self):
        depth = [[PRICE, 1]]
        analyser = Analyser()

        order = analyser.extract_good_order(depth)

        assert order[0] == PRICE
        assert order[1] == 0
Пример #3
0
    def _buy(self, market, volume, rate):
        """
        This try to buy the selected coin from the selected market at the selected price.
        It will cancel the order if it is not able to fill the order instantly.

        .. todo:: Change the parameters

        :param market: The analysis object
        :param volume: The volume wanted
        :param rate: The wanted rate
        :return: The order or None if couldn't buy
        """
        try:
            order = self.trader.buy(market, self.coin, volume, rate)
        except:
            logger.exception("Failed to buy {} on {}".format(
                self.coin, market))
            return None

        logger.debug(order)

        if not Analyser.is_filled(order, market):
            return self._handle_miss_buy(order, market)

        return Trader.fill_buy_sell_order(order, market)
Пример #4
0
def main():
    reporter = Reporter()
    try:
        logger.info("Creating strategy")
        strategy = Balance(settings.COIN, "LIQUI", "BINANCE", Trader(),
                           Analyser(), reporter, Database(), Helper())

        logger.info("Start running current strategy")
        strategy.run()
        logger.info("Finished running current strategy")
    except:
        logger.exception("")
        reporter.error("Service {} is dead, please revive it!".format(
            settings.SERVICE_NUMBER))
Пример #5
0
    def test_extract_remaining_amount_liqui(self):
        amount = Analyser.extract_remaining_amount2(LIQUI_BUY_ORDER, LIQUI)

        assert amount == 10
Пример #6
0
    def test_extract_remaining_amount_binance(self):
        amount = Analyser.extract_remaining_amount2(BINANCE_SELL_ORDER,
                                                    BINANCE)

        assert amount == 20
Пример #7
0
    def test_extract_start_amount_liqui_order(self):
        amount = Analyser.extract_start_amount(LIQUI_FETCH_BUY_ORDER, LIQUI)

        assert amount == 199
Пример #8
0
    def test_extract_start_amount_binance_order(self):
        amount = Analyser.extract_start_amount(BINANCE_FETCH_SELL_ORDER,
                                               BINANCE)

        assert amount == 192
Пример #9
0
    def test_extract_status_liqui(self):
        status = Analyser.extract_status(LIQUI_BUY_ORDER, LIQUI)

        assert status == Status.ONGOING
Пример #10
0
    def test_extract_start_amount_unknown(self):
        amount = Analyser.extract_start_amount({}, TOTO)

        assert amount == 0
Пример #11
0
    def test_extract_price_unknown(self):
        price = Analyser.extract_price2({}, TOTO)

        assert price == 0
Пример #12
0
    def test_extract_remaining_amount_binance_order(self):
        amount = Analyser.extract_remaining_amount_order(
            BINANCE_FETCH_SELL_ORDER, BINANCE)

        assert amount == 20
Пример #13
0
    def test_extract_status_unknown_order(self):
        status = Analyser.extract_status_order({}, TOTO)

        assert status == Status.UNKNOWN
Пример #14
0
    def test_extract_price_liqui_order(self):
        price = Analyser.extract_price2(LIQUI_FETCH_BUY_ORDER, LIQUI)

        assert price == 0.00008469
Пример #15
0
    def test_extract_status_binance_order(self):
        status = Analyser.extract_status_order(BINANCE_FETCH_SELL_ORDER,
                                               BINANCE)

        assert status == Status.DONE
Пример #16
0
    def test_extract_status_liqui_order(self):
        status = Analyser.extract_status_order(LIQUI_FETCH_BUY_ORDER, LIQUI)

        assert status == Status.ONGOING
Пример #17
0
    def test_extract_status_binance(self):
        status = Analyser.extract_status(BINANCE_SELL_ORDER, BINANCE)

        assert status == Status.DONE
Пример #18
0
    def test_extract_remaining_amount_unknown(self):
        amount = Analyser.extract_remaining_amount2({}, TOTO)

        assert amount == 0
Пример #19
0
    def test_extract_type_liqui_order(self):
        type = Analyser.extract_type(LIQUI_FETCH_BUY_ORDER, LIQUI)

        assert type == Types.BUY
Пример #20
0
    def test_extract_remaining_amount_liqui_order(self):
        amount = Analyser.extract_remaining_amount_order(
            LIQUI_FETCH_BUY_ORDER, LIQUI)

        assert amount == 10
Пример #21
0
    def test_extract_type_binance_order(self):
        type = Analyser.extract_type(BINANCE_FETCH_SELL_ORDER, BINANCE)

        assert type == Types.SELL
Пример #22
0
    def test_extract_type_unknown(self):
        type = Analyser.extract_type({}, TOTO)

        assert type == Types.UNKNOWN
Пример #23
0
    def test_extract_price_binance_order(self):
        price = Analyser.extract_price2(BINANCE_FETCH_SELL_ORDER, BINANCE)

        assert price == 0.00008762