Node com.nodelab.interest.CalcBond

com.nodelab.0.10378
Instance of TypeScriptInfo

Node dataValue
org.edgescript.TypeScriptInfo.prerequisiteParcelsList{}
org.edgescript.TypeScriptInfo.prerequisiteMethodsList{}
org.edgescript.TypeScriptInfo.script/* constructor() { View:(); } class Boolean isResourceOf(Listable node, Symbol aspect) { if (aspect == #views) return true; false; } class String resourceLabel() "Name of resource" { "bond calculator"; } inline introspect Collection[Class] requiredConditions() { #(ConditionHistory, ConditionMaturity); } Void designView(WidgetWorkspace ws) { InstrumentBond bond = InstrumentBond{partAt(0).source}; ws.addHeader(new Place(0, 0).setDimensions(3, 1).setWeight(1.0, 0.0, #horizontal), this); ws.addLabel(new Place(0, 1), "Date"); Condition condHist = conditionType(ConditionHistory); ws.addField( new Place(1, 1).setWeight(1.0, 0.0, #horizontal).setDimensions(2, 1), condHist, null); ws.addLabel(new Place(0, 2), "Settlement"); Value[Int] settlement = new Value(Int, 3); ws.addField( new Place(1, 2).setPrefSize(30, 0).setFill(#none), settlement, null); ws.addLabel(new Place(2, 1), "days"); Value[Time] settlementDate = new Value(Time, null); WidgetField f = ws.addField( new Place(1, 3).setDimensions(2, 1), settlementDate, null); ws.setTrigger(Void(){ settlementDate.set(Time{condHist.focus}.settlement(settlement.value)); }); // f.addListener(Void(){settlement = null}); ws.addLabel(new Place(0, 4), "Maturity"); Value[Time] maturity = new Value(Time, bond.aspectValue(#maturity)); ws.addField( new Place(1, 4).setDimensions(2, 1), maturity, null); ws.addLabel(new Place(0, 5), "Rate"); Value[Real] rate = new Value(Real, bond.aspectValue(#bid)); ws.addField( new Place(1, 5).setDimensions(2, 1), rate, null); condHist.addListener(Void() {rate.set(bond.aspectValue(#bid))}); ws.addLabel(new Place(0, 6), "Coupon"); Value[Real] coupon = new Value(Real, bond.aspectValue(#coupon)); ws.addField( new Place(1, 6).setDimensions(2, 1), coupon, null); ws.addLabel(new Place(0, 7), "Dirty price"); Value[Real] dirtyPrice = new Value(Real, null); ws.addField( new Place(1, 7).setDimensions(2, 1), dirtyPrice, null); ws.setTrigger(Void(){ dirtyPrice.set(InstrumentBond.dirtyPriceQuote(settlementDate.value, maturity.value, rate.value, coupon.value)); }); ws.addLabel(new Place(0, 8), "Clean price"); Value[Real] cleanPrice = new Value(Real, null); ws.addField( new Place(1, 8).setDimensions(2, 1), cleanPrice, null); ws.setTrigger(Void(){ cleanPrice.set(InstrumentBond.cleanPriceQuote(settlementDate.value, maturity.value, rate.value, coupon.value)); }); ws.addLabel(new Place(0, 9), "Delta"); Value[Real] delta = new Value(Real, null); ws.addField( new Place(1, 9).setDimensions(2, 1), delta, null); ws.setTrigger(Void(){ delta.set(InstrumentBond.delta(settlementDate.value, maturity.value, rate.value, coupon.value)); }); ws.addLabel(new Place(0, 10), "Duration"); Value[Real] duration = new Value(Real, null); ws.addField( new Place(1, 10).setDimensions(2, 1), duration, null); ws.setTrigger(Void(){ duration.set(InstrumentBond.duration(settlementDate.value, maturity.value, rate.value, coupon.value)); }); ws.addLabel(new Place(0, 11), "Mod Dur"); Value[Real] modDuration = new Value(Real, null); ws.addField( new Place(1, 11).setDimensions(2, 1), modDuration, null); ws.setTrigger(Void(){ modDuration.set(InstrumentBond.modDuration(settlementDate.value, maturity.value, rate.value, coupon.value)); }); ws.addLabel(new Place(0, 12), "Convexity"); Value[Real] convexity = new Value(Real, null); ws.addField( new Place(1, 12).setDimensions(2, 1), convexity, null); ws.setTrigger(Void(){ convexity.set(InstrumentBond.convexity(settlementDate.value, maturity.value, rate.value, coupon.value)); }); } */
org.edgescript.TypeScriptInfo.defineTypecom.nodelab.interest.CalcBond
org.edgescript.TypeScriptInfo.prerequisiteScriptsList{}