Entity: Investment 250 46 null * presentValue double 3 false false false futureValue double 3 false false false internalRate double 3 false false false coupon double 3 false false false frequency int 3 false false false period double 3 false false false term double 3 false false false Operation: createFlows Investment true Integer.subrange(1,( term * frequency )->floor())->forAll( i | CashFlow->exists( f | f.amount = coupon & f.timePoint = i * period & f : flows )) Operation: totalValue Investment double r double query true result = flows->collect( f | f.amount / ( ( 1 + r )->pow(f.timePoint) ) )->sum() + futureValue / ( ( 1 + r )->pow(flows.last.timePoint) ) Operation: payout Investment double query true result = flows->collect(amount)->sum() + futureValue Operation: netPresentValue Investment double r double query true result = totalValue(r) - presentValue Operation: findirr Investment double r double rl double ru double query true v = totalValue(r) & ( ( v > presentValue + 0.0010 => result = findirr(( ru + r ) / 2,r,ru) ) & ( v < presentValue - 0.0010 => result = findirr(( r + rl ) / 2,rl,r) ) & ( true => result = r ) ) Operation: secantNPV Investment double rn double rminus double tvminus double tol double query true tvn = netPresentValue(rn) & ( tvn.abs < tol => result = rn ) & ( tvn.abs >= tol => result = secantNPV(rn - tvn * ( ( rn - rminus ) / ( tvn - tvminus ) ),rn,tvn,tol) ) Operation: dosecantNPV Investment double tol double query flows.size > 0 a = flows->collect(amount)->sum() + presentValue & r1 = (a/presentValue)->pow(2.0/flows.size) - 1 & totalValue1 = totalValue(r1) + presentValue & p = ((a / presentValue)->log())/((a / totalValue1)->log()) & r2 = (1 + r1)->pow(p) - 1 & result = secantNPV(r2, r1, totalValue1 - presentValue, tol) Operation: bisectionNPV Investment double r double rl double ru double tol double query tol > 0 & netPresentValue(rl)*netPresentValue(ru) < 0 v = netPresentValue(r) & ( ( ru - rl < tol => result = r ) & ( ru - rl >= tol & v*netPresentValue(rl) < 0 => result = bisectionNPV(( rl + r ) / 2,rl,r,tol) ) & ( ru - rl >= tol & v*netPresentValue(ru) < 0 => result = bisectionNPV(( r + ru ) / 2,r,ru,tol) ) & ( true => result = r ) ) Operation: cTotalValue Investment double r double query r > 0 result = flows->collect( f | f.amount * ( -r * f.timePoint )->exp() )->sum() + futureValue * ( -r * flows.last.timePoint )->exp() Operation: macaulayD Investment double r double query true result = (flows->collect(timeAmount(r))->sum() + futureValue*term/((1+r)->pow(term))) / totalValue(r) Entity: CashFlow 687 31 null * amount double 3 false false false timePoint double 3 false false false discount double 3 false false false rate double 3 false false false Operation: setDiscount CashFlow r double true discount = 1 / ( 1 + r )->pow(timePoint) Operation: discountedAmount CashFlow double query true result = amount * discount@pre Operation: timeAmount CashFlow double r double query true result = (timePoint * amount) / (( 1 + r )->pow(timePoint)) Entity: YieldData 30 299 null * maturity String 3 false true false timePoint double 3 false false false rate double 3 false false false Association: Investment CashFlow 1 460 84 688 70 0 flows null ordered GeneralUseCase: bootstrap false Constraint: null true Investment->exists( b | b.presentValue = 115 & b.term = 4 & b.frequency = 1 & b.period = 1.0 ) null bootstrap false Constraint: i : Integer.subrange(1,( term * frequency )->floor()) null CashFlow->exists( f | f.amount = 2 & f.timePoint = i * period & f : flows ) Investment bootstrap false Constraint: i : Integer.subrange(1,flows.size - 1) null flows[i].rate = YieldData[i + ""].rate & flows[i].discount = 1 / ( 1 + YieldData[i + ""].rate )->pow(flows[i].timePoint) Investment bootstrap false Constraint: n = flows.size null flows[n].discount = ( presentValue - Integer.Sum(1,n - 1,i,flows[i].discountedAmount()) ) / ( flows[n].amount + 100 ) Investment bootstrap false Constraint: n = flows.size null flows[n].rate = ( flows[n].discount->pow(-1 / flows[n].timePoint) ) - 1 Investment bootstrap false Constraint: n = flows.size null ( "The " + n + " period rate is " + flows[n].rate )->display() Investment bootstrap false GeneralUseCase: getValue false Constraint: null true createFlows() Investment getValue false Constraint: null true payout()->display() Investment getValue false Constraint: null true internalRate = findirr(0.25,0,0.5) & ("findirr rate: " + internalRate)->display() Investment getValue false Constraint: null true internalRate = bisectionNPV(0.25,0,0.5,0.001) & ("bisection rate: " + internalRate)->display() Investment getValue false Constraint: null true internalRate = dosecantNPV(0.001) & ("Secant rate: " + internalRate)->display() Investment getValue false Constraint: null true totalValue(0.05)->display() & cTotalValue(0.05)->display() & totalValue(0.02)->display() & cTotalValue(0.02)->display() Investment getValue false Constraint: null true macaulayD(internalRate)->display() Investment getValue false GeneralUseCase: purchaseBond trm double coup double price double freq int false Constraint: null true Investment->exists( b | b.term = trm & b.coupon = coup & b.presentValue = price & b.futureValue = 100.0 & b.frequency = freq & b.period = 1.0/freq) null purchaseBond false