388 lines
12 KiB
C#
388 lines
12 KiB
C#
using YLErp.Modules;
|
|
|
|
namespace YLErp.Model
|
|
{
|
|
public class trade_contract_group
|
|
{
|
|
public int id { get; set; }
|
|
|
|
public trade trade { get; set; }
|
|
|
|
public trade_cash trade_cash { get; set; }
|
|
|
|
public trade_span trade_span { get; set; }
|
|
|
|
/// <summary>
|
|
/// 结算确认书
|
|
/// </summary>
|
|
public trade_contract_r trade_contract_r { get; set; }
|
|
|
|
/// <summary>
|
|
/// 交易确认书
|
|
/// </summary>
|
|
public trade_contract_r ConfirmContractR { get; set; }
|
|
|
|
public underlying_manager underlying_manager { get; set; }
|
|
|
|
public trade_contract_document trade_contract_document { get; set; }
|
|
|
|
public string TradeType => trade?.TradeType;
|
|
|
|
public string ContractCode { get; set; }
|
|
|
|
public string ContractDocUrl { get; set; }
|
|
|
|
public double? UnwindVol { get; set; }
|
|
|
|
public string ClientName { get; set; }
|
|
|
|
public string UnwindVolString
|
|
{
|
|
get
|
|
{
|
|
if (trade_cash?.Action == "系统操作-行权费")
|
|
{
|
|
return "----";
|
|
}
|
|
return (UnwindVol ?? 0).OtcFormat(OtcFormatFlag.premiumRateP);
|
|
}
|
|
}
|
|
|
|
private double? winloss;
|
|
|
|
/// <summary>
|
|
/// 实现盈亏(客户角度看的)
|
|
/// </summary>
|
|
public double WinLoss
|
|
{
|
|
get
|
|
{
|
|
if (winloss != null)
|
|
{
|
|
return winloss.Value;
|
|
}
|
|
return -(trade_cash.Amount + (trade.TradePrice ?? 0) * (trade_cash.UnwindPercentRate ?? 0) * ((trade.BuySell == "卖出" || trade.TradeType == "远期") ? 1 : -1));
|
|
}
|
|
set => winloss = value;
|
|
}
|
|
|
|
public double? TradeOriginalAmount
|
|
{
|
|
get
|
|
{
|
|
if (trade != null)
|
|
{
|
|
var CountRatio = DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(trade.UnderlyingCode);
|
|
return PS.Config.IsUseDisplayNotional ? trade.TradeOriginalAmount * CountRatio : trade.TradeOriginalAmount;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
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 BuySell => trade != null ? trade.BuySell == "买入" ? "卖出" : "买入" : null;
|
|
|
|
public double? TradePrice
|
|
{
|
|
get
|
|
{
|
|
if (trade != null)
|
|
{
|
|
if (trade.TradeType == "远期")
|
|
{
|
|
return trade.TradePrice * -1;//历史交易页面显示为 开仓总费用
|
|
}
|
|
else
|
|
{
|
|
return trade.TradePrice * ("卖出".Equals(trade.BuySell) ? -1 : 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string TradeMultipleType
|
|
{
|
|
get
|
|
{
|
|
if (trade?.TradeType == "自定义交易" && !string.IsNullOrWhiteSpace(trade.StructureType))
|
|
{
|
|
return trade.StructureType;
|
|
}
|
|
return trade?.TradeMultipleType;
|
|
}
|
|
}
|
|
|
|
public int CountRatio { get; set; }
|
|
|
|
public string SealResult { get; set; }
|
|
|
|
public string SealTime { get; set; }
|
|
}
|
|
|
|
public class trade_contract_group_simple
|
|
{
|
|
public int id { get; set; }
|
|
|
|
public trade trade { get; set; }
|
|
|
|
public trade_cash trade_cash { get; set; }
|
|
|
|
public trade_span trade_span { get; set; }
|
|
|
|
public underlying_manager underlying_manager { get; set; }
|
|
|
|
public string TradeType => trade?.TradeType;
|
|
|
|
public string ContractCode { get; set; }
|
|
|
|
public string ContractDocUrl { get; set; }
|
|
|
|
public double? UnwindVol { get; set; }
|
|
|
|
public string ClientName { get; set; }
|
|
|
|
public string UnwindVolString
|
|
{
|
|
get
|
|
{
|
|
if (trade_cash?.Action == "系统操作-行权费")
|
|
{
|
|
return "----";
|
|
}
|
|
return (UnwindVol ?? 0).OtcFormat(OtcFormatFlag.premiumRateP);
|
|
}
|
|
}
|
|
|
|
private double? winloss;
|
|
|
|
/// <summary>
|
|
/// 实现盈亏(客户角度看的)
|
|
/// </summary>
|
|
public double WinLoss
|
|
{
|
|
get
|
|
{
|
|
if (winloss != null)
|
|
{
|
|
return winloss.Value;
|
|
}
|
|
return -(trade_cash.Amount + (trade.TradePrice ?? 0) * (trade_cash.UnwindPercentRate ?? 0) * ((trade.BuySell == "卖出" || trade.TradeType == "远期") ? 1 : -1));
|
|
}
|
|
set => winloss = value;
|
|
}
|
|
|
|
public double? TradeOriginalAmount
|
|
{
|
|
get
|
|
{
|
|
if (trade != null)
|
|
{
|
|
var CountRatio = DataCacheProvider.GetUnderlyingDataSource().GetCountRatio(trade.UnderlyingCode);
|
|
return PS.Config.IsUseDisplayNotional ? trade.TradeOriginalAmount * CountRatio : trade.TradeOriginalAmount;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
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 BuySell => trade != null ? trade.BuySell == "买入" ? "卖出" : "买入" : null;
|
|
|
|
public double? TradePrice
|
|
{
|
|
get
|
|
{
|
|
if (trade != null)
|
|
{
|
|
if (trade.TradeType == "远期")
|
|
{
|
|
return trade.TradePrice * -1;//历史交易页面显示为 开仓总费用
|
|
}
|
|
else
|
|
{
|
|
if (trade.TradePrice == null) trade.TradePrice = 0;
|
|
return trade.TradePrice * ("卖出".Equals(trade.BuySell) ? -1 : 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 某些情况下需要处理后显示的交易状态
|
|
/// </summary>
|
|
public string TradeStatusShow { get; set; }
|
|
|
|
public string TradeMultipleType
|
|
{
|
|
get
|
|
{
|
|
if (trade?.TradeType == "自定义交易" && !string.IsNullOrWhiteSpace(trade.StructureType))
|
|
{
|
|
return trade.StructureType;
|
|
}
|
|
return trade?.TradeMultipleType;
|
|
}
|
|
}
|
|
|
|
public Dictionary<string, string> dic { get; set; }
|
|
|
|
public int CountRatio { get; set; }
|
|
/// <summary>
|
|
/// 累计了结时相应的乘数(标准累计:看涨乘数,看跌乘数;三段式:乘数1,乘数2,乘数3) 当乘数为0不处理
|
|
/// </summary>
|
|
public double ACCMultiplier { get; set; }
|
|
|
|
/// <summary>
|
|
/// 完整的标的代码:代码+点号+市场代码
|
|
/// </summary>
|
|
public string UnderlyingCodeFull =>
|
|
string.IsNullOrEmpty(trade.UnderlyingCode) || string.IsNullOrEmpty(underlying_manager.MarketCode) ? trade.UnderlyingCode : trade.UnderlyingCode + "." + underlying_manager.MarketCode;
|
|
//成交日
|
|
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 UnWindDate => trade != null && trade.UnWindDate != null ? trade.UnWindDate.Value.ToString("yyyy-MM-dd") : "";
|
|
//了结数量
|
|
public double? UnwindTradeAmount
|
|
{
|
|
get
|
|
{
|
|
if (trade_cash != null)
|
|
{
|
|
return OtcFormatExtensions.OtcFormatValue(PS.Config.IsUseDisplayNotional ? trade_cash.UnwindNotional : trade_cash.UnwindNotional / CountRatio, OtcFormatFlag.notional);
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public double Strike => trade != null ? ((trade.IsMoneynessOptionData ? trade.Strike * trade.SpotPrice : trade.Strike) ?? 0) : 0;
|
|
public string StrikeString => Strike.OtcFormatUmPrice(); //执行价
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public class trade_contract_groupGridSum
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 名义本金合计
|
|
/// </summary>
|
|
public double? StockEqvNotionalSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 交易总额合计
|
|
/// </summary>
|
|
public double? TradePriceSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 了结总额合计
|
|
/// </summary>
|
|
public double? MinusAmountSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 盈亏合计
|
|
/// </summary>
|
|
public double? WinLossSum { get; set; }
|
|
|
|
/// <summary>
|
|
/// 盈亏合计(结算)
|
|
/// </summary>
|
|
public double? QuoteWinLossSum { get; set; }
|
|
}
|
|
}
|