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

# Batch Trades

> Submit multiple trade orders in a single request. Each order is executed sequentially with the same logic as POST /markets/trade. Maximum 20 orders per batch.

Submit multiple trade orders in a single request. Each order is executed sequentially using the same logic as the single [Trade](/api-reference/endpoint/place-trade) endpoint.

## Overview

Use this endpoint when you need to place multiple orders at once — for example, entering positions across several markets in a single skill cycle or placing hedged entries on both sides of a market.

Each order in the batch is processed independently. If one order fails, the remaining orders still execute. The response includes individual results for every order.

Each embedded order follows the same schema as `POST /markets/trade` (12-field EIP-712 Order struct, identical for V1 and V2). Deposit-wallet orders use `signatureType=3`. See the [Place Trade](/api-reference/endpoint/place-trade) reference for the full field list.

<Warning>
  Maximum **20 orders** per batch request. Each order undergoes the same validation and risk checks as the single trade endpoint.
</Warning>

## Example

<Tabs>
  <Tab title="curl">
    ```bash theme={null}
    curl -X POST "https://www.aionmarket.com/bvapi/markets/batch-trade" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "orders": [
          {
            "marketConditionId": "0xabc123...",
            "marketQuestion": "Will BTC exceed $100k by June?",
            "outcome": "YES",
            "orderSize": 10,
            "price": 0.65,
            "isLimitOrder": true,
            "orderType": "GTC",
            "order": {
              "maker": "0x1111111111111111111111111111111111111111",
              "signer": "0x1111111111111111111111111111111111111111",
              "taker": "0x0000000000000000000000000000000000000000",
              "tokenId": "69136365945621600854789649488423522395843457249417452310260493085275775221076",
              "makerAmount": "650000",
              "takerAmount": "1000000",
              "side": "BUY",
              "expiration": "0",
              "nonce": "0",
              "feeRateBps": "0",
              "signature": "0xabcdef...",
              "salt": 599228746038,
              "signatureType": 0
            },
            "reasoning": "BTC momentum signal positive",
            "source": "sdk:my-skill"
          },
          {
            "marketConditionId": "0xdef456...",
            "marketQuestion": "Will ETH exceed $5k by June?",
            "outcome": "NO",
            "orderSize": 5,
            "price": 0.40,
            "isLimitOrder": true,
            "orderType": "GTC",
            "order": {
              "maker": "0x1111111111111111111111111111111111111111",
              "signer": "0x1111111111111111111111111111111111111111",
              "taker": "0x0000000000000000000000000000000000000000",
              "tokenId": "12345678901234567890123456789012345678901234567890123456789012345678",
              "makerAmount": "400000",
              "takerAmount": "1000000",
              "side": "BUY",
              "expiration": "0",
              "nonce": "0",
              "feeRateBps": "0",
              "signature": "0x123456...",
              "salt": 599228746039,
              "signatureType": 0
            },
            "reasoning": "ETH overvalued based on model",
            "source": "sdk:my-skill"
          }
        ]
      }'
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python theme={null}
    from aion_sdk import AionMarketClient

    client = AionMarketClient(api_key="YOUR_API_KEY", base_url="https://www.aionmarket.com/bvapi")

    orders = [
        {
            "marketConditionId": "0xabc123...",
            "marketQuestion": "Will BTC exceed $100k by June?",
            "outcome": "YES",
            "orderSize": 10,
            "price": 0.65,
            "isLimitOrder": True,
            "orderType": "GTC",
            "order": { ... },  # EIP712 signed order
            "reasoning": "BTC momentum signal positive",
            "source": "sdk:my-skill",
        },
        {
            "marketConditionId": "0xdef456...",
            "marketQuestion": "Will ETH exceed $5k by June?",
            "outcome": "NO",
            "orderSize": 5,
            "price": 0.40,
            "isLimitOrder": True,
            "orderType": "GTC",
            "order": { ... },  # EIP712 signed order
            "reasoning": "ETH overvalued based on model",
            "source": "sdk:my-skill",
        },
    ]

    result = client.batch_trade(orders)
    print(f"Submitted: {result['total']}, Succeeded: {result['succeeded']}, Failed: {result['failed']}")
    for r in result["results"]:
        print(f"  Order {r['orderId']}: {r['status']}")
    ```
  </Tab>
</Tabs>

## Response

