From c9aadd121e0dd802adaeb79873b79b72f2a1b2b1 Mon Sep 17 00:00:00 2001 From: DeXtreme Date: Sun, 12 Feb 2023 00:33:44 +0000 Subject: [PATCH] refactor(api_v2): Refactor tickers static method Refactors the `tickers` static method to accept a single symbol string or an iterable of symbol strings while maintaining the symbol parameter default value --- bitfinex/bitfinex_v2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bitfinex/bitfinex_v2.py b/bitfinex/bitfinex_v2.py index e54464d..e4b7fc8 100644 --- a/bitfinex/bitfinex_v2.py +++ b/bitfinex/bitfinex_v2.py @@ -52,8 +52,12 @@ def api_call(self, method, param={}): # Public endpoints @staticmethod def tickers(symbol='btcusd'): - return requests.get('https://api.bitfinex.com/v2/tickers?symbols=t{}'. - format(symbol.upper())).json() + if type(symbol) is str: + symbols = 't{}'.format(symbol.upper()) + else: + symbols = ','.join(['t{}'.format(s.upper()) for s in symbol]) + return requests.get('https://api.bitfinex.com/v2/tickers?symbols={}'. + format(symbols)).json() @staticmethod def ticker(symbol='btcusd'):