#EQD-6597 国联民生-簿记时新增基本费率字段(开平仓费用),并且自动计算
feat: 完善互换平仓交易费用自动计算 - 支持百分比和单位数量模式自动计算平仓交易费用 - 支持全部平仓和部分平仓联动重算 - 保持手动互换不自动填充平仓交易费用 - 补充前后端相关单测
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System.Reflection;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
[TestClass]
|
||||
public class InitUnwindTradingFeeTest
|
||||
{
|
||||
private static decimal InvokeCalcInitTradingFee(swap_position position, UnwindData unwindData)
|
||||
{
|
||||
var method = typeof(SwapDealService).GetMethod(
|
||||
"CalcInitTradingFee",
|
||||
BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
Assert.IsNotNull(method, "未找到 CalcInitTradingFee 私有静态方法");
|
||||
|
||||
return (decimal)method.Invoke(null, new object[] { position, unwindData });
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 百分比模式_按平仓名义本金计算并四舍五入到两位()
|
||||
{
|
||||
var position = new swap_position
|
||||
{
|
||||
PosiFeeType = 0,
|
||||
PosiTradingFeeUnit = 0.1234m
|
||||
};
|
||||
var unwindData = new UnwindData
|
||||
{
|
||||
CloseNotionalValue = 1_000_000m,
|
||||
CloseQty = 8888m
|
||||
};
|
||||
|
||||
var fee = InvokeCalcInitTradingFee(position, unwindData);
|
||||
|
||||
Assert.AreEqual(1234.00m, fee);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 单位数量模式_按平仓数量计算并四舍五入到两位()
|
||||
{
|
||||
var position = new swap_position
|
||||
{
|
||||
PosiFeeType = 1,
|
||||
PosiTradingFeeUnit = 1.235m
|
||||
};
|
||||
var unwindData = new UnwindData
|
||||
{
|
||||
CloseNotionalValue = 1_000_000m,
|
||||
CloseQty = 10m
|
||||
};
|
||||
|
||||
var fee = InvokeCalcInitTradingFee(position, unwindData);
|
||||
|
||||
Assert.AreEqual(12.35m, fee);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 空入参_返回零()
|
||||
{
|
||||
Assert.AreEqual(0m, InvokeCalcInitTradingFee(null, new UnwindData()));
|
||||
Assert.AreEqual(0m, InvokeCalcInitTradingFee(new swap_position(), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user