本文整理汇总了C#中Compounding类的典型用法代码示例。如果您正苦于以下问题:C# Compounding类的具体用法?C# Compounding怎么用?C# Compounding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Compounding类属于命名空间,在下文中一共展示了Compounding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
示例4: InterestRate
public InterestRate(IDayCounter dc, double r, Compounding c, Frequency f)
{
_dc = dc;
_r = r;
_c = c;
_f = f;
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}