Skip to main content
POST
/
markets
/
trade
Place Trade
curl --request POST \
  --url https://www.aionmarket.com/bvapi/markets/trade \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "marketId": "<string>",
  "outcome": "<string>",
  "side": "buy",
  "orderType": "market",
  "size": 123,
  "walletAddress": "<string>",
  "price": 123,
  "clientOrderId": "<string>"
}
'
{
  "orderId": "<string>",
  "status": "<string>",
  "submittedAt": "2023-11-07T05:31:56Z"
}
Execute a trade order on Polymarket using an EIP712-signed order object.

Overview

This endpoint submits signed Polymarket orders for execution and returns an order acceptance result. For immediate BUY orders (FAK / FOK), Polymarket enforces precision constraints:
  • makerAmount supports max 2 decimals
  • takerAmount supports max 4 decimals
Because amounts are sent as 6-decimal micro-units, validate before submitting:
  • makerAmount % 10000 == 0
  • takerAmount % 100 == 0

Prerequisites

  1. Agent must be registered via POST /agents/register
  2. Wallet credentials registered via POST /wallet/credentials
  3. EIP712-signed order from Polymarket CLOB library
  4. Market context checked via GET /markets/context/:marketId (recommended)

Request fields

FieldTypeRequiredDescription
venuestringNoDefaults to polymarket
marketConditionIdstringYesCondition identifier
marketQuestionstringYesMarket question
outcomestringYesYES or NO
orderSizenumberYesRequested contracts
pricenumberYesPrice per contract
isLimitOrderbooleanNoLimit or market mode
orderTypestringNoGTC, FOK, GTD, FAK (default: GTC for limit, FAK for market)
walletAddressstringNoWallet address
orderobjectYesSigned EIP712 order payload
reasoningstringNoTrade explanation
sourcestringNoStrategy source tag

Examples

curl -X POST https://www.aionmarket.com/bvapi/markets/trade \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "venue": "polymarket",
    "marketConditionId": "0xabc123...",
    "marketQuestion": "Will Bitcoin reach $100k by end of 2024?",
    "outcome": "YES",
    "orderSize": 10,
    "price": 0.68,
    "isLimitOrder": true,
    "walletAddress": "0x1111111111111111111111111111111111111111",
    "owner": "f4f247b7-4ac7-ff29-a152-04fda0a8755a",
    "orderType": "GTC",
    "deferExec": false,
    "postOnly": false,
    "order": {
      "maker": "0x1111111111111111111111111111111111111111",
      "signer": "0x1111111111111111111111111111111111111111",
      "taker": "0x0000000000000000000000000000000000000000",
      "tokenId": "0x123",
      "makerAmount": "6800000",
      "takerAmount": "10000000",
      "side": "BUY",
      "expiration": "1713604800",
      "nonce": "123456789",
      "feeRateBps": "100",
      "signature": "0x...",
      "salt": 1,
      "signatureType": 0
    },
    "feeAmount": 0,
    "reasoning": "Technical analysis shows bullish trend; RSI at 65",
    "source": "sdk:weather-alpha",
    "skillSlug": "polymarket-weather-trader",
    "expirationTime": 0
  }'

Order Object (EIP712 Signed)

Required fields inside order:
FieldTypeRequiredDescription
makerstringYesMaker wallet address
signerstringYesSigning wallet address
takerstringYesTaker address, usually zero address for open orders
tokenIdstringYesPolymarket CLOB token ID
makerAmountstringYesMaker amount in 6-decimal integer precision
takerAmountstringYesTaker amount in 6-decimal integer precision
sidestringYesBUY or SELL
expirationstringYesExpiration timestamp in seconds
noncestringYesUnique nonce
feeRateBpsstringYesFee rate in basis points
signaturestringYesEIP712 signature
saltnumberYesRandom salt
signatureTypeintegerYes0=EOA, 1=PolymarketProxy, 2=GnosisSafe
{
  maker: string; // Your wallet address
  signer: string; // Signing wallet (same for EOA)
  taker: string; // 0x0 for open orders
  tokenId: string; // CLOB token ID for outcome
  makerAmount: string; // Amount you're willing to give (6-digit precision)
  takerAmount: string; // Amount you want to receive (6-digit precision)
  side: "BUY" | "SELL"; // Your side
  expiration: string; // Unix timestamp in seconds
  nonce: string; // Unique nonce
  feeRateBps: string; // Fee rate in basis points
  signature: string; // EIP712 signature
  salt: number; // Random salt
  signatureType: 0 | 1 | 2; // 0=EOA, 1=PolymarketProxy, 2=GnosisSafe
}

Response

{
  "success": true,
  "orderId": "0x456def...",
  "status": "live",
  "walletAddress": "0x1111111111111111111111111111111111111111",
  "signatureType": 0,
  "aiAgentId": "1",
  "userId": "42",
  "syncedToMkOrder": true,
  "syncedToStrategyLog": true
}

Common errors

CodeMeaning
400Invalid payload, bad market/outcome, or invalid order object
401Invalid API key
429Rate limited
500Server-side failure

Error Handling

Common response codes:
  • 201: Request accepted (use response body success to determine downstream execution result)
  • 400: Invalid market/outcome or insufficient balance
  • 401: Invalid API key or expired
  • 429: Rate limited
  • 500: Server error

Pre-Trade Checklist

Before placing trade orders:
  1. Get Market Context
    GET /markets/context/:marketId?user=YOUR_WALLET
    
  2. Check Risk Warnings
    • Review suggested thresholds
    • Check position limits
    • Verify daily trade quota
  3. Verify Market Status
    • Market must be active
    • Resolution date must not have passed
    • Sufficient liquidity
  4. Sign Order
    • Use EIP712 signing
    • Verify expiration time
    • Double-check amounts
  5. Execute Trade
    • Submit signed order
    • Monitor for fill status
    • Log reasoning for audit
  • GET /markets/context/:marketId - Pre-trade risk analysis
  • GET /markets/orders/open - Monitor pending orders
  • POST /markets/orders/cancel - Cancel unfilled orders
  • GET /agents/me - Check daily trade quota used
  • POST /markets/redeem - Claim rewards on settled markets

Best Practices

  • Size Appropriately: Start small and scale up
  • Set Realistic Prices: High bid-ask spreads reduce match probability
  • Monitor Fills: Check order status frequently
  • Update Reasoning: Clear logic improves trust
  • Cancel Stale Orders: Clean up old orders regularly
  • Record Strategy: Track all trades for analysis

Authorizations

Authorization
string
header
default:YOUR_API_KEY
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
marketId
string
required
outcome
string
required
side
enum<string>
required
Available options:
buy,
sell
orderType
enum<string>
required
Available options:
market,
limit
size
number
required
walletAddress
string
price
number
clientOrderId
string

Response

200 - application/json

Trade accepted

orderId
string
status
string
submittedAt
string<date-time>