sbiclient 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,307 +1,311 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  $: << "../lib"
2
4
 
3
5
  require 'sbiclient'
4
6
  require 'common'
5
7
 
6
8
  describe "OCO" do
7
- it_should_behave_like "login"
9
+ it_should_behave_like "login" do
8
10
 
9
- it "OCO-買x買-指値" do
10
- # 買いx買い。2つめの取引は逆指値になる
11
- @order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
12
- :rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
13
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
14
- :second_order_rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
15
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
16
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
17
- })
18
- orders = @s.list_orders
19
- @order = orders[@order_id.order_no]
20
- @order_id.should_not be_nil
21
- @order_id.order_no.should_not be_nil
22
- @order.should_not be_nil
23
- @order.order_no.should == @order_id.order_no
24
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
25
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
26
- @order.sell_or_buy.should == SBIClient::FX::BUY
27
- @order.pair.should == SBIClient::FX::EURJPY
28
- @order.count.should == 1
29
- @order.rate.should == @rates[SBIClient::FX::EURJPY].ask_rate - 0.5
30
- @order.trail_range.should be_nil
31
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
11
+ it "OCO-買x買-指値" do
12
+ # 買いx買い。2つめの取引は逆指値になる
13
+ @order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
14
+ :rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
15
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
16
+ :second_order_rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
17
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
18
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
19
+ })
20
+ orders = @s.list_orders
21
+ @order = orders[@order_id.order_no]
22
+ @order_id.should_not be_nil
23
+ @order_id.order_no.should_not be_nil
24
+ @order.should_not be_nil
25
+ @order.order_no.should == @order_id.order_no
26
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
27
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
28
+ @order.sell_or_buy.should == SBIClient::FX::BUY
29
+ @order.pair.should == SBIClient::FX::EURJPY
30
+ @order.count.should == 1
31
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURJPY].ask_rate - 0.5)
32
+ @order.trail_range.should be_nil
33
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
34
+
35
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
36
+ @order.should_not be_nil
37
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
38
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
39
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
40
+ @order.sell_or_buy.should == SBIClient::FX::BUY
41
+ @order.pair.should == SBIClient::FX::EURJPY
42
+ @order.count.should == 1
43
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURJPY].ask_rate + 0.5)
44
+ @order.trail_range.should be_nil
45
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
46
+ end
32
47
 
33
- @order = orders[(@order_id.order_no.to_i+1).to_s]
34
- @order.should_not be_nil
35
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
36
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
37
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
38
- @order.sell_or_buy.should == SBIClient::FX::BUY
39
- @order.pair.should == SBIClient::FX::EURJPY
40
- @order.count.should == 1
41
- @order.rate.should == @rates[SBIClient::FX::EURJPY].ask_rate + 0.5
42
- @order.trail_range.should be_nil
43
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
44
- end
45
-
46
- it "OCO-売x売-指値" do
47
- # 売りx売り。2つめの取引は逆指値になる
48
- @order_id = @s.order( SBIClient::FX::GBPJPY, SBIClient::FX::SELL, 1, {
49
- :rate=>@rates[SBIClient::FX::GBPJPY].ask_rate + 0.5,
50
- :second_order_sell_or_buy=>SBIClient::FX::SELL,
51
- :second_order_rate=>@rates[SBIClient::FX::GBPJPY].ask_rate - 0.5,
52
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
53
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_WEEK_END
54
- })
55
- orders = @s.list_orders
56
- @order = orders[@order_id.order_no]
57
- @order_id.should_not be_nil
58
- @order_id.order_no.should_not be_nil
59
- @order.should_not be_nil
60
- @order.order_no.should == @order_id.order_no
61
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
62
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
63
- @order.sell_or_buy.should == SBIClient::FX::SELL
64
- @order.pair.should == SBIClient::FX::GBPJPY
65
- @order.count.should == 1
66
- @order.rate.should == @rates[SBIClient::FX::GBPJPY].ask_rate + 0.5
67
- @order.trail_range.should be_nil
68
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
48
+ it "OCO-売x売-指値" do
49
+ # 売りx売り。2つめの取引は逆指値になる
50
+ @order_id = @s.order( SBIClient::FX::GBPJPY, SBIClient::FX::SELL, 1, {
51
+ :rate=>@rates[SBIClient::FX::GBPJPY].ask_rate + 0.5,
52
+ :second_order_sell_or_buy=>SBIClient::FX::SELL,
53
+ :second_order_rate=>@rates[SBIClient::FX::GBPJPY].ask_rate - 0.5,
54
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
55
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_WEEK_END
56
+ })
57
+ orders = @s.list_orders
58
+ @order = orders[@order_id.order_no]
59
+ @order_id.should_not be_nil
60
+ @order_id.order_no.should_not be_nil
61
+ @order.should_not be_nil
62
+ @order.order_no.should == @order_id.order_no
63
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
64
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
65
+ @order.sell_or_buy.should == SBIClient::FX::SELL
66
+ @order.pair.should == SBIClient::FX::GBPJPY
67
+ @order.count.should == 1
68
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::GBPJPY].ask_rate + 0.5)
69
+ @order.trail_range.should be_nil
70
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
71
+
72
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
73
+ @order.should_not be_nil
74
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
75
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
76
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
77
+ @order.sell_or_buy.should == SBIClient::FX::SELL
78
+ @order.pair.should == SBIClient::FX::GBPJPY
79
+ @order.count.should == 1
80
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::GBPJPY].ask_rate - 0.5)
81
+ @order.trail_range.should be_nil
82
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
83
+ end
69
84
 
