November 6th, 2009, 1:17 pm
QuoteOriginally posted by: mjI'd be interested to know how much demand there is for this feature. If we really want to take it seriously we would have to add exposing classes to the interface generator...In my everyday work having an object cache similar in spirit to the example I posted ealier is indispensible. All too often you want to deliver Excel functions that require parameters encapsulating market data. By their very nature these parameters can be very large, spanning huge cell ranges on spreadsheets. This also leads to large clumsy spreadsheets, a significant overhead in the function call, tighter dependency between sheets holding market data and sheets responsible for pricing. Almost always the huge cell ranges of raw market data (vol surfaces, yield curves, repo curves, swaption vol cubes etc) have to be converted into internal market data objects ( i.e they are used to instantiate instantances of classes representing market data objects). Moreover these objects are reasonably static. Requiring a pricing function to have to continually convert cell-ranges into appropriate market data objects on every call can be cumbersome and to me appears both unnecessary and unnatural. It is not particulary difficult or complicated to overcome these drawbacks of a pure functional interface. Consider the following setup.You have a (key,value) container class that is easily constructable from a cell-range. ArgumentList in XLW is more than adequate for this.All your market data classes are constructable from your (key,value) container.All your market data classes are convertible to your (key,value) container, such the the resulting (key,value) container can be used to re-construct a market data object of the same typeFor each market data object xxxx_object you have an internal cache Cache_xxxx, where you can add or remove objects of type xxxx_object with a given name.For each market data object xxxx_object you have a method Create_xxxx_object(string name, ArgumentList args) which instantiates xxxx_object with args and inserts it into Cache_xxxx.For each market data object xxxx_object you have a method Clone_xxxx_object(string source_name, dest_name) which instantiates a xxxx_object by cloning the object with name source_name and inserts it into Cache_xxxx with name dest_name .For each market data object xxxx_object you have a method Retrieve_xxxx_object(string name) which returns a cell-range encapsulating the ArgumentList resulting from the conversion of the xxxx_object with name name from Cache_xxxx.A typical function which requires as input a parameter of type xxxx_object would then have the following spec A signature func (CellMatrix & xxxx_input) If input is a single cell containing a string s, then retrieve from Cache_xxxx the object with name sIf input is NOT a single cell containing a string then consider it the ArgumentList for instanciating a new xxxx_object With this setup it would then become possible to have dedicated workbooks holding (possibly retrieving from a database) all the market data with numerous calls to Create_xxxx_object for various xxxx, whereby forcing a compute of the whole workbook (F9) would as a consequence trigger the population of the Caches. It would then be possible to close this workbook as it would no longer be required since all the market data is alread in memory (cached). To execute a pricing the user would only need to open a pricing wookbook on which the pricing function would have as input the names of the market data objects. In the context for these features for XLW, if it is decided they have a significant added value, I think the best way forward would be too ship XLW with an abstract API for the caching along with a default simple but sufficient XLW implementation. Having an abstract API would allow the user to switch in an alternative caching implementation in a similar way to how it is possible to switch in a different implementation for MyArrayAn very simple example can be downloaded here.