protected virtual void CheckBondGroupAverageMaturity(CheckParameter para) { int order = C_Order_BondMaturity;; string title = C_Title_BondMaturity; string description; double warningthreshhold = Convert.ToDouble(para.WarningValue); double failedthreshhold = Convert.ToDouble(para.FailedValue); double warningyears = warningthreshhold / 365; double failedyears = failedthreshhold / 365; MonitorItem mi; ASecurityGroup g = this.SecurityPortfolio.BondHoldings; if (g.SecurityList == null || g.SecurityList.Count == 0) { return; } mi = new MonitorItem(); mi.code = ""; mi.name = "债券组合"; mi.title = title; mi.order = order; mi.securityid = g.SecurityList.Count; mi.status = Status.Pass; double remainingdays = ((BondGroup)g).GetAverageMaturity(); double remainingyears = remainingdays / 365; mi.value = remainingdays.ToString() + "天"; description = C_Desc_BondGroupAverageMaturity.Replace("<1>", mi.name).Replace("<OP>", getOperatorName(para.Operator)); if (this.compareValue(para.Operator, remainingdays, failedthreshhold)) { //检查fail放在前 // 确保当failthreshhold=warningthreshhold时,显示fail mi.threshhold = failedthreshhold.ToString("N0") + "天"; mi.status = Status.Fail; mi.description = description.Replace("<2>", remainingdays.ToString("F2") + "天(" + remainingyears.ToString("N2") + "年)").Replace("<3>", failedthreshhold + "天(" + failedyears.ToString("N2") + "年)"); } else if (this.compareValue(para.Operator, remainingdays, warningthreshhold)) { mi.threshhold = warningthreshhold.ToString("N0") + "天"; mi.status = Status.Warning; mi.description = description.Replace("<2>", remainingdays.ToString("F2") + "天(" + remainingyears.ToString("N2") + "年)").Replace("<3>", warningthreshhold + "天(" + warningyears.ToString("N2") + "年)"); } else { mi.threshhold = warningthreshhold.ToString("N0") + "天"; mi.status = Status.Pass; mi.description = ""; } this.Report.Add(mi); }
/// <summary> /// 检查个券持仓占比 /// </summary> protected virtual void CheckPositionPct(CheckParameter para) { string title = C_Title_PositionPct; string description = "";; int order = C_Order_PositionPct; double warningthreshhold = Convert.ToDouble(para.WarningValue); double failthreshhold = Convert.ToDouble(para.FailedValue); MonitorItem mi; int id = 0; foreach (ASecurityGroup g in this.SecurityPortfolio.SecurityGroupList) { if (g.SecurityList == null || g.SecurityList.Count == 0) { continue; } foreach (ASecurity s in g.SecurityList) { mi = new MonitorItem(); mi.code = s.Code; mi.name = s.Name; mi.title = title; mi.order = order; mi.securityid = id++; mi.value = s.Position.MarketValuePct.ToString("P2"); mi.status = Status.Pass; description = C_Desc_SecurityType.Replace("<1>", s.Name + "(" + s.Code + ")").Replace("<OP>", getOperatorName(para.Operator)); if (this.compareValue(para.Operator, s.Position.MarketValuePct, failthreshhold)) { //检查fail放在前 // 确保当failthreshhold=warningthreshhold时,显示fail mi.threshhold = failthreshhold.ToString("P2"); mi.status = Status.Fail; mi.description = description.Replace("<2>", s.Position.MarketValuePct.ToString("P2")).Replace("<3>", failthreshhold.ToString("P2")); } else if (this.compareValue(para.Operator, s.Position.MarketValuePct, warningthreshhold)) { mi.threshhold = warningthreshhold.ToString("P2"); mi.status = Status.Warning; mi.description = description.Replace("<2>", s.Position.MarketValuePct.ToString("P2")).Replace("<3>", warningthreshhold.ToString("P2")); } else { mi.threshhold = warningthreshhold.ToString("P2"); mi.status = Status.Pass; mi.description = ""; } this.Report.Add(mi); } } }
public void Add(MonitorItem i) { if (i == null || i.securityid < 0) { return; } MonitorSummary s = new MonitorSummary(); s.Add(i); this.Add(s); }
public void Add(MonitorItem i) { if (i == null || i.securityid < 0) { return; } if (this.securityid < 0) { this.securityid = i.securityid; this.code = i.code; this.name = i.name; this.ItemList.Add(i); } else { if (i.securityid == this.securityid) { this.ItemList.Add(i); } else { return; } } //更新状态 if (i.status > this.status) { this.status = i.status; } switch (i.status) { case Status.Warning: this.WarningCounts += 1; break; case Status.Fail: this.FailCounts += 1; break; default: break; } }
/// <summary> /// 检查证券类型 /// 货币基金不得投资股票等资产 /// </summary> protected void CheckSecurityType() { string title = C_Title_SecurityType; string description; int order = C_Order_SecurityType; MonitorItem mi; int id = 0; foreach (ASecurityGroup g in this.SecurityPortfolio.SecurityGroupList) { if (g.SecurityList == null || g.SecurityList.Count == 0) { continue; } foreach (ASecurity s in g.SecurityList) { mi = new MonitorItem(); mi.code = s.Code; mi.name = s.Name; mi.title = title; mi.order = order; mi.securityid = id++; mi.status = Status.Pass; mi.value = s.Type.ToString(); mi.threshhold = "满足条件的债券"; description = C_Desc_PositionPct.Replace("<1>", s.Name + "(" + s.Code + ")"); switch (s.Type) { case SecurityType.Bond: switch (((Bond)s).SubType) { case BondType.Convertable: case BondType.Exchangable: case BondType.Other: mi.status = Status.Fail; mi.description = description.Replace("<2>", "可转换或可交换债券"); break; default: break; } switch (((Bond)s).IntAccruType) { case InterestType.Float: case InterestType.Other: mi.status = Status.Warning; mi.description = description.Replace("<2>", "以定期存款利率为基准利率的浮动利率债券"); mi.description += "(基准利率:" + ((Bond)s).IntFloatRateBase + ")"; if (((Bond)s).IntFloatRateBaseType == BaseRateType.TimeDeposit) { mi.status = Status.Fail; } break; default: break; } break; case SecurityType.Equity: case SecurityType.Fund: case SecurityType.Warrant: mi.status = Status.Fail; mi.description = description.Replace("<2>", "股票/基金/权证等高风险证券"); break; default: break; } this.Report.Add(mi); } } }
/// <summary> /// 检查债券估值偏离 /// </summary> protected virtual void CheckBondValueDeviation(CheckParameter para) { try { int order = C_Order_BondValueDeviation;; string title = C_Title_BondValueDeviation; string description; double warningthreshhold = Convert.ToDouble(para.WarningValue); double failedthreshhold = Convert.ToDouble(para.FailedValue); MonitorItem mi; int id = 0; ASecurityGroup g = this.SecurityPortfolio.BondHoldings; if (g.SecurityList == null || g.SecurityList.Count == 0) { return; } if (((Bond)g.SecurityList[0]).HistoryBondIntrinsicValue.OriginalTimeSeries.Count == 0) { g.LoadData(DataInfoType.HistoryBondValue); } foreach (ASecurity s in g.SecurityList) { mi = new MonitorItem(); mi.code = s.Code; mi.name = s.Name; mi.title = title; mi.order = order; mi.securityid = id++; mi.status = Status.Pass; double basevalue = s.Position.MarketValue / s.Position.Quantity; double estimatevalue = 0; if (((Bond)s).HistoryBondIntrinsicValue.AdjustedTimeSeries != null) { estimatevalue = ((HistoryItemBondValue)((Bond)s).HistoryBondIntrinsicValue.AdjustedTimeSeries[0]).ClearPrice; } double deviation = Math.Abs(estimatevalue / basevalue - 1); mi.value = deviation.ToString("P2"); description = C_Desc_BondValueDeviation.Replace("<1>", s.Name + "(" + s.Code + ")").Replace("<OP>", getOperatorName(para.Operator)); description = description.Replace("<4>", basevalue.ToString("N3")).Replace("<5>", estimatevalue.ToString("N4")); switch (s.Type) { case SecurityType.Bond: if (this.compareValue(para.Operator, deviation, failedthreshhold)) { //检查fail放在前 // 确保当failthreshhold=warningthreshhold时,显示fail mi.threshhold = failedthreshhold.ToString("P2"); mi.status = Status.Fail; mi.description = description.Replace("<2>", deviation.ToString("P2")).Replace("<3>", failedthreshhold.ToString("P2")); } else if (this.compareValue(para.Operator, deviation, warningthreshhold)) { mi.threshhold = warningthreshhold.ToString("P2"); mi.status = Status.Warning; mi.description = description.Replace("<2>", deviation.ToString("P2")).Replace("<3>", warningthreshhold.ToString("P2")); } else { mi.threshhold = warningthreshhold.ToString("P2"); mi.status = Status.Pass; mi.description = ""; } break; default: //对于非债券类型,无需作错误提示,会在其他步骤中检验 break; } this.Report.Add(mi); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 检查付息日 /// </summary> protected virtual void CheckBondPayment(CheckParameter para) { int order = C_Order_BondIntPayment;; string title = C_Title_BondIntPayment; string description; double warningthreshhold = Convert.ToDouble(para.WarningValue); double failedthreshhold = Convert.ToDouble(para.FailedValue); MonitorItem mi; int id = 0; ASecurityGroup g = this.SecurityPortfolio.BondHoldings; if (g.SecurityList == null || g.SecurityList.Count == 0) { return; } foreach (ASecurity s in g.SecurityList) { mi = new MonitorItem(); mi.code = s.Code; mi.name = s.Name; mi.title = title; mi.order = order; mi.securityid = id++; mi.status = Status.Pass; DateTime intPayment = ((Bond)s).IntNextPaymentDate; double remainingdays = (intPayment - DateTime.Today).Days; mi.value = remainingdays.ToString() + "天"; description = C_Desc_BondIntPayment.Replace("<1>", s.Name + "(" + s.Code + ")").Replace("<OP>", getOperatorName(para.Operator)); switch (s.Type) { case SecurityType.Bond: if (this.compareValue(para.Operator, remainingdays, failedthreshhold)) { //检查fail放在前 // 确保当failthreshhold=warningthreshhold时,显示fail mi.threshhold = failedthreshhold.ToString("N0") + "天"; mi.status = Status.Fail; mi.description = description.Replace("<2>", intPayment.ToString("yyyy-MM-dd")).Replace("<3>", failedthreshhold + "天"); } else if (this.compareValue(para.Operator, remainingdays, warningthreshhold)) { mi.threshhold = warningthreshhold.ToString("N0") + "天"; mi.status = Status.Warning; mi.description = description.Replace("<2>", intPayment.ToString("yyyy-MM-dd")).Replace("<3>", warningthreshhold + "天"); } else { mi.threshhold = warningthreshhold.ToString("N0") + "天"; mi.status = Status.Pass; mi.description = ""; } break; default: //对于非债券类型,无需作错误提示,会在其他步骤中检验 break; } this.Report.Add(mi); } }
/// <summary> /// 检查债券评级 /// </summary> protected virtual void CheckBondRating(CheckParameter para) { string title = C_Title_BondRating; string description; int order = C_Order_SecurityType; string failthreshhold = para.FailedValue.ToString(); string warningthreshhold = para.WarningValue.ToString(); int failRating = Bond.ConvertCreditRating(failthreshhold); int warnRating = Bond.ConvertCreditRating(warningthreshhold); MonitorItem mi; int id = 0; ASecurityGroup g = this.SecurityPortfolio.BondHoldings; if (g.SecurityList == null || g.SecurityList.Count == 0) { return; } foreach (ASecurity s in g.SecurityList) { mi = new MonitorItem(); mi.code = s.Code; mi.name = s.Name; mi.title = title; mi.order = order; mi.securityid = id++; mi.status = Status.Pass; mi.value = ((Bond)s).CreditRate; switch (((Bond)s).SubType) { case BondType.Treasury: case BondType.Central: case BondType.SpecialFinancial: mi.value = "AAA"; break; default: break; } description = C_Desc_BondRating.Replace("<1>", s.Name + "(" + s.Code + ")").Replace("<OP>", getOperatorName(para.Operator)); switch (s.Type) { case SecurityType.Bond: int currRating = Bond.ConvertCreditRating(mi.value); if (this.compareValue(para.Operator, currRating, failRating)) { //检查fail放在前 // 确保当failthreshhold=warningthreshhold时,显示fail mi.threshhold = failthreshhold; mi.status = Status.Fail; mi.description = description.Replace("<2>", mi.value).Replace("<3>", failthreshhold); Debug.WriteLine(mi.description); } else if (this.compareValue(para.Operator, currRating, warnRating)) { mi.threshhold = warningthreshhold; mi.status = Status.Warning; mi.description = description.Replace("<2>", mi.value).Replace("<3>", warningthreshhold); } else { mi.threshhold = warningthreshhold; mi.status = Status.Pass; mi.description = ""; } break; default: //对于非债券类型,无需作错误提示,会在其他步骤中检验 break; } this.Report.Add(mi); } }
/// <summary> /// 检查同一公司发行的债券持仓占比 /// </summary> protected virtual void CheckBondGroupPositionPct(CheckParameter para) { int order = C_Order_BondGroupPositionPct;; string title = C_Title_BondGroupPositionPct; string description; double warningthreshhold = Convert.ToDouble(para.WarningValue); double failedthreshhold = Convert.ToDouble(para.FailedValue); MonitorItem mi; ASecurityGroup g = this.SecurityPortfolio.BondHoldings; if (g.SecurityList == null || g.SecurityList.Count == 0) { return; } List <BondGroup.CompanyView> companylist = ((BondGroup)g).GetCompanyPositions(); int id = 0; foreach (BondGroup.CompanyView cv in companylist) { //当前公司仅有一个债券被持有,不做检验 if (cv.CompanyNumber == 1) { id++; continue; } mi = new MonitorItem(); mi.order = order; mi.title = title; mi.securityid = id++; mi.status = Status.Pass; mi.value = cv.TotalPosition.MarketValuePct.ToString("P2"); mi.name = cv.CompanyName; mi.code = ""; string allcodes = ""; foreach (PositionInfo p in cv.RelatedPositionList) { allcodes += p.Name + "(" + p.Code + "),"; } allcodes = allcodes.Substring(0, allcodes.Length - 1); description = C_Desc_BondGroupPositionPct.Replace("<1>", mi.name).Replace("<2>", allcodes).Replace("<OP>", getOperatorName(para.Operator)); if (this.compareValue(para.Operator, cv.TotalPosition.MarketValuePct, failedthreshhold)) { //检查fail放在前 // 确保当failthreshhold=warningthreshhold时,显示fail mi.threshhold = failedthreshhold.ToString("P2"); mi.status = Status.Fail; mi.description = description.Replace("<3>", cv.TotalPosition.MarketValuePct.ToString("P2")).Replace("<4>", failedthreshhold.ToString("P2")); } else if (this.compareValue(para.Operator, cv.TotalPosition.MarketValuePct, warningthreshhold)) { mi.threshhold = warningthreshhold.ToString("P2"); mi.status = Status.Warning; mi.description = description.Replace("<3>", cv.TotalPosition.MarketValuePct.ToString("P2")).Replace("<4>", warningthreshhold.ToString("P2")); } else { mi.threshhold = warningthreshhold.ToString("P2"); mi.status = Status.Pass; mi.description = ""; } this.Report.Add(mi); } }