BugFix 添加信用债的计算

This commit is contained in:
锦麟 王
2026-03-11 15:04:10 +08:00
parent 8c08bf5df1
commit 3ce2dfe4c7
15 changed files with 17 additions and 8 deletions
@@ -110,7 +110,7 @@ namespace YLErp.DBModels
/// <summary> /// <summary>
/// 对冲结构类型 /// 对冲结构类型
/// </summary> /// </summary>
public static readonly List<string> TradeTypesForHedge = new List<string> { "商品期货", "商品现货", "股票", "场内期权" }; public static readonly List<string> TradeTypesForHedge = new List<string> { "商品期货", "商品现货", "股票", "场内期权","信用债" };
/// <summary> /// <summary>
/// 非期权结构类型(包括结构化交易) /// 非期权结构类型(包括结构化交易)
@@ -125,7 +125,7 @@ namespace YLErp.DBModels
/// </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> 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> TradeTypesForStockRiskHedging = new List<string> { "香草期权", "亚式期权", "商品期货", "股票", "信用债" };
public static readonly List<string> BarrierTypes = new List<string> { "上升敲入", "上升敲出", "下降敲入", "下降敲出", "双障碍敲入", "双障碍敲出" }; public static readonly List<string> BarrierTypes = new List<string> { "上升敲入", "上升敲出", "下降敲入", "下降敲出", "双障碍敲入", "双障碍敲出" };
/// <summary> /// <summary>
@@ -7367,6 +7367,7 @@ namespace YLErp.OldVersion
case "远期": case "远期":
result = ForwardradeCalcService.CalcValue(trade, spotPrices[0]); result = ForwardradeCalcService.CalcValue(trade, spotPrices[0]);
break; break;
case "信用债":
case "商品期货": case "商品期货":
case "商品现货": case "商品现货":
case "股票": case "股票":
@@ -51,6 +51,7 @@ namespace YLErp.BLL.Calculation.V2
return CreateAirbagParameter(trade, underlying, variety, vols, spotPrices, preciseTimeMode, discountCurveName, timeToMaturityDays, engineName); return CreateAirbagParameter(trade, underlying, variety, vols, spotPrices, preciseTimeMode, discountCurveName, timeToMaturityDays, engineName);
case "收益增强结构": case "收益增强结构":
return CreateUnderlyingEnhanceParameter(trade, underlying, variety, vols, spotPrices, preciseTimeMode, discountCurveName, timeToMaturityDays, engineName); return CreateUnderlyingEnhanceParameter(trade, underlying, variety, vols, spotPrices, preciseTimeMode, discountCurveName, timeToMaturityDays, engineName);
case "信用债":
case "商品期货": case "商品期货":
case "股票": case "股票":
return CreateUnderlyingProductParameter(underlying, spotPrices); return CreateUnderlyingProductParameter(underlying, spotPrices);
@@ -132,6 +132,7 @@ namespace YLErp.BLL.Calculation.V2
} }
return CalculateForward(trade.Strike ?? 0.0, spotPrice, trade.Notional, trade.CallPut); return CalculateForward(trade.Strike ?? 0.0, spotPrice, trade.Notional, trade.CallPut);
} }
case "信用债":
case "商品期货": case "商品期货":
case "商品现货": case "商品现货":
case "股票": case "股票":
@@ -2009,6 +2009,7 @@ namespace YLErp.BLL.MarginCalculation
} }
optionValue = ForwardradeCalcService.CalcValue(td, closePrice); optionValue = ForwardradeCalcService.CalcValue(td, closePrice);
break; break;
case "信用债":
case "商品期货": case "商品期货":
case "股票": case "股票":
optionValue = new TradeValueResult { Pv = closePrice * td.Notional, Delta = td.Notional, DeltaCash = closePrice * td.Notional }; optionValue = new TradeValueResult { Pv = closePrice * td.Notional, Delta = td.Notional, DeltaCash = closePrice * td.Notional };
+1 -1
View File
@@ -5,7 +5,7 @@
/// <summary> /// <summary>
/// 当前系统支持计算的结构类型, /// 当前系统支持计算的结构类型,
/// </summary> /// </summary>
public readonly static List<string> SupportTradeTypes = new List<string> { "远期", "股票", "场内期权", "商品期货", "香草期权", public readonly static List<string> SupportTradeTypes = new List<string> { "远期", "股票", "场内期权", "商品期货","信用债", "香草期权",
"二元期权", "障碍期权", "亚式期权", "价差期权", "合成价差期权", "结构化交易", "自定义交易", "双鲨期权", "凤凰期权", "雪球期权", "二元期权", "障碍期权", "亚式期权", "价差期权", "合成价差期权", "结构化交易", "自定义交易", "双鲨期权", "凤凰期权", "雪球期权",
"区间累积期权", "收益互换", "气囊结构", "收益增强结构","现金流交易" ,"累计期权","结构化产品","Risky期权"}; "区间累积期权", "收益互换", "气囊结构", "收益增强结构","现金流交易" ,"累计期权","结构化产品","Risky期权"};
} }
@@ -41,6 +41,7 @@ namespace YLErp.CustomizedBizLogic
case "亚式期权": case "亚式期权":
case "彩虹期权": case "彩虹期权":
case "价差期权": case "价差期权":
case "信用债":
case "商品期货": case "商品期货":
case "商品现货": case "商品现货":
case "股票": case "股票":
+1 -1
View File
@@ -649,7 +649,7 @@ namespace YLErp.Models
{ {
tempTrp = viewList.FirstOrDefault(t => ConsTrade.TradeTypesForHedge.Contains(t.TradeType) && t.UnderlyingCode == trp.UnderlyingCode && t.TradeType != "场内期权"); tempTrp = viewList.FirstOrDefault(t => ConsTrade.TradeTypesForHedge.Contains(t.TradeType) && t.UnderlyingCode == trp.UnderlyingCode && t.TradeType != "场内期权");
} }
if ((trp.TradeType == "股票" || trp.TradeType == "商品期货") && string.IsNullOrWhiteSpace(trp.CallPut)) if ((trp.TradeType == "股票" || trp.TradeType == "商品期货" || trp.TradeType == "信用债") && string.IsNullOrWhiteSpace(trp.CallPut))
{ {
trp.CallPut = trp.Notional >= 0 ? ConsGlobal.CallPut.Call : ConsGlobal.CallPut.Put; trp.CallPut = trp.Notional >= 0 ? ConsGlobal.CallPut.Call : ConsGlobal.CallPut.Put;
} }
@@ -52,7 +52,7 @@ namespace YLErp.Modules.CalculationModule
foreach (var td in tradeList) foreach (var td in tradeList)
{ {
if (td.TradeType == "商品期货") if (td.TradeType == "商品期货" || td.TradeType == "信用债")
{ {
continue; continue;
} }
@@ -319,6 +319,7 @@ namespace YLErp.Modules.CalculationModule
result = ForwardradeCalcService.CalcValue(td, spotPrice); result = ForwardradeCalcService.CalcValue(td, spotPrice);
} }
break; break;
case "信用债":
case "商品期货": case "商品期货":
_priceProvider.TryGetPrice(td.UnderlyingCode, out var spotPriceGet); _priceProvider.TryGetPrice(td.UnderlyingCode, out var spotPriceGet);
result = new TradeValueResult() result = new TradeValueResult()
@@ -86,6 +86,7 @@ namespace YLErp.Modules.CalculationModule
{ {
switch (TradeType) switch (TradeType)
{ {
case "信用债":
case "商品期货": case "商品期货":
case "场内期权": case "场内期权":
return BuySell.Contains("多头") ? "long" : "short"; return BuySell.Contains("多头") ? "long" : "short";
@@ -132,6 +132,7 @@ namespace YLErp.Modules.CalculationModule
} }
optionValue = ForwardradeCalcService.CalcValue(_trade, spotPrice); optionValue = ForwardradeCalcService.CalcValue(_trade, spotPrice);
break; break;
case "信用债":
case "商品期货": case "商品期货":
case "股票": case "股票":
{ {
@@ -440,7 +440,8 @@ namespace YLErp.Modules.EodModule
{ {
"场内期权", "场内期权",
"商品期货", "商品期货",
"股票" "股票",
"信用债"
}; };
var sourceQuery = from t in DbContext.Set<TEntity>().Where(t => t.ValueDate >= startDate && t.ValueDate <= endDate && tradeTypes.Contains(t.TradeType)) var sourceQuery = from t in DbContext.Set<TEntity>().Where(t => t.ValueDate >= startDate && t.ValueDate <= endDate && tradeTypes.Contains(t.TradeType))
join un in DbContext.underlying_manager on t.UnderlyingCode equals un.UnderlyingCode join un in DbContext.underlying_manager on t.UnderlyingCode equals un.UnderlyingCode
@@ -692,7 +692,7 @@ namespace YLErp.Modules.ScenarioModule
//获取计算结果 //获取计算结果
private TradeValueResult GetCallResult(trade td, CalcData calcData) private TradeValueResult GetCallResult(trade td, CalcData calcData)
{ {
if (td.TradeType == "商品期货" || td.TradeType == "股票" || td.TradeType == "商品现货") if (td.TradeType == "商品期货" || td.TradeType == "股票" || td.TradeType == "商品现货" || td.TradeType == "信用债")
{ {
var pv = td.Notional * calcData.SpotPrice; var pv = td.Notional * calcData.SpotPrice;
@@ -18,7 +18,7 @@
IsZheQi = PS.Config.Is浙期, IsZheQi = PS.Config.Is浙期,
IsAutoSealGeneratedBook = YLErp.PS.GetErpConfig().IsAutoSealAfterGeneratedBook IsAutoSealGeneratedBook = YLErp.PS.GetErpConfig().IsAutoSealAfterGeneratedBook
}; };
var tradeTypes = ConsTrade.AllTradeTypes.Except(new List<string> { "场内期权", "商品期货", "股票" }).Concat(new List<string> { "黑箱结构" }); var tradeTypes = ConsTrade.AllTradeTypes.Except(new List<string> { "场内期权", "商品期货", "股票","信用债" }).Concat(new List<string> { "黑箱结构" });
} }
@section CSS{ @section CSS{
<style> <style>