feat: 新增成交收益率字段
This commit is contained in:
@@ -119,6 +119,9 @@ namespace YLErp.DBModels
|
||||
[DisplayName("期初标的价格-不含费")]
|
||||
[DataChange]
|
||||
public decimal PosiGrossPrice { get; set; }
|
||||
|
||||
/// 收益率
|
||||
|
||||
/// <summary>
|
||||
/// 剩余持仓数量
|
||||
/// </summary>
|
||||
|
||||
@@ -155,6 +155,11 @@ namespace YLErp.DBModels
|
||||
/// </summary>
|
||||
public decimal? TradingAmountNetFeeAvg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计算后的成交收益率
|
||||
/// </summary>
|
||||
public decimal? InitYtm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易费用后付
|
||||
/// </summary>
|
||||
|
||||
@@ -230,6 +230,10 @@ namespace YLErp.DBModels
|
||||
/// </summary>
|
||||
public string UnderlyingInstrumentType { get; set; }
|
||||
/// <summary>
|
||||
/// 期初收益率
|
||||
/// </summary>
|
||||
public decimal InitYtm { get; set; }
|
||||
/// <summary>
|
||||
/// 是否无效
|
||||
/// </summary>
|
||||
public bool Invalid { get; set; }
|
||||
|
||||
@@ -335,6 +335,9 @@ namespace YLErp.DBModels
|
||||
[DisplayName("除权除息系数")]
|
||||
public double DividendRatio { get; internal set; }
|
||||
|
||||
[DisplayName("簿记后生成的成交收益率")]
|
||||
public decimal InitYtm { get; set; }
|
||||
|
||||
public string GetDataTraceKeyInfo()
|
||||
{
|
||||
return "场外交易:" + TradeNumber;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Qdp.Pricing.Base.Implementations;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text;
|
||||
using YLErp.BLL;
|
||||
using YLErp.BLL.Calculation;
|
||||
using YLErp.BLL.Eod;
|
||||
@@ -303,6 +305,51 @@ namespace YLErp.Modules.SwapModule
|
||||
var swapFlows = DbContext.swap_flow.Where(x => ids.Contains(x.id) && x.DataState == (int)SwapFlowDateStateEnum.等待完成 && x.ClientId > 0).ToList();
|
||||
return swapFlows;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用不含费全价(加权平均全精度)+日期 来计算
|
||||
/// </summary>
|
||||
/// <param name="swapFlows"></param>
|
||||
public async Task<decimal?> CalcInitYtm(string symbol, DateTime valueDate, decimal tradingAmountAvg)
|
||||
{
|
||||
|
||||
using var client = new HttpClient();
|
||||
|
||||
var payload = new Dictionary<string, object>
|
||||
{
|
||||
{ "bondKey", symbol },
|
||||
{ "settlementDate", valueDate },
|
||||
{ "fullPrice", tradingAmountAvg }
|
||||
};
|
||||
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(payload);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponseMessage response = await client.PostAsync("http://localhost:8080/v1/bond/", content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
using var doc = JsonDocument.Parse(responseBody);
|
||||
if (doc.RootElement.TryGetProperty("yield", out var yieldElement))
|
||||
{
|
||||
if (yieldElement.ValueKind == JsonValueKind.Number)
|
||||
{
|
||||
double d = yieldElement.GetDouble();
|
||||
return (decimal)d;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("请求失败: " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 簿记前自动校验
|
||||
/// </summary>
|
||||
@@ -347,7 +394,7 @@ namespace YLErp.Modules.SwapModule
|
||||
/// 汇总流水
|
||||
/// </summary>
|
||||
/// <param name="valueDate"></param>
|
||||
public List<swap_flow_merge> SummaryFlow(List<swap_flow> swapFlows, bool save = true)
|
||||
public async Task<List<swap_flow_merge>> SummaryFlow(List<swap_flow> swapFlows, DateTime valueDate, bool save = true)
|
||||
{
|
||||
var swapFlowGroup = swapFlows.GroupBy(g => new { g.ClientId, g.OccurTime, g.UnderlyingCode, g.BsType }).ToList();
|
||||
List<swap_flow_merge> list = new List<swap_flow_merge>();
|
||||
@@ -382,6 +429,8 @@ namespace YLErp.Modules.SwapModule
|
||||
swap_flow_summary.TradingAmountNetAvg = Math.Round(swap_flow_summary.TradingAmountNetAvg ?? 0, 10);
|
||||
swap_flow_summary.TradingAmountNetFeeAvg = swap_flow_summary.TradingQty == 0 ? swap_flow_summary.TradingAmountNetAvg : swap_flow_summary.TradingAmountNetAvg + swap_flow_summary.TradingFeePending * tradeSide / swap_flow_summary.TradingQty;
|
||||
swap_flow_summary.TradingAmountNetFeeAvg = Math.Round(swap_flow_summary.TradingAmountNetFeeAvg ?? 0, 10);
|
||||
// 计算收益率
|
||||
swap_flow_summary.InitYtm = await CalcInitYtm(gourpItem.Key.UnderlyingCode, valueDate, swap_flow_summary.TradingAmountAvg);
|
||||
swap_flow_summary.SetOpt(UserInfo);
|
||||
if (save)
|
||||
{
|
||||
|
||||
@@ -350,6 +350,7 @@ namespace YLErp.Modules.SwapModule
|
||||
td.ValidState = "Valid";
|
||||
td.TradeSource = "系统交易";
|
||||
td.TradeStatus = ConsTrade.确认成交;
|
||||
td.InitYtm = flowMerge.InitYtm ?? 0;
|
||||
return td;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -384,7 +385,8 @@ namespace YLErp.Modules.SwapModule
|
||||
OptTime = DateTime.Now,
|
||||
OptId = UserInfo.UserId,
|
||||
OptName = UserInfo.UserName,
|
||||
UnderlyingInstrumentType = underlying.UnderlyingInstrumentType
|
||||
UnderlyingInstrumentType = underlying.UnderlyingInstrumentType,
|
||||
InitYtm = flowMerge.InitYtm ?? 0
|
||||
};
|
||||
td.swap_positions.Add(floatPosition);
|
||||
swap_position interestPosition = new swap_position()
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace YLErp.Web.Hubs
|
||||
}
|
||||
currentStep = "正在合成流水";
|
||||
await client.SendAsync("ReceiveMessage", currentStep);
|
||||
var mergeList = service.SummaryFlow(swapFlows);
|
||||
var mergeList = await service.SummaryFlow(swapFlows, req.tradeDate);
|
||||
// 数据校验逻辑
|
||||
currentStep = "校验上一日是否收盘";
|
||||
await client.SendAsync("ReceiveMessage", currentStep);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
bool isBond = trade.StructureType == "普通债券类收益互换";
|
||||
string spotPriceTitle = "期初标的交割全价%";
|
||||
string netSportPriceTitle = "期初标的交割净价%";
|
||||
string initYtmTitle = "期初标的成交收益率%";
|
||||
var positions = trade.swap_positions.Where(x=>x.PosiDirection>0&&x.IsInitial).ToList();
|
||||
var realPositions = trade.swap_positions.Where(x => x.PosiDirection > 0 && !x.IsInitial).ToList();
|
||||
var sr = trade.trade_extend.ExtendObj.SettlementRules;
|
||||
@@ -364,6 +365,7 @@
|
||||
<td>标的代码</td>
|
||||
<td>@spotPriceTitle</td>
|
||||
<td>@netSportPriceTitle</td>
|
||||
<td>@initYtmTitle</td>
|
||||
<td>数量</td>
|
||||
<td>交易费用后付</td>
|
||||
</tr>
|
||||
@@ -381,6 +383,9 @@
|
||||
<td>
|
||||
@(((item.PosiNetNoFeePrice ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice))
|
||||
</td>
|
||||
<td>
|
||||
@(((item.PosiNetNoFeePrice ?? 0) * multiplier).OtcFormat(OtcFormatFlag.umprice))
|
||||
</td>
|
||||
<td>
|
||||
@item.PosiQuantity.OtcFormat(OtcFormatFlag.StockEqvNotional)
|
||||
</td>
|
||||
|
||||
@@ -257,6 +257,15 @@ var colModelGrid = [
|
||||
sortable: false,
|
||||
formatter: PriceFormat
|
||||
}, {
|
||||
name: 'position.InitYtm',
|
||||
label: '期初标的成交收益率',
|
||||
index: 'position.InitYtm',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
formatter: otcformat.trading.premiumRateP
|
||||
},
|
||||
{
|
||||
name: 'position.UnderlyingPrice',
|
||||
label: '期末标的交割全价',
|
||||
index: 'position.UnderlyingPrice',
|
||||
|
||||
@@ -225,6 +225,14 @@ var colModelGrid = [
|
||||
align: 'center',
|
||||
formatter: PriceFormat
|
||||
}, {
|
||||
name: 'FlowEvent.InitYtm',
|
||||
label: '成交收益率',
|
||||
index: 'FlowEvent.InitYtm',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
formatter: otcformat.trading.premiumRateP
|
||||
},
|
||||
{
|
||||
name: 'FlowEvent.Quantity',
|
||||
label: '成交数量',
|
||||
index: 'FlowEvent.Quantity',
|
||||
|
||||
@@ -190,6 +190,13 @@ var getColModelGrid = function () {
|
||||
align: 'center',
|
||||
formatter: otcformat.trading.umprice
|
||||
}, {
|
||||
name: 'InitYtm',
|
||||
label: '成交收益率',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
formatter: otcformat.trading.premiumRateP
|
||||
},
|
||||
{
|
||||
name: 'TradingAmountNetFeeAvg',
|
||||
label: '成交净价(含费)',
|
||||
width: 90,
|
||||
|
||||
Reference in New Issue
Block a user