Derivatives Expert



Frequently Asked Questions (FAQ)

Derivatives ExpertTM for Mathematica®

Introduction

Some of this information may first be relevant to you after you have experimented with Derivatives Expert, but please skim the text so that you have an idea of the contents.

Tips and Techniques

  • Running the Examples
  • Financial Day Counting Conventions
  • Compounding -> Continuous
  • SetOptions
  • Options[...]
  • Getting information on symbols
  • Only Linux: System Time Issue
  • Notation
  • J/Link
  • Displaying Tables

FAQ

Tips & Techniques

Running the Examples

Note when, running the examples in the different notebooks, it may be important to run some of the examples in the correct order, i.e. from top to bottom, because there may be intermediate or temporary results with the same names or because some examples depend on previous results.

Financial Day Counting Conventions

Derivatives Expert can accomodate probably all financial day counting conventions. Please refer to e.g. YearsInPeriod in the CalendarTools.nb notebook about how to set the day counting optionals appropriately.

Compounding -> Continuous

Unless you need the unlimited precision, then set (CompiledDF->True) because the execution is much faster. This is the case for all functions that discount or compound cash flows.

SetOptions

Never use the Mathematica SetOptions with functions and/or objects from Derivatives Expert because this may spoil the consistency of the Derivatives Expert system. In any case, it is often not possible to change the default settings because they have been locked. This is a current design choice in Derivatives Expert. The internal design may change in later versions.

Therefore, always set the specific optionals for the specific task.

Note that the general use of SetOptions with optionals from the standard Mathematica system can be reasonable in given situations.

Options[...]

Options[ object] has been added to relevant objects in addition to the Options[ function] already present. Because there often are several versions of "object" to a function available, the actual optionals that have effect are documented in the respective notebooks. Please refer to these.

Getting information on symbols

[Graphics:Images/intro_gr_1.gif]


For a given symbol, use the question mark in front of the name of the symbol. If you do not remember the full name, you can use a star "*" as a wild card.

[Graphics:Images/intro_gr_2.gif]
[Graphics:Images/intro_gr_3.gif]
[Graphics:Images/intro_gr_4.gif] [Graphics:Images/intro_gr_5.gif] [Graphics:Images/intro_gr_6.gif]
[Graphics:Images/intro_gr_7.gif]
[Graphics:Images/intro_gr_8.gif]

Only Linux: System Time Issue

You may have to change your system time.
Please refer to http: //support.wolfram.com/mathematica/systems/linux/intel/incorrecttime.html

Notation

You may want to stick to ISO-89*-1 characters and American/British notation i.e. "." as decimal divider. With e.g. the Link for Excel and with certain databases, there may be issues of notation. Often it is most "safe" to work with the American/British notation standard.

J/Link

The part handling the connection to Java in "~/.Mathematica/4.1/Kernel/init.m" may be moved to the main "/.../mathematica/Configuration/Kernel/init.m" file.

See also Section A.8.5  in the standard documentation.

This removes all remaining Java objects.

[Graphics:Images/intro_gr_9.gif]
[Graphics:Images/intro_gr_10.gif]

Displaying Tables

Many of the results in the Derivatives Expert documentation are in the form of list of list i.e. tables. Below is a way to display these tables more nicely.

This is a table of random numbers.

[Graphics:Images/intro_gr_11.gif]
[Graphics:Images/intro_gr_12.gif]

This formats table tbl using TableForm.