70
- @order = orders[(@order_id.order_no.to_i+1).to_s]
71
- @order.should_not be_nil
72
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
73
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
74
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
75
- @order.sell_or_buy.should == SBIClient::FX::SELL
76
- @order.pair.should == SBIClient::FX::GBPJPY
77
- @order.count.should == 1
78
- @order.rate.should == @rates[SBIClient::FX::GBPJPY].ask_rate - 0.5
79
- @order.trail_range.should be_nil
80
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
81
- end
82
-
83
- it "OCO-買x売-指値" do
84
- # 買いx売り。両方とも指値になる
85
- @order_id = @s.order( SBIClient::FX::USDJPY, SBIClient::FX::BUY, 1, {
86
- :rate=>@rates[SBIClient::FX::USDJPY].ask_rate - 1,
87
- :second_order_sell_or_buy=>SBIClient::FX::SELL,
88
- :second_order_rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 1,
89
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
90
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
91
- })
92
- orders = @s.list_orders
93
- @order = orders[@order_id.order_no]
94
- @order_id.should_not be_nil
95
- @order_id.order_no.should_not be_nil
96
- @order.should_not be_nil
97
- @order.order_no.should == @order_id.order_no
98
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
99
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
100
- @order.sell_or_buy.should == SBIClient::FX::BUY
101
- @order.pair.should == SBIClient::FX::USDJPY
102
- @order.count.should == 1
103
- @order.rate.should == @rates[SBIClient::FX::USDJPY].ask_rate - 1
104
- @order.trail_range.should be_nil
105
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
85
+ it "OCO-買x売-指値" do
86
+ # 買いx売り。両方とも指値になる
87
+ @order_id = @s.order( SBIClient::FX::USDJPY, SBIClient::FX::BUY, 1, {
88
+ :rate=>@rates[SBIClient::FX::USDJPY].ask_rate - 1,
89
+ :second_order_sell_or_buy=>SBIClient::FX::SELL,
90
+ :second_order_rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 1,
91
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
92
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
93
+ })
94
+ orders = @s.list_orders
95
+ @order = orders[@order_id.order_no]
96
+ @order_id.should_not be_nil
97
+ @order_id.order_no.should_not be_nil
98
+ @order.should_not be_nil
99
+ @order.order_no.should == @order_id.order_no
100
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
101
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
102
+ @order.sell_or_buy.should == SBIClient::FX::BUY
103
+ @order.pair.should == SBIClient::FX::USDJPY
104
+ @order.count.should == 1
105
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::USDJPY].ask_rate - 1)
106
+ @order.trail_range.should be_nil
107
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
108
+
109
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
110
+ @order.should_not be_nil
111
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
112
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
113
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
114
+ @order.sell_or_buy.should == SBIClient::FX::SELL
115
+ @order.pair.should == SBIClient::FX::USDJPY
116
+ @order.count.should == 1
117
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::USDJPY].ask_rate + 1)
118
+ @order.trail_range.should be_nil
119
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
120
+ end
106
121
 
