---
openapi: 3.0.1
info:
  title: Marketdata API v4
  description: APIs related to marketdata operations
  version: v4
paths:
  /marketdata/api/v4/instruments/{marketSymbol}/history:
    get:
      tags:
        - ChartingControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: marketSymbol
          in: path
          required: true
          schema:
            type: string
        - name: type
          in: query
          schema:
            type: string
        - name: startDate
          in: query
          schema:
            type: string
            format: date-time
        - name: endDate
          in: query
          schema:
            type: string
            format: date-time
        - name: count
          in: query
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingHistoryV4.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /marketdata/api/v4/instruments/{marketSymbol}/funding:
    get:
      tags:
        - ChartingControllerV
      description: "Required operations: trading-ui"
      parameters:
        - name: marketSymbol
          in: path
          required: true
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            format: int32
        - name: offset
          in: query
          schema:
            type: integer
            format: int32
        - name: appliedAtFrom
          in: query
          schema:
            type: string
            format: date
        - name: appliedAtTo
          in: query
          schema:
            type: string
            format: date
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingFundingV4.Response
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /marketdata/api/v4/guest/instruments/{marketSymbol}/history:
    get:
      tags:
        - GuestChartingControllerV
      description: >-
        Anonymous counterpart of GET
        /marketdata/api/v4/instruments/{marketSymbol}/history. No authentication
        and no required operations. Returns the same schema; candle prices are not
        account-specific and can differ from the authenticated endpoint's response
        for the same market and window. type, startDate, and endDate are required
        here: the requested window is capped server-side per timeframe (30 days for
        sub-hourly, 365 days for hourly, 5 years for daily and above) and a
        missing, malformed, or oversized window returns 400. A market hidden from
        traders returns an empty candle set rather than an error.
      parameters:
        - name: marketSymbol
          in: path
          required: true
          schema:
            type: string
        - name: type
          in: query
          required: true
          schema:
            type: string
        - name: startDate
          in: query
          required: true
          schema:
            type: string
            format: date-time
        - name: endDate
          in: query
          required: true
          schema:
            type: string
            format: date-time
        - name: count
          in: query
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingHistoryV4.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
  /marketdata/api/v4/guest/instruments/{marketSymbol}/funding:
    get:
      tags:
        - GuestChartingControllerV
      description: >-
        Anonymous counterpart of GET
        /marketdata/api/v4/instruments/{marketSymbol}/funding. No authentication
        and no required operations. Returns the same schema — funding event
        history is account-independent. An unknown market symbol, or a market
        that is not a Perpetual, returns 400.
      parameters:
        - name: marketSymbol
          in: path
          required: true
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            format: int32
        - name: offset
          in: query
          schema:
            type: integer
            format: int32
        - name: appliedAtFrom
          in: query
          schema:
            type: string
            format: date
        - name: appliedAtTo
          in: query
          schema:
            type: string
            format: date
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingFundingV4.Response
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BBP.Platform.Http.ErrorData'
components:
  schemas:
    BBP.Platform.Authorization.AccountContext.AccountContextFeature:
      type: object
      properties:
        accountId:
          type: string
      additionalProperties: false
    BBP.Platform.Authorization.AccountContext.UserContextFeature:
      type: object
      properties:
        userId:
          type: string
          format: uuid
      additionalProperties: false
    BBP.Platform.Http.ErrorData:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        details:
          $ref: '#/components/schemas/BBP.Platform.Http.ErrorData.ErrorDetails'
      additionalProperties: false
    BBP.Platform.Http.ErrorData.ErrorDetails:
      type: object
      properties:
        source:
          type: string
          nullable: true
        message:
          type: string
          nullable: true
        stackTrace:
          type: string
          nullable: true
      additionalProperties: false
    BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingFundingV4.Funding:
      type: object
      properties:
        appliedAt:
          type: string
          format: date-time
        interval:
          type: integer
          format: int32
        rate:
          type: string
      additionalProperties: false
    BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingFundingV4.Response:
      type: object
      properties:
        fundingData:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingFundingV4.Funding
        hasMore:
          type: boolean
      additionalProperties: false
    BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingHistoryV4.Response:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: >-
              #/components/schemas/BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingHistoryV4.Response.CandleInfo
      additionalProperties: false
    BBP.TradingServer.MarketDataApi.Models.v4.ApiChartingHistoryV4.Response.CandleInfo:
      type: object
      properties:
        instrument:
          type: string
          nullable: true
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
        low:
          type: string
        high:
          type: string
        open:
          type: string
        close:
          type: string
      additionalProperties: false
