• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

How to pass market data to c++ code?

Joined
8/11/11
Messages
124
Points
278
Hi all,

I've got a very silly question but that I can't figure out how to deal with.

I have my c++ code for pricing options (MC, FDM whatever), I've tested it and it works right. When testing it I used to type the inputs (vol, spot, rfr, etc.) just to see if it works properly.

But now I want to transform my code into production code, which means that I need to pass market data in a efficient way, for example a interest rate curve, a volatility surface, etc. I have all that stuff in a database.

My question is how I can use that data in my c++ code.

I asked a question here (https://www.quantnet.com/forum/threads/connecting-c-and-sql-server.9145/#post-86056) but I'm not sure if there is a simpler way.

Maybe using Excel as interface?
 
I did something similar years ago. Data is on a SQL server. Excel is the intermediate layer. Create VBA code that call on some sql stored queries to import data onto a sheet/range on Excel. Use this range as input data for C++ code which can be an addin or some VBA macro. When C++ is done calculating, the result is pushed back to Excel or store in SQL.
By the way, I did them in C# but C++ should be similar.
I don't know if there are better ways to do it now.
 
Hi all,

I've got a very silly question but that I can't figure out how to deal with.

I have my c++ code for pricing options (MC, FDM whatever), I've tested it and it works right. When testing it I used to type the inputs (vol, spot, rfr, etc.) just to see if it works properly.

But now I want to transform my code into production code, which means that I need to pass market data in a efficient way, for example a interest rate curve, a volatility surface, etc. I have all that stuff in a database.

My question is how I can use that data in my c++ code.

I asked a question here (https://www.quantnet.com/forum/threads/connecting-c-and-sql-server.9145/#post-86056) but I'm not sure if there is a simpler way.

Maybe using Excel as interface?

Where is your market data stored? a database? some files? on the web somewhere?

Andy's solution will work but it's really complicated and it has too many moving parts which could lead to maintenance and debugging issues.

In an ideal world, you will have a adapter/layer that takes the market data from somewhere (look above for possible sources) and feeds them into your application. So you will only need to call this adapter/layer to feed the calculations. You can make that adapter as flexible as you want for possible market data sources.
 
Many data providers these day would have a robust API which supports many main stream languages which you can use to connect to.
You can bypass the whole Excel together if you use C# to build some windows forms that display the results and control parameters.
 
thanks both for your answers!

Andy Nguyen, that's the scheme I have in mind since the most problematic point for me is the interface c++ with Excel, and I'm already working with Mark Joshi's suggestion, xlw, which seems to be the easiest to implement (at least for me)

alain, all my market data is in SQL Server... any suggestion for this?

thanks again!!
 
alain, all my market data is in SQL Server... any suggestion for this?

What's the goal? how do you plan to use your application? Who is going to consume the data? I would write a layer that takes SQL server data and give it to the world.

BTW, who is in charge of the data?
 
the goal is to make an application that prices a portfolio using COB market data, so at the end of the day I download the data to my database and then, I pass it to my c++ code to price all my products. After that, I get the results from my c++ code and store them in my database again.

well, that's the final image :D I already have some parts of the process but I still don't know how to pass the market data to my c++ code

in which language would you write that layer?

I'm afraid I'm in charge of everything: coding in c++, downloading the data (and ckecking it), storing the data... :oops:
 
There are numerous APIs that will make this very easy for you and abstract away lower level details. For instances Qt has an SQL module (though installing Qt for this may be overkill). Poco libraries, from memory, have a library for DB access though I am not sure that one is under their open source licensed libraries. This one is pretty good to0 - very intuitive syntax - http://soci.sourceforge.net/.
 
Back
Top