Exemple #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
Exemple #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
Exemple #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
Exemple #4
0
    def __init__(self, config=None, sandbox=False, subaccount=None, **kwargs):
        self.config = Config(config=config)
        self.sandbox = sandbox
        self.subaccount = subaccount

        keys = self.config[self.id.lower()] if self.subaccount is None else self.config[self.id.lower()][self.subaccount]
        self.key_id = keys.key_id
        self.key_secret = keys.key_secret
        self.key_passphrase = keys.key_passphrase
        self.account_name = keys.account_name

        self.ignore_invalid_instruments = self.config.ignore_invalid_instruments

        if not Symbols.populated(self.id):
            self.symbol_mapping()
        self.normalized_symbol_mapping, _ = Symbols.get(self.id)
        self.exchange_symbol_mapping = {value: key for key, value in self.normalized_symbol_mapping.items()}
Exemple #5
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