2010年6月25日 星期五

AutoHotKey補一個月的轉檔主程式

這支程式是用AutoHotKey寫的,用來補前幾天(前30天)沒有做轉檔, 要配合
台指期轉檔程式 - part4(懶人包), 自動取得交易檔, 轉Tick及1分K線。

程式中用到他人的 SimpleArray.ahk 要放在同個資料夾(目錄)下。下載SimpleArray.zip, 下載後要解zip檔。

getTick.ahk程式碼


;
; AutoHotkey Version: 1.0.0
; Platform: Win XP
; Author: R.J
; Date : 2010/6/11
; Script Function:
; Get Tick
;
#Include SimpleArray.ahk

; 1 2 3 4 5 6 7 8 9 10 11 12
Month = 31|28|31|30|31|30|31|31|30|31|30|31

PerlExe = c:\perl\bin\perl.exe
plGetTick = c:\tick\prg_perl3w\gettick3w.pl
plProc3wTick = c:\tick\prg_perl3w\proc3w_tick.pl

ToDay = %A_YYYY%-%A_MM%-%A_DD%

if (%A_MM% == 1 ){
sStartMonth := 12 ; 前月
} else {
sStartMonth := A_MM + 99
sStartMonth := SubStr(sStartMonth, 2, 2) ; 前月
}

sStartDay = %A_YYYY%-%sStartMonth%-%A_DD%
sStopDay = %A_YYYY%-%A_MM%-%A_DD%


Gui, Font, S12,
Gui, Add, Text, x10 y25 w70 h20 , Start Date :
Gui, Add, Text, x10 y85 w70 h20 , Stop Date :
Gui, Add, Edit, x90 y23 w90 h20 r1 vStartEdit, %sStartDay%
Gui, Add, Edit, x90 y83 w90 h20 r1 vStopEdit, %sStopDay%
Gui, Add, Button, x220 y18 w46 h29 , Start
Gui, Show, x300 y150 h250 w320, Get Future Daily-Trade from TAIFEX
Return

GuiClose:
ExitApp


ButtonStart:
Gui, Submit
stopDate := StopEdit

stYYYY := SubStr(StartEdit, 1, 4)
stMM := SubStr(StartEdit, 6, 2)
stDD := SubStr(StartEdit, 9, 2)

WorkDate = %stYYYY%-%stMM%-%stDD%

; While (stopDate >= WorkDate) {
While (WorkDate <= stopDate) {
if (stDD > SA_Get(Month, stMM)) {
; 換月
stDD -= SA_Get(Month, stMM)
if (stDD < 10) {
stDD += 100
stDD := SubStr(stDD, 2, 2)
}
stMM += 1
if (stMM > 12) {
stMM := 01
stYYYY += 1
} else if (stMM < 10) {
stMM += 100
stMM := SubStr(stMM, 2, 2)
}
}
WorkDate = %stYYYY%-%stMM%-%stDD%

RunWait, %comspec% /c date %WorkDate%, , min
sleep, 1000

if (A_WDay >= 2 and A_WDay <= 6) {
RunWait, %PerlExe% %plGetTick%
RunWait, %PerlExe% %plProc3wTick%
}

stDD += 1
if (stDD < 10) {
stDD += 100
stDD := SubStr(stDD, 2, 2)
}
WorkDate = %stYYYY%-%stMM%-%stDD%
}

RunWait, %comspec% /c date %ToDay%, , min ;; Reset Today DateTime
Return


-

1 則留言:

聯絡表單

名稱

以電子郵件傳送 *

訊息 *