I’m trying to submit a margin buy order from python but encountered a “Margin account does not exist” error. I have activated my margin account already and flagged
the API to enable margin trade. What’s wrong in this case?
from binance.client import Client
from binance.exceptions import BinanceAPIException
api_key = ‘…’
api_secret = ‘…’
client = Client(api_key=api_key, api_secret=api_secret)
from binance.enums import *
order = client.create_margin_order(
BinanceAPIException: APIError(code=-3003): Margin account does not exist
Can you try to create a new API Key and try again, please?
Are you able to create order via UI?
Created another API key still get the error
BinanceAPIException: APIError(code=-3003): Margin account does not exist.
yes, I can create order via UI without any problem.
Ok, to make sure of you’re steps, can you confirm the following:
- You passed the margin quiz to open the margin account;
- You have USDT balance on margin account;
- You opened a new API after creating a the margin account;
- You have the margin permissions enabled on the new API;
- You’re using the correct API Key when using the order endpoint;
Is this right?
Are you able to use
In addition, can you share a screenshot of your API Key’s permissions settings and also share the exact request URL in query-string, please?
Yes, I followed exactly the same steps 1 to 5.
I can execute
info = client.get_margin_asset(asset=‘BNB’)
transaction = client.transfer_spot_to_margin(asset=‘BTC’, amount=‘0.001’)
failed as well with an error bellow.
BinanceAPIException: APIError(code=-1002): You are not authorized to execute this request.
You are not authorized to execute this request. error is probably related with “Enable Margin…Transfer” permission not been enabled.
For the original error message, thanks for verifying the steps! Just one more request, can you try to send Margin Order request with the Postman to see if it’s not related with the library ( I think it’s python-binance) that you’re using, please?
Please share the request URL in query string afterwards here.