sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.91k stars 2.19k forks source link

cannot transfer from USD-M-Future account to spot account #771

Open ZhiminHeGit opened 3 years ago

ZhiminHeGit commented 3 years ago

Describe the bug Exception when transferring from USD-M-Future account to spot account

binance.exceptions.BinanceAPIException: APIError(code=-1102): Mandatory parameter 'type' was not sent, was empty/null, or malformed.

To Reproduce from binance.client import Client from binance.exceptions import * api_key = '**' api_secret = '***' client = Client(api_key, api_secret) client.futures_account_transfer(type='UMFUTURE_MAIN', asset='USDT', amount=50)

Expected behavior Transfer USDT from future USD-M-Future account to spot account

Environment (please complete the following information):

ZhiminHeGit commented 3 years ago

was able to execute the function when type is set to 1 or 2. however, there is not explanation on the range/meaning of the type parameter.

Angus-Less commented 3 years ago

was able to execute the function when type is set to 1 or 2. however, there is not explanation on the range/meaning of the type parameter.

If you go to the binance docs (that the function lists in the docstring), you can see that the mandatory 'type' is specified. So maybe use some forward judgement and look at the binance docs for the function's equivalent.

hacktek commented 3 years ago

was able to execute the function when type is set to 1 or 2. however, there is not explanation on the range/meaning of the type parameter.

If you go to the binance docs (that the function lists in the docstring), you can see that the mandatory 'type' is specified. So maybe use some forward judgement and look at the binance docs for the function's equivalent.

What are you referring to? The doc doesn't state an integer value for that parameter, it's supposed to be an ENUM

https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer

So what OP did should have worked. I'm trying to use this endpoint and don't feel comfortable using numbers as parameters that I don't know the meaning of.

EDIT: Ah, I see now. That's not the correct endpoint. Digging through the code I found a reference that leads here: https://binance-docs.github.io/apidocs/spot/en/#new-future-account-transfer-user_data

And that one does list the type as an integer.

1: transfer from spot account to USDT-Ⓜ futures account. 2: transfer from USDT-Ⓜ futures account to spot account. 3: transfer from spot account to COIN-Ⓜ futures account. 4: transfer from COIN-Ⓜ futures account to spot account.