{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/foresea-ink/json-schema/foresea-ink-trade-run-create-request-schema.json",
  "title": "TradeRunCreateRequest",
  "description": "Create a durable, human-reviewable live-trade run without executing it.",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/foresea-ink-openapi.json#/components/schemas/TradeRunCreateRequest",
  "properties": {
    "platform": {
      "type": "string",
      "maxLength": 20,
      "title": "Platform",
      "description": "`kalshi` or `polymarket`."
    },
    "action": {
      "type": "string",
      "maxLength": 10,
      "title": "Action",
      "description": "`buy` or `sell`.",
      "default": "buy"
    },
    "outcome": {
      "type": "string",
      "maxLength": 10,
      "title": "Outcome",
      "description": "Outcome side: `yes` or `no`.",
      "default": "yes"
    },
    "order_type": {
      "type": "string",
      "maxLength": 20,
      "title": "Order Type",
      "description": "`limit` or `market`.",
      "default": "limit"
    },
    "price": {
      "anyOf": [
        {
          "type": "number",
          "exclusiveMaximum": 1.0,
          "exclusiveMinimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Price",
      "description": "Limit price, or worst acceptable price for market/IOC-style orders."
    },
    "quantity": {
      "type": "number",
      "exclusiveMinimum": 0.0,
      "title": "Quantity",
      "description": "Contracts/shares. For Polymarket market-buy, max_cost may define spend."
    },
    "max_cost": {
      "anyOf": [
        {
          "type": "number",
          "exclusiveMinimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Max Cost",
      "description": "Polymarket market-buy spend cap in USD."
    },
    "ticker": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 120
        },
        {
          "type": "null"
        }
      ],
      "title": "Ticker",
      "description": "Kalshi market ticker."
    },
    "token_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ],
      "title": "Token Id",
      "description": "Polymarket CLOB outcome token id."
    },
    "slug": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ],
      "title": "Slug",
      "description": "Polymarket market slug for token resolution."
    },
    "market_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 80
        },
        {
          "type": "null"
        }
      ],
      "title": "Market Id",
      "description": "Polymarket market id for token resolution."
    },
    "time_in_force": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 40
        },
        {
          "type": "null"
        }
      ],
      "title": "Time In Force",
      "description": "Venue-specific TIF, e.g. GTC/FOK or good_till_canceled."
    },
    "post_only": {
      "type": "boolean",
      "title": "Post Only",
      "description": "Reject rather than cross the book when supported.",
      "default": false
    },
    "reduce_only": {
      "type": "boolean",
      "title": "Reduce Only",
      "description": "Kalshi reduce-only flag.",
      "default": false
    },
    "tick_size": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 20
        },
        {
          "type": "null"
        }
      ],
      "title": "Tick Size",
      "description": "Polymarket tick size override."
    },
    "neg_risk": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Neg Risk",
      "description": "Polymarket negative-risk market flag."
    },
    "client_order_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 128
        },
        {
          "type": "null"
        }
      ],
      "title": "Client Order Id",
      "description": "Caller-provided idempotency/order id."
    },
    "cancel_order_on_pause": {
      "type": "boolean",
      "title": "Cancel Order On Pause",
      "description": "Kalshi cancel-on-pause flag.",
      "default": false
    },
    "subaccount": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 32.0,
          "minimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Subaccount",
      "description": "Kalshi subaccount number."
    },
    "exchange_index": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Exchange Index",
      "description": "Kalshi exchange shard index; currently 0.",
      "default": 0
    },
    "execute": {
      "type": "boolean",
      "title": "Execute",
      "description": "Must be true on `/trading/orders` for live execution.",
      "default": false
    },
    "confirmation": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 80
        },
        {
          "type": "null"
        }
      ],
      "title": "Confirmation",
      "description": "Must equal the server confirmation phrase."
    },
    "venue_credentials": {
      "anyOf": [
        {
          "$ref": "#/$defs/VenueCredentials"
        },
        {
          "type": "null"
        }
      ],
      "description": "Deprecated and rejected for public trading requests. Connect the account through /trading/connections first."
    },
    "title": {
      "type": "string",
      "maxLength": 160,
      "title": "Title",
      "description": "Short operator-facing name for this run.",
      "default": ""
    },
    "thesis": {
      "type": "string",
      "maxLength": 4000,
      "title": "Thesis",
      "description": "Optional research rationale retained with the trade run.",
      "default": ""
    },
    "source_conversation_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ],
      "title": "Source Conversation Id",
      "description": "Optional chat thread that produced the trade idea."
    },
    "expected_edge": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 1.0,
          "minimum": -1.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Expected Edge",
      "description": "Optional model-minus-market probability edge."
    },
    "sources": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "maxItems": 20,
      "title": "Sources",
      "description": "Optional source URLs or identifiers supporting the thesis."
    }
  },
  "type": "object",
  "required": [
    "platform",
    "quantity"
  ],
  "$defs": {
    "VenueCredentials": {
      "properties": {
        "kalshi_api_key_id": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 200
            },
            {
              "type": "null"
            }
          ],
          "title": "Kalshi Api Key Id"
        },
        "kalshi_private_key": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 8000
            },
            {
              "type": "null"
            }
          ],
          "title": "Kalshi Private Key",
          "description": "RSA private key PEM."
        },
        "kalshi_base_url": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 300
            },
            {
              "type": "null"
            }
          ],
          "title": "Kalshi Base Url"
        },
        "polymarket_private_key": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 400
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Private Key",
          "description": "Wallet private key."
        },
        "polymarket_api_key": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 200
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Api Key"
        },
        "polymarket_api_secret": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 400
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Api Secret"
        },
        "polymarket_api_passphrase": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 200
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Api Passphrase"
        },
        "polymarket_clob_host": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 300
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Clob Host"
        },
        "polymarket_chain_id": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 1000000000.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Chain Id"
        },
        "polymarket_signature_type": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 10.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Signature Type"
        },
        "polymarket_funder_address": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 100
            },
            {
              "type": "null"
            }
          ],
          "title": "Polymarket Funder Address"
        }
      },
      "type": "object",
      "title": "VenueCredentials",
      "description": "Credentials received only by the authenticated connection endpoint.\n\nThese values are accepted once over TLS, encrypted server-side, and never\nreturned to the browser. They are intentionally rejected on order-preview\nand order-submission requests so the public UI cannot fall back to a\nbrowser-held secret flow."
    }
  }
}