107
- @order = orders[(@order_id.order_no.to_i+1).to_s]
108
- @order.should_not be_nil
109
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
110
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
111
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
112
- @order.sell_or_buy.should == SBIClient::FX::SELL
113
- @order.pair.should == SBIClient::FX::USDJPY
114
- @order.count.should == 1
115
- @order.rate.should == @rates[SBIClient::FX::USDJPY].ask_rate + 1
116
- @order.trail_range.should be_nil
117
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
118
- end
119
-
120
- it "OCO-売x買-指値" do
121
- # 買いx売り。両方とも指値になる
122
- @order_id = @s.order( SBIClient::FX::MZDJPY, SBIClient::FX::SELL, 2, {
123
- :rate=>@rates[SBIClient::FX::MZDJPY].ask_rate + 1,
124
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
125
- :second_order_rate=>@rates[SBIClient::FX::MZDJPY].ask_rate - 1,
126
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
127
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED, # 有効期限: 指定
128
- :expiration_date=>Date.today+1
129
- })
130
- orders = @s.list_orders
131
- @order = orders[@order_id.order_no]
132
- @order_id.should_not be_nil
133
- @order_id.order_no.should_not be_nil
134
- @order.should_not be_nil
135
- @order.order_no.should == @order_id.order_no
136
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
137
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
138
- @order.sell_or_buy.should == SBIClient::FX::SELL
139
- @order.pair.should == SBIClient::FX::MZDJPY
140
- @order.count.should == 2
141
- @order.rate.should == @rates[SBIClient::FX::MZDJPY].ask_rate + 1
142
- @order.trail_range.should be_nil
143
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
122
+ it "OCO-売x買-指値" do
123
+
124
+ # 買いx売り。両方とも指値になる
125
+ @order_id = @s.order( SBIClient::FX::MZDJPY, SBIClient::FX::SELL, 2, {
126
+ :rate=>@rates[SBIClient::FX::MZDJPY].ask_rate + 1,
127
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
128
+ :second_order_rate=>@rates[SBIClient::FX::MZDJPY].ask_rate - 1,
129
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
130
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED, # 有効期限: 指定
131
+ :expiration_date=>Date.today+1
132
+ })
133
+ orders = @s.list_orders
134
+ @order = orders[@order_id.order_no]
135
+ @order_id.should_not be_nil
136
+ @order_id.order_no.should_not be_nil
137
+ @order.should_not be_nil
138
+ @order.order_no.should == @order_id.order_no
139
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
140
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
141
+ @order.sell_or_buy.should == SBIClient::FX::SELL
142
+ @order.pair.should == SBIClient::FX::MZDJPY
143
+ @order.count.should == 2
144
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::MZDJPY].ask_rate + 1.0)
145
+ @order.trail_range.should be_nil
146
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
147
+
148
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
149
+ @order.should_not be_nil
150
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
151
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
152
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
153
+ @order.sell_or_buy.should == SBIClient::FX::BUY
154
+ @order.pair.should == SBIClient::FX::MZDJPY
155
+ @order.count.should == 2
156
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::MZDJPY].ask_rate - 1.0)
157
+ @order.trail_range.should be_nil
158
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
159
+ end
144
160
 
