This tutorial is written for Octarisk latest master release.
If you already have Octave versions 8.4 up and running and the financial, io, struct and statistics packages installed, continue with section 2c. Compatibility tests have been done for Octave versions 8.4.0. For Octave 9.1, still the financial package has to be updated in the official sources.
sudo apt-get install octave liboctave-dev
. yum install octave-forge
into your terminal. sudo yum install epel-release
first. The development resources are required for compiling oct files, in some cases you have to also install a Gnu++ and Fortran compilersSince vectorized code relies heavily on matrix operations, it is absolutely essential to have a fast linear algebra package.
sudo apt-get install libopenblas-base liblapack-dev
. yum install openblas lapack-devel
into your terminal.Alternatively, you get your own version of ATLAS / Intel MKL libraries running.
If you are not already familiar with Octave I would recommend to start with some online tutorial. For running Octarisk and adjusting input parameters it is necessary to have a basic understanding of the Matlab progamming language.
Now you can start Octave. If the GUI is mandatory, so you should see something like a console, the editor and a history. In order to get Octave to know where all your scripts are, you have to add your working folder. This can be easily done by typing
addpath ("~/path/to/working/directory")
addpath ("C:/Documents/Path/to/Octave")
After adding the path to your working directory, type in savepath()
to get Octave to remember the added paths.
Go to Octave Sourceforge and download the Financial, io and Statistics Package
and place it somewhere.
After downloading, type into Octave console pkg install "path/to/download/folder/io-X.X.X.tar.gz"
. Adjust the path to your Linux or Windows environment and repeat this step for the other packages.
pkg install -forge financial
pkg install -forge io
pkg install -forge statistics
pkg install -forge struct
pkg install -forge parallel
pkg load financial;pkg load statistics;
to the last lines of the file "octaverc".
You can find these file in
~/.octaverc
C:\Installdirectory\Octave-X.Y.Z\share\octave\X.Y.Z\m\startup\octaverc
Either you download the latest release with all Octarisk files and extract it into your working directory (which you alreadyhave added to your search path) or you clone the latest Octarisk repository from Github from the master branch.
compile_oct_files('/path/to/octarisk-latest')
This takes a couple of minutes and compiles some binaries for even faster pricing (the most performance relevant algorithm have been highly optimized in C++, e.g. curve interpolation of callable bond pricing).
unittests()
integrationtests ('/path/to/octarisk-latest/testing_folder')
The latest release comes with a complete set of example data - it is ready for running the market risk calculation!
By running octarisk('/path/to/octarisk-latest/test_folder')
, a full valuation of a sample portfolio including various financial instruments (Fixed Rate Bonds, European and American options, swaptions, floating rate bonds, some ETFs and stocks etc.)
is performed for parametric and historical stress scenarios and for 50000 Monte Carlo scenarios on a one year time horizon. Standardized reports and plots in various formats are being generated, which can then be used in e.g custom LaTeX reports. All generated reports and plots can be found under /reports subfolder.
Once you got familiar with the design of the script and the input parameters, it is time to adjust the input files to your needs. Before doing so, it is recommended to read Octarisk's User and Developer manual.
working_folder/input/instruments.csv
)working_folder/mktdata/mktdata.csv
)working_folder/input/positions.csv
)working_folder/input/riskfactors.csv
)working_folder/input/stresstests.csv
)working_folder/mktdata/corr.csv
)working_folder/mktdata/vol_index_RF_VOLA_EQ_DE.dat
)If you want to see all the possibilities you have - read the User and Developer manual, look into the code and adjust it to your needs. For contribution you are kindly refered to the developer site.