|
4 days ago | |
---|---|---|
.cursor | 4 days ago | |
.specify | 4 days ago | |
config | 4 days ago | |
docs | 4 days ago | |
examples | 4 days ago | |
scripts | 4 days ago | |
specs | 4 days ago | |
src | 4 days ago | |
tests | 4 days ago | |
.eslintrc.js | 4 days ago | |
.gitignore | 4 days ago | |
.prettierignore | 4 days ago | |
.prettierrc | 4 days ago | |
PACIFICA_API_INTEGRATION_REPORT.md | 4 days ago | |
PROJECT_COMPLETION_REPORT.md | 4 days ago | |
README.md | 4 days ago | |
ecosystem.config.js | 4 days ago | |
env.example | 4 days ago | |
jest.config.js | 4 days ago | |
package-lock.json | 4 days ago | |
package.json | 4 days ago | |
test-config.js | 4 days ago | |
tsconfig.json | 4 days ago |
一个纯后台运行的 Pacifica 多账户 BTC 对冲刷量交易系统,通过配置文件控制所有功能,无需 API 交互。
┌─────────────────────────────────────────────────────────────┐
│ Pacifica 后台交易系统 │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ 守护进程 │ │ 后台系统 │ │ 任务调度器 │ │
│ │ Daemon │ │ BackendSystem│ │TaskScheduler│ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ 监控系统 │ │ 配置管理 │ │ 账户管理 │ │
│ │ Monitoring │ │ Config │ │ Account │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ 订单协调 │ │ 风险管理 │ │ 审计日志 │ │
│ │ Order │ │ Risk │ │ Audit │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
npm install
config/system-config.json
){
"system": {
"name": "Pacifica Wash Trading System",
"version": "1.0.0",
"environment": "development",
"logLevel": "info",
"maxConcurrentSessions": 5,
"sessionTimeout": 3600000,
"healthCheckInterval": 30000
},
"trading": {
"defaultSymbol": "BTC-PERP",
"maxOrderSize": 1.0,
"minOrderSize": 0.001,
"maxSlippage": 0.01,
"orderTimeout": 30000,
"retryAttempts": 3
},
"risk": {
"maxTotalVolume": 100.0,
"maxNetExposure": 0.1,
"maxDailyLoss": 1000.0,
"positionLimit": 10.0,
"stopLossThreshold": 0.05
},
"automation": {
"enabled": true,
"autoStartSessions": true,
"autoStopOnRisk": true,
"scheduleConfig": "0 */6 * * *",
"maxRunningSessions": 3
}
}
config/auto-sessions.json
){
"autoSessions": [
{
"id": "auto-session-1",
"name": "BTC 等量交易会话",
"enabled": true,
"strategy": {
"type": "EQUAL_VOLUME",
"symbol": "BTC-PERP",
"parameters": {
"volumePerOrder": 0.01,
"priceSpread": 0.0001,
"interval": 5000
}
},
"accounts": ["account-1", "account-2"],
"targetVolume": 1.0,
"duration": 3600000,
"schedule": {
"enabled": true,
"cron": "0 9 * * *",
"timezone": "Asia/Shanghai"
}
}
]
}
config/accounts.json
)[
{
"id": "account-1",
"name": "主账户",
"apiKey": "encrypted_api_key",
"privateKey": "encrypted_private_key",
"address": "0x...",
"balance": {
"total": 10000,
"available": 10000,
"used": 0
},
"riskLimits": {
"maxPosition": 1.0,
"dailyVolume": 100.0,
"maxLoss": 500.0
},
"isActive": true
}
]
npm run dev
# 构建项目
npm run build
# 启动守护进程
npm start
# 使用 nohup 后台运行
nohup npm start > logs/daemon.log 2>&1 &
# 或使用 PM2
pm2 start dist/daemon.js --name pacifica-daemon
# 查看进程状态
npm run status
# 查看日志
tail -f logs/daemon.log
# 优雅停止
npm run stop
# 或发送信号
kill -TERM <pid>
npm run restart
# 发送 SIGHUP 信号重新加载配置
kill -HUP <pid>
# 发送 SIGUSR1 信号生成状态报告
kill -USR1 <pid>
# 发送 SIGUSR2 信号重启服务
kill -USR2 <pid>
logs/daemon.log
- 守护进程日志logs/system.log
- 系统日志logs/monitoring-report-*.json
- 监控报告logs/status-report-*.json
- 状态报告# 每天上午9点启动
0 9 * * *
# 每6小时启动一次
0 */6 * * *
# 每分钟检查一次
*/1 * * * *
pacifica-wash-trading-system/
├── src/
│ ├── core/ # 核心系统
│ │ ├── BackendSystem.ts # 后台系统
│ │ ├── ConfigManager.ts # 配置管理
│ │ ├── TaskScheduler.ts # 任务调度
│ │ └── MonitoringSystem.ts # 监控系统
│ ├── services/ # 服务层
│ ├── models/ # 数据模型
│ ├── strategies/ # 交易策略
│ ├── utils/ # 工具类
│ └── daemon.ts # 守护进程入口
├── config/ # 配置文件
├── logs/ # 日志文件
├── tests/ # 测试文件
└── package.json
进程无法启动
任务不执行
内存使用过高
# 启用调试日志
export LOG_LEVEL=debug
npm run dev
如有问题或建议,请:
MIT License - 详见 LICENSE 文件
注意: 本系统仅用于学习和研究目的,请遵守相关法律法规和交易所规则。