def get_book(cls, symbol): endpoint = "/api/v3/depth.json?market={}&limit=1".format("".join( symbol.split("/")).lower()) time.sleep(1) req = Request(base_url, endpoint) rsl = req.get() return rsl
def get_book(cls, pair): """Get order book from exchange.""" endpoint = "/api/order_book/{}".format(pair) for pair in cls.get_symbols(): req = Request(base_url, endpoint) rsl = req.get() return rsl
def create_order(self, cur, coin, amount, price, dir): """ Create a trade order. In bitfinex direction is indicated by amount being positive or negative. :param cur Currency to user to create the trade order. :param coin Coin to use to create the trade order. :param amount Amount to be used to create the order. If the direction equal "buy" amount is positive, else if direction equals "sell" amount is negative or multiplied by -1. :param price Price to use to create the trade order. :param dir Unused paramenter, kept for compatibility. """ prefix = "/api/v1.1/market" suffix = "/{}limit?apikey={}&market={}-{}&quantity={}&rate={}&timeInForce=IOC".format( dir, key, cur, coin, amount, price) endpoint = prefix + suffix headers = {"APISIGN": self.create_signature(endpoint)} req = Request(base_url, suffix) rsl = req.get(headers=headers) if rsl["success"] == "false": return False return True
def get_symbols(cls): """Get available trading symbols.""" endpoint = "/api/v1/market/symbols" req = Request(base_url, endpoint) data = req.get() for i in data["data"]: yield i["symbol"]
def get_balances(self): """Get Balances from exchange""" suffix = "api/spot/v3/accounts", headers = self.create_signature_headers(suffix) req = Request(base_url, suffix) rsl = req.get() parser = Normalizer(rsl) return parser.normalize_balances()
def get_symbols(cls): """Get symbols available""" endpoint = "/api/3/info" req = Request(base_url, endpoint) if req != None: rsl = req.get()["pairs"] parser = Normalizer(rsl) return parser.normalize_symbols()
def get_balances(self): """Get Balances from exchange""" suffix = "/payment/balances" req = Request(base_url, suffix) headers = self.create_signature_headers(suffix) rsl = req.get(headers=headers) parser = Normalizer(rsl) return parser.normalize_balances
def get_balances(self): """Get Balances from exchange""" suffix = "/api/v1/accounts" headers = self.create_signature_headers(suffix) req = Request(base_url, suffix) rsp = req.get(headers) parser = Normalizer(rsp["data"]) return parser.normalize_balances()
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/api/v1/public/tickers" req = Request(base_url, endpoint) rsl = req.get() for i in rsl["result"]: if i != None: parser = Normalizer({"symbol": i, "data": rsl["result"][i]}) yield parser.normalize_ticker()
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/returnTicker" req = Request(base_url, endpoint) rsl = req.get() for i in rsl: if i != None: parser = Normalizer({"symbol": i, "data": rsl[i]}) yield parser.normalize_ticker()
def cancel_order(self, order_id): suffix = "/v2/trading/cancelOrdersById" payload = {"ids": [order_id]} headers = self.create_signature_headers(suffix) req = Request(base_url, suffix) rsl = req.get() if order_id in rsl: return True return False
def get_balances(self): """Get Balances from exchange""" suffix = "/v1/Trade/BalanceFull" nonce = str(int(time.time() * 1000)) headers = self.create_signature_headers({"nonce": nonce}) req = Request(base_url, suffix) rsl = req.get(headers=headers) parser = Normalizer(rsl) return parser.normalize_balances()
def get_book(cls, symbol): """ Get book from exchange for symbol. :param symbol Symbol to be used for the request. """ endpoint = "/api/public/v1/orderbook?market_pair={}".format(symbol) req = Request(base_url, endpoint) return req.get()
def get_tickers(cls): """Fetch tickers from echange""" suffix_ticker = "/market/tickers" req = Request(base_url, suffix_ticker) data = req.get()["data"] for i in data: parser = Normalizer(i) rsl = parser.normalize_ticker() if not rsl == None: yield rsl
def get_tickers(cls): """Fetch tickers from echange""" suffix = "/api/spot/v3/instruments/ticker" req = Request(base_url, suffix) data = req.get() for i in data: parser = Normalizer(i) rsl = parser.normalize_ticker() if not rsl == None: yield rsl
def get_balances(self): """Get Balances from exchange""" suffix = "/v1/balance/info?" nonce = str(int(time.time() * 1000)) query_str = "access_id={}&tonce={}".format(self.key, nonce) headers = self.create_signature_headers(query_str) req = Request(base_url, suffix + query_str) rsl = req.get(headers=headers) parser = Normalizer(rsl["data"]) return parser.normalize_balances()
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/api/v1/market/allTickers" req = Request(base_url, endpoint) data = req.get() for i in data["data"]["ticker"]: parser = Normalizer(i) rsl = parser.normalize_ticker() if not rsl == None: yield rsl
def get_tickers(cls): """Fetch tickers from echange""" suffix = "/v1/Public/Ticker" req = Request(base_url, suffix) data = req.get() for i in data: parser = Normalizer(i) rsl = parser.normalize_ticker() if not rsl == None: yield rsl
def get_tickers(cls): """Fetch tickers from echange""" suffix = "/v2/public/tickers" req = Request(base_url, suffix) data = req.get() if data is not None: for i in data: if not i is None: parser = Normalizer(i) yield parser.normalize_ticker()
def get_balances(self): """Get Balances from exchange""" nonce = str(int(time.time() * 1000)) suffix = "/api/v1.1/account/getbalances?apikey={}&nonce={}".format( self.key, nonce) headers = {"APISIGN": self.create_signature(suffix)} req = Request(base_url, suffix) rsl = req.get(headers=headers) parser = Normalizer(rsl["result"]) return parser.normalize_balances()
def get_tickers(cls): """Fetch tickers from echange""" suffix = "/api/market-public.php" req = Request(base_url, suffix) data = req.get() if data is not None: for i in data: parser = Normalizer(i) rsl = parser.normalize_ticker() if not rsl == None: yield rsl
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/api/v1.1/public/getmarketsummaries" req = Request(base_url, endpoint) data = req.get() if data is not None: for i in data["result"]: parser = Normalizer(i) rsl = parser.normalize_ticker() if not rsl == None: yield rsl
def get_book(cls, symbol): """ Get book for symbol. :param symbol Symbol to get the book from. """ endpoint = "/api/3/depth/{}?limit=1".format(symbol) req = Request(base_url, endpoint) rsl = req.get() return rsl
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/api/ticker/" pair_list = cls.get_symbols() for pair in pair_list: req = Request(base_url, "{}{}".format(endpoint, pair)) rsl = req.get() if not rsl == None: parser = Normalizer({"symbol": pair, "data":rsl}) normalized = parser.normalize_ticker() yield normalized
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/api/v3/tickers.json" req = Request(base_url, endpoint) rsl = req.get() if rsl != None: for i in rsl: parser = Normalizer(rsl[i]) parsed = parser.normalize_ticker() yield parsed pass
def get_balances(self): """Get Balances from exchange""" endpoint = "/api/v1/account/balances" body = { "request": endpoint, "nonce": str(int(time.time() * 1000)) } headers = self.create_signature_headers(body) req = Request(base_url, endpoint) rsl = req.get(headers) rsp = requests.get(base_url + endpoint, headers=headers) return Normalizer(rsl["result"]).normalize_balances()
def get_tickers(cls): """Fetch tickers from echange""" endpoint = "/api/v1/market/ticker?symbol=" # + pair e.g.: BCHBTC pair_list = cls.get_symbols() for pair in pair_list: req = Request(base_url, "{}{}".format(endpoint, pair)) data = req.get() if data["success"] is True: parser = Normalizer({"symbol": pair, "data": data["data"]}) normalized = parser.normalize_ticker() if normalized is not None: yield normalized
def get_symbols(cls): """ Retrieve available symbols. Useful for filtering. """ endpoint = "/api/v3/exchangeInfo" req = Request(base_url, endpoint) try: rsl = req.get() parser = Normalizer(rsl) return parser.normalize_symbols() except Exception as e: logging.error("Error {} in {}".format(e, __name__.upper())) return e
def get_balances(self): """Get Balances from exchange""" endpoint = "/api/v3/members/me.json?" nonce = str(int(time.time() * 1000)) query = "access_key={}&tonce={}".format(self.key, nonce) query_signed = "{}&signature={}".format( query, self.create_signature("GET", endpoint, query)) req = Request(base_url, "{}{}".format(endpoint, query_signed)) rsl = req.get() if rsl: return Normalizer(rsl).normalize_balances() else: return [rsl]
def get_tickers(cls): """Fetch tickers from echange""" suffix = "/v1/market/ticker/all" req = Request(base_url, suffix) rsl = req.get() data = rsl["data"]["ticker"] if data is not None: for i in data: if len(i) <= 10: parser = Normalizer({"symbol": i, "data": data[i]}) entry = parser.normalize_ticker() if not entry == None: yield entry