示例#1
0
文件: trader.py 项目: masroore/artis
 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
文件: balance.py 项目: masroore/artis
    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