def get_first_symbol_data(): try: exchange, exchange_name, exchange_id = _get_first_exchange_identifiers( ) symbol = trading_api.get_trading_pairs(exchange)[0] time_frame = _get_time_frame(exchange_name, exchange_id) return _get_candles_reply(exchange_name, exchange_id, symbol, time_frame) except (KeyError, IndexError): return {}
def get_currency_price_graph_update(exchange_id, symbol, time_frame, list_arrays=True, backtesting=False, minimal_candles=False, ignore_trades=False): bot_api = interfaces_util.get_bot_api() # TODO: handle on the fly backtesting price graph # if backtesting and WebInterface and WebInterface.tools[BOT_TOOLS_BACKTESTING]: # bot = WebInterface.tools[BOT_TOOLS_BACKTESTING].get_bot() symbol = parse_get_symbol(symbol) in_backtesting = backtesting_api.is_backtesting_enabled( interfaces_util.get_global_config()) or backtesting exchange_manager = trading_api.get_exchange_manager_from_exchange_id( exchange_id) if time_frame is not None: try: symbol_data = trading_api.get_symbol_data(exchange_manager, symbol, allow_creation=False) limit = 1 if minimal_candles else -1 historical_candles = trading_api.get_symbol_historical_candles( symbol_data, time_frame, limit=limit) kline = [math.nan] if trading_api.has_symbol_klines(symbol_data, time_frame): kline = trading_api.get_symbol_klines(symbol_data, time_frame) if historical_candles is not None: return _create_candles_data(symbol, time_frame, historical_candles, kline, bot_api, list_arrays, in_backtesting, ignore_trades) except KeyError: traded_pairs = trading_api.get_trading_pairs(exchange_manager) if not traded_pairs or symbol in traded_pairs: # not started yet return None else: return {"error": f"no data for {symbol}"} return None
def get_currencies_with_status(): evaluations_by_exchange_by_pair = {} for exchange_manager in interfaces.get_exchange_managers(): trading_modes = trading_api.get_trading_modes(exchange_manager) for pair in trading_api.get_trading_pairs(exchange_manager): if pair not in evaluations_by_exchange_by_pair: evaluations_by_exchange_by_pair[pair] = {} status_explanation = "N/A" status = "N/A" for trading_mode in trading_modes: if trading_api.get_trading_mode_symbol(trading_mode) == pair: status_explanation, status = trading_api.get_trading_mode_current_state( trading_mode) try: status = round(status, 3) except TypeError: pass break evaluations_by_exchange_by_pair[pair][trading_api.get_exchange_manager_id(exchange_manager)] = \ [status_explanation.replace("_", " "), status, trading_api.get_exchange_name(exchange_manager).capitalize()] return evaluations_by_exchange_by_pair
def _is_symbol_data_available(exchange_manager, symbol): return symbol in trading_api.get_trading_pairs(exchange_manager)
def _get_traded_pairs(self): pairs = set() for exchange_manager in self.exchange_managers: pairs = pairs.union( trading_api.get_trading_pairs(exchange_manager)) return list(pairs)