302 lines
10 KiB
C#
302 lines
10 KiB
C#
using YLErp.DBModels.Helpers;
|
|
using YLErp.Model;
|
|
|
|
namespace YLErp.Modules.ReportModule
|
|
{
|
|
/// <summary>
|
|
/// 日终持仓报告模型
|
|
/// </summary>
|
|
public class EodPositionReportModel : EodPositionModelBase
|
|
{
|
|
public int CountRatio => DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(trade.UnderlyingCode);
|
|
|
|
public string ExerciseModeCn => trade?.ExerciseModeCn;
|
|
|
|
public double UnderlyingPriceValue => (UnderlyingPrice ?? 0).OtcFormatValue(OtcFormatFlag.umprice);
|
|
|
|
public double ExercisePrice => (trade?.Strike ?? 0).OtcFormatValue(OtcFormatFlag.umprice);
|
|
|
|
public string TradeDate => trade != null && trade.TradeDate != null ? trade.TradeDate.Value.ToString("yyyy-MM-dd") : "";
|
|
|
|
public string ExerciseDate => trade != null && trade.ExerciseDate != null ? trade.ExerciseDate.Value.ToString("yyyy-MM-dd") : "";
|
|
|
|
public string SettlementDate => trade != null && trade.SettlementDate != null ? trade.SettlementDate.Value.ToString("yyyy-MM-dd") : "";
|
|
|
|
public string Notional => (trade?.Notional ?? 0).OtcFormatNotional();
|
|
|
|
public string EnhancedPrice => trade.MetaDic.ContainsKey("增强价格") ? trade.MetaDic["增强价格"] : "";
|
|
public double TradeAmount => OtcFormatExtensions.OtcFormatValue(PS.Config.IsUseDisplayNotional ? trade.TradeAmount * CountRatio: trade.TradeAmount, OtcFormatFlag.notional);
|
|
|
|
public double TradeAmountV
|
|
{
|
|
get
|
|
{
|
|
if (trade != null)
|
|
{
|
|
var CountRatio = DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(trade.UnderlyingCode);
|
|
if (trade.TradeType == "累计期权")
|
|
{
|
|
return trade.TradeAmount / CountRatio;
|
|
}
|
|
var annRate = trade.ParticipationRate * trade.AnnualizeFactor;
|
|
var amount = trade.TradeAmount / (annRate ?? 1) / CountRatio;
|
|
return PS.Config.IsUseDisplayNotional ? amount * CountRatio : amount;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public double TradePrice
|
|
{
|
|
get
|
|
{
|
|
if (trade == null)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
double result;
|
|
if (trade.TradeType != "远期")
|
|
{
|
|
result = (trade.TradePrice == null ? 0 : trade.TradePrice.Value) * ("卖出".Equals(trade.BuySell) ? -1 : 1);
|
|
}
|
|
else
|
|
{
|
|
result = (trade.TradePrice == null ? 0 : trade.TradePrice.Value) * (-1);//持仓明细导出
|
|
}
|
|
return double.Parse(result.OtcFormatMoney(grouping: false));
|
|
}
|
|
}
|
|
|
|
public string CurrentPriceString
|
|
{
|
|
get
|
|
{
|
|
if (trade != null)
|
|
{
|
|
if (trade.IsUsePremiumRate == true)
|
|
{
|
|
var premiumRate = TradeHelper.GetPremiumRateByTradePrice(PvDouble, trade.StockEqvNotional, trade.ParticipationRate
|
|
, PS.Config.ErpElement.IsPVIncludePrincipal ? trade.PrincipalSum() : 0, trade.AnnualizeFactor, trade.BuySell, trade.TradeType, false);
|
|
return premiumRate.OtcFormat(OtcFormatFlag.premiumRateP);
|
|
}
|
|
else
|
|
{
|
|
if (trade.TradeType == "远期")
|
|
{
|
|
return (trade.Notional > 0 ? (PvDouble ?? 0) / trade.Notional : 0).OtcFormat(OtcFormatFlag.tradeSinglePrice);
|
|
}
|
|
else
|
|
{
|
|
var singlePrice = TradeHelper.GetTradeSinglePriceByTradePrice(PvDouble, trade.Notional
|
|
, PS.Config.ErpElement.IsPVIncludePrincipal ? trade.PrincipalSum() : 0, trade.BuySell, trade.TradeType, false);
|
|
return singlePrice.OtcFormat(OtcFormatFlag.tradeSinglePrice);
|
|
}
|
|
}
|
|
}
|
|
return "0";
|
|
}
|
|
}
|
|
|
|
public string Pv { get; set; }
|
|
|
|
public string Pnl { get; set; }
|
|
|
|
public double? PvDouble { get; set; }
|
|
|
|
public double? PnlDouble { get; set; }
|
|
|
|
public double StockEqvNotional => trade != null ? trade.StockEqvNotional : 0;
|
|
|
|
public double OriginalStockEqvNotional => trade != null ? trade.OriginalStockEqvNotionalV2 ?? (Math.Abs((trade.SpotPrice ?? 0) * (trade.OriginalNotional ?? 0))) : 0;
|
|
|
|
public double InitialSpotPrice => trade != null ? trade.SpotPrice ?? 0 : 0;
|
|
|
|
public double Strike => trade != null ? ((trade.IsMoneynessOptionData ? trade.Strike * trade.SpotPrice : trade.Strike) ?? 0) : 0;
|
|
|
|
public string StrikeString => Strike.OtcFormatUmPrice();
|
|
|
|
public double TradeSinglePrice => trade != null ? trade.TradeSinglePrice == null ? 0 : trade.TradeSinglePrice.Value : 0;
|
|
|
|
public string TradeSinglePriceString
|
|
{
|
|
get
|
|
{
|
|
if (trade == null)
|
|
{
|
|
return "0";
|
|
}
|
|
else if (trade.IsUsePremiumRate == true)
|
|
{
|
|
return (trade.PremiumRate ?? 0).OtcFormat(OtcFormatFlag.premiumRateP);
|
|
}
|
|
else
|
|
{
|
|
return (trade.TradeSinglePrice ?? 0).OtcFormat(OtcFormatFlag.tradeSinglePrice);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string TradeMultipleType
|
|
{
|
|
get
|
|
{
|
|
return trade?.TradeMultipleType;
|
|
}
|
|
}
|
|
|
|
public double TradeOriginalAmount
|
|
{
|
|
get
|
|
{
|
|
if (trade != null && trade.OriginalNotional.HasValue)
|
|
{
|
|
var CountRatio = DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(trade.UnderlyingCode);
|
|
var amount = trade.OriginalNotional.Value / CountRatio;
|
|
return OtcFormatExtensions.OtcFormatValue(PS.Config.IsUseDisplayNotional ? amount * CountRatio : amount, OtcFormatFlag.notional);
|
|
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public double TradeOriginalAmountV
|
|
{
|
|
get
|
|
{
|
|
if (trade != null && trade.OriginalNotional.HasValue)
|
|
{
|
|
double amount = 0;
|
|
var CountRatio = DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(trade.UnderlyingCode);
|
|
if (trade.TradeType == "累计期权")
|
|
{
|
|
amount = trade.OriginalNotional.Value / CountRatio;
|
|
}
|
|
if (trade.SpotPrice.HasValue)
|
|
{
|
|
amount = trade.OriginalStockEqvNotional.Value / trade.SpotPrice.Value / CountRatio;
|
|
}
|
|
var annRate = trade.ParticipationRate * trade.AnnualizeFactor;
|
|
amount = trade.OriginalNotional.Value / (annRate ?? 1) / CountRatio;
|
|
|
|
return PS.Config.IsUseDisplayNotional ? amount * CountRatio : amount;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 年化系数
|
|
/// </summary>
|
|
public string AnnualizeFactor { get; set; }
|
|
|
|
public string ParticipationRate { get; set; }
|
|
|
|
public string PrincipalRate { get; set; }
|
|
|
|
public string NoRiskRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持仓波动率数值
|
|
/// </summary>
|
|
public double VolValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// 持仓波动率
|
|
/// </summary>
|
|
public string Vol { get; set; }
|
|
|
|
/// <summary>
|
|
/// 开仓波动率数值
|
|
/// </summary>
|
|
public double TradeOpenVolatilityValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// 开仓波动率
|
|
/// </summary>
|
|
public string TradeOpenVolatility { get; set; }
|
|
|
|
public string DeltaOriginal { get; set; }
|
|
|
|
public double DeltaOriginalValue => NumberHelper.ToDouble(DeltaOriginal);
|
|
|
|
public string DeltaCashOriginal
|
|
{ get; set; }
|
|
|
|
public string Delta { get; set; }
|
|
|
|
public double DeltaValue => NumberHelper.ToDouble(Delta);
|
|
|
|
public string GammaOriginal { get; set; }
|
|
|
|
public double GammaOriginalValue => NumberHelper.ToDouble(GammaOriginal);
|
|
|
|
public string Gamma { get; set; }
|
|
|
|
public double GammaValue => NumberHelper.ToDouble(Gamma);
|
|
|
|
public string GammaCashOriginal
|
|
{ get; set; }
|
|
|
|
public string Theta { get; set; }
|
|
|
|
public double ThetaValue => NumberHelper.ToDouble(Theta);
|
|
|
|
public string Vega { get; set; }
|
|
|
|
public double VegaValue => NumberHelper.ToDouble(Vega);
|
|
|
|
public string Rho { get; set; }
|
|
|
|
public double RhoValue => NumberHelper.ToDouble(Rho);
|
|
|
|
/// <summary>
|
|
/// 完整的标的代码:代码+点号+市场代码
|
|
/// </summary>
|
|
public string UnderlyingCodeFull =>
|
|
string.IsNullOrEmpty(UnderlyingCode) || string.IsNullOrEmpty(MarketCode) ? UnderlyingCode : UnderlyingCode + "." + MarketCode;
|
|
|
|
/// <summary>
|
|
/// 结算标识(0:正常结算,1:延期结算)
|
|
/// </summary>
|
|
public int SettlementFlag { get; set; }
|
|
|
|
public string SettlementFlagStr
|
|
{
|
|
get
|
|
{
|
|
return SettlementFlag == 1 ? "是" : "否";
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 宏源 A/B团队
|
|
/// </summary>
|
|
public string UserGroup { get; set; }
|
|
|
|
public string UserGroupStr
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(UserGroup) && PS.Config.Is宏源)
|
|
{
|
|
return UserGroup == "A" ? "A团队" : "B团队";
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |