274 lines
12 KiB
C#
274 lines
12 KiB
C#
using Qdp.Pricing.Base.Enums;
|
|
using YLErp.Configuration;
|
|
|
|
namespace YLErp.Modules.TradeModule.OrderModule
|
|
{
|
|
partial class TradeAbstractService
|
|
{
|
|
/// <summary>
|
|
/// 雪球期权生成交易摘要
|
|
/// </summary>
|
|
private static IEnumerable<(string text, string value)> GenerateTradeAbstract_snowball(trade td, InnerWrap wrap)
|
|
{
|
|
if (td is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(td));
|
|
}
|
|
|
|
if (wrap is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(wrap));
|
|
}
|
|
|
|
var snowball = td.trade_snowball;
|
|
if (snowball == null)
|
|
{
|
|
throw new ServiceException("雪球期权扩展信息不存在,无法生成交易摘要");
|
|
}
|
|
|
|
//专业版雪球
|
|
if (snowball.PrepaymentUsed)
|
|
{
|
|
return GenerateTradeAbstract_specialsnowball(td, wrap);
|
|
}
|
|
|
|
td.TradeOriginalAmount = td.OriginalNotional / wrap.CountRatio;
|
|
|
|
var list = new List<(string, string)> {
|
|
("交易编号", td.TradeNumber),
|
|
("成交日期", td.TradeDate.OtcFormatDate()),
|
|
("买卖方向", td.ClientName),
|
|
("#", td.BuySell == "买入" ? "卖出" : "买入"),
|
|
("标的代码", td.UnderlyingCode),
|
|
};
|
|
if (wrap.UnderlyingInstrumentType == "Stock")
|
|
{
|
|
list.Add(("标的名称", wrap.UnderlyingName));
|
|
}
|
|
list.Add(("期权类型", "雪球 " + td.OptionType));
|
|
list.Add(("标的价格", td.SpotPrice.OtcFormatUmPrice() + (PS.Config.Is浙期 ? " 元" : "")));
|
|
if (td.TradeType != "自定义交易" && (td.TradeType != "亚式期权" || td.trade_asian_option.StrikeType != "Floating") && td.TradeType != "雪球期权")
|
|
{
|
|
list.Add(("执行价格", wrap.strikeFmt(td.Strike) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
}
|
|
|
|
if (!wrap.IsUsePremiumRate)
|
|
{
|
|
list.Add(("成交数量", td.TradeOriginalAmount.OtcFormatNotional(wrap.CountRatio, PS.Config.IsUseDisplayNotional) + (PS.Config.IsUseDisplayNotional ? wrap.QuoteUnit : wrap.TradeUnitString)));
|
|
}
|
|
|
|
if (PS.Config.Is方顿)
|
|
{
|
|
list.Add(("保底收益总额", td.OriginalPrincipalSum.OtcFormatMoney() + " 元"));
|
|
}
|
|
|
|
if (PS.Config.Company != CompanyEnum.厦门象屿 && !PS.Config.Is润和)
|
|
{
|
|
list.AddRange(new[] {
|
|
("名义本金", OtcFormatExtensions.OtcFormat(td.StockEqvNotionalToShow, OtcFormatFlag.StockEqvNotional))
|
|
});
|
|
}
|
|
|
|
if (!snowball.IsInitialKnockedIn)
|
|
{
|
|
list.Add(("敲入价格", wrap.strikeFmt(snowball.KIBarrier) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
}
|
|
else
|
|
{
|
|
list.Add(("初始敲入", "是"));
|
|
}
|
|
list.Add(("敲出价格", wrap.strikeFmt(snowball.KOBarrier) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
|
|
switch (snowball.KIPayoffType)
|
|
{
|
|
case KIPayoffTypeEnum.None:
|
|
break;
|
|
case KIPayoffTypeEnum.ToCallOption:
|
|
case KIPayoffTypeEnum.ToPutOption:
|
|
list.Add(("执行价格一", wrap.strikeFmt(snowball.SpreadStrikeAtMaturity1)));
|
|
break;
|
|
case KIPayoffTypeEnum.ToCallSpreadOption:
|
|
case KIPayoffTypeEnum.ToPutSpreadOption:
|
|
list.Add(("执行价格一", wrap.strikeFmt(snowball.SpreadStrikeAtMaturity)));
|
|
list.Add(("执行价格二", wrap.strikeFmt(snowball.SpreadStrikeAtMaturity1)));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
var kiObsInfo = "每日观察";
|
|
if (!string.IsNullOrWhiteSpace(snowball.ObservationDates))
|
|
{
|
|
kiObsInfo = snowball.ObservationDates;
|
|
}
|
|
switch (snowball.KOPayoffType)
|
|
{
|
|
|
|
case KOPayoffTypeEnum.ToOption:
|
|
list.Add(("敲出执行价1", wrap.strikeFmt(snowball.SpreadStrikeAtKO1) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
break;
|
|
case KOPayoffTypeEnum.ToSpreadOption:
|
|
list.Add(("敲出执行价1", wrap.strikeFmt(snowball.SpreadStrikeAtKO1) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
list.Add(("敲出执行价2", wrap.strikeFmt(snowball.SpreadStrikeAtKO) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
break;
|
|
case KOPayoffTypeEnum.Rebate:
|
|
list.Add(("敲出票息", snowball.KORebate.OtcFormatPercent()));
|
|
break;
|
|
default:
|
|
kiObsInfo = "";
|
|
break;
|
|
}
|
|
|
|
list.Add(("未敲入未敲出收益率", snowball.Coupon.OtcFormat(OtcFormatFlag.percent)));
|
|
list.Add(("票息年化", snowball.IsFixedCoupon ? "否" : "是"));
|
|
|
|
if (!string.IsNullOrWhiteSpace(kiObsInfo) && !snowball.IsInitialKnockedIn)
|
|
{
|
|
list.Add(("敲入观察日期", kiObsInfo));
|
|
}
|
|
var koInfo = "";
|
|
if (!string.IsNullOrWhiteSpace(snowball.KOObservationDates))
|
|
{
|
|
var KOObservationDates = QdpModule.QdpHelper.ParseAutocallCustomizedInfo(snowball.KOObservationDates);
|
|
for (var i = 0; i < KOObservationDates.Item1.Length; i++)
|
|
{
|
|
var splitStr = ", ";
|
|
if (i == KOObservationDates.Item1.Length - 1)
|
|
{
|
|
splitStr = "";
|
|
}
|
|
var couponInfo = PS.Config.Is浙期 ? ":" + KOObservationDates.Item3[i].OtcFormat(OtcFormatFlag.percent) + splitStr : splitStr;
|
|
koInfo += KOObservationDates.Item1[i].DateTime.ToString("yyyy-MM-dd") + couponInfo;
|
|
}
|
|
}
|
|
|
|
list.Add(("到期日期", td.ExerciseDate.OtcFormatDate()));
|
|
list.Add(("敲出观察日期", koInfo));
|
|
|
|
return list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 专业版雪球期权生成交易摘要
|
|
/// </summary>
|
|
private static IEnumerable<(string text, string value)> GenerateTradeAbstract_specialsnowball(trade td, InnerWrap wrap)
|
|
{
|
|
if (td is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(td));
|
|
}
|
|
|
|
if (wrap is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(wrap));
|
|
}
|
|
|
|
var snowball = td.trade_snowball;
|
|
if (snowball == null)
|
|
{
|
|
throw new ServiceException("雪球期权扩展信息不存在,无法生成交易摘要");
|
|
}
|
|
|
|
td.TradeOriginalAmount = td.OriginalNotional / wrap.CountRatio;
|
|
|
|
var list = new List<(string, string)> {
|
|
("交易编号", td.TradeNumber),
|
|
("成交日期", td.TradeDate.OtcFormatDate()),
|
|
("买卖方向", td.ClientName),
|
|
("#", td.BuySell == "买入" ? "卖出" : "买入"),
|
|
("标的代码", td.UnderlyingCode),
|
|
};
|
|
if (wrap.UnderlyingInstrumentType == "Stock")
|
|
{
|
|
list.Add(("标的名称", wrap.UnderlyingName));
|
|
}
|
|
list.Add(("期权类型", "雪球 " + td.OptionType));
|
|
list.Add(("标的价格", td.SpotPrice.OtcFormatUmPrice() + (PS.Config.Is浙期 ? " 元" : "")));
|
|
|
|
if (!wrap.IsUsePremiumRate)
|
|
{
|
|
list.Add(("成交数量", td.TradeOriginalAmount.OtcFormatNotional(wrap.CountRatio, PS.Config.IsUseDisplayNotional) + (PS.Config.IsUseDisplayNotional ? wrap.QuoteUnit : wrap.TradeUnitString)));
|
|
}
|
|
|
|
if (PS.Config.Is方顿)
|
|
{
|
|
list.Add(("保底收益总额", td.OriginalPrincipalSum.OtcFormatMoney() + " 元"));
|
|
}
|
|
|
|
if (PS.Config.Company != CompanyEnum.厦门象屿 && !PS.Config.Is润和)
|
|
{
|
|
list.AddRange(new[] {
|
|
("名义本金", OtcFormatExtensions.OtcFormat(td.StockEqvNotionalToShow, OtcFormatFlag.StockEqvNotional))
|
|
});
|
|
}
|
|
|
|
list.Add(("预付金比例", snowball.PrepaymentRatio.OtcFormatFlex(2, percent: true)));
|
|
//list.Add(("预付金返息率", snowball.PrepaymentInterestRate.OtcFormatFlex(2, percent: true)));
|
|
list.Add(("预付金折现率", snowball.PrepaymentConvertCashRate.OtcFormatFlex(2, percent: true)));
|
|
|
|
if (snowball.IsInitialKnockedIn)
|
|
{
|
|
list.Add(("初始敲入", "是"));
|
|
}
|
|
else
|
|
{
|
|
list.Add(("敲入价格", wrap.strikeFmt(snowball.KIBarrier) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
list.Add(("敲入观察设置", snowball.KIObservationType == KIObservationType.OnlyEndDate ? "仅到期日观察" : "每日观察"));
|
|
}
|
|
|
|
list.Add(("敲入执行价格", wrap.strikeFmt(snowball.SpreadStrikeAtMaturity1) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
list.Add(("敲入参与率", snowball.KIParticipationRate.OtcFormatFlex(2, percent: true)));
|
|
list.Add(("保本比率", snowball.PrincipalProtectionRate.OtcFormatFlex(2, percent: true)));
|
|
|
|
list.Add(("首日是否计息", snowball.CouponIncludeStartDate == true ? "是" : "否"));
|
|
list.Add(("终日是否计息", snowball.CouponIncludeEndDate == true ? "是" : "否"));
|
|
|
|
var couponDayCount = "非年化";
|
|
switch (snowball.CouponDayCount)
|
|
{
|
|
case nameof(DayCount.Act365):
|
|
couponDayCount = "按365日年化";
|
|
break;
|
|
case nameof(DayCount.Act360):
|
|
couponDayCount = "按360日年化";
|
|
break;
|
|
case nameof(DayCount.Monthly):
|
|
couponDayCount = "按月年化";
|
|
break;
|
|
}
|
|
list.Add(("计息年化方式", couponDayCount));
|
|
|
|
list.Add(("票息率", snowball.KORebate.OtcFormatFlex(2, percent: true)));
|
|
list.Add(("红利票息", snowball.Coupon.OtcFormatFlex(2, percent: true)));
|
|
list.Add(("增强参与率", snowball.EnhancedParticipationRate.OtcFormatFlex(2, percent: true)));
|
|
|
|
list.Add(("敲出价格", wrap.strikeFmt(snowball.KOBarrier) + (PS.Config.Is浙期 ? " 元" : "")));
|
|
|
|
var koInfo = "";
|
|
if (!string.IsNullOrWhiteSpace(snowball.KOObservationDates))
|
|
{
|
|
var KOObservationDates = QdpModule.QdpHelper.ParseAutocallCustomizedInfo(snowball.KOObservationDates);
|
|
|
|
if (KOObservationDates != null && KOObservationDates.Item1.Length > 0)
|
|
{
|
|
for (var i = 0; i < KOObservationDates.Item1.Length; i++)
|
|
{
|
|
var splitStr = ", ";
|
|
if (i == KOObservationDates.Item1.Length - 1)
|
|
{
|
|
splitStr = "";
|
|
}
|
|
var couponInfo = PS.Config.Is浙期 ? ":" + KOObservationDates.Item3?[i].OtcFormat(OtcFormatFlag.percent) + splitStr : splitStr;
|
|
koInfo += KOObservationDates.Item1[i].DateTime.ToString("yyyy-MM-dd") + couponInfo;
|
|
}
|
|
}
|
|
}
|
|
|
|
list.Add(("到期日期", td.ExerciseDate.OtcFormatDate()));
|
|
list.Add(("敲出观察日期", koInfo));
|
|
|
|
return list;
|
|
}
|
|
}
|
|
}
|