Node org.unizone.finance.equity.VolatilityBS

org.unizone.0.8532
Instance of TypeScriptInfo

Node dataValue
org.edgescript.TypeScriptInfo.prerequisiteParcelsList{}
org.edgescript.TypeScriptInfo.prerequisiteMethodsList{}
org.edgescript.TypeScriptInfo.script/* BaliTimeSource subclass: #BaliVolatilityBS instanceVariableNames: ' days standardVol ' classVariableNames: '' poolDictionaries: '' category: 'Bali'! !BaliVolatilityBS methodsFor: 'black&scholes'! cashFlowVol: vol rate: rate timeArray: timeArray valueArray: valueArray | extraDays matDate call delta cashFlow trailDelta res strikePrice spotPrice years lastPrice | extraDays := 10. spotPrice := strikePrice := valueArray at: 1. matDate := timeArray last addDays: extraDays. delta := 0. cashFlow := 0. spotPrice isNil ifFalse: [ years := (matDate subtractDate: timeArray first) / 365. call := self nextSource bsPriceCall: true spot: spotPrice years: years strike: strikePrice sigma: vol rate: rate. delta := self nextSource bsDeltaCall: true spot: spotPrice years: years strike: strikePrice sigma: vol rate: rate. cashFlow := (spotPrice * delta - call) * (self raise: (1 + (rate / 100)) to: (years - (extraDays / 365)))]. 2 to: timeArray size do: [:i | trailDelta := delta. spotPrice := valueArray at: i. spotPrice isNil ifFalse: [ strikePrice isNil ifTrue: [strikePrice := spotPrice]. lastPrice := spotPrice. years := (matDate subtractDate: (timeArray at: i)) / 365. delta := self nextSource bsDeltaCall: true spot: spotPrice years: years strike: strikePrice sigma: vol rate: rate. cashFlow := cashFlow + ((delta - trailDelta) * spotPrice * (self raise: (1 + (rate / 100)) to: (years - (extraDays / 365))))]]. res := cashFlow - (lastPrice * delta) + (self nextSource bsPriceCall: true spot: lastPrice years: years strike: strikePrice sigma: vol rate: rate). ^res! volCalcRate: rate environment: env | res startVol src newEnv set sourceSteps array | startVol := self standardVol valueAspect: #value environment: env. startVol isNil ifTrue: [startVol := 25]. src := self nextSource. newEnv := JazzEnvironment new. newEnv localAt: 'cond_history_from' put: (env timestamp subtractDays: self days value). newEnv localAt: 'cond_history_to' put: env timestamp. newEnv localAt: 'cond_history_resolution' put: #day. set := Set new. src collectStepsDim: #dimHistory environment: newEnv into: set. sourceSteps := set asList. sourceSteps sort. (sourceSteps size = 0 or: [(env timestamp subtractDate: (sourceSteps at: 1)) < (self days value - 10)]) ifTrue: [^nil]. array := Array new: sourceSteps size. 1 to: array size do: [:i | newEnv localAt: 'cond_history' put: (sourceSteps at: i). array at: i put: (src valueAspect: #price environment: newEnv)]. res := self optimize: [:vol | vol > 0 ifTrue: [self cashFlowVol: vol rate: rate timeArray: sourceSteps valueArray: array] ifFalse: [self cashFlowVol: 1 rate: rate timeArray: sourceSteps valueArray: array]] final: 0 lowStart: startVol * 0.5 highStart: startVol * 1.5 maxDiff: 0.0001. ^res! ! !BaliVolatilityBS methodsFor: 'source'! asSourceAdaptor self user currentSource isNil ifTrue: [^nil]. self nextSource: self user currentSource. self user sourceCommandQty value > 0 ifTrue: [self days value: self user sourceCommandQty value]. ^self! basicValueTypes ^#(#volatility)! defaultName self nextSource isNil ifTrue: [^self days truncated printString , ' days volatility']. ^self days value truncated printString , ' days B&S vol ' , self nextSource name.! ! !BaliVolatilityBS methodsFor: 'aspects'! days days isNil ifTrue: [days := 30 asValue]. ^days! nextSource: aBaliSource super nextSource: aBaliSource. self standardVol nextSource: aBaliSource.! standardVol standardVol isNil ifTrue: [standardVol := BaliVolatility new days: self days; nextSource: self nextSource]. ^standardVol! ! !BaliVolatilityBS methodsFor: 'timeSource'! basicCreateDataAt: aBaliTime resolution: aResolution environment: env | data | self server user report: 'Preparing ' , self name , ' at ' , (aBaliTime printType: #day). data := BaliTimeData new source: self. data aspects at: #timestamp put: aBaliTime. data aspects at: #value put: (self volCalcRate: self server defaultRate environment: env). self server user report: ''. ^data! ! !BaliVolatilityBS methodsFor: 'copying'! baliCopy: aDictionary | src | src := aDictionary at: self ifAbsent: nil. src isNil ifFalse: [^src]. src := super baliCopy: aDictionary. src days value: self days value. ^src! ! !BaliVolatilityBS methodsFor: ' database'! addDefinition | aspects | (aspects := super addDefinition) isNil ifTrue: [^nil]. self addAspect: #dbDays value: self days value printString position: aspects + 1. ^aspects + 1! dbDays: aString self days value: (GotheTools atod: aString) truncated! ! !BaliVolatilityBS methodsFor: 'element'! uiClass ^BaliDaysUI! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! BaliVolatilityBS class instanceVariableNames: ''! !BaliVolatilityBS class methodsFor: 'aspects'! scriptClass ^'VolatilityBS'! scriptSuperClass ^'Effect'! ! */
org.edgescript.TypeScriptInfo.defineTypeorg.unizone.finance.equity.VolatilityBS
org.edgescript.TypeScriptInfo.prerequisiteScriptsList{}