{
  "openapi": "3.1.1",
  "info": {
    "title": "KFF 交易员出图推送 API",
    "version": "1.1.0",
    "description": "由交易员服务端向本组织出图队列提交结构化素材，以及将真实账户订单映射绑定到已有策略。使用独立的交易员 Bearer 凭据。订单提交由交易员系统处理，账户观测和发布在工作台查看。"
  },
  "servers": [
    {
      "url": "/",
      "description": "当前 KFF 服务"
    }
  ],
  "paths": {
    "/api/v1/posters/events": {
      "post": {
        "operationId": "submitPosterEvent",
        "summary": "接收或重放一个出图事件",
        "description": "请求从服务端发送，省略 Origin，JSON 对象最大 64 KiB。新事件按组织设置的行情平台入队。连接断开、超时或 5xx 时保持 event_id 和原始请求内容重试本 POST。重放按原记录的平台核对输入，返回当前记录，不再次入队。运营后续编辑文案不会改变原请求的幂等判定。不同业务输入须用新 event_id。终止失败的渲染可由工作台管理员请求重试。",
        "security": [
          {
            "PosterIngestBearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/BusinessId"
            },
            "description": "可选，只能出现一次，必须与请求体 event_id 一致。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PosterEvent"
              },
              "examples": {
                "strategy": {
                  "summary": "策略发布",
                  "value": {
                    "event_id": "HY005:published:1",
                    "strategy_id": "HY005",
                    "kind": "strategy",
                    "venue": "binance",
                    "payload": {
                      "id": "HY005",
                      "symbol": "BTCUSDT",
                      "direction": "long",
                      "entry": "80000",
                      "target": "82000",
                      "stop": "79000",
                      "risk": "1.0",
                      "time": "2026-11-24T08:30:00Z",
                      "copyOrderType": "limit"
                    }
                  }
                },
                "result": {
                  "summary": "已结算平均成交价",
                  "value": {
                    "event_id": "HY005:settled:1",
                    "strategy_id": "HY005",
                    "kind": "result",
                    "venue": "binance",
                    "payload": {
                      "symbol": "BTCUSDT",
                      "direction": "long",
                      "entry": "80100",
                      "target": "82000",
                      "stop": "79000",
                      "exit": "82005",
                      "time": "2026-11-24T08:32:00Z",
                      "exitTime": "2026-11-24T12:10:00Z",
                      "status": "止盈",
                      "resultR": "1.73",
                      "netPnl": "18.50 USDT",
                      "plannedEntry": "80000"
                    }
                  }
                },
                "cancel": {
                  "summary": "入场未成交且挂单已终止",
                  "value": {
                    "event_id": "HY006:cancelled:1",
                    "strategy_id": "HY006",
                    "kind": "cancel",
                    "venue": "binance",
                    "payload": {
                      "symbol": "ETHUSDT",
                      "direction": "short",
                      "entry": "2700",
                      "time": "2026-11-24T13:11:00Z",
                      "reason": "未成交挂单已由交易员撤销。"
                    }
                  }
                },
                "weekly": {
                  "summary": "验证周报",
                  "value": {
                    "event_id": "2026-W48:weekly:1",
                    "kind": "weekly",
                    "venue": "binance",
                    "payload": {
                      "start": "2026-11-23",
                      "end": "2026-11-29",
                      "published": 3,
                      "tracking": 1,
                      "unit": "R",
                      "returns": "HY005,1.73\nHY007,-1"
                    }
                  }
                },
                "strategyHyperliquid": {
                  "summary": "Hyperliquid 组织的策略发布",
                  "value": {
                    "event_id": "HY009:published:1",
                    "strategy_id": "HY009",
                    "kind": "strategy",
                    "venue": "hyperliquid",
                    "payload": {
                      "symbol": "ETH",
                      "direction": "short",
                      "entry": "2700",
                      "target": "2650",
                      "stop": "2725",
                      "risk": "0.5",
                      "time": "2026-11-24T08:30:00Z"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "原事件已接收，返回最新记录。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "202": {
            "description": "新事件已入队，图片随后生成。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "400": {
            "description": "JSON、字段、时间或幂等头无效，或使用了内部保留的 execution: 事件前缀。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "交易员 Bearer 凭据缺失或不匹配。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "server_only_api。请求包含 Origin。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed。只接受 POST。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "event_conflict 表示同一编号的事件来源或输入不一致。poster_venue_mismatch 表示新事件显式指定的平台与组织设置不符，details 包含 configured_venue 和 requested_venue。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "payload_too_large。请求体超过 64 KiB。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "unsupported_media_type。使用 application/json。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "达到 IP 或交易员凭据的每分钟 120 次限制。根据 Retry-After 等待后重放原请求。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "重试前等待的秒数。"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "服务端异常。保留请求编号和原请求后重试。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "poster_ingest_disabled、database_unavailable 或服务暂不可用。核对环境与原请求编号后重试。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/posters/executions": {
      "post": {
        "operationId": "bindStrategyExecution",
        "summary": "绑定已提交的交易所订单",
        "description": "使用与出图推送相同的专用 Bearer 凭据。先创建 strategy 类型的原始计划，交易所接单后再按订单 ID 和角色绑定。省略 Idempotency-Key 请求头，超时按原映射重放。同角色重复绑定保持原记录，已封存的入场清单不能重打开。账户、平台、网络和合约保存为原策略绑定。",
        "security": [
          {
            "PosterIngestBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecutionBindingRequest"
              },
              "examples": {
                "bind": {
                  "summary": "登记 Binance 入场和条件止损单并确认入场齐全",
                  "value": {
                    "plan_job_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "account_alias": "binance-test",
                    "symbol": "BTCUSDT",
                    "orders": [
                      {
                        "order_id": "301023",
                        "role": "entry"
                      },
                      {
                        "order_id": "algo:703119",
                        "role": "stop_loss"
                      }
                    ],
                    "entries_complete": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回当前执行记录和精确订单映射。相同绑定重放返回同一记录。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecutionBindingResponse"
                }
              }
            }
          },
          "400": {
            "description": "JSON、字段、订单角色或封存前提错误。invalid_execution_order_id 表示订单编号格式无效。请求使用无查询参数的路径和 JSON 请求体。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "交易员 Bearer 凭据缺失或不匹配。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "server_only_api。请求包含 Origin。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "未在当前组织找到原策略发布记录。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed。只接受 POST。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "计划、账户、合约或订单绑定冲突。可能包括 execution_plan_required、execution_account_unavailable、execution_symbol_unavailable、execution_order_conflict、execution_scope_conflict、execution_entries_sealed、execution_finalized 、execution_network_conflict 或 execution_symbol_mismatch。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "payload_too_large。请求体超过 64 KiB。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "unsupported_media_type。使用 application/json。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "达到 IP 或交易员凭据的每分钟 120 次限制。根据 Retry-After 等待后重放原请求。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "重试前等待的秒数。"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "服务端异常。保留请求编号和原请求后重试。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "推送未配置、执行账户配置不可用或数据库暂不可用。",
            "headers": {
              "X-Request-Id": {
                "description": "KFF 请求编号。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PosterIngestBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "KFF_POSTER_INGEST_TOKEN，绑定 KFF_POSTER_INGEST_TENANT 对应的组织。32 至 248 字符，仅可用 A–Z、a–z、0–9、点、下划线、波浪号、连字符。"
      }
    },
    "schemas": {
      "BusinessId": {
        "type": "string",
        "maxLength": 128,
        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$"
      },
      "UtcTime": {
        "type": "string",
        "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\\.[0-9]{1,6})?)?(?:Z|\\+00:00)?$",
        "description": "UTC 时间，推荐附 Z。省略时区后缀时仍按 UTC。"
      },
      "Venue": {
        "type": "string",
        "enum": [
          "binance",
          "hyperliquid"
        ]
      },
      "EventFields": {
        "type": "object",
        "required": [
          "event_id",
          "kind",
          "payload"
        ],
        "properties": {
          "event_id": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BusinessId"
              },
              {
                "not": {
                  "pattern": "^execution:"
                }
              }
            ],
            "description": "execution: 前缀保留给内部执行账本派生素材。"
          },
          "strategy_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BusinessId"
              },
              {
                "type": "null"
              }
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "strategy",
              "result",
              "weekly",
              "cancel"
            ]
          },
          "venue": {
            "$ref": "#/components/schemas/Venue",
            "description": "可省略，新事件使用组织当前行情来源，未配置时默认为 Binance。显式指定的新事件须与组织设置一致。重试原有事件时保留原 venue 字段或原省略状态。"
          },
          "language": {
            "type": "string",
            "enum": [
              "zh",
              "en"
            ],
            "default": "zh"
          },
          "scale": {
            "type": "integer",
            "enum": [
              1,
              2
            ],
            "default": 1
          },
          "interval": {
            "type": "string",
            "enum": [
              "15m",
              "1h",
              "4h",
              "1d"
            ],
            "default": "4h"
          },
          "copy_text": {
            "type": "string",
            "maxLength": 4000,
            "description": "初始文案。省略时由 KFF 生成。"
          },
          "client_operation_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BusinessId"
              },
              {
                "type": "null"
              }
            ],
            "description": "若提供，必须等于 event_id。"
          }
        }
      },
      "StrategyPayload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "symbol",
          "direction",
          "entry",
          "target",
          "stop",
          "risk",
          "time"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 24,
            "description": "海报展示编号。默认采用 strategy_id，长于 24 字符时须另传短编号。",
            "minLength": 1
          },
          "symbol": {
            "type": "string",
            "maxLength": 22,
            "description": "Binance USDⓈ-M 合约代码或 Hyperliquid 原生永续代码。",
            "minLength": 1
          },
          "direction": {
            "type": "string",
            "enum": [
              "long",
              "short"
            ]
          },
          "entry": {
            "description": "正十进制价格。建议传字符串保留小数位，总长度最多 16 个字符，包括小数点。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "time": {
            "$ref": "#/components/schemas/UtcTime",
            "description": "策略发布时间，后台以此为历史行情截止时间。"
          },
          "example": {
            "const": false,
            "description": "正式记录可省略或传 false。"
          },
          "target": {
            "description": "正十进制价格。建议传字符串保留小数位，总长度最多 16 个字符，包括小数点。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "stop": {
            "description": "正十进制价格。建议传字符串保留小数位，总长度最多 16 个字符，包括小数点。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "risk": {
            "description": "正数，最大 100，表示百分比（1 表示 1%）。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 26,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "待执行",
              "挂单中",
              "持仓中",
              "已取消",
              "止盈",
              "止损",
              "已平仓"
            ],
            "default": "待执行"
          },
          "copyOrderType": {
            "type": "string",
            "enum": [
              "limit",
              "market"
            ],
            "default": "limit"
          }
        }
      },
      "ResultPayload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "symbol",
          "direction",
          "entry",
          "target",
          "stop",
          "exit",
          "time",
          "exitTime"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 24,
            "description": "海报展示编号。默认采用 strategy_id，长于 24 字符时须另传短编号。",
            "minLength": 1
          },
          "symbol": {
            "type": "string",
            "maxLength": 22,
            "description": "Binance USDⓈ-M 合约代码或 Hyperliquid 原生永续代码。",
            "minLength": 1
          },
          "direction": {
            "type": "string",
            "enum": [
              "long",
              "short"
            ]
          },
          "entry": {
            "description": "实际平均开仓价。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "time": {
            "$ref": "#/components/schemas/UtcTime"
          },
          "example": {
            "const": false,
            "description": "正式记录可省略或传 false。"
          },
          "target": {
            "description": "正十进制价格。建议传字符串保留小数位，总长度最多 16 个字符，包括小数点。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "stop": {
            "description": "正十进制价格。建议传字符串保留小数位，总长度最多 16 个字符，包括小数点。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "exit": {
            "description": "实际平均平仓价。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "exitTime": {
            "$ref": "#/components/schemas/UtcTime",
            "description": "必须不早于入场时间。"
          },
          "status": {
            "type": "string",
            "enum": [
              "止盈",
              "止损",
              "已平仓"
            ],
            "default": "已平仓"
          },
          "points": {
            "type": "string",
            "maxLength": 12000,
            "description": "最多 200 行，每行 时间,价格。"
          },
          "resultR": {
            "description": "已确认的收益风险倍数。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 26,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number"
              }
            ]
          },
          "grossPnl": {
            "type": "string",
            "maxLength": 30,
            "description": "实际毛盈亏，金额与币种用一个空格分隔。",
            "pattern": "^[+-]?[0-9]+(?:\\.[0-9]+)? [A-Z0-9]{2,10}$"
          },
          "netPnl": {
            "type": "string",
            "maxLength": 30,
            "description": "实际净盈亏，金额与币种用一个空格分隔。",
            "pattern": "^[+-]?[0-9]+(?:\\.[0-9]+)? [A-Z0-9]{2,10}$"
          },
          "plannedEntry": {
            "description": "原策略计划入场价，可省略。提供时与初始止损和目标价一起校验计划方向。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          }
        },
        "description": "entry 和 exit 分别表示实际平均开仓价和平仓价。实际成交可因滑点超出原计划价格区间。"
      },
      "CancelPayload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "symbol",
          "direction",
          "entry",
          "time"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 24,
            "description": "海报展示编号。默认采用 strategy_id，长于 24 字符时须另传短编号。",
            "minLength": 1
          },
          "symbol": {
            "type": "string",
            "maxLength": 22,
            "description": "Binance USDⓈ-M 合约代码或 Hyperliquid 原生永续代码。",
            "minLength": 1
          },
          "direction": {
            "type": "string",
            "enum": [
              "long",
              "short"
            ]
          },
          "entry": {
            "description": "正十进制价格。建议传字符串保留小数位，总长度最多 16 个字符，包括小数点。",
            "oneOf": [
              {
                "type": "string",
                "maxLength": 16,
                "pattern": "^[+-]?[0-9]{1,18}(?:\\.[0-9]{1,15})?$"
              },
              {
                "type": "number",
                "exclusiveMinimum": 0
              }
            ]
          },
          "time": {
            "$ref": "#/components/schemas/UtcTime",
            "description": "撤单时间。"
          },
          "example": {
            "const": false,
            "description": "正式记录可省略或传 false。"
          },
          "status": {
            "const": "已取消"
          },
          "reason": {
            "type": "string",
            "maxLength": 240,
            "description": "可核对的撤单原因。默认撤销挂单。"
          },
          "reasonEn": {
            "type": "string",
            "maxLength": 240,
            "description": "自定义中文原因的英文稿。"
          }
        }
      },
      "WeeklyPayload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "start",
          "end",
          "published",
          "tracking"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date"
          },
          "end": {
            "type": "string",
            "format": "date"
          },
          "published": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 999999999
              },
              {
                "type": "string",
                "pattern": "^[0-9]{1,9}$"
              }
            ]
          },
          "tracking": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 999999999
              },
              {
                "type": "string",
                "pattern": "^[0-9]{1,9}$"
              }
            ]
          },
          "unit": {
            "type": "string",
            "enum": [
              "%",
              "R"
            ],
            "default": "%"
          },
          "returns": {
            "type": "string",
            "maxLength": 12000,
            "description": "最多 16 行，每行 业务编号,数值。编号不可重复。"
          },
          "example": {
            "const": false
          }
        }
      },
      "StrategyEvent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EventFields"
          },
          {
            "type": "object",
            "required": [
              "strategy_id",
              "payload"
            ],
            "properties": {
              "kind": {
                "const": "strategy"
              },
              "strategy_id": {
                "$ref": "#/components/schemas/BusinessId"
              },
              "payload": {
                "$ref": "#/components/schemas/StrategyPayload"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "ResultEvent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EventFields"
          },
          {
            "type": "object",
            "required": [
              "strategy_id",
              "payload"
            ],
            "properties": {
              "kind": {
                "const": "result"
              },
              "strategy_id": {
                "$ref": "#/components/schemas/BusinessId"
              },
              "payload": {
                "$ref": "#/components/schemas/ResultPayload"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "CancelEvent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EventFields"
          },
          {
            "type": "object",
            "required": [
              "strategy_id",
              "payload"
            ],
            "properties": {
              "kind": {
                "const": "cancel"
              },
              "strategy_id": {
                "$ref": "#/components/schemas/BusinessId"
              },
              "payload": {
                "$ref": "#/components/schemas/CancelPayload"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "WeeklyEvent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EventFields"
          },
          {
            "type": "object",
            "required": [
              "payload"
            ],
            "properties": {
              "kind": {
                "const": "weekly"
              },
              "payload": {
                "$ref": "#/components/schemas/WeeklyPayload"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "PosterEvent": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/StrategyEvent"
          },
          {
            "$ref": "#/components/schemas/ResultEvent"
          },
          {
            "$ref": "#/components/schemas/WeeklyEvent"
          },
          {
            "$ref": "#/components/schemas/CancelEvent"
          }
        ]
      },
      "JobResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/PosterJob"
          }
        }
      },
      "PosterJob": {
        "type": "object",
        "required": [
          "id",
          "event_id",
          "strategy_id",
          "kind",
          "venue",
          "language",
          "scale",
          "interval",
          "source",
          "created_at",
          "updated_at",
          "render_status",
          "render_error",
          "attempts",
          "image_sha256",
          "copy_text",
          "copy_version",
          "publication_status",
          "approved_at",
          "payload",
          "image_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[0-9a-f]{32}$"
          },
          "event_id": {
            "$ref": "#/components/schemas/BusinessId"
          },
          "strategy_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BusinessId"
              },
              {
                "type": "null"
              }
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "strategy",
              "result",
              "weekly",
              "cancel"
            ]
          },
          "venue": {
            "$ref": "#/components/schemas/Venue"
          },
          "language": {
            "type": "string",
            "enum": [
              "zh",
              "en"
            ]
          },
          "scale": {
            "type": "integer",
            "enum": [
              1,
              2
            ]
          },
          "interval": {
            "type": "string",
            "enum": [
              "15m",
              "1h",
              "4h",
              "1d"
            ]
          },
          "source": {
            "const": "trader_api"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "render_status": {
            "type": "string",
            "enum": [
              "pending",
              "rendering",
              "ready",
              "failed"
            ]
          },
          "render_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "可读的失败或等待重试原因。"
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "image_sha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{64}$"
          },
          "copy_text": {
            "type": "string",
            "description": "响应反映当前文案版本，其中可能包含运营修改。"
          },
          "copy_version": {
            "type": "integer",
            "minimum": 1
          },
          "publication_status": {
            "type": "string",
            "enum": [
              "draft",
              "ready"
            ],
            "description": "ready 表示人工确认待发布。"
          },
          "approved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payload": {
            "type": "object",
            "description": "规范化后的模板数据，包含字段默认值和必要时的原始时间精度。"
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "供授权工作台账号使用的同源 PNG 路径。"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error",
          "request_id"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "ExecutionOrderBinding": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "pattern": "^(?:algo:)?[1-9][0-9]{0,20}$",
            "description": "1 至 21 位正整数订单 ID，以字符串传入。Binance 条件单使用 algo:<algoId>。"
          },
          "role": {
            "type": "string",
            "enum": [
              "entry",
              "take_profit",
              "stop_loss",
              "exit"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "order_id",
          "role"
        ]
      },
      "ExecutionBindingRequest": {
        "type": "object",
        "properties": {
          "plan_job_id": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$",
            "description": "先前创建的原策略发布记录 ID。"
          },
          "account_alias": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_.-]{0,63}$",
            "description": "已配置、与原计划平台和合约一致的账户别名。"
          },
          "orders": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ExecutionOrderBinding"
            },
            "description": "订单按 ID 精确绑定。同一策略累计最多 100 笔。"
          },
          "entries_complete": {
            "type": "boolean",
            "default": false,
            "description": "确认所有入场订单已登记。需至少已有一笔 entry。封存后仅能在终态前追加退出订单。"
          },
          "symbol": {
            "type": "string",
            "description": "可选合约断言。规范化后必须与原策略合约一致。"
          }
        },
        "additionalProperties": false,
        "required": [
          "plan_job_id",
          "account_alias",
          "orders"
        ]
      },
      "ExecutionSummary": {
        "type": "object",
        "properties": {
          "entry_qty": {
            "type": "string",
            "description": "精确十进制字符串。"
          },
          "exit_qty": {
            "type": "string",
            "description": "精确十进制字符串。"
          },
          "average_entry": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "average_exit": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "gross_pnl": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "fee_total": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "net_pnl": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "quote_asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "entry_time": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "exit_time": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "description": "归因到策略的逐笔成交汇总。尚未归因时可为空对象。净盈亏扣除同币种可核对手续费，资金费用单独归原账目。 已实现盈亏以交易所的账户仓位成本为基础。多策略共享仓位时不能据此得到各策略独立收益。"
      },
      "ExecutionObservedOrder": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$",
            "description": "交易所订单 ID。Binance 条件单使用 algo:<algoId>。"
          },
          "client_order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "parent_order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "filled",
              "canceled",
              "expired",
              "rejected"
            ]
          },
          "filled_qty": {
            "type": "string",
            "description": "精确十进制字符串。"
          },
          "at_ms": {
            "type": "integer",
            "minimum": 0
          },
          "position_side": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "LONG",
              "SHORT",
              "BOTH",
              null
            ]
          },
          "reduce_only": {
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "order_id",
          "client_order_id",
          "parent_order_id",
          "status",
          "filled_qty",
          "at_ms",
          "position_side",
          "reduce_only"
        ]
      },
      "ExecutionObservedFill": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$",
            "description": "交易所订单 ID。Binance 条件单使用 algo:<algoId>。"
          },
          "fill_id": {
            "type": "string"
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "price": {
            "type": "string",
            "description": "精确十进制字符串。"
          },
          "qty": {
            "type": "string",
            "description": "精确十进制字符串。"
          },
          "pnl": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "fee": {
            "type": [
              "string",
              "null"
            ],
            "description": "精确十进制字符串。缺少证据时为 null。"
          },
          "fee_asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "quote_asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "at_ms": {
            "type": "integer",
            "minimum": 0
          },
          "intent_direction": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "open_long",
              "close_long",
              "open_short",
              "close_short",
              "other",
              null
            ]
          }
        },
        "required": [
          "order_id",
          "fill_id",
          "side",
          "price",
          "qty",
          "pnl",
          "fee",
          "fee_asset",
          "quote_asset",
          "at_ms",
          "intent_direction"
        ]
      },
      "ExecutionRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$"
          },
          "strategy_id": {
            "$ref": "#/components/schemas/BusinessId"
          },
          "plan_job_id": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$"
          },
          "venue": {
            "$ref": "#/components/schemas/Venue"
          },
          "account_alias": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": [
              "long",
              "short"
            ]
          },
          "entries_complete": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "awaiting_orders",
              "tracking",
              "partially_filled",
              "partially_closed",
              "needs_review",
              "canceled",
              "settled"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "result_job_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{32}$"
          },
          "summary": {
            "$ref": "#/components/schemas/ExecutionSummary"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "reconciled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "bindings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExecutionOrderBinding"
            }
          },
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExecutionObservedOrder"
            }
          },
          "fills": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExecutionObservedFill"
            }
          },
          "network": {
            "type": "string",
            "enum": [
              "mainnet",
              "testnet"
            ],
            "description": "从原账户配置冻结的交易网络。"
          }
        },
        "required": [
          "id",
          "strategy_id",
          "plan_job_id",
          "venue",
          "account_alias",
          "symbol",
          "direction",
          "entries_complete",
          "status",
          "reason",
          "result_job_id",
          "summary",
          "created_at",
          "updated_at",
          "reconciled_at",
          "bindings",
          "orders",
          "fills",
          "network"
        ]
      },
      "ExecutionBindingResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExecutionRecord"
          }
        },
        "required": [
          "data"
        ]
      }
    }
  }
}
