顯示具有 cronw 標籤的文章。 顯示所有文章
顯示具有 cronw 標籤的文章。 顯示所有文章

2021年3月11日 星期四

結算日-2021年台期所期貨最後交易日檔

110年台期所期貨最後交易日(結算日)檔


20210120
20210217
20210317
20210421
20210519
20210616
20210721
20210818
20210922
20211020
20211117
20211222
20220119

2016年12月23日 星期五

結算日-2017年台期所期貨最後交易日檔

2017(中華民國106年)台期所期貨最後交易日(結算日)檔

2016-12-24
106年台期所期貨最後交易日檔

資訊來源 -> 臺灣期貨交易所首頁 > 交易制度 > 行事曆

20170118
20170215
20170315
20170419
20170517
20170622
20170719
20170816
20170920
20171018
20171115
20171220
20180117
20180221
20180321
20180418
20180516
20180620
20180718
20180815
20180919
20181017
20181121
20181219
20190116

--

2015年12月2日 星期三

2016年台期所期貨最後交易日(結算日)檔

2016(中華民國105年)台期所期貨最後交易日(結算日)檔

2015-12-03

2016年台期所期貨最後交易日檔

資訊來源 -> 首頁 > 交易制度 > 行事曆

20160120
20160217
20160316
20160420
20160518
20160615
20160720
20160817
20160921
20161019
20161116
20161221

--

2014年12月16日 星期二

2015年台期所期貨最後交易日檔

2015(中華民國104年)台期所期貨最後交易日檔

2014-12-17

2015台期所期貨最後交易日檔(結算日)

資訊來源 - 期貨交易所 - 最新消息 - 公告 - 1205期交所-年曆卡(底黑).pdf

20150121
20150218
20150318
20150415
20150520
20150617
20150715
20150819
20150916
20151021
20151118
20151216

--

2012年1月12日 星期四

2012年台期所期貨最後交易日檔

有用的人補一下吧, 2012(中華民國101年)台期所期貨最後交易日檔

2012-01-13

2012台期所期貨最後交易日檔(結算日)

資訊來源 - 期貨交易所 - 交易制度 - 台灣行事曆


20120118
20120215
20120321


20120418
20120516
20120620
20120718
20120815
20120919
20121017
20121121
20121219
20130119



--

2010年12月20日 星期一

2011年台期所期貨最後交易日檔(結算日)

2010-12-21

每年都要補的內容,最後交易日也就是結算日, 期交所每年定訂,在程式交易中會用到, 是得到當月期貨及換倉重要參考。

2011(中華民國100年)台期所期貨最後交易日檔(結算日)

資訊來源 - 期貨交易所 - 交易制度 - 台灣行事曆



20101117
20101215
20110119
20110216
20110316
20110420
20110518
20110615
20110720
20110817
20110921
20111019
20111116
20111221





-
--
-

2010年6月17日 星期四

2010年台期所期貨最後交易日檔

2010-06-18

2010台期所期貨最後交易日檔


20100120
20100217
20100317
20100421
20100519
20100616
20100721
20100818
20100915
20101020
20101117
20101215


參考 - 台灣期貨交易所 - 行事曆

-
--
-

2010年4月27日 星期二

台指期轉檔程式 - part4(懶人包)

因應 JameX 網友所提的"懶人包",

1. tick.zip
2. tool.zip
3. CRONw_crontab.zip

為配合TS的匯入, 這次改了一分K線的檔案名稱, 及輸出目錄, 並刪除抬頭

安裝說明, 參照 台指期轉檔程式 - part4

---

2010年4月20日 星期二

台指期轉檔程式 - part4

因為我比較懶, 用K線轉檔機還要按按鈕, 所以用 CRONw 排程, 自行到期交所抓當日的成交檔, 分類 tick, 再轉K線...

最近在 win XP sp3 下安裝
  • perl - ActivePerl-5.8.2.808-MSWin32-x86.msi
  • CRONw - CRONw_2.0.zip
  • tool - wget.exe unzip.exe
  • perl 轉檔程式
之前的操作忘了, 這次記錄一下。



