> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fairground.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# GetEstimatedFees

> Estimates the trading fee for opening a position, given the margin
 you plan to post and the leverage you intend to use. The fee is
 computed as if it were deducted from `margin` upfront, before the
 position opens: `fee = (rate / (1 + rate)) * margin`, where `rate`
 is the market's configured trade-fee rate multiplied by `leverage`.

 If the market has no trade-fee percentage configured, this returns
 a successful response with `fees: -1` rather than an error.



## OpenAPI

````yaml /developers/api-reference/openapi.yaml post /order_service.v1.OrderService/GetEstimatedFees
openapi: 3.1.0
info:
  title: Fairground.Fi API
  description: |
    API for the Fairground Perpetuals trading platform.

    This API uses ConnectRPC which accepts JSON over HTTP POST requests.
    All service endpoints follow the pattern: `/package.ServiceName/MethodName`
  version: 1.0.0
  contact:
    name: Forte Service Company
    url: https://github.com/Forte-Service-Company-Ltd/perpetuals-api-server
  license:
    name: Proprietary
    identifier: UNLICENSED
servers:
  - url: https://api.fairground.fi
    description: Production API server
security:
  - bearerAuth: []
tags:
  - name: Trades
    description: Wallet trade/fill history
  - name: Markets
    description: Market configuration and summary endpoints
  - name: Orderbook
    description: Orderbook data retrieval
  - name: Orders
    description: Order management operations
  - name: Portfolio
    description: Aggregated per-wallet portfolio data
  - name: Positions
    description: Position management operations
  - name: Prices
    description: Oracle price and historical price data
paths:
  /order_service.v1.OrderService/GetEstimatedFees:
    post:
      tags:
        - Orders
      summary: GetEstimatedFees
      description: |-
        Estimates the trading fee for opening a position, given the margin
         you plan to post and the leverage you intend to use. The fee is
         computed as if it were deducted from `margin` upfront, before the
         position opens: `fee = (rate / (1 + rate)) * margin`, where `rate`
         is the market's configured trade-fee rate multiplied by `leverage`.

         If the market has no trade-fee percentage configured, this returns
         a successful response with `fees: -1` rather than an error.
      operationId: order_service.v1.OrderService.GetEstimatedFees
      parameters:
        - name: Connect-Protocol-Version
          in: header
          required: true
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
        - name: Connect-Timeout-Ms
          in: header
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/order_service.v1.GetEstimatedFeesRequest'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/order_service.v1.GetEstimatedFeesResponse'
              example:
                fees: 4.49
components:
  schemas:
    connect-protocol-version:
      type: number
      title: Connect-Protocol-Version
      enum:
        - 1
      description: Define the version of the Connect protocol. If omitted, use 1.
      const: 1
      default: 1
    connect-timeout-header:
      type: number
      title: Connect-Timeout-Ms
      description: Define the timeout, in ms
    order_service.v1.GetEstimatedFeesRequest:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
          description: Market to estimate the fee for.
        margin:
          type: number
          title: margin
          format: float
          description: Collateral you plan to post for the position, in quote asset units.
        leverage:
          type: number
          title: leverage
          format: float
          description: |-
            Leverage multiplier you intend to use. Combined with the
            market's configured trade-fee rate to compute the effective fee
            rate.
        size:
          type: number
          title: size
          format: float
          description: >-
            Currently unused by the server. Reserved for future fee calculations
            that account for position size.
        price:
          type: number
          title: price
          format: float
          description: >-
            Currently unused by the server. Reserved for future fee calculations
            that account for entry price.
      title: GetEstimatedFeesRequest
      additionalProperties: false
    order_service.v1.GetEstimatedFeesResponse:
      type: object
      properties:
        fees:
          type: number
          title: fees
          format: float
          description: |-
            Estimated fee in USDC, deducted from `margin` upfront. `-1` if
            the market has no trade-fee percentage configured.
      title: GetEstimatedFeesResponse
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````