Beispiel #1
0
 def _try_get_value_of_currency(self, currency, quantity):
     symbol = merge_currencies(currency, self.reference_market)
     symbol_inverted = merge_currencies(self.reference_market, currency)
     if self.exchange.get_exchange_manager().symbol_exists(symbol):
         self._update_currencies_prices(symbol)
         return self.currencies_last_prices[symbol] * quantity
     elif self.exchange.get_exchange_manager().symbol_exists(symbol_inverted):
         self._update_currencies_prices(symbol_inverted)
         return quantity / self.currencies_last_prices[symbol_inverted]
     else:
         # TODO : manage if currency/market doesn't exist
         return 0
    async def _try_get_value_of_currency(self, currency, quantity):
        symbol = merge_currencies(currency, self.reference_market)
        symbol_inverted = merge_currencies(self.reference_market, currency)

        if self.exchange.get_exchange_manager().symbol_exists(symbol):
            await self._update_currencies_prices(symbol)
            return self.currencies_last_prices[symbol] * quantity

        elif self.exchange.get_exchange_manager().symbol_exists(symbol_inverted):
            await self._update_currencies_prices(symbol_inverted)
            return quantity / self.currencies_last_prices[symbol_inverted]

        else:
            self._inform_no_matching_symbol(currency)
            return 0
Beispiel #3
0
    def _try_get_value_of_currency(self, currency, quantity):
        symbol = merge_currencies(currency, self.reference_market)
        symbol_inverted = merge_currencies(self.reference_market, currency)

        if self.exchange.get_exchange_manager().symbol_exists(symbol):
            self._update_currencies_prices(symbol)
            return self.currencies_last_prices[symbol] * quantity

        elif self.exchange.get_exchange_manager().symbol_exists(symbol_inverted):
            self._update_currencies_prices(symbol_inverted)
            return quantity / self.currencies_last_prices[symbol_inverted]

        else:
            self.logger.warning(f"Can't find matching symbol for {currency} and {self.reference_market}")
            return 0
def interpret_file_name(file_name):
    data = basename(file_name).split("_")
    try:
        exchange_name = data[0]
        symbol = merge_currencies(data[1], data[2])
        timestamp = data[3] + data[4].replace(DATA_FILE_EXT, "")
    except KeyError:
        exchange_name = None
        symbol = None
        timestamp = None

    return exchange_name, symbol, timestamp
Beispiel #5
0
    def get_file_name(file_name):
        data = os.path.basename(file_name).split("_")
        try:
            exchange_name = data[0]
            symbol = merge_currencies(data[1], data[2])
            timestamp = data[3] + data[4].replace(
                ExchangeDataCollector.Exchange_Data_Collector_File_Ext, "")
        except KeyError:
            exchange_name = None
            symbol = None
            timestamp = None

        return exchange_name, symbol, timestamp
    def _try_get_value_of_currency(self, currency, quantity):
        symbol = merge_currencies(currency, self.reference_market)
        symbol_inverted = merge_currencies(self.reference_market, currency)

        if self.exchange.get_exchange_manager().symbol_exists(symbol):
            self._update_currencies_prices(symbol)
            return self.currencies_last_prices[symbol] * quantity

        elif self.exchange.get_exchange_manager().symbol_exists(
                symbol_inverted):
            self._update_currencies_prices(symbol_inverted)
            return quantity / self.currencies_last_prices[symbol_inverted]

        else:
            if not isinstance(self.exchange.get_exchange(), ExchangeSimulator):
                # do not log warning in backtesting or tests
                self.logger.warning(
                    f"Can't find matching symbol for {currency} and {self.reference_market}"
                )
            else:
                self.logger.info(
                    f"Can't find matching symbol for {currency} and {self.reference_market}"
                )
            return 0
Beispiel #7
0
def interpret_file_name(file_name):
    data = basename(file_name).split("_")
    try:
        exchange_name = data[0]
        symbol = merge_currencies(data[1], data[2])
        data_type = get_data_type(file_name)
        file_ext = get_file_ending(data_type)
        timestamp = data[3] + data[4].replace(file_ext, "")
    except KeyError:
        exchange_name = None
        symbol = None
        timestamp = None
        data_type = None

    return exchange_name, symbol, timestamp, data_type