和顺 / 衡律 返回所属 Agent
24.3

数学与数值测试

原能力

按独立基准验证金融数值、边界、误差、收敛和约束残差。(合同附件 R7 24.3)

首选项目

QuantLib(Modified BSD,上游许可正文)。 QuantLib

匹配范围

独立数值参考候选,以及差分测试工具。

源码

QuantLib · testValues

test-suite/europeanoption.cpp · 288–301 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
BOOST_AUTO_TEST_CASE(testValues) {

    BOOST_TEST_MESSAGE("Testing European option values...");

    /* The data below are from
       "Option pricing formulas", E.G. Haug, McGraw-Hill 1998
    */
    EuropeanOptionData values[] = {
      // pag 2-8
      //        type, strike,   spot,    q,    r,    t,  vol,   value,    tol
      { Option::Call,  65.00,  60.00, 0.00, 0.08, 0.25, 0.30,  2.1334, 1.0e-4},
      { Option::Put,   95.00, 100.00, 0.05, 0.10, 0.50, 0.20,  2.4648, 1.0e-4},
      { Option::Put,   19.00,  19.00, 0.10, 0.10, 0.75, 0.28,  1.7011, 1.0e-4},
      { Option::Call,  19.00,  19.00, 0.10, 0.10, 0.75, 0.28,  1.7011, 1.0e-4},
  • Copyright (C) 2003, 2007 Ferdinando Ametrano
  • Copyright (C) 2003, 2007 StatPro Italia srl
  • Copyright (C) 2009 Klaus Spanderen
  • Copyright (C) 2026 Mahimn Patel

pytest · def parametrize(

src/_pytest/python.py · 1387–1400 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
    def parametrize(
        self,
        argnames: str | Sequence[str],
        argvalues: Iterable[ParameterSet | Sequence[object] | object],
        *,
        indirect: bool | Sequence[str] = False,
        ids: Iterable[object | None] | Callable[[Any], object | None] | None = None,
        scope: ScopeName | None = None,
        _param_mark: Mark | None = None,
    ) -> None:
        """Add new invocations to the underlying test function using the list
        of argvalues for the given argnames. Parametrization is performed
        during the collection phase. If you need to setup expensive resources
        see about setting ``indirect`` to do it at test setup time instead.

实现与验收要点

冻结对照方法、精度、参考独立性与误差。