债券计算器 返回结果后要进行 /100 * 100 处理 适配目前的 这个 /100 * 100,避免 很离谱的 值
This commit is contained in:
@@ -111,6 +111,40 @@ describe('错误反馈:getBondCalcErrorMessage(对齐 C# BondCalcHepler 的
|
||||
expect(SwapCalc.getBondCalcErrorMessage(resp)).toBeNull();
|
||||
});
|
||||
|
||||
test('防御值域:成功(errCode=0)但净价为负 → 拦截提示、不回写(用户实测 180205.IB 场景)', () => {
|
||||
const resp = { errCode: 0, dirtyPrice: 100, cleanPrice: -117.93, ytm: 6.37 };
|
||||
const err = SwapCalc.getBondCalcErrorMessage(resp);
|
||||
expect(err).not.toBeNull();
|
||||
expect(err).toContain("净价");
|
||||
});
|
||||
|
||||
test('防御值域:成功但收益率量级爆炸(378543) → 拦截提示、不回写', () => {
|
||||
const resp = { errCode: 0, dirtyPrice: 100, cleanPrice: 97.82, ytm: 378543.526601942 };
|
||||
const err = SwapCalc.getBondCalcErrorMessage(resp);
|
||||
expect(err).not.toBeNull();
|
||||
expect(err).toContain("收益率");
|
||||
});
|
||||
|
||||
test('防御值域:净价超过 1000(量纲错误)→ 拦截', () => {
|
||||
const resp = { errCode: 0, dirtyPrice: 100, cleanPrice: 9782, ytm: 6.37 };
|
||||
expect(SwapCalc.getBondCalcErrorMessage(resp)).not.toBeNull();
|
||||
});
|
||||
|
||||
test('防御值域:命中哨兵值 -999999 → 拦截', () => {
|
||||
const resp = { errCode: 0, dirtyPrice: 100, cleanPrice: 99, ytm: -999999 };
|
||||
expect(SwapCalc.getBondCalcErrorMessage(resp)).not.toBeNull();
|
||||
});
|
||||
|
||||
test('防御值域:合理范围内的正常值(净价97.82/收益率6.37) → 放行返回 null', () => {
|
||||
const resp = { errCode: 0, dirtyPrice: 100, cleanPrice: 97.82, ytm: 6.37 };
|
||||
expect(SwapCalc.getBondCalcErrorMessage(resp)).toBeNull();
|
||||
});
|
||||
|
||||
test('防御值域:负收益率但量级合理(-2.5%) → 放行(允许负利率债券)', () => {
|
||||
const resp = { errCode: 0, dirtyPrice: 100, cleanPrice: 99, ytm: -2.5 };
|
||||
expect(SwapCalc.getBondCalcErrorMessage(resp)).toBeNull();
|
||||
});
|
||||
|
||||
test('端到端:业务错误时不覆盖手工输入(仅提示)', () => {
|
||||
const item = { PosiNetNoFeePrice: 99.5, PosiGrossPrice: 100.0, InitYtm: 2.6,
|
||||
bondDriverType: 'CP', bondManual: { CP: true, DP: false, YD: false } };
|
||||
|
||||
Reference in New Issue
Block a user