sbiclient 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +13 -0
- data/README +0 -0
- data/lib/jiji_plugin.rb +2 -5
- data/lib/sbiclient.rb +5 -2
- data/sample/common.rb +14 -5
- data/sample/sample_ifd_oco_order.rb +2 -0
- data/sample/sample_ifd_order.rb +2 -0
- data/sample/sample_list_positions.rb +2 -0
- data/sample/sample_list_rates.rb +2 -0
- data/sample/sample_oco_order.rb +2 -0
- data/sample/sample_order.rb +2 -0
- data/sample/sample_settle.rb +2 -0
- data/sample/sample_trail_order.rb +2 -0
- data/spec/cancel_order_spec.rb +56 -53
- data/spec/common.rb +18 -5
- data/spec/ifd_oco_order_spec.rb +54 -50
- data/spec/ifd_order_spec.rb +105 -101
- data/spec/jiji_plugin_daily_spec.rb +63 -0
- data/spec/jiji_plugin_spec!.rb +2 -32
- data/spec/limit_order_spec.rb +88 -84
- data/spec/list_orders_spec.rb +47 -42
- data/spec/market_order_spec!.rb +39 -35
- data/spec/oco_order_spec.rb +294 -290
- data/spec/order_error_spec.rb +344 -339
- data/spec/trail_order_spec.rb +46 -42
- metadata +31 -10
data/spec/oco_order_spec.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
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
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
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
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
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
|