Node com.nodelab.interest.CalcStripYield

com.nodelab.0.10382
Instance of TypeScriptInfo

Node dataValue
org.edgescript.TypeScriptInfo.prerequisiteParcelsList{}
org.edgescript.TypeScriptInfo.prerequisiteMethodsList{}
org.edgescript.TypeScriptInfo.script/* BaliCalculator subclass: #BaliCalcStripYield instanceVariableNames: 'couponTable couponList coupon editMaturity bid editBid resultBid sourceName rateChoices interest yield yieldName yieldBid settlementText settlement sumYieldPrice sumNewPrice fetchedValues breakEvenDiff breakEven fixedRow ' classVariableNames: '' poolDictionaries: '' category: 'Bali'! !BaliCalcStripYield methodsFor: 'aspects'! bid bid isNil ifTrue: [(self source isKindOf: BaliSecBond) ifTrue: [ bid := (self source dataEnvironment: self display envDimensions) bid asDouble asValue] ifFalse: [bid := nil asValue]]. ^bid! breakEven "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^breakEven isNil ifTrue: [breakEven := 0 asValue] ifFalse: [breakEven]! breakEvenDiff "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^breakEvenDiff isNil ifTrue: [breakEvenDiff := 0 asValue] ifFalse: [breakEvenDiff]! coupon coupon isNil ifTrue: [ (self source isKindOf: BaliSecInterest) ifTrue: [coupon := (self source dataEnvironment: self display envDimensions) coupon asDouble asValue] ifFalse: [coupon := 0 asValue]]. ^coupon.! couponList | date aList yieldVal | couponList isNil ifTrue: [ date := self maturity. date isNil ifTrue: [^List new]. date type: #day. aList := List new. [date > (self settlementDate addYears: 1)] whileTrue: [date := date addYears: -1]. [date <= self maturity] whileTrue: [ date type: #day. aList addLast: date. yieldVal := nil. self source isNil ifFalse: [ (self source isKindOf: BaliYield) ifTrue: [ yieldVal := self source valueTime: self date maturity: (self display dimMaturity maturityYearsFrom: self date to: date) - self source maturityOffset]]. yieldVal isNil ifTrue: [aList addLast: 0] ifFalse: [aList addLast: yieldVal asDouble]. aList addLast: aList last. aList addLast: ''. aList addLast: ''. aList addLast: ''. aList addLast: ''. aList addLast: ''. date := date addYears: 1]. aList addLast: (date addYears: -1). aList addLast: (aList at: aList size - 7). aList addLast: aList last. aList addLast: ''. aList addLast: ''. aList addLast: ''. aList addLast: ''. aList addLast: ''. couponList := TwoDList on: aList columns: 8]. ^couponList.! couponList: aList couponList := aList! couponTable ^couponTable isNil ifTrue: [couponTable := TableInterface new selectionInTable: (SelectionInTable with: self couponList)] ifFalse: [couponTable]! couponTableSelection ^couponTableSelection isNil ifTrue: [couponTableSelection := SelectionInTable new tableHolder: (ValueHolder with: (TwoDList on: List new columns: 3)); selectionIndexHolder: (ValueHolder with: 1@1)] ifFalse: [couponTableSelection]! date ^self display dimHistory focus! date: aBaliTime self display dimHistory focus: aBaliTime.! dateText ^self display dimHistory focusHolder! editBid ^editBid isNil ifTrue: [editBid := 0 asValue] ifFalse: [editBid]! editMaturity ^editMaturity isNil ifTrue: [editMaturity := String new asValue] ifFalse: [editMaturity]! fetchedValues fetchedValues isNil ifTrue: [fetchedValues := false]. ^fetchedValues! fetchedValues: aBoolean fetchedValues := aBoolean! fixedRow "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^fixedRow isNil ifTrue: [fixedRow := false asValue] ifFalse: [fixedRow]! interest ^interest! interest: aBaliInterest interest := aBaliInterest. aBaliInterest isNil ifFalse: [self sourceName value: aBaliInterest name] ifTrue: [self sourceName value: ''].! maturity ^self display dimMaturity focusDate! maturity: aBaliTime self display dimMaturity focusDate: aBaliTime.! maturityText ^self display dimMaturity focusHolder! modifiedTime ^self date addYears: self firstSource maturityOffset.! resultBid ^resultBid isNil ifTrue: [resultBid := 0 asValue] ifFalse: [resultBid]! settlement settlement isNil ifTrue: [^settlement := 3]. ^settlement! settlement: aNumber settlement := aNumber. self settlementText value: (self settlementDate printType: #day) , ' (' , self settlement printString , ')'. self redrawComplete.! settlementDate ^(self date addYears: self source maturityOffset) settlement: self settlement! settlementText settlementText isNil ifTrue: [ settlementText := '' asValue. self settlement: self settlement]. ^settlementText! source ^self firstSource! sourceName ^sourceName isNil ifTrue: [self curves isEmpty ifTrue: [sourceName := String new asValue] ifFalse: [sourceName := self source printString asValue]] ifFalse: [sourceName]! sumNewPrice "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^sumNewPrice isNil ifTrue: [sumNewPrice := 0 asValue] ifFalse: [sumNewPrice]! sumYieldPrice "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^sumYieldPrice isNil ifTrue: [sumYieldPrice := 0 asValue] ifFalse: [sumYieldPrice]! yield ^yield! yield: aBaliYield yield := aBaliYield. aBaliYield isNil ifFalse: [self yieldName value: aBaliYield name] ifTrue: [self yieldName value: ''].! yieldBid ^yieldBid isNil ifTrue: [yieldBid := 0 asValue] ifFalse: [yieldBid]! yieldName ^yieldName isNil ifTrue: [yieldName := String new asValue] ifFalse: [yieldName]! ! !BaliCalcStripYield methodsFor: 'actions'! calculate | t x0 x1 x2 yieldRate newRate yieldPrice newPrice rows totalYieldPrice totalNewPrice env | self fetchedValues ifFalse: [ (self source isKindOf: BaliSecInterest) ifTrue: [ env := self display envDimensions. self bid value: (self source dataEnvironment: env) bid asDouble. self coupon value: (self source dataEnvironment: env) coupon asDouble. self display dimMaturity focusDate: (self source dataEnvironment: env) maturity]. self updateTable. self fetchedValues: true]. rows := self couponList rowSize. t := ((self couponList at: 1@1) subtractDate: (self date settlement: self settlement)) / 365. t < 0 ifTrue: [^nil]. yieldRate := self couponList at: 2@1. newRate := self couponList at: 3@1. yieldPrice := self coupon value / (1 + (t * yieldRate / 100)). newPrice := self coupon value / (1 + (t * newRate / 100)). totalYieldPrice := yieldPrice asDouble. totalNewPrice := newPrice asDouble. interest := BaliSecBond new. interest settlementDays: self settlement. self couponList at: 4@1 put: yieldPrice asDouble. self couponList at: 5@1 put: newPrice asDouble. self couponList at: 6@1 put: (interest deltaAt: self date maturity: (self couponList at: 1@1) rate: yieldRate coupon: 0). self couponList at: 7@1 put: (interest durationAt: self date maturity: (self couponList at: 1@1) rate: yieldRate coupon: 0). 2 to: rows - 1 do: [:r | t := ((self couponList at: 1@r) subtractDate360: self settlementDate) / 360. yieldRate := self couponList at: 2@r. newRate := self couponList at: 3@r. yieldPrice := self coupon value / (self raise: (1 + (yieldRate / 100)) to: t). newPrice := self coupon value / (self raise: (1 + (newRate / 100)) to: t). totalYieldPrice := totalYieldPrice + yieldPrice. totalNewPrice := totalNewPrice + newPrice. self couponList at: 4@r put: yieldPrice asDouble. self couponList at: 5@r put: newPrice asDouble. self couponList at: 6@r put: (interest deltaAt: self date maturity: (self couponList at: 1@r) rate: yieldRate coupon: 0). self couponList at: 7@r put: (interest durationAt: self date maturity: (self couponList at: 1@r) rate: yieldRate coupon: 0). ]. "totalYieldPrice := totalYieldPrice - yieldPrice." "totalNewPrice := totalNewPrice - newPrice." yieldRate := self couponList at: 2@rows. newRate := self couponList at: 3@rows. yieldPrice := 100 / (self raise: (1 + (yieldRate / 100)) to: t). newPrice := 100 / (self raise: (1 + (newRate / 100)) to: t). totalYieldPrice := totalYieldPrice + yieldPrice. totalNewPrice := totalNewPrice + newPrice. self couponList at: 4@rows put: yieldPrice asDouble. self couponList at: 5@rows put: newPrice asDouble. self sumYieldPrice value: totalYieldPrice. self sumNewPrice value: totalNewPrice. x0 := self couponList at: 2@1. x1 := x0 * 3/2 + 1. x2 := self optimize: [:rate | interest dirtyPriceAt: self date maturity: self maturity rate: rate coupon: self coupon value asDouble] final: totalYieldPrice lowStart: x0 highStart: x1 maxDiff: 0.00001. x2 isNil ifTrue: [^self resultBid value: nil]. x2 > 0 ifTrue: [self yieldBid value: x2 asDouble] ifFalse: [self yieldBid value: nil]. x0 := self couponList at: 3@1. x1 := x0 * 3/2 + 1. x2 := self optimize: [:rate | interest dirtyPriceAt: self date maturity: self maturity rate: rate coupon: self coupon value asDouble] final: totalNewPrice lowStart: x0 highStart: x1 maxDiff: 0.00001. self resultBid value: (x2 max: 0) asDouble.! changeBid | row | row := self couponTable selectionInTable selectionIndexHolder value y. row = 0 ifTrue: [^nil]. self couponList at: 3@row put: self editBid value. self calculate. row < self couponList rowSize ifTrue: [ couponTable selectionInTable selectionIndexHolder value: 1@(row + 1)]. self changeTable.! changeBreakEven | final | self coupon value = 0 ifTrue: [^Dialog warn: 'You must select a coupon']. final := BaliSecBond dirtyPriceAtSettlement: (self date settlement: self settlement value) maturity: self maturity rate: self breakEven value coupon: self coupon value. GotheObject optimize: [:d | self setDiff: d] final: final lowStart: -0.1 highStart: 0.1 maxDiff: 0.0000001 " GotheObject optimize: [:d | self setDiff: d] final: self breakEven value lowStart: 90 highStart: 110 maxDiff: 0.0001"! changeDate self display dimHistory realtime value: false. self date: (BaliTime fromString: self dateText value string). self reset.! changeFixedRow | row | row := self couponTable selectionInTable selectionIndexHolder value y. row = 0 ifTrue: [^nil]. self fixedRow value ifTrue: [self couponList at: 8@row put: 'Fixed'] ifFalse: [self couponList at: 8@row put: ''].! changeMaturity self maturity: (BaliTime fromString: self maturityText value). self updateTable. self calculate.! changeTable | row | row := couponTable selectionInTable selectionIndexHolder value y. (row < 1) ifTrue: [ self editMaturity value: ''. self editBid value: 0. ^nil]. self editMaturity value: (self couponList at: 1@row). self editBid value: (self couponList at: 3@row). self fixedRow value: (self couponList at: 8@row) = 'Fixed'.! nextSettlement self settlement: self settlement + 1. self updateTable. self calculate.! previousSettlement (self settlement > 1) ifTrue: [ self settlement: self settlement - 1. self updateTable. self calculate].! reset self editBid value: nil. self editMaturity value: nil. self settlement: self settlement. self fetchedValues: false. super reset.! setDiff: diff self breakEvenDiff value: diff. 1 to: self couponList rowSize do: [:r | (self couponList at: 8@r) = 'Fixed' ifFalse: [self couponList at: 3@r put: (self couponList at: 2@r) + diff]]. self calculate. ^self sumNewPrice value.! updateTable couponList := nil. self couponTable selectionInTable tableHolder value: self couponList.! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! BaliCalcStripYield class instanceVariableNames: ''! !BaliCalcStripYield class methodsFor: 'interface specs'! windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" ^#(#FullSpec #window: #(#WindowSpec #label: 'Strip Calculator' #min: #(#Point 263 240 ) #max: #(#Point 737 480 ) #bounds: #(#Rectangle 126 408 863 746 ) #flags: 4 #menu: #menu #colors: #(#LookPreferences #setForegroundColor: #(#ColorValue #black ) #setBackgroundColor: #(#ColorValue 6143 7167 8191 ) #setSelectionForegroundColor: #(#ColorValue #black ) #setSelectionBackgroundColor: #(#ColorValue 4915 4915 4915 ) #setBorderColor: #(#ColorValue #black ) ) #isEventDriven: true ) #component: #(#SpecCollection #collection: #( #(#TableViewSpec #layout: #(#LayoutFrame 1 0 94 0 730 0 -69 1 ) #flags: 13 #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #couponTable #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #changeTable ) #tabable: false #selectionStyle: #row ) #(#InputFieldSpec #layout: #(#LayoutFrame 4 0 1 0 -4 1 24 0 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7167 7679 8191 ) ) #model: #sourceName #tabable: false #alignment: #center #isReadOnly: true ) #(#InputFieldSpec #layout: #(#Rectangle 50 53 114 77 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue #white ) ) #model: #coupon #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #calculate ) #tabable: false #isReadOnly: false #type: #number ) #(#InputFieldSpec #layout: #(#Rectangle 171 53 261 76 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue #white ) ) #model: #maturityText #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #changeMaturity ) #tabable: false #isReadOnly: false ) #(#InputFieldSpec #layout: #(#LayoutFrame 4 0 -25 1 69 0 -3 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #bid #tabable: false #isReadOnly: true #type: #number ) #(#InputFieldSpec #layout: #(#LayoutFrame 4 0 -67 1 79 0 -46 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #editMaturity #tabable: false #isReadOnly: true ) #(#InputFieldSpec #layout: #(#LayoutFrame 169 0 -67 1 246 0 -46 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue #white ) ) #model: #editBid #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #changeBid ) #tabable: false #isReadOnly: false #type: #number ) #(#InputFieldSpec #layout: #(#LayoutFrame 175 0 -25 1 261 0 -3 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #resultBid #tabable: false #isReadOnly: true #type: #number #formatString: '0.0000' ) #(#LabelSpec #layout: #(#Point 115 55 ) #label: 'Maturity' ) #(#LabelSpec #layout: #(#Point 2 55 ) #label: 'Coupon' ) #(#LabelSpec #layout: #(#Point 2 27 ) #label: ' date' ) #(#InputFieldSpec #layout: #(#Rectangle 34 26 114 49 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue #white ) ) #model: #dateText #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #changeDate ) #tabable: false #isReadOnly: false ) #(#LabelSpec #layout: #(#Point 3 78 ) #label: ' date' ) #(#LabelSpec #layout: #(#Point 85 77 ) #label: 'Curve yield' ) #(#LabelSpec #layout: #(#Point 173 78 ) #label: 'New yield' ) #(#LabelSpec #layout: #(#LayoutOrigin 6 0 -45 1 ) #label: 'Quoted bid' ) #(#LabelSpec #layout: #(#LayoutOrigin 196 0 -45 1 ) #label: 'New bid' ) #(#InputFieldSpec #layout: #(#LayoutFrame 76 0 -25 1 165 0 -3 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #yieldBid #tabable: false #isReadOnly: true #type: #number #formatString: '0.0000' ) #(#LabelSpec #layout: #(#LayoutOrigin 93 0 -45 1 ) #label: 'Curve bid' ) #(#InputFieldSpec #layout: #(#Rectangle 171 26 261 49 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #settlementText #tabable: false #isReadOnly: true ) #(#LabelSpec #layout: #(#Point 115 29 ) #label: 'Settl.' ) #(#ArbitraryComponentSpec #layout: #(#LayoutFrame 114 0 -68 1 136 0 -45 1 ) #flags: 0 #component: #logotype ) #(#ActionButtonSpec #layout: #(#Rectangle 146 25 169 37 ) #flags: 0 #model: #nextSettlement #tabable: false #label: '+' #defaultable: true ) #(#ActionButtonSpec #layout: #(#Rectangle 146 37 169 49 ) #flags: 0 #model: #previousSettlement #tabable: false #label: '-' #defaultable: true ) #(#InputFieldSpec #layout: #(#LayoutFrame 256 0 -67 1 344 0 -46 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #sumYieldPrice #tabable: false #isReadOnly: true #type: #number ) #(#InputFieldSpec #layout: #(#LayoutFrame 353 0 -67 1 439 0 -46 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #sumNewPrice #tabable: false #isReadOnly: true #type: #number ) #(#LabelSpec #layout: #(#Point 255 78 ) #label: 'Curve cash flow' ) #(#LabelSpec #layout: #(#Point 353 78 ) #label: 'New cash flow' ) #(#InputFieldSpec #layout: #(#LayoutFrame 269 0 -25 1 362 0 -3 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue #white ) ) #model: #breakEven #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #changeBreakEven ) #type: #number ) #(#LabelSpec #layout: #(#LayoutOrigin 282 0 -45 1 ) #label: 'Break even' ) #(#InputFieldSpec #layout: #(#LayoutFrame 370 0 -25 1 468 0 -3 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue 7700 7700 7700 ) ) #model: #breakEvenDiff #tabable: false #isReadOnly: true #type: #number ) #(#LabelSpec #layout: #(#LayoutOrigin 404 0 -45 1 ) #label: ' diff' ) #(#LabelSpec #layout: #(#Point 470 79 ) #label: ' delta' ) #(#LabelSpec #layout: #(#Point 541 78 ) #label: ' duration' ) #(#LabelSpec #layout: #(#Point 630 78 ) #label: 'Fixed' ) #(#CheckBoxSpec #layout: #(#LayoutOrigin 445 0 -65 1 ) #colors: #(#LookPreferences #setBackgroundColor: #(#ColorValue #white ) ) #model: #fixedRow #callbacksSpec: #(#UIEventCallbackSubSpec #valueChangeSelector: #changeFixedRow ) #label: 'Fixed' ) ) ) )! ! */
org.edgescript.TypeScriptInfo.defineTypecom.nodelab.interest.CalcStripYield
org.edgescript.TypeScriptInfo.prerequisiteScriptsList{}