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,405 +1,410 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  $: << "../lib"
2
4
 
3
5
  require 'sbiclient'
4
6
  require 'common'
5
7
 
6
8
  describe "注文の異常系テスト" do
7
- it_should_behave_like "login"
8
-
9
- it "指値/逆指値" do
10
- # 執行条件の指定がない
11
- proc {
12
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
13
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
14
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
15
- })
16
- }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
17
-
18
- # 有効期限の指定がない
19
- proc {
20
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
21
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
22
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
23
- })
24
- }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
25
-
26
- # 日付指定であるのに日時の指定がない
27
- proc {
28
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
29
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
30
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
31
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED
32
- })
33
- }.should raise_error( RuntimeError, "options[:expiration_date] is required." )
34
-
35
- # 日付指定の範囲が不正
36
- proc {
37
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
38
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
39
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
40
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
41
- :expiration_date=>Date.today
42
- })
43
- }.should raise_error( RuntimeError )
44
-
45
- # レートが不正
46
- proc {
47
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
48
- :rate=>"-10000000",
49
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
50
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
51
- })
52
- }.should raise_error( RuntimeError )
53
-
54
- # 取引数量が不正
55
- proc {
56
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, -1, {
57
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
58
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
59
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
60
- })
61
- }.should raise_error( RuntimeError )
62
-
63
- proc {
64
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 0, {
65
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
66
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
67
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
68
- })
69
- }.should raise_error( RuntimeError )
70
-
71
- proc {
72
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1000, {
73
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
74
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
75
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
76
- })
77
- }.should raise_error( RuntimeError )
78
-
79
- # 不利な注文
80
- proc {
81
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
82
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
83
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
84
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
85
- })
86
- }.should raise_error( RuntimeError )
9
+ it_should_behave_like "login" do
87
10
 
88
- proc {
89
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
90
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
91
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
11
+ it "指値/逆指値" do
12
+ # 執行条件の指定がない
13
+ proc {
14
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
15
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
16
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
17
+ })
18
+ }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
19
+
20
+ # 有効期限の指定がない
21
+ proc {
22
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
23
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
24
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
25
+ })
26
+ }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
27
+
28
+ # 日付指定であるのに日時の指定がない
29
+ proc {
30
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
31
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
32
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
33
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED
34
+ })
35
+ }.should raise_error( RuntimeError, "options[:expiration_date] is required." )
36
+
37
+ # 日付指定の範囲が不正
38
+ proc {
39
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
40
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
41
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
42
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
43
+ :expiration_date=>Date.today
44
+ })
45
+ }.should raise_error( RuntimeError )
46
+
47
+ # レートが不正
48
+ proc {
49
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
50
+ :rate=>"-10000000",
51
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
52
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
53
+ })
54
+ }.should raise_error( RuntimeError )
55
+
56
+ # 取引数量が不正
57
+ proc {
58
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, -1, {
59
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
60
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
61
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
62
+ })
63
+ }.should raise_error( RuntimeError )
64
+
65
+ proc {
66
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 0, {
67
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
68
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
69
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
70
+ })
71
+ }.should raise_error( RuntimeError )
72
+
73
+ proc {
74
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1000, {
75
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
76
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
77
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
78
+ })
79
+ }.should raise_error( RuntimeError )
80
+
81
+ # 不利な注文
82
+ proc {
83
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
84
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
85
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
86
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
87
+ })
88
+ }.should raise_error( RuntimeError )
89
+
90
+ proc {
91
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
92
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
93
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
94
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
95
+ })
96
+ }.should raise_error( RuntimeError )
97
+ end
98
+
99
+ it "OCO" do
100
+ # 執行条件の指定がない
101
+ proc {
102
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
103
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
104
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
105
+ :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
92
106
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
93
107
  })
94
- }.should raise_error( RuntimeError )
95
- end
96
-
97
- it "OCO" do
98
- # 執行条件の指定がない
99
- proc {
100
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
101
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
102
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
103
- :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
104
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
105
- })
106
- }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
107
-
108
- # 有効期限の指定がない
109
- proc {
110
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
111
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
112
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
113
- :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
114
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
115
- })
116
- }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
117
-
118
- # 不利な注文
119
- proc {
120
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
121
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
108
+ }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
109
+
110
+ # 有効期限の指定がない
111
+ proc {
112
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
113
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
122
114
  :second_order_sell_or_buy=>SBIClient::FX::BUY,
123
115
  :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
124
116
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
125
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
126
117
  })
127
- }.should raise_error( RuntimeError )
118
+ }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
119
+
120
+ # 不利な注文
121
+ proc {
122
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
123
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
124
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
125
+ :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
126
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
127
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
128
+ })
129
+ }.should raise_error( RuntimeError )
130
+
131
+ proc {
132
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
133
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
134
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
135
+ :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
136
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
137
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
138
+ })
139
+ }.should raise_error( RuntimeError )
140
+ end
128
141
 
