每年都要補的內容,最後交易日也就是結算日, 期交所每年定訂,在程式交易中會用到, 是得到當月期貨及換倉重要參考。
2011(中華民國100年)台期所期貨最後交易日檔(結算日)
資訊來源 - 期貨交易所 - 交易制度 - 台灣行事曆
20101117
20101215
20110119
20110216
20110316
20110420
20110518
20110615
20110720
20110817
20110921
20111019
20111116
20111221
-
--
-
;
; 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
20100120
20100217
20100317
20100421
20100519
20100616
20100721
20100818
20100915
20101020
20101117
20101215
#!C:\Perl\bin\perl.exe
# 取出今天的K線, 去除最後一筆
# 輸入一分K線檔 - C:\tmp\1.csv
# 輸出一分K線檔 - C:\tickhist\txf.csv
use POSIX qw(strftime);
use integer;
$src_k1m = 'C:\\tmp\\1.csv'; # 1mk source file
$tmpfile = 'C:\\tickhist\\tmp001.csv'; # tmp file
$tar_k1m = 'C:\\tickhist\\txf.csv'; # 1mk target file
$today = strftime "%Y/%m/%d", localtime;
print "Process $today Today 1 Minute K To : $tar_k1m.\n";
open(infile, $src_k1m) || die("Cannot open $src_k1m.\n");
open(tempfile, ">$tmpfile");
$rec_no=0;
;
while(my $k1m_record = )
{
chomp $k1m_record;
# $k1m_record =~ s/ //g;
# ($kDate, $kTime, $kOpen, $kHigh, $kLow, $kClose, $kVol)=split(/, / , $k1m_record);
($kDateTime, $kOpen, $kHigh, $kLow, $kClose, $kVol)=split(/,/ , $k1m_record);
($kDate, $kTime)=split(/ / , $kDateTime);
if ($kDate eq $today ){
print tempfile "$kDate,$kTime,$kOpen,$kHigh,$kLow,$kClose,$kVol\n";
$rec_no = $rec_no + 1;
}
}
close(tempfile);
close(infile);
open(tmp_file, $tmpfile) || die("Cannot open $tmpfile.\n");
open(outfile, ">$tar_k1m");
print outfile "Date,Time,Open,High,Low,Close,Vol\n";
for ( $i=1; $i<$rec_no; $i++ ) {
my $tmp_record = ;
print outfile $tmp_record;
# print "$i\n";
}
close(tmp_file);
close(outfile);
# 刪除暫存檔
unlink $tmpfile;
installer.pl
perl cronHelper.pl --install
net start CRON
net start