891 lines
32 KiB
C#
891 lines
32 KiB
C#
using System.Runtime.CompilerServices;
|
|
using YLErp.Models;
|
|
|
|
namespace YLErp
|
|
{
|
|
/// <summary>
|
|
/// 全局常量定义
|
|
/// </summary>
|
|
public static class ConsGlobal
|
|
{
|
|
/// <summary>
|
|
/// 默认波动率
|
|
/// </summary>
|
|
public const double DefaultVol = 0.3;
|
|
|
|
/// <summary>
|
|
/// 默认日历
|
|
/// </summary>
|
|
public const string DefaultCalendar = "chn";
|
|
|
|
/// <summary>
|
|
/// 日期格式:yyyy-MM-dd
|
|
/// </summary>
|
|
public const string DateFormat = "yyyy-MM-dd";
|
|
|
|
/// <summary>
|
|
/// 日期时间格式:yyyy-MM-dd HH:mm:ss
|
|
/// </summary>
|
|
public const string DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
/// <summary>
|
|
/// 系统
|
|
/// </summary>
|
|
public const string XiTong = "系统";
|
|
|
|
/// <summary>
|
|
/// 参考价标的代码前缀
|
|
/// </summary>
|
|
public const string RefPricePrefix = "\a[R1]";
|
|
/// <summary>
|
|
/// 债券价格乘数
|
|
/// </summary>
|
|
public const decimal bondPriceMultiple = 0.01m;
|
|
/// <summary>
|
|
/// 债券价格展示乘数
|
|
/// </summary>
|
|
public const decimal bondShowPriceMultiple = 100m;
|
|
|
|
/// <summary>
|
|
/// 限额监控系数
|
|
/// </summary>
|
|
public const double quotaMonitorMultiple = 0.0001;
|
|
/// <summary>
|
|
/// 互换结算岗组
|
|
/// </summary>
|
|
public const string SwapSettlementConfigGroup = "SwapSettlement";
|
|
/// <summary>
|
|
/// 互换计算岗邮件配置key
|
|
/// </summary>
|
|
public const string SwapSettlementConfigEmail = "SettlementEmail";
|
|
/// <summary>
|
|
/// 价格四舍五入保留位数
|
|
/// </summary>
|
|
|
|
public const int PriceRound = 11;
|
|
/// <summary>
|
|
/// 互换期初、期末交割价四舍五入保留位数
|
|
/// </summary>
|
|
public const int SwapDeliveryPriceRound = 9;
|
|
/// <summary>
|
|
/// 金额四舍五入保留位数
|
|
/// </summary>
|
|
|
|
public const int MoneyRound = 2;
|
|
|
|
#region----有效Valid/无效InValid----
|
|
|
|
public const string Valid = "Valid";
|
|
public const string InValid = "InValid";
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static bool IsValid(string validState)
|
|
{
|
|
return !InValid.Equals(validState, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public static IList<SelectItem> ValidStates()
|
|
{
|
|
return new List<SelectItem>
|
|
{
|
|
new SelectItem {Text = "有效", Value = Valid },
|
|
new SelectItem {Text = "无效", Value = InValid},
|
|
};
|
|
}
|
|
|
|
public static string GetValidDesc(string validState)
|
|
{
|
|
return InValid.Equals(validState, StringComparison.OrdinalIgnoreCase) || validState == "2" ? "无效" : "有效";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----资产类型InstrumentType----
|
|
|
|
/// <summary>
|
|
/// 资产类型
|
|
/// </summary>
|
|
public static class InstrumentType
|
|
{
|
|
public const string Stock = "Stock";
|
|
public const string StockIndex = "StockIndex";
|
|
public const string StockIF = "StockIF";
|
|
public const string CommoditySpot = "CommoditySpot";
|
|
public const string CommodityFutures = "CommodityFutures";
|
|
public const string NewOtcStock = "NewOtcStock";
|
|
public const string HKStock = "HKStock";
|
|
public const string HKStockIndex = "HKStockIndex";
|
|
public const string Fund = "Fund";
|
|
public const string TBonds = "TBonds";
|
|
public const string CreditBonds = "CreditBonds"; //信用债
|
|
public const string OtherBonds = "OtherBonds"; //其它债券
|
|
public const string Bonds = "Bond"; //债券
|
|
public const string GoldFutures = "GoldFutures";
|
|
public const string TBFutures = "TBFutures";
|
|
public const string OtherFutures = "OtherFutures";
|
|
public const string GoldSpot = "GoldSpot";
|
|
public const string OtherSpot = "OtherSpot";
|
|
public const string AbroadFutures = "AbroadFutures";
|
|
public const string AbroadSpot = "AbroadSpot";
|
|
public const string AbroadStock = "AbroadStock";
|
|
public const string AbroadStockIndex = "AbroadStockIndex";
|
|
public const string ExRate = "ExRate";
|
|
public const string Shibor = "Shibor";
|
|
public const string FixingRepoRate = "FixingRepoRate";
|
|
public const string OtherRate = "OtherRate";
|
|
//public const string OtherUnderlying = "OtherUnderlying";
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string GetDesc(string instType)
|
|
{
|
|
switch (instType)
|
|
{
|
|
case Stock: return "股票";
|
|
case StockIndex: return "股指";
|
|
case StockIF: return "股指期货";
|
|
case CommoditySpot: return "商品现货";
|
|
case CommodityFutures: return "商品期货";
|
|
case NewOtcStock: return "新三板挂牌股票";
|
|
case HKStock: return "香港股票";
|
|
case HKStockIndex: return "香港股指";
|
|
case Fund: return "基金及基金专户";
|
|
case TBonds: return "利率债";
|
|
case GoldFutures: return "黄金期货";
|
|
case TBFutures: return "国债期货";
|
|
case OtherFutures: return "其他期货";
|
|
case GoldSpot: return "黄金现货";
|
|
case OtherSpot: return "其他现货";
|
|
case AbroadFutures: return "境外期货";
|
|
case AbroadSpot: return "境外现货";
|
|
case AbroadStock: return "境外股票";
|
|
case AbroadStockIndex: return "境外股指";
|
|
case ExRate: return "汇率";
|
|
case Shibor: return "Shibor";
|
|
case FixingRepoRate: return "银行间回购定盘";
|
|
case OtherRate: return "其他利率";
|
|
//case OtherUnderlying: return "其他标的";
|
|
case CreditBonds: return "信用债";
|
|
case OtherBonds: return "其它债券";
|
|
default: return instType;
|
|
}
|
|
}
|
|
|
|
public static string GetFromDesc(string CnName)
|
|
{
|
|
switch (CnName)
|
|
{
|
|
case "股票": return Stock;
|
|
case "股指": return StockIndex;
|
|
case "股指期货": return StockIF;
|
|
case "商品现货": return CommoditySpot;
|
|
case "商品期货": return CommodityFutures;
|
|
case "新三板挂牌股票": return NewOtcStock;
|
|
case "香港股票": return HKStock;
|
|
case "香港股指": return HKStockIndex;
|
|
case "基金及基金专户": return Fund;
|
|
case "国债": return TBonds;
|
|
case "利率债": return TBonds;
|
|
case "黄金期货": return GoldFutures;
|
|
case "国债期货": return TBFutures;
|
|
case "其他期货": return OtherFutures;
|
|
case "黄金现货": return GoldSpot;
|
|
case "其他现货": return OtherSpot;
|
|
case "境外期货": return AbroadFutures;
|
|
case "境外现货": return AbroadSpot;
|
|
case "境外股票": return AbroadStock;
|
|
case "境外股指": return AbroadStockIndex;
|
|
case "汇率": return ExRate;
|
|
case "Shibor": return Shibor;
|
|
case "银行间回购定盘": return FixingRepoRate;
|
|
case "其他利率": return OtherRate;
|
|
//case "其他标的": return OtherUnderlying;
|
|
case "信用债": return CreditBonds;
|
|
case "其它债券": return OtherBonds;
|
|
default: throw new ServiceException("资产类型不存在");
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<SelectItem> SelectItems()
|
|
{
|
|
if (PS.Config.Company == Configuration.CompanyEnum.中金)
|
|
{
|
|
return new[] {
|
|
new SelectItem { Text = "股票", Value = Stock },
|
|
new SelectItem { Text = "股指", Value = StockIndex },
|
|
new SelectItem { Text = "股指期货", Value = StockIF },
|
|
new SelectItem { Text = "新三板挂牌股票" ,Value = NewOtcStock},
|
|
new SelectItem { Text = "香港股票" ,Value = HKStock},
|
|
new SelectItem { Text = "香港股指" ,Value = HKStockIndex},
|
|
new SelectItem { Text = "基金及基金专户" ,Value = Fund},
|
|
new SelectItem { Text = "国债" ,Value = TBonds},
|
|
new SelectItem { Text = "黄金期货" ,Value = GoldFutures},
|
|
new SelectItem { Text = "国债期货" ,Value = TBFutures},
|
|
new SelectItem { Text = "其他期货" ,Value = OtherFutures},
|
|
new SelectItem { Text = "黄金现货" ,Value = GoldSpot},
|
|
new SelectItem { Text = "其他现货" ,Value = OtherSpot},
|
|
new SelectItem { Text = "境外期货" ,Value = AbroadFutures},
|
|
new SelectItem { Text = "境外现货" ,Value = AbroadSpot},
|
|
new SelectItem { Text = "境外股票" ,Value = AbroadStock},
|
|
new SelectItem { Text = "境外股指" ,Value = AbroadStockIndex},
|
|
new SelectItem { Text = "汇率" ,Value = ExRate },
|
|
new SelectItem { Text = "Shibor" ,Value = Shibor},
|
|
new SelectItem { Text = "银行间回购定盘" ,Value = FixingRepoRate},
|
|
new SelectItem { Text = "其他利率" ,Value = OtherRate},
|
|
//new SelectItem { Text = "其他标的" ,Value = OtherUnderlying}
|
|
};
|
|
}
|
|
|
|
|
|
return new[] {
|
|
new SelectItem { Text = "股票", Value = Stock },
|
|
new SelectItem { Text = "股指", Value = StockIndex },
|
|
new SelectItem { Text = "股指期货", Value = StockIF },
|
|
new SelectItem { Text = "商品期货", Value = CommodityFutures },
|
|
new SelectItem { Text = "商品现货", Value = CommoditySpot },
|
|
new SelectItem { Text = "新三板挂牌股票" ,Value = NewOtcStock},
|
|
new SelectItem { Text = "香港股票" ,Value = HKStock},
|
|
new SelectItem { Text = "香港股指" ,Value = HKStockIndex},
|
|
new SelectItem { Text = "基金及基金专户" ,Value = Fund},
|
|
new SelectItem { Text = "利率债" ,Value = TBonds},
|
|
new SelectItem { Text = "信用债" ,Value = CreditBonds},
|
|
new SelectItem { Text = "其它债券" ,Value = OtherBonds},
|
|
new SelectItem { Text = "黄金期货" ,Value = GoldFutures},
|
|
new SelectItem { Text = "国债期货" ,Value = TBFutures},
|
|
new SelectItem { Text = "其他期货" ,Value = OtherFutures},
|
|
new SelectItem { Text = "黄金现货" ,Value = GoldSpot},
|
|
new SelectItem { Text = "其他现货" ,Value = OtherSpot},
|
|
new SelectItem { Text = "境外期货" ,Value = AbroadFutures},
|
|
new SelectItem { Text = "境外现货" ,Value = AbroadSpot},
|
|
new SelectItem { Text = "境外股票" ,Value = AbroadStock},
|
|
new SelectItem { Text = "境外股指" ,Value = AbroadStockIndex},
|
|
new SelectItem { Text = "汇率" ,Value = ExRate },
|
|
new SelectItem { Text = "Shibor" ,Value = Shibor},
|
|
new SelectItem { Text = "银行间回购定盘" ,Value = FixingRepoRate},
|
|
//new SelectItem { Text = "其他利率" ,Value = OtherRate},
|
|
//new SelectItem { Text = "其他标的" ,Value = OtherUnderlying}
|
|
};
|
|
}
|
|
|
|
public static IEnumerable<string> FutureTypes()
|
|
{
|
|
return new[] { CommodityFutures, StockIF, GoldFutures, TBFutures, OtherFutures, AbroadFutures };
|
|
}
|
|
|
|
/// <summary>
|
|
/// 权益类
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static IEnumerable<string> EquityTypes()
|
|
{
|
|
return new[] { Stock, StockIndex, StockIF, NewOtcStock, HKStock, HKStockIndex, AbroadStock, AbroadStockIndex };
|
|
}
|
|
|
|
//------------IS-----------------------
|
|
|
|
/// <summary>
|
|
/// 是否股票资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsStock(string instType)
|
|
{
|
|
return Stock.Equals(instType, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否股指资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsStockIndex(string instType)
|
|
{
|
|
return StockIndex.Equals(instType, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否股票指数期货资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsStockIF(string instType)
|
|
{
|
|
return StockIF.Equals(instType, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否商品现货资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsCommoditySpot(string instType)
|
|
{
|
|
return CommoditySpot.Equals(instType, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否商品期货资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsCommodityFutures(string instType)
|
|
{
|
|
return CommodityFutures.Equals(instType, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否债券资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool IsBond(string instType)
|
|
{
|
|
switch (instType)
|
|
{
|
|
case Bonds:
|
|
case TBonds:
|
|
case CreditBonds:
|
|
case OtherBonds:
|
|
return true;
|
|
default: return false;
|
|
}
|
|
}
|
|
|
|
//------------CalcType-----------------------
|
|
|
|
/// <summary>
|
|
/// 是否期货资产类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool CalcTypeIsFutures(string instType)
|
|
{
|
|
return IsCommodityFutures(ConvertCalcType(instType));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 计算方式是否是股票类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static bool CalcTypeIsStock(string instType)
|
|
{
|
|
return IsStock(ConvertCalcType(instType));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 类型转换为计算所用类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string ConvertCalcType(string instType)
|
|
{
|
|
switch (instType)
|
|
{
|
|
case Stock:
|
|
case StockIndex:
|
|
case NewOtcStock:
|
|
case HKStock:
|
|
case HKStockIndex:
|
|
case AbroadStock:
|
|
case AbroadStockIndex:
|
|
case Shibor:
|
|
return Stock;
|
|
case StockIF:
|
|
case CommodityFutures:
|
|
case GoldFutures:
|
|
case TBFutures:
|
|
case OtherFutures:
|
|
case AbroadFutures:
|
|
return CommodityFutures;
|
|
case CommoditySpot:
|
|
case GoldSpot:
|
|
case OtherSpot:
|
|
case AbroadSpot:
|
|
return CommoditySpot;
|
|
case TBonds:
|
|
case CreditBonds:
|
|
case OtherBonds:
|
|
return Bonds;
|
|
default:
|
|
return instType;
|
|
}
|
|
}
|
|
|
|
//------------LinkType-----------------------
|
|
|
|
/// <summary>
|
|
/// 期货类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string[] GetFutureTypes()
|
|
{
|
|
return new[] { CommodityFutures, StockIF,
|
|
GoldFutures, TBFutures, AbroadFutures, OtherFutures };
|
|
}
|
|
|
|
/// <summary>
|
|
/// 股票类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string[] GetStockTypes()
|
|
{
|
|
return new[] {
|
|
Stock,
|
|
StockIndex,
|
|
NewOtcStock,
|
|
HKStock,
|
|
HKStockIndex,
|
|
AbroadStock,
|
|
AbroadStockIndex
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 现货类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string[] GetSpotTypes()
|
|
{
|
|
return new[] {
|
|
CommoditySpot,
|
|
GoldSpot,
|
|
OtherSpot,
|
|
AbroadSpot
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 债券类型
|
|
/// </summary>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string[] GetBondTypes()
|
|
{
|
|
return new[] {
|
|
Bonds,
|
|
TBonds,
|
|
CreditBonds,
|
|
OtherBonds
|
|
};
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public static class MainCategory
|
|
{
|
|
public const string Equity = "Equity";
|
|
public const string BulkCommodity = "BulkCommodity";
|
|
public const string InterestRate = "InterestRate";//利率
|
|
public const string Credit = "Credit";//信用类
|
|
public const string ExchangeRate = "ExchangeRate";//汇率
|
|
public const string Other = "Other";
|
|
|
|
public static string GetDesc(string instType)
|
|
{
|
|
switch (instType)
|
|
{
|
|
case Equity: return "权益类";
|
|
case BulkCommodity: return "大宗商品";
|
|
case InterestRate: return "利率";
|
|
case Credit: return "信用类";
|
|
case ExchangeRate: return "汇率";
|
|
case Other: return "其他";
|
|
|
|
default: return instType;
|
|
}
|
|
}
|
|
|
|
public static string GetFromDesc(string CnName)
|
|
{
|
|
switch (CnName)
|
|
{
|
|
case "权益类": return Equity;
|
|
case "大宗商品": return BulkCommodity;
|
|
case "利率": return InterestRate;
|
|
case "信用类": return Credit;
|
|
case "汇率": return ExchangeRate;
|
|
case "其他": return Other;
|
|
default: throw new ServiceException("主类型不存在");
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<SelectItem> SelectItems()
|
|
{
|
|
return new[] {
|
|
new SelectItem { Text = "权益类", Value = Equity },
|
|
new SelectItem { Text = "大宗商品", Value = BulkCommodity },
|
|
new SelectItem { Text = "利率", Value = InterestRate },
|
|
new SelectItem { Text = "信用类", Value = Credit },
|
|
new SelectItem { Text = "汇率", Value = ExchangeRate },
|
|
new SelectItem { Text = "其他" ,Value = Other},
|
|
};
|
|
}
|
|
}
|
|
|
|
#region----看涨看跌CallPut----
|
|
|
|
/// <summary>
|
|
/// 看涨看跌
|
|
/// </summary>
|
|
public static class CallPut
|
|
{
|
|
public const string Call = "Call";
|
|
public const string Call_CN = "看涨";
|
|
|
|
public const string Put = "Put";
|
|
public const string Put_CN = "看跌";
|
|
|
|
public static bool IsCall(string value)
|
|
{
|
|
return Call.Equals(value, StringComparison.OrdinalIgnoreCase) || value == Call_CN;
|
|
}
|
|
|
|
public static bool IsPut(string value)
|
|
{
|
|
return Put.Equals(value, StringComparison.OrdinalIgnoreCase) || value == Put_CN;
|
|
}
|
|
|
|
public static string ConvertToCN(string value)
|
|
{
|
|
switch (value?.ToLowerInvariant())
|
|
{
|
|
case "call": return Call_CN;
|
|
case "put": return Put_CN;
|
|
default: return value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取CallPut
|
|
/// </summary>
|
|
public static string GetCallPut(string OptionType)
|
|
{
|
|
switch (OptionType)
|
|
{
|
|
case "看涨":
|
|
case "Call":
|
|
case "多头":
|
|
return "Call";
|
|
case "看跌":
|
|
case "Put":
|
|
case "空头":
|
|
return "Put";
|
|
default: return OptionType;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----交易方向TradeSide----
|
|
|
|
/// <summary>
|
|
/// 交易方向
|
|
/// </summary>
|
|
public static class TradeSide
|
|
{
|
|
public const string 多头开仓 = "多头开仓";
|
|
public const string 多头平仓 = "多头平仓";
|
|
public const string 空头开仓 = "空头开仓";
|
|
public const string 空头平仓 = "空头平仓";
|
|
|
|
public static IEnumerable<SelectItem> SelectItems()
|
|
{
|
|
return new[] {
|
|
new SelectItem { Text = "多头开仓", Value = 多头开仓 },
|
|
new SelectItem { Text = "多头平仓", Value = 多头平仓 },
|
|
new SelectItem { Text = "空头开仓", Value = 空头开仓 },
|
|
new SelectItem { Text = "空头平仓", Value = 空头平仓 }
|
|
};
|
|
}
|
|
|
|
public static bool IsValid(string value)
|
|
{
|
|
return SelectItems().Any(n => n.Value == value);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----行权方式ExerciseMode----
|
|
|
|
/// <summary>
|
|
/// 行权方式
|
|
/// </summary>
|
|
public static class ExerciseMode
|
|
{
|
|
public const string American = "American";
|
|
public const string European = "European";
|
|
|
|
public static string GetDesc(string exerciseMode)
|
|
{
|
|
switch (exerciseMode)
|
|
{
|
|
case American: return "美式";
|
|
case European: return "欧式";
|
|
default: return exerciseMode;
|
|
}
|
|
}
|
|
|
|
public static IEnumerable<SelectItem> SelectItems()
|
|
{
|
|
return new[] {
|
|
new SelectItem { Text = "美式", Value = American },
|
|
new SelectItem { Text = "欧式", Value = European},
|
|
};
|
|
}
|
|
|
|
public static bool IsAmerican(string exerciseMode)
|
|
{
|
|
return American.Equals(exerciseMode, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public static bool IsEuropean(string exerciseMode)
|
|
{
|
|
return European.Equals(exerciseMode, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----结算价模式SettlePriceMode----
|
|
|
|
/// <summary>
|
|
/// 结算价模式
|
|
/// </summary>
|
|
public static class SettlePriceMode
|
|
{
|
|
public const string 结算价 = "结算价";
|
|
public const string 收盘价 = "收盘价";
|
|
|
|
/// <summary>
|
|
/// 如果mode不等于结算价就使用收盘价
|
|
/// </summary>
|
|
public static bool UseClosePrice(string mode)
|
|
{
|
|
return mode != 结算价;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 如果mode等于结算价就使用结算价
|
|
/// </summary>
|
|
public static bool UseSettlePrice(string mode)
|
|
{
|
|
return mode == 结算价;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据结算价类型中文描述获取枚举值
|
|
/// </summary>
|
|
public static DBModels.SettlementTypeEnum GetSettlementType(string mode)
|
|
{
|
|
if (mode == 结算价)
|
|
{
|
|
return DBModels.SettlementTypeEnum.SettlePrice;
|
|
}
|
|
|
|
//这个方法不会涉及到参考价,如果要增加参考价逻辑,建议另开方法
|
|
|
|
return DBModels.SettlementTypeEnum.ClosePrice;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----价格是否为0----
|
|
|
|
public const double TooSmallValue = 1e-6;
|
|
|
|
/// <summary>
|
|
/// 把过小值变为0;
|
|
/// </summary>
|
|
public static double IgnoreTSV(double price)
|
|
{
|
|
return Math.Abs(price) < TooSmallValue ? 0 : price;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----交易类型----
|
|
|
|
public static class TradeType
|
|
{
|
|
/// <summary>
|
|
/// 远期
|
|
/// </summary>
|
|
public const string Forward = "远期";
|
|
|
|
/// <summary>
|
|
/// 收益互换
|
|
/// </summary>
|
|
public const string PayoffSwap = "收益互换";
|
|
|
|
/// <summary>
|
|
/// 自定义交易
|
|
/// </summary>
|
|
public const string Custom = "自定义交易";
|
|
|
|
/// <summary>
|
|
/// 自定义交易(和Custom同义)
|
|
/// </summary>
|
|
public const string Manual = "自定义交易";
|
|
|
|
/// <summary>
|
|
/// 现金流交易
|
|
/// </summary>
|
|
public const string CashFlow = "现金流交易";
|
|
|
|
/// <summary>
|
|
/// 结构化交易
|
|
/// </summary>
|
|
public const string Structure = "结构化交易";
|
|
|
|
/// <summary>
|
|
/// 区间累积期权
|
|
/// </summary>
|
|
public const string RangeAcc = "区间累积期权";
|
|
|
|
/// <summary>
|
|
/// 是否期权交易(采用反证法)
|
|
/// </summary>
|
|
public static bool IsOptionTrade(string tradeType)
|
|
{
|
|
return tradeType != Forward && tradeType != PayoffSwap && tradeType != Custom && tradeType != CashFlow;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ----客户文件类型----
|
|
|
|
public static class ClientFileType
|
|
{
|
|
/// <summary>
|
|
/// ----
|
|
/// </summary>
|
|
public const string NoType = "";
|
|
/// <summary>
|
|
/// 适当性文件
|
|
/// </summary>
|
|
public const string Suitably = "适应性文件";
|
|
/// <summary>
|
|
/// 双录视频文件
|
|
/// </summary>
|
|
public const string BookRadio = "双录视频文件";
|
|
/// <summary>
|
|
/// 主协议附件
|
|
/// </summary>
|
|
public const string MainProtocol = "主协议附件(PDF)";
|
|
/// <summary>
|
|
/// 补充协议附件
|
|
/// </summary>
|
|
public const string EnhanceProtocol = "补充协议附件(PDF)";
|
|
/// <summary>
|
|
/// 履约预付金附件
|
|
/// </summary>
|
|
public const string DateMargin = "履约协议附件(PDF)";
|
|
/// <summary>
|
|
/// 代签产品附件
|
|
/// </summary>
|
|
public const string AllographProduct = "代签产品附件(PDF)";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----波动率类型----
|
|
|
|
/// <summary>
|
|
/// 波动率类型
|
|
/// </summary>
|
|
public static class VolType
|
|
{
|
|
/// <summary>
|
|
/// 开仓
|
|
/// </summary>
|
|
public const string OpeningVol = "开仓";
|
|
|
|
/// <summary>
|
|
/// 持仓
|
|
/// </summary>
|
|
public const string PositionVol = "持仓";
|
|
|
|
/// <summary>
|
|
/// 对冲
|
|
/// </summary>
|
|
public const string HedgingVol = "对冲";
|
|
|
|
public static bool IsPositionVol(string volType)
|
|
{
|
|
return string.IsNullOrWhiteSpace(volType) || volType == PositionVol;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region----交易所类型----
|
|
public static class MarketType
|
|
{
|
|
public static readonly List<string> ChineseMarketCode = new List<string> { "SHFE", "INE", "CFFEX", "CZCE", "DCE" };
|
|
}
|
|
#endregion
|
|
|
|
#region----货币类型----
|
|
|
|
public static class Currency
|
|
{
|
|
public const string CNH = "CNH";
|
|
public const string CNY = "CNY";
|
|
public const string USD = "USD";
|
|
public const string EUR = "EUR";
|
|
|
|
public static readonly string[] CNCurrencies;
|
|
|
|
static Currency()
|
|
{
|
|
CNCurrencies = new[] { CNH, CNY };
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否中国货币
|
|
/// </summary>
|
|
public static bool IsCnCurrency(string currency)
|
|
{
|
|
return CNCurrencies.Contains(currency, StringComparer.OrdinalIgnoreCase);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public static class ReportMainNode
|
|
{
|
|
//{ "A1001", "A1002","A1003","A1004", "A1005", "A1006" ,"A1007",
|
|
//"A1008", "A1009","A1010", "A1011", "A1012","A1013","A1014","A1015","A1016","A1017" }
|
|
public static string GetMaxDpethNode(string BusiDataType)
|
|
{
|
|
switch (BusiDataType)
|
|
{
|
|
case "A1005":
|
|
case "A1006":
|
|
return "SwapConfirmation";
|
|
default:
|
|
return "OtherReport";
|
|
}
|
|
}
|
|
public static string GetKeyNode(string BusiDataType)
|
|
{
|
|
switch (BusiDataType)
|
|
{
|
|
case "A1005":
|
|
case "A1006":
|
|
return "ConfirmationNo";
|
|
default:
|
|
return "ExceID";
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 收盘状态值
|
|
/// </summary>
|
|
public static class EodStatusVlue
|
|
{
|
|
public const string Success = "已收盘";
|
|
}
|
|
}
|
|
}
|