Target:
其實理由很簡單,為了簡化我的交易系統,讓整體的 flow 更完整點,不然東一塊西一塊的看起來真醜....像之前的所寫過的
learning plus: SDDE Server-V1 ,
learning plus: DDE server for Stock ..怎現在都不知道在做啥....XD, 不過人說最初的心血是不會白費的,好在之前有些紀錄.不然還真是砍掉重練.
Trader API
我們主要分成 3 大部份來講解
在 part 1 DDE, 主要透過 Web/DDE server 來抓取我們要的 info.
1. DDE part support
1-1 OFF_TIME data
1-1-1. history data @(Yahoo,Google)
1-1-2. super sell/buy [1,5,10,30] @ Web(yuanta)
1-1-3. trader info [1,5,10,30] @ Web (yuanta)
1-1-4. finance_bill [1] @ Web (yuanta)
1-2 ON_TIME data
1-2-1 Real DDE server @ Fubon e01
ex: data.pl
my $google = NET::GoogleDailyData->new();
$google->get_history_data('2330.TW','2010/01/01','2010/10/10');
$google->exp_history_data('2330.TW',"./DATA/2330.TW.csv");
my $yahoo = NET::YahooDailyData->new();
$yahoo->get_history_data('2330.TW','2010/01/01','2010/10/15');
$yahoo->exp_history_data('2330.TW',"2330.TW.csv");
my $trader = NET::TraderDetail->new();
$trader->get_trader_data();
$trader->exp_trader_data("2010_10_20_trader_detail.csv");
#===========================================
#
# get super buy/sell[1,5,10,30] info from web
# get trader [1,5,30] info from web
#
#============================================
my $global = SYS::GLB->new();
my $market_super_hstable = $global->get_market_super_hstable;
# printf Dumper($market_super_hstable);
my $market = NET::Market->new($market_super_hstable);
$market->get_market_super_buyer_seller_data();
$market->exp_market_data();
my $market_trader_hstable = $global->get_market_trader_hstable;
#printf Dumper($market_trader_hstable);
my $td4bysel = NET::Trader4BuySellDetail->new($market_trader_hstable);
$td4bysel->get_market_trader_data();
$td4bysel->exp_market_trader_data();
在 part 2 FINANCE 為資料分析 跟 簡單的判斷
2. FINANCE part support
2-1 Indicator
2-1-1 KD
2-1-2 BIAS
2-1-3 DMI
2-1-3 MACD
2-1-4 MA
2-1-5 OBV
2-1-6 PSY
2-1-7 RSI
2-1-8 SAR
2-1-9 VR
2-1-10 WR
2-2 Trader info
2-2-1 get trader info list by day
2-2-2 get statistic info by constrain
2-3 super buy/sell info
2-3-1 get super buy/sell by day
2-3-2 get statistic info by constrain
ex:
my $ikd = FINANCE::KD->new($hslist);
my $kd = $ikd->get_KD('30','2010/08/12');
printf Dumper($kd);
my $ibias = FINANCE::BIAS->new($hslist);
my $bias = $ibias->get_BIAS('30','2010/08/12');
printf Dumper($bias);
my $idmi = FINANCE::DMI->new($hslist);
my $dmi = $idmi->get_DMI('30','2010/08/12');
printf Dumper($dmi);
my $trader = TRADER::UTIL->new();
$trader->set_market_super_hstable($market_super_hstable);
$trader->set_market_trader_hstable($market_trader_hstable);
my $rst = $trader->get_bk_external_super_buy_hstable('1','2010/10/26');
$rst = $trader->get_bk_main_super_sell_hstable('1','2010/10/26');
printf Dumper($rst);
$rst = $trader->get_bk_external_trader_buy_hstable('1','2010/10/26','1440');
$rst = $trader->get_bk_internal_trader_sell_hstable('1','2010/10/26','9800');
在 part 3 PROFIT 為回測分析我們進場點的 report
my %data = (
"START_TIME" => '2010/09/01', #開始時間
"END_TIME" => '2010/10/18', #結束時間
"CAPITAL" => '500000', #成本
"LEAVE_PROFIT_LOST" => '15.0', #出場停損 10%
"LEAVE_PROFIT_MAKE" => '10.0', #出場獲利 7%
"KEEP_PROFIT_LOST" => '5.0', #持有時確保 損失 達 -5%,如超過則回補
"KEEP_PROFIT_MAKE" => '3.0', #持有時確保 獲利 達 3%,如操過則加碼
"KEEP_PROFIT_LOST_T"=> '1', #最多回補次數 3 次
"KEEP_PROFIT_MAKE_T"=> '0', #最多加碼次數 3 次
"KEEP_PROFIT_LENGTH"=> '1', #每5 天 check 損失/獲利
"PRICE_UP_LIMIT" => '40', #股價 <> '10', #股價 > 10 的才會進場 check
);
my $prt = PROFIT::profit->new(\%data);
$prt->get_input_set();
$prt->set_history_path("./daily/");
$prt->set_profit_info("Sharkv2_2010_09_10_c3.csv");
$prt->get_profit_run();
$prt->get_profit_report("rep.csv");
~
有興趣的人可以到
http://github.com/funningboy 參考看看,當然也歡迎一起開發..@@
請問一下為何
回覆刪除"LEAVE_PROFIT_LOST" => '15.0', 停損10%? 而非15%
"LEAVE_PROFIT_MAKE" => '10.0', 獲利7%? 而非10%
"KEEP_PROFIT_LOST_T"=> '1', 1表示次數?
"KEEP_PROFIT_MAKE_T"=> '0', 0表示次數? 最高只能到3次?
"KEEP_PROFIT_LENGTH"=> '1', 只要設定為1就會每5天檢查?
"PRICE_UP_LIMIT" => '40' 這裡的40表示要高於10元才進場? 如果要設定其他價位要如何更改值?
不好意思問了這麼多問題
"LEAVE_PROFIT_LOST" => '15.0', 停損10%? 而非15%
回覆刪除指的是系統 default 設為 10%, 而使用者現在設成 15% ,請依此類推...謝謝