Calling C++ from Excel as Execution platform

Discussion in 'Automated Trading' started by Longbow, Jun 22, 2011.

  1. Longbow


    Hi everyone,

    first of all, i would like to introduce myself. I am a 23 years old and would like to look into trading with algorithms. I am working in markets, but would also like to trade in my leisure time and explore different strategies and also develop my programming knowledge.

    Having said that, i have got a question to the programmers in the forum. I am right now using Matlab as a backtesting platform, but would like to test my strategies with IBs paper trading account from a different platform. I know there is a interface to connnect IB to Matlab, however I do not feel comfortable with this as execution platform. My choice would be either Excel or C++. However, I have read that Excel is very slow in retrieving data through the DDE interface. Therefore, my question is whether there is any enhancement in speed if i would use Excel as my platform, but do the calculations and data retrievals/order sending via C++ - so i would include like different C++ functions as dll and call them all in a loop in VBA that also writes the most important data to the spreadsheet every loop..

    Do you think this would be a speed enhancement, and would you think this is a rather good or bad way to approach the topic?

    Thanks in advance for any thoughts and help :)

  2. Longbow


    Hi again,

    first of all:
    Is this part of the forum the right place for this question? Or would it better fit in the automated trading forum? If so, can a moderator please transfer this thread to this forum? Thx in advance :)

    So I´ve been thinking: Would my idea mean that whenever I want to do an action in C++ (e.g. sending an order, receiving a price), the DLL needs to open a new connection to IB? If so, is it a better idea to write a C++ program that connects to IB, starts an Excel application, and then this same C++ program will remain in a loop retrieving market data, making calculations, sending orders, and then display the intermediary results in excel (e.g. writing the current ask in a predefined cell). It would also be checking the sheet for any change in cell values by which i would be able to interact with the program through Excel?
    Of course I could create a GUI, but I think that this is much harder and more time consuming than this solution, especially since I would be able to directly save results/logs to excel and do my "bookkeeping" in there.. What do you think?

    Sorry for this probably very easy question to most of you, but this is really keeping me running right now.

  3. Longbow


    Please, anyone can help me?
  4. DSITrader


    I use Amibroker to do all my backtesting. I highly recommend it. It is very easy to program and it has all the tools you need for backtesting. You can import free EOD data from Amibroker is free to use for 30 days as a trial, but you can still use it after the deadline. After the deadline, you can't save databases or chart studies, but your formulas are still saved.

    Amibroker also allows autotrading with IB.

    I know this doesn't answer your question, but this will get around a lot of the problems you are having.
  5. sma202


    you can export using matlabbuilder a com component and then include it in excel
  6. I have developed a platform similar to your design, but with C# and VB.Net and VSTO instead of DDE.

    Broker <-> Broker Liason <-> Excel Liason <-> Excel <-> VBA

    By pushing events from one end to the other, you can use Excel as an execution platform with good human-timescale responsiveness. One is never going to get a HFT-timescale responsiveness.

    It is asking for alot of trouble to try to handle communication problems from Excel. If you are missing a confirmation, for example, you can reconnect and reload your positions to get Excel synchronized. If a bad trade really happened, you can drop back to the broker's tools to close positions and view audit records. Trying to do all of these things from Excel will create take a long time and be a bit dubious.

    There is absolutely nothing wrong with using Excel to compute your view of the markets to manually transcribe the orders, but order management means diving into exception handling which is ultimately a manual operation.
  7. the1


    I agree. Amibroker is an excellent service at a reasonable price and the AFL language is very similar to C++ I don't use it, however. I prefer to code my own algos with C++ with a data feed.