unageanu-clickclient_scrap 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -0
- data/lib/clickclient_scrap.rb +229 -124
- metadata +2 -2
data/README
CHANGED
data/lib/clickclient_scrap.rb
CHANGED
@@ -2,8 +2,7 @@ begin
|
|
2
2
|
require 'rubygems'
|
3
3
|
rescue LoadError
|
4
4
|
end
|
5
|
-
require '
|
6
|
-
require 'rexml/document'
|
5
|
+
require 'mechanize'
|
7
6
|
require 'date'
|
8
7
|
require 'kconv'
|
9
8
|
|
@@ -16,11 +15,6 @@ require 'kconv'
|
|
16
15
|
#クリック証券を利用するためのクライアントライブラリです。携帯向けサイトのスクレイピングにより以下の機能を提供します。
|
17
16
|
#- 外為証拠金取引(FX)取引
|
18
17
|
#
|
19
|
-
#====依存モジュール
|
20
|
-
#「{httpclient}[http://dev.ctor.org/http-access2]」を利用しています。以下のコマンドを実行してインストールしてください。
|
21
|
-
#
|
22
|
-
# gem install httpclient --source http://dev.ctor.org/download/
|
23
|
-
#
|
24
18
|
#====基本的な使い方
|
25
19
|
#
|
26
20
|
# require 'clickclient'
|
@@ -29,7 +23,7 @@ require 'kconv'
|
|
29
23
|
# # c = ClickClient::Client.new https://<プロキシホスト>:<プロキシポート> # プロキシを利用する場合
|
30
24
|
# c.fx_session( "<ユーザー名>", "<パスワード>" ) { | fx_session |
|
31
25
|
# # 通貨ペア一覧取得
|
32
|
-
# list = fx_session.
|
26
|
+
# list = fx_session.list_rates
|
33
27
|
# puts list
|
34
28
|
# }
|
35
29
|
#
|
@@ -42,8 +36,66 @@ module ClickClient
|
|
42
36
|
# クライアント
|
43
37
|
class Client
|
44
38
|
# ホスト名
|
45
|
-
DEFAULT_HOST_NAME = "https://sec-sso.click-sec.com/mf"
|
39
|
+
DEFAULT_HOST_NAME = "https://sec-sso.click-sec.com/mf/"
|
46
40
|
|
41
|
+
#
|
42
|
+
#===コンストラクタ
|
43
|
+
#
|
44
|
+
#*proxy*:: プロキシホストを利用する場合、そのホスト名とパスを指定します。
|
45
|
+
# 例) https://proxyhost.com:80
|
46
|
+
#
|
47
|
+
def initialize( proxy=nil )
|
48
|
+
@client = WWW::Mechanize.new {|c|
|
49
|
+
# プロキシ
|
50
|
+
if proxy
|
51
|
+
uri = URI.parse( proxy )
|
52
|
+
c.set_proxy( uri.host, uri.port )
|
53
|
+
end
|
54
|
+
}
|
55
|
+
@client.user_agent_alias = 'Windows IE 7'
|
56
|
+
@host_name = DEFAULT_HOST_NAME
|
57
|
+
end
|
58
|
+
|
59
|
+
#ログインし、セッションを開始します。
|
60
|
+
#-ブロックを指定した場合、引数としてセッションを指定してブロックを実行します。ブロック実行後、ログアウトします。
|
61
|
+
#-そうでない場合、セッションを返却します。この場合、ClickClient::FX::FxSession#logoutを実行しログアウトしてください。
|
62
|
+
#
|
63
|
+
#戻り値:: ClickClient::FX::FxSession
|
64
|
+
def fx_session( userid, password, &block )
|
65
|
+
page = @client.get(@host_name)
|
66
|
+
ClickClient::Client.error(page) if page.forms.length <= 0
|
67
|
+
form = page.forms.first
|
68
|
+
form.j_username = userid
|
69
|
+
form.j_password = password
|
70
|
+
result = @client.submit(form, form.buttons.first)
|
71
|
+
if result.body.toutf8 =~ /<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=([^"]*)">/
|
72
|
+
result = @client.get($1)
|
73
|
+
session = FX::FxSession.new( @client, result.links )
|
74
|
+
if block_given?
|
75
|
+
begin
|
76
|
+
yield session
|
77
|
+
ensure
|
78
|
+
session.logout
|
79
|
+
end
|
80
|
+
else
|
81
|
+
return session
|
82
|
+
end
|
83
|
+
else
|
84
|
+
ClickClient::Client.error( result )
|
85
|
+
end
|
86
|
+
end
|
87
|
+
def self.error( page )
|
88
|
+
msgs = page.body.scan( /<font color="red">([^<]*)</ ).flatten
|
89
|
+
error = !msgs.empty? ? msgs.map{|m| m.strip}.join(",") : page.body
|
90
|
+
raise "operation failed.detail=#{error}".toutf8
|
91
|
+
end
|
92
|
+
|
93
|
+
#ホスト名
|
94
|
+
attr :host_name, true
|
95
|
+
end
|
96
|
+
|
97
|
+
module FX
|
98
|
+
|
47
99
|
# 通貨ペア: 米ドル-円
|
48
100
|
USDJPY = :USDJPY
|
49
101
|
# 通貨ペア: ユーロ-円
|
@@ -79,88 +131,52 @@ module ClickClient
|
|
79
131
|
SELL = 1
|
80
132
|
|
81
133
|
# 注文タイプ: 通常
|
82
|
-
|
134
|
+
ORDER_TYPE_MARKET_ORDER = "00"
|
135
|
+
# 注文タイプ: 通常
|
136
|
+
ORDER_TYPE_NORMAL = "01"
|
83
137
|
# 注文タイプ: IFD
|
84
|
-
ORDER_TYPE_IFD =
|
138
|
+
ORDER_TYPE_IFD = "11"
|
85
139
|
# 注文タイプ: OCO
|
86
|
-
ORDER_TYPE_OCO =
|
140
|
+
ORDER_TYPE_OCO = "21"
|
87
141
|
# 注文タイプ: IFD-OCO
|
88
|
-
ORDER_TYPE_IFD_OCO =
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
#
|
97
|
-
def initialize( proxy=nil )
|
98
|
-
@client = HTTPClient.new( proxy, "Mozilla/5.0")
|
99
|
-
#@client.debug_dev=STDOUT
|
100
|
-
@client.set_cookie_store("cookie.dat")
|
101
|
-
@host_name = DEFAULT_HOST_NAME
|
102
|
-
end
|
142
|
+
ORDER_TYPE_IFD_OCO = "31"
|
143
|
+
|
144
|
+
# 執行条件: 成行
|
145
|
+
EXECUTION_EXPRESSION_MARKET_ORDER = 0
|
146
|
+
# 執行条件: 指値
|
147
|
+
EXECUTION_EXPRESSION_LIMIT_ORDER = 1
|
148
|
+
# 執行条件: 逆指値
|
149
|
+
EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER = 2
|
103
150
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
result = @client.post_content("#{@host_name}/sso-redirect", {
|
113
|
-
"j_username"=>userid,
|
114
|
-
"j_password"=>password,
|
115
|
-
"LoginForm"=>"ログイン".tosjis,
|
116
|
-
"s"=>"02",
|
117
|
-
"p"=>"80"
|
118
|
-
})
|
119
|
-
if result.toutf8 =~ /<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=([^"]*)">/
|
120
|
-
uri = URI.parse( $1 )
|
121
|
-
base = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
122
|
-
result = @client.get_content($1)
|
123
|
-
commands = result.toutf8.scan( /<a[^>]*?href="([^"]*)"[^>]*>([^<]*)<\/a>/).inject({}) {|r,l|
|
124
|
-
r[l[1]] = "#{base}#{l[0]}"; r
|
125
|
-
}
|
126
|
-
session = FX::FxSession.new( @client, commands )
|
127
|
-
if block_given?
|
128
|
-
begin
|
129
|
-
yield session
|
130
|
-
ensure
|
131
|
-
session.logout
|
132
|
-
end
|
133
|
-
else
|
134
|
-
return session
|
135
|
-
end
|
136
|
-
else
|
137
|
-
error = result.toutf8 =~ /<font color="red">([^<]*)</ ? $1.strip : result
|
138
|
-
raise "login failed.detail=#{error}".toutf8
|
139
|
-
end
|
140
|
-
end
|
151
|
+
# 有効期限: 当日限り
|
152
|
+
EXPIRATION_TYPE_TODAY = 0
|
153
|
+
# 有効期限: 週末まで
|
154
|
+
EXPIRATION_TYPE_WEEK_END = 1
|
155
|
+
# 有効期限: 無期限
|
156
|
+
EXPIRATION_TYPE_INFINITY = 2
|
157
|
+
# 有効期限: 日付指定
|
158
|
+
EXPIRATION_TYPE_SPECIFIED = 3
|
141
159
|
|
142
|
-
#ホスト名
|
143
|
-
attr :host_name, true
|
144
|
-
end
|
145
|
-
|
146
|
-
module FX
|
147
160
|
#=== FX取引のためのセッションクラス
|
148
161
|
#Client#fx_sessionのブロックの引数として渡されます。詳細はClient#fx_sessionを参照ください。
|
149
162
|
class FxSession
|
150
163
|
|
151
|
-
def initialize( client,
|
164
|
+
def initialize( client, links )
|
152
165
|
@client = client
|
153
|
-
@
|
166
|
+
@links = links
|
154
167
|
end
|
168
|
+
|
155
169
|
#レート一覧を取得します。
|
156
170
|
#
|
157
171
|
#戻り値:: 通貨ペアをキーとするClickClient::FX::Rateのハッシュ。
|
158
172
|
def list_rates
|
159
|
-
result =
|
173
|
+
result = @client.click( @links.find {|i|
|
174
|
+
i.attributes["accesskey"] == "1"
|
175
|
+
})
|
160
176
|
@swaps = list_swaps unless @swaps
|
161
177
|
reg = />([A-Z]+\/[A-Z]+)<\/a>[^\-\.\d]*?([\d]+\.[\d]+\-[\d]+)/
|
162
|
-
return result.toutf8.scan( reg ).inject({}) {|r,l|
|
163
|
-
pair = l[0]
|
178
|
+
return result.body.toutf8.scan( reg ).inject({}) {|r,l|
|
179
|
+
pair = to_pair( l[0] )
|
164
180
|
swap = @swaps[pair]
|
165
181
|
rate = FxSession.convert_rate l[1]
|
166
182
|
if ( rate && swap )
|
@@ -189,10 +205,12 @@ module ClickClient
|
|
189
205
|
#
|
190
206
|
#戻り値:: 通貨ペアをキーとするClickClient::FX::Swapのハッシュ。
|
191
207
|
def list_swaps
|
192
|
-
result =
|
208
|
+
result = @client.click( @links.find {|i|
|
209
|
+
i.attributes["accesskey"] == "8"
|
210
|
+
})
|
193
211
|
reg = /<dd>([A-Z]+\/[A-Z]+) <font[^>]*>売<\/font>[^\-\d]*?([\-\d]+)[^\-\d]*<font[^>]*>買<\/font>[^\-\d]*([\-\d]+)[^\-\d]*<\/dd>/
|
194
|
-
return result.toutf8.scan( reg ).inject({}) {|r,l|
|
195
|
-
pair = l[0]
|
212
|
+
return result.body.toutf8.scan( reg ).inject({}) {|r,l|
|
213
|
+
pair = to_pair( l[0] )
|
196
214
|
r[pair] = Swap.new( pair, l[1].to_i, l[2].to_i ); r
|
197
215
|
}
|
198
216
|
end
|
@@ -200,66 +218,153 @@ module ClickClient
|
|
200
218
|
#
|
201
219
|
#注文を行います。
|
202
220
|
#
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
221
|
+
#currency_pair_code:: 通貨ペアコード(必須)
|
222
|
+
#sell_or_buy:: 売買区分。ClickClient::FX::BUY,ClickClient::FX::SELLのいずれかを指定します。(必須)
|
223
|
+
#unit:: 取引数量(必須)
|
224
|
+
#options:: 注文のオプション。注文方法に応じて以下の情報を設定できます。
|
225
|
+
# - <b>成り行き注文</b>
|
226
|
+
# - <tt>:slippage</tt> .. スリッページ (オプション)
|
227
|
+
# - <tt>:slippage_base_rate</tt> .. スリッページの基準となる取引レート(スリッページが指定された場合、必須。)
|
207
228
|
# - <b>通常注文</b> ※注文レートが設定されていれば通常取引となります。
|
208
229
|
# - <tt>:rate</tt> .. 注文レート(必須)
|
209
230
|
# - <tt>:execution_expression</tt> .. 執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
|
210
231
|
# - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
|
211
232
|
# - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
|
212
|
-
|
233
|
+
# - <b>OCO注文</b> ※逆指値レートが設定されていればOCO取引となります。
|
234
|
+
# - <tt>:rate</tt> .. 注文レート(必須)
|
235
|
+
# - <tt>:stop_order_rate</tt> .. 逆指値レート(必須)
|
236
|
+
# - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
|
237
|
+
# - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
|
238
|
+
# - <b>IFD注文</b> ※決済取引の指定があればIFD取引となります。
|
239
|
+
# - <tt>:rate</tt> .. 注文レート(必須)
|
240
|
+
# - <tt>:execution_expression</tt> .. 執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
|
241
|
+
# - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
|
242
|
+
# - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
|
243
|
+
# - <tt>:settle</tt> .. 決済取引の指定。マップで指定します。
|
244
|
+
# - <tt>:unit</tt> .. 決済取引の取引数量(必須)
|
245
|
+
# - <tt>:sell_or_buy</tt> .. 決済取引の売買区分。ClickClient::FX::BUY,ClickClient::FX::SELLのいずれかを指定します。(必須)
|
246
|
+
# - <tt>:rate</tt> .. 決済取引の注文レート(必須)
|
247
|
+
# - <tt>:execution_expression</tt> .. 決済取引の執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
|
248
|
+
# - <tt>:expiration_type</tt> .. 決済取引の有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
|
249
|
+
# - <tt>:expiration_date</tt> .. 決済取引の有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
|
250
|
+
# - <b>IFD-OCO注文</b> ※決済取引の指定と逆指値レートの指定があればIFD-OCO取引となります。
|
251
|
+
# - <tt>:rate</tt> .. 注文レート(必須)
|
252
|
+
# - <tt>:execution_expression</tt> .. 執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
|
253
|
+
# - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
|
254
|
+
# - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
|
255
|
+
# - <tt>:settle</tt> .. 決済取引の指定。マップで指定します。
|
256
|
+
# - <tt>:unit</tt> .. 決済取引の取引数量(必須)
|
257
|
+
# - <tt>:sell_or_buy</tt> .. 決済取引の売買区分。ClickClient::FX::BUY,ClickClient::FX::SELLのいずれかを指定します。(必須)
|
258
|
+
# - <tt>:rate</tt> .. 決済取引の注文レート(必須)
|
259
|
+
# - <tt>:stop_order_rate</tt> .. 決済取引の逆指値レート(必須)
|
260
|
+
# - <tt>:expiration_type</tt> .. 決済取引の有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
|
261
|
+
# - <tt>:expiration_date</tt> .. 決済取引の有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
|
262
|
+
#戻り値:: ClickClient::FX::OrderResult TODO
|
213
263
|
#
|
214
264
|
def order ( currency_pair_code, sell_or_buy, unit, options={} )
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
265
|
+
|
266
|
+
# 取り引き種別の判別とパラメータチェック
|
267
|
+
type = ORDER_TYPE_MARKET_ORDER
|
268
|
+
if ( options[:settle] != nil )
|
269
|
+
if ( options[:settle][:stop_order_rate] != nil)
|
270
|
+
# 逆指値レートと決済取引の指定があればIFD-OCO取引
|
271
|
+
raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
|
272
|
+
type = ORDER_TYPE_IFD_OCO
|
273
|
+
else
|
274
|
+
# 決済取引の指定のみがあればIFD取引
|
275
|
+
raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
|
276
|
+
raise "options[:settle][:execution_expression] is required." if options[:settle][:execution_expression] == nil
|
277
|
+
type = ORDER_TYPE_IFD
|
278
|
+
end
|
279
|
+
raise "options[:rate] is required." if options[:rate] == nil
|
280
|
+
raise "options[:execution_expression] is required." if options[:execution_expression] == nil
|
281
|
+
raise "options[:expiration_type] is required." if options[:expiration_type] == nil
|
282
|
+
raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
|
283
|
+
raise "options[:settle][:sell_or_buy] is required." if options[:settle][:sell_or_buy] == nil
|
284
|
+
raise "options[:settle][:unit] is required." if options[:settle][:unit] == nil
|
285
|
+
raise "options[:settle][:expiration_type] is required." if options[:expiration_type] == nil
|
286
|
+
elsif ( options[:rate] != nil )
|
287
|
+
if ( options[:stop_order_rate] != nil )
|
288
|
+
# 逆指値レートが指定されていればOCO取引
|
289
|
+
type = ORDER_TYPE_OCO
|
290
|
+
else
|
291
|
+
# そうでなければ通常取引
|
292
|
+
raise "options[:execution_expression] is required." if options[:execution_expression] == nil
|
293
|
+
type = ORDER_TYPE_NORMAL
|
294
|
+
end
|
295
|
+
raise "options[:expiration_type] is required." if options[:expiration_type] == nil
|
296
|
+
else
|
297
|
+
# 成り行き
|
298
|
+
type = ORDER_TYPE_MARKET_ORDER
|
299
|
+
if ( options[:slippage] != nil )
|
300
|
+
raise "if you use a slippage, options[:slippage_base_rate] is required." if options[:slippage_base_rate] == nil
|
301
|
+
end
|
302
|
+
end
|
303
|
+
raise "not supported yet." if type != ORDER_TYPE_NORMAL
|
304
|
+
|
305
|
+
# レート一覧
|
306
|
+
result = @client.click( @links.find {|i|
|
307
|
+
i.attributes["accesskey"] == "1"
|
308
|
+
})
|
309
|
+
form = result.forms.first
|
310
|
+
|
311
|
+
# 通貨ペア
|
312
|
+
option = form.fields.find{|f| f.name == "P001" }.options.find {|o|
|
313
|
+
to_pair( o.text.strip ) == currency_pair_code
|
314
|
+
}
|
315
|
+
raise "illegal currency_pair_code. currency_pair_code=#{currency_pair_code.to_s}" unless option
|
316
|
+
option.select
|
317
|
+
|
318
|
+
#注文方式
|
319
|
+
form["P100"] = type
|
320
|
+
|
321
|
+
# 詳細設定画面へ
|
322
|
+
result = @client.submit(form)
|
323
|
+
form = result.forms.first
|
324
|
+
form["P003"] = options[:rate].to_s # レート
|
325
|
+
form["P005"] = unit.to_s # 取り引き数量
|
326
|
+
form["P002.0"] = sell_or_buy == ClickClient::FX::SELL ? "1" : "0" #売り/買い
|
327
|
+
|
328
|
+
exp = options[:execution_expression]
|
329
|
+
form["P004.0"] = exp == ClickClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER ? "2" : "1" #指値/逆指値
|
330
|
+
|
331
|
+
# 有効期限
|
332
|
+
case options[:expiration_type]
|
333
|
+
when ClickClient::FX::EXPIRATION_TYPE_TODAY
|
334
|
+
form["P008"] = "0"
|
335
|
+
when ClickClient::FX::EXPIRATION_TYPE_WEEK_END
|
336
|
+
form["P008"] = "1"
|
337
|
+
when ClickClient::FX::EXPIRATION_TYPE_SPECIFIED
|
338
|
+
form["P008"] = "3"
|
339
|
+
raise "options[:expiration_date] is required." unless options[:expiration_date]
|
340
|
+
form["P009.Y"] = options[:expiration_date].year
|
341
|
+
form["P009.M"] = options[:expiration_date].month
|
342
|
+
form["P009.D"] = options[:expiration_date].day
|
343
|
+
form["P009.h"] = options[:expiration_date].respond_to?(:hour) ? options[:expiration_date].hour : "0"
|
344
|
+
else
|
345
|
+
form["P008"] = "2"
|
234
346
|
end
|
235
|
-
|
236
|
-
#
|
237
|
-
|
238
|
-
|
239
|
-
#
|
240
|
-
|
241
|
-
#
|
242
|
-
# # そうでなければ通常取引
|
243
|
-
# raise "options[:execution_expression] is required." if options[:execution_expression] == nil
|
244
|
-
# path = "/ws/fx/tsujoChumon.do"
|
245
|
-
# body << "&crp=#{options[:rate].to_s}"
|
246
|
-
# body << "&sjt=#{options[:execution_expression].to_s}"
|
247
|
-
# end
|
248
|
-
# raise "options[:expiration_type] is required." if options[:expiration_type] == nil
|
249
|
-
# body << "&bbt=#{sell_or_buy.to_s}"
|
250
|
-
# body << "&thn=#{unit.to_s}"
|
251
|
-
# body << "&dat=#{options[:expiration_type].to_s}"
|
252
|
-
# body << "&ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
|
253
|
-
# end
|
254
|
-
# result = @client.post( @base_uri + path, body)
|
255
|
-
# doc = ClickClient.parse( result.content )
|
256
|
-
# return OrderResult.new( doc.root )
|
347
|
+
|
348
|
+
# 確認画面へ
|
349
|
+
result = @client.submit(form)
|
350
|
+
result = @client.submit(result.forms.first)
|
351
|
+
#puts result.body.toutf8
|
352
|
+
ClickClient::Client.error( result ) unless result.body.toutf8 =~ /注文受付完了/
|
353
|
+
# TODO 結果を返す・・・どうするかな。
|
257
354
|
end
|
258
355
|
|
259
356
|
# ログアウトします。
|
260
357
|
def logout
|
261
|
-
@client.
|
358
|
+
@client.click( @links.find {|i|
|
359
|
+
i.text == "\303\233\302\270\303\236\302\261\302\263\303\204"
|
360
|
+
})
|
262
361
|
end
|
362
|
+
|
363
|
+
private
|
364
|
+
# "USD/JPY"を:USDJPYのようなシンボルに変換します。
|
365
|
+
def to_pair( str )
|
366
|
+
str.gsub( /\//, "" ).to_sym
|
367
|
+
end
|
263
368
|
end
|
264
369
|
|
265
370
|
#=== スワップ
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unageanu-clickclient_scrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaya Yamauchi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|