openapi: 3.0.1
info:
  title: Trading 212 Public API
  version: v0
  description: >
    Welcome to the official API reference for the Trading 212 Public API! This
    guide provides all the information you need to start building your own
    trading applications and integrations.


    ---


    # General Information


    This API is currently in **beta** and is under active development. We're
    continuously adding new features and improvements, and we welcome your
    feedback.


    ### API Environments


    We provide two distinct environments for development and trading:


    * **Paper Trading (Demo):** `https://demo.trading212.com/api/v0`

    * **Live Trading (Real Money):** `https://live.trading212.com/api/v0`


    You can test your applications extensively in the paper trading environment
    without risking real funds before moving to live trading.


    ### ⚠️ API Limitations


    Please be aware of the following limitations for any order placement:


    * **Supported account types:**  The Trading 212 Public API is enabled and
    usable only for **Invest and Stocks ISA** account types.

    * **Live trading order types:** For the live (real money) environment, only
    **Market Orders** are supported for execution via the API.

    * **Order execution:** Orders can be executed only in the **primary account
    currency**

    * **Multi-currency:** Multi-currency accounts are not currently supported
    through the API. Meaning your account, position and result values in the
    responses will be in the primary account currency.


    ### Key Concepts


    * **Authentication:** Every request to the API must be authenticated using a
    secure key pair. See the **Authentication** section below for details.

    * **Rate Limiting:** All API calls are subject to rate limits to ensure fair
    usage and stability. See the **Rate Limiting** section for a full
    explanation.

    * **IP Restrictions:** For enhanced security, you can optionally restrict
    your API keys to a specific set of IP addresses from within your Trading 212
    account settings.

    * **Selling Orders:** To execute a sell order, you must provide a
    **negative** value for the `quantity` parameter (e.g., `-10.5`). This is a
    core convention of the API.


    ---

     ## Quickstart

    This simple example shows you how to retrieve your account's cash balance.


    First, you must generate your API keys from within the Trading 212 app. For
    detailed instructions, please visit our Help Centre:


    * [**How to get your Trading 212 API
    key**](https://helpcentre.trading212.com/hc/en-us/articles/14584770928157-Trading-212-API-key)


    Once you have your **API Key** and **API Secret**, you can make your first
    call using `cURL`:


    ```bash

    # Step 1: Replace with your actual credentials and Base64-encode them.

    # The `-n` is important as it prevents adding a newline character.

    CREDENTIALS=$(echo -n "<YOUR_API_KEY>:<YOUR_API_SECRET>" | base64)


    # Step 2: Make the API call to the live environment using the encoded
    credentials.

    curl -X GET "https://live.trading212.com/api/v0/equity/account/cash" \
         -H "Authorization: Basic $CREDENTIALS"
    ```


    ---


    # Authentication


    The API uses a secure key pair for authentication on every request. You must
    provide your **API Key** as the username and your **API Secret** as the
    password, formatted as an HTTP Basic Authentication header.


    The `Authorization` header is constructed by Base64-encoding your
    `API_KEY:API_SECRET` string and prepending it with `Basic `.


    ### Building the Authorization Header


    Here are examples of how to generate the required value in different
    environments.


    **Linux or macOS (Terminal)**


    You can use the `echo` and `base64` commands. Remember to use the `-n` flag
    with `echo` to prevent it from adding a trailing newline, which would
    invalidate the credential string.


    ```bash

    # This command outputs the required Base64-encoded string for your header.

    echo -n "<YOUR_API_KEY>:<YOUR_API_SECRET>" | base64

    ```


    **Python**


    This simple snippet shows how to generate the full header value.


    ```python

    import base64


    # 1. Your credentials

    api_key = "<YOUR_API_KEY>"

    api_secret = "<YOUR_API_SECRET>"


    # 2. Combine them into a single string

    credentials_string = f"{api_key}:{api_secret}"


    # 3. Encode the string to bytes, then Base64 encode it

    encoded_credentials =
    base64.b64encode(credentials_string.encode('utf-8')).decode('utf-8')


    # 4. The final header value

    auth_header = f"Basic {encoded_credentials}"


    print(auth_header)

    ```


    ---


    # Rate Limiting


    To ensure high performance and fair access for all users, all API endpoints
    are subject to rate limiting.


    > **IMPORTANT NOTE:** All rate limits are applied on a per-account basis,
    regardless of which API key is used or which IP address the request
    originates from.


    Specific rate limits are detailed in the reference for each endpoint.


    ### Response Headers


    Every API response includes the following headers to help you manage your
    request frequency and avoid hitting limits.


    * `x-ratelimit-limit`: The total number of requests allowed in the current
    time period.

    * `x-ratelimit-period`: The duration of the time period in seconds.

    * `x-ratelimit-remaining`: The number of requests you have left in the
    current period.

    * `x-ratelimit-reset`: A Unix timestamp indicating the exact time when the
    limit will be fully reset.

    * `x-ratelimit-used`: The number of requests you have already made in the
    current period.


    ### How It Works


    The rate limiter allows for requests to be made in bursts. For example, an
    endpoint with a limit of `50 requests per 1 minute` does **not** strictly
    mean you can only make one request every 1.2 seconds. Instead, you could:


    * Make a burst of all 50 requests in the first 5 seconds of a minute. You
    would then need to wait for the reset time indicated by the
    `x-ratelimit-reset` header before making more requests.

    * Pace your requests evenly, for example, by making one call every 1.2
    seconds, ensuring you always stay within the limit.


    ### Function-Specific Limits


    In addition to the general rate limits on HTTP calls, some actions have
    their own functional limits. For example, there is a maximum of **50 pending
    orders** allowed per ticker, per account.


    ---


    # Useful Links 


    Here are some additional resources that you may find helpful.


    * [**Trading 212 API
    Terms**](https://www.trading212.com/legal-documentation/API-Terms_EN.pdf)

    * [**Trading 212 Community Forum**](https://community.trading212.com/) - A
    great place to ask questions and share what you've built.
servers:
  - url: https://demo.trading212.com
  - url: https://live.trading212.com
tags:
  - description: >-
      Access fundamental information about your trading account. Retrieve
      details such as your account ID, currency, and current cash balance.
    name: Account Data
  - description: >-
      **⚠️ Order Limitations**

      * Orders can be executed only in the **main account currency**

      * Only **Market Orders** are supported for the live (real money)
      environment


      Place, monitor, and cancel equity trade orders. This section provides the
      core functionality for programmatically executing your trading strategies
      for stocks and ETFs.
    name: Equity Orders
  - description: >-
      View the current state of your portfolio. Get a real-time overview of all
      your open positions, including quantity, average price, and current profit
      or loss.
    name: Personal Portfolio
  - description: >-
      Discover what you can trade. These endpoints provide comprehensive lists
      of all tradable instruments and the exchanges they belong to, including
      details like tickers and trading hours.
    name: Instruments Metadata
  - description: >-
      Review your account's trading history. Access detailed records of past
      orders, dividend payments, and cash transactions, or generate downloadable
      CSV reports for analysis and record-keeping.
    name: Historical items
paths:
  /api/v0/equity/account/cash:
    get:
      description: >
        **Rate Limit:** 1 request per 2 seconds


        Provides a detailed breakdown of your account's cash and investment
        metrics, including available funds, invested capital, and total account
        value.
      operationId: accountCash
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cash'
          description: OK
        '401':
          description: Bad API key
        '403':
          description: Scope( account ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 2s'
      security:
        - authWithSecretKey: []
      summary: Get Account Cash Balance
      tags:
        - Account Data
  /api/v0/equity/account/info:
    get:
      description: >
        **Rate Limit:** 1 request per 30 seconds


        Retrieves fundamental information about your trading account, such as
        your primary account number and its base currency.
      operationId: account
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
          description: OK
        '401':
          description: Bad API key
        '403':
          description: Scope( account ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 30s'
      security:
        - authWithSecretKey: []
      summary: Get Account Information
      tags:
        - Account Data
  /api/v0/equity/history/orders:
    get:
      description: |
        **Rate Limit:** 6 requests per 1 minute
      operationId: orders_1
      parameters:
        - description: Pagination cursor
          in: query
          name: cursor
          required: false
          schema:
            format: int64
            type: integer
        - description: Ticker filter
          in: query
          name: ticker
          required: false
          schema:
            type: string
        - description: 'Max items: 50'
          example: 21
          in: query
          name: limit
          required: false
          schema:
            default: 20
            format: int32
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponseHistoricalOrder'
          description: OK
        '400':
          description: Bad filtering arguments
        '401':
          description: Bad API key
        '403':
          description: Scope( history:orders ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 6 / 1m0s'
      security:
        - authWithSecretKey: []
      summary: Historical order data
      tags:
        - Historical items
  /api/v0/equity/metadata/exchanges:
    get:
      description: >
        **Rate Limit:** 1 request per 30 seconds


        Fetch all exchanges and their corresponding working schedules that your
        account has access to
      operationId: exchanges
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Exchange'
                type: array
          description: OK
        '401':
          description: Bad API key
        '403':
          description: Scope( metadata ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 30s'
      security:
        - authWithSecretKey: []
      summary: Exchange List
      tags:
        - Instruments Metadata
  /api/v0/equity/metadata/instruments:
    get:
      description: |
        **Rate Limit:** 1 request per 50 seconds

        Fetch all instruments that your account has access to
      operationId: instruments
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/TradableInstrument'
                type: array
          description: OK
        '401':
          description: Bad API key
        '403':
          description: Scope( metadata ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 50s'
      security:
        - authWithSecretKey: []
      summary: Instrument List
      tags:
        - Instruments Metadata
  /api/v0/equity/orders:
    get:
      description: >
        **Rate Limit:** 1 request per 5 seconds


        Retrieves a list of all orders that are currently active (i.e., not yet
        filled, cancelled, or expired). This is useful for monitoring the status
        of your open positions and managing your trading strategy.
      operationId: orders
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Order'
                type: array
          description: OK
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:read ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 5s'
      security:
        - authWithSecretKey: []
      summary: Get All Pending Orders
      tags:
        - Equity Orders
  /api/v0/equity/orders/limit:
    post:
      description: >
        **Rate Limit:** 1 request per 2 seconds


        Creates a new Limit order, which executes at a specified price or
        better.

        - To place a **buy** order, use a positive `quantity`. The order will
        fill at the `limitPrice` or lower.

        - To place a **sell** order, use a negative `quantity`. The order will
        fill at the `limitPrice` or higher.



        **Order Limitations**

        * Orders can be executed only in the **main account currency**

        * Only **Market Orders** are supported for the live (real money)
        environment


        **Important:** In this beta version, this endpoint is **not
        idempotent**. Sending the same request multiple times may result in
        duplicate orders.
      operationId: placeLimitOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LimitRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceOrderError'
          description: Failed validation
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:execute ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 2s'
      security:
        - authWithSecretKey: []
      summary: Place a Limit Order
      tags:
        - Equity Orders
  /api/v0/equity/orders/market:
    post:
      description: >
        **Rate Limit:** 50 requests per 1 minute


        Creates a new Market order, which is an instruction to trade a security
        immediately at the next available price. 

        - To place a **buy** order, use a positive `quantity`. 

        - To place a **sell** order, use a negative `quantity`.


        - **`extendedHours`**: Set to `true` to allow the order to be filled
        outside of the standard trading session.

        - If placed when the market is closed, the order will be queued to
        execute when the market next opens.


        **Order Limitations**

        * Orders can be executed only in the **main account currency**

        * Only **Market Orders** are supported for the live (real money)
        environment


        **Warning:** Market orders can be subject to price slippage, where the
        final execution price may differ from the price at the time of order
        placement.


        **Important:** In this beta version, this endpoint is **not
        idempotent**. Sending the same request multiple times may result in
        duplicate orders.
      operationId: placeMarketOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MarketRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceOrderError'
          description: Failed validation
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:execute ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 50 / 1m0s'
      security:
        - authWithSecretKey: []
      summary: Place a Market Order
      tags:
        - Equity Orders
  /api/v0/equity/orders/stop:
    post:
      description: >
        **Rate Limit:** 1 request per 2 seconds


        Creates a new Stop order, which places a Market order once the
        `stopPrice` is reached.

        - To place a **buy** stop order, use a positive `quantity`.

        - To place a **sell** stop order (commonly a 'stop-loss'), use a
        negative `quantity`.


        - The `stopPrice` is triggered by the instrument's **Last Traded Price
        (LTP)**.




        **Order Limitations**

        * Orders can be executed only in the **main account currency**

        * Only **Market Orders** are supported for the live (real money)
        environment



        **Important:** In this beta version, this endpoint is **not
        idempotent**. Sending the same request multiple times may result in
        duplicate orders.
      operationId: placeStopOrder_1
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StopRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceOrderError'
          description: Failed validation
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:execute ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 2s'
      security:
        - authWithSecretKey: []
      summary: Place a Stop Order
      tags:
        - Equity Orders
  /api/v0/equity/orders/stop_limit:
    post:
      description: >
        **Rate Limit:** 1 request per 2 seconds


        Creates a new Stop-Limit order, combining features of a Stop and a Limit
        order. The direction of the trade (buy/sell) is determined by the sign
        of the `quantity` field.


        **Execution Logic:**

        1.  When the instrument's **Last Traded Price (LTP)** reaches the
        specified `stopPrice`, the order is triggered.

        2.  A Limit order is then automatically placed at the specified
        `limitPrice`.


        This two-step process helps protect against price slippage that can
        occur with a standard Stop order.


        **Order Limitations**

        * Orders can be executed only in the **main account currency**

        * Only **Market Orders** are supported for the live (real money)
        environment


        **Important:** In this beta version, this endpoint is **not
        idempotent**. Sending the same request multiple times may result in
        duplicate orders.
      operationId: placeStopOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StopLimitRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceOrderError'
          description: Failed validation
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:execute ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 2s'
      security:
        - authWithSecretKey: []
      summary: Place a Stop-Limit Order
      tags:
        - Equity Orders
  /api/v0/equity/orders/{id}:
    delete:
      description: >
        **Rate Limit:** 50 requests per 1 minute


        Attempts to cancel an active, unfilled order by its unique ID.
        Cancellation is not guaranteed if the order is already in the process of
        being filled. A successful response indicates the cancellation request
        was accepted.
      operationId: cancelOrder
      parameters:
        - description: The unique identifier of the order you want to cancel.
          in: path
          name: id
          required: true
          schema:
            format: int64
            type: integer
      responses:
        '200':
          content:
            '*/*':
              schema:
                type: object
          description: OK
        '400':
          description: Not available for real money accounts
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:execute ) missing for API key
        '404':
          description: Order not found
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 50 / 1m0s'
      security:
        - authWithSecretKey: []
      summary: Cancel a Pending Order
      tags:
        - Equity Orders
    get:
      description: >
        **Rate Limit:** 1 request per 1 second


        Retrieves a single pending order using its unique numerical ID. This is
        useful for checking the status of a specific order you have previously
        placed.
      operationId: orderById
      parameters:
        - description: The unique identifier of the order you want to retrieve.
          in: path
          name: id
          required: true
          schema:
            format: int64
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
          description: Order found
        '401':
          description: Bad API key
        '403':
          description: Scope( orders:read ) missing for API key
        '404':
          description: Order not found
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 1s'
      security:
        - authWithSecretKey: []
      summary: Get Order by ID
      tags:
        - Equity Orders
  /api/v0/equity/portfolio:
    get:
      description: |
        **Rate Limit:** 1 request per 5 seconds

        Fetch an open positions for your account
      operationId: portfolio
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Position'
                type: array
          description: OK
        '401':
          description: Bad API key
        '403':
          description: Scope( portfolio ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 5s'
      security:
        - authWithSecretKey: []
      summary: Fetch all open positions
      tags:
        - Personal Portfolio
  /api/v0/equity/portfolio/ticker:
    post:
      description: |
        **Rate Limit:** 1 request per 1 second

        Search for a open position by ticker
      operationId: positionByTickerV2
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PositionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Position'
          description: OK
        '400':
          description: Invalid ticker supplied
        '401':
          description: Bad API key
        '403':
          description: Scope( portfolio ) missing for API key
        '404':
          description: No open position with that ticker
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 1s'
      security:
        - authWithSecretKey: []
      summary: Search for a specific position by ticker
      tags:
        - Personal Portfolio
  /api/v0/equity/portfolio/{ticker}:
    get:
      description: |
        **Rate Limit:** 1 request per 1 second

        Fetch an open position by ticker
      operationId: positionByTicker
      parameters:
        - example: AAPL_US_EQ
          in: path
          name: ticker
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Position'
          description: OK
        '400':
          description: Invalid ticker supplied
        '401':
          description: Bad API key
        '403':
          description: Scope( portfolio ) missing for API key
        '404':
          description: No open position with that ticker
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 1s'
      security:
        - authWithSecretKey: []
      summary: Fetch a specific position
      tags:
        - Personal Portfolio
  /api/v0/history/dividends:
    get:
      description: |
        **Rate Limit:** 6 requests per 1 minute
      operationId: dividends
      parameters:
        - description: Pagination cursor
          in: query
          name: cursor
          required: false
          schema:
            format: int64
            type: integer
        - description: Ticker filter
          in: query
          name: ticker
          required: false
          schema:
            type: string
        - description: 'Max items: 50'
          example: 21
          in: query
          name: limit
          required: false
          schema:
            default: 20
            format: int32
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponseHistoryDividendItem'
          description: OK
        '400':
          description: Bad filtering arguments
        '401':
          description: Bad API key
        '403':
          description: Scope( history:dividends ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 6 / 1m0s'
      security:
        - authWithSecretKey: []
      summary: Paid out dividends
      tags:
        - Historical items
  /api/v0/history/exports:
    get:
      description: >
        **Rate Limit:** 1 request per 1 minute


        Retrieves a list of all requested CSV reports and their current status. 


        **Asynchronous Workflow:**

        1. Call `POST /history/exports` to request a report. You will receive a
        `reportId`.

        2. Periodically call this endpoint (`GET /history/exports`) to check the
        `status` of the report corresponding to your `reportId`.

        3. Once the status is `Finished`, the `downloadLink` field will contain
        a URL to download the CSV file.
      operationId: getReports
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/ReportResponse'
                type: array
          description: OK
        '400':
          description: Bad filtering arguments
        '401':
          description: Bad API key
        '403':
          description: Missing Permissions
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 1m0s'
      security:
        - authWithSecretKey: []
      summary: List Generated Reports
      tags:
        - Historical items
    post:
      description: >
        **Rate Limit:** 1 request per 30 seconds


        Initiates the generation of a CSV report containing historical account
        data. This is an asynchronous operation. The response will include a
        `reportId` which you can use to track the status of the generation
        process using the `GET /history/exports` endpoint.
      operationId: requestReport
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicReportRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnqueuedReportResponse'
          description: OK
        '400':
          description: Bad filtering arguments
        '401':
          description: Bad API key
        '403':
          description: Missing Permissions
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 1 / 30s'
      security:
        - authWithSecretKey: []
      summary: Request a CSV Report
      tags:
        - Historical items
  /api/v0/history/transactions:
    get:
      description: |
        **Rate Limit:** 6 requests per 1 minute

        Fetch superficial information about movements to and from your account
      operationId: transactions
      parameters:
        - description: Pagination cursor
          in: query
          name: cursor
          required: false
          schema:
            type: string
        - description: Retrieve transactions starting from the specified time
          in: query
          name: time
          required: false
          schema:
            format: date-time
            type: string
        - description: 'Max items: 50'
          example: 21
          in: query
          name: limit
          required: false
          schema:
            default: 20
            format: int32
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponseHistoryTransactionItem'
          description: OK
        '400':
          description: Bad filtering arguments
        '401':
          description: Bad API key
        '403':
          description: Scope( history:transactions ) missing for API key
        '408':
          description: Timed-out
        '429':
          description: 'Limited: 6 / 1m0s'
      security:
        - authWithSecretKey: []
      summary: Transaction list
      tags:
        - Historical items
components:
  schemas:
    Account:
      description: Contains the basic identifying information for a trading account.
      properties:
        currencyCode:
          description: >-
            The ISO 4217 currency code of your account's base currency (e.g.,
            'USD', 'EUR', 'GBP').
          example: USD
          maxLength: 3
          minLength: 3
          type: string
        id:
          description: >-
            Your primary trading account number. This is the same account ID you
            would see in the Trading 212 web or mobile application.
          format: int64
          type: integer
      type: object
    Cash:
      description: >-
        A detailed breakdown of the account's financial state, including cash,
        investments, and profit/loss.
      properties:
        blocked:
          description: >-
            The amount of cash reserved for pending orders. This cash is not
            available for placing new trades but is part of your withdrawable
            funds.
          type: number
        free:
          description: >-
            The amount of cash available for investing. This amount is not
            reserved for any pending orders. Note: Your total withdrawable cash
            is the sum of `free` and `blocked` cash.
          type: number
        invested:
          description: >-
            The cost basis of your current investments. This represents the
            total amount of money you have paid for the securities you currently
            own.
          type: number
        pieCash:
          description: >-
            The sum of uninvested cash held within all of your pies, in your
            account's main currency.
          type: number
        ppl:
          description: >-
            The total unrealized (potential) profit and loss from all your open
            positions.
          type: number
        result:
          description: >-
            The all time realised profit loss from all of the trades executed
            converted into your main account currency.
          type: number
        total:
          description: >-
            The total value of your account. `total = free + blocked + invested
            + unrealised profit/loss + spending pot`.
          type: number
      type: object
    EnqueuedReportResponse:
      description: >-
        The response received after successfully queueing a new report for
        generation.
      properties:
        reportId:
          description: >-
            The unique identifier for the report you have just requested. Use
            this ID to track its status via the `GET /history/exports` endpoint.
          format: int64
          type: integer
      type: object
    Exchange:
      properties:
        id:
          format: int64
          type: integer
        name:
          type: string
        workingSchedules:
          items:
            $ref: '#/components/schemas/WorkingSchedule'
          type: array
      type: object
    HistoricalOrder:
      properties:
        dateCreated:
          format: date-time
          type: string
        dateExecuted:
          format: date-time
          type: string
        dateModified:
          format: date-time
          type: string
        executor:
          enum:
            - API
            - IOS
            - ANDROID
            - WEB
            - SYSTEM
            - AUTOINVEST
          type: string
        extendedHours:
          description: >-
            If true, the order was eligible for execution outside regular
            trading hours
          type: boolean
        fillCost:
          description: In your account main currency
          type: number
        fillId:
          format: int64
          type: integer
        fillPrice:
          description: In the instrument currency
          type: number
        fillResult:
          type: number
        fillType:
          enum:
            - TOTV
            - OTC
            - STOCK_SPLIT
            - STOCK_DISTRIBUTION
            - FOP
            - FOP_CORRECTION
            - CUSTOM_STOCK_DISTRIBUTION
            - EQUITY_RIGHTS
          type: string
        filledQuantity:
          description: Applicable to quantity orders
          type: number
        filledValue:
          description: Applicable to value orders
          type: number
        id:
          format: int64
          type: integer
        limitPrice:
          description: Applicable to limit orders
          type: number
        orderedQuantity:
          description: Applicable to quantity orders
          type: number
        orderedValue:
          description: Applicable to value orders
          type: number
        parentOrder:
          format: int64
          type: integer
        status:
          enum:
            - LOCAL
            - UNCONFIRMED
            - CONFIRMED
            - NEW
            - CANCELLING
            - CANCELLED
            - PARTIALLY_FILLED
            - FILLED
            - REJECTED
            - REPLACING
            - REPLACED
          type: string
        stopPrice:
          description: Applicable to stop orders
          type: number
        taxes:
          items:
            $ref: '#/components/schemas/Tax'
          type: array
        ticker:
          type: string
        timeValidity:
          description: Applicable to stop, limit and stopLimit orders
          enum:
            - DAY
            - GOOD_TILL_CANCEL
          type: string
        type:
          enum:
            - LIMIT
            - STOP
            - MARKET
            - STOP_LIMIT
          type: string
      type: object
    HistoryDividendItem:
      properties:
        amount:
          description: In account currency
          type: number
        amountInEuro:
          type: number
        grossAmountPerShare:
          description: In instrument currency
          type: number
        paidOn:
          format: date-time
          type: string
        quantity:
          type: number
        reference:
          type: string
        ticker:
          type: string
        type:
          type: string
      type: object
    HistoryTransactionItem:
      properties:
        amount:
          description: In the account currency
          type: number
        dateTime:
          format: date-time
          type: string
        reference:
          description: ID
          type: string
        type:
          enum:
            - WITHDRAW
            - DEPOSIT
            - FEE
            - TRANSFER
          type: string
      type: object
    LimitRequest:
      properties:
        limitPrice:
          description: >-
            The target price for the order. For a buy order, this is the maximum
            price you are willing to pay. For a sell order, this is the minimum
            price you are willing to accept.
          example: 100.23
          type: number
        quantity:
          description: >-
            The number of shares or units to trade. Use a **positive** number
            (e.g., `10.5`) for a **BUY** order and a **negative** number (e.g.,
            `-10.5`) for a **SELL** order. The value cannot be zero.
          example: 0.1
          type: number
        ticker:
          description: >-
            The unique identifier for the instrument you want to trade. You can
            retrieve a list of available tickers from the
            `/equity/metadata/instruments` endpoint.
          example: AAPL_US_EQ
          type: string
        timeValidity:
          description: >
            Specifies how long the order remains active.

            - `DAY`: The order will automatically expire if not executed by
            midnight in the time zone of the instrument's exchange.

            - `GOOD_TILL_CANCEL`: The order remains active indefinitely until it
            is either filled or explicitly cancelled by you.
          enum:
            - DAY
            - GOOD_TILL_CANCEL
          example: DAY
          type: string
      type: object
    MarketRequest:
      properties:
        extendedHours:
          default: false
          description: >-
            If 'true', allows the order to be filled outside of regular trading
            hours. If the order is placed when the market is fully closed, it
            will be queued for the next market open.
          example: true
          type: boolean
        quantity:
          description: >-
            The number of shares or units to trade. Use a **positive** number
            (e.g., `10.5`) for a **BUY** order and a **negative** number (e.g.,
            `-10.5`) for a **SELL** order. The value cannot be zero.
          example: 0.1
          type: number
        ticker:
          description: >-
            The unique identifier for the instrument to trade. Retrieve from the
            `/equity/metadata/instruments` endpoint.
          example: AAPL_US_EQ
          type: string
      type: object
    Order:
      description: >-
        Represents a trade order, containing details about its status, type, and
        execution.
      properties:
        creationTime:
          description: The ISO 8601 timestamp of when the order was created.
          format: date-time
          type: string
        extendedHours:
          description: >-
            Indicates if the order is eligible for execution outside regular
            trading hours.
          type: boolean
        filledQuantity:
          description: The number of shares that have been successfully executed.
          type: number
        filledValue:
          description: The total monetary value of the executed portion of the order.
          type: number
        id:
          description: A unique, system-generated identifier for the order.
          format: int64
          type: integer
        limitPrice:
          description: The limit price for `LIMIT` and `STOP_LIMIT` orders.
          type: number
        quantity:
          description: >-
            The number of shares requested in the order. A negative number
            indicates a sell order. Applicable to orders placed by quantity.
          type: number
        status:
          description: The current state of the order in its lifecycle.
          enum:
            - LOCAL
            - UNCONFIRMED
            - CONFIRMED
            - NEW
            - CANCELLING
            - CANCELLED
            - PARTIALLY_FILLED
            - FILLED
            - REJECTED
            - REPLACING
            - REPLACED
          type: string
        stopPrice:
          description: The stop price for `STOP` and `STOP_LIMIT` orders.
          type: number
        strategy:
          description: >-
            The strategy used to place the order, either by `QUANTITY` or
            `VALUE`. The API currently only supports placing orders by
            `QUANTITY`.
          enum:
            - QUANTITY
            - VALUE
          type: string
        ticker:
          description: Unique instrument identifier for the traded asset.
          example: AAPL_US_EQ
          type: string
        type:
          description: The type of the order, which determines its execution logic.
          enum:
            - LIMIT
            - STOP
            - MARKET
            - STOP_LIMIT
          type: string
        value:
          description: >-
            The monetary value of the order in your account's currency.
            Applicable to orders placed by value. Note: Placing orders by value
            is not currently supported via the API but can be done through other
            Trading 212 platforms.
          type: number
      type: object
    PaginatedResponseHistoricalOrder:
      properties:
        items:
          items:
            $ref: '#/components/schemas/HistoricalOrder'
          type: array
        nextPagePath:
          type: string
      type: object
    PaginatedResponseHistoryDividendItem:
      properties:
        items:
          items:
            $ref: '#/components/schemas/HistoryDividendItem'
          type: array
        nextPagePath:
          type: string
      type: object
    PaginatedResponseHistoryTransactionItem:
      properties:
        items:
          items:
            $ref: '#/components/schemas/HistoryTransactionItem'
          type: array
        nextPagePath:
          type: string
      type: object
    PlaceOrderError:
      properties:
        clarification:
          type: string
        code:
          enum:
            - SellingEquityNotOwned
            - CantLegalyTradeException
            - InsufficientResources
            - InsufficientValueForStocksSell
            - TargetPriceTooFar
            - TargetPriceTooClose
            - NotEligibleForISA
            - ShareLendingAgreementNotAccepted
            - InstrumentNotFound
            - MaxEquityBuyQuantityExceeded
            - MaxEquitySellQuantityExceeded
            - LimitPriceMissing
            - StopPriceMissing
            - TickerMissing
            - QuantityMissing
            - MaxQuantityExceeded
            - InvalidValue
            - InsufficientFreeForStocksException
            - MinValueExceeded
            - MinQuantityExceeded
            - PriceTooFar
            - UNDEFINED
            - NotAvailableForRealMoneyAccounts
            - ExtendedHoursTradingNotAllowed
            - UnfilledOrderCountExceeded
          type: string
      type: object
    Position:
      properties:
        averagePrice:
          type: number
        currentPrice:
          type: number
        frontend:
          description: Origin
          enum:
            - API
            - IOS
            - ANDROID
            - WEB
            - SYSTEM
            - AUTOINVEST
          type: string
        fxPpl:
          description: >-
            Forex movement impact, only applies to positions with instrument
            currency that differs from the accounts'
          type: number
        initialFillDate:
          format: date-time
          type: string
        maxBuy:
          description: Additional quantity that can be bought
          type: number
        maxSell:
          description: Quantity that can be sold
          type: number
        pieQuantity:
          description: Invested in pies
          type: number
        ppl:
          type: number
        quantity:
          type: number
        ticker:
          description: Unique instrument identifier
          example: AAPL_US_EQ
          type: string
      type: object
    PositionRequest:
      properties:
        ticker:
          type: string
      type: object
    PublicReportRequest:
      description: Specifies the parameters for a new CSV report request.
      properties:
        dataIncluded:
          $ref: '#/components/schemas/ReportDataIncluded'
        timeFrom:
          description: The start date and time for the report period, in ISO 8601 format.
          format: date-time
          type: string
        timeTo:
          description: The end date and time for the report period, in ISO 8601 format.
          format: date-time
          type: string
      type: object
    ReportDataIncluded:
      description: A set of booleans to select the data types for a report.
      properties:
        includeDividends:
          description: Set to `true` to include dividend history in the report.
          type: boolean
        includeInterest:
          description: Set to `true` to include interest payments in the report.
          type: boolean
        includeOrders:
          description: Set to `true` to include historical orders in the report.
          type: boolean
        includeTransactions:
          description: >-
            Set to `true` to include cash transactions (deposits, withdrawals,
            etc.) in the report.
          type: boolean
      type: object
    ReportResponse:
      description: Contains the details and status of a requested CSV report.
      properties:
        dataIncluded:
          $ref: '#/components/schemas/ReportDataIncluded'
        downloadLink:
          description: >-
            A temporary URL to download the generated CSV file. This field will
            only be populated once the report `status` is `Finished`. The link
            may expire after a certain period.
          type: string
        reportId:
          description: The unique identifier for the report.
          format: int64
          type: integer
        status:
          description: >-
            The current status of the report generation. Poll this field until
            it becomes `Finished`.
          enum:
            - Queued
            - Processing
            - Running
            - Canceled
            - Failed
            - Finished
          type: string
        timeFrom:
          format: date-time
          type: string
        timeTo:
          format: date-time
          type: string
      type: object
    StopLimitRequest:
      properties:
        limitPrice:
          description: >-
            The price for the subsequent Limit order that is placed after the
            `stopPrice` is triggered. This defines the maximum price for a buy
            or minimum price for a sell.
          example: 100.23
          type: number
        quantity:
          description: >-
            The number of shares or units to trade. Use a **positive** number
            (e.g., `10.5`) for a **BUY** order and a **negative** number (e.g.,
            `-10.5`) for a **SELL** order. The value cannot be zero.
          example: 0.1
          type: number
        stopPrice:
          description: >-
            The price at which the order triggers. The trigger is based on the
            instrument's Last Traded Price (LTP). Once triggered, a Limit order
            is placed at the `limitPrice`.
          example: 100.23
          type: number
        ticker:
          description: >-
            The unique identifier for the instrument to trade. Retrieve from the
            `/equity/metadata/instruments` endpoint.
          example: AAPL_US_EQ
          type: string
        timeValidity:
          description: >
            Specifies how long the order remains active.

            - `DAY`: The order will automatically expire if not executed by
            midnight in the time zone of the instrument's exchange.

            - `GOOD_TILL_CANCEL`: The order remains active indefinitely until it
            is either filled or explicitly cancelled by you.
          enum:
            - DAY
            - GOOD_TILL_CANCEL
          example: DAY
          type: string
      type: object
    StopRequest:
      properties:
        quantity:
          description: >-
            The number of shares or units to trade. Use a **positive** number
            (e.g., `10.5`) for a **BUY** order and a **negative** number (e.g.,
            `-10.5`) for a **SELL** order. The value cannot be zero.
          example: 0.1
          type: number
        stopPrice:
          description: >-
            The price at which the Stop order triggers a Market order. The
            trigger is based on the instrument's Last Traded Price (LTP).
          example: 100.23
          type: number
        ticker:
          description: >-
            The unique identifier for the instrument to trade. Retrieve from the
            `/equity/metadata/instruments` endpoint.
          example: AAPL_US_EQ
          type: string
        timeValidity:
          description: >
            Specifies how long the order remains active.

            - `DAY`: The order will automatically expire if not executed by
            midnight in the time zone of the instrument's exchange.

            - `GOOD_TILL_CANCEL`: The order remains active indefinitely until it
            is either filled or explicitly cancelled by you.
          enum:
            - DAY
            - GOOD_TILL_CANCEL
          example: DAY
          type: string
      type: object
    Tax:
      properties:
        fillId:
          type: string
        name:
          enum:
            - COMMISSION_TURNOVER
            - CURRENCY_CONVERSION_FEE
            - FINRA_FEE
            - FRENCH_TRANSACTION_TAX
            - PTM_LEVY
            - STAMP_DUTY
            - STAMP_DUTY_RESERVE_TAX
            - TRANSACTION_FEE
          type: string
        quantity:
          type: number
        timeCharged:
          format: date-time
          type: string
      type: object
    TimeEvent:
      properties:
        date:
          format: date-time
          type: string
        type:
          enum:
            - OPEN
            - CLOSE
            - BREAK_START
            - BREAK_END
            - PRE_MARKET_OPEN
            - AFTER_HOURS_OPEN
            - AFTER_HOURS_CLOSE
            - OVERNIGHT_OPEN
          type: string
      type: object
    TradableInstrument:
      properties:
        addedOn:
          description: On the platform since
          format: date-time
          type: string
        currencyCode:
          description: ISO 4217
          example: USD
          maxLength: 3
          minLength: 3
          type: string
        isin:
          type: string
        maxOpenQuantity:
          type: number
        name:
          type: string
        shortName:
          type: string
        ticker:
          description: Unique identifier
          example: AAPL_US_EQ
          type: string
        type:
          enum:
            - CRYPTOCURRENCY
            - ETF
            - FOREX
            - FUTURES
            - INDEX
            - STOCK
            - WARRANT
            - CRYPTO
            - CVR
            - CORPACT
          example: ETF
          type: string
        workingScheduleId:
          description: Get items in the /exchanges endpoint
          format: int64
          type: integer
      type: object
    WorkingSchedule:
      properties:
        id:
          format: int64
          type: integer
        timeEvents:
          items:
            $ref: '#/components/schemas/TimeEvent'
          type: array
      type: object
  securitySchemes:
    authWithSecretKey:
      description: >-
        This API uses an authentication scheme, which requires a secure pair of
        API keys. Use your API Key as the username and your API Secret as the
        password. You can generate and manage your API keys in the Settings >
        API section of your Trading 212 account. The Authorization header should
        be constructed as follows: Authorization: Basic
        base64(<YOUR_API_KEY>:<YOUR_API_SECRET>)
      scheme: basic
      type: http