1. perl
ActivePerl-5.8.2.808-MSWin32-x86.msi
2. CRONw
CRONw_2.0.zip
a.unzip CRONw_2.0.zip
b. CRONw -> C:\CRONw
3. tool.zip
a.unzip put at c:\tool\
b.file
1. c:\tool\wget.exe
2. c:\tool\unzip.exe
3. c:\tool\unzip32.dll
4. tick.zip (perl script)
a. unzip put at c:\tick
b.file
1. c:\tick\prg_perl3w\gettick3w.bat
2. c:\tick\prg_perl3w\proc3w_tick.bat
3. c:\tick\prg_perl3w\gettick3w.pl
4. c:\tick\prg_perl3w\proc3w_tick.pl
5. c:\tick\prg_perl3w\last-trading-days
6. c:\tick\prg_perl3w\movefile2dir.pl
(其他-手動補之前的K線)
7. c:\tick\ext\make_kline
8. c:\tick\ext\win_crontab.txt
9. c:\tick\ext\user_proc3w_tick.ba
10. c:\tick\ext\tick2kline.pl
c. 排程時間 copy c:\tick\ext\win_crontab.txt to c:\CRONw\crontab.txt
(add crontab rule)
27 15 * * 1-5 c:\perl\bin\perl.exe C:\tick\prg_perl3w\gettick3w.pl
29 15 * * 1-5 c:\perl\bin\perl.exe C:\tick\prg_perl3w\proc3w_tick.pl

5. install CRONW modules -> read \INSTALL.txt
a.
installer.pl

6. install CRONw to WinXP Service
a. 安裝服務 - perl cronHelper.pl --install

b. 起動服務 - net start CRON
c. 檢查 -> Cron Service (CRONw) -
net start

時間定在 15:27 以後, 是確保當時可以抓得到今日的成交檔


相關 -  台指期轉檔程式 - part4(懶人包)
 

2009年7月30日 星期四

cronw - perl 程式的自動排程

配合前兩篇 - 自期交所自行下載交易檔 perl 程式(win-XP)台指期轉檔程式,perl 程式 2 (配合前支gettick3w.pl-自行下載交易檔)

另外有兩部份 crontab 的設定最後交易日檔, crontab 是自動排程, 最後交易日檔是判斷交易檔中的當月成交資料基的依據。

說明:
  • 程式放在 C:\tick\prg_perl3w\ 下。
  • 資料處理在 C:\tick\prg_perl3w\daily\ 下。
  • 最後交易檔會移到 C:\tick\prg_perl3w\daily\yyyymm\ , 成交檔分好的 tick 及 k線檔(附名csv)會移到 C:\tick\prg_perl3w\tick\yyyymm\ 。以今天為例會移到 C:\tick\prg_perl3w\daily\200907\ 及 C:\tick\prg_perl3w\tick\200907\ , 若是日期為 2009-08-04 會移到 C:\tick\prg_perl3w\daily\200908\ 及 C:\tick\prg_perl3w\tick\200908\ 。




crontab 的設定
  1. 每週 1-5 15:38分,執行這支perl程式 C:\tick\prg_perl3w\gettick3w.pl (到期交所抓檔)
  2. 每週 1-5 15:43分,執行分拆 C:\tick\prg_perl3w\proc_tick3w.pl
  3. crontab 內容(C:\CRONw\crontab.txt)
#      
# m h dom mon dow command
# 分 時 日 月 周 指令
38 15 * * 1-5 c:\perl\bin\perl.exe C:\tick\prg_perl3w\gettick3w.pl
43 15 * * 1-5 c:\perl\bin\perl.exe C:\tick\prg_perl3w\proc_tick3w.pl
參考我的 wiki : windows版 Crontab for Win - cronw


2009年台期所期貨最後交易日檔
2009依日期排順序的最後交易, 2010年(含)以後要自行建立。要用我的成程轉以前的資料, 要自行建立這個 "最後交易日檔"。

內容

20090121
20090218
20090318
20090415
20090520
20090617
20090715
20090819
20090916
20091021
20091118
20091216
參考我的 wiki : 2009 Last Trading Days - 2009年台期所期貨最後交易日


台指期轉檔程式 - perl 程式 2 (配合前支gettick3w.pl-自行下載交易檔)

配合前支程式 : 自期交所自行下載交易檔 perl 程式(win-XP) - gettick3w.pl

  1. 配合環境: windows xp sp2
  2. 程式名稱 : proc3w_tick.pl
  3. 程式目的 : 將當天交易檔分拆成台指期,小台,電指期,金指期當月分tick檔
  4. 程式碼



#!C:\Perl\bin\perl.exe

# 2009-06-25 change output file name
# 2009/6/25 Change directory to C:\\tick\\prg_perl3w\\
# 2009/6/18 For Win32 ActivePerl
# 2009-06-17 for move File to Storage Directory
# 2009-06-06 Process Tick and Make K-Line File

use POSIX qw(strftime);
use integer;

$workDir = 'C:\\tick\\prg_perl3w\\daily\\';
$tickDir = 'C:\\tick\\prg_perl3w\\tick\\';
# 可以改成 5 分K
# my $Minute5K = 5; # 5分K
my $Minute1K = 1; # 1分K

# 讀取最後交易日檔
my $LastTradingDays = "C:\\tick\\prg_perl3w\\last-trading-days";


$today = strftime "%Y%m%d", localtime;

