Tag Archives: SWIG

Wrap C++ with Python in SWIG

Wrap C++ with Python in SWIG

Another attempt for Python to call a ++ generated library. It sounds like very few have attempted this successfully

http://intermediate-and-advanced-software-carpentry.readthedocs.org/en/latest/c++-wrapping.html

Join my FREE newsletter to see when I am able demo this

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

How is Python with SWIG and QuantLib still an issue to be integrated? Or is it?

How is Python with SWIG and QuantLib still an issue to be integrated? Or is it?

 

A comment posted about:

I am closer to building Quantlib SWIG,for Ruby ,Python using C++,wrappers in Ubuntu Linux

Hi, were you ever able to get QuantLib-SWIG bindings for Python built on your linux box? i’ve been trying unsuccessfully for some time now and i’m arriving at the same result when running python setup.py test, that is, it throws an error which appears to be an issue with one’s path. Thanks!

 

My response:

I have not yet looked at this with no success Part of it is I find Python will just add to the confusion of too many languagees you need to know. I am just surprised this is still a problem from a few years ago. If you got a solution, please let me know by comment below with a solution.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Getting close to building Quantlib SWIG for Ruby and Python using C++ wrappers in Ubuntu Linux

Getting close to building Quantlib SWIG for Ruby and Python using C++ wrappers in Ubuntu Linux
I have a spent one day trying to build both the QuantLib and Quantlib SWIG libraries and objects within my Linux environment. It seems Ubuntu was favoured choice for that.
For the proper tar balls download, I used a variety including the SWIG from Ubuntu’s Launch pad site and the one on Sourceforge. It seems that you make sure the Quantlib library must synch up exactly with the SWIG version so you need 1.0 for both. I do not know if QuantLib version 1.0.1 is compatible with Quantlib SWIG 1.0. I could be wrong so if someone can comment to give me guidance on that would be appreciated. As a result, only focus on the Quantlib 1.0 and Bindings subfolder for the corresponding SWIG components.
Next up, I found that I was able to build QuantLib library fairly easily. I virtually had no issues with this regardless of platform if it is Ubuntu Linux, Centos (like Red Hat), or Windows. It is quite easy.
It is this QuantLib SWIG that is a bitch. I only care about Python and Ruby for now. Using the exact instructions at
http://chicagoquantitativetrading.wordpress.com/
This seems to work with the exception of using my language like:
python setup.py test
Or
ruby setup.rb test
Both failed but it may be due to file path issues. I am still working on it but the errors seem strange.
I also finding if I follow the instructions from the READ ME text file for either subdirectory of Ruby or Python, I should build first using:
ruby setup.rb wrap
Or
python setup.rb wrap
I then use the typical order of:
Build, test, install.
I did look at these results but did build ok. It seems it points back to a missing file path. I am still experimenting with this to ensure a proper build and test for either Python or Ruby.
I shall report something once I get it running fine.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Giving up on QuantLib SWIG, I will now try JQuantlib for Java Quant development use.

Giving up on QuantLib SWIG, I will now try JQuantlib for Java Quant development use.
I have given up on this QuantLib SWIG (maybe for now). I am looking into an alternative call JQuantLib which offers a completely written interpretation of QuantLib itself.
Benefits of this include:
Benefits
• coverage of a wide range of financial instruments;
• running at speeds competitive with C++;
• smooth learning curve with lucid documentation;
• easy integration with other projects;
• shortening time to market.

Features in a nutshell
• Performs valuation of a wide variety of financial instruments;
• Employs analytical, stochastic and simulation algorithms;
• Offers functions for VaR (value at risk) valuation;
There are more benefits. I realize that this in Java and it is not quite one hundred per cent compatible with the current version of Quantlib. As it stands, the Quantlib SWIG is not up to my standards in terms of quality, support, or ease of use. I move forward but I can never get a positive Test run on my chosen language of Python or Ruby. Screw that, I no longer have the time or patience for it.
SWIG also appears to be meant for Linux only as the alternative workarounds within Windows. You need to use either MINGW or CYGWIN which kind of is substandard. There is too much monkeying around with MINGW to make sure the packages you use are compatible.
I hope JQuantlib is universal with less harassments I have found with QuantLib SWIG. I am sure my deficiencies are my own cause but I could never figure out how I could propose this to a potential client. This option of QuantLib SWIG is not a mature product or reliable enough.
I will report on my JQuantLib experience so wish me luck. The big disadvantage is that Quantlib SWIG offers of being able to bind to other programming languages like Python or Ruby. I have worked on this worked on this for a day and a half. I still have no successful results. Sorry QuantLib folks.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

I am closer to building Quantlib SWIG,for Ruby ,Python using C++,wrappers in Ubuntu Linux

I am closer to building Quantlib SWIG,for Ruby ,Python using C++,wrappers in Ubuntu Linux

