sbiclient 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+
2
+ 2010-11-07 0.1.4
3
+ * ruby1.9対応
4
+
5
+ 2010-04-14 0.1.3
6
+ * 0.1.2で追加したレスポンス本文が文字化けする問題を修正。
7
+
8
+ 2010-03-21 0.1.2
9
+ * 決済でエラーが発生した場合、その時点のレスポンス本文を例外に含めるように修正
10
+
11
+ 2010-01-19 0.1.1
12
+ * 一定時間経過すると強制的にログアウト状態になる問題に対応。レート情報取得でのログアウトを検知したら
13
+  再ログインを行うようにした。
data/README CHANGED
File without changes
@@ -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
@@ -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 = WWW::Mechanize.new {|c|
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
- WWW::Mechanize::AGENT_ALIASES["KDDI-CA39"] = \
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
@@ -1,9 +1,18 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
2
- # ※「../etc」ディレクトリにuser,passファイルを作成し、
3
- # ユーザー名,パスワードを設定しておくこと。
4
- USER=IO.read("../etc/user")
5
- PASS=IO.read("../etc/pass")
6
- ORDER_PASS=IO.read("../etc/order_pass") # 取引パスワード
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
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -1,4 +1,6 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
3
+ $: << "."
2
4
  $: << "../lib"
3
5
 
4
6
  require 'sbiclient'
@@ -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
- before { @order_ids = [] }
9
- after {
10
- @order_ids.each {|id| @s.cancel_order(id.order_no) }
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
- 3.times{|i|
42
- @order_ids << @s.order( SBIClient::FX::MURJPY, SBIClient::FX::BUY, 1, {
43
- :rate=>@rates[SBIClient::FX::MURJPY].ask_rate + 0.5,
44
- :trail_range=>0.5,
45
- :expiration_type=>SBIClient::FX::EXPIRATION_TYPE_TODAY
46
- })
47
- }
48
- # 末尾から消していき、すべて削除できればOK。
49
- @order_ids.reverse.each {|id|
50
- @s.cancel_order(id.order_no)
51
- @order_ids.pop
52
- }
53
- @s.list_orders.size.should == 0
54
- end
55
-
56
- it "削除対象が存在しない" do
57
- proc {
58
- @s.cancel_order("not found")
59
- }.should raise_error( RuntimeError, "illegal order_no. order_no=not found" )
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
@@ -1,9 +1,18 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
2
- # ※「../etc」ディレクトリにuser,passファイルを作成し、
3
- # ユーザー名,パスワードを設定しておくこと。
4
- USER=IO.read("../etc/user")
5
- PASS=IO.read("../etc/pass")
6
- ORDER_PASS=IO.read("../etc/order_pass") # 取引パスワード
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
@@ -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
- 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
- :stop_order_rate=>@rates[SBIClient::FX::EURJPY].ask_rate - 1
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_OCO
33
- end
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
@@ -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