level2 Backtesting API

Endpoints for running backtests on strategies against historical market data to validate performance before live deployment.

Operations 1

POST /broker/users/{userId}/strategies/{strategyId}/backtest Backtest a user strategy #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/level2-backtesting-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

level2-backtesting-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Level2 TradeStation Integration Backtesting API
  description: The Level2 TradeStation Integration API enables broker partners to embed the Level2 visual strategy builder into their trading platforms and manage user strategies programmatically. This API connects the Level2 no-code strategy builder with TradeStation Securities brokerage accounts, allowing traders to create automated strategies using a drag-and-drop interface and execute them in real time through their TradeStation accounts. The API supports strategy lifecycle management including creation, retrieval, updating, deployment, and deletion of user strategies, as well as backtesting against historical market data.
  version: 1.0.0
  contact:
    name: Level2 Broker Support
    url: https://learn.trylevel2.com/docs/category/brokers
  termsOfService: https://www.trylevel2.com/terms-and-conditions
servers:
- url: https://api.trylevel2.com/v1
  description: Production Server
security:
- bearerAuth: []
tags:
- name: Backtesting
  description: Endpoints for running backtests on strategies against historical market data to validate performance before live deployment.
paths:
  /broker/users/{userId}/strategies/{strategyId}/backtest:
    post:
      operationId: backtestUserStrategy
      summary: Backtest a user strategy
      description: Runs a backtest on the specified strategy against historical market data for the configured instruments and date range. Returns performance metrics including profit and loss, win rate, maximum drawdown, Sharpe ratio, and trade-by-trade results. Backtesting enables traders to validate strategy effectiveness before deploying with real capital.
      tags:
      - Backtesting
      parameters:
      - $ref: '#/components/parameters/userId'
      - $ref: '#/components/parameters/strategyId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BacktestRequest'
      responses:
        '200':
          description: Backtest completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BacktestResponse'
        '400':
          description: Invalid backtest parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - invalid or missing bearer token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Strategy or user not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    BacktestResponse:
      type: object
      description: Response containing the results of a strategy backtest including performance metrics and trade history.
      properties:
        strategyId:
          type: string
          description: The strategy that was backtested
        startDate:
          type: string
          format: date
          description: The start date of the backtest period
        endDate:
          type: string
          format: date
          description: The end date of the backtest period
        initialCapital:
          type: number
          format: float
          description: The starting capital used in the backtest
        finalCapital:
          type: number
          format: float
          description: The ending capital after the backtest
        totalReturn:
          type: number
          format: float
          description: Total return as a decimal (e.g., 0.15 for 15%)
        totalTrades:
          type: integer
          description: Total number of trades executed during the backtest
        winningTrades:
          type: integer
          description: Number of profitable trades
        losingTrades:
          type: integer
          description: Number of losing trades
        winRate:
          type: number
          format: float
          description: Win rate as a decimal between 0 and 1
          minimum: 0
          maximum: 1
        maxDrawdown:
          type: number
          format: float
          description: Maximum drawdown as a decimal
        sharpeRatio:
          type: number
          format: float
          description: Sharpe ratio of the strategy returns
        profitFactor:
          type: number
          format: float
          description: Ratio of gross profits to gross losses
        trades:
          type: array
          description: Detailed list of individual trades executed
          items:
            $ref: '#/components/schemas/BacktestTrade'
    BacktestTrade:
      type: object
      description: A single trade executed during a backtest.
      properties:
        entryDate:
          type: string
          format: date-time
          description: Timestamp when the trade was entered
        exitDate:
          type: string
          format: date-time
          description: Timestamp when the trade was exited
        side:
          type: string
          description: The trade direction
          enum:
          - long
          - short
        entryPrice:
          type: number
          format: float
          description: The price at which the trade was entered
        exitPrice:
          type: number
          format: float
          description: The price at which the trade was exited
        quantity:
          type: number
          format: float
          description: The number of shares or contracts traded
        pnl:
          type: number
          format: float
          description: The profit or loss for this trade in USD
        returnPct:
          type: number
          format: float
          description: The return percentage for this trade
        exitReason:
          type: string
          description: The reason the trade was exited
          enum:
          - take_profit
          - stop_loss
          - trailing_stop
          - exit_condition
          - end_of_backtest
    ErrorResponse:
      type: object
      description: Standard error response for broker API requests.
      properties:
        error:
          type: string
          description: A human-readable error message
        code:
          type: string
          description: A machine-readable error code
        details:
          type: object
          description: Additional error details when available
          additionalProperties: true
    BacktestRequest:
      type: object
      description: Request body specifying the parameters for a strategy backtest run.
      required:
      - startDate
      - endDate
      properties:
        startDate:
          type: string
          format: date
          description: The start date for the backtest period
        endDate:
          type: string
          format: date
          description: The end date for the backtest period
        initialCapital:
          type: number
          format: float
          description: The starting capital amount for the backtest in USD
          default: 100000
          minimum: 0
        commissionPerTrade:
          type: number
          format: float
          description: Commission cost per trade in USD
          default: 0
          minimum: 0
  parameters:
    userId:
      name: userId
      in: path
      required: true
      description: The unique identifier of the broker user on the Level2 platform.
      schema:
        type: string
    strategyId:
      name: strategyId
      in: path
      required: true
      description: The unique identifier of the trading strategy.
      schema:
        type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Bearer token authentication for broker API access. Tokens are issued to broker partners during the integration onboarding process.
externalDocs:
  description: Level2 Broker API Documentation
  url: https://learn.trylevel2.com/docs/Broker/API/update-user-strategy