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

2 則留言:

  1. 您好~可以提供下載嗎?或是可以email給我嗎?
    想要大盤跟台指期的1min,5min資料檔.2008~2009年的.thanks (email: a0_2_0@yahoo.com.tw)

    回覆刪除
  2. 0428my你好:

    大盤資料沒有。
    2008年有成交資料(已分類好的台指期tick), 2009年01月~04月, 我是自己從yeswin看盤軟體下載當天的tick, 2009年05月以後到 http://rj.twbbs.org/~redjoe/future/daily/ 抓(1min)。

    再用我提供的程式自行轉成 1min, 及 5min 的k線。

    以上兩部份tick會找地方來放, 請自行下載。

    註:這兩天會將轉k線程式放上來, 自行複製。

    回覆刪除

聯絡表單

名稱

以電子郵件傳送 *

訊息 *