clickclient_scrap 0.1.9 → 0.1.10
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/ChangeLog +5 -0
- data/lib/clickclient_scrap.rb +726 -688
- data/lib/jiji_plugin.rb +17 -8
- data/sample/constants.rb +5 -0
- data/sample/sample_get_margin.rb +24 -0
- data/sample/sample_list_open_interests.rb +25 -0
- data/sample/sample_list_orders.rb +28 -0
- data/sample/sample_list_rates.rb +16 -0
- data/sample/sample_market_order.rb +21 -0
- data/sample/sample_oco_order.rb +36 -0
- data/sample/sample_order.rb +64 -0
- data/sample/sample_settle.rb +18 -0
- data/specs/cancel_order_spec.rb +43 -0
- data/specs/common.rb +30 -0
- data/specs/jiji_plugin_spec!.rb +127 -0
- data/specs/limit_order_spec.rb +98 -0
- data/specs/list_orders_spec.rb +28 -0
- data/specs/market_order_spec!.rb +131 -0
- data/specs/oco_order_spec.rb +60 -0
- data/specs/order_error_spec.rb +139 -0
- metadata +27 -6
- data/test/test_FxSession.rb +0 -38
- data/test/test_jiji_plugin.rb +0 -77
@@ -0,0 +1,98 @@
|
|
1
|
+
$: << "../lib"
|
2
|
+
|
3
|
+
require 'clickclient_scrap'
|
4
|
+
require 'common'
|
5
|
+
|
6
|
+
describe "limit" do
|
7
|
+
include TestBase
|
8
|
+
|
9
|
+
it "指値/逆指値での注文テスト" do
|
10
|
+
do_test {|s|
|
11
|
+
#指値-買い
|
12
|
+
@order_ids[0] = @s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::BUY, 1, {
|
13
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
14
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
15
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
16
|
+
})
|
17
|
+
@order = @s.list_orders[@order_ids[0].order_no]
|
18
|
+
@order_ids[0].should_not be_nil
|
19
|
+
@order_ids[0].order_no.should_not be_nil
|
20
|
+
@order.should_not be_nil
|
21
|
+
@order.order_no.should == @order_ids[0].order_no
|
22
|
+
@order.trade_type.should == ClickClientScrap::FX::TRADE_TYPE_NEW
|
23
|
+
@order.execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
24
|
+
@order.sell_or_buy.should == ClickClientScrap::FX::BUY
|
25
|
+
@order.pair.should == ClickClientScrap::FX::EURJPY
|
26
|
+
@order.count.should == 1
|
27
|
+
@order.rate.should == @rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5
|
28
|
+
@order.stop_order_rate.should be_nil
|
29
|
+
@order.stop_order_execution_expression.should be_nil
|
30
|
+
@order.order_type= ClickClientScrap::FX::ORDER_TYPE_NORMAL
|
31
|
+
|
32
|
+
#指値-売り
|
33
|
+
@order_ids[1] = @s.order( ClickClientScrap::FX::USDJPY, ClickClientScrap::FX::SELL, 1, {
|
34
|
+
:rate=>@rates[ClickClientScrap::FX::USDJPY].ask_rate + 0.5,
|
35
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
36
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_WEEK_END
|
37
|
+
})
|
38
|
+
@order = @s.list_orders[@order_ids[1].order_no]
|
39
|
+
@order_ids[1].should_not be_nil
|
40
|
+
@order_ids[1].order_no.should_not be_nil
|
41
|
+
@order.should_not be_nil
|
42
|
+
@order.order_no.should == @order_ids[1].order_no
|
43
|
+
@order.trade_type.should == ClickClientScrap::FX::TRADE_TYPE_NEW
|
44
|
+
@order.execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
45
|
+
@order.sell_or_buy.should == ClickClientScrap::FX::SELL
|
46
|
+
@order.pair.should == ClickClientScrap::FX::USDJPY
|
47
|
+
@order.count.should == 1
|
48
|
+
@order.rate.should == @rates[ClickClientScrap::FX::USDJPY].ask_rate + 0.5
|
49
|
+
@order.stop_order_rate.should be_nil
|
50
|
+
@order.stop_order_execution_expression.should be_nil
|
51
|
+
@order.order_type= ClickClientScrap::FX::ORDER_TYPE_NORMAL
|
52
|
+
|
53
|
+
#逆指値-買い
|
54
|
+
@order_ids[2] = @s.order( ClickClientScrap::FX::EURUSD, ClickClientScrap::FX::BUY, 1, {
|
55
|
+
:rate=>@rates[ClickClientScrap::FX::EURUSD].ask_rate + 0.05,
|
56
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
57
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
58
|
+
})
|
59
|
+
@order = @s.list_orders[@order_ids[2].order_no]
|
60
|
+
@order_ids[2].should_not be_nil
|
61
|
+
@order_ids[2].order_no.should_not be_nil
|
62
|
+
@order = @s.list_orders[@order_ids[2].order_no]
|
63
|
+
@order.should_not be_nil
|
64
|
+
@order.order_no.should == @order_ids[2].order_no
|
65
|
+
@order.trade_type.should == ClickClientScrap::FX::TRADE_TYPE_NEW
|
66
|
+
@order.execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
67
|
+
@order.sell_or_buy.should == ClickClientScrap::FX::BUY
|
68
|
+
@order.pair.should == ClickClientScrap::FX::EURUSD
|
69
|
+
@order.count.should == 1
|
70
|
+
@order.rate.to_s.should == (@rates[ClickClientScrap::FX::EURUSD].ask_rate + 0.05).to_s
|
71
|
+
@order.stop_order_rate.should be_nil
|
72
|
+
@order.stop_order_execution_expression.should be_nil
|
73
|
+
@order.order_type= ClickClientScrap::FX::ORDER_TYPE_NORMAL
|
74
|
+
|
75
|
+
#逆指値-売り
|
76
|
+
@order_ids[3] = @s.order( ClickClientScrap::FX::GBPJPY, ClickClientScrap::FX::SELL, 2, {
|
77
|
+
:rate=>@rates[ClickClientScrap::FX::GBPJPY].ask_rate - 0.5,
|
78
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
79
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_SPECIFIED, # 有効期限: 指定
|
80
|
+
:expiration_date=>Date.today+2 # 2日後
|
81
|
+
})
|
82
|
+
@order = @s.list_orders[@order_ids[3].order_no]
|
83
|
+
@order_ids[3].should_not be_nil
|
84
|
+
@order_ids[3].order_no.should_not be_nil
|
85
|
+
@order.should_not be_nil
|
86
|
+
@order.order_no.should == @order_ids[3].order_no
|
87
|
+
@order.trade_type.should == ClickClientScrap::FX::TRADE_TYPE_NEW
|
88
|
+
@order.execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
89
|
+
@order.sell_or_buy.should == ClickClientScrap::FX::SELL
|
90
|
+
@order.pair.should == ClickClientScrap::FX::GBPJPY
|
91
|
+
@order.count.should == 2
|
92
|
+
@order.rate.should == @rates[ClickClientScrap::FX::GBPJPY].ask_rate - 0.5
|
93
|
+
@order.stop_order_rate.should be_nil
|
94
|
+
@order.stop_order_execution_expression.should be_nil
|
95
|
+
@order.order_type= ClickClientScrap::FX::ORDER_TYPE_NORMAL
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$: << "../lib"
|
2
|
+
|
3
|
+
require 'clickclient_scrap'
|
4
|
+
require 'common'
|
5
|
+
|
6
|
+
describe "list_orders" do
|
7
|
+
include TestBase
|
8
|
+
it "複数のページがあってもすべてのデータが取得できる" do
|
9
|
+
do_test {|s|
|
10
|
+
10.times{|i|
|
11
|
+
@order_ids << @s.order( ClickClientScrap::FX::USDJPY, ClickClientScrap::FX::BUY, 1, {
|
12
|
+
:rate=>@rates[ClickClientScrap::FX::USDJPY].ask_rate - 0.5,
|
13
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
14
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
15
|
+
})
|
16
|
+
}
|
17
|
+
10.times{|i|
|
18
|
+
@order_ids << @s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::BUY, 1, {
|
19
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
20
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
21
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
22
|
+
})
|
23
|
+
}
|
24
|
+
result = @s.list_orders(ClickClientScrap::FX::ORDER_CONDITION_ON_ORDER)
|
25
|
+
result.size.should == 20
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
$: << "../lib"
|
2
|
+
|
3
|
+
require 'clickclient_scrap'
|
4
|
+
require 'common'
|
5
|
+
|
6
|
+
# 成り行きで発注および決済を行うテスト。
|
7
|
+
# <b>注意:</b> 決済まで行う為、実行すると資金が減少します。
|
8
|
+
describe "market order" do
|
9
|
+
include TestBase
|
10
|
+
|
11
|
+
it "成り行きで発注し決済するテスト" do
|
12
|
+
do_test {|s|
|
13
|
+
prev = @s.list_open_interests
|
14
|
+
|
15
|
+
# 成り行きで注文
|
16
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::BUY, 1, {
|
17
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
18
|
+
})
|
19
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
20
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_WEEK_END
|
21
|
+
})
|
22
|
+
sleep 1
|
23
|
+
|
24
|
+
#建玉一覧取得
|
25
|
+
after = @s.list_open_interests
|
26
|
+
positions = after.find_all {|i| !prev.include?(i[0]) }.map{|i| i[1] }
|
27
|
+
positions.length.should == 2 # 新規の建玉が2つ存在することを確認
|
28
|
+
positions.each {|p|
|
29
|
+
p.open_interest_id.should_not be_nil
|
30
|
+
p.pair.should_not be_nil
|
31
|
+
p.sell_or_buy.should_not be_nil
|
32
|
+
p.count.should == 1
|
33
|
+
p.rate.should_not be_nil
|
34
|
+
p.profit_or_loss.should_not be_nil
|
35
|
+
}
|
36
|
+
|
37
|
+
# 決済注文
|
38
|
+
@s.settle( positions[0].open_interest_id, 1 )
|
39
|
+
@s.settle( positions[1].open_interest_id, 1 )
|
40
|
+
sleep 1
|
41
|
+
|
42
|
+
after_settle = @s.list_open_interests
|
43
|
+
after_settle.key?( positions[0].open_interest_id ).should == false
|
44
|
+
after_settle.key?( positions[1].open_interest_id ).should == false
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "部分決済のテスト" do
|
49
|
+
do_test {|s|
|
50
|
+
prev = @s.list_open_interests
|
51
|
+
|
52
|
+
# 成り行きで注文
|
53
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::BUY, 2, {
|
54
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
55
|
+
})
|
56
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 2, {
|
57
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_WEEK_END
|
58
|
+
})
|
59
|
+
sleep 1
|
60
|
+
|
61
|
+
#建玉一覧取得
|
62
|
+
after = @s.list_open_interests
|
63
|
+
positions = after.find_all {|i| !prev.include?(i[0]) }.map{|i| i[1] }
|
64
|
+
positions.length.should == 2 # 新規の建玉が2つ存在することを確認
|
65
|
+
positions.each {|p|
|
66
|
+
p.open_interest_id.should_not be_nil
|
67
|
+
p.pair.should_not be_nil
|
68
|
+
p.sell_or_buy.should_not be_nil
|
69
|
+
p.count.should == 2
|
70
|
+
p.rate.should_not be_nil
|
71
|
+
p.profit_or_loss.should_not be_nil
|
72
|
+
}
|
73
|
+
|
74
|
+
# 決済注文
|
75
|
+
@s.settle( positions[0].open_interest_id, 1 ) # 1つだけ決済
|
76
|
+
@s.settle( positions[1].open_interest_id, 1 )
|
77
|
+
sleep 1
|
78
|
+
|
79
|
+
after_settle = @s.list_open_interests
|
80
|
+
after_settle.key?( positions[0].open_interest_id ).should == true
|
81
|
+
after_settle.key?( positions[1].open_interest_id ).should == true
|
82
|
+
|
83
|
+
@s.settle( positions[0].open_interest_id, 1 )
|
84
|
+
@s.settle( positions[1].open_interest_id, 1 )
|
85
|
+
after_settle = @s.list_open_interests
|
86
|
+
after_settle.key?( positions[0].open_interest_id ).should == false
|
87
|
+
after_settle.key?( positions[1].open_interest_id ).should == false
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
it "建玉が多数ある場合のテスト" do
|
92
|
+
do_test {|s|
|
93
|
+
prev = @s.list_open_interests
|
94
|
+
|
95
|
+
# 成り行きで注文
|
96
|
+
4.times {
|
97
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::BUY, 1, {
|
98
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
99
|
+
})
|
100
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
101
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_WEEK_END
|
102
|
+
})
|
103
|
+
}
|
104
|
+
sleep 1
|
105
|
+
|
106
|
+
#建玉一覧取得
|
107
|
+
after = @s.list_open_interests
|
108
|
+
positions = after.find_all {|i| !prev.include?(i[0]) }.map{|i| i[1] }
|
109
|
+
positions.length.should == 8 # 新規の建玉が2つ存在することを確認
|
110
|
+
positions.each {|p|
|
111
|
+
p.open_interest_id.should_not be_nil
|
112
|
+
p.pair.should_not be_nil
|
113
|
+
p.sell_or_buy.should_not be_nil
|
114
|
+
p.count.should == 1
|
115
|
+
p.rate.should_not be_nil
|
116
|
+
p.profit_or_loss.should_not be_nil
|
117
|
+
}
|
118
|
+
|
119
|
+
# 決済注文
|
120
|
+
positions.each {|p|
|
121
|
+
@s.settle( p.open_interest_id, 1 )
|
122
|
+
}
|
123
|
+
sleep 1
|
124
|
+
|
125
|
+
after_settle = @s.list_open_interests
|
126
|
+
positions.each {|p|
|
127
|
+
after_settle.key?( p.open_interest_id ).should == false
|
128
|
+
}
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
$: << "../lib"
|
2
|
+
|
3
|
+
require 'clickclient_scrap'
|
4
|
+
require 'common'
|
5
|
+
|
6
|
+
describe "OCO" do
|
7
|
+
include TestBase
|
8
|
+
|
9
|
+
it "OCO-買" do
|
10
|
+
do_test {|s|
|
11
|
+
@order_id = @s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::BUY, 1, {
|
12
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
13
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
14
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
15
|
+
})
|
16
|
+
@order_ids << @order_id
|
17
|
+
orders = @s.list_orders
|
18
|
+
@order = orders[@order_id.order_no]
|
19
|
+
@order_id.should_not be_nil
|
20
|
+
@order_id.order_no.should_not be_nil
|
21
|
+
@order.should_not be_nil
|
22
|
+
@order.order_no.should == @order_id.order_no
|
23
|
+
@order.trade_type.should == ClickClientScrap::FX::TRADE_TYPE_NEW
|
24
|
+
@order.execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
25
|
+
@order.sell_or_buy.should == ClickClientScrap::FX::BUY
|
26
|
+
@order.pair.should == ClickClientScrap::FX::EURJPY
|
27
|
+
@order.count.should == 1
|
28
|
+
@order.rate.should == @rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5
|
29
|
+
@order.stop_order_rate.should == @rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5
|
30
|
+
@order.stop_order_execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
31
|
+
@order.order_type= ClickClientScrap::FX::ORDER_TYPE_OCO
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "OCO-売" do
|
36
|
+
do_test {|s|
|
37
|
+
@order_id = @s.order( ClickClientScrap::FX::GBPJPY, ClickClientScrap::FX::SELL, 1, {
|
38
|
+
:rate=>@rates[ClickClientScrap::FX::GBPJPY].ask_rate + 0.5,
|
39
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::GBPJPY].ask_rate - 0.5,
|
40
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_WEEK_END
|
41
|
+
})
|
42
|
+
@order_ids << @order_id
|
43
|
+
orders = @s.list_orders
|
44
|
+
@order = orders[@order_id.order_no]
|
45
|
+
@order_id.should_not be_nil
|
46
|
+
@order_id.order_no.should_not be_nil
|
47
|
+
@order.should_not be_nil
|
48
|
+
@order.order_no.should == @order_id.order_no
|
49
|
+
@order.trade_type.should == ClickClientScrap::FX::TRADE_TYPE_NEW
|
50
|
+
@order.execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
51
|
+
@order.sell_or_buy.should == ClickClientScrap::FX::SELL
|
52
|
+
@order.pair.should == ClickClientScrap::FX::GBPJPY
|
53
|
+
@order.count.should == 1
|
54
|
+
@order.rate.should == @rates[ClickClientScrap::FX::GBPJPY].ask_rate + 0.5
|
55
|
+
@order.stop_order_rate.should == @rates[ClickClientScrap::FX::GBPJPY].ask_rate - 0.5
|
56
|
+
@order.stop_order_execution_expression.should == ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
57
|
+
@order.order_type= ClickClientScrap::FX::ORDER_TYPE_OCO
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
$: << "../lib"
|
2
|
+
|
3
|
+
require 'clickclient_scrap'
|
4
|
+
require 'common'
|
5
|
+
|
6
|
+
describe "注文の異常系テスト" do
|
7
|
+
include TestBase
|
8
|
+
|
9
|
+
it "指値/逆指値" do
|
10
|
+
do_test {|s|
|
11
|
+
# 執行条件の指定がない
|
12
|
+
proc {
|
13
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
14
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
15
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
16
|
+
})
|
17
|
+
}.should raise_error( RuntimeError, "options[:execution_expression] is required." )
|
18
|
+
|
19
|
+
# 有効期限の指定がない
|
20
|
+
proc {
|
21
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
22
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
23
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
24
|
+
})
|
25
|
+
}.should raise_error( RuntimeError, "options[:expiration_type] is required." )
|
26
|
+
|
27
|
+
# 日付指定であるのに日時の指定がない
|
28
|
+
proc {
|
29
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
30
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
31
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
32
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_SPECIFIED
|
33
|
+
})
|
34
|
+
}.should raise_error( RuntimeError, "options[:expiration_date] is required." )
|
35
|
+
|
36
|
+
# 日付指定の範囲が不正
|
37
|
+
proc {
|
38
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
39
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
40
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
41
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_SPECIFIED,
|
42
|
+
:expiration_date=>Date.today
|
43
|
+
})
|
44
|
+
}.should raise_error( RuntimeError )
|
45
|
+
|
46
|
+
# レートが不正
|
47
|
+
proc {
|
48
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
49
|
+
:rate=>"-10000000",
|
50
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
51
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
52
|
+
})
|
53
|
+
}.should raise_error( RuntimeError )
|
54
|
+
|
55
|
+
# 取引数量が不正
|
56
|
+
proc {
|
57
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, -1, {
|
58
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
59
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
60
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
61
|
+
})
|
62
|
+
}.should raise_error( RuntimeError )
|
63
|
+
|
64
|
+
proc {
|
65
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 0, {
|
66
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
67
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
68
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
69
|
+
})
|
70
|
+
}.should raise_error( RuntimeError )
|
71
|
+
|
72
|
+
proc {
|
73
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1000, {
|
74
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
75
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
76
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
77
|
+
})
|
78
|
+
}.should raise_error( RuntimeError )
|
79
|
+
|
80
|
+
# 不利な注文
|
81
|
+
proc {
|
82
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
83
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
84
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
85
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
86
|
+
})
|
87
|
+
}.should raise_error( RuntimeError )
|
88
|
+
|
89
|
+
proc {
|
90
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
91
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
92
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
93
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
94
|
+
})
|
95
|
+
}.should raise_error( RuntimeError )
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
it "OCO" do
|
100
|
+
do_test {|s|
|
101
|
+
# 執行条件の指定がない
|
102
|
+
proc {
|
103
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
104
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
105
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5
|
106
|
+
})
|
107
|
+
}.should raise_error( RuntimeError, "options[:expiration_type] is required." )
|
108
|
+
|
109
|
+
# 有効期限の指定がない
|
110
|
+
proc {
|
111
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
112
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
113
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
114
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
115
|
+
})
|
116
|
+
}.should raise_error( RuntimeError, "options[:expiration_type] is required." )
|
117
|
+
|
118
|
+
# 不利な注文
|
119
|
+
proc {
|
120
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
121
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
122
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate - 0.5,
|
123
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
124
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
125
|
+
})
|
126
|
+
}.should raise_error( RuntimeError )
|
127
|
+
|
128
|
+
proc {
|
129
|
+
@s.order( ClickClientScrap::FX::EURJPY, ClickClientScrap::FX::SELL, 1, {
|
130
|
+
:rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
131
|
+
:stop_order_rate=>@rates[ClickClientScrap::FX::EURJPY].ask_rate + 0.5,
|
132
|
+
:execution_expression=>ClickClientScrap::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
133
|
+
:expiration_type=>ClickClientScrap::FX::EXPIRATION_TYPE_TODAY
|
134
|
+
})
|
135
|
+
}.should raise_error( RuntimeError )
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|