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

# Backtest

> Backtest a funding arbitrage pair

Uses settled funding rates for the latest 30 days and daily aggregates for earlier dates.

```bash theme={null}
curl -X POST "https://api.bendbasis.com/v1/funding/arbitrage/backtest" \
  -H "Content-Type: application/json" \
  -d '{"long_market_id":15036,"short_market_id":125}'
```


## OpenAPI

````yaml POST /v1/funding/arbitrage/backtest
openapi: 3.1.0
info:
  title: bendbasis API
  description: Funding market and arbitrage data from bendbasis.
  version: 1.0.0-preview
servers:
  - url: https://api.bendbasis.com
security: []
tags:
  - name: Portfolio
    description: Read-only access to your portfolios and positions.
paths:
  /v1/funding/arbitrage/backtest:
    post:
      summary: Backtest
      description: >-
        Backtests a funding arbitrage pair for up to 365 days. Dates default to
        the latest seven completed UTC days. Uses settled funding rates for the
        latest 30 days and daily aggregates for earlier dates.
      operationId: runFundingArbitrageBacktest
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FundingBacktestRequest'
            example:
              long_market_id: 15036
              short_market_id: 125
              from: '2026-09-01'
              to: '2026-09-02'
              notional_per_leg: 10000
              execution_cost_pct: 0.4
      responses:
        '200':
          description: Backtest result
          headers:
            X-API-Version:
              schema:
                type: string
              example: v1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FundingBacktestResponse'
              example:
                data:
                  from: '2026-09-01'
                  to: '2026-09-02'
                  notional_per_leg: 10000
                  execution_cost_pct: 0.4
                  summary:
                    funding_pnl: -0.7729115921
                    execution_cost: 40
                    net_pnl: -40.7729115921
                    net_return_pct: -0.4077291159
                    net_apr: -148.8211273112
                  series:
                    - timestamp: '2026-09-01T00:00:00.000Z'
                      funding_pnl: -0.6303
                      execution_cost: 20
                      net_pnl: -20.6303
                      cumulative_net_pnl: -20.6303
                    - timestamp: '2026-09-01T08:00:00.000Z'
                      funding_pnl: 0
                      execution_cost: 0
                      net_pnl: 0
                      cumulative_net_pnl: -20.6303
                    - timestamp: '2026-09-01T16:00:00.000Z'
                      funding_pnl: -0.1426115921
                      execution_cost: 20
                      net_pnl: -20.1426115921
                      cumulative_net_pnl: -40.7729115921
        '400':
          description: Invalid request or market pair.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    FundingBacktestRequest:
      type: object
      additionalProperties: false
      required:
        - long_market_id
        - short_market_id
      properties:
        long_market_id:
          type: integer
          minimum: 1
        short_market_id:
          type: integer
          minimum: 1
        from:
          type: string
          format: date
          description: Inclusive start.
        to:
          type: string
          format: date
          description: Exclusive end.
        notional_per_leg:
          type: number
          exclusiveMinimum: 0
          maximum: 1000000000000
          default: 10000
          description: USD notional allocated to each leg.
        execution_cost_pct:
          type: number
          minimum: 0
          maximum: 100
          default: 0.4
          description: Total opening and closing cost as a percentage of per-leg notional.
    FundingBacktestResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - from
            - to
            - notional_per_leg
            - execution_cost_pct
            - summary
            - series
          properties:
            from:
              type: string
              format: date
            to:
              type: string
              format: date
            notional_per_leg:
              type: number
              description: USD notional allocated to each leg.
            execution_cost_pct:
              type: number
              description: >-
                Total opening and closing cost as a percentage of per-leg
                notional.
            summary:
              $ref: '#/components/schemas/FundingBacktestSummary'
            series:
              type: array
              items:
                $ref: '#/components/schemas/FundingBacktestPoint'
    ValidationError:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          enum:
            - VALIDATION_ERROR
        message:
          type: string
      example:
        code: VALIDATION_ERROR
        message: Invalid parameter
    FundingBacktestSummary:
      type: object
      required:
        - funding_pnl
        - execution_cost
        - net_pnl
        - net_return_pct
        - net_apr
      properties:
        funding_pnl:
          type: number
          description: Funding PnL in USD.
        execution_cost:
          type: number
          description: Modeled execution cost in USD.
        net_pnl:
          type: number
          description: PnL after execution cost in USD.
        net_return_pct:
          type: number
          description: Net return against per-leg notional, in percent.
        net_apr:
          type: number
          description: Annualized net return in percent.
    FundingBacktestPoint:
      type: object
      required:
        - timestamp
        - funding_pnl
        - execution_cost
        - net_pnl
        - cumulative_net_pnl
      properties:
        timestamp:
          type: string
          format: date-time
        funding_pnl:
          type: number
          description: Funding PnL in USD.
        execution_cost:
          type: number
          description: Modeled execution cost in USD.
        net_pnl:
          type: number
          description: PnL after execution cost in USD.
        cumulative_net_pnl:
          type: number
          description: Cumulative net PnL in USD.
  responses:
    RateLimited:
      description: Rate limit exceeded.

````