Class for setting up Cash objects.
This class contains all attributes and methods related to the following Cash types:
- Cash: Specify riskless cash instruments
In the following, all methods and attributes are explained and a code example is given.
Methods for Cash object obj:
- Cash(id) or Cash(): Constructor of a Cash object. id is optional and specifies id and name of new object.
- obj.set(attribute,value): Setter method. Provide pairs of attributes and values. Values are checked for format and constraints.
- obj.get(attribute): Getter method. Query the value of specified attribute.
- obj.calc_value(scenario,scen_number): Extends base value to vector of row size scen_number
and stores vector for given scenario. Cash instruments are per definition risk free.
- obj.getValue(scenario): Return Cash value for given scenario.
Method inherited from Superclass Instrument
- Cash.help(format,returnflag): show this message. Format can be [plain text, html or texinfo].
If empty, defaults to plain text. Returnflag is boolean: True returns
documentation string, false (default) returns empty string. [static method]
Attributes of Cash objects:
- id: Instrument id. Has to be unique identifier. Default: empty string.
- name: Instrument name. Default: empty string.
- description: Instrument description. Default: empty string.
- value_base: Base value of instrument of type real numeric. Default: 0.0.
- currency: Currency of instrument of type string. Default: ’EUR’
During instrument valuation and aggregation, FX conversion takes place if corresponding FX rate is available.
- asset_class: Asset class of instrument. Default: ’unknown’
- type: Type of instrument, specific for class. Set to ’cash’.
- value_stress: Line vector with instrument stress scenario values.
- value_mc: Line vector with instrument scenario values.
MC values for several timestep_mc are stored in columns.
- timestep_mc: String Cell array with MC timesteps. If new timesteps are set, values are automatically appended.
For illustration see the following example:
A THB Cash instrument is being generated and during value calculation the stress and MC scenario values
with 20 resp. 1000 scenarios are derived from the base value:
c = Cash();
c = c.set('id','THB_CASH','name','Cash Position THB');
c = c.set('asset_class','cash','currency','THB');
c = c.set('value_base',346234.1256);
c = c.calc_value('stress',20);
c = c.calc_value('250d',1000);
value_stress = c.getValue('stress');