[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IB & AUTOIT script



PureBytes Links

Trading Reference Links

List & Abhijet:

Thanks for your great description of IB data, and the Emini-Trader link.

I read through it just now, and very strange, can't find where I can 
download it, the AUTOIT script.    Hope it is one of those that once 
installed, it gets itself going at 2400central time after IB had gone to 
nap?    Or I am still just dreaming.   Probably should shut down the pc 
when I went on my vacation?

Here's the script. software is at hiddensoft.com. This code is in v2 of 
autoit. You can use autoit to run it or create an executable. It expects 
2 parameters - your TWS username & password.

Yes, switching off the pc would be a good idea. When you are back, ask 
around for data the old fashioned way  8D

Or just keep waiting till someday I write a megascript to babysit TWS in 
every which way possible. 8D (might be a really long wait)

Abhijit
SetEnv,search,%2%
IfNotInString,search,ManualInput,Goto,AutoInput
InputBox,2,AutoIt,Password
AutoInput:

GoSub,LetUserKnowWeAreWorking



MainMonitoringLoop:
IfWinExist,Trader Workstation,,GoSub,AnswerConnectRequest
IfWinExist,IB Trader Workstation,,GoSub,AnswerConnectRequest
IfWinNotExist,Universal Account,,Gosub,RestartTWS
Sleep,10000
Goto,MainMonitoringLoop


AnswerConnectRequest:
IfWinNotExist,Trader Workstation,,GoTo,ACR2
WinRestore,Trader Workstation
WinActivate,Trader Workstation
IfWinActive,Trader Workstation,,Send,{SPACE}
ACR2:
IfWinNotExist,IB Trader Workstation,,GoTo,ACREnd
WinRestore,IB Trader Workstation
WinActivate,IB Trader Workstation
IfWinActive,IB Trader Workstation,,Send,{SPACE}
ACREnd:
Return


RestartTWS:
IfWinNotExist,New Login,,Goto,StartLoginNow
; are we logging in already (eg. ib downtime or connection down)

IfNotExist,C:\\Kill.txt,Goto,RstrtTryAgain0
; agressive kill zone here
SplashTextOn,500,100,none,Error 1 - Killing Login Window and Trying Again
Sleep,3000
SplashTextOff
Gosub,KillLoginWindow
Sleep,2000

StartLoginNow:
Run,C:\\WINDOWS\\system32\\javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\\JTS ,C:\\JTS

WaitforLoginWindowToAppear:
Sleep,500
IfWinNotExist,New Login,,Goto,WaitforLoginWindowToAppear

RstrtTryAgain0:
Gosub,EnterUserNameAndPassword
Sleep,30000

RstrtTryAgain:
IfWinNotExist,New Login,,Goto,RTWSEnd
Sleep,30000
IfWinNotExist,New Login,,Goto,RTWSEnd
Sleep,30000
IfWinNotExist,New Login,,Goto,RTWSEnd
Sleep,30000
IfWinNotExist,New Login,,Goto,RTWSEnd
Sleep,10000
IfWinNotExist,New Login,,Goto,RTWSEnd

; if its still without login in progress then kill it and try again on 3 min cycle
IfWinNotExist,Login,progress,SplashTextOn,500,100,none,Error 2 - Killing Login Window and Trying Again
IfWinNotExist,Login,,Sleep,3000
IfWinNotExist,Login,,SplashTextOff
IfWinNotExist,Login,,Gosub,KillLoginWindow


RTWSEnd:
; wait 50 seconds for the login to take place before monitoring TWS again
Sleep,50000
Goto,MainMonitoringLoop





;
;SUBROUTINES
;

LetUserKnowWeAreWorking:
SplashTextOn,500,100,none,*** Keep_TWS_Alive for TWS819 is now Working ***
Sleep,3000
SplashTextOff
Return


KillLoginWindow:
WinActivate,New Login
Send,!{TAB}
Send,{SPACE}
Send,{BACKSPACE}
WinActivate,New Login
Sleep,100
IfWinActive,New Login,,Send,!{F4}
Sleep,2000
IfWinNotExist,New Login,,GoTo,KLWend
WinActivate,New Login
Send,!{TAB}
Send,{SPACE}
Send,{BACKSPACE}
WinActivate,New Login
Sleep,100
IfWinActive,New Login,,Send,!{F4}
KLWEnd:
Return


EnterUserNameAndPassword:
Sleep,300
WinActivate,New Login
Sleep,100
Send,!{TAB}
Send,{SPACE}
Send,{BACKSPACE}
WinActivate,New Login
Sleep,100
Send,%1%
Send,{TAB}
Sleep,100
IfWinNotActive,New Login,,GoTo,Error_WindowNotActive
Send,%2%
Sleep,100
IfWinNotActive,New Login,,GoTo,Error_WindowNotActive
Send,{Enter}
GoTo,EUPEnd

Error_WindowNotActive:
SplashTextOn,400,100,none,Error - NewLogin Window Not Active for Password Entry
Sleep,5000
SplashTextOff
GoSub,KillLoginWindow
EUPEnd:
Return


Exit



[ADLIB]