gateio / gateapi-python

247 stars 92 forks source link

Transfer not working #75

Closed Workingsolutions1 closed 2 years ago

Workingsolutions1 commented 2 years ago

Trying to transfer 10 USDT from futures account to spot and it doesn't work, code is next:

`# !/usr/bin/env python

coding: utf-8

import logging import time from decimal import Decimal as D, ROUND_UP, getcontext

from gate_api import ApiClient, Configuration, Order, SpotApi, WalletApi, FuturesApi, FuturesOrder, Transfer from gate_api.exceptions import GateApiException from config import RunConfig

logger = logging.getLogger(name)

def spot_demo(): currency_pair = "BTC_USDT" currency = "USDT"

host_used = "https://api.gateio.ws/api/v4"
api_key = "key1"
api_secret = "key2"
# Initialize API client
# Setting host is optional. It defaults to https://api.gateio.ws/api/v4
config = Configuration(key=api_key, secret=api_secret, host=host_used)

wallet_api = WalletApi(ApiClient(config))
futures_api = FuturesApi(ApiClient(config))
futures_balance = futures_api.list_futures_accounts(currency.lower()).available
print(futures_balance)

transfer = Transfer(currency="USDT", amount=str(10), _from='futures', to='spot')
print(transfer.amount)
wallet_api.transfer(transfer)

spot_demo()`

Those are the errors:

`105.99474908522 10 Traceback (most recent call last): File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\api_client.py", line 190, in __call_api response_data = self.request( File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\api_client.py", line 471, in request return self.rest_client.POST( File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\rest.py", line 298, in POST return self.request( File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\rest.py", line 232, in request raise ApiException(http_resp=r) gate_api.exceptions.ApiException: (400) Reason: HTTP response headers: HTTPHeaderDict({'Date': 'Sun, 10 Oct 2021 17:19:54 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty', 'X-Frame-Options': 'SAMEORIGIN', 'X-Powered-By': 'CF ()', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache, must-revalidate', 'Set-Cookie': 'login_notice_check=%2F; path=/; secure; HttpOnly'}) HTTP response body: {"label":"INVALID_PARAM_VALUE","message":"Invalid settle"}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\root\PycharmProjects\gateapi-python\example\spot.py", line 34, in spot_demo() File "C:\Users\root\PycharmProjects\gateapi-python\example\spot.py", line 32, in spot_demo wallet_api.transfer(transfer) File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\api\wallet_api.py", line 429, in transfer return self.transfer_with_http_info(transfer, **kwargs) # noqa: E501 File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\api\wallet_api.py", line 494, in transfer_with_http_info return self.api_client.call_api( File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\api_client.py", line 395, in call_api return self.__call_api( File "C:\Users\root\PycharmProjects\gateapi-python\gate_api\api_client.py", line 209, in __call_api raise GateApiException(err.get('label'), err.get('message'), err.get('detail'), e) gate_api.exceptions.GateApiException: (400) Reason: HTTP response headers: HTTPHeaderDict({'Date': 'Sun, 10 Oct 2021 17:19:54 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty', 'X-Frame-Options': 'SAMEORIGIN', 'X-Powered-By': 'CF ()', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache, must-revalidate', 'Set-Cookie': 'login_notice_check=%2F; path=/; secure; HttpOnly'}) HTTP response body: {"label":"INVALID_PARAM_VALUE","message":"Invalid settle"}

Process finished with exit code 1 `

revilwang commented 2 years ago

The error message tells that you need to set settle field when transferring from or to futures account, which is either btc or usdt