• 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!

C++ or C#, RTD or DDE, Xll or Dll?

Joined
7/18/09
Messages
8
Points
11
Hello,

I'm a newcomer in FE and I'm a bit lost with the ton of tools used. Well, I guess that there is no absolute set of tools, but it depends on what's your objective.

Let's say I'm a arbitrageur (hi. freq.). Hence, I need to have real-time quotations and analysis of markets. Will I still use Bloomberg (or reuters.. doesn't matter)? If I made a list of securities in Excel to look for, will I retrieve the informations from Bloomberg via DDE or RTD? How would you make your choice?
Then, once I have these informations, I'll make few computations. In order to be efficient (an because, in my case, I'm better at those languages), I wrote a piece of code.
Should that code be in C++ or in C#? My favorite is C++, but which one is the most widespread in front-offices? What about for the quants? Finally, would you have wrapped it into a DLL or an Excel Addin (Xll) (I mean, with all the "useless" functions required for compatibility) ?


When using the "=blph" bloomberg function in a cell, you may have noticed that it returns a list of values, an array, but an Excel-style array (shift+ctrl+enter). It's definitely more convenient! How do you think they do? I may have a guess : they use the blph function to retrieve the first cell's address, then a code returns the first value into that cell ("passive" : Excel uses the code). But that code also triggers an automation process ("active" : the code drives Excel) and fills up the following cells.
It sounds it could work, but a bit complicated, isn't it?


