Files
zszq-trs/Framework/YLErp.Core/DBModels/Consts/ConsTrade.cs
T

463 lines
21 KiB
C#

using YLErp.Models;
namespace YLErp.DBModels
{
public static class ConsTrade
{
public const string 确认成交 = "确认成交";
public const string 新增待确认 = "新增待确认";
public const string 修改待确认 = "修改待确认";
public const string 期初价格已确认 = "期初价格已确认";
public const string 未确认 = "未确认";
public const string 审批中 = "审批中";
public const string 已到期 = "已到期";
public const string 已执行 = "已执行";
public const string 已平仓 = "已平仓";
public const string 平仓待复核 = "平仓待复核";
public const string 提前终止拒绝 = "提前终止拒绝";
public const string 行权待复核 = "行权待复核";
public const string 互换待复核 = "互换待复核";
public static readonly string 已拒绝 = "已拒绝";//审批用
public static readonly string 已除权 = "已除权";
public static readonly string 已回退 = "已回退";
/// <summary>
/// 数据表名称
/// </summary>
public const string TableName = "trade";
/// <summary>
/// 已完成的订单状态 已到期, 已执行, 已平仓,不允许再修改
/// </summary>
public static readonly List<string> TradeCompleteStatus = new List<string> { 已到期, 已执行, 已平仓 };
public static readonly List<string> AllTradeStatus = new List<string> { 确认成交, 新增待确认, 修改待确认, 审批中, 已拒绝, 已执行, 已平仓, 已到期, 平仓待复核, 行权待复核, 互换待复核, 提前终止拒绝 };
//所有确认成交之后的状态
public static readonly List<string> TradeStatusAfterConfirmed = new List<string> { 确认成交, 已执行, 已平仓, 已到期, 平仓待复核, 行权待复核, 互换待复核, 提前终止拒绝 };
//所有确认成交之后的状态(不包含确认成交)
public static readonly List<string> TradeStatusAfterAndWithOutConfirmed = new List<string> { 已执行, 已平仓, 已到期, 平仓待复核, 行权待复核, 互换待复核, 提前终止拒绝 };
/// <summary>
/// Live trade state
/// </summary>
public static readonly List<string> TradeStatusBeforConfirmed = new List<string> { 新增待确认, 修改待确认, 审批中, 已拒绝 };
public static readonly List<string> TradeStatusBeforConfirmedAndConfirmed = new List<string> { 新增待确认, 修改待确认, 审批中, 已拒绝, 确认成交 };
public static readonly List<string> LiveTradeStatusList = new List<string> { 确认成交, 新增待确认, 修改待确认, 审批中, 平仓待复核, 提前终止拒绝, 行权待复核, 互换待复核 };
public static readonly List<string> NeedMarginTradeStatusList = new List<string> { 确认成交, 平仓待复核, 提前终止拒绝, 行权待复核, 互换待复核 };
public static readonly List<string> TradeStatusList = new List<string> { 新增待确认, 修改待确认, 确认成交, 已执行, 已到期, 已平仓 };
public static readonly List<string> PositionTradeStatusList = new List<string>() { 确认成交, 平仓待复核, 行权待复核, 互换待复核, 提前终止拒绝 };
public static readonly List<string> BondTypeList = new List<string> { "利率债", "信用债", "其它债券" };
/// <summary>
/// 待确认状态
/// </summary>
public static readonly List<string> UnConfirmTradeStatusList = new List<string> { 新增待确认, 修改待确认, 已拒绝 };
/// <summary>
/// 光子并表状态
/// </summary>
public static readonly List<string> TradeStatusCustomexport = new List<string> { 确认成交, 已执行, 已到期, 已平仓 };
//"彩虹期权", "价差期权",
public static readonly IReadOnlyList<string> AllTradeTypes = new List<string> {
"香草期权", "障碍期权", "二元期权", "亚式期权", "合成价差期权", "双鲨期权","Risky期权",
"凤凰期权", "雪球期权","累计期权","区间累积期权","气囊结构","收益增强结构","自定义交易",
"牛市价差", "熊市价差", "亚式熊市价差", "跨式组合", "宽跨式组合", "蝶式组合","风险逆转",
"远期", "掉期", "收益互换", "现金流交易","场内期权","商品期货", "商品现货", "股票"
};
//,"彩虹期权", "价差期权"
public static readonly List<string> TradeTypesForOtcOptions = new List<string> {
"香草期权", "障碍期权", "二元期权", "亚式期权","合成价差期权", "双鲨期权","Risky期权",
"凤凰期权", "雪球期权","区间累积期权","气囊结构", "累计期权","收益增强结构","现金流交易","自定义交易"
};
//"彩虹期权", "价差期权",
public static readonly List<string> OptionTradeTypeWithPricingModel = new List<string> {
"香草期权", "障碍期权", "二元期权", "亚式期权","合成价差期权", "双鲨期权","Risky期权",
"凤凰期权", "雪球期权", "区间累积期权", "气囊结构", "收益增强结构","现金流交易"
};
public static readonly List<string> HasBarrierPriceOptions = new List<string> {
"障碍期权", "二元期权", "双鲨期权","凤凰期权", "雪球期权", "气囊结构", "累计期权"};
public static readonly List<string> HasCouponOptions = new List<string> {
"障碍期权", "二元期权", "双鲨期权","凤凰期权", "雪球期权","区间累积期权","气囊结构","累计期权"};
public static readonly List<string> HasMinusValueOptions = new List<string> {
"凤凰期权", "雪球期权", "自定义交易", "累计期权"
};
public static readonly IReadOnlyList<string> OptionTradeTypeUsed =
OptionTradeTypeWithPricingModel.Where(n => n != "彩虹期权" && n != "价差期权").Concat(new[] { "自定义交易" }).ToList().AsReadOnly();
// OTC-4032 只保留XX期权和结构化交易
public static readonly List<string> OptionTradeTypes = new List<string> { "香草期权", "障碍期权", "二元期权", "亚式期权", "彩虹期权", "价差期权", "合成价差期权","Risky期权",
"牛市价差", "熊市价差", "亚式熊市价差", "跨式组合", "宽跨式组合", "复制标的资产", "蝶式组合", "飞鹰式组合", "比例价差", "日历价差", "箱式价差", "风险逆转", "三领口组合",
"双鲨期权", "区间累积期权", "凤凰期权", "雪球期权", "气囊结构","累计期权", "收益增强结构", "现金流交易", "自定义交易","结构化交易" };
//OTC-4042 组合交易类型
public static readonly List<string> CombineOptionStructures = new List<string> {"自由组合",
"牛市价差", "熊市价差", "跨式组合", "宽跨式组合", "复制标的资产", "蝶式组合", "飞鹰式组合", "比例价差", "日历价差", "箱式价差", "风险逆转", "三领口组合" };
/// <summary>
/// 对冲结构类型
/// </summary>
public static readonly List<string> TradeTypesForHedge = new List<string> { "商品期货", "商品现货", "股票", "场内期权","信用债" };
/// <summary>
/// 非期权结构类型(包括结构化交易)
/// </summary>
public static readonly List<string> NonOptionTradeTypes = new List<string> { "收益互换", "远期", "掉期", "结构化交易", "SWAP" };
//可以删除TradeCash的交易状态
public static readonly List<string> CantDeleteTradeCash = new List<string> { 确认成交, 已拒绝, 已执行, 已平仓, 已到期, 平仓待复核, 行权待复核, 互换待复核, 提前终止拒绝 };
/// <summary>
/// 价差期权类型
/// </summary>
public static readonly List<string> SpreadPayoffTypes = new List<string> { "S1-S2", "S1-S2-S3", "S1-S2-S3", "S1+S2-S3", "S1-S2-S3-S4", "S1+S2-S3-S4", "S1+S2+S3-S4" };
public static readonly List<string> TradeTypesForStockRiskHedging = new List<string> { "香草期权", "亚式期权", "商品期货", "股票", "信用债" };
public static readonly List<string> BarrierTypes = new List<string> { "上升敲入", "上升敲出", "下降敲入", "下降敲出", "双障碍敲入", "双障碍敲出" };
/// <summary>
/// 互换利率端计息方式
/// </summary>
public static readonly List<int> InterestModels = new List<int>() { (int)InterestModeEnum.固定值, (int)InterestModeEnum.合约名义本金规模, (int)InterestModeEnum.空头存续名义本金,(int)InterestModeEnum.多头存续名义本金, (int)InterestModeEnum.标的期初全价 };
/// <summary>
/// 互换利率端计息方式-名义本金相关
/// </summary>
public static readonly List<int> InterestNotionalModels = new List<int>() {(int)InterestModeEnum.合约名义本金规模, (int)InterestModeEnum.空头存续名义本金, (int)InterestModeEnum.多头存续名义本金, (int)InterestModeEnum.标的期初全价 };
/// <summary>
/// 互换利率计息方式 预付金
/// </summary>
public static readonly List<int> InterestMarginModels = new List<int>() { (int)InterestModeEnum.初始预付金, (int)InterestModeEnum.追加预付金};
#region----买入卖出BuySellType----
/// <summary>
/// 买入卖出
/// </summary>
public static class BuySellType
{
public const string Buy = "买入";
public const string Sell = "卖出";
//用于场内对冲交易买卖类型
public const string LongOpen = "多头开仓";
public const string LongClose = "多头平仓";
public const string ShortOpen = "空头开仓";
public const string ShortClose = "空头平仓";
public static IEnumerable<SelectItem> GetSelectItems(bool forExchangeTrade = false)
{
if (forExchangeTrade)
{
return new[] {
new SelectItem{ Value= LongOpen, Text= LongOpen },
new SelectItem{ Value= LongClose, Text= LongClose },
new SelectItem{ Value= ShortOpen, Text= ShortOpen },
new SelectItem{ Value= ShortClose, Text= ShortClose }
};
}
return new[] {
new SelectItem{ Value= Sell, Text= Sell },
new SelectItem{ Value= Buy, Text= Buy }
};
}
}
#endregion
#region----开仓平仓OpenClose----
/// <summary>
/// 开仓平仓
/// </summary>
public static class OpenClose
{
public const string Open = "开仓";
public const string Close = "平仓";
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= Open, Text= Open },
new SelectItem{ Value= Close, Text= Close }
};
}
}
#endregion
#region----多头空头LongShort----
/// <summary>
/// 多头空头
/// </summary>
public static class LongShort
{
public const string Long = "多头";
public const string Short = "空头";
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= Long, Text= Long },
new SelectItem{ Value= Short, Text= Short }
};
}
}
#endregion
#region----看涨看跌OptionType----
/// <summary>
/// 看涨看跌
/// </summary>
public static class OptionType
{
public const string Call = "看涨";
public const string Put = "看跌";
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= Call, Text= Call },
new SelectItem{ Value= Put, Text= Put }
};
}
}
#endregion
#region----行权方式ExerciseType----
/// <summary>
/// 行权方式
/// </summary>
public static class ExerciseType
{
public const string European = "European";
public const string American = "American";
public static string GetDesc(string type)
{
switch (type)
{
case American: return "美式";
case European: return "欧式";
default: return type ?? string.Empty;
}
}
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= European, Text= "欧式" },
new SelectItem{ Value= American, Text= "美式" }
};
}
}
#endregion
#region----敲入敲出状态KnockState----
/// <summary>
/// 敲入敲出状态
/// </summary>
public static class KnockState
{
public const string 观察中 = "观察中";
public const string Monitoring = "Monitoring";
public const string KnockedIn = "KnockedIn";
public const string KnockedOut = "KnockedOut";
public static string GetDesc(string type)
{
switch (type)
{
case KnockedIn: return "敲入";
case KnockedOut: return "敲出";
case Monitoring: return "观察中";
default: return type ?? "";
}
}
public static bool IsMonitoring(string type)
{
return type == Monitoring || type == 观察中;
}
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= 观察中, Text= "观察中"},
new SelectItem{ Value= KnockedIn, Text= "敲入"},
new SelectItem{ Value= KnockedOut, Text= "敲出"}
};
}
}
#endregion
#region----亚式期权均价计算类型AsianAverageType----
/// <summary>
/// 亚式期权均价计算类型
/// </summary>
public static class AsianAverageType
{
public const string ArithmeticAverage = "ArithmeticAverage";
public const string GeometricAverage = "GeometricAverage";
public const string DiscreteArithmeticAverage = "DiscreteArithmeticAverage";
public const string EnhancedArithmeticAverage = "EnhancedArithmeticAverage";
public const string DiscreteGeometricAverage = "DiscreteGeometricAverage";
public static string GetDesc(string type)
{
switch (type)
{
case ArithmeticAverage: return "算术平均";
case GeometricAverage: return "几何平均";
case DiscreteArithmeticAverage: return "算术平均(离散)";
case EnhancedArithmeticAverage: return "增强算术平均";
case DiscreteGeometricAverage: return "几何平均(离散)";
default: return type ?? "";
}
}
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= ArithmeticAverage, Text= "算术平均"},
new SelectItem{ Value= GeometricAverage, Text= "几何平均"},
new SelectItem{ Value= DiscreteArithmeticAverage, Text= "算术平均(离散)"},
new SelectItem{ Value= EnhancedArithmeticAverage, Text= "增强算术平均"},
};
}
}
#endregion
#region----亚式期权行权价类型AsiaStrikeType----
/// <summary>
/// 亚式期权行权价类型
/// </summary>
public static class AsiaStrikeType
{
public const string Fixed = "Fixed";
public const string Floating = "Floating";
public const string Segmented = "Segmented";
public static string GetDesc(string type)
{
switch (type)
{
case Fixed: return "固定行权价";
case Floating: return "浮动行权价";
case Segmented: return "分段式";
default: return type ?? "";
}
}
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= Fixed, Text= "固定行权价"},
new SelectItem{ Value= Floating, Text= "浮动行权价"},
new SelectItem{ Value= Segmented, Text= "分段式"}
};
}
}
#endregion
#region----补偿支付方式RebateType----
/// <summary>
/// 补偿支付方式
/// </summary>
public static class RebateType
{
public const string AtEnd = "AtEnd";
public const string AtHit = "AtHit";
public static string GetDesc(string type)
{
switch (type)
{
case AtEnd: return "递延";
case AtHit: return "立即";
default: return type ?? string.Empty;
}
}
public static IEnumerable<SelectItem> GetSelectItems()
{
return new[] {
new SelectItem{ Value= AtEnd, Text= "递延" },
new SelectItem{ Value= AtHit, Text= "立即" }
};
}
}
#endregion
public static readonly List<string> RainbowTypes = new List<string> { "Max", "Min", "BestOfAssetsOrCash", "BestCashOrNothing", "WorstCashOrNothing", "TwoAssetsCashOrNothing", "TwoAssetsCashOrNothingUpDown", "TwoAssetsCashOrNothingDownUp" };
public static readonly List<string> BinaryEuropeanPayoffTypes = new List<string> { "CashOrNothing", "AssetOrNothing" };
public static readonly List<string> BinaryAmericanPayoffTypes = new List<string> { "UpOneTouch", "DownOneTouch", "UpNoTouch", "DownNoTouch", "DoubleOneTouch", "DoubleNoTouch" };
public static readonly List<string> DiscreteTypes = new List<string> { "离散", "连续" };
/// <summary>
/// 默认情景分析参数
/// </summary>
public static readonly List<double> PriceRate = new List<double> { -0.3, -0.2, -0.1, -0.05, 0, 0.05, 0.1, 0.2, 0.3 };
/// <summary>
/// 默认情景分析参数
/// </summary>
public static readonly List<double> VolRate = new List<double> { 0.20, 0.15, 0.10, 0.05, 0, -0.05, -0.10, -0.15, -0.20 };
/// <summary>
/// 用户自定义结构的定价方式
/// </summary>
public static readonly Dictionary<string, string> UserDefinedPricingMethods = new Dictionary<string, string> { { "无", UserDefinedPricingMethod.None.ToString() }, { "通用蒙特卡洛", UserDefinedPricingMethod.GenericMonteCarlo.ToString() }, { "外部计算服务", UserDefinedPricingMethod.ExternalService.ToString() } };
public static readonly List<string> PriceDistributions = new List<string> { "LogNormal" };
public static readonly List<string> UserDefinedFieldTypes = GenerateSelectListFromEnum(typeof(OptionFieldType));
/// <summary>
/// 非默认的定价模型名称映射关系
/// </summary>
public static string GetEngineName(string engineName)
{
switch (engineName)
{
case "二叉树":
case "BinomialTreeAmericanEngine":
return "BinomialTreeAmericanEngine";
case "蒙特卡洛":
case "GbmMonteCarloEngine":
return "GbmMonteCarloEngine";
default: return null;
}
}
private static List<string> GenerateSelectListFromEnum(Type enumType)
{
return Enum.GetNames(enumType).ToList();
}
}
}