開拓者 TB【升級】用AUTOIT和TB打造國內(nèi)期貨無人值守全自動交易系統(tǒng)[開拓者公式]
- AUTORUN_config.ini --基礎(chǔ)配置文件
AUTORUN_holiday.ini --法定節(jié)假日定義,這個手動輸入,軟件函數(shù)可以判斷是否工作日,但無法判斷法定節(jié)假日,這個外部定義。
AUTORUN_notes.ini --日志文件,看自己是否使用了,
功能介紹:主要是我定義了3個配置文件,這樣使用還是比較方便的
1、節(jié)假日,以及周六周末不打開運(yùn)行交易開拓者,只交易日運(yùn)行。
2、交易日上午08:50運(yùn)行,自動啟動交易開拓者,并運(yùn)行自動交易,11:31自動關(guān)閉自動交易,并關(guān)閉交易開拓者
3、交易日下午13:20運(yùn)行,自動啟動交易開拓者,并運(yùn)行自動交易,15:15自動關(guān)閉自動交易,并關(guān)閉交易開拓者
自用代碼,分享給大家,有部分估計大家也用不到看著也眼花就刪除了,
在此特感謝hyjok的分享,這個是在hyjok的分享的方法上進(jìn)行修改的
// m.kzuj.com.cn
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:小平常心
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
;Script Start - Add your code below here
;程序文件:TradeBlazer.exe
;軟件名稱:交易開拓者平臺
;版本:4, 2, 1, 0
;更新:2011-09-05
#Include <Date.au3>
#include <Excel.au3>
#include <Array.au3>
#include <String.au3>
#include <Timers.au3>
#include <Math.au3>
#include <process.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#NoTrayIcon ;托盤不顯示exe文件的圖標(biāo)
Dim $result,$tmp1,$tmp2,$tmp3,$tmp4
Dim $path,$TBloginname,$TBloginpassword,$record
Global $tmp01,$tmp02,$tmp03,$tmp04,$tmp05,$tmp06,$tmp07,$tmp08,$tmp09,$tmp10
Global $tmp50,$tmp51,$tmp52,$tmp53,$tmp54,$tmp55
Global $temp01,$temp02,$temp03,$temp04,$temp05
Global $temp11,$temp12,$temp13,$temp14,$temp15
Global $temp20,$temp21,$temp22,$temp23,$temp24,$temp25,$temp26,$temp27,$temp28,$temp29
Global $temp31,$temp32,$temp33,$temp34,$temp35,$temp36,$temp37,$temp38,$temp39
Global $temp40,$temp41,$temp42,$temp43,$temp44
Sleep(30000)
$path="D:\temp\TradeBlazerV4\" ;TB默認(rèn)安裝路徑,如非默認(rèn)安裝,這里需要更改為你TB安裝路徑
$TBloginname="***" ;用你的TB登陸賬號替換***
$TBloginpassword="***" ;用你的TB登陸密碼替換***
$tmp05=FileOpen("D:\temp\AUTORUNWHALL\AUTORUN_config.ini",0) ;//根據(jù)情況修改,基本配置文件
$tmp06 =Number(FileReadLine($tmp05, 2)) ;狀態(tài)
$tmp07 =Number(FileReadLine($tmp05, 4)) ;啟動Mytrader2011
$tmp08 =Number(FileReadLine($tmp05, 6)) ;啟動博易大師
$tmp09 =Number(FileReadLine($tmp05, 8)) ;啟動TB自動交易下單
$tmp10 =Number(FileReadLine($tmp05, 10)) ;重新啟動文化WH3
$tmp51 =Number(FileReadLine($tmp05, 20)) ;啟動WH3
$tmp52 =Number(FileReadLine($tmp05, 22)) ;自動下單
$tmp53 =Number(FileReadLine($tmp05, 24)) ;保留配置
$tmp54 =Number(FileReadLine($tmp05, 26)) ;保留配置
FileClose($tmp05)
$temp20=FileOpen("D:\temp\AUTORUNWHALL\AUTORUN_holiday.ini",0) ;//根據(jù)情況修改,國家法定節(jié)假日配置文件
$temp21 =Number(FileReadLine($temp20, 01))
$temp22 =Number(FileReadLine($temp20, 02))
$temp23 =Number(FileReadLine($temp20, 03))
$temp24 =Number(FileReadLine($temp20, 04))
$temp25 =Number(FileReadLine($temp20, 05))
$temp26 =Number(FileReadLine($temp20, 06))
$temp27 =Number(FileReadLine($temp20, 07))
$temp28 =Number(FileReadLine($temp20, 08))
$temp29 =Number(FileReadLine($temp20, 09))
$temp31 =Number(FileReadLine($temp20, 10))
$temp32 =Number(FileReadLine($temp20, 11))
$temp33 =Number(FileReadLine($temp20, 12))
$temp34 =Number(FileReadLine($temp20, 13))
$temp35 =Number(FileReadLine($temp20, 14))
$temp36 =Number(FileReadLine($temp20, 15))
$temp37 =Number(FileReadLine($temp20, 16))
$temp38 =Number(FileReadLine($temp20, 17))
$temp39 =Number(FileReadLine($temp20, 18))
FileClose($temp20)
;循環(huán)開始
While 1
$temp11 = (@WDAY>1 and @WDAY<7) ;工作日
$temp12 = (@WDAY=1 Or @WDAY=7) ;周末
$temp01=((@HOUR=08 And @MIN>=50) Or @HOUR>08) And ((@HOUR =11 And @MIN<=31) Or @HOUR <11) And $temp11=1; //上午程序運(yùn)行時段: 8:50 -- 11:31
$temp02=((@HOUR=12 And @MIN>=50) Or @HOUR>12) And ((@HOUR =15 AND @MIN<=01) Or @HOUR <15) And $temp11=1; //下午程序運(yùn)行時段: 13:20 -- 15:15
Sleep(1000)
$temp40=@YEAR&@MON&@MDAY ;
$temp41 =($temp40=$temp21 or $temp40=$temp22 or $temp40=$temp23 or $temp40=$temp24 or $temp40=$temp25 or $temp40=$temp26)
$temp42 =($temp40=$temp27 or $temp40=$temp28 or $temp40=$temp29 or $temp40=$temp31 or $temp40=$temp32 or $temp40=$temp33)
$temp43 =($temp40=$temp34 or $temp40=$temp35 or $temp40=$temp36 or $temp40=$temp37 or $temp40=$temp38 or $temp40=$temp39)
$temp44 =($temp41=1 or $temp42=1 or $temp43=1) ;判斷是否節(jié)假日
If ProcessExists("TradeBlazer.exe") And WinExists("交易開拓者平臺(旗艦版) - ") = 0 Then
ProcessClose("TradeBlazer.exe")
ProcessClose("TBDataCenter.exe")
Sleep(3000)
EndIf
If WinExists("交易開拓者平臺(旗艦版) - ") = 0 And ($temp01=1 Or $temp02=1 Or $tmp06=1) And $temp44=0 Then ;>=8:50且小于15:00如果TB未開則打開TB
$result=0
FileDelete($path&"data\__db.001")
FileDelete($path&"data\__db.002")
FileDelete($path&"data\__db.003")
Run($path&"TradeBlazer.exe",$path)
Sleep(10000)
WinWaitActive("歡迎登錄交易開拓者平臺(旗艦版)","",20)
WinActivate("交易開拓者平臺(旗艦版)")
;ControlFocus("歡迎登錄交易開拓者平臺(旗艦版)","","Edit1")
;ControlSetText("歡迎登錄交易開拓者平臺(旗艦版)","","Edit1",$TBloginname) ;保存帳號,可以不用再輸入了
ControlFocus("歡迎登錄交易開拓者平臺(旗艦版)","","Edit2")
ControlSetText("歡迎登錄交易開拓者平臺(旗艦版)","","Edit2",$TBloginpassword)
ControlFocus("歡迎登錄交易開拓者平臺(旗艦版)","","Button1")
Sleep(1000)
ControlClick("歡迎登錄交易開拓者平臺(旗艦版)","","Button1")
WinWaitActive("交易開拓者平臺(旗艦版) - ","",30)
Sleep(5000)
WinActivate("交易開拓者平臺(旗艦版) - ")
If WinExists("系統(tǒng)消息") Then
WinActivate("系統(tǒng)消息")
Sleep(1000)
WinClose("系統(tǒng)消息")
Sleep(1000)
EndIf
;_record0("交易開拓者啟動完成")
;************TB自動登陸*****結(jié)束***********************
Sleep(2000)
WinActivate("交易開拓者平臺(旗艦版) - ")
if ($tmp09=1) then ;啟動工作區(qū)內(nèi)所有自動交易
$result=WinMenuSelectItem("交易開拓者平臺(旗艦版) - ","","文件(&F)", "啟動所有自動交易");啟動工作區(qū)內(nèi)所有自動交易
EndIf
Sleep(2000)
If $result=0 Then
WinActivate("交易開拓者")
Sleep(1000)
;WinClose("交易開拓者")
Sleep(2000)
EndIf
WinSetState("交易開拓者平臺(旗艦版) -","",@SW_MINIMIZE)
MouseMove(650, 550, 10) ;
Sleep(1000)
EndIf
If WinExists("交易開拓者") And ($temp01=0 And $temp02=0 And $tmp06=0) Then ;非交易時間關(guān)閉TB;11:31后收盤時間 以及>=15:10后關(guān)閉都TB
ProcessClose("TradeBlazer.exe")
ProcessClose("TBDataCenter.exe")
;_record0("關(guān)閉交易開拓者")
EndIf
Sleep(5000)
WEnd;循環(huán)結(jié)束
;//記錄運(yùn)行狀態(tài)函數(shù) ---這里你可以自己定義其他函數(shù),比如給自己發(fā)送短信什么的,這個就看自己怎么擴(kuò)展了
Func _record0($record)
Sleep(500)
$fileHand = FileOpen("D:\temp\AUTORUNWHALL\AUTORUN_notes.ini",1) ;不清除原來的內(nèi)容
FileWrite($fileHand,_NowCalc()& " " &$record&@crlf) ;把數(shù)據(jù)寫入tt.txt
FileClose($fileHand) ;關(guān)閉文本文件
Sleep(500)
EndFunc
- TB技術(shù)人員: 本帖最后由 小平常心 于 2013-7-21 12:15 編輯
AUTORUN_TB.au3
AUTORUN_TB.rar (2.31 KB, 下載次數(shù): 7) 2013-7-21 12:15:38 上傳下載次數(shù): 7
holiday.ini
AUTORUN_notes.ini
AUTORUN_config.ini
三個配置文件如下:
AUTORUN_holiday.rar (161 Bytes, 下載次數(shù): 30) 2013-7-20 19:24:48 上傳下載次數(shù): 30
文件格式
AUTORUN_notes.rar (214 Bytes, 下載次數(shù): 28) 2013-7-20 22:13:23 上傳下載次數(shù): 28
-
AUTORUN_config.rar
2013-7-20 21:21:14 上傳
下載次數(shù): 6
370 Bytes, 下載次數(shù): 6
- TB客服: 本帖最后由 小平常心 于 2013-7-20 21:44 編輯
小平常心 發(fā)表于 2013-7-20 19:25
AUTORUN_holiday.ini
程序定型后,以后都不用再重新編譯整個程序,僅手動修改配置文件即可,給不會編程的人用也方便哈
注意,AUTORUN_holiday.ini的前18個日期有效,不限順序,這個已經(jīng)足夠了
1年的法定節(jié)假日基本就這么多,1年基本修改一次就行了,
比如某日有事不打算運(yùn)行,你也可以加進(jìn)去,讓電腦休息哈{ m.kzuj.com.cn }
- 網(wǎng)友回復(fù): 本帖最后由 小平常心 于 2013-7-20 21:39 編輯
小平常心 發(fā)表于 2013-7-20 19:26
可以手動修改配置文件即可,不用再重新編譯整個程序
聲明:
這個是在hyjok的分享的方法上進(jìn)行修改的,原貼地址如下:
用AUTOIT和TB打造國內(nèi)期貨無人值守全自動交易系統(tǒng)
http://bbs.tb18.net/forum.php?mo ... 0%E4%BA%BA%E5%80%BC - 網(wǎng)友回復(fù): 非常實用!頂一個。
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫!(不貴!點擊查看價格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容