[Graphics:Images/intro_gr_13.gif]
1 0.30741800505618677` 0.9159157594641144` 0.174217407306002`
2 0.1133077585206359` 0.34527652516953267` 0.2203851727367737`
3 0.7703645411318185` 0.20680183608263059` 0.02991277158296989`
4 0.010556365537723999` 0.09518548496247904` 0.39147160792812336`
5 0.31298189035822493` 0.4525194750200095` 0.9597439103363754`

This is one way to format the numbers of table tbl using PaddedForm.

[Graphics:Images/intro_gr_14.gif]
[Graphics:Images/intro_gr_15.gif]
[Graphics:Images/intro_gr_16.gif]
[Graphics:Images/intro_gr_17.gif] [Graphics:Images/intro_gr_18.gif] [Graphics:Images/intro_gr_19.gif] [Graphics:Images/intro_gr_20.gif]
[Graphics:Images/intro_gr_21.gif] [Graphics:Images/intro_gr_22.gif] [Graphics:Images/intro_gr_23.gif] [Graphics:Images/intro_gr_24.gif]
[Graphics:Images/intro_gr_25.gif] [Graphics:Images/intro_gr_26.gif] [Graphics:Images/intro_gr_27.gif] [Graphics:Images/intro_gr_28.gif]
[Graphics:Images/intro_gr_29.gif] [Graphics:Images/intro_gr_30.gif] [Graphics:Images/intro_gr_31.gif] [Graphics:Images/intro_gr_32.gif]
[Graphics:Images/intro_gr_33.gif] [Graphics:Images/intro_gr_34.gif] [Graphics:Images/intro_gr_35.gif] [Graphics:Images/intro_gr_36.gif]

This defines a function dsp1 to format the table. Also refer to the Mathematica functions GridBox, StyleBox, and DisplayForm.

[Graphics:Images/intro_gr_37.gif]


This applies the function dsp1 to the table.

[Graphics:Images/intro_gr_38.gif]
1 0.61730715170979666 0.86404483240972974 0.44780872243173941
2 0.41745571083583333 0.65739415108957999 0.44604437490121995
3 0.055612349722459202 0.074141888273683745 0.90489234335166124
4 0.47588085429722665 0.70617061217745414 0.17064616347093409
5 0.034874555467485031 0.93229000368259418 0.74632734603493622

This applies the functions fun2 and dsp1 to the table.

[Graphics:Images/intro_gr_39.gif]
[Graphics:Images/intro_gr_40.gif] [Graphics:Images/intro_gr_41.gif] [Graphics:Images/intro_gr_42.gif] [Graphics:Images/intro_gr_43.gif]
[Graphics:Images/intro_gr_44.gif] [Graphics:Images/intro_gr_45.gif] [Graphics:Images/intro_gr_46.gif] [Graphics:Images/intro_gr_47.gif]
[Graphics:Images/intro_gr_48.gif] [Graphics:Images/intro_gr_49.gif] [Graphics:Images/intro_gr_50.gif] [Graphics:Images/intro_gr_51.gif]
[Graphics:Images/intro_gr_52.gif] [Graphics:Images/intro_gr_53.gif] [Graphics:Images/intro_gr_54.gif] [Graphics:Images/intro_gr_55.gif]
[Graphics:Images/intro_gr_56.gif] [Graphics:Images/intro_gr_57.gif] [Graphics:Images/intro_gr_58.gif] [Graphics:Images/intro_gr_59.gif]

This prepends a table header to tbl.

[Graphics:Images/intro_gr_60.gif]
[Graphics:Images/intro_gr_61.gif]

This defines a function dsp2 to format a table with header.

[Graphics:Images/intro_gr_62.gif]

This applies the function dsp2 to the table with header.

[Graphics:Images/intro_gr_63.gif]
Index First Second Third
1 0.61730715170979666 0.86404483240972974 0.44780872243173941
2 0.41745571083583333 0.65739415108957999 0.44604437490121995
3 0.055612349722459202 0.074141888273683745 0.90489234335166124
4 0.47588085429722665 0.70617061217745414 0.17064616347093409
5 0.034874555467485031 0.93229000368259418 0.74632734603493622

This applies the functions fun2 and dsp2 to the table.

[Graphics:Images/intro_gr_64.gif]
[Graphics:Images/intro_gr_65.gif] [Graphics:Images/intro_gr_66.gif] [Graphics:Images/intro_gr_67.gif] [Graphics:Images/intro_gr_68.gif]
[Graphics:Images/intro_gr_69.gif] [Graphics:Images/intro_gr_70.gif] [Graphics:Images/intro_gr_71.gif] [Graphics:Images/intro_gr_72.gif]
[Graphics:Images/intro_gr_73.gif] [Graphics:Images/intro_gr_74.gif] [Graphics:Images/intro_gr_75.gif] [Graphics:Images/intro_gr_76.gif]
[Graphics:Images/intro_gr_77.gif] [Graphics:Images/intro_gr_78.gif] [Graphics:Images/intro_gr_79.gif] [Graphics:Images/intro_gr_80.gif]
[Graphics:Images/intro_gr_81.gif] [Graphics:Images/intro_gr_82.gif] [Graphics:Images/intro_gr_83.gif] [Graphics:Images/intro_gr_84.gif]
[Graphics:Images/intro_gr_85.gif] [Graphics:Images/intro_gr_86.gif] [Graphics:Images/intro_gr_87.gif] [Graphics:Images/intro_gr_88.gif]

FAQ

Bookmark Are there any known bugs?

All known bugs, at the time of the release, in Derivatives Expert III are listed below.

ExoticOptions1.nb

Do not set passedobservations different from zero in
    TheoreticalPrice[ EuropeanGeometricAverageCallOption,Zhang[..]]
Doing so will result in a wrong option price.

To price a geometric average Asian option correctly, where the geometric averaging is deferred, use the Montecarlo version with a sufficiently high number of simulations.

ExoticOptions1.nb

Do not use the Zhang versions to price EuropeanGeometricAverageStrikeCallOption and EuropeanGeometricAverageStrikePutOption. Doing so will result in a wrong option price.

To price a geometric average strike Asian option correctly, use the Montecarlo versions with a sufficiently high number of simulations.

Bookmark How do I Install the Packages?

Refer to http://www.ifs.dk/Support/install.html

You may also want to refer to the standard Mathematica documentation on how to install packages in general. This may be found via the Mathematica Help browser: Write Packages in the text field, and click the Master Index button, and then select Packages and click Go To.

Bookmark Are the Package Files Encoded?

The software is delivered and distributed in Mathematica encoded format, i.e. the code cannot be read or modified directly as plain text, but it can be loaded into Mathematica. Refer to the Mathematica function Encode.

Bookmark What is init.m?

Please refer to the standard Mathematica documentation.
(Master.m was used instead of init.m in pre-3.0 versions of Mathematica.)

Bookmark Term Structure Functions

Are jumps allowed?

Often continuous term structure functions are used in the examples. The term structure functions do not have to be smooth continuous functions. They may e.g. have jumps. The only requirement is that there is one and only one function value for every time to maturity.

Why are Term Structure Functions Used Instead of Discrete Points?

Derivatives Expert uses a more sophisticated approach than normally seen and hence a more elegant way of treating term structures in the analysis. If you have a number of discrete term structure points then you need to construct a function. On how to do this please refer to the notebook TermStructureTools.nb and the function InterpolateInterestRates.

Bookmark Are Annual Rates or Periodic Rates Used?

Interest rates are generally passed to the functions as annual rates and the functions normally return annual rates. Refer to the notebook TermStructureTools.nb.

Bookmark Coupon Rates and Interest Rates

Coupon rates are normally assumed to be annual nominal rates, in percent. 
E.g. 10 means 10 percent and 0.10 means 0.10 percent

Interest rates are normally assumed to be annual effective rates, in percent.

Bookmark What are Objects?

Objects normally refer to financial contracts. The financial contracts are not always fully specified by the objects, e.g. whether an options contract is a European call option or an American put option is not specified by the object, but is passed to the calling function e.g. the pricing function TheoreticalPrice.

Bookmark Time

Several functions are written to accomodate more than one way of time specification. There are generally two different ways of specifying time, plus the case where time specification is not needed or does not make sense. 

(1) Calendar-Time
In this case functions work using actual calendar dates for specification of time. E.g. {1999,9,19} stands for September 19, 1999.

(2) Time as Numbers
Time is specified as numbers, not dates. E.g. half a year is specified as 1/2 or 0.5.

(3) No Time
In this case functions do not need any specification of time. 
See e.g. the function NominalRateToEffectiveRate in the notebook TermStructureTools.nb.

Bookmark What Date Formats are Available?

Dates are specified as {full year, month, day}. Thus 14. June 1998 is written as {1998, 6, 14}.

Bookmark Can Calendar Time Versions be Derived From Non-Calendar Versions?

Often it is possible to pass e.g. the function YearsInPeriod instead of an exact number (theta). Thus in practice many non-calendar functions can also be used in calendar time.

Bookmark Holiday Symbols

The holiday symbols that can be calculated by Derivatives Expert are found by evaluating SymbolsHolidays after opening the package CalendarTools.m. In addition you can make your own holidays known to the system through the optionals HolidaysSpecific and HolidaysGeneral.

Graphics Graphics Graphics

Bookmark Workday Optionals

You can often make the functions automatically change all non-workdays to workdays, by setting the optionals correctly. Remember to set: ToWorkdaysQ -> Yes. Refer to the optionals of the specific object and function. See also the notebook CalendarTools.nb.

Bookmark Are Cash Flows Viewed From a Buyer´s (Long) or a Seller´s (Short) View?

Cash flows are generally viewed from a buyer´s point of view unless otherwise stated.

Bookmark Principal Amounts

In the documentation these amounts are just referred to as the principal as a matter of simplicity.

Many examples in the documentation have a principal of 100, but that can be changed to any number (which of course normally changes the result of the specific evaluation). Market rates of financial instruments are often quoted in amounts of nominally 100, e.g. most bond market prices.

Bookmark What Currency Symbols are Used?

The currency symbols used in Derivatives Expert are the ISO codes. You may use any symbols you like as the currency symbols (except reserved symbols for other purposes in Derivatives Expert, Mathematica and other packages), as long as you use the symbols consistently, but these are the recommended ones. Many symbols can be found here.

Bookmark About Optionals

The Terminology

When talking about "optionals" in Derivatives Expert we actually mean "options" in the sense defined by standard Mathematica. The reason for this is to distinguish optionals from financial options contracts.

A Shorthand Notation

A list of optionals are sometimes written as e.g.:
{LengthMonth -> Actual, ..., Options[FindRoot]}

The thing to note is the Options[FindRoot] part. If you execute Options[FindRoot] in Mathematica it will return the list of optionals and their default settings for the function FindRoot. So Options[FindRoot] is just a shorthand notation for the full list of optionals and their default settings.

Using an Alien Optional

If an alien optional (but otherwise correctly specified optional) is passed to a function, then the optional should be ignored by the function, or the function should return unevaluated or return $Failed together with a message.

Note that many of the optionals that may apply to a function, may not apply to another version of the same function because there are many methods of the same function that do not all take the same optionals.

Changing an Optional Value

If an optional, that is usable for a function, has a non-valid value then it will normally terminate the evaluation of the function. Thus either the function should return unevaluated or return $Failed together with a message.

Changing the Default Settings of Optionals

You can change the default settings of optionals that do not have the attribute Locked. This is done via the function SetOptions.

The functions UnProtect and SetOptions cannot be used on symbols that have the attributes: {Protected, ReadProtected, Locked}. These symbols cannot be changed or read. This is to protect you from changing important characteristics of these symbols.

Bookmark How is Output Handled?

Typical Formats

In the documentation the format of the result is often changed from an exact format to a numerical result using the function ToN or the Mathematica function N.
In addition the number of returned lines are sometimes shortened by using the Mathematica function Short.

Exception Handling

A function that is given false input should either return unevaluated, return a value together with a warning or return $Failed and a message.

This will not always be the case in this version of Derivatives Expert. Sometimes you will get a long list of output because you have e.g. some missing arguments or entered some wrong arguments.

Bookmark Are Some Functions Overloaded?

Many functions are "overloaded" which means that they can take different sets of arguments and/or optionals, and thereby have different properties. This is done: 

  • to reduce the number of different function names (symbols); 
  • to make the system more simple to use;
  • to make the system more consistent.

Bookmark Rational Numbers and Real Numbers

Some functions return a rational number (e.g. 2/3). In some cases it is convenient to transform the result to a real number (e.g. 0.666667). This can often be done by using ToN or the Mathematica function N. If you want the highest degree of precision then always use the rational numbers where possible.

Note that the transformation to a real number can result in loss of precision. This should especially be noted when using results in further calculations. Please refer to the sections in the main Mathematica book ("A System for Doing Mathematics by Computer" by Steven Wolfram) about N, numbers and precision.

Bookmark Can I Execute the Functions Faster than Reported in The Documentation ?

Running the functions using faster machines will speed up the timing compared to that reported in the documentation.

Bookmark System Related Topics

Strange Function Behavior

There are different ways to terminate a calculation that is running. Please refer to the standard Mathematica documentation about e.g. Abort, Interrupt and Exit.

Evaluation Crash !

See also: $RecursionLimit, $IterationLimit, MemoryInUse[].

How Much Memory is Required by Derivatives Expert?

See e.g. the Mathematica function MemoryInUse[].

 
Copyright © 1994-2009 Innova Financial Solutions ApS. All rights reserved.   

Updated 2 August 2009