Merge branch 'refs/heads/glms/feature/1.4.2' into glms/feature/0812_zmr_divPower
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using YLErp.Modules.CalculationModule;
|
||||
using YLErp.Modules.EodModule;
|
||||
|
||||
namespace YLErp.BasicTests
|
||||
{
|
||||
[TestClass]
|
||||
public class GLMSGreeksHandleServiceTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void Handle_NonRateAsset_CalculatesVega1bpBeforeRateFilter()
|
||||
{
|
||||
var service = new GLMSGreeksHandleService();
|
||||
var dto = new EodPositionRisksDTO
|
||||
{
|
||||
Vega = 2500d
|
||||
};
|
||||
var underlying = new underlying_manager
|
||||
{
|
||||
UnderlyingInstrumentType = ConsGlobal.InstrumentType.Stock
|
||||
};
|
||||
|
||||
service.Handle(dto, underlying);
|
||||
|
||||
Assert.IsNotNull(dto.Vega_1bp);
|
||||
Assert.AreEqual(0.25d, dto.Vega_1bp.Value, 1e-12);
|
||||
Assert.IsNull(dto.Vega_r);
|
||||
Assert.IsNull(dto.Vega_r_1bp);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Handle_TradeValueResult_NonRateAsset_CalculatesVega1bpBeforeRateFilter()
|
||||
{
|
||||
var service = new GLMSGreeksHandleService();
|
||||
var result = new TradeValueResult
|
||||
{
|
||||
Vega = 2500d
|
||||
};
|
||||
var underlying = new underlying_manager
|
||||
{
|
||||
UnderlyingInstrumentType = ConsGlobal.InstrumentType.Stock
|
||||
};
|
||||
|
||||
service.Handle(new trade(), result, underlying);
|
||||
|
||||
Assert.IsNotNull(result.Vega_1bp);
|
||||
Assert.AreEqual(0.25d, result.Vega_1bp.Value, 1e-12);
|
||||
Assert.IsNull(result.Vega_r);
|
||||
Assert.IsNull(result.Vega_r_1bp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using YLErp.Helpers;
|
||||
using YLErp.Model;
|
||||
|
||||
namespace UnitTestProject.Modules
|
||||
{
|
||||
/// <summary>
|
||||
/// EQD-6953 疑似到期债券值域闸门:IsMaturedDegenerate / IsResultAbsurd 分支覆盖。
|
||||
/// 场景来源:UAT 060203.IB(2006年国债,2026估值日已无剩余现金流)——
|
||||
/// jquantlib 对空现金流求解得 ytm=0、净/全价均为面值100,errCode=0"成功但退化"。
|
||||
/// 与前端 swapCalc.js::getBondCalcErrorMessage 的同款闸门保持一致口径。
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class BondCalcHeplerTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void 到期退化值_三条件同时成立_命中()
|
||||
{
|
||||
var r = new CalBondResult { cleanPrice = 100m, dirtyPrice = 100m, ytm = 0m };
|
||||
Assert.IsTrue(BondCalcHepler.IsMaturedDegenerate(r));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 正常券_不命中_按UAT实测180205IB()
|
||||
{
|
||||
var r = new CalBondResult { cleanPrice = 97.43300000000002m, dirtyPrice = 100.00001369863016m, ytm = 6.738278242318886m };
|
||||
Assert.IsFalse(BondCalcHepler.IsMaturedDegenerate(r));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ytm为0但净价非面值_不命中_真实零息平价券场景()
|
||||
{
|
||||
var r = new CalBondResult { cleanPrice = 99.5m, dirtyPrice = 100m, ytm = 0m };
|
||||
Assert.IsFalse(BondCalcHepler.IsMaturedDegenerate(r));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 价格为面值但ytm非0_不命中_正常息票平价券场景()
|
||||
{
|
||||
var r = new CalBondResult { cleanPrice = 100m, dirtyPrice = 100.5m, ytm = 3.2m };
|
||||
Assert.IsFalse(BondCalcHepler.IsMaturedDegenerate(r));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ytm为null_不命中()
|
||||
{
|
||||
var r = new CalBondResult { cleanPrice = 100m, dirtyPrice = 100m, ytm = null };
|
||||
Assert.IsFalse(BondCalcHepler.IsMaturedDegenerate(r));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsResultAbsurd_到期退化值_命中并带原因()
|
||||
{
|
||||
var r = new CalBondResult { cleanPrice = 100m, dirtyPrice = 100m, ytm = 0m };
|
||||
var ok = typeof(BondCalcHepler)
|
||||
.GetMethod("IsResultAbsurd", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
|
||||
.Invoke(null, new object[] { r, null });
|
||||
Assert.IsTrue((bool)ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Reflection;
|
||||
|
||||
namespace YLErp.UnitTestProject.Modules.UnderlyingModule
|
||||
{
|
||||
[TestClass]
|
||||
public class UnderlyingFundManagerMappingTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void InvestAdvisorName_MapsExistingFundManagerColumn()
|
||||
{
|
||||
var property = typeof(underlying_manager).GetProperty("InvestAdvisorName");
|
||||
|
||||
Assert.IsNotNull(property, "underlying_manager 应公开基金管理人属性 InvestAdvisorName");
|
||||
Assert.AreEqual("investadvisorname", property.GetCustomAttribute<ColumnAttribute>()?.Name);
|
||||
Assert.AreEqual("基金管理人", property.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user