org.unizone.finance.interest

Type TheoreticalBond

org.unizone.0.6140
Instance of Type
Inheriting from SourceAdapterSingleTimeseries

Type dataValue
org.uninode.Type.displayPattern{att:org.unizone.source.Source.displayName}
org.unizone.source.Source.valueAttribute
org.uninode.Resource.resourceType
org.uninode.Resource.label
org.uninode.Resource.resourceOfList{}
org.uninode.Listable.resourcesReference[org.uninode.Listable.resources] of org.unizone.finance.interest.TheoreticalBond

Attribute summaryDefined inUninode® IdPropertiesDefault
Reference[org.uninode.Listable.resources]resourcesListableorg.uninode.0.2001type
StringtoString
This is the display string.
Nodeorg.uninode.0.102
Typetype
The type of an object determines the behaviour and attributes of the object.
Nodeorg.uninode.0.101
StringuriNodeorg.uninode.0.103
StringlabelResourceorg.uninode.0.2041type
List[Type]resourceOfResourceorg.uninode.0.2042type
SignatureresourceType
This defines the type of resource. It can be 'view', 'adapter' or 'action'
Resourceorg.uninode.0.2043type
StringdisplayName
The display name is the name that is shown in lists, displays and graphs.
Sourceorg.unizone.0.4001essential
AttributevalueAttribute
The value attribute is used for determining the default value that should be used for displaying this source in a graph.
Sourceorg.unizone.0.4011type
inheritValue
SignaturevalueType
The value type determines which axes should be used in graphs.
Sourceorg.unizone.0.4002inheritValue
SourcesourceSourceAdapterSingleorg.unizone.0.4051

Method summaryDefined inOverridesProperties
voidactivateListable
voidcheckRangeSourceAdapterSingleSource
voiddesignEditor(WidgetWorkspace ws)Listable
voidgenerateScript(ScriptGenerationInfo info)SourceAdapterSingleScriptGenerator
Realget(DateTime timestamp)SourceAdapterSingleTimeseries
BooleanisResourceOf(Listable listable, Signature aspect)Mixabletype
ListablemixOn(Mixable mix)Mixable
ListablemixWith(Mixable mix)Mixable
voidput(DateTime timestamp, Real value)SourceAdapterSingleTimeseries
StringresourceStringListableintrospection
voidsetSource(Source source)SourceAdapterSingle
SourcesourceSourceAdapterSingle
voidXXXcom.nodelab.java.sourceadaptersingle.CheckRangeSourceAdapterSingle
SignatureXXXcom.nodelab.java.sourceadaptersingle.ValueTypeSourceAdapterSingle
voidcom.nodelab.java.source.ActivateSourceListable
Listablecom.nodelab.java.source.MixWithMiSourceMixable

