using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YLErp.DBModels;
using YLErp.Helpers;
namespace YLErp.DBModels
{
public class swap_event: DBModelBaseV2
{
///
/// 事件日期
///
[DisplayName("事件日期")]
[DataChange]
public DateTime ValueDate { get; set; }
///
/// 互换交易编号id
///
[DisplayName("互换交易编号id")]
[DataChange]
public int SwapTradeId { get; set; }
///
/// 事件类型 1:合成持仓,2:平仓,3:收益互换
///
[DisplayName("平仓事件")]
[DataChange]
public int EventType { get; set; }
///
/// 事件类型名称
///
[NotMapped]
public string EventTypeName { get { return ((SwapEventTypeEnum)EventType).ToString(); } }
///
/// 事件原因
///
[DisplayName("事件原因")]
[DataChange]
public string EventReason { get; set; }
///
/// 事件数据json
///
[DisplayName("事件数据")]
[DataChange]
public string EventData { get; set; }
///
/// 是否无效
///
[DisplayName("是否无效")]
[DataChange]
public bool Invalid { get; set; }
///
/// 客户资金记录id
///
[DisplayName("客户资金记录id")]
[DataChange]
public int ClientCashId { get; set; }
///
/// 回退记录id
///
[DisplayName("回退记录id")]
[DataChange]
public long BackId { get; set; }
///
/// 展期信息
///
[NotMapped]
public ExtenstionData extenstionData { get; set; }
///
/// 交易编码
///
[NotMapped]
public string SwapTradeNumber { get; set; }
///
/// 平仓/互换/自动互换主干数据
///
[NotMapped]
public UnwindData unwindData { get; set; }
}
///
/// 公司行为事件快照。登记日先写入待生效快照,真实除权日补齐调整后数据;
/// 已应用快照只允许追加回退事件,不覆盖原记录。
/// ExDividendDate 是登记日,EffectiveDate 是 Q/P 真实切换日;GiveShareAmount
/// 表示每 10 份增减数量,Split 表示独立拆/合股倍数(null 按 1)。Before/After
/// 分别保存调整前后名义本金、价格、数量和待实现分红,CashFlowChange 保存现金变化。
///
public class CorporateActionEventData
{
public int ExDividendInfoId { get; set; }
public long PositionId { get; set; }
public string UnderlyingCode { get; set; }
public DateTime? ExDividendDate { get; set; }
public DateTime? EffectiveDate { get; set; }
public decimal GiveCashAmount { get; set; }
public decimal GiveShareAmount { get; set; }
public decimal? Split { get; set; }
public decimal RationedSharesAmount { get; set; }
public decimal RationedSharesPrice { get; set; }
public decimal BeforeNotional { get; set; }
public decimal BeforePrice { get; set; }
public decimal BeforeQuantity { get; set; }
public decimal AfterNotional { get; set; }
public decimal AfterPrice { get; set; }
public decimal AfterQuantity { get; set; }
public decimal BeforePendingDividend { get; set; }
public decimal AfterPendingDividend { get; set; }
public decimal CashFlowChange { get; set; }
public bool Applied { get; set; }
}
///
/// 展期信息
///
public class ExtenstionData
{
///
/// 旧到期日
///
public DateTime OldMaturityDate { get; set; }
///
/// 新到期日
///
public DateTime NewMaturityDate { get; set; }
}
public class UnwindData
{
public UnwindData()
{
FlowEvents = new List();
ClientCashIds = new List();
}
public int SwapTradeId { get; set; }
///
/// 平仓类型 1:数量 ,2:名义本金
///
public int CloseType { get; set; }
///
/// 平仓数量
///
public decimal CloseQty { get; set; }
///
/// 平仓比例
///
public decimal ClosePercent { get; set; }
///
/// 是否计罚息(EQD-6977):提前终止平仓时利息端按持有至到期计息。默认 false=否。
/// 由平仓页“是否罚息”下拉写入,经 GetUnwindInterests 透传至罚息接缝层。
///
public bool IsPenaltyInterest { get; set; }
///
/// 平仓名义本金
///
public decimal CloseNotionalValue { get; set; }
///
/// 开始日期
///
public DateTime StartDate { get; set; }
///
/// 交易日期
///
public DateTime ValueDate { get; set; }
///
/// 收益结算日期上限
///
[NotMapped]
public DateTime? MaxIncomeValueDate { get; set; }
///
/// 平仓/互换日期
///
public DateTime? UnwindDate { get; set; }
///
/// 期初名义本金
///
public decimal NotionalValue { get; set; }
///
/// 期初持仓数量
///
public decimal NotionalQty { get; set; }
///
/// 持仓名义本金
///
public decimal PosiNotionalValue { get; set; }
///
/// 持仓数量
///
public decimal PositionQty { get; set; }
///
/// 年化天数
///
public int AnnualDays { get; set; }
///
/// 平仓方式
///
public int CloseMethod { get; set; }
///
/// 实现盈亏
///
public decimal SwapRealizedPnL { get; set; }
///
/// 预付金腿返息盈亏
///
public decimal SwapMarginRebatePnl { get; set; }
///
/// 预付金腿 返还预付金轧差
///
public decimal SwapMarginAmount { get; set; }
///
/// 平仓总额
///
public decimal SwapCloseAmount { get; set; }
///
/// 浮动端分红盈亏
///
public decimal SwapDividendPnl { get; set; }
///
/// 自动互换生成的客户资金记录ID集合
///
public List ClientCashIds { get; set; }
///
/// 利息腿/浮动腿 集合,不序列化存储,只做查询
///
public List FlowEvents { get; set; }
public string StructureType { get; set; }
///
/// 支付日
///
public DateTime? PayDate { get; set; }
[NotMapped]
public DateTime? TradeStartDate { get; set; }
}
}