145
- @order = orders[(@order_id.order_no.to_i+1).to_s]
146
- @order.should_not be_nil
147
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
148
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
149
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
150
- @order.sell_or_buy.should == SBIClient::FX::BUY
151
- @order.pair.should == SBIClient::FX::MZDJPY
152
- @order.count.should == 2
153
- @order.rate.should == @rates[SBIClient::FX::MZDJPY].ask_rate - 1
154
- @order.trail_range.should be_nil
155
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
156
- end
157
-
158
- it "OCO-買x買-逆指値" do
159
- # 買いx買い。2つめの取引は指値になる
160
- @order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
161
- :rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
162
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
163
- :second_order_rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
164
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
165
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
166
- })
167
- orders = @s.list_orders
168
- @order = orders[@order_id.order_no]
169
- @order_id.should_not be_nil
170
- @order_id.order_no.should_not be_nil
171
- @order.should_not be_nil
172
- @order.order_no.should == @order_id.order_no
173
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
174
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
175
- @order.sell_or_buy.should == SBIClient::FX::BUY
176
- @order.pair.should == SBIClient::FX::EURJPY
177
- @order.count.should == 1
178
- @order.rate.should == @rates[SBIClient::FX::EURJPY].ask_rate + 0.5
179
- @order.trail_range.should be_nil
180
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
161
+ it "OCO-買x買-逆指値" do
162
+ # 買いx買い。2つめの取引は指値になる
163
+ @order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
164
+ :rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
165
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
166
+ :second_order_rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
167
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
168
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
169
+ })
170
+ orders = @s.list_orders
171
+ @order = orders[@order_id.order_no]
172
+ @order_id.should_not be_nil
173
+ @order_id.order_no.should_not be_nil
174
+ @order.should_not be_nil
175
+ @order.order_no.should == @order_id.order_no
176
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
177
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
178
+ @order.sell_or_buy.should == SBIClient::FX::BUY
179
+ @order.pair.should == SBIClient::FX::EURJPY
180
+ @order.count.should == 1
181
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURJPY].ask_rate + 0.5)
182
+ @order.trail_range.should be_nil
183
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
184
+
185
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
186
+ @order.should_not be_nil
187
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
188
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
189
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
190
+ @order.sell_or_buy.should == SBIClient::FX::BUY
191
+ @order.pair.should == SBIClient::FX::EURJPY
192
+ @order.count.should == 1
193
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURJPY].ask_rate - 0.5)
194
+ @order.trail_range.should be_nil
195
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
196
+ end
181
197
 
182
- @order = orders[(@order_id.order_no.to_i+1).to_s]
183
- @order.should_not be_nil
184
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
185
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
186
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
187
- @order.sell_or_buy.should == SBIClient::FX::BUY
188
- @order.pair.should == SBIClient::FX::EURJPY
189
- @order.count.should == 1
190
- @order.rate.should == @rates[SBIClient::FX::EURJPY].ask_rate - 0.5
191
- @order.trail_range.should be_nil
192
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
193
- end
194
-
195
- it "OCO-売x売-逆指値" do
196
- # 売りx売り。2つめの取引は指値になる
197
- @order_id = @s.order( SBIClient::FX::GBPJPY, SBIClient::FX::SELL, 1, {
198
- :rate=>@rates[SBIClient::FX::GBPJPY].ask_rate - 0.5,
199
- :second_order_sell_or_buy=>SBIClient::FX::SELL,
200
- :second_order_rate=>@rates[SBIClient::FX::GBPJPY].ask_rate + 0.5,
201
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
202
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_WEEK_END
203
- })
204
- orders = @s.list_orders
205
- @order = orders[@order_id.order_no]
206
- @order_id.should_not be_nil
207
- @order_id.order_no.should_not be_nil
208
- @order.should_not be_nil
209
- @order.order_no.should == @order_id.order_no
210
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
211
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
212
- @order.sell_or_buy.should == SBIClient::FX::SELL
213
- @order.pair.should == SBIClient::FX::GBPJPY
214
- @order.count.should == 1
215
- @order.rate.should == @rates[SBIClient::FX::GBPJPY].ask_rate - 0.5
216
- @order.trail_range.should be_nil
217
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
198
+ it "OCO-売x売-逆指値" do
199
+ # 売りx売り。2つめの取引は指値になる
200
+ @order_id = @s.order( SBIClient::FX::GBPJPY, SBIClient::FX::SELL, 1, {
201
+ :rate=>@rates[SBIClient::FX::GBPJPY].ask_rate - 0.5,
202
+ :second_order_sell_or_buy=>SBIClient::FX::SELL,
203
+ :second_order_rate=>@rates[SBIClient::FX::GBPJPY].ask_rate + 0.5,
204
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
205
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_WEEK_END
206
+ })
207
+ orders = @s.list_orders
208
+ @order = orders[@order_id.order_no]
209
+ @order_id.should_not be_nil
210
+ @order_id.order_no.should_not be_nil
211
+ @order.should_not be_nil
212
+ @order.order_no.should == @order_id.order_no
213
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
214
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
215
+ @order.sell_or_buy.should == SBIClient::FX::SELL
216
+ @order.pair.should == SBIClient::FX::GBPJPY
217
+ @order.count.should == 1
218
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::GBPJPY].ask_rate - 0.5)
219
+ @order.trail_range.should be_nil
220
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
221
+
222
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
223
+ @order.should_not be_nil
224
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
225
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
226
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
227
+ @order.sell_or_buy.should == SBIClient::FX::SELL
228
+ @order.pair.should == SBIClient::FX::GBPJPY
229
+ @order.count.should == 1
230
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::GBPJPY].ask_rate + 0.5)
231
+ @order.trail_range.should be_nil
232
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
233
+ end
218
234
 
