Files
PolyHermes/frontend
WrBug 20df471683 feat: 回测任务添加最大仓位参数支持
参考跟单配置的实现,为回测任务添加最大仓位金额限制功能。

后端改动:
- 添加数据库迁移文件 V31__add_backtest_max_position_value.sql
- BacktestTask 实体添加 maxPositionValue 字段(BigDecimal?,NULL表示不启用)
- BacktestCreateRequest 添加 maxPositionValue 字段
- BacktestConfigDto 添加 maxPositionValue 字段
- BacktestService 处理 maxPositionValue 的创建、详情和复制
- BacktestExecutionService.taskToCopyTrading 映射 maxPositionValue 参数
- BacktestExecutionService.executeBacktest 在买入逻辑中添加仓位检查
  * 检查条件:当前仓位 + 买入金额 <= 最大仓位
  * 仓位价值计算:quantity * avgPrice
  * 超过限制时跳过该笔买入并记录详细日志
  * 按市场+方向(marketId + outcomeIndex)分别检查

前端改动:
- BacktestList 表单添加最大仓位金额输入框(可选字段)
- 创建回测任务时包含 maxPositionValue
- 回测任务详情中显示 maxPositionValue(仅在配置了时显示)
- 默认最大每日订单数从 50 改为 100
- 多语言翻译新增:
  * backtest.maxPositionValue: 最大仓位金额 / 最大倉位金額 / Max Position Value
  * maxPositionValuePlaceholder: 留空表示不启用最大仓位限制

功能特点:
- 可选参数:留空或为 null 时表示不启用该限制,保持向后兼容
- 单市场单方向限制:按 marketId 和 outcomeIndex 分别计算和限制
- 精确计算:使用 BigDecimal 进行数值比较
- 详细日志:超过限制时记录当前仓位、买入金额、总计等详细信息

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 02:25:24 +08:00
..
2025-12-07 16:15:59 +08:00
2025-12-07 16:15:59 +08:00
2026-01-31 07:27:36 +08:00
2026-01-31 07:27:36 +08:00

Polymarket 跟单系统前端

技术栈

  • 框架: React 18 + TypeScript
  • 构建工具: Vite
  • UI 库: Ant Design + Ant Design Mobile
  • HTTP 客户端: axios
  • 状态管理: Zustand
  • 路由: React Router
  • 以太坊库: ethers.js

功能特性

  • 账户管理(通过私钥导入,支持多账户)
  • Leader 管理(被跟单者管理)
  • 跟单配置管理
  • 订单管理
  • 统计信息
  • 移动端适配

开发

# 安装依赖
npm install

# 启动开发服务器
npm run dev

# 构建生产版本
npm run build

项目结构

frontend/
├── src/
│   ├── components/      # 公共组件
│   │   └── Layout.tsx   # 布局组件(支持移动端)
│   ├── pages/           # 页面组件
│   │   ├── AccountList.tsx
│   │   ├── AccountImport.tsx
│   │   ├── LeaderList.tsx
│   │   ├── LeaderAdd.tsx
│   │   ├── ConfigPage.tsx
│   │   ├── OrderList.tsx
│   │   └── Statistics.tsx
│   ├── services/        # API 服务
│   │   └── api.ts
│   ├── store/           # 状态管理
│   │   └── accountStore.ts
│   ├── types/           # TypeScript 类型定义
│   │   └── index.ts
│   ├── utils/           # 工具函数
│   │   └── ethers.ts
│   ├── styles/          # 样式文件
│   │   └── index.css
│   ├── App.tsx          # 根组件
│   └── main.tsx         # 入口文件
├── index.html
├── package.json
├── tsconfig.json
└── vite.config.ts

移动端适配

  • 使用 react-responsive 检测设备类型
  • 移动端使用 Ant Design Mobile 组件
  • 响应式布局(移动端 < 768px,桌面端 >= 768px
  • 触摸友好的按钮尺寸(>= 44x44px