fix(swap): 解决日期刷新后部分平仓数量计算问题-公司行为
- 在日期刷新基线方法中添加平仓数量重新计算逻辑 - 确保非全平仓情况下按原比例重新计算平仓数量 - 添加单元测试验证部分平仓数量按原比例重算功能 - 修复了日期刷新后平仓比例与实际平仓数量不匹配的bug
This commit is contained in:
@@ -353,5 +353,33 @@ namespace YLErp.Modules.SwapModule
|
||||
Console.WriteLine($"⚠ 退化场景:A={closePercentA} == B={convertedB}(首次平仓,无法暴露双重转换bug)");
|
||||
Console.WriteLine($"✅ 非退化场景见 CPC_005/007:A=0.325 ≠ B=0.50(多次部分平仓后才能暴露)");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CPC_011_日期刷新基线后_部分平仓数量必须按原比例重算()
|
||||
{
|
||||
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
string source = null;
|
||||
while (directory != null && source == null)
|
||||
{
|
||||
var path = Path.Combine(directory.FullName, "YLErpWeb", "wwwroot", "Scripts", "app", "swaptrade", "unwindSwapTrade.js");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
source = File.ReadAllText(path);
|
||||
}
|
||||
directory = directory.Parent;
|
||||
}
|
||||
|
||||
Assert.IsNotNull(source, "未找到 unwindSwapTrade.js");
|
||||
var refreshStart = source.IndexOf("refreshUnwindBaseline() {//", StringComparison.Ordinal);
|
||||
var refreshEnd = source.IndexOf("getInterestList() {//", refreshStart, StringComparison.Ordinal);
|
||||
var refreshMethod = source.Substring(refreshStart, refreshEnd - refreshStart);
|
||||
var oriClosePercentIndex = refreshMethod.IndexOf("thisObj.oriClosePercent =", StringComparison.Ordinal);
|
||||
var recalcCloseQtyIndex = refreshMethod.IndexOf(
|
||||
"thisObj.deal.CloseQty = thisObj.calcCloseQtyByPercent(thisObj.deal.ClosePercent);",
|
||||
StringComparison.Ordinal);
|
||||
|
||||
Assert.IsTrue(recalcCloseQtyIndex > oriClosePercentIndex,
|
||||
"日期刷新并更新最多可平比例后,部分平仓数量必须按保留的平仓比例重新计算。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,6 +524,8 @@ const vue = new Vue({
|
||||
// 如果是全平,更新平仓比例
|
||||
if (thisObj.deal.CloseMethod == 1) {
|
||||
thisObj.deal.ClosePercent = thisObj.oriClosePercent;
|
||||
} else {
|
||||
thisObj.deal.CloseQty = thisObj.calcCloseQtyByPercent(thisObj.deal.ClosePercent);
|
||||
}
|
||||
|
||||
// 强制 Vue 更新界面
|
||||
|
||||
Reference in New Issue
Block a user