XLL+ Class Library

SimpOpt Sample

Overview

This simple add-in contains a calculator for calculating the value and derivatives of a vanilla option.

It is typical of financial calculator add-ins, and offers a useful model for an XLL+ add-in which makes use of existing pure C libraries.

Features

The sample displays the following features:

Implementation

The following steps were significant in creating and completing the SimpOpt application.

  1. Pre-cooked header and source files were added to the project, containing code for the business functions.
  2. The Calendar functions (CalDiffYears, CalDiffDays, CalDaysInYear and CalDayCountText) were each implemented as a thin shell around existing business functions, with the majority of the code being generated by the XLL+ Function Wizard. This is typical of most real-world add-in functions.
  3. Each of Black-Scholes functions has the same arguments. Therefore only one was entered into the XLL+ Function Wizard. All the rest were created as clones of the first function, using the Copy signature from... field of the New Function dialog.
  4. Each of the single value Black-Scholes functions (BsValue, BsDelta etc) calls the array function (BsCalc), via CXlOper::CallAddin. The value of interest is then extracted from the array and returned to Excel.
  5. The BsCalc function, which returns an array, allocates the array with CXlOper::AllocArray and populates it using CXlOper::Cell.
  6. The Div argument to the Black-Scholes functions is specified as a COper type, meaning that it can contain any or no data. Code was written (in BsCalc) to examine the contents of the Div argument, and handle it differently depending on its shape.
  7. The Excel date functions (XlLSerialToDate and XlDateToLSerial) were used for all date conversions. This makes the code immune to problem of the user setting an unusual zero date in Excel's options.

Functions used

COper::IsDouble
COper::ToDouble
COper::IsArray
COper::GetWidth
COper::ReadVector
CXlOper::AllocArray
CXlOper::IsArray
CXlOper::Cell
CXlOper::CallAddin
CXlOper::RetString
CXlOper::Ret
::XllGetTypedApp
CXlOperCache::Clear
::XlLSerialToDate
::XlDateToLSerial

Project files

If you are using MS Developer Studio 6, then you should open the project file SimpOpt.dsp.

If you are using MS Visual Studio .NET 2002, then you should open the solution file SimpOpt.sln or the project file SimpOpt.vcproj.

If you are using MS Visual Studio .NET 2003, then you should open the solution file SimpOpt71.sln or the project file SimpOpt71.vcproj.

If you are using MS Visual Studio 2005, then you should open the solution file SimpOpt8.sln or the project file SimpOpt8.vcproj.

See Also

List of Sample Projects | Samples and Walkthroughs