0

My summer project is developing an algorithmic trader that receives market data and trades based off indicators. I pull data from a company called Interactive Brokers using their TWS(Trader workshop station). I have downloaded their Excel API which uses DDE, but cannot get the Excel spreadsheet to properly connect with TWS.

In my excel spreadsheet, I wrote this command into a random cell. I've replaced 'sample123' with my TWS username It is suppose to evaluate to 0 before I make other adjustments but it evaluates to #REF!:

=Ssample123|tik!'id1?req?EUR_CASH_IDEALPRO_USD_~/'

Image of error received

Another issue with the error is it deletes two characters off my username and I am unsure of why.

Ex: username -> Sample123 Outcome -> Sample1

Any suggestions would be greatly appreciated! Thank you and have a nice day.

David
  • 3
  • 4
  • The error clearly states that the DDE application is not running. Thus Excel takes first part of DDE formula to be the application program name and tries starting SSAMPLE1.EXE. The application program name is truncated to 8 characters because of DDE is ancient technology from ancient times where file names only had could be 8 characters long. Have you followed "Tutorial: Requesting Real-Time Market Data - What You Will Need"? – Axel Richter Jul 08 '18 at 04:09
  • Yes, that is one of the resources I've been using. I also have "enable activeX and socket clients" and "enable dde clients" both on so I don't understand why the DDE is not running? So do you believe the core error here is the truncation? – David Jul 09 '18 at 07:01
  • I tried a user name of 8 characters and It still runs me the same initial error. I believe the beginning of each string automatically begins with an S so it will always loose at best a character. What are the steps to fix this problem? – David Jul 09 '18 at 07:30
  • The core error is not the truncation but that DDE application probably is not running. "2. Log into TWS, which **must be up and running while you are using the DDE** for Excel API." – Axel Richter Jul 09 '18 at 07:53
  • I downloaded the TWS software and I have it logged in and running in the background. It still doesn't work. Is it possibly the path excel has setup for the TWS? – David Jul 10 '18 at 05:58
  • Here is an article where they are getting the same exact problem as me but no solution has been found on that site. http://exceltrader.net/1401/getting-twsdde-xls-to-work-without-errors-with-latest-tws-and-api/ – David Jul 10 '18 at 06:07
  • As said, DDE is ancient technology from ancient times where file names only had could be 8 characters long and 64-bit technology was science fiction. Ask for a more recent API. – Axel Richter Jul 10 '18 at 06:18
  • I don't believe I have a choice. My boss wants me to connect TWS to an Excel to update market data for our spreadsheet. DDE looks like the only option. Do you know of how to work around this issue? – David Jul 10 '18 at 18:53
  • I am not using this. I commented only because I know DDE. But [As far as I see](http://interactivebrokers.github.io/tws-api/excel_apis.html), there are at least two additional possibilities too. And there is a [Troubleshooting Excel DDE](http://interactivebrokers.github.io/tws-api/dde_intro.html#dde_issues) which you could work off. – Axel Richter Jul 11 '18 at 03:30
  • ActiveX is another option, a much better one. DDE does not work reliably, you don't want to trade real money using such a horrible technology. Did you tick "Enable DDE Clients" in TWS? You also need to enable macros. – misantroop Aug 25 '18 at 09:08
  • First, I would recomment to launch the demo excel application comes with the API, and check if it is working (I expect yes). Then, look for the parts that are relevant for your current task. – Janos Sep 03 '18 at 13:01

2 Answers2

0

'sample123' in the example formula is the username that was used to login to TWS. It has to be replaced in your formulas with the actual username you used to login to TWS.

Also, to use the older legacy TWS DDE API you have to be running 32 bit TWS and have the setting "Enable DDE" checked in TWS Global Configuration.

Issues causing the #REF error

There is a newer 'DDE Socket Bridge' TWS API also available in the Latest version of the API which has additional functionality and is compatible with the 64 bit version of TWS.

DDE SocketBridge API

Josh
  • 706
  • 3
  • 8
0

I've had the same problem. Just put twsserver instead

Stan
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 19 '22 at 15:57