I have a spent one day trying to build both the QuantLib and Quantlib SWIG libraries and objects within my Linux environment. It seems Ubuntu was favoured choice for that.
For the proper tar balls download, I used a variety including the SWIG from Ubuntu’s Launch pad site and the one on Sourceforge. It seems that you make sure the Quantlib library must synch up exactly with the SWIG version so you need 1.0 for both. I do not know if QuantLib version 1.0.1 is compatible with Quantlib SWIG 1.0. I could be wrong so if someone can comment to give me guidance on that would be appreciated. As a result, only focus on the Quantlib 1.0 and Bindings subfolder for the corresponding SWIG components.
Next up, I found that I was able to build QuantLib library fairly easily. I virtually had no issues with this regardless of platform if it is Ubuntu Linux, Centos (like Red Hat), or Windows. It is quite easy.
It is this QuantLib SWIG that is a bitch. I only care about Python and Ruby for now. Using the exact instructions at
http://chicagoquantitativetrading.wordpress.com/
This seems to work with the exception of using my language like:
python setup.py test
Or
ruby setup.rb test
Both failed but it may be due to file path issues. I am still working on it but the errors seem strange.
I also finding if I follow the instructions from the READ ME text file for either subdirectory of Ruby or Python, I should build first using:
ruby setup.rb wrap
Or
python setup.rb wrap
I then use the typical order of:
Build, test, install.
I did look at these results but did build ok. It seems it points back to a missing file path. I am still experimenting with this to ensure a proper build and test for either Python or Ruby.
I shall report something once I get it running fine.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Painless instructions on how to build QuantLib SWIG for Python and Ruby bindings in Ubuntu Linux

Painless instructions on how to build QuantLib SWIG for Python and Ruby bindings in Ubuntu Linux

Getting Quantlib SWIG to work properly is a real pain in the ass. First, if you go to Sourceforge, you will not find QuantLib SWIG at all. When you attempt to check out using SVN, you will find the particular version will not contain the required configure program to set up your Linux environment. Again, I am using Ubuntu Linux.
Thankfully, I found an awesome link right from Ubuntu’s website. The link was:
https://launchpad.net/ubuntu/maverick/+source/quantlib-swig
This was easily the most critical link and / or documentation to get this working. Others seem to be inadequate in assuming you are Linux guru to get this working. As you download this one library and tar ball, make sure you install each dependency package list. This includes:
• debhelper (>= 7.0.0)
• g++ (>= 4:4.0)
• gcc (>= 4:4.0)
• libboost-dev (>= 1.34.0)
• libboost-test-dev (>= 1.34.0)
• libquantlib0-dev (>= 1.0.0~20100209)
• python-all-dev (>= 2.3.5-10)
• python-central (>= 0.5)
• ruby
• ruby1.8
• ruby1.8-dev

For each package on the command line, you can use Aptitude to cleanly install. Do as root:
apt-get install (package)
or use as an non root:
sudo apt-get install (package)
From the above link, you should be able to run individually configure, make, and make install.
Within the QuantLib SWIG directory, run:
./configure
make
make install
I do notice that the last two commands will produce Java exceptions of missing directories. This is where I get confused. Anyhow, I tried:

make –C Python at the QuantLib-SWIG-1.0 directory level. I did not running this within the Python sub directory.
There appears to be a step by step blog post at:
http://chicagoquantitativetrading.wordpress.com/
This may help if you still have difficulty.
I am not sure why this has to be this difficult. There is a definite need for the QuantLib SWIG authors to improve this. I will report my results as I get it at it. I want to get the Ruby bindings but will Python as a role model. There appears to be more third party documents for Python.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Why my choice Ubuntu is my choice to deploy on for C++ SWIG, Marketcetera, and QuantLib? Awesome

Why my choice Ubuntu is my choice to deploy on for C++ SWIG, Marketcetera, and QuantLib? Awesome

OK. I am really frustrated with this C++ SWIG package on Windows. I cannot handle the obsolete documents where you need to use SWIG within MINGW. It is very frustrating and backdated when it comes to running the latest required updated packages. Screw it. I feel I am now going to move to Linux.

Now the question becomes which flavour. I have thought about and pushed for Centos for quite a while. As many investment banks and hedge funds appear to use it, I also find it limiting on their repository when I decide to do yum install or updates. It is one of those back flashes to the 80s. I still feel it is worth knowing CentOS in order to stay in synch with what potential employers are looking for.
That brings me to my updated decision to deploy onto Ubuntu 10.04 desktop and server editions. Why? Well, first they are free. Ubuntu also is gaining some traction as it appears I saw a posting on Bloomberg which appears to legitimize versus Red Hat. Security also seems to be less of an issue as well.

The number one reason why I went with Ubuntu is that my productivity jumps through the roof. When I do my updates for dependencies, I just use the apt-get command to get the latest. Less hassles compared to Red Hat or Centos. Also, it is such a popular flavour of Linux you cannot go wrong.
As for C++ SWIG and Quantlib SWIG, it appears I have made a correct decision as I am blazing through my builds and compilations to move foward in deploying on Ubuntu. Also, I am very thankful I can deploy my Marketcetera on it as well.

If you are deciding which platform to use, I would strongly recommend you look at Ubuntu as potential. Not only is it free, it is mature, and has great third party support. It is becoming the new future in operating systems.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!