linux下编译并配置quantlib

quantlib是一个C++编写的免费,开源的数量金融库。

在sourceforge(http://sourceforge.net/project/showfiles.php?group_id=12740)上下载软件包QuantLib,目前的版本是0.9.6

 

下面开始安装

quantlib需要boost的支持,大多数inux发行版已经预先安装了boost,就不用劳神了

$  tar  zxvf QuantLib-0.9.6.tar.gz

$  cd QuantLIb-0.9.6

$   ./configure

$  make

$  sudo make install

编译要花一点时间,请耐心等待

 

完成后可以在/usr/local/lib下看到libQuantLib.a以及libQuantLib.so,这分别是quantlib的静态库和共享库。

为了链接正确键入  export LD_LIBRARY_PATH=/usr/local/lib

 

下面进行测试,重新进入QuantLib-0.9.6,就是我们解压的目录

$  cd Examples

$  cd CDS

$  g++ -c CDS.cpp

$  g++ -o CDS CDS.o -lQuantLib

$  ./CDS

 


Calibrated hazard rate values:
hazard rate on May 15th, 2007 is 0.0299689
hazard rate on September 20th, 2007 is 0.0299689
hazard rate on December 20th, 2007 is 0.0299613
hazard rate on June 20th, 2008 is 0.0299619
hazard rate on June 22nd, 2009 is 0.0299622

Some survival probability values:
1Y survival probability: 97.040061 %
               expected: 97.040000 %
2Y survival probability: 94.175660 %
               expected: 94.180000 %


Repricing of quoted CDSs employed for calibration:
3M fair spread: 1.500000 %
   NPV:         1.86446e-10
   default leg: -5218.16
   coupon leg:  5218.16

6M fair spread: 1.500000 %
   NPV:         -5.09317e-11
   default leg: -8882.83
   coupon leg:  8882.83

1Y fair spread: 1.500000 %
   NPV:         -2.15732e-09
   default leg: -16142.9
   coupon leg:  16142.9

2Y fair spread: 1.500000 %
   NPV:         -2.91038e-11
   default leg: -30271.7
   coupon leg:  30271.7



Run completed in 0 s

 

运行正常,以后便可以用quantlib快速高效的开发数量金融程序了

你可能感兴趣的:(c,PHP,linux,金融,软件测试)