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.
buffer_platform/openspec/archive/trade-import-behavior-fix/design.md

1.6 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.

Context

当前 trade_parser.pysave_to_db 中对本次导入的数据做了文件内和跨文件去重,且会根据交易时间重新计算 trade_date21:00 之后归属下一交易日)。

业务要求:

  • 同一委托拆单成交的数据应全部导入,不应去重。
  • 导入时保留结算单原始日期。
  • 统计分析时按夜盘规则重新归集交易日,但展示日期仍用原始日期。

Goals / Non-Goals

Goals:

  1. 移除导入时对本次导入数据的去重逻辑。
  2. 导入时直接使用结算单原始日期作为 trade_date
  3. 统计分析查询时,新增一个统计用交易日字段,将 21:00 之后的数据归集到下一交易日。
  4. 前端统计表格的日期列仍显示原始成交日期。

Non-Goals:

  • 不修改数据库 schema。
  • 不修改单条导入接口路径和返回结构。

Decisions

  1. 去重策略:仅保留与数据库已有记录的去重,移除 batch_existing_keysnew_keys_in_batch 逻辑。
  2. 交易日计算:导入时不再调用 recalculate_trade_date;在 trade_review_service.py 查询统计时,使用 recalculate_trade_date(trade_date, trade_time) 生成统计用交易日,但原始 trade_date 字段保留用于展示。
  3. 前端展示:表格中继续使用原始 trade_date,统计分组使用后端返回的统计用交易日字段(或在后端完成分组后直接返回)。

Risks / Trade-offs

  • 如果用户重复导入同一文件,会产生重复数据。需要通过业务提示引导用户,本次变更不再自动去重。