Currently this script places orders blindly, I mean it runs at scheduled time and places the order, the scope of improvement is - it should be intelligent enough to decide whether to place or not or when to place 8 AM or 11 AM or both ?? -- I am working on it :)
#Include <Date.au3>
#include <IE.au3>
Dim $Filename
WriteToLogFile ("foliofn_log.txt", "Connecting to Foliofn...")
ShellExecute("C:\Program Files\Internet Explorer\IEXPLORE.EXE", "about:blank")
Sleep (3000)
$oIE = _IEAttach ("about:blank", "url")
Sleep (2000)
_IENavigate ($oIE, "https://www.folioinvesting.com/servlets/ProcessAction?identifier=loginFormEntry&click1=Login")
_IELoadWait ($oIE)
$oForm = _IEFormGetObjByName ($oIE, "loginForm")
$oElement = _IEGetObjById($oIE, "inputLogin")
_IEFormElementSetValue ($oElement, "user_id")
$oElement = _IEGetObjById($oIE, "inputPassword")
_IEFormElementSetValue ($oElement, "********")
$oElement = _IEGetObjById($oIE, "loginBtn")
_IEAction ($oElement, "click")
WriteToLogFile ("foliofn_log.txt", "Logged-in to Foliofn")
_IELoadWait ($oIE)
WriteToLogFile ("foliofn_log.txt", "Started Placing Order")
_IENavigate ($oIE, "https://www.foliofn.com/servlets/ProcessAction? &_
identifier=default_myAccounts_portal&myAcct.destination=tradeWindow& &_
;myAcct.level=F&myAcct.accountname=*****&myAcct.accountType &_
=I&myAcct.accountNumber=********&myAcct.folioNumber=**********") &_
_IELoadWait ($oIE)
WriteToLogFile ("foliofn_log.txt", "Opening - [Trade Entire Folio] Tab")
;Find the link "Trade Entire Folio" and click it
$sMyString = "Trade Entire Folio"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
$sLinkText = _IEPropertyGet($oLink, "innerText")
If StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next
_IELoadWait ($oIE)
WriteToLogFile ("foliofn_log.txt", "Opening - [Update & Exchange] Tab")
;Find the link "Update & Exchange" and click it
$sMyString = "Update & Exchange"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
$sLinkText = _IEPropertyGet($oLink, "innerText")
If StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next
_IELoadWait ($oIE)
WriteToLogFile ("foliofn_log.txt", "Making final selections")
; Select RADIO button
$oForm = _IEFormGetObjByName ($oIE, "tradeFolioSyncSubmit")
_IEFormElementRadioSelect ($oForm, "R", "syncOption", 1, "byValue")
;Preview Order : remember it's an image button
_IEFormImageClick ($oIE, "btn_preview.gif", "src")
_IELoadWait ($oIE)
WriteToLogFile ("foliofn_log.txt", "Clicked on order PREVIEW button")
;Preview Order : remember it's an image button
_IEFormImageClick ($oIE, "btn_order.gif", "src")
WriteToLogFile ("foliofn_log.txt", "Clicked on [Place Order] button")
_IELoadWait ($oIE)
WriteToLogFile ("foliofn_log.txt", "Order Placed")
WriteToLogFile ("foliofn_log.txt", "Loging-out of the site..")
_IEImgClick ($oIE, "/_linkedfiles/_images/_ui/icon_logout.gif", "src")
sleep(1000)
_IELoadWait ($oIE)
_IEQuit ($oIE)
If _NowTime(5) > '10:58:00' Then
WriteToLogFile ("foliofn_log.txt", "Putting the computer in Sleep mode !")
Shutdown(32)
EndIf
WriteToLogFile ("foliofn_log.txt", "===================================")
;-- Order Placed..
;==============================================
; Logging function
Func WriteToLogFile ($Filename, $Contents)
$file = FileOpen($Filename, 1)
FileWriteLine($file, @ScriptName & @TAB & _Now() & @TAB & $Contents & @CRLF )
FileClose($file)
EndFunc
;==============================================
No comments:
Post a Comment