예제 #1
0
    def symbol_mapping(cls, refresh=False) -> Dict:
        if Symbols.populated(cls.id) and not refresh:
            return Symbols.get(cls.id)[0]
        try:
            LOG.debug("%s: reading symbol information from %s", cls.id,
                      cls.symbol_endpoint)
            if isinstance(cls.symbol_endpoint, list):
                data = []
                for ep in cls.symbol_endpoint:
                    data.append(cls.http_sync.read(ep, json=True, uuid=cls.id))
            elif isinstance(cls.symbol_endpoint, dict):
                data = []
                for input, output in cls.symbol_endpoint.items():
                    for d in cls.http_sync.read(input, json=True, uuid=cls.id):
                        data.append(
                            cls.http_sync.read(f"{output}{d}",
                                               json=True,
                                               uuid=cls.id))
            else:
                data = cls.http_sync.read(cls.symbol_endpoint,
                                          json=True,
                                          uuid=cls.id)

            syms, info = cls._parse_symbol_data(data)
            Symbols.set(cls.id, syms, info)
            return syms
        except Exception as e:
            LOG.error("%s: Failed to parse symbol information: %s",
                      cls.id,
                      str(e),
                      exc_info=True)
            raise
예제 #2
0
    def symbol_mapping(cls, refresh=False) -> Dict:
        if Symbols.populated(cls.id) and not refresh:
            return Symbols.get(cls.id)[0]
        try:
            data = []
            for ep in cls.rest_endpoints:
                addr = cls._symbol_endpoint_prepare(ep)
                if isinstance(addr, list):
                    for ep in addr:
                        LOG.debug("%s: reading symbol information from %s",
                                  cls.id, ep)
                        data.append(
                            cls.http_sync.read(ep, json=True, uuid=cls.id))
                else:
                    LOG.debug("%s: reading symbol information from %s", cls.id,
                              addr)
                    data.append(
                        cls.http_sync.read(addr, json=True, uuid=cls.id))

            syms, info = cls._parse_symbol_data(
                data if len(data) > 1 else data[0])
            Symbols.set(cls.id, syms, info)
            return syms
        except Exception as e:
            LOG.error("%s: Failed to parse symbol information: %s",
                      cls.id,
                      str(e),
                      exc_info=True)
            raise
예제 #3
0
    def symbol_mapping(cls, symbol_separator='-', refresh=False) -> Dict:
        if Symbols.populated(cls.id) and not refresh:
            return Symbols.get(cls.id)[0]
        try:
            LOG.debug("%s: reading symbol information from %s", cls.id, cls.symbol_endpoint)
            data = {}
            for ep, quote_curr in cls.symbol_endpoint:
                data[quote_curr] = cls.http_sync.read(ep, json=True, uuid=cls.id)

            syms, info = cls._parse_symbol_data(data, symbol_separator)
            Symbols.set(cls.id, syms, info)
            return syms
        except Exception as e:
            LOG.error("%s: Failed to parse symbol information: %s", cls.id, str(e), exc_info=True)
            raise
예제 #4
0
    def symbol_mapping(cls, refresh=False) -> Dict:
        if Symbols.populated(cls.id) and not refresh:
            return Symbols.get(cls.id)[0]
        try:
            data = {}
            for ep in cls.rest_endpoints[0].route('instruments'):
                ret = cls.http_sync.read(ep, json=True, uuid=cls.id)
                if 'BTC' in ep:
                    data['BTC'] = ret
                else:
                    data['KRW'] = ret

            syms, info = cls._parse_symbol_data(data)
            Symbols.set(cls.id, syms, info)
            return syms
        except Exception as e:
            LOG.error("%s: Failed to parse symbol information: %s",
                      cls.id,
                      str(e),
                      exc_info=True)
            raise