示例#1
0
 def get_instruments(self):
     instrument_map = {}
     for info in self.public_get('/symbols_details'):
         pair = info['pair'].upper()
         base_id, quote_id = pair[:-3], pair[-3:]
         base, quote = base_id.upper(), quote_id.upper()
         base = self.CURRENCY_MAP.get(base, base)
         quote = self.CURRENCY_MAP.get(quote, quote)
         name = f'{base}_{quote}'
         instrument_map[name] = Instrument(name=name, base=base, quote=quote,
                                           name_id=pair, base_id=base_id, quote_id=quote_id, _data=info)
     return instrument_map
示例#2
0
 def get_instruments(self) -> Dict[str, Instrument]:
     instrument_map = {}
     for pair in self.PAIRS:
         base_id, quote_id = pair.split('_')
         base, quote = pair.upper().split('_')
         base = self.CURRENCY_MAP.get(base, base)
         quote = self.CURRENCY_MAP.get(quote, quote)
         name = f'{base}_{quote}'
         instrument_map[name] = Instrument(name=name,
                                           base=base,
                                           quote=quote,
                                           name_id=pair,
                                           base_id=base_id,
                                           quote_id=quote_id,
                                           _data=pair)
     return instrument_map
示例#3
0
 def get_instruments(self):
     instruments = {}
     for x in self.public_get('/instrument/active'):
         symbol = x['symbol']
         base_id = x['underlying']
         quote_id = x['quoteCurrency']
         base = self.CURRENCY_MAP.get(base_id, base_id)
         quote = self.CURRENCY_MAP.get(quote_id, quote_id)
         instruments[symbol] = Instrument(name=symbol,
                                          base=base,
                                          quote=quote,
                                          name_id=symbol,
                                          base_id=base_id,
                                          quote_id=quote_id,
                                          _data=x)
     return instruments
示例#4
0
 def get_instruments(self):
     instruments = {}
     for product in self.public_get('/products'):
         base_id, quote_id = product['base_currency'], product[
             'quoted_currency']
         base, quote = base_id, quote_id
         if base not in self.CURRENCIES or quote not in self.CURRENCIES:
             continue
         name = f'{base}_{quote}'
         instruments[name] = Instrument(name=name,
                                        base=base,
                                        quote=quote,
                                        name_id=str(product['id']),
                                        base_id=base_id,
                                        quote_id=quote_id,
                                        _data=product)
     return instruments
示例#5
0
 def get_instruments(self):
     instrument_map = {}
     for product in self.public_get('/markets'):
         product_code = product['product_code']
         split = product_code.split('_')
         if len(split) == 2:
             # spot
             base_id, quote_id = split
             base, quote = base_id, quote_id
             name = f'{base}_{quote}'
         else:
             # not spot
             base_id, quote_id = None, None
             base, quote = base_id, quote_id
             name = product_code
         instrument_map[name] = Instrument(name=name,
                                           base=base,
                                           quote=quote,
                                           name_id=product_code,
                                           base_id=base_id,
                                           quote_id=quote_id,
                                           _data=product)
     return instrument_map