def set_api_keys(self, exchange, key, secret): """ set clients, assumes conf file present """ self.logger.info("set api " + str(exchange)) if exchange == exc.BITMEX: self.clients[exchange] = bitmex.BitMEX(apiKey=key, apiSecret=secret) elif exchange == exc.DERIBIT: self.clients[exchange] = DeribitWrapper(key=key, secret=secret) self.logger.debug("set deri %s" % str(self.clients[exchange])) elif exchange == exc.DELTA: self.clients[exchange] = DeltaRestClient(api_key=key, api_secret=secret) self.logger.debug("set %s %s" % (exchange, str(self.clients[exchange]))) elif exchange == exc.BITTREX: self.clients[exchange] = bittrex.Bittrex(key, secret) #maintain version for candles self.clients[rex_API_v2] = bittrex.Bittrex( key, secret, api_version=bittrex.API_V2_0) elif exchange == exc.KUCOIN: self.clients[exchange] = KuClient(key, secret) elif exchange == exc.HITBTC: self.clients[exchange] = hitbtc.RestClient(key, secret) elif exchange == exc.BINANCE: self.clients[exchange] = binance.Client(key, secret) elif exchange == exc.KRAKEN: self.clients[exchange] = KrakenAPI(key, secret)
def set_client(self, exchange): """ set clients from stored keys """ #self.logger.info ("set keys %s %s"%(exchange,keys['public_key'])) if not self.session_active: raise Exception("no active session") #keys = self.db.apikeys.find_one({"exchange":exchange}) print("set client ", self.session_user_id, exchange) tmp = self.db.apikeys.find_one({ "user_id": self.session_user_id, "exchange": exchange }) print("keys ", tmp) keys = tmp["apikeys"] self.logger.info("set api %s %s" % (str(exchange), keys["public_key"])) print(self.clients) if exchange == exc.BITMEX: self.clients[self.session_user_id][exchange] = bitmex.BitMEX( apiKey=keys["public_key"], apiSecret=keys["secret"]) elif exchange == exc.DELTA: self.clients[self.session_user_id][exchange] = DeltaRestClient( api_key=keys["public_key"], api_secret=keys["secret"]) self.logger.debug("set %s" % exchange) elif exchange == exc.KRAKEN: self.clients[self.session_user_id][exchange] = KrakenAPI( keys["public_key"], keys["secret"]) elif exchange == exc.BINANCE: self.clients[self.session_user_id][exchange] = binance.Client( keys["public_key"], keys["secret"])
def set_api_keys(self, exchange, key, secret): """ set clients, assumes conf file present """ self.logger.info("set api " + str(exchange)) if exchange == exc.BITMEX: self.clients[exchange] = bitmex.BitMEX(apiKey=key, apiSecret=secret) elif exchange == exc.DERIBIT: self.clients[exchange] = DeribitWrapper(key=key, secret=secret)