$today_YY = substr $today, 0, 4;
$today_mm = substr $today, 4, 2;
$today_dd = substr $today, 6, 2;

$tick_day = $today_YY . "-" . $today_mm . "-" . $today_dd;

$wkMonth = &get_current_month_product($LastTradingDays);

print "Process $today Tick and Make $Minute1K Minute K-Line File..\n";

chdir $workDir;

&split_Tick ($today_YY, $today_mm, $today_dd, $wkMonth);

$tickdayfile = '???' . $today;

$daily_trade_file = 'Daily_' . $today_YY . '_' . $today_mm . '_' . $today_dd;

$saveDir = substr $today, 0, 6;
$tickStoreDir = $tickDir . $saveDir . '/';
$dailyStoreDir = $workDir . $saveDir . '/';

`C:\\tick\\prg_perl3w\\movefile2dir.pl $workDir $dailyStoreDir $daily_trade_file`;
`C:\\tick\\prg_perl3w\\movefile2dir.pl $workDir $tickStoreDir $tickdayfile`;

exit;

sub process_kline {
# in參數 $tickfile $KMinute

my $startHH = '08'; # 開始時
my $startMM = '45'; # 開始分
my $IdxK = -1; # idx
my $PreIdxK = -1; # idx

my $tickfile = $_[0];
my $KMinute = $_[1];

$workday = substr $tickfile, 3, 8;
my $kline_file = substr($tickfile, 0, 11) . '_' . $KMinute . 'k' . substr($tickfile, 11, 4);

open(infile, $tickfile) || die("Cannot open $tickfile.\n");
open(outfile, ">$kline_file");

print outfile "Date Time,Open,High,Low,Close,Vol\n";

# print "K File Processing...\n";

;

while(my $tk_record = )
{
chomp $tk_record;
$tk_record =~ s/ //g;
($tickTime, $tickPrice, $tickVol)=split(/,/ , $tk_record);

$tkTimeHh = substr $tickTime, 0, 2;
$tkTimeMm = substr $tickTime, 3, 2;
$tkTimeSs = substr $tickTime, 6, 2;

$IdxK = int(((($tkTimeHh - $startHH) * 60) + ($tkTimeMm - $startMM)) / $KMinute);
if ($IdxK == $PreIdxK) { # 同根k
if ($tickPrice > $HPrice) {
$HPrice = $tickPrice;
}
if ($tickPrice < $LPrice) {
$LPrice = $tickPrice;
}
$CPrice = $tickPrice;
$KVol = $KVol + $tickVol;
}
else {
if ($PreIdxK != -1){
print outfile $KTime,$OPrice,$HPrice,$LPrice,$CPrice,$KVol\n";
}
$OPrice = $tickPrice;
$HPrice = $tickPrice;
$LPrice = $tickPrice;
$CPrice = $tickPrice;
$KVol = $tickVol ;

my $KTimeHH = ((($IdxK + 1) * $KMinute) + ($startHH * 60) + $startMM) / 60 + 100;
my $KTimeMM = ((($IdxK + 1) * $KMinute) + ($startHH * 60) + $startMM) % 60 + 100;
$KTimeHH = substr $KTimeHH, 1, 2;
$KTimeMM = substr $KTimeMM, 1, 2;

$KTime = $tick_day . ' ' . $KTimeHH . ':' . $KTimeMM;
$PreIdxK = $IdxK;
}
}
if ($IdxK == $PreIdxK) {
# 同根k
print outfile "$KTime,$OPrice,$HPrice,$LPrice,$CPrice,$KVol\n";
}
close(outfile);
close(infile);
}

# get current month product. ex: 200906 (取得當月月分)
sub get_current_month_product{
my $LastTradingDays_file = $_[0];
open(open_LastTradingDays, $LastTradingDays_file)|| die("Cannot open $LastTradingDays_file.\n");
@recs = ;

for($row=@recs-1; $row >= 0; $row=$row-1)
{
my $LastTradingDays = $recs[$row];
if ($LastTradingDays >= $today ) {
$TradingDays = $LastTradingDays;
}
}
my $wkMonth = substr $TradingDays, 0, 6;

close(open_LastTradingDays);
return $wkMonth;
}

