QuantLib Installation for .NET

前言

QuantLib是一套免費且開放原始碼(open-source)的quantitative finance library(財務的函式厙),是用強大的Boost C++ Library所開發的,託SWIG(Simplified Wrapper and Interface Generator)的福,我可以在熟悉的.NET環境底下使用QuantLib這個強大且方便的library。

QuantLib在財務方面提供了許多實用的class,從基本的Random Number Generator到各式各樣的Pricing Engines都有提供,甚至也有Monte Carlo蒙地卡羅的class(不過都還沒有去仔細研究裡面運作的方式orz),或是像Calendar這種可以根據各個國家有不同的Business Day Convention來計算交易日、結算日的class;此外各種金融商品也幾乎都有對應的class來處理,例如選擇權(Option)、期貨(future)等。雖然說我目前對於 QuantLib還不是很熟悉,不過之前花了點時間在嘗試將QuantLib拿來.NET的環境使用,在此分享一下安裝心得。

QuantLib網址:http://quantlib.sourceforge.net/index.shtml

有任何問題歡迎留言給我!Any question are welcomed.

Requirements

  • Microsoft .NET Framework 2.0
  • Microsoft Visual Studio 2005
  • Boost:QuantLib需要用Boost來進行編譯的動作。
  • BoostJam :BoostJam是用來編譯、安裝Boost的。
  • QuantLib
  • QuantLib Extension – SWIG:銜接.NET跟Boost C++之間的橋樑(wrapper)

Where to Download

Compile Your Boost C++ Library(Using bjam.exe)

  1. Extract Boost to any directory.
    (for example, “C:\Documents and Settings\deduce\Desktop\QuantLib\”)
  2. Extract BoostJam to any directory.(There would be 2 files: bjam.exe & LICENSE file)
  3. Copy bjam.exe to your Boost source code directory.(i.e. \boost_1_33_1\bjam.exe)
  4. Run your Command window and type “bjam -sTOOLS=vc-8_0 install” in boost_1_33_1
    (To change directory, type cd “C:\Documents and Settings\Wilmer\Desktop\QuantLib”)**The default directory of Boost is c:\Boost

Add Boost Files in your Visual Studio

  1. In Visual Studio 2005, TOOLS->Options->Projects and Solutions->VC++ Directory
  2. Show directories for “Include Files”, and add the directory c:\boost\include\boost-[version], such as “C:\Boost\include\boost-1_33_1”
  3. For “Libraries Files”, add the directory “c:\boost\lib”

Compile Your QuantLib

  1. Extract QuantLib.
  2. Open “QuantLib_vc8.sln” in QuantLib directory.
  3. Change “Debug CRTDLL” to “Debug”
  4. Set any example project as a startup project for build up your QuantLib and run example project.

Setting up QuantLib SWIG

  1. Extract QuantLib-SWIG
  2. Add a system Environment VariableQL_PATH” to your QuantLib path, such as
    “D:\My Documents\Documents\MIS Project\QuantLib-0.4.0”
  3. Open QuantLib.sln in QuantLib-SWIG\CSharp
  4. Try to run BermudanSwaption.

Create a new QuantLib project for yourself

  1. Create a new project
  2. Right click on the “Reference” in solution explorer and “Add Reference”
  3. Click on the tab “Browse” and find “NQuantLib.dll” in your QuantLib-SWIG\CSharp\csharp\bin\Debug,
    for example, ”D:\My Documents\Documents\MIS Project\QuantLib-SWIG-0.4.0\CSharp\csharp\bin\Debug\NQuantLib.dll”
  4. Copy NQuantLibc.dll” in your QuantLib-SWIG\CSharp\cpp\bin\Debug to “your Project\bin\debug”.
    For example,
    Copy “D:\My Documents\Documents\MIS Project\QuantLib-SWIG-0.4.0\CSharp\cpp\bin\Debug\NQuantLibc.dll
    to “D:\My Documents\Visual Studio 2005\Projects\ConsoleApplication7\ConsoleApplication7\bin\Debug”
  5. Add a new line of code“Using QuantLib;” in the head of your source code and enjoy QuantLib programming!

Reference

Rails Recipes

我連Agile Web Development with Rails都還沒看完,就迫不及待拿出Rails Recipes開始看看裡面提供了些什麼有趣的玩意兒。Rails Recipes這本書比較適合已經對於Ruby on Rails有點瞭解,甚至是已經開始製作、經營網站的User,裡面提供了一些很實用的技巧,共70個Recipes分成以下幾篇:

  • User Interface Recipes
  • Database Recipes
  • Controller Recipes
  • Testing Recipes
  • Big-Picture Recipes
  • Email Recipes

