diff --git a/libraries/wrappers/earn_binance.py b/libraries/wrappers/earn_binance.py index 2368c4a..95eaa7f 100644 --- a/libraries/wrappers/earn_binance.py +++ b/libraries/wrappers/earn_binance.py @@ -28,6 +28,12 @@ class binance_earn: def get_available_products(self, coin): try: response = self.client.get_simple_earn_flexible_product_list(asset=coin, current=1, size=100, recvWindow=5000) + if response["total"]>0: + return {"coin": response["rows"][0]["asset"], + "product_id": response["rows"][0]["productId"], + "rate": response["rows"][0]["latestAnnualPercentageRate"], + "min_amount": response["rows"][0]["minPurchaseAmount"], + "isActive": response["rows"][0]["canPurchase"] and response["rows"][0]["canRedeem"] and not response["rows"][0]["isSoldOut"]} return response except ClientError as error: print("Found error. status: {}, error code: {}, error message: {}".format(error.status_code, error.error_code, error.error_message)) diff --git a/libraries/wrappers/earn_gateio.py b/libraries/wrappers/earn_gateio.py index e9ff208..4772d9a 100644 --- a/libraries/wrappers/earn_gateio.py +++ b/libraries/wrappers/earn_gateio.py @@ -58,14 +58,18 @@ class gateio_earn: def get_available_products(self,coin): - url = "/earn/uni/currencies" + url = f"/earn/uni/currencies/{coin}" headers = {"Accept": "application/json", "Content-Type": "application/json"} query_param = "" sign_headers = self.gen_sign("GET", self.prefix+url, query_param) headers.update(sign_headers) response = requests.get(self.host+self.prefix+url, params=query_param, headers=sign_headers) if response.status_code == 200: - return response.json() + return {"coin": response.json()["currency"], + "product_id": response.json()["currency"], + "rate": response.json()["max_rate"], + "min_amount": response.json()["min_lend_amount"], + "isActive": True} else: return {"Error": response.text} @@ -77,7 +81,11 @@ class gateio_earn: headers.update(sign_headers) response = requests.get(self.host+self.prefix+url, headers=sign_headers) if response.status_code == 200: - return response.json() + return {"coin": response.json()["currency"], + "product_id": response.json()["currency"], + "rate": response.json()["max_rate"], + "min_amount": response.json()["min_lend_amount"], + "isActive": True} else: return {"Error": response.text} diff --git a/libraries/wrappers/earn_kucoin.py b/libraries/wrappers/earn_kucoin.py index 49b4741..c3a9349 100644 --- a/libraries/wrappers/earn_kucoin.py +++ b/libraries/wrappers/earn_kucoin.py @@ -61,7 +61,11 @@ class kucoin_earn: def get_available_products(self, coin): request = GetSavingsProductsReqBuilder().set_currency(coin).build() response = self.earn_api().get_savings_products(request) - return response.to_dict() + return {"coin": response.to_dict()["common_response"]["data"][0]["currency"], + "product_id": response.to_dict()["common_response"]["data"][0]["id"], + "rate": response.to_dict()["common_response"]["data"][0]["returnRate"], + "min_amount": response.to_dict()["common_response"]["data"][0]["userLowerLimit"], + "isActive": response.to_dict()["common_response"]["data"][0]["status"]=="ONGOING"} def subscribe_product(self, product_id, amount, auto_subscribe=True, source_account="SPOT"): diff --git a/libraries/wrappers/earn_okx.py b/libraries/wrappers/earn_okx.py index 6f34927..39a2f2b 100644 --- a/libraries/wrappers/earn_okx.py +++ b/libraries/wrappers/earn_okx.py @@ -129,7 +129,12 @@ class okx_earn: def get_available_products(self, coin): - return self.earning_api.get_public_borrow_info(coin) + response = self.earning_api.get_public_borrow_info(coin) + return {"coin": response["data"][0]["ccy"], + "product_id": response["data"][0]["ccy"], + "rate": response["data"][0]["avgRate"], + "min_amount": "0", + "isActive": True} def subscribe_product(self, coin, amount, rate=None): diff --git a/main.py b/main.py index fc032e6..b39bb0c 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,16 @@ gateio = earn_gateio.gateio_earn() if __name__=="__main__": #Available products - print(gateio.get_trading_balance("USDT")) + print("Binance:") + print(binance.get_available_products("USDT")) + print("="*80) + print("Gate.io:") + print(gateio.get_available_products("USDT")) + print("="*80) + print("Kucoin:") + print(kucoin.get_available_products("USDT")) + print("="*80) + print("OKX:") + print(okx.get_available_products("USDT"))