Пример #1
0
    async def sell_all(self, currencies_to_sell=None, timeout=None):
        """
        Sell every currency in portfolio for reference market using market orders.
        :param currencies_to_sell: List of currencies to sell, default values consider every currency in portfolio
        :param timeout: Timeout to get market price
        :return: The created orders
        """
        orders = []
        currency_list = self.exchange_manager.exchange_personal_data.portfolio_manager.portfolio.portfolio

        if not currencies_to_sell:
            currencies = currency_list
        else:
            currencies = [
                currency for currency in currencies_to_sell
                if currency in currency_list
            ]

        for currency in currencies:
            symbol, inverted = get_market_pair(self.config, currency)
            if symbol:
                orders += await self._sell_everything(symbol,
                                                      inverted,
                                                      timeout=timeout)
        return orders
Пример #2
0
def test_get_market_pair(config):
    config[commons_constants.CONFIG_TRADING][commons_constants.CONFIG_TRADER_REFERENCE_MARKET] = "BTC"
    assert util.get_market_pair(config, "ETH") == ("", False)
    assert util.get_market_pair(config, "ADA") == ("ADA/BTC", False)
    assert util.get_market_pair(config, "USDT") == ("BTC/USDT", True)
    assert util.get_market_pair(config, "BTC") == ("", False)

    # with disabled currency
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Cardano"][commons_constants.CONFIG_ENABLED_OPTION] = False
    assert util.get_market_pair(config, "ADA", enabled_only=False) == ("ADA/BTC", False)
    assert util.get_market_pair(config, "ADA", enabled_only=True) == ("", False)
Пример #3
0
    async def sell_all(self, currencies_to_sell=None, timeout=None):
        orders = []
        currency_list = self.exchange_manager.exchange_personal_data.portfolio_manager.portfolio.portfolio

        if not currencies_to_sell:
            currencies = currency_list
        else:
            currencies = [
                currency for currency in currencies_to_sell
                if currency in currency_list
            ]

        for currency in currencies:
            symbol, inverted = get_market_pair(self.config, currency)
            if symbol:
                orders += await self._sell_everything(symbol,
                                                      inverted,
                                                      timeout=timeout)
        return orders