Files
zszq-trs/YLErpDAL/Modules/SwapModule/Accrual/FundingLegRate.cs
T

41 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace YLErp.Modules.SwapModule.Accrual;
/// <summary>
/// 融资腿在某一计息日生效的利率(不可变值对象)。
///
/// <para>把"固定利率 / 加点利差 / 浮动指数定盘"三种来源收敛为一个概念,避免把它们作为裸 decimal
/// 散落在计息方法签名里——这正是初版 <c>AccrueSimpleEod</c> 参数膨胀、可读性差的根因。</para>
///
/// <para>固定腿与浮动腿是互斥的两种形态:固定腿只设 <see cref="FixedRate"/>(其余为 0);
/// 浮动腿设 <see cref="Spread"/> + <see cref="IndexFixing"/><see cref="FixedRate"/> 为 0)。
/// <see cref="AllInRate"/> 对两种形态统一为三者之和。</para>
///
/// <list type="bullet">
/// <item><description><see cref="FixedRate"/>:固定腿的固定年利率;浮动腿为 0。</description></item>
/// <item><description><see cref="Spread"/>:浮动腿在指数之上的加点利差(合约侧);固定腿为 0。</description></item>
/// <item><description><see cref="IndexFixing"/>:浮动指数定盘(FR007 等);固定腿为 0。</description></item>
/// <item><description><see cref="AllInRate"/>:计息用的"当日生效年利率"。固定腿取 <see cref="FixedRate"/>;浮动腿取 <see cref="Spread"/> + <see cref="IndexFixing"/>(二者互斥,非叠加)。</description></item>
/// </list>
/// </summary>
public readonly struct FundingLegRate
{
/// <summary>固定腿的固定年利率;浮动腿为 0。</summary>
public decimal FixedRate { get; }
/// <summary>浮动腿在指数之上的加点利差(合约侧);固定腿为 0。</summary>
public decimal Spread { get; }
/// <summary>浮动指数定盘利率(市场侧,FR007 等);固定腿为 0。</summary>
public decimal IndexFixing { get; }
/// <summary>
/// 当日生效年利率。固定腿与浮动腿是互斥的两种利率确定方式,不是可叠加分量:
/// 固定腿取 <see cref="FixedRate"/>;浮动腿取 <see cref="Spread"/> + <see cref="IndexFixing"/>。
/// 约定:固定腿只设 FixedRate(其余为 0),浮动腿只设 Spread + IndexFixingFixedRate 为 0)。
/// </summary>
public decimal AllInRate => FixedRate != 0m ? FixedRate : Spread + IndexFixing;
public FundingLegRate(decimal fixedRate = 0m, decimal spread = 0m, decimal indexFixing = 0m)
=> (FixedRate, Spread, IndexFixing) = (fixedRate, spread, indexFixing);
}