```json theme={null}
{
  "total": 2,
  "succeeded": 2,
  "failed": 0,
  "results": [
    {
      "success": true,
      "orderId": "0xabc...",
      "status": "live",
      "makingAmount": "650000",
      "takingAmount": "1000000",
      "venue": "polymarket",
      "isLimitOrder": true,
      "walletAddress": "0x1111111111111111111111111111111111111111",
      "signatureType": 0,
      "aiAgentId": "10000001",
      "userId": "26",
      "syncedToMkOrder": true,
      "syncedToStrategyLog": true,
      "orderVersion": 1,
      "collateralSymbol": "pUSD"
    },
    {
      "success": true,
      "orderId": "0xdef...",
      "status": "live",
      "makingAmount": "400000",
      "takingAmount": "1000000",
      "venue": "polymarket",
      "isLimitOrder": true,
      "walletAddress": "0x1111111111111111111111111111111111111111",
      "signatureType": 0,
      "aiAgentId": "10000001",
      "userId": "26",
      "syncedToMkOrder": true,
      "syncedToStrategyLog": true,
      "orderVersion": 1,
      "collateralSymbol": "pUSD"
    }
  ]
}
```

## Response Fields

| Field       | Type    | Description                                                                                              |
| ----------- | ------- | -------------------------------------------------------------------------------------------------------- |
| `total`     | integer | Total number of orders submitted                                                                         |
| `succeeded` | integer | Number of successfully executed orders                                                                   |
| `failed`    | integer | Number of failed orders                                                                                  |
| `results`   | array   | Array of individual trade results (same schema as [Trade](/api-reference/endpoint/place-trade) response) |

## Common Errors

| Code  | Meaning                                                  |
| ----- | -------------------------------------------------------- |
| `400` | Invalid request body, empty orders array, or exceeds max |
| `401` | Missing or invalid API key                               |
| `500` | Server-side error                                        |

## Notes

* Orders are executed **sequentially**, not in parallel. Each order completes before the next begins.
* Each order undergoes independent risk checks and Polymarket API submission.
* A failed order does **not** stop subsequent orders from executing.
* The `orders` field in each result matches the single trade response schema exactly.


## OpenAPI

````yaml POST /markets/batch-trade
openapi: 3.1.0
info:
  title: Aion AI Agent API
  description: >-
    API for agent registration, wallet onboarding, market discovery, order
    management, and execution on Aion.
  version: 1.0.0
  contact:
    name: Aion Support
    email: info@aionmarket.com
    url: https://docs.aionmarket.com
servers:
  - url: https://www.aionmarket.com/bvapi
    description: Aion API
security:
  - bearerAuth: []
tags:
  - name: Agent Management
  - name: Market Operations
  - name: Order Management
  - name: Trading
  - name: Kalshi
  - name: Skills
  - name: Wallet Management
  - name: Trades & Leaderboard
  - name: Utilities
  - name: Settings
  - name: Positions & Portfolio
  - name: Fee Charging
paths:
  /markets/batch-trade:
    post:
      tags:
        - Trading
      summary: Batch Trades
      description: >-
        Submit multiple trade orders in a single request. Each order is executed
        sequentially with the same logic as POST /markets/trade. Maximum 20
        orders per batch.
      operationId: batchTrades
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchTradeRequest'
      responses:
        '200':
          description: Batch trade results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchTradeResult'