129
- proc {
130
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
131
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
132
- :second_order_sell_or_buy=>SBIClient::FX::BUY,
133
- :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
134
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
135
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
142
+ it "IFD" do
143
+ # 執行条件の指定がない
144
+ proc {
145
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
146
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
147
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
148
+ :settle => {
149
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
150
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
151
+ }
136
152
  })
137
- }.should raise_error( RuntimeError )
138
- end
139
-
140
- it "IFD" do
141
- # 執行条件の指定がない
142
- proc {
143
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
144
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
145
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
146
- :settle => {
147
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
148
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
149
- }
150
- })
151
- }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
152
-
153
- # 有効期限の指定がない
154
- proc {
155
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
156
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
157
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
158
- :settle => {
159
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
160
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
161
- }
162
- })
163
- }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
164
-
165
- # レートの指定がない
166
- proc {
167
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
168
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
169
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
170
- :settle => {
171
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
172
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
173
- }
174
- })
175
- }.should raise_error( RuntimeError, "options[:rate] is required." )
176
-
177
- # 決済取引のレートの指定がない
178
- proc {
179
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
180
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
181
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
182
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
183
- :settle => {
184
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
185
- }
186
- })
187
- }.should raise_error( RuntimeError, "options[:settle][:rate] is required." )
188
-
189
- # 決済取引の取引種別の指定がない
190
- proc {
191
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
192
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
193
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
194
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
195
- :settle => {
196
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1
197
- }
198
- })
199
- }.should raise_error( RuntimeError, "options[:settle][:execution_expression] is required." )
200
-
201
- # 不利な注文
202
- proc {
203
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
204
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
153
+ }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
154
+
155
+ # 有効期限の指定がない
156
+ proc {
157
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
158
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
205
159
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
206
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
207
160
  :settle => {
208
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
161
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
209
162
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
210
163
  }
211
- })
212
- }.should raise_error( RuntimeError )
213
-
214
- proc {
215
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
216
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
217
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
164
+ })
165
+ }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
166
+
167
+ # レートの指定がない
168
+ proc {
169
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
170
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
218
171
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
219
172
  :settle => {
220
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
173
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
221
174
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
222
175
  }
223
176
  })
224
- }.should raise_error( RuntimeError )
225
-
226
- # 決済注文レートが不正
227
- proc {
228
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
229
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
177
+ }.should raise_error( RuntimeError, "options[:rate] is required." )
178
+
179
+ # 決済取引のレートの指定がない
180
+ proc {
181
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
182
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
230
183
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
231
184
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
232
185
  :settle => {
233
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
234
186
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
235
187
  }
236
188
  })
237
- }.should raise_error( RuntimeError )
238
-
239
- proc {
240
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
241
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
189
+ }.should raise_error( RuntimeError, "options[:settle][:rate] is required." )
190
+
191
+ # 決済取引の取引種別の指定がない
192
+ proc {
193
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
194
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
242
195
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
243
196
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
244
197
  :settle => {
245
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
246
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
198
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1
247
199
  }
248
200
  })
249
- }.should raise_error( RuntimeError )
250
- end
251
-
252
- it "IFDOCO" do
253
- # 執行条件の指定がない
254
- proc {
255
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
256
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
257
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
258
- :settle => {
259
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
260
- :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
261
- }
262
- })
263
- }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
264
-
265
- # 有効期限の指定がない
266
- proc {
267
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
268
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
269
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
270
- :settle => {
271
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
272
- :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
273
- }
274
- })
275
- }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
201
+ }.should raise_error( RuntimeError, "options[:settle][:execution_expression] is required." )
202
+
203
+ # 不利な注文
204
+ proc {
205
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
206
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
207
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
208
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
209
+ :settle => {
210
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
211
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
212
+ }
213
+ })
214
+ }.should raise_error( RuntimeError )
215
+
216
+ proc {
217
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
218
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
219
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
220
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
221
+ :settle => {
222
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
223
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
224
+ }
225
+ })
226
+ }.should raise_error( RuntimeError )
227
+
228
+ # 決済注文レートが不正
229
+ proc {
230
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
231
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
232
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
233
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
234
+ :settle => {
235
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
236
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
237
+ }
238
+ })
239
+ }.should raise_error( RuntimeError )
240
+
241
+ proc {
242
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
243
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
244
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
245
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
246
+ :settle => {
247
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
248
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
249
+ }
250
+ })
251
+ }.should raise_error( RuntimeError )
252
+ end
276
253
 
