Tìm endpoint, bảo vệ khóa và tích hợp với giới hạn credit rõ ràng.
Tạo khóa trong console. Gửi Authorization: Bearer hoặc X-API-Key từ máy chủ của bạn. Không đưa khóa vào URL, mã trình duyệt công khai, hệ thống phân tích hay kho mã. Secret chỉ hiển thị một lần; thu hồi khóa nếu bị lộ.
Lưu Idempotency-Key trước khi thực thi và dùng lại khi mất phản hồi. Cùng định danh nhưng khác đầu vào sẽ bị từ chối. Replay kiểm tra quyền hiện tại và không trừ thêm credit. Định danh còn hiệu lực nhưng kết quả đã hết hạn không được chạy lại. Operation chưa rõ kết quả cần được đối soát trước lần thử mới.
Lấy báo giá rồi thực thi với X-Max-Credits. Báo giá có hạn; lúc chạy, hệ thống kiểm tra lại giá và quyền hiện tại. Budget project và khóa dùng chung allowance và ví của tài khoản. Tạo project không cấp thêm credit. Trong batch thành công một phần, item thành công vẫn bị tính credit; retry item lỗi bằng định danh ban đầu.
Thời gian nến là Unix giây theo UTC. Chỉ báo null nghĩa là chưa đủ dữ liệu khởi tạo hoặc không tính được, không phải số 0. Thiếu volume khác với volume đo được bằng 0. Độ tương đồng và chất lượng thiết lập không phải xác suất có lãi. asOf lịch sử không được hỗ trợ nếu chưa có bằng chứng đúng thời điểm.
REST, GraphQL, JSON-RPC, MCP, batch tuần tự, kết quả tác vụ SSE và Socket.IO dùng chung xác thực và tính credit. Kiểm tra lỗi từng item hoặc field ngay cả khi HTTP 200. SSE và Socket.IO trả kết quả tác vụ, không phải luồng giá trực tiếp. GraphQL giữ dữ liệu JSON cũ và bổ sung query có kiểu.
SDK giữ nguyên định danh operation qua số lần retry có giới hạn, tuân thủ Retry-After, hỗ trợ deadline và hủy. Không retry mù quáng lỗi đầu vào, xác thực, quyền hoặc số dư. Lưu thông tin xác thực trong biến môi trường phía máy chủ. Ví dụ bên dưới thực hiện phép tính khối lượng vị thế.
curl -X POST https://traderai.cloud/api/v1/open/risk/position-size \
-H "Authorization: Bearer $TRADERAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"accountBalance":10000,"riskPercent":1,"entryPrice":100,"stopLossPrice":95,"takeProfitPrice":110}'import os, requests
res = requests.post(
"https://traderai.cloud/api/v1/open/risk/position-size",
headers={"Authorization": f"Bearer {os.environ['TRADERAI_API_KEY']}"},
json={"accountBalance": 10000, "riskPercent": 1, "entryPrice": 100, "stopLossPrice": 95},
timeout=30,
)
print(res.json()["meta"]["creditsCharged"])Team dùng chung credit trả trước của chủ thanh toán. Thêm thành viên, project hay key không tăng hạn mức.
Chỉ chủ thanh toán được mua credit hoặc xem đơn của mình. Thành viên xem mức sử dụng của team.
Quyền dữ liệu phụ thuộc nguồn đã duyệt, khu vực và mục đích sử dụng. Gói cao hơn không tự cấp quyền phân phối. Chưa cung cấp feed live.
Chạy tác vụ bằng API key. Sự kiện hoàn thành có thể gửi đến địa chỉ HTTPS của bạn. Giao lại sự kiện không chạy lại tác vụ.
Sự kiện chỉ được đánh giá khi ứng dụng của bạn gửi nến đã đóng. Không tiếp tục theo dõi trực tiếp khi thiếu dữ liệu mới.
POST /open/jobs
{ "endpoint": "risk.position-size", "input": { "accountBalance": 10000, "riskPercent": 1, "entryPrice": 100, "stopLossPrice": 95 }, "options": { "idempotencyKey": "my-job-1", "maxCredits": 10 } }
GET /open/jobs/{id}
GET /open/jobs/{id}/result
POST /open/jobs/{id}/cancel
POST /open/workflows
POST /open/workflows/{id}/run
POST /open/subscriptions
POST /open/subscriptions/{id}/push
GET /open/subscriptions/{id}/events?after=0&limit=20{
"type": "object",
"properties": {
"candles": {
"type": "array",
"items": {
"type": "object",
"description": "One OHLCV bar. time = bar OPEN time in UTC seconds (or milliseconds; auto-detected). Ascending, unique.",
"properties": {
"time": {
"type": "number"
},
"open": {
"type": "number"
},
"high": {
"type": "number"
},
"low": {
"type": "number"
},
"close": {
"type": "number"
},
"volume": {
"type": "number",
"description": "Optional. Required by volume studies."
}
},
"required": [
"time",
"open",
"high",
"low",
"close"
]
},
"minItems": 2,
"maxItems": 5000
},
"indicators": {
"type": "array",
"minItems": 1,
"maxItems": 10,
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Indicator id from GET /indicators."
},
"params": {
"type": "object",
"additionalProperties": true
},
"key": {
"type": "string",
"maxLength": 40,
"description": "Optional label echoed back."
}
},
"required": [
"id"
]
}
},
"last": {
"type": "number",
"minimum": 1,
"maximum": 5000,
"description": "Return only the newest N points of each series."
}
},
"required": [
"candles",
"indicators"
]
}{
"type": "object",
"properties": {
"candles": {
"type": "integer",
"minimum": 2
},
"indicators": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"family": {
"type": "string"
},
"formulaVersion": {
"type": "string"
},
"params": {
"type": "object",
"additionalProperties": true,
"description": "Validated effective indicator parameters."
},
"outputs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"points": {
"type": "array",
"items": {
"type": "object",
"properties": {
"time": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"value": {
"type": [
"number",
"null"
],
"description": "Indicator-native units. null means warm-up, a gap, or mathematically unavailable; never zero-fill."
}
},
"required": [
"time",
"value"
],
"additionalProperties": true
}
}
},
"required": [
"id",
"points"
],
"additionalProperties": true
}
},
"key": {
"type": "string",
"description": "Optional caller label."
}
},
"required": [
"id",
"family",
"formulaVersion",
"params",
"outputs"
],
"additionalProperties": true
}
},
"metadata": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"origin": {
"type": "string",
"enum": [
"caller",
"server"
]
},
"observedAt": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"computedAt": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"dataAsOf": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"lastClosedBar": {
"type": [
"number",
"null"
],
"description": "Bar OPEN time in UTC Unix seconds."
},
"barPolicy": {
"type": "string",
"enum": [
"closed",
"caller-supplied"
]
},
"market": {
"type": [
"string",
"null"
]
},
"requestedSymbol": {
"type": [
"string",
"null"
]
},
"resolvedInstrument": {
"type": "null"
},
"venue": {
"type": "null"
},
"currency": {
"type": "null"
},
"units": {
"type": "object",
"properties": {
"time": {
"type": "string",
"enum": [
"unix_seconds"
]
},
"prices": {
"type": "string"
},
"volume": {
"type": "string"
}
},
"required": [
"time",
"prices",
"volume"
],
"additionalProperties": true
},
"volume": {
"type": "object",
"properties": {
"missingBars": {
"type": "number"
},
"zeroBars": {
"type": "number"
}
},
"required": [
"missingBars",
"zeroBars"
],
"additionalProperties": true
},
"gaps": {
"type": "object",
"properties": {
"assessed": {
"type": "boolean"
},
"missingIntervals": {
"type": [
"number",
"null"
]
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"properties": {
"after": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"before": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"missing": {
"type": "number"
}
},
"required": [
"after",
"before",
"missing"
],
"additionalProperties": true
}
},
"truncated": {
"type": "boolean"
}
},
"required": [
"assessed",
"missingIntervals",
"ranges",
"truncated"
],
"additionalProperties": true
},
"stale": {
"type": "null"
},
"delaySeconds": {
"type": [
"number",
"null"
]
}
},
"required": [
"version",
"origin",
"observedAt",
"computedAt",
"dataAsOf",
"lastClosedBar",
"barPolicy",
"market",
"requestedSymbol",
"resolvedInstrument",
"venue",
"currency",
"units",
"volume",
"gaps",
"stale",
"delaySeconds"
],
"additionalProperties": true,
"description": "Unknown instrument, venue, currency and stale status remain null until the adapter supplies verified evidence. observedAt is API observation time, not a provider publication timestamp."
}
},
"required": [
"candles",
"indicators"
],
"additionalProperties": true
}{
"type": "object",
"properties": {
"candles": {
"type": "array",
"items": {
"type": "object",
"description": "One OHLCV bar. time = bar OPEN time in UTC seconds (or milliseconds; auto-detected). Ascending, unique.",
"properties": {
"time": {
"type": "number"
},
"open": {
"type": "number"
},
"high": {
"type": "number"
},
"low": {
"type": "number"
},
"close": {
"type": "number"
},
"volume": {
"type": "number",
"description": "Optional. Required by volume studies."
}
},
"required": [
"time",
"open",
"high",
"low",
"close"
]
},
"minItems": 2,
"maxItems": 5000
},
"max": {
"type": "number",
"minimum": 1,
"maximum": 50,
"default": 10
}
},
"required": [
"candles"
]
}{
"type": "object",
"properties": {
"patterns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"descriptionKey": {
"type": "string"
},
"bias": {
"type": "string",
"enum": [
"bullish",
"bearish",
"neutral"
]
},
"strength": {
"type": "string",
"enum": [
"strong",
"moderate",
"weak"
]
},
"candleIndex": {
"type": "integer",
"minimum": 0
},
"time": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"price": {
"type": "number",
"description": "Chart annotation price, not an executable quote."
}
},
"required": [
"id",
"label",
"description",
"descriptionKey",
"bias",
"strength",
"candleIndex",
"time",
"price"
],
"additionalProperties": true
},
"description": "Empty array means no detected pattern, not a request failure."
},
"note": {
"type": "string"
},
"metadata": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"origin": {
"type": "string",
"enum": [
"caller",
"server"
]
},
"observedAt": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"computedAt": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"dataAsOf": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"lastClosedBar": {
"type": [
"number",
"null"
],
"description": "Bar OPEN time in UTC Unix seconds."
},
"barPolicy": {
"type": "string",
"enum": [
"closed",
"caller-supplied"
]
},
"market": {
"type": [
"string",
"null"
]
},
"requestedSymbol": {
"type": [
"string",
"null"
]
},
"resolvedInstrument": {
"type": "null"
},
"venue": {
"type": "null"
},
"currency": {
"type": "null"
},
"units": {
"type": "object",
"properties": {
"time": {
"type": "string",
"enum": [
"unix_seconds"
]
},
"prices": {
"type": "string"
},
"volume": {
"type": "string"
}
},
"required": [
"time",
"prices",
"volume"
],
"additionalProperties": true
},
"volume": {
"type": "object",
"properties": {
"missingBars": {
"type": "number"
},
"zeroBars": {
"type": "number"
}
},
"required": [
"missingBars",
"zeroBars"
],
"additionalProperties": true
},
"gaps": {
"type": "object",
"properties": {
"assessed": {
"type": "boolean"
},
"missingIntervals": {
"type": [
"number",
"null"
]
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"properties": {
"after": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"before": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"missing": {
"type": "number"
}
},
"required": [
"after",
"before",
"missing"
],
"additionalProperties": true
}
},
"truncated": {
"type": "boolean"
}
},
"required": [
"assessed",
"missingIntervals",
"ranges",
"truncated"
],
"additionalProperties": true
},
"stale": {
"type": "null"
},
"delaySeconds": {
"type": [
"number",
"null"
]
}
},
"required": [
"version",
"origin",
"observedAt",
"computedAt",
"dataAsOf",
"lastClosedBar",
"barPolicy",
"market",
"requestedSymbol",
"resolvedInstrument",
"venue",
"currency",
"units",
"volume",
"gaps",
"stale",
"delaySeconds"
],
"additionalProperties": true,
"description": "Unknown instrument, venue, currency and stale status remain null until the adapter supplies verified evidence. observedAt is API observation time, not a provider publication timestamp."
}
},
"required": [
"patterns",
"note"
],
"additionalProperties": true
}{
"type": "object",
"properties": {
"accountBalance": {
"type": "number",
"minimum": 0
},
"riskPercent": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"entryPrice": {
"type": "number"
},
"stopLossPrice": {
"type": "number"
},
"takeProfitPrice": {
"type": "number"
},
"leverage": {
"type": "number",
"minimum": 1,
"maximum": 200,
"default": 1
}
},
"required": [
"accountBalance",
"riskPercent",
"entryPrice",
"stopLossPrice"
]
}{
"type": "object",
"properties": {
"direction": {
"type": "string",
"enum": [
"long",
"short"
]
},
"riskAmount": {
"type": "number"
},
"quantity": {
"type": "number"
},
"notional": {
"type": "number"
},
"marginRequired": {
"type": "number"
},
"stopDistance": {
"type": "number"
},
"stopDistancePercent": {
"type": [
"number",
"null"
],
"description": "Percent of entry price."
},
"rewardRisk": {
"type": [
"number",
"null"
],
"description": "Dimensionless reward/risk ratio; null without a target."
},
"potentialProfit": {
"type": [
"number",
"null"
],
"description": "Account/quote currency; excludes fees, slippage and contract multipliers."
},
"note": {
"type": "string"
}
},
"required": [
"direction",
"riskAmount",
"quantity",
"notional",
"marginRequired",
"stopDistance",
"stopDistancePercent",
"rewardRisk",
"potentialProfit",
"note"
],
"additionalProperties": true,
"description": "Quantity is base asset units. Monetary numbers are calculated IEEE-754 estimates, not venue fills or payment amounts."
}{
"type": "object",
"properties": {
"candles": {
"type": "array",
"items": {
"type": "object",
"description": "One OHLCV bar. time = bar OPEN time in UTC seconds (or milliseconds; auto-detected). Ascending, unique.",
"properties": {
"time": {
"type": "number"
},
"open": {
"type": "number"
},
"high": {
"type": "number"
},
"low": {
"type": "number"
},
"close": {
"type": "number"
},
"volume": {
"type": "number",
"description": "Optional. Required by volume studies."
}
},
"required": [
"time",
"open",
"high",
"low",
"close"
]
},
"minItems": 2,
"maxItems": 5000
}
},
"required": [
"candles"
]
}{
"type": "object",
"properties": {
"model": {
"type": "string"
},
"lastClose": {
"type": "number"
},
"sigmaPercent": {
"type": "number",
"description": "Expected next-bar move in percent; not direction."
},
"range68": {
"type": "object",
"properties": {
"lower": {
"type": "number"
},
"upper": {
"type": "number"
}
},
"required": [
"lower",
"upper"
],
"additionalProperties": true
},
"range95": {
"type": "object",
"properties": {
"lower": {
"type": "number"
},
"upper": {
"type": "number"
}
},
"required": [
"lower",
"upper"
],
"additionalProperties": true
},
"note": {
"type": "string"
},
"metadata": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"origin": {
"type": "string",
"enum": [
"caller",
"server"
]
},
"observedAt": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"computedAt": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"dataAsOf": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"lastClosedBar": {
"type": [
"number",
"null"
],
"description": "Bar OPEN time in UTC Unix seconds."
},
"barPolicy": {
"type": "string",
"enum": [
"closed",
"caller-supplied"
]
},
"market": {
"type": [
"string",
"null"
]
},
"requestedSymbol": {
"type": [
"string",
"null"
]
},
"resolvedInstrument": {
"type": "null"
},
"venue": {
"type": "null"
},
"currency": {
"type": "null"
},
"units": {
"type": "object",
"properties": {
"time": {
"type": "string",
"enum": [
"unix_seconds"
]
},
"prices": {
"type": "string"
},
"volume": {
"type": "string"
}
},
"required": [
"time",
"prices",
"volume"
],
"additionalProperties": true
},
"volume": {
"type": "object",
"properties": {
"missingBars": {
"type": "number"
},
"zeroBars": {
"type": "number"
}
},
"required": [
"missingBars",
"zeroBars"
],
"additionalProperties": true
},
"gaps": {
"type": "object",
"properties": {
"assessed": {
"type": "boolean"
},
"missingIntervals": {
"type": [
"number",
"null"
]
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"properties": {
"after": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"before": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"missing": {
"type": "number"
}
},
"required": [
"after",
"before",
"missing"
],
"additionalProperties": true
}
},
"truncated": {
"type": "boolean"
}
},
"required": [
"assessed",
"missingIntervals",
"ranges",
"truncated"
],
"additionalProperties": true
},
"stale": {
"type": "null"
},
"delaySeconds": {
"type": [
"number",
"null"
]
}
},
"required": [
"version",
"origin",
"observedAt",
"computedAt",
"dataAsOf",
"lastClosedBar",
"barPolicy",
"market",
"requestedSymbol",
"resolvedInstrument",
"venue",
"currency",
"units",
"volume",
"gaps",
"stale",
"delaySeconds"
],
"additionalProperties": true,
"description": "Unknown instrument, venue, currency and stale status remain null until the adapter supplies verified evidence. observedAt is API observation time, not a provider publication timestamp."
}
},
"required": [
"model",
"lastClose",
"sigmaPercent",
"range68",
"range95",
"note"
],
"additionalProperties": true
}{
"type": "object",
"properties": {
"candles": {
"type": "array",
"items": {
"type": "object",
"description": "One OHLCV bar. time = bar OPEN time in UTC seconds (or milliseconds; auto-detected). Ascending, unique.",
"properties": {
"time": {
"type": "number"
},
"open": {
"type": "number"
},
"high": {
"type": "number"
},
"low": {
"type": "number"
},
"close": {
"type": "number"
},
"volume": {
"type": "number",
"description": "Optional. Required by volume studies."
}
},
"required": [
"time",
"open",
"high",
"low",
"close"
]
},
"minItems": 2,
"maxItems": 20000
},
"intervalSec": {
"type": "number",
"minimum": 60,
"maximum": 604800
},
"window": {
"type": "number",
"enum": [
20,
30,
50,
100
],
"default": 30
},
"limit": {
"type": "number",
"minimum": 1,
"maximum": 20,
"default": 10
}
},
"required": [
"candles",
"intervalSec"
]
}{
"type": "object",
"properties": {
"methodVersion": {
"type": "string"
},
"intervalSec": {
"type": "number"
},
"window": {
"type": "number"
},
"horizons": {
"type": "array",
"items": {
"type": "number"
}
},
"query": {
"type": "object",
"properties": {
"startTime": {
"type": "number"
},
"endTime": {
"type": "number"
},
"close": {
"type": "number"
},
"features": {
"type": "object",
"properties": {
"rsi": {
"type": "number"
},
"atrPct": {
"type": "number"
},
"rangePos": {
"type": "number"
},
"rsiZone": {
"type": "string",
"enum": [
"oversold",
"neutral",
"overbought"
]
},
"trendAtr": {
"type": [
"number",
"null"
]
},
"trend": {
"type": [
"string",
"null"
]
},
"fundingRate": {
"type": [
"number",
"null"
]
}
},
"required": [
"rsi",
"atrPct",
"rangePos",
"rsiZone",
"trendAtr",
"trend",
"fundingRate"
],
"additionalProperties": true
},
"path": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": [
"startTime",
"endTime",
"close",
"features",
"path"
],
"additionalProperties": true
},
"matches": {
"type": "array",
"items": {
"type": "object",
"properties": {
"rank": {
"type": "number"
},
"startTime": {
"type": "number"
},
"endTime": {
"type": "number"
},
"similarity": {
"type": "number"
},
"close": {
"type": "number"
},
"features": {
"type": "object",
"properties": {
"rsi": {
"type": "number"
},
"atrPct": {
"type": "number"
},
"rangePos": {
"type": "number"
},
"rsiZone": {
"type": "string",
"enum": [
"oversold",
"neutral",
"overbought"
]
},
"trendAtr": {
"type": [
"number",
"null"
]
},
"trend": {
"type": [
"string",
"null"
]
},
"fundingRate": {
"type": [
"number",
"null"
]
}
},
"required": [
"rsi",
"atrPct",
"rangePos",
"rsiZone",
"trendAtr",
"trend",
"fundingRate"
],
"additionalProperties": true
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"horizon": {
"type": "number"
},
"returnPct": {
"type": "number"
},
"maePct": {
"type": "number"
},
"mfePct": {
"type": "number"
}
},
"required": [
"horizon",
"returnPct",
"maePct",
"mfePct"
],
"additionalProperties": true
}
},
"path": {
"type": "array",
"items": {
"type": "number"
}
},
"forward": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": [
"rank",
"startTime",
"endTime",
"similarity",
"close",
"features",
"outcomes",
"path",
"forward"
],
"additionalProperties": true
}
},
"stats": {
"type": "array",
"items": {
"type": "object",
"properties": {
"horizon": {
"type": "number"
},
"sample": {
"type": "number"
},
"medianPct": {
"type": "number"
},
"p25Pct": {
"type": "number"
},
"p75Pct": {
"type": "number"
},
"meanPct": {
"type": "number"
},
"upPct": {
"type": "number"
},
"worstReturnPct": {
"type": "number"
},
"bestReturnPct": {
"type": "number"
},
"worstDrawdownPct": {
"type": "number"
},
"bestRunupPct": {
"type": "number"
}
},
"required": [
"horizon",
"sample",
"medianPct",
"p25Pct",
"p75Pct",
"meanPct",
"upPct",
"worstReturnPct",
"bestReturnPct",
"worstDrawdownPct",
"bestRunupPct"
],
"additionalProperties": true
}
},
"coverage": {
"type": "object",
"properties": {
"bars": {
"type": "number"
},
"firstTime": {
"type": "number"
},
"lastTime": {
"type": "number"
},
"candidates": {
"type": "number"
},
"eligible": {
"type": "number"
}
},
"required": [
"bars",
"firstTime",
"lastTime",
"candidates",
"eligible"
],
"additionalProperties": true
},
"fundingUsed": {
"type": "boolean"
},
"fundingCoverage": {
"type": "number"
},
"unavailable": {
"type": [
"string",
"null"
],
"enum": [
"insufficient_history",
"flat_window",
"no_candidates",
null
]
},
"note": {
"type": "string"
},
"metadata": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"origin": {
"type": "string",
"enum": [
"caller",
"server"
]
},
"observedAt": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"computedAt": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"dataAsOf": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"lastClosedBar": {
"type": [
"number",
"null"
],
"description": "Bar OPEN time in UTC Unix seconds."
},
"barPolicy": {
"type": "string",
"enum": [
"closed",
"caller-supplied"
]
},
"market": {
"type": [
"string",
"null"
]
},
"requestedSymbol": {
"type": [
"string",
"null"
]
},
"resolvedInstrument": {
"type": "null"
},
"venue": {
"type": "null"
},
"currency": {
"type": "null"
},
"units": {
"type": "object",
"properties": {
"time": {
"type": "string",
"enum": [
"unix_seconds"
]
},
"prices": {
"type": "string"
},
"volume": {
"type": "string"
}
},
"required": [
"time",
"prices",
"volume"
],
"additionalProperties": true
},
"volume": {
"type": "object",
"properties": {
"missingBars": {
"type": "number"
},
"zeroBars": {
"type": "number"
}
},
"required": [
"missingBars",
"zeroBars"
],
"additionalProperties": true
},
"gaps": {
"type": "object",
"properties": {
"assessed": {
"type": "boolean"
},
"missingIntervals": {
"type": [
"number",
"null"
]
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"properties": {
"after": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"before": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"missing": {
"type": "number"
}
},
"required": [
"after",
"before",
"missing"
],
"additionalProperties": true
}
},
"truncated": {
"type": "boolean"
}
},
"required": [
"assessed",
"missingIntervals",
"ranges",
"truncated"
],
"additionalProperties": true
},
"stale": {
"type": "null"
},
"delaySeconds": {
"type": [
"number",
"null"
]
}
},
"required": [
"version",
"origin",
"observedAt",
"computedAt",
"dataAsOf",
"lastClosedBar",
"barPolicy",
"market",
"requestedSymbol",
"resolvedInstrument",
"venue",
"currency",
"units",
"volume",
"gaps",
"stale",
"delaySeconds"
],
"additionalProperties": true,
"description": "Unknown instrument, venue, currency and stale status remain null until the adapter supplies verified evidence. observedAt is API observation time, not a provider publication timestamp."
}
},
"required": [
"methodVersion",
"intervalSec",
"window",
"horizons",
"query",
"matches",
"stats",
"coverage",
"fundingUsed",
"fundingCoverage",
"unavailable",
"note"
],
"additionalProperties": true,
"description": "Similarity is a distance score, not a probability. Inspect unavailable even on HTTP 200."
}{
"type": "object",
"properties": {
"candles": {
"type": "array",
"items": {
"type": "object",
"description": "One OHLCV bar. time = bar OPEN time in UTC seconds (or milliseconds; auto-detected). Ascending, unique.",
"properties": {
"time": {
"type": "number"
},
"open": {
"type": "number"
},
"high": {
"type": "number"
},
"low": {
"type": "number"
},
"close": {
"type": "number"
},
"volume": {
"type": "number",
"description": "Optional. Required by volume studies."
}
},
"required": [
"time",
"open",
"high",
"low",
"close"
]
},
"minItems": 2,
"maxItems": 20000
},
"strategy": {
"type": "object",
"description": "Same strategy object as the TraderAI backtester: initialCapital, indicators, entryConditions, exitCondition, positionSizing, tradingCost.",
"additionalProperties": true
}
},
"required": [
"candles",
"strategy"
]
}{
"type": "object",
"properties": {
"result": {
"type": "object",
"properties": {
"metrics": {
"type": "object",
"properties": {
"totalTrades": {
"type": "number"
},
"winningTrades": {
"type": "number"
},
"losingTrades": {
"type": "number"
},
"winRate": {
"type": "number"
},
"totalPnlPct": {
"type": "number"
},
"totalPnlAbs": {
"type": "number"
},
"profitFactor": {
"type": "number"
},
"maxDrawdownPct": {
"type": "number"
},
"sharpeRatio": {
"type": "number"
},
"sortino": {
"type": "number"
},
"avgWinPct": {
"type": "number"
},
"avgLossPct": {
"type": "number"
},
"avgRR": {
"type": "number"
},
"expectancy": {
"type": "number"
},
"initialCapital": {
"type": "number"
},
"finalCapital": {
"type": "number"
},
"equity": {
"type": "array",
"items": {
"type": "object",
"properties": {
"time": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"equity": {
"type": "number"
}
},
"required": [
"time",
"equity"
],
"additionalProperties": true
}
},
"monthlyPnl": {
"type": "array",
"items": {
"type": "object",
"properties": {
"month": {
"type": "string"
},
"pnl": {
"type": "number"
}
},
"required": [
"month",
"pnl"
],
"additionalProperties": true
}
},
"costs": {
"type": "object",
"properties": {
"commission": {
"type": "number"
},
"slippage": {
"type": "number"
},
"funding": {
"type": "number"
},
"total": {
"type": "number"
},
"totalPctOfCapital": {
"type": "number"
},
"grossPnlAbs": {
"type": "number"
}
},
"required": [
"commission",
"slippage",
"funding",
"total",
"totalPctOfCapital",
"grossPnlAbs"
],
"additionalProperties": true
},
"costConfig": {
"type": "object",
"properties": {
"commissionPct": {
"type": "number"
},
"slippagePct": {
"type": "number"
},
"fundingRatePct": {
"type": "number"
},
"fundingIntervalHours": {
"type": "number"
}
},
"required": [
"commissionPct",
"slippagePct",
"fundingRatePct",
"fundingIntervalHours"
],
"additionalProperties": true
},
"skippedEntries": {
"type": "number"
},
"coverage": {
"type": "object",
"properties": {
"continuousClosedBars": {
"type": "boolean"
},
"barsAnalyzed": {
"type": "number"
},
"barsRequested": {
"type": "number"
},
"truncated": {
"type": "boolean"
},
"actualDateFrom": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"actualDateTo": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
}
},
"required": [
"barsAnalyzed",
"barsRequested",
"truncated",
"actualDateFrom",
"actualDateTo"
],
"additionalProperties": true
}
},
"required": [
"totalTrades",
"winningTrades",
"losingTrades",
"winRate",
"totalPnlPct",
"totalPnlAbs",
"profitFactor",
"maxDrawdownPct",
"sharpeRatio",
"sortino",
"avgWinPct",
"avgLossPct",
"avgRR",
"expectancy",
"initialCapital",
"finalCapital",
"equity",
"monthlyPnl"
],
"additionalProperties": true,
"description": "Calculated engine metrics in account currency/percent. Profit factor 999 is the existing no-loss sentinel, not an observed finite return. Optional cost/coverage blocks absent means unavailable, not zero."
},
"trades": {
"type": "array",
"items": {
"type": "object",
"properties": {
"entryTime": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"exitTime": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"direction": {
"type": "string",
"enum": [
"long",
"short"
]
},
"entryPrice": {
"type": "number"
},
"exitPrice": {
"type": "number"
},
"pnlPct": {
"type": "number"
},
"pnlAbs": {
"type": "number"
},
"rr": {
"type": "number"
},
"grossPnlAbs": {
"type": "number"
},
"exitReason": {
"type": "string",
"enum": [
"tp",
"sl",
"trailing",
"max_bars",
"eod",
"rule"
]
},
"costs": {
"type": "object",
"additionalProperties": true,
"description": "Commission, slippage and funding breakdown in account currency."
}
},
"required": [
"entryTime",
"exitTime",
"direction",
"entryPrice",
"exitPrice",
"pnlPct",
"pnlAbs",
"rr",
"exitReason"
],
"additionalProperties": true
}
},
"ruleEvidence": {
"type": "object",
"additionalProperties": true,
"description": "Versioned condition-tree evidence, present only when a rule was evaluated. This extension remains JSON for compatibility."
}
},
"required": [
"metrics",
"trades"
],
"additionalProperties": true
},
"bars": {
"type": "integer"
},
"costModel": {
"type": "object",
"properties": {
"commissionPct": {
"type": "number"
},
"slippagePct": {
"type": "number"
},
"fundingRatePct": {
"type": "number"
},
"fundingIntervalHours": {
"type": "number"
}
},
"required": [
"commissionPct",
"slippagePct",
"fundingRatePct",
"fundingIntervalHours"
],
"additionalProperties": true
},
"metadata": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"origin": {
"type": "string",
"enum": [
"caller",
"server"
]
},
"observedAt": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"computedAt": {
"type": "string",
"description": "UTC ISO 8601 timestamp."
},
"dataAsOf": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 timestamp."
},
"lastClosedBar": {
"type": [
"number",
"null"
],
"description": "Bar OPEN time in UTC Unix seconds."
},
"barPolicy": {
"type": "string",
"enum": [
"closed",
"caller-supplied"
]
},
"market": {
"type": [
"string",
"null"
]
},
"requestedSymbol": {
"type": [
"string",
"null"
]
},
"resolvedInstrument": {
"type": "null"
},
"venue": {
"type": "null"
},
"currency": {
"type": "null"
},
"units": {
"type": "object",
"properties": {
"time": {
"type": "string",
"enum": [
"unix_seconds"
]
},
"prices": {
"type": "string"
},
"volume": {
"type": "string"
}
},
"required": [
"time",
"prices",
"volume"
],
"additionalProperties": true
},
"volume": {
"type": "object",
"properties": {
"missingBars": {
"type": "number"
},
"zeroBars": {
"type": "number"
}
},
"required": [
"missingBars",
"zeroBars"
],
"additionalProperties": true
},
"gaps": {
"type": "object",
"properties": {
"assessed": {
"type": "boolean"
},
"missingIntervals": {
"type": [
"number",
"null"
]
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"properties": {
"after": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"before": {
"type": "number",
"description": "Bar OPEN time in UTC Unix seconds."
},
"missing": {
"type": "number"
}
},
"required": [
"after",
"before",
"missing"
],
"additionalProperties": true
}
},
"truncated": {
"type": "boolean"
}
},
"required": [
"assessed",
"missingIntervals",
"ranges",
"truncated"
],
"additionalProperties": true
},
"stale": {
"type": "null"
},
"delaySeconds": {
"type": [
"number",
"null"
]
}
},
"required": [
"version",
"origin",
"observedAt",
"computedAt",
"dataAsOf",
"lastClosedBar",
"barPolicy",
"market",
"requestedSymbol",
"resolvedInstrument",
"venue",
"currency",
"units",
"volume",
"gaps",
"stale",
"delaySeconds"
],
"additionalProperties": true,
"description": "Unknown instrument, venue, currency and stale status remain null until the adapter supplies verified evidence. observedAt is API observation time, not a provider publication timestamp."
}
},
"required": [
"result",
"bars",
"costModel"
],
"additionalProperties": true
}{
"type": "object",
"properties": {
"image": {
"type": "string",
"description": "Base64 PNG/JPEG/WebP (data URL or raw base64), max 4 MB."
},
"market": {
"type": "string",
"enum": [
"crypto",
"forex",
"stocks"
],
"default": "crypto"
},
"timeframe": {
"type": "string",
"maxLength": 8
},
"locale": {
"type": "string",
"maxLength": 5,
"default": "en"
}
},
"required": [
"image"
]
}{
"type": "object",
"properties": {
"analysis": {
"type": "object",
"properties": {
"patterns": {
"type": "array",
"items": {
"type": "string"
}
},
"trend": {
"type": "string"
},
"summary": {
"type": "string"
},
"critique": {
"type": "string"
},
"confidence": {
"type": "string"
},
"marketBias": {
"type": "string"
},
"recommendation": {
"type": "string"
},
"reasoning": {
"type": "string"
},
"ticker": {
"type": "string"
},
"volumeAnalysis": {
"type": "string"
},
"macroContext": {
"type": "string"
},
"cautionNote": {
"type": "string"
},
"direction": {
"type": "string",
"enum": [
"long",
"short",
"none"
]
},
"entry": {
"type": "number"
},
"stopLoss": {
"type": "number"
},
"takeProfit": {
"type": "number"
},
"riskReward": {
"type": "number"
},
"keyLevels": {
"type": "array",
"items": {
"type": "string"
}
},
"tradePlan": {
"type": "object",
"properties": {
"entryCondition": {
"type": "string"
},
"slReason": {
"type": "string"
},
"tp1Note": {
"type": "string"
},
"tp1Size": {
"type": "string"
},
"tp2Note": {
"type": "string"
},
"tp2Size": {
"type": "string"
},
"breakeven": {
"type": "string"
},
"invalidation": {
"type": "string"
},
"takeProfit1": {
"type": "number"
},
"takeProfit2": {
"type": "number"
}
},
"required": [
"entryCondition",
"slReason",
"tp1Note",
"tp1Size",
"tp2Note",
"tp2Size",
"breakeven",
"invalidation",
"takeProfit1",
"takeProfit2"
],
"additionalProperties": true
},
"pricePlan": {
"type": "object",
"additionalProperties": true,
"description": "Canonical validated price plan, when available; legacy scalar prices remain aliases."
},
"setupScore": {
"type": "object",
"additionalProperties": true,
"description": "Technical quality grade. Not a probability of profit."
},
"leverageAnalysis": {
"type": "object",
"properties": {
"leverageVerdict": {
"type": "string"
},
"suggestedLeverage": {
"type": "string"
},
"liquidationRisk": {
"type": "string"
},
"costNote": {
"type": "string"
},
"advice": {
"type": "string"
}
},
"required": [
"leverageVerdict",
"suggestedLeverage",
"liquidationRisk",
"costNote",
"advice"
],
"additionalProperties": true
},
"advisories": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true,
"description": "Deterministic advisory code and supporting numeric evidence."
}
},
"textEncodingIssue": {
"type": "boolean"
}
},
"required": [
"patterns",
"trend",
"direction",
"entry",
"stopLoss",
"takeProfit",
"riskReward",
"summary",
"critique",
"confidence"
],
"additionalProperties": true
},
"note": {
"type": "string"
}
},
"required": [
"analysis",
"note"
],
"additionalProperties": true,
"description": "AI analysis may have direction=none or a cautionNote; neither constitutes an execution recommendation."
}{
"type": "object",
"properties": {}
}{
"type": "object",
"properties": {
"patterns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"market": {
"type": "string"
},
"patternId": {
"type": "string"
},
"bias": {
"type": "string"
},
"firstDate": {
"type": "string"
},
"lastDate": {
"type": "string"
},
"total": {
"type": "number"
},
"wins": {
"type": "number"
},
"winRatePct": {
"type": "number"
},
"avgEdgePct": {
"type": "number"
},
"baselinePct": {
"type": "number"
},
"edgeVsBaselinePct": {
"type": "number"
}
},
"required": [
"market",
"patternId",
"bias",
"firstDate",
"lastDate",
"total",
"wins",
"winRatePct",
"avgEdgePct",
"baselinePct",
"edgeVsBaselinePct"
],
"additionalProperties": true
},
"description": "Empty until recorded observations exist. Percent fields use 0..100."
},
"evidence": {
"type": "object",
"additionalProperties": false,
"required": [
"version",
"computedAt",
"source",
"status",
"modelVersion",
"promptVersion",
"cohorts",
"limitations"
],
"properties": {
"version": {
"type": "string"
},
"computedAt": {
"type": "string"
},
"source": {
"type": "string",
"enum": [
"recorded_pattern_outcomes",
"recorded_volatility_forecasts"
]
},
"status": {
"type": "string",
"enum": [
"available",
"empty",
"incomplete"
]
},
"modelVersion": {
"type": "null"
},
"promptVersion": {
"type": "null"
},
"cohorts": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"market",
"key",
"bias",
"sampleSize",
"period",
"baseline",
"outcomes"
],
"properties": {
"market": {
"type": "string"
},
"key": {
"type": "string"
},
"bias": {
"type": [
"string",
"null"
]
},
"sampleSize": {
"type": [
"integer",
"null"
],
"minimum": 0
},
"period": {
"type": [
"object",
"null"
],
"required": [
"firstDate",
"lastDate",
"dateBasis"
],
"properties": {
"firstDate": {
"type": "string"
},
"lastDate": {
"type": "string"
},
"dateBasis": {
"type": "string",
"enum": [
"pattern_entry_date_utc",
"forecast_date_utc"
]
}
},
"additionalProperties": false
},
"baseline": {
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"valuePct",
"sampleSize",
"period",
"uncertainty"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"resolved_pattern_occurrence_pool_bias_adjusted",
"nominal_model_coverage"
]
},
"valuePct": {
"type": [
"number",
"null"
]
},
"sampleSize": {
"type": "null"
},
"period": {
"type": "null"
},
"uncertainty": {
"type": "null"
}
}
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"metric",
"successes",
"ratePct",
"nominalCoveragePct",
"uncertainty"
],
"properties": {
"metric": {
"type": "string",
"enum": [
"directional_win",
"within_68_band",
"within_95_band"
]
},
"successes": {
"type": [
"integer",
"null"
],
"minimum": 0
},
"ratePct": {
"type": [
"number",
"null"
]
},
"nominalCoveragePct": {
"type": [
"number",
"null"
]
},
"uncertainty": {
"type": [
"object",
"null"
],
"required": [
"method",
"confidenceLevel",
"lowerPct",
"upperPct",
"interpretation"
],
"properties": {
"method": {
"type": "string",
"enum": [
"wilson_score"
]
},
"confidenceLevel": {
"type": "number"
},
"lowerPct": {
"type": "number"
},
"upperPct": {
"type": "number"
},
"interpretation": {
"type": "string",
"enum": [
"descriptive_binomial_interval_not_independence_adjusted"
]
}
},
"additionalProperties": false
}
}
}
}
}
}
},
"limitations": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"required": [
"patterns"
],
"additionalProperties": true
}{
"type": "object",
"properties": {}
}{
"type": "object",
"properties": {
"symbols": {
"type": "array",
"items": {
"type": "object",
"properties": {
"market": {
"type": "string"
},
"symbol": {
"type": "string"
},
"firstDate": {
"type": "string"
},
"lastDate": {
"type": "string"
},
"total": {
"type": "number"
},
"hit68": {
"type": "number"
},
"hit95": {
"type": "number"
},
"hit68Pct": {
"type": "number"
},
"hit95Pct": {
"type": "number"
},
"avgForecastPct": {
"type": "number"
},
"avgActualPct": {
"type": "number"
}
},
"required": [
"market",
"symbol",
"firstDate",
"lastDate",
"total",
"hit68",
"hit95",
"hit68Pct",
"hit95Pct",
"avgForecastPct",
"avgActualPct"
],
"additionalProperties": true
},
"description": "Recorded observations only. Empty does not imply perfect calibration."
},
"evidence": {
"type": "object",
"additionalProperties": false,
"required": [
"version",
"computedAt",
"source",
"status",
"modelVersion",
"promptVersion",
"cohorts",
"limitations"
],
"properties": {
"version": {
"type": "string"
},
"computedAt": {
"type": "string"
},
"source": {
"type": "string",
"enum": [
"recorded_pattern_outcomes",
"recorded_volatility_forecasts"
]
},
"status": {
"type": "string",
"enum": [
"available",
"empty",
"incomplete"
]
},
"modelVersion": {
"type": "null"
},
"promptVersion": {
"type": "null"
},
"cohorts": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"market",
"key",
"bias",
"sampleSize",
"period",
"baseline",
"outcomes"
],
"properties": {
"market": {
"type": "string"
},
"key": {
"type": "string"
},
"bias": {
"type": [
"string",
"null"
]
},
"sampleSize": {
"type": [
"integer",
"null"
],
"minimum": 0
},
"period": {
"type": [
"object",
"null"
],
"required": [
"firstDate",
"lastDate",
"dateBasis"
],
"properties": {
"firstDate": {
"type": "string"
},
"lastDate": {
"type": "string"
},
"dateBasis": {
"type": "string",
"enum": [
"pattern_entry_date_utc",
"forecast_date_utc"
]
}
},
"additionalProperties": false
},
"baseline": {
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"valuePct",
"sampleSize",
"period",
"uncertainty"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"resolved_pattern_occurrence_pool_bias_adjusted",
"nominal_model_coverage"
]
},
"valuePct": {
"type": [
"number",
"null"
]
},
"sampleSize": {
"type": "null"
},
"period": {
"type": "null"
},
"uncertainty": {
"type": "null"
}
}
},
"outcomes": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"metric",
"successes",
"ratePct",
"nominalCoveragePct",
"uncertainty"
],
"properties": {
"metric": {
"type": "string",
"enum": [
"directional_win",
"within_68_band",
"within_95_band"
]
},
"successes": {
"type": [
"integer",
"null"
],
"minimum": 0
},
"ratePct": {
"type": [
"number",
"null"
]
},
"nominalCoveragePct": {
"type": [
"number",
"null"
]
},
"uncertainty": {
"type": [
"object",
"null"
],
"required": [
"method",
"confidenceLevel",
"lowerPct",
"upperPct",
"interpretation"
],
"properties": {
"method": {
"type": "string",
"enum": [
"wilson_score"
]
},
"confidenceLevel": {
"type": "number"
},
"lowerPct": {
"type": "number"
},
"upperPct": {
"type": "number"
},
"interpretation": {
"type": "string",
"enum": [
"descriptive_binomial_interval_not_independence_adjusted"
]
}
},
"additionalProperties": false
}
}
}
}
}
}
},
"limitations": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"required": [
"symbols"
],
"additionalProperties": true
}Schema devapi-2026-11-14.1 bổ sung điều khiển operation, schema phản hồi và query GraphQL có kiểu. Các field data v1 hiện có tiếp tục khả dụng. Phiên bản công thức độc lập với schema API. Kiểm tra schema đã công bố trước khi cập nhật client sinh tự động.