新的策略引擎基于信号触发机制,支持多种触发器和策略类型,提供高度可定制化的交易系统。
{
"id": "strategy-1", // 策略唯一标识
"name": "BTC 等量对刷策略", // 策略名称
"enabled": true, // 是否启用
"type": "EQUAL_VOLUME", // 策略类型
"symbol": "BTC-PERP", // 交易对
"accounts": ["account-1", "account-2"], // 参与账户
"parameters": { ... }, // 策略参数
"triggers": [ ... ], // 触发器配置
"risk": { ... } // 风险控制
}
{
"type": "EQUAL_VOLUME",
"parameters": {
"orderSize": 0.01, // 每笔订单大小
"priceSpread": 0.0001, // 价格价差
"interval": 5000, // 交易间隔(毫秒)
"maxVolume": 1.0 // 最大交易量
}
}
{
"type": "MARKET_MAKING",
"parameters": {
"bidSpread": 0.0005, // 买价价差
"askSpread": 0.0005, // 卖价价差
"orderSize": 0.005, // 订单大小
"refreshInterval": 10000, // 刷新间隔
"maxOrders": 5 // 最大订单数
}
}
{
"type": "TREND_FOLLOWING",
"parameters": {
"maPeriod": 20, // 移动平均周期
"orderSize": 0.02, // 订单大小
"priceSpread": 0.0002, // 价格价差
"trendThreshold": 0.001 // 趋势阈值
}
}
{
"type": "time",
"schedule": "0 9 * * *", // cron表达式
"enabled": true
}
{
"type": "price_change",
"threshold": 0.02, // 价格变化阈值(2%)
"enabled": true
}
{
"type": "volume_spike",
"threshold": 1.5, // 交易量倍数阈值
"enabled": true
}
{
"type": "volatility",
"threshold": 0.01, // 波动率阈值
"enabled": true
}
{
"type": "technical_signal",
"indicator": "MA_CROSSOVER", // 技术指标
"enabled": true
}
{
"type": "momentum",
"threshold": 0.005, // 动量阈值
"enabled": true
}
{
"risk": {
"maxPosition": 0.1, // 最大持仓(BTC)
"stopLoss": 0.05, // 止损阈值
"maxDailyVolume": 10.0 // 最大日交易量
}
}
{
"id": "strategy-1",
"name": "BTC 等量对刷策略",
"enabled": true,
"type": "EQUAL_VOLUME",
"symbol": "BTC-PERP",
"accounts": ["account-1", "account-2"],
"parameters": {
"orderSize": 0.01,
"priceSpread": 0.0001,
"interval": 5000,
"maxVolume": 1.0
},
"triggers": [
{
"type": "time",
"schedule": "0 9 * * *",
"enabled": true
}
],
"risk": {
"maxPosition": 0.1,
"stopLoss": 0.05,
"maxDailyVolume": 10.0
}
}
{
"id": "strategy-2",
"name": "BTC 智能交易策略",
"enabled": true,
"type": "MARKET_MAKING",
"symbol": "BTC-PERP",
"accounts": ["account-1", "account-2"],
"parameters": {
"bidSpread": 0.0005,
"askSpread": 0.0005,
"orderSize": 0.005,
"refreshInterval": 10000,
"maxOrders": 5
},
"triggers": [
{
"type": "time",
"schedule": "0 */2 * * *",
"enabled": true
},
{
"type": "volatility",
"threshold": 0.01,
"enabled": true
},
{
"type": "volume_spike",
"threshold": 1.5,
"enabled": true
}
],
"risk": {
"maxPosition": 0.05,
"stopLoss": 0.03,
"maxDailyVolume": 5.0
}
}
您可以通过以下方式扩展策略:
StrategyEngine.ts
中添加新的策略类系统提供完整的策略监控:
通过策略引擎,您可以实现真正智能化的交易系统!