components:
  schemas:
    BatchTradeRequest:
      type: object
      required:
        - orders
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/TradeRequest'
          minItems: 1
          maxItems: 20
          description: Array of trade orders to execute in batch (max 20)
    BatchTradeResult:
      type: object
      properties:
        total:
          type: integer
          description: Total number of orders submitted
        succeeded:
          type: integer
          description: Number of successfully executed orders
        failed:
          type: integer
          description: Number of failed orders
        results:
          type: array
          items:
            $ref: '#/components/schemas/TradeResult'
          description: Individual results for each order
    TradeRequest:
      type: object
      required:
        - marketConditionId
        - marketQuestion
        - outcome
        - orderSize
        - price
        - order
      properties:
        venue:
          type: string
          description: Trading venue (default polymarket)
          default: polymarket
          maxLength: 50
        marketConditionId:
          type: string
          description: Market conditionId (persisted to mk_order)
          example: '0xf64f880b571d7a70d858649d30f0843aa57307e304aeb617349df74ce34d044e'
        marketQuestion:
          type: string
          description: Market question (persisted to mk_order)
          example: Will Crude Oil (CL) hit (HIGH) $120 by end of March?
          maxLength: 250
        outcome:
          type: string
          description: Outcome direction
          enum:
            - 'YES'
            - 'NO'
        orderSize:
          type: number
          description: Order size (contracts), persisted to mk_order.orderSize
          example: 1
        price:
          type: number
          description: Order price per contract, persisted to mk_order.price
          example: 0.54
        isLimitOrder:
          type: boolean
          description: true=createOrder (limit); false=createMarketOrder (market)
          default: true
        orderType:
          type: string
          description: Order type (default GTC for limit, FAK for market)
          enum:
            - GTC
            - FOK
            - GTD
            - FAK
          default: GTC
        walletAddress:
          type: string
          description: Wallet address (optional; falls back to order.signer)
          pattern: ^0x[a-fA-F0-9]{40}$
        owner:
          type: string
          description: Polymarket owner (optional, defaults to apiKey from credentials)
          maxLength: 128
        deferExec:
          type: boolean
          description: Defer execution flag
          default: false
        orderVersion:
          type: integer
          description: >-
            Order version: 1=legacy V1, 2=Polymarket V2 (auto-inferred when
            omitted)
          enum:
            - 1
            - 2
        tickSize:
          type: string
          description: V2 tickSize hint
          enum:
            - '0.1'
            - '0.01'
            - '0.001'
            - '0.0001'
        negRisk:
          type: boolean
          description: V2 negRisk flag
          default: false
        funderAddress:
          type: string
          description: V2 funder address (optional)
          pattern: ^0x[a-fA-F0-9]{40}$
        postOnly:
          type: boolean
          description: Post-only flag
          default: false
        feeAmount:
          type: number
          description: Market-order fee (only when isLimitOrder=false)
          default: 0
        reasoning:
          type: string
          description: Trade reasoning text (max 1000 chars)
          maxLength: 1000
        source:
          type: string
          description: Source tag (suggested format sdk:strategy-name)
          maxLength: 100
        skillSlug:
          type: string
          description: Skill identifier for attribution
          maxLength: 100
        expirationTime:
          type: number
          description: Limit order expiration in milliseconds (mk_order.expirationTime)
          default: 0
        order:
          $ref: '#/components/schemas/TradeOrderPayload'
    TradeResult:
      type: object
      properties:
        orderId:
          type: string
        status:
          type: string
        submittedAt:
          type: string
          format: date-time
    TradeOrderPayload:
      type: object
      required:
        - maker
        - signer
        - tokenId
        - makerAmount
        - takerAmount
        - side
        - signature
        - salt
        - signatureType
      properties:
        maker:
          type: string
          description: Maker wallet address
          example: '0x1111111111111111111111111111111111111111'
        signer:
          type: string
          description: Signing wallet address
          example: '0x1111111111111111111111111111111111111111'
        taker:
          type: string
          description: Taker wallet address (zero address for open orders)
          example: '0x0000000000000000000000000000000000000000'
        tokenId:
          type: string
          description: CLOB token ID
          example: >-
            69136365945621600854789649488423522395843457249417452310260493085275775221076
        makerAmount:
          type: string
          description: Maker amount (6-decimal integer)
          example: '120000'
        takerAmount:
          type: string
          description: Taker amount (6-decimal integer)
          example: '1000000'
        side:
          type: string
          enum:
            - BUY
            - SELL
          description: Trade direction
        expiration:
          type: string
          description: Expiration timestamp in seconds
          example: '0'
        nonce:
          type: string
          description: Nonce (V1 only)
          example: '0'
        feeRateBps:
          type: string
          description: Fee rate in basis points (V1 only)
          example: '0'
        signature:
          type: string
          description: EIP712 signature
          example: '0x1234abcd'
        salt:
          type: number
          description: Random salt
          example: 599228746038
        signatureType:
          type: integer
          description: 0=EOA, 1=PolymarketProxy, 2=GnosisSafe, 3=DepositWallet (POLY_1271)
          enum:
            - 0
            - 1
            - 2
            - 3
        timestamp:
          type: string
          description: 'V2 only: order timestamp in milliseconds'
          example: '1713000000000'
        metadata:
          type: string
          description: 'V2 only: metadata (bytes32 hex)'
          example: '0x0000000000000000000000000000000000000000000000000000000000000000'
        builder:
          type: string
          description: 'V2 only: builder (bytes32 hex)'
          example: '0x0000000000000000000000000000000000000000000000000000000000000000'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      x-default: YOUR_API_KEY

````