sbiclient 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,405 @@
1
+ $: << "../lib"
2
+
3
+ require 'sbiclient'
4
+ require 'common'
5
+
6
+ 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 )
87
+
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,
92
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
93
+ })
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,
122
+ :second_order_sell_or_buy=>SBIClient::FX::BUY,
123
+ :second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
124
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
125
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
126
+ })
127
+ }.should raise_error( RuntimeError )
128
+
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
136
+ })
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,
205
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
206
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
207
+ :settle => {
208
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
209
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
210
+ }
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,
218
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
219
+ :settle => {
220
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
221
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
222
+ }
223
+ })
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,
230
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
231
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
232
+ :settle => {
233
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1,
234
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
235
+ }
236
+ })
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,
242
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
243
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
244
+ :settle => {
245
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
246
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
247
+ }
248
+ })
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." )
276
+
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,
306
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
307
+ :settle => {
308
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
309
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
310
+ }
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,
319
+ :settle => {
320
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
321
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
322
+ }
323
+ })
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,
330
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
331
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
332
+ :settle => {
333
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.8,
334
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 1
335
+ }
336
+ })
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,
342
+ :execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
343
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
344
+ :settle => {
345
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
346
+ :stop_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5
347
+ }
348
+ })
349
+ }.should raise_error( RuntimeError )
350
+ end
351
+
352
+ end
353
+
354
+
355
+ describe "trail" do
356
+ it_should_behave_like "login"
357
+
358
+ it "指値/逆指値" do
359
+
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." )
367
+
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
+ end
405
+ end
@@ -0,0 +1,51 @@
1
+ $: << "../lib"
2
+
3
+ require 'sbiclient'
4
+ require 'common'
5
+
6
+ describe "trail" do
7
+ it_should_behave_like "login"
8
+
9
+ it "買い" do
10
+ @order_id = @s.order( SBIClient::FX::EURUSD, SBIClient::FX::BUY, 1, {
11
+ :rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.05,
12
+ :trail_range=>0.5,
13
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
14
+ })
15
+ @order_id.should_not be_nil
16
+ @order_id.order_no.should_not be_nil
17
+ @order = @s.list_orders[@order_id.order_no]
18
+ @order.should_not be_nil
19
+ @order.order_no.should == @order_id.order_no
20
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
21
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
22
+ @order.sell_or_buy.should == SBIClient::FX::BUY
23
+ @order.pair.should == SBIClient::FX::EURUSD
24
+ @order.count.should == 1
25
+ @order.rate.to_s.should == (@rates[SBIClient::FX::EURUSD].ask_rate + 0.05).to_s
26
+ @order.trail_range.to_s.should == (0.5).to_s
27
+ @order.order_type= SBIClient::FX::ORDER_TYPE_TRAIL
28
+ end
29
+
30
+ it "売り" do
31
+ @order_id = @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 2, {
32
+ :rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
33
+ :trail_range=>1,
34
+ :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED, # 有効期限: 指定
35
+ :expiration_date=>Date.today+2 # 2日後
36
+ })
37
+ @order = @s.list_orders[@order_id.order_no]
38
+ @order_id.should_not be_nil
39
+ @order_id.order_no.should_not be_nil
40
+ @order.should_not be_nil
41
+ @order.order_no.should == @order_id.order_no
42
+ @order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
43
+ @order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
44
+ @order.sell_or_buy.should == SBIClient::FX::SELL
45
+ @order.pair.should == SBIClient::FX::MURJPY
46
+ @order.count.should == 2
47
+ @order.rate.should == @rates[SBIClient::FX::MURJPY].ask_rate - 0.5
48
+ @order.trail_range.to_s.should == (1.0).to_s
49
+ @order.order_type= SBIClient::FX::ORDER_TYPE_TRAIL
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sbiclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masaya Yamauchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-12 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mechanize
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.3
24
+ version:
25
+ description:
26
+ email: y-masaya@red.hot.co.jp
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ files:
34
+ - README
35
+ - lib/jiji_plugin.rb
36
+ - lib/sbiclient.rb
37
+ - sample/common.rb
38
+ - sample/sample_ifd_oco_order.rb
39
+ - sample/sample_ifd_order.rb
40
+ - sample/sample_list_positions.rb
41
+ - sample/sample_list_rates.rb
42
+ - sample/sample_oco_order.rb
43
+ - sample/sample_order.rb
44
+ - sample/sample_settle.rb
45
+ - sample/sample_trail_order.rb
46
+ - spec/cancel_order_spec.rb
47
+ - spec/common.rb
48
+ - spec/ifd_oco_order_spec.rb
49
+ - spec/ifd_order_spec.rb
50
+ - spec/jiji_plugin_spec!.rb
51
+ - spec/limit_order_spec.rb
52
+ - spec/list_orders_spec.rb
53
+ - spec/market_order_spec!.rb
54
+ - spec/oco_order_spec.rb
55
+ - spec/order_error_spec.rb
56
+ - spec/trail_order_spec.rb
57
+ has_rdoc: true
58
+ homepage: http://github.com/unageanu/sbiclient/tree/master
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --main
64
+ - README
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 1.3.5
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: SBI securities client library for ruby.
86
+ test_files:
87
+ - sample/common.rb
88
+ - sample/sample_ifd_oco_order.rb
89
+ - sample/sample_ifd_order.rb
90
+ - sample/sample_list_positions.rb
91
+ - sample/sample_list_rates.rb
92
+ - sample/sample_oco_order.rb
93
+ - sample/sample_order.rb
94
+ - sample/sample_settle.rb
95
+ - sample/sample_trail_order.rb
96
+ - spec/cancel_order_spec.rb
97
+ - spec/common.rb
98
+ - spec/ifd_oco_order_spec.rb
99
+ - spec/ifd_order_spec.rb
100
+ - spec/jiji_plugin_spec!.rb
101
+ - spec/limit_order_spec.rb
102
+ - spec/list_orders_spec.rb
103
+ - spec/market_order_spec!.rb
104
+ - spec/oco_order_spec.rb
105
+ - spec/order_error_spec.rb
106
+ - spec/trail_order_spec.rb