计算器调用调整
This commit is contained in:
@@ -8,6 +8,7 @@ using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Org.BouncyCastle.Math.EC.Multiplier;
|
||||
using Qdp.Pricing.Base.Implementations;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using YLErp.Abstract;
|
||||
using YLErp.Abstract.DataProviders;
|
||||
@@ -589,7 +590,7 @@ namespace YLErp.BLL.Eod
|
||||
bondDb.SaveChanges();
|
||||
if (clientPosition.deal_full_price_avg > 0 && enableCalcBongd)//发kafka 获取成交收益率
|
||||
{
|
||||
BondCalcKafka(bondCalcTopic, clientPosition.id, clientPosition.security_id, clientPosition.side, clientPosition.deal_full_price_avg.Value);
|
||||
CalcBandPrice(clientPosition);
|
||||
}
|
||||
}
|
||||
var sql = $"{nameof(ClientPosition.create_time)}<'{datenow.AddSeconds(-1):yyyy-MM-dd HH:mm:ss}' or {nameof(ClientPosition.position_qty)}=0";
|
||||
@@ -633,7 +634,7 @@ namespace YLErp.BLL.Eod
|
||||
//发kafka 获取成交收益率
|
||||
if (clientPosition.deal_full_price_avg > 0 && enableCalcBongd)
|
||||
{
|
||||
BondCalcKafka(bondCalcTopic, clientPosition.id, clientPosition.security_id, clientPosition.side, clientPosition.deal_full_price_avg.Value);
|
||||
CalcBandPrice(clientPosition);
|
||||
}
|
||||
else if (clientPosition.id > 0 && (clientPosition.position_qty > 0 || clientPosition.today_profit_loss != 0))
|
||||
{
|
||||
@@ -710,42 +711,15 @@ namespace YLErp.BLL.Eod
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算互换成交收益率消费任务
|
||||
/// </summary>
|
||||
/// <param name="_kafkaConsumer"></param>
|
||||
public static void ConsumerBondCalcResp(KafkaConsumerHelper _kafkaConsumer)
|
||||
{
|
||||
_kafkaConsumer.Subscribe(msg =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
var result = JsonHelper.Deserialize<BondCalcResp>(msg);
|
||||
var logid = Convert.ToInt64(result.requestID);
|
||||
if (result.errCode == "0")
|
||||
{
|
||||
using var bondDb = new BondOmsDBContext();
|
||||
string sqlstr = $"update client_position set deal_yield_avg={result.YTM} where id={logid}";
|
||||
bondDb.Database.ExecuteSqlRaw(sqlstr);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
#region 新互换实时持仓私有方法
|
||||
private static void BondCalcKafka(string topic, long clientPosiId, string underlyingCode, int side, decimal price)
|
||||
private static void BondCalcApi(ClientPosition clientPosition)
|
||||
{
|
||||
BondCalcReq req = new BondCalcReq()
|
||||
var resp = BondCalcHepler.BondCalc(clientPosition.security_id, clientPosition.deal_full_price_avg ?? 0, "DP");
|
||||
if (resp!=null)
|
||||
{
|
||||
bondId = underlyingCode,
|
||||
requestId = clientPosiId.ToString(),
|
||||
direction = side.ToString(),
|
||||
price = price,
|
||||
priceType = "DP",
|
||||
settleType = "0",
|
||||
requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
valueDate = DateTime.Now.ToString("yyyy-MM-dd")
|
||||
};
|
||||
kafkaProduceHelper.Produce(topic, JsonHelper.Serialize(req));
|
||||
clientPosition.deal_yield_avg = resp.ytm* ConsGlobal.bondPriceMultiple;
|
||||
_yLCache.StringSetWithNoPrefix<CalBondResult>("TRS-BondFullPrice:" + clientPosition.security_id, resp);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建持仓
|
||||
@@ -892,6 +866,30 @@ namespace YLErp.BLL.Eod
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算债券价格
|
||||
/// </summary>
|
||||
/// <param name="clientPosition"></param>
|
||||
private static void CalcBandPrice(ClientPosition clientPosition)
|
||||
{
|
||||
if (clientPosition.position_qty <= 0 || _yLCache == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
//TRS-BondDepthMarket:160010.IB-0
|
||||
CalBondResult bondPrice = _yLCache.StringGetWithNoPrefix<CalBondResult>("TRS-BondFullPrice:" + clientPosition.security_id);
|
||||
if (bondPrice?.dirtyPrice != clientPosition.deal_full_price_avg)
|
||||
{
|
||||
BondCalcApi(clientPosition);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 实时risk计算
|
||||
|
||||
@@ -9,23 +9,22 @@ using YLErp.Model;
|
||||
namespace YLErp.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// 衡泰计算器帮助类
|
||||
/// 计算器帮助类
|
||||
/// </summary>
|
||||
public class HTCalcHepler
|
||||
public class BondCalcHepler
|
||||
{
|
||||
/// <summary>
|
||||
/// 衡泰计算器
|
||||
/// 计算器
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static CalBondResult BondCalc(string underlyingCode,int positionType,decimal price,string valueDate)
|
||||
public static CalBondResult BondCalc(string underlyingCode,decimal price,string priceType="DP")
|
||||
{
|
||||
var baseUrl = Environment.GetEnvironmentVariable("BondOmsInterface_BaseUrl");
|
||||
var calculateUrl = "/calc/cal_bond_value";
|
||||
CalcBondRequest request = new CalcBondRequest() {
|
||||
bondId= underlyingCode,
|
||||
price = price.ToString(),
|
||||
valueDate=valueDate,
|
||||
direction= positionType.ToString()
|
||||
priceType = priceType,
|
||||
};
|
||||
if (!string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
@@ -34,7 +33,7 @@ namespace YLErp.Helpers
|
||||
var result = httpHelper.PostRequestNoAuth<CalcBondRequest, CalcBondReponse>(calculateUrl, request).Result;
|
||||
if (result != null && !result.success)
|
||||
{
|
||||
LogFactory.GetLogger("HTCalcHepler").Info("衡泰计算器计算失败:" + result.message);
|
||||
LogFactory.GetLogger("BondCalcHepler").Info("计算器计算失败:" + result.message);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -15,27 +15,13 @@ namespace YLErp.Model
|
||||
/// </summary>
|
||||
public string bondId { get; set; }
|
||||
/// <summary>
|
||||
/// 买卖方向0买1卖
|
||||
/// </summary>
|
||||
public string direction { get; set; }
|
||||
/// <summary>
|
||||
/// 价格
|
||||
/// </summary>
|
||||
public string price { get; set; }
|
||||
/// <summary>
|
||||
/// 清算速度
|
||||
/// </summary>
|
||||
// public string settleType { get; set; } = "0";
|
||||
/// <summary>
|
||||
/// 价格类型 必填 DP(全价)CP(净价)YD(到期收益率)
|
||||
/// </summary>
|
||||
public string priceType { get; set; } = "DP";
|
||||
/// <summary>
|
||||
/// 定价日期
|
||||
/// </summary>
|
||||
public string valueDate { get; set; }
|
||||
//public string requestTime { get; set; }
|
||||
//public string requestId { get; set; }
|
||||
}
|
||||
|
||||
public class CalcBondRequestList
|
||||
@@ -61,6 +47,6 @@ namespace YLErp.Model
|
||||
/// <summary>
|
||||
/// 收益率
|
||||
/// </summary>
|
||||
public decimal YTM { get; set; }
|
||||
public decimal ytm { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YLErp.Model.HengTaiModel
|
||||
{
|
||||
public class BondCalcReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 债券代码 必填,格式为"券名,资产类型,市场类型" "220210,SPT_BD,X_CNBD"
|
||||
/// </summary>
|
||||
public string bondId { get; set; }
|
||||
/// <summary>
|
||||
/// 定价日 必填
|
||||
/// </summary>
|
||||
public string valueDate { get; set; }
|
||||
/// <summary>
|
||||
/// 价格类型 必填 DP(全价)CP(净价)YD(到期收益率)
|
||||
/// </summary>
|
||||
public string priceType { get; set; }
|
||||
/// <summary>
|
||||
/// 价格 必填
|
||||
/// </summary>
|
||||
public decimal price { get; set; }
|
||||
/// <summary>
|
||||
/// 清算速度 必填
|
||||
/// </summary>
|
||||
public string settleType { get; set; }
|
||||
/// <summary>
|
||||
/// 请求编号
|
||||
/// </summary>
|
||||
public string requestId { get; set; }
|
||||
/// <summary>
|
||||
/// 请求时间
|
||||
/// </summary>
|
||||
public string requestTime { get; set;}
|
||||
/// <summary>
|
||||
/// 买卖方向
|
||||
/// </summary>
|
||||
public string direction { get; set; }
|
||||
/// <summary>
|
||||
/// 保留字段1
|
||||
/// </summary>
|
||||
public string reserver1 { get; set; }
|
||||
/// <summary>
|
||||
/// 保留字段2
|
||||
/// </summary>
|
||||
public string reserver2 { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YLErp.Model.HengTaiModel
|
||||
{
|
||||
public class BondCalcResp
|
||||
{
|
||||
/// <summary>
|
||||
/// 债券代码
|
||||
/// </summary>
|
||||
public string bondId { get; set; }
|
||||
/// <summary>
|
||||
/// 定价日
|
||||
/// </summary>
|
||||
public string valueDate { get; set; }
|
||||
/// <summary>
|
||||
/// 清算速度
|
||||
/// </summary>
|
||||
public string settleType { get; set; }
|
||||
/// <summary>
|
||||
/// 请求编号
|
||||
/// </summary>
|
||||
public string requestID { get; set; }
|
||||
/// <summary>
|
||||
/// 请求时间
|
||||
/// </summary>
|
||||
public string requestTime { get; set; }
|
||||
/// <summary>
|
||||
/// 买卖方向
|
||||
/// </summary>
|
||||
public string direction { get; set; }
|
||||
/// <summary>
|
||||
/// 保留字段1
|
||||
/// </summary>
|
||||
public string reserver1 { get; set; }
|
||||
/// <summary>
|
||||
/// 保留字段2
|
||||
/// </summary>
|
||||
public string reserver2 { get; set; }
|
||||
/// <summary>
|
||||
/// 全价
|
||||
/// </summary>
|
||||
public decimal dirtyPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 净价
|
||||
/// </summary>
|
||||
public decimal cleanPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 到期收益率
|
||||
/// </summary>
|
||||
public decimal YTM { get; set; }
|
||||
/// <summary>
|
||||
/// 应计利息
|
||||
/// </summary>
|
||||
public decimal Al { get; set; }
|
||||
/// <summary>
|
||||
/// 麦克劳林久期
|
||||
/// </summary>
|
||||
public decimal MD { get; set; }
|
||||
/// <summary>
|
||||
/// 修正久期
|
||||
/// </summary>
|
||||
public decimal AD { get; set; }
|
||||
/// <summary>
|
||||
/// 凸性
|
||||
/// </summary>
|
||||
public decimal CV { get; set; }
|
||||
/// <summary>
|
||||
/// 基点价值
|
||||
/// </summary>
|
||||
public decimal DVBP { get; set; }
|
||||
/// <summary>
|
||||
/// 剩余期限
|
||||
/// </summary>
|
||||
public decimal remainTerm { get; set; }
|
||||
/// <summary>
|
||||
/// 关键基点价值
|
||||
/// </summary>
|
||||
public decimal KDVBP { get; set; }
|
||||
/// <summary>
|
||||
/// 关键久期
|
||||
/// </summary>
|
||||
public decimal KD { get; set; }
|
||||
public string errMsg { get; set; }
|
||||
public string errCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -105,9 +105,6 @@
|
||||
<FunctionSub Name="机构账号设置" Title="机构账号设置"></FunctionSub>
|
||||
<FunctionSub Name="机构账号设置新增" Title="机构账号设置新增" Type="Operate" Note="是否有机构账号设置新增权限" ></FunctionSub>
|
||||
<FunctionSub Name="机构账号设置编辑" Title="机构账号设置编辑" Type="Operate" Note="是否有机构账号设置编辑权限" ></FunctionSub>
|
||||
<FunctionSub Name="开放API配置" Title="开放API配置"></FunctionSub>
|
||||
<FunctionSub Name="开放API配置新增" Title="开放API配置新增" Type="Operate" Note="是否有开放API配置新增权限" ></FunctionSub>
|
||||
<FunctionSub Name="开放API配置编辑" Title="开放API配置编辑" Type="Operate" Note="是否有开放API配置编辑权限" ></FunctionSub>
|
||||
</FunctionParent>
|
||||
<FunctionParent Name="互换簿记预设" Title="互换簿记预设">
|
||||
<FunctionSub Name="TRS用簿记账户设置" Title="TRS用簿记账户设置"></FunctionSub>
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
{Name:"客户审批",Rights:["客户管理-客户审批"],Url:"clientApproval/openingclientList"},
|
||||
{Name:"资信等级有效期",Rights:["客户管理-资信等级有效期"],Url:"client_rating/List"},
|
||||
{Name:"黑名单客户",Rights:["客户管理-黑名单客户"],Url:"clientblack/clientblacklist"},
|
||||
{Name:"机构账号设置",Rights:["客户管理-机构账号设置"],Url:"v3/client/account"},
|
||||
{Name:"开放API配置",Rights:["客户管理-开放API配置"],Url:"v3/client/open-api"},
|
||||
{Name:"机构账号设置",Rights:["客户管理-机构账号设置"],Url:"v3/client/account"}
|
||||
]
|
||||
},
|
||||
{Name:"互换簿记预设",Rights:["互换簿记预设"],Icon:"menu-icon iconfour"
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace YLErp.Web.Controllers
|
||||
{
|
||||
|
||||
[AllowAnonymous]
|
||||
public JsonResult CalcBond(string underlyingCode, int positionType, decimal price, string valueDate)
|
||||
public JsonResult CalcBond(string underlyingCode, decimal price, string priceType)
|
||||
{
|
||||
var obj = HTCalcHepler.BondCalc(underlyingCode, positionType, price, valueDate);
|
||||
var obj = BondCalcHepler.BondCalc(underlyingCode, price, priceType);
|
||||
if (obj == null)
|
||||
{
|
||||
return JsonError("计算价格失败");
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"OnRspCalcBondTopic": "OnRspCalcBond", //互换成交收益率计算器消费topic
|
||||
"OnRspCalcBondTopicGroupId": "OnRspCalcBondConsumer", //互换成交收益率计算器消费topic消费组
|
||||
"AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2)
|
||||
"EnableCalcBongd": false //是否启用kafka计算
|
||||
"EnableCalcBongd": true //是否调用计算器
|
||||
},
|
||||
"BondOmsInterface": {
|
||||
"BaseUrl": "http://trs.yiliantech.com:8080/trs_hub_api",
|
||||
|
||||
Reference in New Issue
Block a user