feat(trade): 新增真实除权日字段并完善基金公司行为处理 init

- 添加 EffectiveDate 字段用于标识真实除权生效日
- 实现公司行为价格系数和数量系数统一计算方法
- 增加基金除权回退和平仓基线恢复功能
- 完善除权日验证逻辑,确保真实除权日不早于股权登记日
- 重构平仓流程,支持按有效EOD基线重新计算损益和现金
- 添加基金拆合股和现金分红的特殊处理逻辑
- 增加单元测试验证各种公司行为场景下的正确性
This commit is contained in:
张名锐
2026-08-18 11:20:56 +08:00
parent 04f4468be5
commit aa1a13d7a3
11 changed files with 1582 additions and 18 deletions
@@ -42,6 +42,9 @@ namespace YLErp.Modules.SwapModule
/// <summary>AddClientCash 调用记录(金额, 操作)</summary>
public List<(double amount, string action)> ClientCashCalls { get; } = new();
/// <summary>SwapPositionCompose 使用的公司行为内存数据;默认空,避免测试访问数据库。</summary>
public List<ex_dividend_info> ExDividendInfos { get; } = new();
/// <summary>自增 id 模拟器(新增 eod 时分配 id</summary>
private int _nextId = 1;
@@ -78,6 +81,25 @@ namespace YLErp.Modules.SwapModule
return 1.0; // 本币,汇率=1
}
protected override List<ex_dividend_info> FindExDividendInfos(DateTime settleDate)
{
return ExDividendInfos
.Where(x => x.ValidStatus
&& x.EffectiveDate.HasValue
&& x.EffectiveDate.Value.Date == settleDate.Date)
.ToList();
}
protected override decimal GetFundCorporateActionClosePrice(
ex_dividend_info dividendInfo,
decimal fallbackPrice)
=> fallbackPrice;
protected override decimal GetDividendTaxRate()
{
return 0m;
}
protected override int AddClientCash(trade td, double amount, string action, DateTime valueDate)
{
ClientCashCalls.Add((amount, action));