277
- # レートの指定がない
278
- proc {
279
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
280
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
281
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
282
- :settle => {
283
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
284
- :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
285
- }
286
- })
287
- }.should raise_error( RuntimeError, "options[:rate] is required." )
288
-
289
- # 決済取引のレートの指定がない
290
- proc {
291
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
292
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
293
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
294
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
295
- :settle => {
296
- :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
297
- }
298
- })
299
- }.should raise_error( RuntimeError, "options[:settle][:rate] is required." )
300
-
301
- # 不利な注文
302
- proc {
303
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
304
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
305
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
254
+ it "IFDOCO" do
255
+ # 執行条件の指定がない
256
+ proc {
257
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
258
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
306
259
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
307
260
  :settle => {
308
261
  :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
309
262
  :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
310
263
  }
311
- })
312
- }.should raise_error( RuntimeError )
313
-
314
- proc {
315
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
316
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
317
- :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
318
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
264
+ })
265
+ }.should raise_error( RuntimeError, "options[:execution_expression] is required." )
266
+
267
+ # 有効期限の指定がない
268
+ proc {
269
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
270
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
271
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
319
272
  :settle => {
320
273
  :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
321
274
  :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
322
275
  }
323
276
  })
324
- }.should raise_error( RuntimeError )
325
-
326
- # 決済注文レートが不正
327
- proc {
328
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
329
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
277
+ }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
278
+
279
+ # レートの指定がない
280
+ proc {
281
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
330
282
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
331
283
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
332
284
  :settle => {
333
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.8,
285
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
334
286
  :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
335
287
  }
336
288
  })
337
- }.should raise_error( RuntimeError )
338
-
339
- proc {
340
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
341
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
289
+ }.should raise_error( RuntimeError, "options[:rate] is required." )
290
+
291
+ # 決済取引のレートの指定がない
292
+ proc {
293
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
294
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
342
295
  :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
343
296
  :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
344
297
  :settle => {
345
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
346
- :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5
298
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
347
299
  }
348
300
  })
349
- }.should raise_error( RuntimeError )
301
+ }.should raise_error( RuntimeError, "options[:settle][:rate] is required." )
302
+
303
+ # 不利な注文
304
+ proc {
305
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
306
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
307
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
308
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
309
+ :settle => {
310
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
311
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
312
+ }
313
+ })
314
+ }.should raise_error( RuntimeError )
315
+
316
+ proc {
317
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
318
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
319
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
320
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
321
+ :settle => {
322
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
323
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
324
+ }
325
+ })
326
+ }.should raise_error( RuntimeError )
327
+
328
+ # 決済注文レートが不正
329
+ proc {
330
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
331
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
332
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
333
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
334
+ :settle => {
335
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.8,
336
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
337
+ }
338
+ })
339
+ }.should raise_error( RuntimeError )
340
+
341
+ proc {
342
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
343
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
344
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
345
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
346
+ :settle => {
347
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
348
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5
349
+ }
350
+ })
351
+ }.should raise_error( RuntimeError )
352
+ end
353
+
350
354
  end
351
-
352
355
  end
353
356
 
354
357
 
355
358
  describe "trail" do
356
- it_should_behave_like "login"
357
-
358
- it "指値/逆指値" do
359
+ it_should_behave_like "login" do
359
360
 
360
- # 有効期限の指定がない
361
- proc {
362
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
363
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
364
- :trail_range=>0.5
365
- })
366
- }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
361
+ it "指値/逆指値" do
362
+
363
+ # 有効期限の指定がない
364
+ proc {
365
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
366
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
367
+ :trail_range=>0.5
368
+ })
369
+ }.should raise_error( RuntimeError, "options[:expiration_type] is required." )
370
+
371
+ # 日付指定であるのに日時の指定がない
372
+ proc {
373
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
374
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
375
+ :trail_range=>0.5,
376
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED
377
+ })
378
+ }.should raise_error( RuntimeError, "options[:expiration_date] is required." )
379
+
380
+ # 日付指定の範囲が不正
381
+ proc {
382
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
383
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
384
+ :trail_range=>0.5,
385
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
386
+ :expiration_date=>Date.today
387
+ })
388
+ }.should raise_error( RuntimeError )
389
+
390
+ # レートが不正
391
+ proc {
392
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
393
+ :rate=>"-10000000",
394
+ :trail_range=>0.5,
395
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
396
+ })
397
+ }.should raise_error( RuntimeError )
398
+
399
+ # 不利な注文
400
+ proc {
401
+ @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
402
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
403
+ :trail_range=>0.5,
404
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
405
+ })
406
+ }.should raise_error( RuntimeError )
407
+ end
367
408
 
368
- # 日付指定であるのに日時の指定がない
369
- proc {
370
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
371
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
372
- :trail_range=>0.5,
373
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED
374
- })
375
- }.should raise_error( RuntimeError, "options[:expiration_date] is required." )
376
-
377
- # 日付指定の範囲が不正
378
- proc {
379
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
380
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
381
- :trail_range=>0.5,
382
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
383
- :expiration_date=>Date.today
384
- })
385
- }.should raise_error( RuntimeError )
386
-
387
- # レートが不正
388
- proc {
389
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
390
- :rate=>"-10000000",
391
- :trail_range=>0.5,
392
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
393
- })
394
- }.should raise_error( RuntimeError )
395
-
396
- # 不利な注文
397
- proc {
398
- @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 1, {
399
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
400
- :trail_range=>0.5,
401
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
402
- })
403
- }.should raise_error( RuntimeError )
404
409
  end
405
410
  end