Script summary
org.unizone.0.8537
/*

BaliSecBond subclass: #BaliYieldSecurity

	instanceVariableNames: 'interest maturity coupon adaptorType '

	classVariableNames: ''

	poolDictionaries: ''
	category: 'Bali'!


!BaliYieldSecurity methodsFor: 'source'!

asSourceAdaptor
	self nextSource: self user currentSource.
	self user previousSources size >= 2 ifTrue: [
		self interest value: (self user previousSources at: 2)].
	(self interest value isNil not 
		and: [self interest value isKindOf: BaliSecBond]) 
		ifFalse: [
			self adaptorType value: #maturityCoupon.
			self interest value: nil.
			self report: 'No bond on source stack'].
	^self!

baseSources
	"return a list of the system sources that this source depends on"
	| src |
	(src := self nextSource) isNil
		ifTrue: [^List new]
		ifFalse: [^src baseSources].!

basicDimensionsRequired: aBaliDisplay
	^#(#dimHistory)!

basicValueAspect: anAspect environment: env
	| rate |
	anAspect = #cleanPrice ifTrue: [
		rate := self valueAspect: #value environment: env.
		^BaliSecBond new
			cleanPriceAt: env timestamp
			maturity: self maturity value
			rate: rate
			coupon: self coupon value].
	anAspect = #dirtyPrice ifTrue: [
		rate := self valueAspect: #value environment: env.
		^BaliSecBond new
			dirtyPriceAt: env timestamp
			maturity: self maturity value
			rate: rate
			coupon: self coupon value].
	^super basicValueAspect: anAspect environment: env!

basicValueTypes
	^#(#rate)!

defaultName
	self adaptorType value = #theoreticalInterest
		ifTrue: [self interest value isNil
			ifTrue: [^'theoretical bond, no interest']
			ifFalse: [^'theor. bond (' , self interest value name , ', ' , 
				self nextSource name , ')']]
		ifFalse: [^'theor. bond (' , self maturity value printString , 
			', cup. ' , self coupon value printString , ', ' , 
			self nextSource name , ')']!

estimatedAspect: anAspect environment: env
	"return value of the first possible non-nil value"
	^self valueAspect: anAspect environment: env!

listAspects: aDictionary
	super listAspects: aDictionary.
	aDictionary at: #cleanPrice put: nil.
	aDictionary at: #dirtyPrice put: nil.
	aDictionary at: #bid put: nil.
	aDictionary at: #maturity put: nil.
	aDictionary at: #coupon put: nil.!

nextSourcesAspect: anAspect
	| res |
	res := super nextSourcesAspect: anAspect.
	self interest value isNil ifFalse: [res add: self interest value].
	^res! !

!BaliYieldSecurity methodsFor: 'aspects'!

adaptorType
	"#theoreticalInterest (non-existent interest) or #virtualInterest (based on a real interest)"
	^adaptorType isNil
		ifTrue:
			[adaptorType := #theoreticalInterest asValue]
		ifFalse:
			[adaptorType]!

coupon
	^coupon isNil
		ifTrue:
			[coupon := 0 asValue]
		ifFalse:
			[coupon]!

interest
	^interest isNil
		ifTrue:
			[interest := nil asValue]
		ifFalse:
			[interest]!

maturity
	^maturity isNil
		ifTrue:
			[maturity := ((BaliTime now addYears: 10) type: #day) asValue]
		ifFalse:
			[maturity]!

uiClass
	^BaliYieldSecurityUI! !

!BaliYieldSecurity methodsFor: 'timeSource'!

basicCreateDataAt: aBaliTime resolution: aResolution environment: env
	| data val newData |
	newData := BaliTimeData new source: self.
	newData aspects at: #timestamp put: aBaliTime.
	self adaptorType value = #theoreticalInterest
		ifFalse: [
			val := self 
				zeroCouponRate: self nextSource 
				at: aBaliTime 
				maturity: self maturity value 
				coupon: self coupon value.
			newData aspects at: #bid put: val.
			newData aspects at: #maturity put: self maturity value.
			newData aspects at: #coupon put: self coupon value]
		ifTrue: [
			self interest value isNil ifTrue: [^newData].
			data := self interest value dataTime: aBaliTime resolution: aResolution environment: env.
			newData aspects: Dictionary new.
			data isNil
				ifFalse: [
					val := data zeroCouponRate: self nextSource.
					data aspects keys do: [:key | newData aspects at: key put: (data aspects at: key)]]
				ifTrue: [val := nil].
			newData aspects at: #timestamp put: aBaliTime.
			newData aspects at: #bid put: val].
	^newData!

reportPreparation
	^true! !

!BaliYieldSecurity methodsFor: 'copying'!

baliCopy: aDictionary
	| src |
	src := aDictionary at: self ifAbsent: nil.
	src isNil ifFalse: [^src].
	src := super baliCopy: aDictionary.
	src nextSource: (self nextSource baliCopy: aDictionary).
	self interest value isNil
		ifFalse: [src interest value: (self interest value baliCopy: aDictionary)].
	src adaptorType value: self adaptorType value.
	src maturity value: self maturity value copy.
	src coupon value: self coupon value.
	^src! !

!BaliYieldSecurity methodsFor: ' database'!

addDefinition
	| aspects |
	(aspects := super addDefinition) isNil ifTrue: [^nil].
	self interest value isNil ifFalse: [
		aspects := aspects + 1.
		self 
			addAspect: #dbInterest 
			value: self interest value symbol asString 
			position: aspects.
		self interest value addDefinition].
	maturity value isNil ifFalse: [
		aspects := aspects + 1.
		self 
			addAspect: #dbMaturity
			value: self maturity value asSybaseString
			position: aspects].
	coupon value isNil ifFalse: [
		aspects := aspects + 1.
		self 
			addAspect: #dbCoupon
			value: self coupon value printString
			position: aspects].
	self 
		addAspect: #dbAdaptorType
		value: self adaptorType value asString
		position: aspects + 1.
	^aspects + 1!

dbAdaptorType: aString
	self adaptorType value: aString asSymbol!

dbCoupon: aString
	self coupon value: (GotheTools atod: aString)!

dbInterest: aString
	self interest value: (self server element: aString asSymbol)!

dbLoadInfo2!

dbMaturity: aString
	self maturity value: (BaliTime fromString: aString)! !

!BaliYieldSecurity methodsFor: 'menus'!

setEffectMenu: aMenu
	super setEffectMenu: aMenu.
	aMenu addItem: ((MenuItem labeled: 'Clean Price') value: BaliPriceClean).
	aMenu addItem: ((MenuItem labeled: ' dirty Price') value: BaliPriceDirty).! !

!BaliYieldSecurity methodsFor: 'timeList'!

prepareDataFrom: aBaliTime resolution: aResolution
	"load all historical data between (including) aBaliTime and now"
	| env set first timeList load |
	load := self loadResolution: aResolution.
	load loadedFrom isNil
		ifTrue: [first := BaliTime now addDays: 1]
		ifFalse: [first := load loadedFrom].
	aBaliTime < first ifFalse: [^nil].
	env := JazzEnvironment new.
	env localAt: 'cond_history_from' put: (aBaliTime subtractDays: 30).
	env localAt: 'cond_history_to' put: first.
	env localAt: 'cond_history_resolution' put: #day.
	set := Set new.
	self nextSource collectStepsDim: #dimHistory environment: env into: set.
	timeList := set asList.
	timeList sort.
	timeList do: [:time |
		time < first ifTrue: [
			self dataList add: (self createDataAt: time resolution: aResolution environment: env)]].
	load loadedFrom: timeList first.
	self dataList sort.! !

!BaliYieldSecurity methodsFor: 'steps'!

collectStepsFor: aBaliDisplay environment: aJazzEnvironment
	self nextSources do: [:src | 
		src collectStepsFor: aBaliDisplay environment: aJazzEnvironment].! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

BaliYieldSecurity class
	instanceVariableNames: ''!


!BaliYieldSecurity class methodsFor: 'aspects'!

scriptClass
	^'YieldInterest'!

scriptSuperClass
	^'Effect'! !




*/