You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

trade-pairing spec

ADDED Requirements

Requirement: 自动交易配对

系统 SHALL 在用户选择日期后,自动按品种+方向+时间段配对开平仓记录。

Scenario: 自动配对成功

  • WHEN 用户选择某个交易日
  • AND 系统检测到该日期有交易记录
  • THEN 系统执行自动配对逻辑
  • AND 生成 pair_type='auto' 的 TradePair 记录
  • AND 展示配对结果给前端

Requirement: FIFO 配对规则

系统 SHALL 按时间顺序FIFO将开仓记录与平仓记录配对。同一品种同一方向的连续开仓合并为一个头寸。

Scenario: 多次开仓配对

  • WHEN 某品种有 2 笔开仓和 3 笔平仓
  • THEN 系统将 2 笔开仓合并为一个头寸
  • AND 按时间顺序匹配 3 笔平仓

Requirement: 手动配对修正

系统 SHALL 允许用户手动创建、修改、删除配对关系。

Scenario: 用户手动修正配对

  • WHEN 用户对自动配对结果不满意
  • AND 用户选择开仓记录和平仓记录
  • AND 用户点击「手动配对」
  • THEN 系统创建 pair_type='manual' 的 TradePair 记录
  • AND 移除相关的 auto 配对记录

Requirement: 未配对交易展示

系统 SHALL 将无法配对的单边交易单独展示,并提供手动配对入口。