Bybit Api - CannotAffordOrderCost problem - Code 130021

589 views Asked by At

I'm trying to open a long position to OPUSDT coin, but I always get the "CannotAffordOrderCost" error.

Numbers are here;

  1. Mark price of OPUSDT Coin: 1.708$
  2. Wallet Balance in USDT: 108.96975186$
  3. Leverage: 10x
  4. Position size in USDT with leverage: 871.8$
  5. Position amount in OP: 510.4

So the position I'm trying to open a position with 87$. Why API returning this error? I know I have enough money for this position.

    const order: APIResponseWithTime<LinearOrder | null> = await client.placeActiveOrder({
        symbol: `${position.symbol}`,
        reduce_only: false,
        close_on_trigger: false,
        order_type: "Market",
        qty: positionAmount,
        side: "Buy",
        time_in_force: "GoodTillCancel",
    });
1

There are 1 answers

0
Murat Karagozgil On

Thanks for the answer @DamiToma

The problem is position amount calculation should be based on available balance, not total wallet balance.