kucoin transfers
This commit is contained in:
parent
8e999d5049
commit
f0bfcacc45
|
|
@ -166,6 +166,9 @@ class earner:
|
||||||
position = self.connector.get_position(self.currency)
|
position = self.connector.get_position(self.currency)
|
||||||
if "Error" not in position:
|
if "Error" not in position:
|
||||||
redemption = self.connector.redeem_product(position["positionId"],amount=amount)
|
redemption = self.connector.redeem_product(position["positionId"],amount=amount)
|
||||||
|
time.sleep(1)
|
||||||
|
#The funds go to the funding account - transfer them to the trading account.
|
||||||
|
transfer_step = self.connector.transfer_to_trading(self.currency, amount)
|
||||||
else:
|
else:
|
||||||
print(f"{str(self.connector)} - Position not found!")
|
print(f"{str(self.connector)} - Position not found!")
|
||||||
self.write_to_log("Position not found! " + str(position))
|
self.write_to_log("Position not found! " + str(position))
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from kucoin_universal_sdk.generate.earn.earn.model_get_account_holding_req impor
|
||||||
from kucoin_universal_sdk.generate.earn.earn.model_purchase_req import PurchaseReqBuilder
|
from kucoin_universal_sdk.generate.earn.earn.model_purchase_req import PurchaseReqBuilder
|
||||||
from kucoin_universal_sdk.generate.earn.earn.model_redeem_req import RedeemReqBuilder
|
from kucoin_universal_sdk.generate.earn.earn.model_redeem_req import RedeemReqBuilder
|
||||||
from kucoin_universal_sdk.generate.account.account.model_get_spot_account_list_req import GetSpotAccountListReqBuilder
|
from kucoin_universal_sdk.generate.account.account.model_get_spot_account_list_req import GetSpotAccountListReqBuilder
|
||||||
|
from kucoin_universal_sdk.generate.account.transfer.model_flex_transfer_req import FlexTransferReqBuilder
|
||||||
|
|
||||||
class kucoin_earn:
|
class kucoin_earn:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -42,6 +43,7 @@ class kucoin_earn:
|
||||||
kucoin_rest_service = self.client.rest_service()
|
kucoin_rest_service = self.client.rest_service()
|
||||||
self.account_api = kucoin_rest_service.get_account_service().get_account_api
|
self.account_api = kucoin_rest_service.get_account_service().get_account_api
|
||||||
self.earn_api = kucoin_rest_service.get_earn_service().get_earn_api
|
self.earn_api = kucoin_rest_service.get_earn_service().get_earn_api
|
||||||
|
self.transfer_api = kucoin_rest_service.get_account_service().get_transfer_api
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
@ -127,6 +129,27 @@ class kucoin_earn:
|
||||||
return {"Error": response}
|
return {"Error": response}
|
||||||
|
|
||||||
|
|
||||||
|
def transfer_to_trading(self, coin, amount):
|
||||||
|
'''
|
||||||
|
Args:
|
||||||
|
coin (str): The coin to transfer to trading
|
||||||
|
amount (float): The amount to transfer
|
||||||
|
Returns:
|
||||||
|
dict: The response from the api
|
||||||
|
'''
|
||||||
|
request = FlexTransferReqBuilder().set_from_account_type("MAIN").set_to_account_type("TRADE").set_currency(coin).set_amount(str(amount)).set_type("INTERNAL").set_client_oid("1234").build()
|
||||||
|
response = self.transfer_api().flex_transfer(request).to_dict()
|
||||||
|
response_dict = response["common_response"]["data"]
|
||||||
|
if "orderId" in response_dict:
|
||||||
|
return {"Success": "",
|
||||||
|
"orderId": response["orderId"],
|
||||||
|
"txId": "",
|
||||||
|
"amount": amount
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {"Error": response}
|
||||||
|
|
||||||
|
|
||||||
def get_position(self, coin):
|
def get_position(self, coin):
|
||||||
'''
|
'''
|
||||||
Return {'common_response': {'code': '200000', 'data': {'totalNum': 1, 'items': [{'orderId': '2987632', 'productId': '2152', 'productCategory': 'DEMAND', 'productType': 'DEMAND', 'currency': 'USDT', 'incomeCurrency': 'USDT', 'returnRate': '0.04767484', 'holdAmount': '20', 'redeemedAmount': '0', 'redeemingAmount': '0', 'lockStartTime': 1641806718000, 'lockEndTime': None, 'purchaseTime': 1736027283000, 'redeemPeriod': 0, 'status': 'LOCKED', 'earlyRedeemSupported': 0}], 'currentPage': 1, 'pageSize': 15, 'totalPage': 1}, 'rate_limit': {'limit': 2000, 'remaining': 1995, 'reset': 16550}}, 'totalNum': 1, 'items': [{'orderId': '2987632', 'productId': '2152', 'productCategory': 'DEMAND', 'productType': 'DEMAND', 'currency': 'USDT', 'incomeCurrency': 'USDT', 'returnRate': '0.04767484', 'holdAmount': '20', 'redeemedAmount': '0', 'redeemingAmount': '0', 'lockStartTime': 1641806718000, 'purchaseTime': 1736027283000, 'redeemPeriod': 0, 'status': <StatusEnum.LOCKED: 'LOCKED'>, 'earlyRedeemSupported': <EarlyRedeemSupportedEnum.T_0: 0>}], 'currentPage': 1, 'pageSize': 15, 'totalPage': 1}
|
Return {'common_response': {'code': '200000', 'data': {'totalNum': 1, 'items': [{'orderId': '2987632', 'productId': '2152', 'productCategory': 'DEMAND', 'productType': 'DEMAND', 'currency': 'USDT', 'incomeCurrency': 'USDT', 'returnRate': '0.04767484', 'holdAmount': '20', 'redeemedAmount': '0', 'redeemingAmount': '0', 'lockStartTime': 1641806718000, 'lockEndTime': None, 'purchaseTime': 1736027283000, 'redeemPeriod': 0, 'status': 'LOCKED', 'earlyRedeemSupported': 0}], 'currentPage': 1, 'pageSize': 15, 'totalPage': 1}, 'rate_limit': {'limit': 2000, 'remaining': 1995, 'reset': 16550}}, 'totalNum': 1, 'items': [{'orderId': '2987632', 'productId': '2152', 'productCategory': 'DEMAND', 'productType': 'DEMAND', 'currency': 'USDT', 'incomeCurrency': 'USDT', 'returnRate': '0.04767484', 'holdAmount': '20', 'redeemedAmount': '0', 'redeemingAmount': '0', 'lockStartTime': 1641806718000, 'purchaseTime': 1736027283000, 'redeemPeriod': 0, 'status': <StatusEnum.LOCKED: 'LOCKED'>, 'earlyRedeemSupported': <EarlyRedeemSupportedEnum.T_0: 0>}], 'currentPage': 1, 'pageSize': 15, 'totalPage': 1}
|
||||||
|
|
|
||||||
10
profits.py
10
profits.py
|
|
@ -8,16 +8,19 @@ binance = earn_binance.binance_earn()
|
||||||
gateio = earn_gateio.gateio_earn()
|
gateio = earn_gateio.gateio_earn()
|
||||||
okx = earn_okx.okx_earn()
|
okx = earn_okx.okx_earn()
|
||||||
|
|
||||||
|
total_profits = []
|
||||||
print("Profits OKX:")
|
print("Profits OKX:")
|
||||||
total_rewards = Decimal(0)
|
total_rewards = Decimal(0)
|
||||||
rewards = okx.get_lending_history("USDT")
|
rewards = okx.get_lending_history("USDT")
|
||||||
for item in rewards["data"]:
|
for item in rewards["data"]:
|
||||||
total_rewards += Decimal(item["earnings"])
|
total_rewards += Decimal(item["earnings"])
|
||||||
print(total_rewards)
|
print(total_rewards)
|
||||||
|
total_profits.append(total_rewards)
|
||||||
|
|
||||||
print("Profits Gate.io:")
|
print("Profits Gate.io:")
|
||||||
print(gateio.get_rewards_history("USDT")["interest"])
|
total_rewards = gateio.get_rewards_history("USDT")["interest"]
|
||||||
|
print(total_rewards)
|
||||||
|
total_profits.append(Decimal(total_rewards))
|
||||||
|
|
||||||
print("Profits Binance:")
|
print("Profits Binance:")
|
||||||
total_rewards = Decimal(0)
|
total_rewards = Decimal(0)
|
||||||
|
|
@ -25,3 +28,6 @@ rewards = binance.get_rewards_history()
|
||||||
for item in rewards["rows"]:
|
for item in rewards["rows"]:
|
||||||
total_rewards += Decimal(item["rewards"])
|
total_rewards += Decimal(item["rewards"])
|
||||||
print(total_rewards)
|
print(total_rewards)
|
||||||
|
total_profits.append(total_rewards)
|
||||||
|
|
||||||
|
print(f"Total: {sum(total_profits)}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue