PureBytes Links
Trading Reference Links
|
I was looking at the VB macro's behind TWS's Excel
example and it appears all the VB code does is
create a string and sends it via DDE to TWS, I.E.
to send an order to purchase 10 Mar 2004 E-mini
S&P's at 1170.00 to the demo accounts the string is
"=edemo|ord!id1036896412?place?SELL_10_ES_FUT_200403_GLOBEX_LMT_1170_EMPTY_DAY_EMPTY_EMPTY_O_0_EMPTY_1_EMPTY_0_0_0_0_0_0_EMPTY"
(idxxxxxxxxxx is generated based on the time)
I.E. (Date - 37000) * 1000000 + (Time * 1000000)
This got me to thinking, if you used TS Link,
http://www.tsresearchgroup.com/en/articles/prod_20021208140528.php
you could generate DDE calls to TWS directly from
within EasyLanguage.
I generated a trade in Excel, and wrote some quick
EL code to cancel the order (I did a copy/paste
of the trade id, this is just a proof of concept).
The EL code looks like this:
defineDLLFunc: "tslink.dll", int, "TS_StartExcel",LPSTR,LPSTR;
defineDLLFunc: "tslink.dll", int, "TS_SetString",lpstr,int,int,int,int;
if currentbar = 1 then begin
TS_StartExcel("TSLinkDemo.xls","C:\Program Files\TS Link\TSLinkDemo.xls");
TS_SetString("=edemo|ord!id1036868160?cancel?",1,1,2,0);
end;
... And guess what? It worked! TS sent a DDE
instruction to Excel, that in turn sent the DDE to
TWS. You could jump over Excel with a more
flexible DLL, but I was working within the TS Link
demo limitations.
Just experimenting with differing automation
methods, hope this was of interest to someone :)
Kind Regards,
Justin
|