我覺得這本書跟Agile Web Development with Rails都很有收藏價值,Rails Recipe在每一章的開頭會先敘述一段網站開發者可能遭遇的「Problem」(或是一段簡單的場景敘述),隨後列出需要準備的「Ingredients」,並且提出對應的「Solution」,內容我認為是簡短有力,沒事拿來當閒書翻閱一下或是放在旁邊當工具書參考用都很有幫助。

註:另一本「Advanced Rails Recipes」預計在August 2007出版,真是令人期待!
http://www.pragmaticprogrammer.com/titles/fr_mrr/index.html

Free WIFLY!!

免費的WIFLY上網用學校的E-Mail帳號即可連線!有圖有真相!這是由經濟部工業局與WIFLY共同推動的「行動台灣漫遊無限,校園漫遊上網專案」,用自己學校的無線上網帳號即可連線!

關於該計畫可前往「史上最大無限夢想漫遊網」的官方網址查看詳細資訊:http://www.wifly.com.tw/sp/wiflynet/iii-students/iii-students.html

選擇研究單位,並選擇「帳號認證交換中心」,帳號密碼的地方輸入平常在學校用的無線網路帳號及密碼(以政大為例,就是學生的E-mail帳號、密碼),即可成功上網!目前只能免費使用20分鐘,時間一到會自動斷線(以此跟付費帳號區隔)。

首次連線成功之後會出現以下畫面:

22 Successful Ruby on Rails Web Applications

http://rubycorner.net/articles/22-successful-ruby-on-rails-web-applications/

這篇文章介紹了22個成功的Ruby on Rails個案,稍微做個簡單的中文翻譯替螢幕前的訪客省點時間好了:)

(另外在http://happycodr.com/biglist有更多的網站介紹,共有388個!)

第一部份主要是37signals他們公司所經營的網站,

  1. Basecamp
    http://www.basecamphq.com
    專案管理網站
  2. Campfire
    http://www.campfirenow.com
    即時群組聊天網站
  3. Backpack
    http://www.backpackit.com
    資訊彙整與行事曆網站
  4. Tadalist
    http://www.tadalist.com
    簡單好用的Todo List(要做的事)
  5. Writeboard
    http://www.writeboard.com
    線上共同編輯文件

第二部份則是在RubyonRails.org有介紹的網站,

  1. 43things.com
    http://www.43things.com
    這個網站也算是Web 2.0與Ruby on Rails的經典網站,人們可以上去分享自己想做的事情,藉此來找到跟自己有著相同目標的朋友們。
  2. odeo.com
    http://odeo.com
    音樂分享網站
  3. shopify.com
    http://shopify.com
    提供使用者快速建立屬於自己的電子商務網站
  4. fluxion
    http://www.fluxiom.com
    管理、組織並分想你的數位資產
  5. strongspace.com
    http://www.strongspace.com
    File hosting檔案分享網站
  6. Typo
    http://www.typosphere.org
    Blogging engine,這在Ruby on Rails也算是很紅的一套blog系統

第三部份應該是筆者自行發現的網站,還滿不錯的~看到好多以前沒逛過的站

  1. ajaxed.com
    http://www.ajaxed.com
    不需要寫程式即可輕輕鬆鬆在你現有的網站上加上Ajax的效果
  2. atopsites.com
    http://atopsites.com
    仿Alaxa.com的網站
  3. asoboo.com
    http://asoboo.com
    針對Creative people所設立的社群網站(筆者特別強調該網站是佈署在Win2003)
  4. thebeststuffintheworld
    http://www.thebeststuffintheworld.com
    有趣的web 2.0應用
  5. dealplumber.com
    http://www.dealplumber.com
    另一個有趣的社群網站
  6. digital-tunes.net
    http://www.digital-tunes.net
    專做音樂的電子商務網站
  7. flagr.com
    http://www.flagr.com
    看起來應該是跟Google map有關的Mashup
  8. godefy.com
    http://www.godefy.com
    有關網路行銷公司或產品的比較
  9. lovexpress.fr
    http://www.lovexpress.fr
    法國的交友網站
  10. podomatic.com
    http://podomatic.com
    專門分享podcasts的網站
  11. pixrat.com
    http://www.pixrat.com
    Social picture bookmars,人家del.icio.us做的是書籤,pixrat做的是「圖籤」,其實前陣子出現的diggirl概念就類似Pixrat,都是要收藏美女並且用類似「digg」的方式來推選出本日熱門,不過Pixrat的精神比較接近書籤,比較著重在收藏、分享,而diggirl則是著重在本日最熱門,比較接近digg的概念。(但diggirl同時又搭配幹圖王可以收藏,還滿威的!)