Margin is insufficient binance пишет

Getting <"code":-2019,"msg":"Margin is insufficient." errors for funded accounts #7542

Comments

cadmufasa commented Aug 31, 2020 •

OS: Linux PYTHONWORK 5.3.0-18-generic #19-Ubuntu SMP Tue Oct 8 20:14:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Programming Language version: Python 2.7.17
CCXT version: latest
Exchange: binance
Method: fapiPrivatePostMarginType, createOrder

This is in reference to an earlier message: #7534

I am not understanding why this Order will not go through. I keep getting the following error:

This is what is associated with the SPOT account for USDT:

command executed: wallets = exchange.fetch_balance()

This is what is associated with the FUTURES account for USDT

command executed: wallets = exchange.fetch_balance()

NOTE: Even though both use the command «wallets = exchange.fetch_balance()» above, the connections are initiailzed differently

For the MARGIN connection:

For the SPOT connecton:

ETA:
I forgot to add the information below (related to executing a SELL order on FUTURES:
=> CHANGED MARGIN TO 1 (which supposedly is like not taking out any margin at all)

retval = exchange.createOrder( in_symbol, k_type, side, in_amount, None, server_params )

/root/trade_exchange/api_work/trade_binance/bin_market.py(342)create_market_order()
-> retval = exchange.createOrder( in_symbol, k_type, side, in_amount, None, server_params )

The text was updated successfully, but these errors were encountered:

kroitor commented Aug 31, 2020

I am not understanding why this Order will not go through. I keep getting the following error:

First of all, you have to understand Binance accounts, there’s a bunch of them:

  • spot account
  • margin account (trade spot markets with leverage)
  • swap futures account (has its own margin, don’t confuse it with the margin account)
  • delivery futures account (has its own margin, do not confuse it. )

So, the system is saying that you need margin on your futures account to execute that order.

In order to help you we need your code to reproduce it, including the exchange instantiation, and your verbose request+response (always paste that info, but without your keys of course):

↑ Edit the above snippet for your values and paste your output including the verbose request and verbose response.

cadmufasa commented Aug 31, 2020 •

Hi kroitor and thanks for the response.

A -> spot account
B -> margin account (trade spot markets with leverage)
C -> swap futures account (has its own margin, don’t confuse it with the margin account)
D -> delivery futures account (has its own margin, do not confuse it. )

For now, I just want to work with A, B, and C but .

Question though : On the Binance UI, which item represents D ( «delivery futures account» )
-> JEX or
-> P2P or
-> BPLAY or .

Before starting this task, could you point me to the code that will allow me to transfer funds from SPOT to the FUTURES Margin account?

I cleaned up the first post I made above (so it could be more clear). I have not had the opportunity to clean the code up as of yet.

I thought the funds transferred to a MARGIN account would be service the FUTURES, SPOT and any other accounts. In other words, I though that one MARGIN account would serve them all.

I only mentioned this because I thought I saw some video stating that if one opened a type of SPOT order (using MARGIN) that became FILLED and then later opened a FUTURES order (also using MARGIN) — for example — a MARKET FUTURES order that ALSO used MARGIN, then there was a high probability that the ORIGINAL position (using the SPOT/MARGIN) would be LIQUIDATED

Читайте также:  Азиатский банк инфраструктурных инвестиций проекты

This suggested to me that all accounts were using the same MARGIN («pool») source.

From what you are saying, each account (SPOT, FUTURES, etc.) has its very own margin account

If that is true, then my transfer of funds to a MARGIN account would not work in the case of using FUTURES (if I am understanding things correctly).

Given that being the case, then would not something like the item below resolve the problem? My understanding is that the command can transfer funds from SPOT to an ISOLATED MARGIN account (which is what I was using for FUTURES).

If so, how would could it be done within CCXT.

kroitor commented Sep 1, 2020 •

Question though : On the Binance UI, which item represents D ( «delivery futures account» )

Historically, Binance had a spot account and a futures account (for perpetual contracts or swaps).
There’s a bit of a naming confusion here, because perpetual futures contracts are called swaps in CCXT, as opposed to classic futures with a delivery date.
Binance has recently introduced the classic futures, and they did some renaming on their API docs, so previously they had:

  • spot+margin
  • perpetual futures (swaps)

. and now they have:

  • spot+margin
  • perpetual futures (swaps)
  • delivery futures, this is not implemented in the master branch of CCXT yet, however, the work on it is going on here:
    • #7117
    • #7474

Before starting this task, could you point me to the code that will allow me to transfer funds from SPOT to the FUTURES Margin account?

You can do that using the implicit API methods:

From what you are saying, each account (SPOT, FUTURES, etc.) has its very own margin account

That is correct.

If that is true, then my transfer of funds to a MARGIN account would not work in the case of using FUTURES (if I am understanding things correctly).

That is correct.

Given that being the case, then would not something like the item below resolve the problem?

Which problem, specifically?

My understanding is that the command can transfer funds from SPOT to an ISOLATED MARGIN account (which is what I was using for FUTURES).

You should transfer funds from some of your accounts to your futures account in order to trade futures with margin. The Binance’s margin account is for spot-markets only, and you can’t use it for trading futures, because futures have their own account with its own margin. Transferring to a futures account is done as shown above.

If so, how would could it be done within CCXT.

You have to clearly specify the task you’re trying to solve, so that I could show how that could be done within CCXT. In general, with CCXT you can call any endpoint supported by the exchange, so you can pretty much do anything as long as it is allowed by the exchange itself. Transferring to a futures margin account is shown above. Let me know if that answers your question or not.

cadmufasa commented Sep 1, 2020

Thanks for getting back to me so quickly. It is appreciated!

Above, I had mentioned receiving the following:

when trying to create an Order using a FUTURES account. I was transferring funds to the MARGIN account — but — the MARGIN account only works with the SPOT and not the FUTURES. The information you provided above should allow me to transfer funds to the FUTURES MARGIN account — and — hopefully — get past this latest error.

I will update the post with my findings.

cadmufasa commented Sep 1, 2020 •

I have been able to transfer funds to the FUTURES account using this command.

Читайте также:  Что такое bts криптовалюта

It does show up in the Binance User Interface as well.

That was no issue.

The problem was that when executing:

retval = exchange.createOrder( in_symbol, k_type, side, in_amount, None, server_params )

I got the following error:
ccxt.base.errors.ExchangeError: binance

After your input above, I thought to attempt to transfer funds to the ISOLATED MARGIN account directly.
Pls see: https://binance-docs.github.io/apidocs/spot/en/#create-isolated-margin-account-margin

I WAS REFERRING TO THIS FOR ISOLATED MARGIN

with a focus of executing this command:

Isolated Margin Account Transfer (MARGIN)

def create_market_order (in_client_id : int = 0, in_symbol : str = », in_amount : float = 0, in_market : int = 0,
in_side : str = » ):

kroitor commented Sep 1, 2020 •

The problem was that when executing:

retval = exchange.createOrder( in_symbol, k_type, side, in_amount, None, server_params )

I got the following error:
ccxt.base.errors.ExchangeError: binance

First of all, when you mention any error, please, always paste the full code to reproduce it, including the instantiation code, since we can’t guess what exactly you’re executing on your side without seeing the code itself. Apart from that it is mentioned everywhere, in the Manual and in the FAQ, that we always ask for your verbose request + response in case of any error:

Basically, your code for creating a futures margin order should look like so:

↑ Edit this snippet for your keys, symbol, amount and other values and launch it on your side. Then please copy-paste all of your output here.

with a focus of executing this command:

Isolated Margin Account Transfer (MARGIN) sapi_post_margin_isolated_transfer . You can see all available methods and their names as documented in the Manual:

However, in your case, if you’re trying to place a futures margin order, you don’t need to use the margin account for spot markets.

cadmufasa commented Sep 1, 2020

Thanks again for the quick response. Will apply what you have written.

kroitor commented Sep 1, 2020 •

Basically, placing the futures order depends on whether your futures margin mode is ISOLATED or CROSSED and depending on that you must either have enough margin on your entire futures-margin account, or enough margin on the futures-margin account for a specific isolated symbol/position.

kroitor commented Sep 1, 2020 •

Forget about spot margin sapi – you don’t need it if you want to trade futures.
Futures accounts have their own margin.
This message says that you don’t have enough margin on your futures margin account related to your position, it has nothing to do with the spot margin (or sapi ):

That message will pop up depending on how exactly you want to trade futures, considering the variety of trading modes.

In short, Binance’s API is structured as follows and you should understand the meaning and the difference between ISOLATED vs CROSSED margin mode and the difference between Hedged positions vs One-way positions.

  • wapi: funding for withdrawals and deposits (wapi)
  • api: spot (api)
  • sapi: spot margin
    • CROSSED margin mode
      • Hedged positions
      • One-way positions
    • ISOLATED margin mode
      • Hedged positions
      • One-way positions
  • fapi: swap/perpetual futures margin
    • CROSSED margin mode
      • Hedged positions
      • One-way positions
    • ISOLATED margin mode
      • Hedged positions
      • One-way positions
  • dapi: classic delivery futures margin
    • CROSSED margin mode
      • Hedged positions
      • One-way positions
    • ISOLATED margin mode
      • Hedged positions
      • One-way positions

↑ You should pick the following:

  1. which API you want to trade (fapi, i believe)
  2. which specific margin mode you want (CROSSED or ISOLATED)
  3. which specific position mode you want (Hedged or One-way)

Differences in margin modes:

  • CROSSED margin mode = you have one futures-margin account for all your positions, if some position requires too much margin, your entire account is affected, leaving less margin for the other positions, thus you share the same margin «across» all your positions.
  • ISOLATED margin mode = you have separate futures-margin for each of your positions, if some position runs out of margin the other positions are not affected, thus your positions are «isolated» from one another.
Читайте также:  Территория инвестиций нижегородской области

Difference in position modes:

  • One-way position mode — when you’re in this mode, there’s no such thing as LONG or SHORT positions. You just buy or sell a number of contracts, and if the price goes down, your PnL goes negative, if the price goes up, your PnL is positive. Thus, the position operates BOTH ways, both long and short at the same time, the notion of «long» and «short» is abstracted away from you, so there’s only one way the position can go and that way is called «both».
  • Hedge mode — you either enter a LONG position or a SHORT position and your PnL calculation rules depend on that, so there’s a number of ways a position can go.

Which specific mode of trading (margin mode + position mode) do you want?

Источник

На Binance происходит что-то странное с ордерами и балансами счетов

Поделиться

Пользователи криптовалютной биржи Binance жалуются на некорректную обработку ордеров и отображение остатков на счетах. В некоторых случаях со счетов исчезли все деньги, потому что кошельки биржи некорректно отображали нулевой баланс.

Трейдеры обеспокоены, потому что жалобы относительно работы сервисов Binance продолжают поступать. Некоторые также отмечают абсолютно некорректное отображение размещенных торговых ордеров. Более того, пользователи сообщают, что сделки осуществляются, но остатки на счетах при этом не обновляются. Ошибки зафиксируются на глобальном уровне, пользователями из разных стран.

Недавний твит пользователя Crypto Krillin (@LSDinmycoffee) привлек внимание многих пользователей криптовалюты. В комментариях под его постом трейдеры подтвердили, что у них тоже возникли проблемы с Binance.

Binance balances are not even correct. Orders not being processed.

I’m started to get worried.

Instead of a «funds are SAFU», CZ is telling us we’ll be able to trade $NEO x50 tomorrow.

Некоторые даже сообщают о полном обнулении своих счетов – на балансе отображается ноль. Очевидно, что ошибка вызвана техническим сбоем, который затронул многих пользователей, независимо от их географического местоположения.

I lost my whole account it shows no balance rn ……

No big deal, my wallet says I’ve been liquidated of my entire portfolio.

На момент написания статьи глава биржи Чангпенг Чжао (CZ) написал туманный комментарий, не добавивший ясность в происходящее. По его словам, на платформе возникли функциональные проблемы, и команда активно работает над их решением. Он также добавил что в течение суток опубликует подробный отчет, в котором расскажет, что случилось, и какие меры предприняты.

Writing a detailed report on some of the perf issues we face in the last few days. Will publish in 24h or so. It’s not the first time @Binance faced challenges, and it won’t be the last time we solve them. We are humbled to have the heaviest traffic in crypto, and your support!

Если ошибку не удастся устранить в ближайшее время, репутация Binance может серьезно пострадать, поскольку она всегда позиционировала себя как безопасное место для криптовалютных активов. “Деньги в безопасности” – ключевая идея концепции Binance. Надеемся, что в скором времени биржа внесет ясность в эту ситуацию.

Последние несколько дней торговая платформа сталкивается со шквалом критики относительно функционирования ряда сервисов. Несколько дней назад трейдеры отмечали сложности с выставлением ордеров на покупку BTC/USDT на Binance. Крупные трейдеры получили сообщение об ошибке, когда пытались взять заем в USDT для маржинальной торговли. Тогда глава Binance Чангпенг Чжао (CZ) признал «небольшую задержку в отображении книги приказов по нескольким торговым парам» и сказал, что команда активно работает над этим.

Проблема с отображением остатков на счетах совпала с массовыми распродажами на криптовалютном рынке. Биткоин потерял лишь 1.3% своей стоимости в дневном исчислении, однако некоторые монеты показали просадку, исчисляемую двузначными числами. Пока неясно, мог ли сбой в работе платформы усилить распродажи на рынке. На момент написания статьи объем торгов на Binance составляет 2,7 млрд долларов.

Источник

Оцените статью