unified get_available_products result
This commit is contained in:
parent
28cd48c7e7
commit
2e3427d448
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
12
main.py
12
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"))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue