本文整理汇总了C#中CarbonClient.PriceBondAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CarbonClient.PriceBondAsync方法的具体用法?C# CarbonClient.PriceBondAsync怎么用?C# CarbonClient.PriceBondAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CarbonClient
的用法示例。
在下文中一共展示了CarbonClient.PriceBondAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHistoricValues
public static IEnumerable<KeyValuePair<string, double>> GetHistoricValues(
BondMarket market_,
MongoBond bond_,
double price_,
DateTime asOf_,
CarbonClient client_,
string pricingSetup_="Sym_LIBOR"
)
{
try
{
var baseBondId = getBaseBondID(market_, bond_.Maturity);
var result = client_.PriceBondAsync(
baseBondId: (long)baseBondId,
issueDate: DateConversions.ToNodaLocalDate(bond_.IssueDate),
maturityDate: DateConversions.ToNodaLocalDate(bond_.Maturity),
coupon: bond_.Coupon / 100d,
asof: asOf_,
pricingSetup: pricingSetup_,
quantity: 1000000d,
stubDate: DateConversions.ToNodaLocalDate(bond_.FirstCouponDate),
price: price_).Result;
if (result.Results.Any(x => double.IsNaN(x.Value)))
{
Logger.Error(
string.Format("At least one Null value returned from carbon Date={0}, Market={1}", asOf_.ToString("dd-MMM-yyyy"),
market_), typeof(CarbonHistoricRetriever));
}
return result.Results;
}
catch (Exception ex_)
{
Logger.Error("Error pricing bond", typeof(CarbonHistoricRetriever), ex_);
return null;
}
}
示例2: GetSpreads
internal static BondSpreadResult GetSpreads(
OTBond bondType_,
NodaTime.LocalDate maturity_,
NodaTime.LocalDate issueDate_,
NodaTime.LocalDate firstCouponDate_,
QuoteValueType priceType_,
double priceValue_,
double coupon_,
CurveMappings.Mapping pricingSetup_,
DateTime asOf_,
CarbonClient client_,
ThrowBehavior behavior_=ThrowBehavior.DontThrow )
{
var ret = new BondSpreadResult();
ret.Spreads = new BondSpread();
try
{
SLog.log.DebugFormat(
"Calling PriceBondAsync with params: baseBondID={0} issueDate={1} maturity={2} coupon={3} asOf={4} pricingSetup={5} stubDate={6} priceValue={7}, priceType_={8}",
((long) bondType_).ToString(), issueDate_, maturity_, coupon_, asOf_, pricingSetup_.OT_BondPricingSetup,
firstCouponDate_, priceValue_, priceType_);
switch (priceType_)
{
case QuoteValueType.Price:
{
ret.Price = priceValue_;
var result = client_.PriceBondAsync(
baseBondId: (long)bondType_,
issueDate: issueDate_,
maturityDate: maturity_,
coupon: coupon_,
asof: asOf_,
pricingSetup: pricingSetup_.OT_BondPricingSetup,
quantity: 100000d,
stubDate: firstCouponDate_,
price: ret.Price.Value).Result;
ret.Spreads.Spread = -result.Results[ServiceConstants.KEY_ASW_YY];
ret.Spreads.TrueSpread = -result.Results[ServiceConstants.KEY_ZSpread];
ret.Spreads.Yield = result.Results[ServiceConstants.KEY_Yield];
}
break;
case QuoteValueType.Yield:
{
var result = client_.GetBondPriceFromYieldAsync(
baseBondId: (long)bondType_,
issueDate: issueDate_,
maturityDate: maturity_,
coupon: coupon_,
asof: asOf_,
pricingSetup: pricingSetup_.OT_BondPricingSetup,
quantity: 100000d,
yield: priceValue_,
stubDate: firstCouponDate_).Result;
ret.Price = result.Results[ServiceConstants.KEY_Price];
ret.Spreads.Spread = -result.Results[ServiceConstants.KEY_ASW_YY];
ret.Spreads.TrueSpread = -result.Results[ServiceConstants.KEY_ZSpread];
ret.Spreads.Yield = priceValue_;
}
break;
default:
SLog.log.ErrorFormat("Cannot call Carbon to get spreads with priceType {0}", priceType_);
break;
}
SLog.log.DebugFormat(
"Calling PriceSwapAsync with params: curveName={0} startDate={1} endDate={2} asOf={3} pricingSetup={4}",
pricingSetup_.OT_Swap, issueDate_, maturity_, asOf_, pricingSetup_.OT_BondPricingSetup);
var mmsResult = client_.PriceSwapAsync(
curveName: pricingSetup_.OT_Swap,
startDate: asOf_.ToNodaLocalDate(),
endDate: maturity_,
asof: asOf_,
pricingSetup: pricingSetup_.OT_BondPricingSetup).Result;
ret.Spreads.MMS = mmsResult.Results[ServiceConstants.KEY_MMS];
SLog.log.DebugFormat("Result: y={0} m={1} s={2} t={3}", ret.Spreads.Yield, ret.Spreads.MMS, ret.Spreads.Spread, ret.Spreads.TrueSpread);
postProcess(bondType_, ret.Spreads, pricingSetup_);
}
catch (Exception ex_)
{
Exceptions.Rethrow("GetCurves", behavior_, ex_);
}
return ret;
}