219
- @order = orders[(@order_id.order_no.to_i+1).to_s]
220
- @order.should_not be_nil
221
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
222
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
223
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
224
- @order.sell_or_buy.should == SBIClient::FX::SELL
225
- @order.pair.should == SBIClient::FX::GBPJPY
226
- @order.count.should == 1
227
- @order.rate.should == @rates[SBIClient::FX::GBPJPY].ask_rate + 0.5
228
- @order.trail_range.should be_nil
229
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
230
- end
231
-
232
- it "OCO-買x売-逆指値" do
233
- # 買いx売り。両方とも逆指値になる
234
- @order_id = @s.order( SBIClient::FX::USDJPY, SBIClient::FX::BUY, 1, {
235
- :rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 1,
236
- :second_order_sell_or_buy=>SBIClient::FX::SELL,
237
- :second_order_rate=>@rates[SBIClient::FX::USDJPY].ask_rate - 1,
238
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
239
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
240
- })
241
- orders = @s.list_orders
242
- @order = orders[@order_id.order_no]
243
- @order_id.should_not be_nil
244
- @order_id.order_no.should_not be_nil
245
- @order.should_not be_nil
246
- @order.order_no.should == @order_id.order_no
247
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
248
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
249
- @order.sell_or_buy.should == SBIClient::FX::BUY
250
- @order.pair.should == SBIClient::FX::USDJPY
251
- @order.count.should == 1
252
- @order.rate.should == @rates[SBIClient::FX::USDJPY].ask_rate + 1
253
- @order.trail_range.should be_nil
254
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
235
+ it "OCO-買x売-逆指値" do
236
+ # 買いx売り。両方とも逆指値になる
237
+ @order_id = @s.order( SBIClient::FX::USDJPY, SBIClient::FX::BUY, 1, {
238
+ :rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 1,
239
+ :second_order_sell_or_buy=>SBIClient::FX::SELL,
240
+ :second_order_rate=>@rates[SBIClient::FX::USDJPY].ask_rate - 1,
241
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
242
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
243
+ })
244
+ orders = @s.list_orders
245
+ @order = orders[@order_id.order_no]
246
+ @order_id.should_not be_nil
247
+ @order_id.order_no.should_not be_nil
248
+ @order.should_not be_nil
249
+ @order.order_no.should == @order_id.order_no
250
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
251
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
252
+ @order.sell_or_buy.should == SBIClient::FX::BUY
253
+ @order.pair.should == SBIClient::FX::USDJPY
254
+ @order.count.should == 1
255
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::USDJPY].ask_rate + 1)
256
+ @order.trail_range.should be_nil
257
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
258
+
259
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
260
+ @order.should_not be_nil
261
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
262
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
263
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
264
+ @order.sell_or_buy.should == SBIClient::FX::SELL
265
+ @order.pair.should == SBIClient::FX::USDJPY
266
+ @order.count.should == 1
267
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::USDJPY].ask_rate - 1)
268
+ @order.trail_range.should be_nil
269
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
270
+ end
255
271
 
