unageanu-jiji 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -0
- data/base/agents/moving_average_agent.rb +78 -0
- data/base/shared_lib/moving_average.rb +34 -0
- data/bin/jiji +5 -0
- data/html/css/default.css +7 -0
- data/html/img/button_calendar_over.gif +0 -0
- data/html/img/button_cancel.gif +0 -0
- data/html/img/button_no.gif +0 -0
- data/html/img/button_no_gray.gif +0 -0
- data/html/img/button_no_over.gif +0 -0
- data/html/img/button_save.gif +0 -0
- data/html/img/button_save_gray.gif +0 -0
- data/html/img/button_save_over.gif +0 -0
- data/html/img/button_update_s.gif +0 -0
- data/html/img/button_update_s_gray.gif +0 -0
- data/html/img/button_update_s_over.gif +0 -0
- data/html/img/button_yes.gif +0 -0
- data/html/img/button_yes_gray.gif +0 -0
- data/html/img/button_yes_over.gif +0 -0
- data/html/index.html +29 -33
- data/html/js/agent-editor-page.js +178 -88
- data/html/js/agent-selector.js +68 -39
- data/html/js/bt-create-page.js +24 -11
- data/html/js/dialog.js +43 -34
- data/html/js/result-page.js +37 -25
- data/html/js/rt-setting-page.js +13 -6
- data/html/js/sidebar.js +8 -5
- data/html/js/templates.js +37 -3
- data/html/js/utils.js +47 -9
- data/html/swf/chart.swf +0 -0
- data/lib/jiji/agent/agent_manager.rb +2 -2
- data/lib/jiji/agent/agent_registry.rb +4 -1
- data/lib/jiji/command.rb +6 -0
- data/lib/jiji/process.rb +32 -10
- data/lib/jiji/process_manager.rb +7 -0
- data/lib/jiji/registry.rb +6 -4
- data/lib/jiji/server.rb +6 -1
- data/lib/jiji/service/output_service.rb +10 -6
- data/swf/chart/fx/chart/Chart.as +4 -1
- data/swf/chart/fx/chart/ui/Constants.as +3 -3
- data/swf/chart/fx/chart/ui/InformationWindow.as +45 -41
- data/swf/chart/fx/chart/ui/Pointer.as +6 -4
- data/swf/chart/fx/chart/ui/Scroll.as +3 -2
- data/swf/chart/fx/chart/ui/Stage.as +3 -3
- data/swf/chart/fx/chart/ui/TradeDetailWindow.as +9 -8
- data/swf/chart/fx/chart/ui/TradeResult.as +3 -17
- data/swf/chart/fx/chart/ui/graph/Graph.as +4 -2
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +3 -1
- data/swf/chart/fx/chart/ui/resource/fixed.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/unfixed.gif +0 -0
- data/swf/chart/fx/net/StubFactory.as +3 -3
- data/test/all_tests.rb +1 -1
- data/test/test_AgentManager.rb +4 -4
- data/test/{test_AgentRegistory.rb → test_AgentRegistry.rb} +0 -0
- data/test/test_Collector.rb +1 -1
- data/test/test_Output_registry.rb +7 -3
- data/test/test_Process.rb +5 -5
- data/test/test_ProcessManager.rb +120 -68
- metadata +20 -14
- data/bin/jiji.rb +0 -6
- data/html/js/W3CDTF.js +0 -131
data/README
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
see http://unageanu.sakura.ne.jp/jiji
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#
|
2
|
+
# 移動平均を使うエージェント。
|
3
|
+
# -ゴールデンクロスで買い。
|
4
|
+
# -デッドクロスで売り。
|
5
|
+
#
|
6
|
+
class MovingAverageAgent < JIJI::PeriodicallyAgent
|
7
|
+
|
8
|
+
# エージェントの説明
|
9
|
+
def description
|
10
|
+
<<-STR
|
11
|
+
移動平均を使うエージェントです。
|
12
|
+
-ゴールデンクロスで買い&売り建て玉をコミット。
|
13
|
+
-デッドクロスで売り&買い建て玉をコミット。
|
14
|
+
STR
|
15
|
+
end
|
16
|
+
|
17
|
+
# エージェントを初期化する。
|
18
|
+
def init
|
19
|
+
# 移動平均の算出クラス
|
20
|
+
# 共有ライブラリのクラスを利用。(JIJI::Agent::Sharedモジュールに定義される。)
|
21
|
+
@mvs = [
|
22
|
+
JIJI::Agent::Shared::MovingAverage.new(@short),
|
23
|
+
JIJI::Agent::Shared::MovingAverage.new(@long)
|
24
|
+
]
|
25
|
+
@prev_state = nil
|
26
|
+
|
27
|
+
# 移動平均をグラフで表示するためのOutput
|
28
|
+
@out = output.get( "移動平均線", :graph, {
|
29
|
+
:column_count=>2, # データ数は2
|
30
|
+
:graph_type=>:rate, # レートにあわせる形式で表示
|
31
|
+
:colors=>["#779999","#557777"] # デフォルトのグラフの色
|
32
|
+
} )
|
33
|
+
end
|
34
|
+
|
35
|
+
# 次のレートを受け取る
|
36
|
+
def next_period_rates( rates )
|
37
|
+
|
38
|
+
# 移動平均を計算
|
39
|
+
res = @mvs.map{|mv| mv.next_rate( rates[:EURJPY].bid ) }
|
40
|
+
|
41
|
+
return if ( !res[0] || !res[1])
|
42
|
+
|
43
|
+
# グラフに出力
|
44
|
+
@out.put( *res )
|
45
|
+
|
46
|
+
# ゴールデンクロス/デッドクロスを判定
|
47
|
+
state = res[0] > res[1] ? :high : :low
|
48
|
+
if ( @prev_state && @prev_state != state )
|
49
|
+
if state == :high
|
50
|
+
# ゴールデンクロス
|
51
|
+
# 売り建玉があれば全て決済
|
52
|
+
operator.positions.each_pair {|k,p|
|
53
|
+
operator.commit(p) if p.sell_or_buy == JIJI::Position::SELL
|
54
|
+
}
|
55
|
+
# 新規に買い
|
56
|
+
operator.buy 1
|
57
|
+
else
|
58
|
+
# デッドクロス
|
59
|
+
# 買い建玉があれば全て決済
|
60
|
+
operator.positions.each_pair {|k,p|
|
61
|
+
operator.commit(p) if p.sell_or_buy == JIJI::Position::BUY
|
62
|
+
}
|
63
|
+
# 新規に売り
|
64
|
+
operator.sell 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@prev_state = state
|
68
|
+
end
|
69
|
+
|
70
|
+
# UIから設定可能なプロパティの一覧を返す。
|
71
|
+
def property_infos
|
72
|
+
super().concat [
|
73
|
+
Property.new( "short", "短期移動平均線", 25, :number ),
|
74
|
+
Property.new( "long", "長期移動平均線", 75, :number )
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# 一定期間の移動平均を得る
|
2
|
+
class MovingAverage
|
3
|
+
def initialize( range=25 )
|
4
|
+
@rates = [] # レートを記録するバッファ
|
5
|
+
@range = range
|
6
|
+
end
|
7
|
+
|
8
|
+
def next_rate( rate )
|
9
|
+
# バッファのデータを更新
|
10
|
+
@rates.push rate
|
11
|
+
@rates.shift if @rates.length > @range
|
12
|
+
|
13
|
+
# バッファサイズが十分でなければ、nilを返す。
|
14
|
+
return nil if @rates.length != @range
|
15
|
+
|
16
|
+
# 移動平均を算出
|
17
|
+
return MovingAverage.get_moving_average(@rates)
|
18
|
+
end
|
19
|
+
|
20
|
+
# 前の結果(引数で指定した件数だけ記録。)
|
21
|
+
attr :prev, true
|
22
|
+
|
23
|
+
private
|
24
|
+
# 移動平均値を計算する。
|
25
|
+
def self.get_moving_average( rates )
|
26
|
+
total = 0
|
27
|
+
rates.each {|s|
|
28
|
+
total += s.end
|
29
|
+
total += s.max
|
30
|
+
total += s.min
|
31
|
+
}
|
32
|
+
return total / ( rates.length * 3 )
|
33
|
+
end
|
34
|
+
end
|
data/bin/jiji
ADDED
data/html/css/default.css
CHANGED
@@ -262,6 +262,7 @@ div.button {
|
|
262
262
|
float: left;
|
263
263
|
margin-right: 10px;
|
264
264
|
}
|
265
|
+
div.button * { font-size: 0px; }
|
265
266
|
|
266
267
|
/* white line -------------------------------------------------------------- */
|
267
268
|
div.wl {
|
@@ -280,6 +281,12 @@ div.wl {
|
|
280
281
|
background-position: 0px 3px;
|
281
282
|
margin-bottom: 5px;
|
282
283
|
}
|
284
|
+
#agent_edit_msg {
|
285
|
+
margin: 10px 0px 0px 0px;
|
286
|
+
padding: 10px;
|
287
|
+
border: 1px dotted #999999;
|
288
|
+
width:480px;
|
289
|
+
}
|
283
290
|
|
284
291
|
div.agent-property-editor {
|
285
292
|
padding: 10px 10px 10px 20px;
|
Binary file
|
data/html/img/button_cancel.gif
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/html/index.html
CHANGED
@@ -61,20 +61,20 @@
|
|
61
61
|
<div id="hesder">
|
62
62
|
<!-- ロゴとメッセージ表示領域 -->
|
63
63
|
<div style="float:right;margin:10px 20px 0px 0px;">
|
64
|
-
<img id="head_trade_enable" src="./img/auto_trade_off.gif"
|
64
|
+
<img id="head_trade_enable" src="./img/auto_trade_off.gif" alt="自動取引" title="自動取引" />
|
65
65
|
</div>
|
66
66
|
</div>
|
67
67
|
<div id="body">
|
68
68
|
<div id="left">
|
69
69
|
<!-- メニュー -->
|
70
70
|
<div class="menu-container">
|
71
|
-
<div class="menu-1"><img src="./img/sidebar_rt.png"
|
71
|
+
<div class="menu-1"><img src="./img/sidebar_rt.png" alt="リアルトレード" title="リアルトレード" /></div>
|
72
72
|
<div class="menu-2 menu" id="sidebar_result_rmt" alt="状態を見る" style="width:178px"></div>
|
73
73
|
<div class="menu-2 menu" id="sidebar_rt_setting" alt="設定" style="width:178px"></div>
|
74
74
|
</div>
|
75
75
|
|
76
76
|
<div class="menu-container">
|
77
|
-
<div class="menu-1"><img src="./img/sidebar_agent.png"
|
77
|
+
<div class="menu-1"><img src="./img/sidebar_agent.png" alt="エージェント" title="エージェント" /></div>
|
78
78
|
<div class="menu-2 menu" id="sidebar_agent_edit_agent" alt="エージェントの編集" style="width:178px">
|
79
79
|
</div>
|
80
80
|
<div class="menu-2 menu" id="sidebar_agent_edit_shared_lib" alt="共有ライブラリの編集" style="width:178px">
|
@@ -82,11 +82,11 @@
|
|
82
82
|
</div>
|
83
83
|
|
84
84
|
<div class="menu-container">
|
85
|
-
<div class="menu-1"><img src="./img/sidebar_bt.png"
|
85
|
+
<div class="menu-1"><img src="./img/sidebar_bt.png" alt="バックテスト" title="バックテスト" /></div>
|
86
86
|
<div class="menu-2 menu" id="sidebar_bt_create" alt="新規作成" style="width:178px">
|
87
87
|
</div>
|
88
88
|
<div class="menu-2">
|
89
|
-
<img src="./img/sidebar_bt_result.png"
|
89
|
+
<img src="./img/sidebar_bt_result.png" alt="テスト結果をみる" title="テスト結果をみる" style="width:178px"/>
|
90
90
|
<div id="back-tests" style="margin-top:5px;">
|
91
91
|
</div>
|
92
92
|
</div>
|
@@ -162,7 +162,7 @@
|
|
162
162
|
<div class="breaker"></div>
|
163
163
|
</div>
|
164
164
|
<div class="separator" style="width:620px;"></div>
|
165
|
-
<div><img src="./img/h3_result_0.gif"
|
165
|
+
<div><img src="./img/h3_result_0.gif" alt="統計" title="統計" /></div>
|
166
166
|
<div class="wl" style="width:620px;"></div>
|
167
167
|
<div id="subpage-trade_summary" >
|
168
168
|
</div>
|
@@ -170,7 +170,7 @@
|
|
170
170
|
</div>
|
171
171
|
<div style="margin-left:10px;">
|
172
172
|
<div style="width:620px;">
|
173
|
-
<div style="margin-top:20px;"><img src="./img/h3_result_1.gif"
|
173
|
+
<div style="margin-top:20px;"><img src="./img/h3_result_1.gif" alt="エージェントごとの統計" title="エージェントごとの統計" /></div>
|
174
174
|
<div class="wl" style="width:620px;"></div>
|
175
175
|
</div>
|
176
176
|
</div>
|
@@ -183,7 +183,7 @@
|
|
183
183
|
</div>
|
184
184
|
<div style="margin-left:10px;">
|
185
185
|
<div style="width:620px;">
|
186
|
-
<div style="margin-top:20px;"><img src="./img/h3_result_2.gif"
|
186
|
+
<div style="margin-top:20px;"><img src="./img/h3_result_2.gif" alt="取引一覧" title="取引一覧" /></div>
|
187
187
|
<div class="wl" style="width:620px;"></div>
|
188
188
|
</div>
|
189
189
|
</div>
|
@@ -198,13 +198,13 @@
|
|
198
198
|
<div class="page" id="subpage-info">
|
199
199
|
<div style="margin-left:10px;" >
|
200
200
|
<div id="subpage-info_info">
|
201
|
-
<div><img src="./img/h3_result_3.gif"
|
201
|
+
<div><img src="./img/h3_result_3.gif" alt="設定" title="設定" /></div>
|
202
202
|
<div class="wl" style="width:620px;"></div>
|
203
203
|
<div id="subpage-info_info-values" style="margin: 10px 0px 15px 0px;">
|
204
204
|
</div>
|
205
205
|
</div>
|
206
206
|
|
207
|
-
<div><img src="./img/h3_result_4.gif"
|
207
|
+
<div><img src="./img/h3_result_4.gif" alt="エージェント" title="エージェント" /></div>
|
208
208
|
<div class="wl" style="width:620px;"></div>
|
209
209
|
</div>
|
210
210
|
<div id="subpage-info_as">
|
@@ -230,7 +230,7 @@
|
|
230
230
|
<div class="page" id="subpage-log" style="margin-left:10px;" >
|
231
231
|
<div style="width:620px;">
|
232
232
|
<div style="float: left;">
|
233
|
-
<div><img src="./img/h3_result_5.gif"
|
233
|
+
<div><img src="./img/h3_result_5.gif" alt="ログ" title="ログ" /></div>
|
234
234
|
<div class="wl" style="width:450px;"></div>
|
235
235
|
</div>
|
236
236
|
<div style="float: right;">
|
@@ -243,7 +243,7 @@
|
|
243
243
|
</div>
|
244
244
|
<div class="page" id="subpage-graph" style="margin-left:10px;" >
|
245
245
|
<div style="width:620px;">
|
246
|
-
<div><img src="./img/h3_result_6.gif"
|
246
|
+
<div><img src="./img/h3_result_6.gif" alt="グラフの表示設定" title="グラフの表示設定" /></div>
|
247
247
|
<div class="wl" style="width:620px;"></div>
|
248
248
|
<div class="desc" style="margin-top:10px;" >
|
249
249
|
※ローソク足チャートで表示するグラフを設定します。
|
@@ -268,7 +268,7 @@
|
|
268
268
|
<div class="separator" style="width:780px;margin-left:10px;"></div>
|
269
269
|
|
270
270
|
<div style="margin-left:10px;">
|
271
|
-
<div style="margin-top:20px;" ><img src="./img/h3_rt-setting_0.gif"
|
271
|
+
<div style="margin-top:20px;" ><img src="./img/h3_rt-setting_0.gif" alt="自動取引の設定" title="自動取引の設定" /></div>
|
272
272
|
<div class="wl" style="margin-right:10px;width:780px;"></div>
|
273
273
|
<div style="margin: 10px 0px 0px 20px;">
|
274
274
|
<form id="rt-setting_form" name="rt-setting_form" action="javascript:void(0);" >
|
@@ -286,7 +286,7 @@
|
|
286
286
|
</div>
|
287
287
|
|
288
288
|
<div style="margin-left:10px;margin-bottom:10px;">
|
289
|
-
<div style="margin-top:30px;" ><img src="./img/h3_rt-setting_1.gif"
|
289
|
+
<div style="margin-top:30px;" ><img src="./img/h3_rt-setting_1.gif" alt="エージェント" title="エージェント" /></div>
|
290
290
|
<div class="wl" style="margin-right:10px;width:780px;"></div>
|
291
291
|
<div class="desc" style="margin-top:10px;" >※自動取引で動作させるエージェントを選択します。</div>
|
292
292
|
</div>
|
@@ -319,6 +319,8 @@
|
|
319
319
|
|
320
320
|
<!-- エージェント - 新規作成/編集 -->
|
321
321
|
<div class="page" id="page-agent-edit" style="margin-left:10px;margin-top:10px;">
|
322
|
+
<div id="agent_edit_desc" class="desc" style="margin:10px;clear:both;" >
|
323
|
+
</div>
|
322
324
|
<div style="float:left;">
|
323
325
|
<div style="margin-left:9px;">
|
324
326
|
<div id="agent-edit_add" class="button"></div>
|
@@ -338,8 +340,16 @@
|
|
338
340
|
|
339
341
|
<div style="float:right;">
|
340
342
|
<div style="margin-left:10px;">
|
341
|
-
<div
|
342
|
-
|
343
|
+
<div>
|
344
|
+
<div style="float: left;width:370px;">
|
345
|
+
<div id="agent-editor-file-name">-</div>
|
346
|
+
<div class="wl" style="margin-right:10px;width:370px;"></div>
|
347
|
+
</div>
|
348
|
+
<div id="agent-edit_save" class="button" style="margin-left:10px;" ></div>
|
349
|
+
<div class="breaker"></div>
|
350
|
+
</div>
|
351
|
+
<div id="agent_edit_msg" class="agent_edit_msg" >
|
352
|
+
</div>
|
343
353
|
</div>
|
344
354
|
<div class="panel_500">
|
345
355
|
<div class="panel_top"></div>
|
@@ -366,7 +376,7 @@
|
|
366
376
|
<div class="separator" style="width:780px;margin-left:10px;"></div>
|
367
377
|
|
368
378
|
<div style="margin-left:10px;">
|
369
|
-
<div style="margin-top:20px;" ><img src="./img/h3_bt-create_0.gif"
|
379
|
+
<div style="margin-top:20px;" ><img src="./img/h3_bt-create_0.gif" alt="テストの名前とメモ" title="テストの名前とメモ" /></div>
|
370
380
|
<div class="wl" style="margin-right:10px;width:780px;"></div>
|
371
381
|
<div class="desc" style="margin-top:10px;" >※バックテストの名前を設定します。メモとして任意のテキストを残すこともできます。</div>
|
372
382
|
<div style="margin: 10px 0px 0px 0px;">
|
@@ -391,7 +401,7 @@
|
|
391
401
|
</div>
|
392
402
|
|
393
403
|
<div style="margin-left:10px;">
|
394
|
-
<div style="margin-top:20px;" ><img src="./img/h3_bt-create_1.gif"
|
404
|
+
<div style="margin-top:20px;" ><img src="./img/h3_bt-create_1.gif" alt="期間" title="期間" /></div>
|
395
405
|
<div class="wl" style="margin-right:10px;width:780px;"></div>
|
396
406
|
<div class="desc" style="margin:10px 0px 0px 0px;" >
|
397
407
|
※テストする期間を設定します。日付を直接入力するか、カレンダーから選択して下さい。<br/>
|
@@ -419,7 +429,7 @@
|
|
419
429
|
</div>
|
420
430
|
|
421
431
|
<div style="margin-left:10px;margin-bottom:10px;">
|
422
|
-
<div style="margin-top:30px;" ><img src="./img/h3_bt-create_2.gif"
|
432
|
+
<div style="margin-top:30px;" ><img src="./img/h3_bt-create_2.gif" alt="エージェント" title="エージェント" /></div>
|
423
433
|
<div class="wl" style="margin-right:10px;width:780px;"></div>
|
424
434
|
<div class="desc" style="margin-top:10px;" >※バックテストで動作させるエージェントを選択します。</div>
|
425
435
|
</div>
|
@@ -450,20 +460,6 @@
|
|
450
460
|
</div>
|
451
461
|
</div>
|
452
462
|
|
453
|
-
<!-- バックテスト - 結果を見る -->
|
454
|
-
<div class="page" id="page-bt-result">
|
455
|
-
<!--
|
456
|
-
- チャート
|
457
|
-
- タブ
|
458
|
-
- 取引結果一覧
|
459
|
-
- エージェント
|
460
|
-
- エラーログ
|
461
|
-
-
|
462
|
-
- 「再実行する」
|
463
|
-
-->
|
464
|
-
</div>
|
465
|
-
|
466
|
-
|
467
463
|
</div>
|
468
464
|
<div class="breaker"></div>
|
469
465
|
</div>
|