本文整理汇总了C#中Compounding类的典型用法代码示例。如果您正苦于以下问题:C# Compounding类的具体用法?C# Compounding怎么用?C# Compounding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Compounding类属于命名空间,在下文中一共展示了Compounding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EquivalentRate
public InterestRate EquivalentRate(IDayCounter dc, Compounding c, Frequency f, DateTimeOffset d1, DateTimeOffset d2)
{
var t1 = _dc.YearFraction(d1, d2);
var t2 = dc.YearFraction(d1, d2);
var compoundFactor = CompoundFactor(t1);
return ImpliedRate(dc, compoundFactor, c, f, t2);
}
开发者ID:agryb,项目名称:XBTQ,代码行数:7,代码来源:InterestRate.cs
示例2: FlatForward
public FlatForward(Date referenceDate, double forward, DayCounter dayCounter, Compounding compounding, Frequency frequency)
: base(referenceDate, new Calendar(), dayCounter)
{
forward_ = new SimpleQuote(forward);
compounding_ = compounding;
frequency_ = frequency;
}
开发者ID:akasolace,项目名称:qlnet,代码行数:7,代码来源:Flatforward.cs
示例3: ImpliedRate
public static InterestRate ImpliedRate(IDayCounter dc, double compoundFactor, Compounding c, Frequency f, double time)
{
double r;
if (Helper.Equals(compoundFactor, 1.0))
{
r = 0.0;
}
else
{
switch (c)
{
case Compounding.Simple:
r = (compoundFactor - 1.0)/time;
break;
case Compounding.Compounded:
r = (Math.Pow(compoundFactor, 1.0 / ((double)f * time)) - 1.0) * (double)f;
break;
case Compounding.Continuous:
r = Math.Log(compoundFactor)/time;
break;
default:
throw new NotImplementedException($"Unknown Compounding {c}");
}
}
return new InterestRate(dc, r, c, f);
}
开发者ID:agryb,项目名称:XBTQ,代码行数:27,代码来源:InterestRate.cs
示例4: InterestRate
public InterestRate(IDayCounter dc, double r, Compounding c, Frequency f)
{
_dc = dc;
_r = r;
_c = c;
_f = f;
}
开发者ID:agryb,项目名称:XBTQ,代码行数:7,代码来源:InterestRate.cs
示例5: CommonVars
// setup
public CommonVars()
{
// force garbage collection
// garbage collection in .NET is rather weird and we do need when we run several tests in a row
GC.Collect();
// data
calendar = new TARGET();
settlementDays = 2;
today = new Date(9, Month.June, 2009);
compounding = Compounding.Continuous;
dayCount = new Actual360();
settlementDate = calendar.advance(today, settlementDays, TimeUnit.Days);
Settings.setEvaluationDate(today);
int[] ts = new int[] { 13, 41, 75, 165, 256, 345, 524, 703 };
double[] r = new double[] { 0.035, 0.033, 0.034, 0.034, 0.036, 0.037, 0.039, 0.040 };
List<double> rates = new List<double>() { 0.035 };
List<Date> dates = new List<Date>() { settlementDate };
for (int i = 0; i < 8; ++i)
{
dates.Add(calendar.advance(today, ts[i], TimeUnit.Days));
rates.Add(r[i]);
}
termStructure = new InterpolatedZeroCurve<Linear>(dates, rates, dayCount);
}
开发者ID:minikie,项目名称:test,代码行数:28,代码来源:T_PiecewiseZeroSpreadedTermStructure.cs
示例6: flatRate
static YieldTermStructure flatRate(Date today,
double forward,
DayCounter dc,
Compounding compounding,
Frequency frequency)
{
return new FlatForward(today, forward, dc, compounding, frequency);
//FlatForward flatRate = new FlatForward(settlementDate, r.rate(), r.dayCounter(), r.compounding(), r.frequency());
}
开发者ID:Yenyenx,项目名称:qlnet,代码行数:9,代码来源:CallableBonds.cs
示例7: YieldFinder
public YieldFinder(double faceAmount, List<CashFlow> cashflows, double dirtyPrice, DayCounter dayCounter, Compounding compounding, Frequency frequency, Date settlement)
{
_faceAmount = faceAmount;
_cashflows = cashflows;
_dirtyPrice = dirtyPrice;
_compounding = compounding;
_dayCounter = dayCounter;
_frequency = frequency;
_settlement = settlement;
}
开发者ID:StreetConnect,项目名称:QLNet,代码行数:10,代码来源:YieldFinder.cs
示例8: InterestRateData
public InterestRateData(double _r, Compounding _comp, Frequency _freq, double _t, Compounding _comp2, Frequency _freq2, double _expected, int _precision)
{
r = _r;
comp = _comp;
freq = _freq;
t = _t;
comp2 = _comp2;
freq2 = _freq2;
expected = _expected;
precision = _precision;
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:11,代码来源:T_InterestRate.cs
示例9: InterestRate
public InterestRate(double? r, DayCounter dc, Compounding comp, Frequency freq) {
r_ = r;
dc_ = dc;
comp_ = comp;
if (comp_ == Compounding.Compounded || comp_ == Compounding.SimpleThenCompounded)
{
freqMakesSense_ = true;
if (!(freq != Frequency.Once && freq != Frequency.NoFrequency))
throw new ArgumentException("Frequency not allowed for this interest rate");
freq_ = (double)freq;
}
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:13,代码来源:InterestRate.cs
示例10: zeroRate
public InterestRate zeroRate(Date d, DayCounter dayCounter, Compounding comp, Frequency freq, bool extrapolate)
{
if (d == referenceDate())
{
double t = 0.0001;
double compound = 1 / discount(t, extrapolate);
return InterestRate.impliedRate(compound, t, dayCounter, comp, freq);
}
else
{
double compound = 1 / discount(d, extrapolate);
return InterestRate.impliedRate(compound, referenceDate(), d, dayCounter, comp, freq);
}
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:14,代码来源:YieldTermStructure.cs
示例11: ZeroSpreadedTermStructure
public ZeroSpreadedTermStructure(Handle<YieldTermStructure> h, Quote spread, Compounding comp, Frequency freq, DayCounter dc) {
originalCurve_ = h;
spread_ = spread;
comp_ = comp;
freq_ = freq;
dc_ = dc;
//QL_REQUIRE(h->dayCounter()==dc_,
// "spread daycounter (" << dc_ <<
// ") must be the same of the curve to be spreaded (" <<
// originalCurve_->dayCounter() <<
// ")");
originalCurve_.registerWith(update);
spread_.registerWith(update);
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:14,代码来源:ZeroSpreadedTermStructure.cs
示例12: InterestRate
//! Standard constructor
public InterestRate(double r, DayCounter dc, Compounding comp, Frequency freq)
{
r_ = r;
dc_ = dc;
comp_ = comp;
freqMakesSense_ = false;
if (comp_ == Compounding.Compounded || comp_ == Compounding.SimpleThenCompounded)
{
freqMakesSense_ = true;
Utils.QL_REQUIRE(freq != Frequency.Once && freq != Frequency.NoFrequency, "frequency not allowed for this interest rate");
freq_ = (double)freq;
}
}
开发者ID:huxletic,项目名称:qlnet,代码行数:16,代码来源:InterestRate.cs
示例13: ZeroSpreadedTermStructure
public ZeroSpreadedTermStructure(Handle<YieldTermStructure> h,
Handle<Quote> spread,
Compounding comp = Compounding.Continuous,
Frequency freq = Frequency.NoFrequency,
DayCounter dc = null)
{
originalCurve_ = h;
spread_ = spread;
comp_ = comp;
freq_ = freq;
dc_ = dc;
originalCurve_.registerWith(update);
spread_.registerWith(update);
}
开发者ID:Yenyenx,项目名称:qlnet,代码行数:15,代码来源:ZeroSpreadedTermStructure.cs
示例14: npv
// NPV of the cash flows.
// The NPV is the sum of the cash flows, each discounted
// according to the z-spreaded term structure. The result
// is affected by the choice of the z-spread compounding
// and the relative frequency and day counter.
public static double npv(Leg leg,YieldTermStructure discountCurve,double zSpread,DayCounter dc,Compounding comp,
Frequency freq,bool includeSettlementDateFlows,
Date settlementDate = null,Date npvDate = null)
{
if (leg.empty())
return 0.0;
if (settlementDate == null)
settlementDate = Settings.evaluationDate();
if (npvDate == null)
npvDate = settlementDate;
Handle<YieldTermStructure> discountCurveHandle = new Handle<YieldTermStructure>(discountCurve);
Handle<Quote> zSpreadQuoteHandle = new Handle<Quote>(new SimpleQuote(zSpread));
ZeroSpreadedTermStructure spreadedCurve = new ZeroSpreadedTermStructure(discountCurveHandle,zSpreadQuoteHandle,
comp, freq, dc);
spreadedCurve.enableExtrapolation(discountCurveHandle.link.allowsExtrapolation());
return npv(leg, spreadedCurve, includeSettlementDateFlows, settlementDate, npvDate);
}
开发者ID:akasolace,项目名称:qlnet,代码行数:28,代码来源:CashFlows.cs
示例15: yieldValueBasisPoint
public static double yieldValueBasisPoint(Leg leg, double yield, DayCounter dayCounter, Compounding compounding,
Frequency frequency, bool includeSettlementDateFlows, Date settlementDate = null,
Date npvDate = null)
{
return yieldValueBasisPoint(leg, new InterestRate(yield, dayCounter, compounding, frequency),
includeSettlementDateFlows, settlementDate, npvDate);
}
开发者ID:akasolace,项目名称:qlnet,代码行数:7,代码来源:CashFlows.cs
示例16: zSpread
//! implied Z-spread.
public static double zSpread(Leg leg, double npv, YieldTermStructure discount, DayCounter dayCounter, Compounding compounding,
Frequency frequency, bool includeSettlementDateFlows, Date settlementDate = null,
Date npvDate = null, double accuracy = 1.0e-10, int maxIterations = 100, double guess = 0.0)
{
if (settlementDate == null)
settlementDate = Settings.evaluationDate();
if (npvDate == null)
npvDate = settlementDate;
Brent solver = new Brent();
solver.setMaxEvaluations(maxIterations);
ZSpreadFinder objFunction = new ZSpreadFinder(leg,discount,npv,dayCounter, compounding, frequency,
includeSettlementDateFlows, settlementDate, npvDate);
double step = 0.01;
return solver.solve(objFunction, accuracy, guess, step);
}
开发者ID:akasolace,项目名称:qlnet,代码行数:18,代码来源:CashFlows.cs
示例17: CommonVars
//public IndexHistoryCleaner indexCleaner;
// initial setup
public CommonVars()
{
backup = new SavedSettings();
//indexCleaner = new IndexHistoryCleaner();
termStructure = new RelinkableHandle<YieldTermStructure>();
int swapSettlementDays = 2;
faceAmount = 100.0;
BusinessDayConvention fixedConvention = BusinessDayConvention.Unadjusted;
compounding = Compounding.Continuous;
Frequency fixedFrequency = Frequency.Annual;
Frequency floatingFrequency = Frequency.Semiannual;
iborIndex = new Euribor(new Period(floatingFrequency), termStructure);
Calendar calendar = iborIndex.fixingCalendar();
swapIndex= new SwapIndex("EuriborSwapIsdaFixA", new Period(10,TimeUnit.Years), swapSettlementDays,
iborIndex.currency(), calendar,
new Period(fixedFrequency), fixedConvention,
iborIndex.dayCounter(), iborIndex);
spread = 0.0;
nonnullspread = 0.003;
Date today = new Date(24,Month.April,2007);
Settings.setEvaluationDate(today);
//Date today = Settings::instance().evaluationDate();
termStructure.linkTo(Utilities.flatRate(today, 0.05, new Actual365Fixed()));
pricer = new BlackIborCouponPricer();
Handle<SwaptionVolatilityStructure> swaptionVolatilityStructure =
new Handle<SwaptionVolatilityStructure>(new ConstantSwaptionVolatility(today,
new NullCalendar(),BusinessDayConvention.Following, 0.2, new Actual365Fixed()));
Handle<Quote> meanReversionQuote = new Handle<Quote>(new SimpleQuote(0.01));
cmspricer = new AnalyticHaganPricer(swaptionVolatilityStructure, GFunctionFactory.YieldCurveModel.Standard, meanReversionQuote);
}
开发者ID:akasolace,项目名称:qlnet,代码行数:35,代码来源:T_AssetSwap.cs
示例18: impliedYield
/*! Simple yield calculation based on underlying spot and
forward values, taking into account underlying income.
When \f$ t>0 \f$, call with:
underlyingSpotValue=spotValue(t),
forwardValue=strikePrice, to get current yield. For a
repo, if \f$ t=0 \f$, impliedYield should reproduce the
spot repo rate. For FRA's, this should reproduce the
relevant zero rate at the FRA's maturityDate_;
*/
public InterestRate impliedYield(double underlyingSpotValue, double forwardValue, Date settlementDate,
Compounding compoundingConvention, DayCounter dayCounter) {
double tenor = dayCounter.yearFraction(settlementDate,maturityDate_) ;
double compoundingFactor = forwardValue/ (underlyingSpotValue-spotIncome(incomeDiscountCurve_)) ;
return InterestRate.impliedRate(compoundingFactor,
tenor,
dayCounter,
compoundingConvention);
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:19,代码来源:forward.cs
示例19: yieldValueBasisPoint
public static double yieldValueBasisPoint(Bond bond, double yield, DayCounter dayCounter, Compounding compounding, Frequency frequency) {
double ret = NQuantLibcPINVOKE.BondFunctions_yieldValueBasisPoint__SWIG_3(Bond.getCPtr(bond), yield, DayCounter.getCPtr(dayCounter), (int)compounding, (int)frequency);
if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs
示例20: basisPointValue
public static double basisPointValue(Bond bond, double yield, DayCounter dayCounter, Compounding compounding, Frequency frequency, Date settlementDate) {
double ret = NQuantLibcPINVOKE.BondFunctions_basisPointValue__SWIG_2(Bond.getCPtr(bond), yield, DayCounter.getCPtr(dayCounter), (int)compounding, (int)frequency, Date.getCPtr(settlementDate));
if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs
注:本文中的Compounding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论