256
- @order = orders[(@order_id.order_no.to_i+1).to_s]
257
- @order.should_not be_nil
258
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
259
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
260
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
261
- @order.sell_or_buy.should == SBIClient::FX::SELL
262
- @order.pair.should == SBIClient::FX::USDJPY
263
- @order.count.should == 1
264
- @order.rate.should == @rates[SBIClient::FX::USDJPY].ask_rate - 1
265
- @order.trail_range.should be_nil
266
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
267
- end
268
-
269
- it "OCO-売りx買い" do
270
- # 買いx売り。両方とも指値になる
271
- @order_id = @s.order( SBIClient::FX::MZDJPY, SBIClient::FX::SELL, 2, {
272
- :rate=>@rates[SBIClient::FX::MZDJPY].ask_rate - 1,
273
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
274
- :second_order_rate=>@rates[SBIClient::FX::MZDJPY].ask_rate + 1,
275
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
276
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
277
- :expiration_date=>Date.today+5
278
- })
279
- orders = @s.list_orders
280
- @order = orders[@order_id.order_no]
281
- @order_id.should_not be_nil
282
- @order_id.order_no.should_not be_nil
283
- @order.should_not be_nil
284
- @order.order_no.should == @order_id.order_no
285
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
286
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
287
- @order.sell_or_buy.should == SBIClient::FX::SELL
288
- @order.pair.should == SBIClient::FX::MZDJPY
289
- @order.count.should == 2
290
- @order.rate.should == @rates[SBIClient::FX::MZDJPY].ask_rate - 1
291
- @order.trail_range.should be_nil
292
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
272
+ it "OCO-売りx買い" do
273
+ # 買いx売り。両方とも指値になる
274
+ @order_id = @s.order( SBIClient::FX::MZDJPY, SBIClient::FX::SELL, 2, {
275
+ :rate=>@rates[SBIClient::FX::MZDJPY].ask_rate - 1,
276
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
277
+ :second_order_rate=>@rates[SBIClient::FX::MZDJPY].ask_rate + 1,
278
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
279
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
280
+ :expiration_date=>Date.today+5
281
+ })
282
+ orders = @s.list_orders
283
+ @order = orders[@order_id.order_no]
284
+ @order_id.should_not be_nil
285
+ @order_id.order_no.should_not be_nil
286
+ @order.should_not be_nil
287
+ @order.order_no.should == @order_id.order_no
288
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
289
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
290
+ @order.sell_or_buy.should == SBIClient::FX::SELL
291
+ @order.pair.should == SBIClient::FX::MZDJPY
292
+ @order.count.should == 2
293
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::MZDJPY].ask_rate - 1.0)
294
+ @order.trail_range.should be_nil
295
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
296
+
297
+ @order = orders[(@order_id.order_no.to_i+1).to_s]
298
+ @order.should_not be_nil
299
+ @order.order_no.should == (@order_id.order_no.to_i+1).to_s
300
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
301
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
302
+ @order.sell_or_buy.should == SBIClient::FX::BUY
303
+ @order.pair.should == SBIClient::FX::MZDJPY
304
+ @order.count.should == 2
305
+ normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::MZDJPY].ask_rate + 1.0)
306
+ @order.trail_range.should be_nil
307
+ @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
308
+ end
293
309
 
294
- @order = orders[(@order_id.order_no.to_i+1).to_s]
295
- @order.should_not be_nil
296
- @order.order_no.should == (@order_id.order_no.to_i+1).to_s
297
- @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
298
- @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
299
- @order.sell_or_buy.should == SBIClient::FX::BUY
300
- @order.pair.should == SBIClient::FX::MZDJPY
301
- @order.count.should == 2
302
- @order.rate.should == @rates[SBIClient::FX::MZDJPY].ask_rate + 1
303
- @order.trail_range.should be_nil
304
- @order.order_type= SBIClient::FX::ORDER_TYPE_OCO
305
310
  end
306
-
307
311
  end