Example function usage.
http://www.QuantTools.com
Here we provide examples in various languages of how to use the function described.
Data Types
Two types of output values are possible from any CapeTools QuantTools function call.
Either basic datatypes (string, integer, double or range values), or a string 'string-key' value.
The string 'string-key' value is returned when a CapeTools QuantTools function creates an object in memory that needs to be refered to at a later time.
Functions that create objects, return 'string-key' values back to the user. The 'string-key' string acts as a reference to the created object.
Function snippets
Each example snippet shown actually presents 2 (or more) function calls.
The first function is the so-called driver function, which is responsible for preparing 'string-key' valued parameters (parameters that references objects in memory) necessary to call the main function in question.
This driver function may call other sub driver functions in order to prepare the 'string-key' valued parameters. These parameters can be the result of multiple function calls. These functions are not shown here (apart from the C# examples). To view the code for these functions, please refer to the sample code provided with the library.
The second function call takes the 'string-key' valued parameters that the driver function has prepared and actually calls the function.
For the C# examples, the further functions may be displayed showing how the sub driver functions were setup. From the C# sub driver examples, it should be easy to reconstruct the examples for the other languages.
When an object function returns a 'key' value, it is returned as a string variable. This 'string-key' string variable actually is broken into three parts. The name given by the creator of the object, an extension tag and finally a ticker (ie - MyBook.BOOK.5).
The first part of the returned 'string-key' is the name chosen by the user (ie - MyBook ). The second part of 'the string-key' is an internal identifier indicating what function created this object (ie - BOOK ), finally the ticker value which is very using within an Excel setting (ie - BOOK ). The ticker will increment by one (1) each time the function is called. This will signal to Excel to recalculate any dependant functions if the user requests a spreadsheet page or a workbook refresh (via the F9 Function key).
Note : In total, the 'string-key' is the sum of these three parts separated by a period. (ie - MyBook.BOOK.5). Thus it is very important that you do not use periods within the name chosen to represent your objects.
Object functions
CapeTools functions that create objects all have the same first two parameters. A 'Name' parameter and a 'Reload' parameter.The first parameter, 'Name', holds the first part of the 'string-key' that will be generated. This parameter is filled in by the user. The second parameter, 'Reload', indicates whether (once the function has been executed) you wish for the object to be re-created if executed again. Hence the first time you execute any object function, provide a positive value for the 'Reload' parameter (typically 1), then change this value to zero (0) if you wish for the object to retain it's setting during a re-calculation (ie - you do not want to rebuild a large portfolio book if the trades within it has not changed).
Setting the 'Reload' parameter to a positive number will always rebuild the object. (Implemented as an long variable type for future modes).
Setting the 'Reload' parameter to zero (0), will simply return the generated 'string-key' will the same ticker value (Excel will not detect a change and thus dependant cells will not be signalled to update). Thus it is very important that the first time you call the function, the reload flag has a positive number.
Copyright (c) 2003-2007 CapeTools - All Rights Reserved.