Định Dạng Chiến Lược AI
Dùng bất kỳ AI assistant nào để tạo pipeline JSON hợp lệ và import trực tiếp vào Strategy Builder.
Tệp này đã tối ưu để dùng với AI. Hãy dán file .md bạn tải xuống vào cuộc trò chuyện với AI để làm context.
Cách Hoạt Động
Bước 1: Lấy Schema
- Nhấn Tải Schema để lưu toàn bộ danh mục node và quy tắc lint dưới dạng file `.md`. [icon:download]
Bước 2: Dán vào AI
- Mở AI assistant của bạn (ChatGPT, Claude, Gemini) và dán file schema làm context. [icon:clipboard]
Bước 3: Mô Tả Chiến Lược
- Nói với AI chiến lược bạn muốn giao dịch. AI sẽ tạo pipeline JSON hợp lệ dựa trên schema. [icon:message-circle]
Bước 4: Import vào Strategy Builder
- Sao chép JSON, mở Strategy Builder, nhấn Import và dán vào. Validation chạy tự động. [icon:upload]
Tải Schema
Cấu Trúc Pipeline JSON
Một pipeline là đối tượng JSON có dạng như sau:
interface Pipeline {
id: string; // UUID
userId: string; // UUID
name: string; // Tên chiến lược
description: string; // Mô tả chiến lược
nodes: Node[]; // Mảng các node pipeline
connections: Connection[]; // Mảng các kết nối port
parameters: Record<string, unknown>; // Tham số toàn cục
version: string; // Phiên bản schema
status: "draft"; // Luôn là "draft" khi import
createdAt: string; // Dấu thời gian ISO 8601
updatedAt: string; // Dấu thời gian ISO 8601
}Mỗi node có:
interface Node {
id: string; // ID node duy nhất (UUID)
type: string; // Loại node từ danh mục (ví dụ: "rsi", "sma_crossover")
position: { x: number; y: number }; // Vị trí trên canvas
parameters: Record<string, unknown>; // Tham số riêng của node
inputs: Port[]; // Các port đầu vào
outputs: Port[]; // Các port đầu ra
}
interface Port {
id: string;
name: string;
dataType: string; // OHLCV, TIMESERIES, SIGNAL, ORDER, v.v.
required: boolean;
}Mỗi kết nối liên kết một port đầu ra với một port đầu vào:
interface Connection {
id: string; // ID kết nối duy nhất (UUID)
source: { nodeId: string; portId: string };
target: { nodeId: string; portId: string };
}Ví Dụ: Chiến Lược RSI Crossover
Chiến lược đơn giản mua khi RSI vượt lên trên 30 và bán khi RSI vượt xuống dưới 70:
{
"id": "example-rsi-crossover",
"userId": "your-user-id",
"name": "RSI Crossover Strategy",
"description": "Buy when RSI crosses above 30, sell when RSI crosses below 70",
"nodes": [
{
"id": "node-1",
"type": "ohlcv_data",
"position": { "x": 100, "y": 200 },
"parameters": { "exchange": "binance", "symbol": "BTC/USDT", "timeframe": "1h" },
"inputs": [],
"outputs": [
{ "id": "ohlcv", "name": "OHLCV", "dataType": "OHLCV" }
]
},
{
"id": "node-2",
"type": "rsi",
"position": { "x": 400, "y": 200 },
"parameters": { "period": 14 },
"inputs": [
{ "id": "ohlcv", "name": "OHLCV", "dataType": "OHLCV", "required": true }
],
"outputs": [
{ "id": "rsi", "name": "RSI", "dataType": "NUMBER" }
]
},
{
"id": "node-3",
"type": "threshold_signal",
"position": { "x": 700, "y": 100 },
"parameters": { "upperThreshold": 70, "lowerThreshold": 30 },
"inputs": [
{ "id": "input", "name": "Input", "dataType": "NUMBER", "required": true }
],
"outputs": [
{ "id": "signal", "name": "Signal", "dataType": "SIGNAL" }
]
},
{
"id": "node-4",
"type": "signal_to_order",
"position": { "x": 1000, "y": 100 },
"parameters": { "orderType": "market", "quantity": 0.01 },
"inputs": [
{ "id": "signal", "name": "Signal", "dataType": "SIGNAL", "required": true }
],
"outputs": [
{ "id": "order", "name": "Order", "dataType": "ORDER" }
]
}
],
"connections": [
{
"id": "conn-1",
"source": { "nodeId": "node-1", "portId": "ohlcv" },
"target": { "nodeId": "node-2", "portId": "ohlcv" }
},
{
"id": "conn-2",
"source": { "nodeId": "node-2", "portId": "rsi" },
"target": { "nodeId": "node-3", "portId": "input" }
},
{
"id": "conn-3",
"source": { "nodeId": "node-3", "portId": "signal" },
"target": { "nodeId": "node-4", "portId": "signal" }
}
],
"parameters": {},
"version": 1,
"status": "draft",
"createdAt": "2026-01-01T00:00:00.000Z",
"updatedAt": "2026-01-01T00:00:00.000Z"
}Mẹo Tạo Chiến Lược Với AI
Mẹo khi prompt AI
Giữ pipeline ở trạng thái nháp
- Luôn đặt `status` là `"draft"` để chiến lược được mở an toàn trong Strategy Builder. icon:shield-check
Dùng đúng loại node
- Chỉ dùng các node type có trong schema vì hệ thống sẽ kiểm tra loại node ngay khi import. icon:box
Kết nối đủ các cổng bắt buộc
- Mọi input port có `required: true` đều phải được nối trước khi import. icon:clipboard
Khớp đúng kiểu dữ liệu
- Chỉ nối các port có data type tương thích, ví dụ `OHLCV` sang `OHLCV`. icon:code
Đưa AI toàn bộ schema
- Tải tài liệu schema đầy đủ để AI thấy danh mục node, tham số và phạm vi hợp lệ. icon:download