As a practice case, I would like to make a code (C++ or C#, dll if possible) that highlight a cell in green or red when its value has just changed, say for a second. In your opinion, how should I proceed? I thought I could use the "Worksheet_Change" (getting the previous value with a Application.undo trick...) event as a trigger. The point is that the dll must not freeze Excel (start a thread?) and has to come back later, by its own, changing the cell's background color. How?


Thank you for having read such a long post!

C.
 
First, thanks for Andy's recommendation :)

Naos,

The answer to your questions can be very long as it always "depends ...". So let me try some potentially over-simplified answers.

1. RTD v.s. DDE: I will prefer RTD, especially if you start from something "clean". Writing RTD using C# is simple. There is a sample on my website

2. Excel UDF: Add-In or XLL is the answer, not regular DLL (as it will require VBA wrappers) unless your functions have been already written in some legacy libraries.

3. Add-in v.s. XLL. Each has its own advantage. My judging criteria is whether your UDF will require lots of already written C++ static libraries. If the answer is yes, C++ based XLL may be more appropriate. Otherwise, if you primarily work in Excel or need to integrate with other stuffs (e.g. RTD, multithreading etc), you will be better off using C# Add-In.

4. Excel array function is very simple to write. Again, there is an example on my website.

5. Making a cell "flashing" will typically require an Excel Add-In (not UDF Add-in or XLL). In this case, C# is the most productive tool (implementing the IDTExtensibility2 interface). In fact, you can either extend my ExcelUDFBase class (if you want a single library for both UDFs, flashing, and maybe RTD) or create a new Extensibility project in VS from scratch.

Hope this helps.
 
In this case, C# is the most productive tool (implementing the IDTExtensibility2 interface).

I agree. This can be done in C++ as well but it is necessary to create an ATL project and implement the methods in this interface.

ATL project needs a number of easy steps; mostly it's a question of pressing the right buttons.

eidt: Using C++ means also access to a wide range of maths libraries and C# does not. It's a choice.
 
Thank you for your answers!

I'm seriously considering ordering your book, Xing ;)... as soon as I'll have basic samples running on my computer (e.g : the mail I sent you) !

For the flashing thing, I may have missed something : if not UDF, what alternative?

Thanks a lot!

C.
 
Which mail? the one concerning issues in a French/English hybrid environment?

UDF, by definition, is designed to do some calculation and return some values. Therefore it cannot (or not supposed to) change workbook/sheet properties such as color. That said, it is possible to read such properties (e.g. cell color, even values/properties of those cells not part of the UDF inputs etc) in the UDF in order to create some "fancy" UDFs. This can be easily done using the C# automation add-in approach (but may be difficult in the traditional XLL approach).

To change workbook/sheet properties, you need an Excel AddIn that can run in the background (so called extensibility project). UDF addin is one type of Excel Add-Ins that serve special purpose (i.e. to create callable worksheet functions). Technically an add-in usually implements the IDTExtensiblity2 interface. As you may see from my ExcelUDFBase example, implementing this interface allows you to get a reference to the running Excel instance. In the case of UDF, we only need this Excel reference for Volatile function, get_callers() etc. It is easy to see that as soon as you get the handle, nothing prevents you from doing more complicated stuffs such as making a cell flashing.
 
Yeap, it's the one concerning the hybrid environment.

It's crystal clear now! This is the way I thought I would do, but wasn't sure it was the way it has to be done.

Many thanks !

Last question : Concerning the C++ part (not that I'm stubborn, just very curious... and a bit old fashioned, yes), what's your opinion on "Financial Applications Using Excel Add-in Development in C/C++" (S. Dalton)?

Thanks again

Charles
 
Last question : Concerning the C++ part (not that I'm stubborn, just very curious... and a bit old fashioned, yes), what's your opinion on "Financial Applications Using Excel Add-in Development in C/C++" (S. Dalton)?

I haven't read that book personally (simply because I know C/C++ APIs and am able to write Excel Add-In using C/C++ as well). But table of contents looks good. Its coverage on this topic seems to be very complete and pretty detailed.
 
XLW

Hi Naos,

One alternative option to writing UDFs you may find interesting is XLW. If you're more interested in FE and want to spend your time coding Monte Carlo or PDE engines and pricing analytics then it may be more appropriate. However if you're more interested in development of GUIs for such software then there are better alternatives such as those suggested by others on this thread.

Have a look at
http://www.youtube.com/watch?v=_mpw5_JW7T4
and
http://www.youtube.com/watch?v=1yLodcb32sI

Also you may find this thread intersting :

http://www.wilmott.com/messageview.cfm?catid=10&threadid=70576

and entertaining ;-)

If you find yourself leaning more towards wanting to code pricing analytics in C++ then I strongly recommend C++ DESIGN PATTERNS AND DERIVATIVES PRICING by Mark Joshi for which you can see the contents page here :

http://www.markjoshi.com/design/contents.pdf

AlexesDad
 
I am new to this forum and don't now how to start a new topic yet. Recently, I developed an excel addin using C# .NET, which uses the Bloomberg .NET API to get the historical equity data. It works fine on my machine. However, when I tried to deploy it to another machine (also a Bloomberg station), I had a hard time to make it to work. The error always related to Bloomberg function. For a test, if the addin without using Bloomberg functions, it works on another machine. Has any one here had experience to deploy excel addin (developed using C#) with bloomberg functions?

Thanks
 
Old thread. Hopefully I can add some value. Excel 2003 has a max of 1GB RAM it can draw from while Excel 2007 has the ability to take essentially everything not being used by other system processes. When using DDE/RDP links (like Bloomberg plug-in) with Excel, v.2007 is far superior to 2003. Just be careful that if you max out the 2007 spreadsheet with complicated formulas and lots of data points you have the ability to draw so much RAM in 2007 that the system can freeze when other processes try to access more.

Also, when talking HFT/HFT Arbitrage, these are relative terms. If you interface to Excel 2007 with an application that faces an API it takes ~200ms to access each message. If you are developing to trade in the sub 200ms space, excel should be nothing but a developmental GUI tool.

I’m not sure what the OP was asking about with historical data and Bloomberg – in the last 2/3 years the Bloomberg add-in has improved a lot and everything he was asking about is now available via a nice GUI wizard tool.

I am new to this forum and don't know how to start a new topic yet. Recently, I developed an excel addin using C# .NET, which uses the Bloomberg .NET API to get the historical equity data. It works fine on my machine. However, when I tried to deploy it to another machine (also a Bloomberg station), I had a hard time to make it to work. The error always related to Bloomberg function. For a test, if the addin without using Bloomberg functions, it works on another machine. Has anyone here had experience to deploy excel addin (developed using C#) with Bloomberg functions?
Have you contacted HELP HELP <GO> yet? What error are you getting? #N/A Auth?
What version of Excel are you using and what tick data are you trying to get? The only time I receive errors is when I try to pull tick-level data when the data set is larger than the number of rows available in the excel sheet. 2007 has a much larger sheet than 2003 so you may need to upgrade to Excel 2007. Also, depending on whether you are at a generic Terminal, Bloomberg Anywhere or using Bloomberg Server, you are allowed only a certain number of data points per day. Bloomberg recently changed the Excel formulas from =blp to =bdp, BDP = Bloomberg Data Point. If you choose a security, such as IBM EQUITY FLDS <GO> the FLDS is for what fields are available – the ones in white are live “BDP” and the orange is historical “BDH”. You should be able to pull historical data from the base level subscription for up to 30-days but know that Bloomberg does not differentiate sub-second so you may see several data points per second and they ARE in chronological order, but you don’t know the exact sub-second time-stamp of the event.
Hope that helps. I’m T.WINSTON on Bloomberg. Send me an IB if you need any help.
 
Other suggestion.

Another suggestion for creating Excel (2007) add-ins in C++ is a library called KeyValue that I have recently made available as open-source:

KeyValue

Since XLW has been mentionned, I have a few words on that and its difference in respect to KeyValue. XLW is, indeed, a very good library. If you wish just to write Excel UDFs, then in my opinion XLW it is unbeatable!

However, if you want to create C++ objects and call their methods from Excel spreadsheets then, please, consider KeyValue. AFAIK, the kind of framework KeyValue implements is widely used in derivative pricing libraries developed and used in investment banks. It has also other features that might be interesting: it runs in Windows and GNU/Linux, it also creates OpenOffice addins, its key-value based interface, ... See the website for more details.

Finally, there are many others similar libraries. To name a few (google them): managedxll, Obba, ExcelDna, XLLoop.

As usual, each of those libraries has its advantages and flaws: the best choice depends on your needs.

Cheers
 
Back
Top