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/ChangeLog
ADDED
data/README
CHANGED
File without changes
|
data/lib/jiji_plugin.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
3
|
require 'rubygems'
|
3
4
|
require 'jiji/plugin/securities_plugin'
|
@@ -37,11 +38,7 @@ class SBISecuritiesPlugin
|
|
37
38
|
def list_pairs
|
38
39
|
return ALL_PAIRS.map {|pair|
|
39
40
|
count = 10000
|
40
|
-
if pair == SBIClient::FX::MSDJPY
|
41
|
-
|| pair == SBIClient::FX::MURJPY \
|
42
|
-
|| pair == SBIClient::FX::MBPJPY \
|
43
|
-
|| pair == SBIClient::FX::MUDJPY \
|
44
|
-
|| pair == SBIClient::FX::MZDJPY
|
41
|
+
if pair == SBIClient::FX::MSDJPY || pair == SBIClient::FX::MURJPY || pair == SBIClient::FX::MBPJPY || pair == SBIClient::FX::MUDJPY || pair == SBIClient::FX::MZDJPY
|
45
42
|
count = 1000
|
46
43
|
elsif pair == SBIClient::FX::ZARJPY
|
47
44
|
count = 100000
|
data/lib/sbiclient.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'rubygems'
|
3
5
|
rescue LoadError
|
@@ -47,7 +49,7 @@ module SBIClient
|
|
47
49
|
# 例) https://proxyhost.com:80
|
48
50
|
#
|
49
51
|
def initialize( proxy=nil )
|
50
|
-
@client =
|
52
|
+
@client = Mechanize.new {|c|
|
51
53
|
# プロキシ
|
52
54
|
if proxy
|
53
55
|
uri = URI.parse( proxy )
|
@@ -56,7 +58,7 @@ module SBIClient
|
|
56
58
|
}
|
57
59
|
@client.keep_alive = false
|
58
60
|
@client.max_history=0
|
59
|
-
|
61
|
+
Mechanize::AGENT_ALIASES["KDDI-CA39"] = \
|
60
62
|
'KDDI-CA39 UP.Browser/6.2.0.13.1.5 (GUI) MMP/2.0'
|
61
63
|
@client.user_agent_alias = "KDDI-CA39"
|
62
64
|
@host_name = DEFAULT_HOST_NAME
|
@@ -72,6 +74,7 @@ module SBIClient
|
|
72
74
|
#options:: オプション
|
73
75
|
#戻り値:: SBIClient::FX::FxSession
|
74
76
|
def fx_session( userid, password, order_password, options={}, &block )
|
77
|
+
|
75
78
|
# ログイン
|
76
79
|
page = @client.get(@host_name)
|
77
80
|
SBIClient::Client.error(page) if page.forms.length <= 0
|
data/sample/common.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
|
-
# ※「../etc
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# ※「../etc/auth.yaml」を作成し、以下の内容を設定しておくこと。
|
4
|
+
# <pre>
|
5
|
+
# ---
|
6
|
+
# user: <SBI証券のアクセスユーザー名>
|
7
|
+
# pass: <SBI証券のアクセスユーザーパスワード>
|
8
|
+
# order_pass: <SBI証券の取引パスワード>
|
9
|
+
# </pre>
|
10
|
+
require 'yaml'
|
11
|
+
|
12
|
+
auth = YAML.load_file "#{File.dirname(__FILE__)}/../etc/auth.yaml"
|
13
|
+
USER=auth["user"]
|
14
|
+
PASS=auth["pass"]
|
15
|
+
ORDER_PASS=auth["order_pass"]# 取引パスワード
|
7
16
|
|
8
17
|
#注文一覧を出力する。
|
9
18
|
#session:: Session
|
data/sample/sample_ifd_order.rb
CHANGED
data/sample/sample_list_rates.rb
CHANGED
data/sample/sample_oco_order.rb
CHANGED
data/sample/sample_order.rb
CHANGED
data/sample/sample_settle.rb
CHANGED
data/spec/cancel_order_spec.rb
CHANGED
@@ -1,62 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
$: << "../lib"
|
2
4
|
|
3
5
|
require 'sbiclient'
|
4
6
|
require 'common'
|
5
7
|
|
6
8
|
describe "cancel_order" do
|
7
|
-
it_should_behave_like "login"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
it "複数のページがあってもキャンセルできる" do
|
14
|
-
3.times{|i|
|
15
|
-
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
16
|
-
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
17
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
18
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
|
19
|
-
})
|
20
|
-
}
|
21
|
-
3.times{|i|
|
22
|
-
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
23
|
-
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
24
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
25
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
26
|
-
:settle => {
|
27
|
-
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
|
28
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
29
|
-
}
|
30
|
-
})
|
31
|
-
}
|
32
|
-
2.times{|i|
|
33
|
-
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
34
|
-
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
35
|
-
:second_order_sell_or_buy=>SBIClient::FX::BUY,
|
36
|
-
:second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
|
37
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
38
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
|
39
|
-
})
|
9
|
+
it_should_behave_like "login" do
|
10
|
+
before { @order_ids = [] }
|
11
|
+
after {
|
12
|
+
@order_ids.each {|id| @s.cancel_order(id.order_no) }
|
40
13
|
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
14
|
+
|
15
|
+
it "複数のページがあってもキャンセルできる" do
|
16
|
+
3.times{|i|
|
17
|
+
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
18
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
19
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
20
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
|
21
|
+
})
|
22
|
+
}
|
23
|
+
3.times{|i|
|
24
|
+
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
25
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
26
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
27
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
28
|
+
:settle => {
|
29
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
|
30
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
31
|
+
}
|
32
|
+
})
|
33
|
+
}
|
34
|
+
2.times{|i|
|
35
|
+
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
36
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
37
|
+
:second_order_sell_or_buy=>SBIClient::FX::BUY,
|
38
|
+
:second_order_rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
|
39
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
40
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
|
41
|
+
})
|
42
|
+
}
|
43
|
+
3.times{|i|
|
44
|
+
@order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
|
45
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
|
46
|
+
:trail_range=>0.5,
|
47
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
|
48
|
+
})
|
49
|
+
}
|
50
|
+
# 末尾から消していき、すべて削除できればOK。
|
51
|
+
@order_ids.reverse.each {|id|
|
52
|
+
@s.cancel_order(id.order_no)
|
53
|
+
@order_ids.pop
|
54
|
+
}
|
55
|
+
@s.list_orders.size.should == 0
|
56
|
+
end
|
57
|
+
|
58
|
+
it "削除対象が存在しない" do
|
59
|
+
proc {
|
60
|
+
@s.cancel_order("not found")
|
61
|
+
}.should raise_error( RuntimeError, "illegal order_no. order_no=not found" )
|
62
|
+
end
|
63
|
+
|
60
64
|
end
|
61
|
-
|
62
65
|
end
|
data/spec/common.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
|
-
# ※「../etc
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# ※「../etc/auth.yaml」を作成し、以下の内容を設定しておくこと。
|
4
|
+
# <pre>
|
5
|
+
# ---
|
6
|
+
# user: <SBI証券のアクセスユーザー名>
|
7
|
+
# pass: <SBI証券のアクセスユーザーパスワード>
|
8
|
+
# order_pass: <SBI証券の取引パスワード>
|
9
|
+
# </pre>
|
10
|
+
require 'yaml'
|
11
|
+
|
12
|
+
auth = YAML.load_file "#{File.dirname(__FILE__)}/../etc/auth.yaml"
|
13
|
+
USER=auth["user"]
|
14
|
+
PASS=auth["pass"]
|
15
|
+
ORDER_PASS=auth["order_pass"]# 取引パスワード
|
7
16
|
|
8
17
|
# ログインする
|
9
18
|
shared_examples_for "login" do
|
@@ -18,3 +27,7 @@ shared_examples_for "login" do
|
|
18
27
|
before { @order_id = nil }
|
19
28
|
after { @s.cancel_order(@order_id.order_no) if @order_id }
|
20
29
|
end
|
30
|
+
|
31
|
+
def normalize_rate(rate)
|
32
|
+
((rate * 100000).floor / 100000.0).to_s
|
33
|
+
end
|
data/spec/ifd_oco_order_spec.rb
CHANGED
@@ -1,59 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
$: << "../lib"
|
2
4
|
|
3
5
|
require 'sbiclient'
|
4
6
|
require 'common'
|
5
7
|
|
6
8
|
describe "IFDOCO" do
|
7
|
-
it_should_behave_like "login"
|
9
|
+
it_should_behave_like "login" do
|
10
|
+
|
11
|
+
it "指値" do
|
12
|
+
@order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
|
13
|
+
:rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
|
14
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
15
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
16
|
+
:settle => {
|
17
|
+
:rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
|
18
|
+
:stop_order_rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 1
|
19
|
+
}
|
20
|
+
})
|
21
|
+
orders = @s.list_orders
|
22
|
+
@order = orders[@order_id.order_no]
|
23
|
+
@order_id.should_not be_nil
|
24
|
+
@order_id.order_no.should_not be_nil
|
25
|
+
@order.should_not be_nil
|
26
|
+
@order.order_no.should == @order_id.order_no
|
27
|
+
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
28
|
+
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
29
|
+
@order.sell_or_buy.should == SBIClient::FX::BUY
|
30
|
+
@order.pair.should == SBIClient::FX::EURJPY
|
31
|
+
@order.count.should == 1
|
32
|
+
normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURJPY].ask_rate - 0.5)
|
33
|
+
@order.trail_range.should be_nil
|
34
|
+
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD_OCO
|
35
|
+
end
|
8
36
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
it "逆指値" do
|
36
|
-
@order_id = @s.order( SBIClient::FX::EURUSD, SBIClient::FX::BUY, 1, {
|
37
|
-
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.05,
|
38
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
39
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
40
|
-
:settle => {
|
41
|
-
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.1,
|
42
|
-
:stop_order_rate=>@rates[SBIClient::FX::EURUSD].ask_rate-0.05
|
43
|
-
}
|
44
|
-
})
|
45
|
-
@order_id.should_not be_nil
|
46
|
-
@order_id.order_no.should_not be_nil
|
47
|
-
@order = @s.list_orders[@order_id.order_no]
|
48
|
-
@order.should_not be_nil
|
49
|
-
@order.order_no.should == @order_id.order_no
|
50
|
-
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
51
|
-
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
52
|
-
@order.sell_or_buy.should == SBIClient::FX::BUY
|
53
|
-
@order.pair.should == SBIClient::FX::EURUSD
|
54
|
-
@order.count.should == 1
|
55
|
-
@order.rate.to_s.should == (@rates[SBIClient::FX::EURUSD].ask_rate + 0.05).to_s
|
56
|
-
@order.trail_range.should be_nil
|
57
|
-
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD_OCO
|
37
|
+
it "逆指値" do
|
38
|
+
@order_id = @s.order( SBIClient::FX::EURUSD, SBIClient::FX::BUY, 1, {
|
39
|
+
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.05,
|
40
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
41
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
42
|
+
:settle => {
|
43
|
+
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.1,
|
44
|
+
:stop_order_rate=>@rates[SBIClient::FX::EURUSD].ask_rate-0.05
|
45
|
+
}
|
46
|
+
})
|
47
|
+
@order_id.should_not be_nil
|
48
|
+
@order_id.order_no.should_not be_nil
|
49
|
+
@order = @s.list_orders[@order_id.order_no]
|
50
|
+
@order.should_not be_nil
|
51
|
+
@order.order_no.should == @order_id.order_no
|
52
|
+
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
53
|
+
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
54
|
+
@order.sell_or_buy.should == SBIClient::FX::BUY
|
55
|
+
@order.pair.should == SBIClient::FX::EURUSD
|
56
|
+
@order.count.should == 1
|
57
|
+
normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURUSD].ask_rate + 0.05)
|
58
|
+
@order.trail_range.should be_nil
|
59
|
+
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD_OCO
|
60
|
+
end
|
61
|
+
|
58
62
|
end
|
59
63
|
end
|
data/spec/ifd_order_spec.rb
CHANGED
@@ -1,110 +1,114 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
$: << "../lib"
|
2
4
|
|
3
5
|
require 'sbiclient'
|
4
6
|
require 'common'
|
5
7
|
|
6
8
|
describe "IFD" do
|
7
|
-
it_should_behave_like "login"
|
9
|
+
it_should_behave_like "login" do
|
10
|
+
|
11
|
+
it "指値-指値" do
|
12
|
+
@order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
|
13
|
+
:rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
|
14
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
15
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
16
|
+
:settle => {
|
17
|
+
:rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
|
18
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
19
|
+
}
|
20
|
+
})
|
21
|
+
orders = @s.list_orders
|
22
|
+
@order = orders[@order_id.order_no]
|
23
|
+
@order_id.should_not be_nil
|
24
|
+
@order_id.order_no.should_not be_nil
|
25
|
+
@order.should_not be_nil
|
26
|
+
@order.order_no.should == @order_id.order_no
|
27
|
+
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
28
|
+
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
29
|
+
@order.sell_or_buy.should == SBIClient::FX::BUY
|
30
|
+
@order.pair.should == SBIClient::FX::EURJPY
|
31
|
+
@order.count.should == 1
|
32
|
+
normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURJPY].ask_rate - 0.5)
|
33
|
+
@order.trail_range.should be_nil
|
34
|
+
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
35
|
+
end
|
36
|
+
|
37
|
+
it "指値-逆指値" do
|
38
|
+
@order_id = @s.order( SBIClient::FX::USDJPY, SBIClient::FX::SELL, 1, {
|
39
|
+
:rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 0.5,
|
40
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
41
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_WEEK_END,
|
42
|
+
:settle => {
|
43
|
+
:rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 1,
|
44
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
45
|
+
}
|
46
|
+
})
|
47
|
+
@order = @s.list_orders[@order_id.order_no]
|
48
|
+
@order_id.should_not be_nil
|
49
|
+
@order_id.order_no.should_not be_nil
|
50
|
+
@order.should_not be_nil
|
51
|
+
@order.order_no.should == @order_id.order_no
|
52
|
+
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
53
|
+
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
54
|
+
@order.sell_or_buy.should == SBIClient::FX::SELL
|
55
|
+
@order.pair.should == SBIClient::FX::USDJPY
|
56
|
+
@order.count.should == 1
|
57
|
+
normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::USDJPY].ask_rate + 0.5)
|
58
|
+
@order.trail_range.should be_nil
|
59
|
+
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
60
|
+
end
|
61
|
+
|
62
|
+
it "逆指値-逆指値" do
|
63
|
+
@order_id = @s.order( SBIClient::FX::EURUSD, SBIClient::FX::BUY, 1, {
|
64
|
+
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.05,
|
65
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
66
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
67
|
+
:settle => {
|
68
|
+
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate,
|
69
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
70
|
+
}
|
71
|
+
})
|
72
|
+
@order_id.should_not be_nil
|
73
|
+
@order_id.order_no.should_not be_nil
|
74
|
+
@order = @s.list_orders[@order_id.order_no]
|
75
|
+
@order.should_not be_nil
|
76
|
+
@order.order_no.should == @order_id.order_no
|
77
|
+
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
78
|
+
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
79
|
+
@order.sell_or_buy.should == SBIClient::FX::BUY
|
80
|
+
@order.pair.should == SBIClient::FX::EURUSD
|
81
|
+
@order.count.should == 1
|
82
|
+
normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::EURUSD].ask_rate + 0.05)
|
83
|
+
@order.trail_range.should be_nil
|
84
|
+
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
85
|
+
end
|
86
|
+
|
87
|
+
it "逆指値-指値" do
|
88
|
+
@order_id = @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 2, {
|
89
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
90
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
91
|
+
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
|
92
|
+
:expiration_date=>Date.today+2,
|
93
|
+
:settle => {
|
94
|
+
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
|
95
|
+
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
96
|
+
}
|
97
|
+
})
|
98
|
+
@order = @s.list_orders[@order_id.order_no]
|
99
|
+
@order_id.should_not be_nil
|
100
|
+
@order_id.order_no.should_not be_nil
|
101
|
+
@order.should_not be_nil
|
102
|
+
@order.order_no.should == @order_id.order_no
|
103
|
+
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
104
|
+
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
105
|
+
@order.sell_or_buy.should == SBIClient::FX::SELL
|
106
|
+
@order.pair.should == SBIClient::FX::MURJPY
|
107
|
+
@order.count.should == 2
|
108
|
+
normalize_rate(@order.rate).should == normalize_rate(@rates[SBIClient::FX::MURJPY].ask_rate - 0.5)
|
109
|
+
@order.trail_range.should be_nil
|
110
|
+
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
111
|
+
end
|
8
112
|
|
9
|
-
it "指値-指値" do
|
10
|
-
@order_id = @s.order( SBIClient::FX::EURJPY, SBIClient::FX::BUY, 1, {
|
11
|
-
:rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 0.5,
|
12
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
13
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
14
|
-
:settle => {
|
15
|
-
:rate=>@rates[SBIClient::FX::EURJPY].ask_rate + 0.5,
|
16
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
17
|
-
}
|
18
|
-
})
|
19
|
-
orders = @s.list_orders
|
20
|
-
@order = orders[@order_id.order_no]
|
21
|
-
@order_id.should_not be_nil
|
22
|
-
@order_id.order_no.should_not be_nil
|
23
|
-
@order.should_not be_nil
|
24
|
-
@order.order_no.should == @order_id.order_no
|
25
|
-
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
26
|
-
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
27
|
-
@order.sell_or_buy.should == SBIClient::FX::BUY
|
28
|
-
@order.pair.should == SBIClient::FX::EURJPY
|
29
|
-
@order.count.should == 1
|
30
|
-
@order.rate.should == @rates[SBIClient::FX::EURJPY].ask_rate - 0.5
|
31
|
-
@order.trail_range.should be_nil
|
32
|
-
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
33
|
-
end
|
34
|
-
|
35
|
-
it "指値-逆指値" do
|
36
|
-
@order_id = @s.order( SBIClient::FX::USDJPY, SBIClient::FX::SELL, 1, {
|
37
|
-
:rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 0.5,
|
38
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER,
|
39
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_WEEK_END,
|
40
|
-
:settle => {
|
41
|
-
:rate=>@rates[SBIClient::FX::USDJPY].ask_rate + 1,
|
42
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
43
|
-
}
|
44
|
-
})
|
45
|
-
@order = @s.list_orders[@order_id.order_no]
|
46
|
-
@order_id.should_not be_nil
|
47
|
-
@order_id.order_no.should_not be_nil
|
48
|
-
@order.should_not be_nil
|
49
|
-
@order.order_no.should == @order_id.order_no
|
50
|
-
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
51
|
-
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
52
|
-
@order.sell_or_buy.should == SBIClient::FX::SELL
|
53
|
-
@order.pair.should == SBIClient::FX::USDJPY
|
54
|
-
@order.count.should == 1
|
55
|
-
@order.rate.should == @rates[SBIClient::FX::USDJPY].ask_rate + 0.5
|
56
|
-
@order.trail_range.should be_nil
|
57
|
-
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
58
|
-
end
|
59
|
-
|
60
|
-
it "逆指値-逆指値" do
|
61
|
-
@order_id = @s.order( SBIClient::FX::EURUSD, SBIClient::FX::BUY, 1, {
|
62
|
-
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate + 0.05,
|
63
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
64
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY,
|
65
|
-
:settle => {
|
66
|
-
:rate=>@rates[SBIClient::FX::EURUSD].ask_rate,
|
67
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
68
|
-
}
|
69
|
-
})
|
70
|
-
@order_id.should_not be_nil
|
71
|
-
@order_id.order_no.should_not be_nil
|
72
|
-
@order = @s.list_orders[@order_id.order_no]
|
73
|
-
@order.should_not be_nil
|
74
|
-
@order.order_no.should == @order_id.order_no
|
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::BUY
|
78
|
-
@order.pair.should == SBIClient::FX::EURUSD
|
79
|
-
@order.count.should == 1
|
80
|
-
@order.rate.to_s.should == (@rates[SBIClient::FX::EURUSD].ask_rate + 0.05).to_s
|
81
|
-
@order.trail_range.should be_nil
|
82
|
-
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
83
|
-
end
|
84
|
-
|
85
|
-
it "逆指値-指値" do
|
86
|
-
@order_id = @s.order( SBIClient::FX::MURJPY, SBIClient::FX::SELL, 2, {
|
87
|
-
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 0.5,
|
88
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER,
|
89
|
-
:expiration_type=>SBIClient::FX::EXPIRATION_TYPE_SPECIFIED,
|
90
|
-
:expiration_date=>Date.today+2,
|
91
|
-
:settle => {
|
92
|
-
:rate=>@rates[SBIClient::FX::MURJPY].ask_rate - 1,
|
93
|
-
:execution_expression=>SBIClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER
|
94
|
-
}
|
95
|
-
})
|
96
|
-
@order = @s.list_orders[@order_id.order_no]
|
97
|
-
@order_id.should_not be_nil
|
98
|
-
@order_id.order_no.should_not be_nil
|
99
|
-
@order.should_not be_nil
|
100
|
-
@order.order_no.should == @order_id.order_no
|
101
|
-
@order.trade_type.should == SBIClient::FX::TRADE_TYPE_NEW
|
102
|
-
@order.execution_expression.should == SBIClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER
|
103
|
-
@order.sell_or_buy.should == SBIClient::FX::SELL
|
104
|
-
@order.pair.should == SBIClient::FX::MURJPY
|
105
|
-
@order.count.should == 2
|
106
|
-
@order.rate.should == @rates[SBIClient::FX::MURJPY].ask_rate - 0.5
|
107
|
-
@order.trail_range.should be_nil
|
108
|
-
@order.order_type= SBIClient::FX::ORDER_TYPE_IFD
|
109
113
|
end
|
110
114
|
end
|