490 lines
16 KiB
C#
490 lines
16 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using YLErp.Commons;
|
|
using YLErp.DBModels.Helpers;
|
|
|
|
namespace YLErp.DBModels
|
|
{
|
|
[Table("variety")]
|
|
[Serializable]
|
|
public class Variety : DBModelWithOperator, IDataEntity, IDataTraceV2, IClonable<Variety>
|
|
{
|
|
public static string LogClass = "品种信息";
|
|
|
|
/// <summary>
|
|
/// 是否有场内期权
|
|
/// </summary>
|
|
[DisplayName("是否有场内期权")]
|
|
public bool? HasFieldOptions { get; set; }
|
|
|
|
[DisplayName("简称")]
|
|
public string ShortName { get; set; }
|
|
|
|
/// <summary>
|
|
/// 数量单位,暂时取 QuoteUnit /后的字母,特别:500千克 鸡蛋,取吨,份数*2
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string QuoteUnitSingle
|
|
{
|
|
get { return VarietyHelper.GetQuoteUnitSingle(QuoteUnit); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 交易单位,暂时取 TradeUnit 中去掉 数字 / 手 元 之后的部分,为了兼容 300元/点 和 20吨/手
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string TradeUnitSingle
|
|
{
|
|
get { return VarietyHelper.GetTradeUnitSingle(TradeUnit); }
|
|
}
|
|
/// <summary>
|
|
/// 数量单位,暂时取 QuoteUnit /后的字母
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string QuoteUnitSingleOriginal
|
|
{
|
|
get { return VarietyHelper.GetQuoteUnitSingleOriginal(QuoteUnit); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 份额对数量的系数,默认都为1,只是鸡蛋的时候为2
|
|
/// TradeAmount = Notional / CountRatio
|
|
/// </summary>
|
|
|
|
[NotMapped]
|
|
public int CountRatio
|
|
{
|
|
get { return VarietyHelper.GetCountRatio(QuoteUnit); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 合约乘数
|
|
/// 获取 TradeUnit 数字 开头的交易单位
|
|
/// 手数(Lots)和份额(notional)的关系
|
|
/// </summary>
|
|
[DisplayName("交易单位")]
|
|
[NotMapped]
|
|
public double? TradeUnitValue
|
|
{
|
|
get { return VarietyHelper.GetTradeUnitValue(VarietyCode, TradeUnit); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 品种代码(唯一)
|
|
/// </summary>
|
|
[DisplayName("品种代码"), Required]
|
|
public string VarietyCode { set; get; }
|
|
|
|
/// <summary>
|
|
/// 品种名称
|
|
/// </summary>
|
|
[DisplayName("品种名称"), Required]
|
|
public string VarietyName { set; get; }
|
|
|
|
/// <summary>
|
|
/// 品种英文名
|
|
/// </summary>
|
|
[NotMapped]
|
|
[DisplayName("品种英文名")]
|
|
public string VarietyEnName { set; get; }
|
|
|
|
/// <summary>
|
|
/// 品种类型
|
|
/// </summary>
|
|
[DisplayName("品种类型")]
|
|
public string AssetType { set; get; }
|
|
|
|
/// <summary>
|
|
/// 大类
|
|
/// </summary>
|
|
[DisplayName("主类型")]
|
|
public string MainCategory { set; get; }
|
|
|
|
/// <summary>
|
|
/// 大类
|
|
/// </summary>
|
|
[DisplayName("主类型")]
|
|
[NotMapped]
|
|
public string MainCategoryDesc
|
|
{
|
|
get
|
|
{
|
|
return ConsGlobal.MainCategory.GetDesc(MainCategory);
|
|
}
|
|
}
|
|
|
|
[DisplayName("交易市场")]
|
|
public int? TradingMarketId { get; set; }
|
|
/// <summary>
|
|
/// 交易市场
|
|
/// </summary>
|
|
[DisplayName("交易市场")]
|
|
public string TradingMarket { set; get; }
|
|
|
|
[NotMapped]
|
|
[DisplayName("交易市场代码")]
|
|
public string TradingMarketNo { get; set; }
|
|
/// <summary>
|
|
/// 交易单位
|
|
/// </summary>
|
|
[DisplayName("交易单位")]
|
|
public string TradeUnit { set; get; }
|
|
/// <summary>
|
|
/// 报价单位
|
|
/// </summary>
|
|
[DisplayName("报价单位")]
|
|
public string QuoteUnit { set; get; }
|
|
/// <summary>
|
|
/// 单位英文描述
|
|
/// </summary>
|
|
[NotMapped]
|
|
[DisplayName("单位英文描述")]
|
|
public string EnUnit { set; get; }
|
|
/// <summary>
|
|
/// 最小变动价位
|
|
/// </summary>
|
|
[DisplayName("最小变动价位")]
|
|
public string MinPriceChange { set; get; }
|
|
/// <summary>
|
|
/// 涨停幅度
|
|
/// </summary>
|
|
[DisplayName("Span涨跌幅度")]
|
|
public string UpLimit { set; get; }
|
|
/// <summary>
|
|
/// 跌停幅度
|
|
/// </summary>
|
|
[DisplayName("跌停幅度")]
|
|
public string DownLimit { set; get; }
|
|
/// <summary>
|
|
/// 最低预付金
|
|
/// </summary>
|
|
[DisplayName("最低预付金")]
|
|
public double? Margin { set; get; }
|
|
/// <summary>
|
|
/// 描述
|
|
/// </summary>
|
|
[DisplayName("描述")]
|
|
public string Description { set; get; }
|
|
/// <summary>
|
|
/// 合约月份
|
|
/// </summary>
|
|
[DisplayName("合约月份")]
|
|
public string ContractMonth { set; get; }
|
|
/// <summary>
|
|
/// 交易时间段
|
|
/// </summary>
|
|
[DisplayName("交易时间段")]
|
|
public string TradeTimeSlot { set; get; }
|
|
/// <summary>
|
|
/// 交割类型
|
|
/// </summary>
|
|
[DisplayName("交割类型")]
|
|
public string DeliveryType { set; get; }
|
|
/// <summary>
|
|
/// 交割地点
|
|
/// </summary>
|
|
[DisplayName("交割地点")]
|
|
public string DeliveryPlace { set; get; }
|
|
/// <summary>
|
|
/// 交割等级
|
|
/// </summary>
|
|
[DisplayName("交割等级")]
|
|
public string DeliveryGrade { set; get; }
|
|
/// <summary>
|
|
/// 最小交割单位
|
|
/// </summary>
|
|
[DisplayName("最小交割单位")]
|
|
public string MiniDeliveryUnit { set; get; }
|
|
/// <summary>
|
|
/// 有无夜盘
|
|
/// </summary>
|
|
[DisplayName("有无夜盘")]
|
|
public bool HasNightMarket { set; get; }
|
|
[DisplayName("手续费类型")]
|
|
public string CommissionType { get; set; }
|
|
[DisplayName("手续费")]
|
|
public double? Commission { get; set; }
|
|
[DisplayName("交易所手续费")]
|
|
public double? CommissionExchange { get; set; }
|
|
[DisplayName("手续费偏离值")]
|
|
public double? CommissionDeviation { get; set; }
|
|
[DisplayName("平今仓手续费类型")]
|
|
public string CloseTodayCommissionType { get; set; }
|
|
[DisplayName("平今仓手续费")]
|
|
public double? CloseTodayCommission { get; set; }
|
|
[DisplayName("交易所平今仓手续费")]
|
|
public double? CloseTodayCommissionExchange { get; set; }
|
|
[DisplayName("平今仓手续费偏离值")]
|
|
public double? CloseTodayCommissionDeviation { get; set; }
|
|
[DisplayName("平今仓手续费合约规则")]
|
|
public string CloseTodayContractRule { get; set; }
|
|
[DisplayName("场内期权手续费类型")]
|
|
public string TradedOptionCommissionType { get; set; }
|
|
[DisplayName("场内期权手续费")]
|
|
public double? TradedOptionCommission { get; set; }
|
|
[DisplayName("交易所场内期权手续费")]
|
|
public double? TradedOptionCommissionExchange { get; set; }
|
|
[DisplayName("场内期权手续费偏离值")]
|
|
public double? TradedOptionCommissionDeviation { get; set; }
|
|
|
|
//[DisplayName("标的资产类型")]
|
|
//public string UnderlyingInstrumentType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 敞口限额
|
|
/// </summary>
|
|
[DisplayName("敞口限额")]
|
|
public double? VarietyOpenLimit { get; set; }
|
|
|
|
/// <summary>
|
|
/// BBG Ticker
|
|
/// </summary>
|
|
[DisplayName("BBG Ticker")]
|
|
public string BBGTicker { get; set; }
|
|
|
|
/// <summary>
|
|
/// 计价货币
|
|
/// </summary>
|
|
[DisplayName("计价货币")]
|
|
public string QuoteCurrency { get; set; }
|
|
|
|
/// <summary>
|
|
/// 指数类型
|
|
/// </summary>
|
|
[DisplayName("指数类型")]
|
|
public string IndexType { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 敞口金额是否为百分比格式
|
|
/// </summary>
|
|
[DisplayName("敞口金额是否为百分比格式")]
|
|
public bool? IsVarietyOpenLimitPercent { set; get; }
|
|
|
|
//[DisplayName("标的种类")]
|
|
//[NotMapped]
|
|
//public string UnderlyingInstrumentTypeName
|
|
//{
|
|
// get
|
|
// {
|
|
// switch (UnderlyingInstrumentType)
|
|
// {
|
|
// case ConsGlobal.InstrumentType.Stock: return "股票";
|
|
// case ConsGlobal.InstrumentType.CommodityFutures: return "商品期货";
|
|
// case ConsGlobal.InstrumentType.CommoditySpot: return "商品现货";
|
|
// default: return "其它";
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
public double UpLimitValue
|
|
{
|
|
get
|
|
{
|
|
return string.IsNullOrWhiteSpace(UpLimit) ? 0 : OtcFormatHelper.FormatValue(NumberHelper.ToDouble(UpLimit.Replace("%", string.Empty)) / 100, 8);
|
|
}
|
|
}
|
|
|
|
public double DownLimitValue
|
|
{
|
|
get
|
|
{
|
|
return string.IsNullOrWhiteSpace(DownLimit) ? 0 : OtcFormatHelper.FormatValue(NumberHelper.ToDouble(DownLimit.Replace("%", string.Empty)) / 100, 8);
|
|
}
|
|
}
|
|
|
|
|
|
[DisplayName("Span波动率变动")]
|
|
public string VolatilityRate { get; set; }
|
|
|
|
public double VolatilityRateValue
|
|
{
|
|
get
|
|
{
|
|
return string.IsNullOrWhiteSpace(VolatilityRate) ? 0 : OtcFormatHelper.FormatValue(NumberHelper.ToDouble(VolatilityRate.Replace("%", string.Empty)) / 100, 8);
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 手续费
|
|
/// </summary>
|
|
[DisplayName("手续费")]
|
|
public string CommissionForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!Commission.HasValue) return null;
|
|
return CommissionType == ConsCommissionType.Ratio ? $"{OtcFormatHelper.FormatValue(Commission.Value * 10000, 8)}‱" : Commission.Value.ToString();
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 场内期权手续费
|
|
/// </summary>
|
|
[DisplayName("场内期权手续费")]
|
|
public string TradedOptionCommissionForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!TradedOptionCommission.HasValue) return null;
|
|
return TradedOptionCommissionType == ConsCommissionType.Ratio
|
|
? $"{OtcFormatHelper.FormatValue(TradedOptionCommission.Value * 10000, 8)}‱"
|
|
: TradedOptionCommission.Value.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 平今手续费
|
|
/// </summary>
|
|
[DisplayName("平今仓手续费")]
|
|
public string CloseTodayCommissionForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!CloseTodayCommission.HasValue) return null;
|
|
return CloseTodayCommissionType == ConsCommissionType.Ratio
|
|
? $"{OtcFormatHelper.FormatValue(CloseTodayCommission.Value * 10000, 8)}‱"
|
|
: $"{CloseTodayCommission.Value}";
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 手续费
|
|
/// </summary>
|
|
[DisplayName("交易所手续费")]
|
|
public string CommissionExchangeForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!CommissionExchange.HasValue) return null;
|
|
return CommissionType == ConsCommissionType.Ratio ? $"{OtcFormatHelper.FormatValue(CommissionExchange.Value * 10000, 8)}‱" : CommissionExchange.Value.ToString();
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 场内期权手续费
|
|
/// </summary>
|
|
[DisplayName("交易所场内期权手续费")]
|
|
public string TradedOptionCommissionExchangeForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!TradedOptionCommissionExchange.HasValue) return null;
|
|
return TradedOptionCommissionType == ConsCommissionType.Ratio
|
|
? $"{OtcFormatHelper.FormatValue(TradedOptionCommissionExchange.Value * 10000, 8)}‱"
|
|
: TradedOptionCommissionExchange.Value.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 平今手续费
|
|
/// </summary>
|
|
[DisplayName("交易所平今仓手续费")]
|
|
public string CloseTodayCommissionExchangeForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!CloseTodayCommissionExchange.HasValue) return null;
|
|
return CloseTodayCommissionType == ConsCommissionType.Ratio
|
|
? $"{OtcFormatHelper.FormatValue(CloseTodayCommissionExchange.Value * 10000, 8)}‱"
|
|
: $"{CloseTodayCommissionExchange.Value}";
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 手续费
|
|
/// </summary>
|
|
[DisplayName("手续费偏离值")]
|
|
public string CommissionDeviationForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!CommissionDeviation.HasValue) return null;
|
|
return CommissionType == ConsCommissionType.Ratio ? $"{OtcFormatHelper.FormatValue(CommissionDeviation.Value * 10000, 8)}‱" : CommissionDeviation.Value.ToString();
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 场内期权手续费
|
|
/// </summary>
|
|
[DisplayName("场内期权手续费偏离值")]
|
|
public string TradedOptionCommissionDeviationForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!TradedOptionCommissionDeviation.HasValue) return null;
|
|
return TradedOptionCommissionType == ConsCommissionType.Ratio
|
|
? $"{OtcFormatHelper.FormatValue(TradedOptionCommissionDeviation.Value * 10000, 8)}‱"
|
|
: TradedOptionCommissionDeviation.Value.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
[NotMapped]
|
|
/// <summary>
|
|
/// 万分之一单位 平今手续费
|
|
/// </summary>
|
|
[DisplayName("平今仓手续费偏离值")]
|
|
public string CloseTodayCommissionDeviationForTenThousandth
|
|
{
|
|
get
|
|
{
|
|
if (!CloseTodayCommissionDeviation.HasValue) return null;
|
|
return CloseTodayCommissionType == ConsCommissionType.Ratio
|
|
? $"{OtcFormatHelper.FormatValue(CloseTodayCommissionDeviation.Value * 10000, 8)}‱"
|
|
: $"{CloseTodayCommissionDeviation.Value}";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 波动率调整(风险计算用)
|
|
/// </summary>
|
|
public double VolatilityAdjust { get; set; }
|
|
|
|
public Variety Clone()
|
|
{
|
|
return (Variety)MemberwiseClone();
|
|
}
|
|
|
|
public string GetDataTraceKeyId()
|
|
{
|
|
return id.ToString();
|
|
}
|
|
|
|
public string GetDataTraceKeyInfo()
|
|
{
|
|
return "标的品种:" + VarietyCode;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return id + "--" + VarietyCode;
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public class VarietyDto : Variety
|
|
{
|
|
public IEnumerable<HistoryData> HisDataList { get; set; }
|
|
}
|
|
|
|
public class VarietyBasic
|
|
{
|
|
public string VarietyCode { get; set; }
|
|
|
|
public double? TradeUnitValue { get; set; }
|
|
|
|
public int CountRatio { get; set; }
|
|
}
|
|
}
|