ccxt: Can't create any order on binance futures

I just can’t get futures orders running

response = await self.account.exchange.fapiPrivate_post_order({  # noqa: unresolved
                        'symbol': self.formattedSymbol,
                        'side': self.account.side,
                        'positionSide': _positionSide,
                        'quantity': _amount,
                        'type': 1
                        })

Getting “Invalid order type”

response = await self.account.exchange.fapiPrivate_post_positionmargin({  # noqa: unresolved
                         'symbol': self.account.futureMarketAsset['id'],
                         'amount': _amount,
                         'positionSide': _positionSide,  # BOTH for One-way positions, LONG/SHORT for Hedge Mode # noqa
                         'type': _side,  # 1 = add position margin, 2 = reduce position margin # noqa
                     })

Getting “Cannot add position margin: position is 0.”


if futures:
    self.amount = self.account.exchange.amount_to_precision(self.formattedSymbol, self.futureAmount)
await self.account.exchange.create_order(amount=self.amount, side=self.account.side,
                                         symbol=self.formattedSymbol, type=self.account.orderType,
                                         params=params)

Getting binance {“code”:-4061,“msg”:“Order’s position side does not match user’s setting.”}

It becomes somewhat tiring, is there any documentation on this, couldn’t find it in the manual. Also can’t find any documentation on the specific fapi methods, the code is unreachable, and couldn’t find it in the manual.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (11 by maintainers)

Most upvoted comments

@Salz0 it’s a shorthand that we added recently for more convenient initialization of binance futures, without having to specify the defaultType.