Function calculateGrossFillQuantities

  • Determines the liquidity available in the given order book (asks or bids) for a given taker quantity (which may be expressed in base or quote asset) and price (optional). In other words, it performs very basic order matching to provide an estimate of the base and quote quantities with which a taker order of the given size (quantity) and limit price (optional) would be filled.

    The taker order may represent a limit or a market order: If a limit price is given, it is matched as a limit order (which necessitates specifying whether it's a buy or a sell). Otherwise it is matched as a market order.

    The provided list of orders or price levels (asks or bids) is expected to be sorted by best price (ascending for asks (lowest first), descending for bids (highest first)). Multiple orders per price level are supported.

    To support high-precision calculations in which pip-precision is insufficient, the result may optionally be returned in double-pip precision; the returned values then represent numbers with 16 decimals instead of 8.

    Parameters

    • makerSideOrders: Iterable<PriceAndSize>
    • takerOrder: {
          side: OrderSide;
          quantity: bigint;
          isQuantityInQuote: boolean;
          limitPrice?: bigint;
      }
      • side: OrderSide
      • quantity: bigint
      • isQuantityInQuote: boolean
      • Optional limitPrice?: bigint
    • returnInDoublePipPrecision: boolean = false

      Defaults to false

    Returns {
        baseQuantity: bigint;
        quoteQuantity: bigint;
    }

    • baseQuantity: bigint
    • quoteQuantity: bigint