sub split_Tick {
chdir $workDir;
# in參數 $today_YY $today_mm $today_dd $wkMonth

$workday_YY = $_[0];
$workday_mm = $_[1];
$workday_dd = $_[2];
$workMonth = $_[3];

$workdayfile = $workday_YY . $workday_mm . $workday_dd;


$trade_file = 'Daily_' . $workday_YY . '_' . $workday_mm . '_' . $workday_dd . '.rpt';

my $TX_Product = 'TX'; # 台指
my $MTX_Product = 'MTX'; # 小台
my $TE_Product = 'TE'; # 電指期
my $TF_Product = 'TF'; # 金指期

# 2009-06-25 change output file name
$tx_tickfile = 'txf' . $workdayfile . '.csv'; # 台指
$mtx_tickfile = 'mxf' . $workdayfile . '.csv'; # 小台
$te_tickfile = 'exf' . $workdayfile . '.csv'; # 電指期
$tf_tickfile = 'fxf' . $workdayfile . '.csv'; # 金指期

open(read_file, $trade_file) || die("Cannot open $trade_file.\n");


open(out_tx, ">$tx_tickfile");
open(out_mtx,">$mtx_tickfile");
open(out_te, ">$te_tickfile");
open(out_tf, ">$tf_tickfile");

print out_tx "Date Time,Price,Vol\n";
print out_mtx "Date Time,Price,Vol\n";
print out_te "Date Time,Price,Vol\n";
print out_tf "Date Time,Price,Vol\n";

# print "Split Tick File Processing...\n";

while(my $record = )
{
chomp $record;
$record =~ s/ //g;
# 交易日期,商品代號,交割年月,成交時間,成交價格,成交數量(B+S),近月價格,遠月價格
($tDays, $tProduct, $tMonth, $tickTime, $tPrice, $tVol, $nPrice, $fPrice)=split(/,/ , $record);
# print "$tDays, $tProduct, $tMonth, $tickTime, $tPrice, $tVol, $nPrice, $fPrice\n";

$tVol = $tVol / 2;

$tTimeHh = substr $tickTime, 0, 2;
$tTimeMm = substr $tickTime, 2, 2;
$tTimeSs = substr $tickTime, 4, 2;

$tTime = $tTimeHh . ':' . $tTimeMm . ':' . $tTimeSs;

# 當月
if ($tMonth eq $workMonth)
{
if ($tProduct eq $TX_Product) { # 台指
print out_tx "$tTime,$tPrice,$tVol\n";
}
elsif ($tProduct eq $MTX_Product) { # 小台
print out_mtx "$tTime,$tPrice,$tVol\n";
}
elsif ($tProduct eq $TE_Product) { # 電指期
print out_te "$tTime,$tPrice,$tVol\n";
}
elsif ($tProduct eq $TF_Product) { # 金指期
print out_tf "$tTime,$tPrice,$tVol\n";
}
}
}

close(out_tf);
close(out_te);
close(out_mtx);
close(out_tx);

close(read_file);

&process_kline($tx_tickfile, $Minute1K);
}

參考我的 wiki : Process split tick - proc3w_tick.pl

2009年7月14日 星期二

自期交所自行下載交易檔 perl 程式(win-XP)

在Windows XP使用 perl script 程式,配合cronw自動排程,自動抓台期交所當天交易檔
  1. 環境: windows xp sp2
  2. 程式名稱 : gettick3w.pl
  3. 程式目的 : 抓台期交所當天交易檔
  4. 程式碼




#!C:\Perl\bin\perl.exe

# 2009/6/25 Change directory to C:\\tick\\prg_perl3w\\
# 2009/6/18 For Win32 ActivePerl
#!/usr/bin/perl # 原程式是在 Debian linux 下
# 2009-05-30 get taiwan future tick

use POSIX qw(strftime);

$workDir = 'C:\\tick\\prg_perl3w\\daily\\';

$today_ziptickfile = strftime "Daily_%Y_%m_%d.zip", localtime;
$today_tickfile = strftime "Daily_%Y_%m_%d.rpt", localtime;

$LogFile = $workDir . "perl_crontab.log";

$tickfile = "http://www.taifex.com.tw/DailyDownload/" .$today_ziptickfile ;

chdir $workDir;

# 用 wget 抓台期交所當天交易檔
my $content = `C:\\tool\\wget.exe -c -a $LogFile -P $workDir $tickfile`;

if (-e $today_ziptickfile) {
# 解 zip 檔
# `unzip $today_ziptickfile`;
`c:\\tool\\unzip $today_ziptickfile`;
}
else {
die("File not exist : $today_ziptickfile.\n");
}

參考我的 wiki : Get Taiwan future tick - gettick3w.pl

2009年6月19日 星期五

Win XP 下安裝自動排程 CRONw 2.0

Win XP 下 安裝 自動排程 CRONw 2.0。

這個 CRONw 是用 perl 寫的自動排程工具, 先要裝 perl, 為了安裝方便, 請參考 CRONw 的安裝 這篇來安裝 ActivePerl 及 CRONw 2.0 。

這樣就可以使用 CRONw 這個自動排程工具, 下篇再寫自動排程 CRONw 的使用設定。

我的 Wiki -- 2009-06-20 cronw 安裝 (包括ActivePerl)



聯絡表單

名稱

以電子郵件傳送 *

訊息 *