def __fee(self, exchange): nonce = str(int(time.time() * 1e6)) d = dict() if exchange == "trt": url = "https://api.therocktrading.com/v1/funds/BTCEUR" signature = hmac.new(self.secret_trt.encode(), msg=(str(nonce) + url).encode(), digestmod=hashlib.sha512).hexdigest() _headers = { "Content-Type": "application/json", "X-TRT-KEY": self.apikey_trt, "X-TRT-SIGN": signature, "X-TRT-NONCE": nonce } resp = requests.get(url, headers=_headers) d["feetrttaker"] = json.loads(resp.text)["buy_fee"] d["feetrtmaker"] = json.loads(resp.text)["sell_fee"] return d elif exchange == "krk": api = krakenex.API(self.apikey_krk, self.secret_krk) k = KrakenAPI(api) resp = pd.DataFrame(k.get_trade_volume("BTCEUR")[2]) d["feekrk"] = resp["XXBTZEUR"][0] return d elif exchange == "bnb": resp = self.client.get_trade_fee(symbol="BNBTRX") print(resp) d["feebnbtaker"] = resp["tradeFee"][0]["taker"] d["feebnbmaker"] = resp["tradeFee"][0]["maker"] return d
def __order(self, exchange, order): nonce = str(int(time.time() * 1e6)) d = dict() if order == None: return d if exchange == "TRT": url = "https://api.therocktrading.com/v1/funds/" + self.pair + "/orders/" + order signature = hmac.new(self.secret_TRT.encode(), msg=(str(nonce) + url).encode(), digestmod=hashlib.sha512).hexdigest() _headers = { "Content-Type": "application/json", "X-TRT-KEY": self.apikey_TRT, "X-TRT-SIGN": signature, "X-TRT-NONCE": nonce } resp = requests.get(url, headers=_headers) print("TRT", resp) d["status_TRT"] = json.loads(resp.text)["status"] return d elif exchange == "krk": print( "FUNCTION NOT ENABLED ON KRAKEN EXCHANGE, USE OTHER EXCHANGES FOR THIS FEATURE TO WORK" ) exit(2) api = krakenex.API(self.apikey_krk, self.secret_krk) k = KrakenAPI(api) resp = pd.DataFrame(k.get_trade_volume(self.pair)[2]) d["feekrk"] = resp["XXBTZEUR"][0] return d elif exchange == "BNB": resp = self.client.get_order(symbol=self.pair, orderId=order) print("binance", resp) d["status_BNB"] = resp["status"] return d