clickclient 0.0.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.
@@ -0,0 +1,992 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ end
5
+ require 'httpclient'
6
+ require 'rexml/document'
7
+ require 'date'
8
+
9
+ module ClickClient
10
+
11
+ class Client
12
+
13
+ # FX取引のデフォルトパス
14
+ DEFAULT_FX_PATH = "/webservice/wsfx-redirect"
15
+
16
+ #
17
+ #===FX取引を開始します。
18
+ #
19
+ #- このAPIを呼び出すとサーバーへのログインが行われます。
20
+ #- ログイン後、引数で指定されたブロックを実行します。ブロックの引数としてClickClient::FX::FxSessionが渡されるので、それを使って取引を行います。
21
+ #- ブロックの実行後、ログアウトします。
22
+ #
23
+ #*userid*:: ユーザーID
24
+ #*password*:: パスワード
25
+ #<b>&block</b>:: 取引処理。引数でClickClient::FX::FxSessionが渡されます。
26
+ #
27
+ def fx_session( userid, password, &block )
28
+ return unless block_given?
29
+ uri = @host_name + ( @fx_path != nil ? @fx_path : DEFAULT_FX_PATH )
30
+ session( uri, userid, password ) { |client, base_uri|
31
+ block.call( ClickClient::FX::FxSession.new( client, base_uri ) )
32
+ }
33
+ end
34
+
35
+ #FX取引のパス
36
+ attr :fx_path, true
37
+ end
38
+
39
+
40
+ #
41
+ #FX取引のクラス/定数が属するモジュールです。
42
+ #
43
+ module FX
44
+
45
+ # 通貨ペア: 米ドル-円
46
+ USDJPY = 1
47
+ # 通貨ペア: ユーロ-円
48
+ EURJPY = 2
49
+ # 通貨ペア: イギリスポンド-円
50
+ GBPJPY = 3
51
+ # 通貨ペア: 豪ドル-円
52
+ AUDJPY = 4
53
+ # 通貨ペア: ニュージーランドドル-円
54
+ NZDJPY = 5
55
+ # 通貨ペア: カナダドル-円
56
+ CADJPY = 6
57
+ # 通貨ペア: スイスフラン-円
58
+ CHFJPY = 7
59
+ # 通貨ペア: 南アランド-円
60
+ ZARJPY = 8
61
+ # 通貨ペア: ユーロ-米ドル
62
+ EURUSD = 9
63
+ # 通貨ペア: イギリスポンド-米ドル
64
+ GBPUSD = 10
65
+ # 通貨ペア: 豪ドル-米ドル
66
+ AUDUSD = 11
67
+ # 通貨ペア: ユーロ-スイスフラン
68
+ EURCHF = 12
69
+ # 通貨ペア: イギリスポンド-スイスフラン
70
+ GBPCHF = 13
71
+ # 通貨ペア: 米ドル-スイスフラン
72
+ USDCHF = 14
73
+
74
+ # 売買区分: 買い
75
+ BUY = 0
76
+ # 売買区分: 売り
77
+ SELL = 1
78
+
79
+
80
+ # トレード種別: 新規
81
+ TRADE_TYPE_NEW = 0
82
+ # トレード種別: 決済
83
+ TRADE_TYPE_SETTLEMENT = 1
84
+
85
+ # 注文タイプ: 通常
86
+ ORDER_TYPE_NORMAL = 0
87
+ # 注文タイプ: IFD
88
+ ORDER_TYPE_IFD = 1
89
+ # 注文タイプ: OCO
90
+ ORDER_TYPE_OCO = 2
91
+ # 注文タイプ: IFD-OCO
92
+ ORDER_TYPE_IFD_OCO = 3
93
+
94
+ # 注文状況: すべて
95
+ ORDER_CONDITION_ALL = 0
96
+ # 注文状況: 注文中
97
+ ORDER_CONDITION_ON_ORDER = 1
98
+ # 注文状況: 取消済
99
+ ORDER_CONDITION_CANCELED = 2
100
+ # 注文状況: 約定
101
+ ORDER_CONDITION_EXECUTION = 3
102
+ # 注文状況: 不成立
103
+ ORDER_CONDITION_FAILED = 4
104
+
105
+ # 注文状態: 待機中
106
+ ORDER_STATE_WAITING = 10
107
+ # 注文状態: 受付済み
108
+ ORDER_STATE_RECEIVED = 20
109
+ # 注文状態: 取り消し中
110
+ ORDER_STATE_CANCELING = 21
111
+ # 注文状態: 約定(新規)
112
+ ORDER_STATE_AGREED_NEW = 30
113
+ # 注文状態: 約定(決済)
114
+ ORDER_STATE_AGREED_SETTLEMENT = 97
115
+ # 注文状態: 失効[期限切]
116
+ ORDER_STATE_EXPIRED = 98
117
+ # 注文状態: 取消済
118
+ ORDER_STATE_CANCELED = 99
119
+
120
+ # 執行条件: 成行
121
+ EXECUTION_EXPRESSION_MARKET_ORDER = 0
122
+ # 執行条件: 指値
123
+ EXECUTION_EXPRESSION_LIMIT_ORDER = 1
124
+ # 執行条件: 逆指値
125
+ EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER = 2
126
+
127
+ # 有効期限: 当日限り
128
+ EXPIRATION_TYPE_TODAY = 0
129
+ # 有効期限: 週末まで
130
+ EXPIRATION_TYPE_WEEK_END = 1
131
+ # 有効期限: 無期限
132
+ EXPIRATION_TYPE_INFINITY = 2
133
+ # 有効期限: 日付指定
134
+ EXPIRATION_TYPE_SPECIFIED = 3
135
+
136
+ # 不成立理由: 不成立ではない
137
+ FAILURE_REASON_NOT_FAILED = 0
138
+ # 不成立理由: 注文状態が「取消済」で、当社オペレータによる取消の場合。
139
+ FAILURE_REASON_GMT = 1
140
+ # 不成立理由: 期限切れ。注文状態が「失効[期限切]」の場合。
141
+ FAILURE_REASON_EXPIRED = 2
142
+ # 不成立理由: 自動(システム)。注文状態が「取消済」で、OCO約定によるもう一方の取消、又はロスカット発動による取消の場合。
143
+ FAILURE_REASON_AUTO = 4
144
+ # 不成立理由: 会員。注文状態が「取消済」で、お客様による取消の場合。
145
+ FAILURE_REASON_USER = 6
146
+
147
+ # 証拠金ステータス: 適用外。時価評価総額が0以下の場合。
148
+ GUARANTEE_MONEY_STATUS_NONAPPLOVED = 0
149
+ # 証拠金ステータス: 適正
150
+ GUARANTEE_MONEY_STATUS_APPROPRIATED = 1
151
+ # 証拠金ステータス: ロスカットアラート
152
+ GUARANTEE_MONEY_STATUS_LOSS_CUT_ALERT = 2
153
+
154
+ #
155
+ #=== FX取引のためのセッションクラス
156
+ #
157
+ #Client#fx_sessionのブロックの引数として渡されます。詳細はClient#fx_sessionを参照ください。
158
+ #
159
+ class FxSession
160
+
161
+ #
162
+ #=== コンストラクタ
163
+ #
164
+ def initialize( client, base_uri )
165
+ @client = client
166
+ @base_uri = base_uri
167
+ end
168
+
169
+ #
170
+ #===通貨ペア一覧を取得します。
171
+ #
172
+ #*currency_pair_codes*:: 取得したい通貨ペアのコードの配列。nilの場合、全一覧を取得します。
173
+ #<b>戻り値</b>:: ClickClient::FX::CurrencyPairの配列。
174
+ #
175
+ def list_currency_pairs( currency_pair_codes=nil )
176
+ post = ""
177
+ i =0
178
+ if currency_pair_codes != nil
179
+ currency_pair_codes.each{ |code|
180
+ post << "tka[#{i}].tkt="<< code.to_s << "&"
181
+ i += 1
182
+ }
183
+ post.chop
184
+ end
185
+ result = @client.post( @base_uri + "/ws/fx/tsukaPairList.do", post)
186
+ list = {}
187
+ doc = ClickClient.parse( result.content )
188
+ doc.elements.each("./tsukaPairListResponse/tsukaPairList/tsukaPairListItem") { |item|
189
+ v = CurrencyPair.new( item )
190
+ list[v.currency_pair_code] = v
191
+ }
192
+ return list
193
+ end
194
+
195
+ #
196
+ #=== 現在のレートの一覧を取得します。
197
+ #
198
+ #<b>戻り値</b>:: ClickClient::FX::Rateの配列。
199
+ #
200
+ def list_rates( )
201
+ result = @client.post( @base_uri + "/ws/fx/rateList.do")
202
+ list = {}
203
+ doc = ClickClient.parse( result.content )
204
+ doc.elements.each("./rateListResponse/rateList/rateListItem") { |item|
205
+ v = Rate.new( item )
206
+ list[v.currency_pair_code] = v
207
+ }
208
+ return list
209
+ end
210
+
211
+ #
212
+ #=== 注文一覧を取得します。
213
+ #
214
+ #*order_condition_code*:: 注文状況コード(必須)
215
+ #*currency_pair_code*:: 通貨ペアコード
216
+ #*from*:: 注文日期間開始日。Dateで指定。例) Date.new(2007, 1, 1)
217
+ #*to*:: 注文日期間終了日。Dateで指定。例) Date.new(2007, 1, 1)
218
+ #<b>戻り値</b>:: ClickClient::FX::Orderの配列。
219
+ #
220
+ def list_orders( order_condition_code, currency_pair_code=nil, from=nil, to=nil )
221
+ body = "cms=" << order_condition_code.to_s
222
+ body << "&tkt=" << currency_pair_code.to_s
223
+ body << "&cfd=" << from.strftime( "%Y%m%d" ) if from != nil
224
+ body << "&ctd=" << to.strftime( "%Y%m%d" ) if to != nil
225
+ result = @client.post( @base_uri + "/ws/fx/chumonList.do", body)
226
+ list = {}
227
+ doc = ClickClient.parse( result.content )
228
+ doc.elements.each("./chumonListResponse/chumonList/chumonListItem/chumon") { |item|
229
+ order = Order.new( item )
230
+ list[order.order_no] = order
231
+ }
232
+ return list
233
+ end
234
+
235
+ #
236
+ #=== 注文を行います。
237
+ #
238
+ #*currency_pair_code*:: 通貨ペアコード(必須)
239
+ #*sell_or_buy*:: 売買区分。ClickClient::FX::BUY,ClickClient::FX::SELLのいずれかを指定します。(必須)
240
+ #*unit*:: 取引数量(必須)
241
+ #*options*:: 注文のオプション。注文方法に応じて以下の情報を設定できます。
242
+ # - <b>成り行き注文</b>
243
+ # - <tt>:slippage</tt> .. スリッページ (オプション)
244
+ # - <tt>:slippage_base_rate</tt> .. スリッページの基準となる取引レート(スリッページが指定された場合、必須。)
245
+ # - <b>通常注文</b> ※注文レートが設定されていれば通常取引となります。
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>OCO注文</b> ※逆指値レートが設定されていればOCO取引となります。
251
+ # - <tt>:rate</tt> .. 注文レート(必須)
252
+ # - <tt>:stop_order_rate</tt> .. 逆指値レート(必須)
253
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
254
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
255
+ # - <b>IFD注文</b> ※決済取引の指定があればIFD取引となります。
256
+ # - <tt>:rate</tt> .. 注文レート(必須)
257
+ # - <tt>:execution_expression</tt> .. 執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
258
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
259
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
260
+ # - <tt>:settle</tt> .. 決済取引の指定。マップで指定します。
261
+ # - <tt>:unit</tt> .. 決済取引の取引数量(必須)
262
+ # - <tt>:sell_or_buy</tt> .. 決済取引の売買区分。ClickClient::FX::BUY,ClickClient::FX::SELLのいずれかを指定します。(必須)
263
+ # - <tt>:rate</tt> .. 決済取引の注文レート(必須)
264
+ # - <tt>:execution_expression</tt> .. 決済取引の執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
265
+ # - <tt>:expiration_type</tt> .. 決済取引の有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
266
+ # - <tt>:expiration_date</tt> .. 決済取引の有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
267
+ # - <b>IFD-OCO注文</b> ※決済取引の指定と逆指値レートの指定があればIFD-OCO取引となります。
268
+ # - <tt>:rate</tt> .. 注文レート(必須)
269
+ # - <tt>:execution_expression</tt> .. 執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
270
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
271
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
272
+ # - <tt>:settle</tt> .. 決済取引の指定。マップで指定します。
273
+ # - <tt>:unit</tt> .. 決済取引の取引数量(必須)
274
+ # - <tt>:sell_or_buy</tt> .. 決済取引の売買区分。ClickClient::FX::BUY,ClickClient::FX::SELLのいずれかを指定します。(必須)
275
+ # - <tt>:rate</tt> .. 決済取引の注文レート(必須)
276
+ # - <tt>:stop_order_rate</tt> .. 決済取引の逆指値レート(必須)
277
+ # - <tt>:expiration_type</tt> .. 決済取引の有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
278
+ # - <tt>:expiration_date</tt> .. 決済取引の有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
279
+ #<b>戻り値</b>:: ClickClient::FX::OrderResult
280
+ #
281
+ def order ( currency_pair_code, sell_or_buy, unit, options={} )
282
+ path = nil
283
+ body = "tkt=#{currency_pair_code.to_s}"
284
+ if ( options[:settle] != nil )
285
+ if ( options[:settle][:stop_order_rate] != nil)
286
+ # 逆指値レートと決済取引の指定があればIFD-OCO取引
287
+ raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
288
+ path = "/ws/fx/ifdOcoChumon.do"
289
+ body << "&kc.grp=#{options[:settle][:stop_order_rate].to_s}"
290
+ body << "&kc.srp=#{options[:settle][:rate].to_s}"
291
+ else
292
+ # 決済取引の指定のみがあればIFD取引
293
+ raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
294
+ raise "options[:settle][:execution_expression] is required." if options[:settle][:execution_expression] == nil
295
+ path = "/ws/fx/ifdChumon.do"
296
+ body << "&kc.crp=#{options[:settle][:rate].to_s}"
297
+ body << "&kc.sjt=#{options[:settle][:execution_expression].to_s}"
298
+ end
299
+ raise "options[:rate] is required." if options[:rate] == nil
300
+ raise "options[:execution_expression] is required." if options[:execution_expression] == nil
301
+ raise "options[:expiration_type] is required." if options[:expiration_type] == nil
302
+ body << "&sc.bbt=#{sell_or_buy.to_s}"
303
+ body << "&sc.crp=#{options[:rate].to_s}"
304
+ body << "&sc.sjt=#{options[:execution_expression].to_s}"
305
+ body << "&sc.thn=#{unit.to_s}"
306
+ body << "&sc.dat=#{options[:expiration_type].to_s}"
307
+ body << "&sc.ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
308
+
309
+ raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
310
+ raise "options[:settle][:sell_or_buy] is required." if options[:settle][:sell_or_buy] == nil
311
+ raise "options[:settle][:unit] is required." if options[:settle][:unit] == nil
312
+ raise "options[:settle][:expiration_type] is required." if options[:expiration_type] == nil
313
+ body << "&kc.bbt=#{options[:settle][:sell_or_buy].to_s}"
314
+ body << "&kc.dat=#{options[:settle][:expiration_type].to_s}"
315
+ body << "&kc.thn=#{options[:settle][:unit].to_s}"
316
+ body << "&kc.ykd=" << options[:settle][:expiration_date].strftime( "%Y%m%d%H" ) if options[:settle][:expiration_date] != nil
317
+ elsif ( options[:rate] != nil )
318
+ if ( options[:stop_order_rate] != nil )
319
+ # 逆指値レートが指定されていればOCO取引
320
+ path = "/ws/fx/ocoChumon.do"
321
+ body << "&srp=#{options[:rate].to_s}"
322
+ body << "&grp=#{options[:stop_order_rate].to_s}"
323
+ else
324
+ # そうでなければ通常取引
325
+ raise "options[:execution_expression] is required." if options[:execution_expression] == nil
326
+ path = "/ws/fx/tsujoChumon.do"
327
+ body << "&crp=#{options[:rate].to_s}"
328
+ body << "&sjt=#{options[:execution_expression].to_s}"
329
+ end
330
+ raise "options[:expiration_type] is required." if options[:expiration_type] == nil
331
+ body << "&bbt=#{sell_or_buy.to_s}"
332
+ body << "&thn=#{unit.to_s}"
333
+ body << "&dat=#{options[:expiration_type].to_s}"
334
+ body << "&ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
335
+ else
336
+ # 成り行き
337
+ path = "/ws/fx/nariyukiChumon.do"
338
+ body << "&bbt=#{sell_or_buy.to_s}&thn=#{unit.to_s}"
339
+ if ( options[:slippage] != nil )
340
+ raise "if you use a slippage, options[:slippage_base_rate] is required." if options[:slippage_base_rate] == nil
341
+ body << "&slp=#{options[:slippage].to_s}&gnp=#{options[:slippage_base_rate].to_s}"
342
+ end
343
+ end
344
+ result = @client.post( @base_uri + path, body)
345
+ doc = ClickClient.parse( result.content )
346
+ return OrderResult.new( doc.root )
347
+ end
348
+
349
+ #
350
+ #=== 注文を変更します。
351
+ #
352
+ #変更可能な注文とその値は次のとおりです。成り行き注文は変更できません。
353
+ #- <b>通常注文</b>
354
+ # - 注文レート
355
+ # - 有効期限
356
+ # - 有効日時
357
+ #- <b>IFD注文</b>
358
+ # - 新規注文レート
359
+ # - 新規有効期限
360
+ # - 新規有効日時
361
+ # - 決済注文レート
362
+ # - 決済有効期限
363
+ # - 決済有効日時
364
+ #- <b>OCO注文</b>
365
+ # - 注文レート
366
+ # - 逆指値レート
367
+ # - 有効期限
368
+ # - 有効日時
369
+ #- <b>IFD-OCO注文</b>
370
+ # - 新規注文レート
371
+ # - 新規有効期限
372
+ # - 新規有効日時
373
+ # - 決済注文レート
374
+ # - 決済注文逆指値レート
375
+ # - 決済有効期限
376
+ # - 決済有効日時
377
+ #
378
+ #*order_no*:: 注文番号
379
+ #*options*:: 注文のオプション。注文方法に応じて以下の情報を設定できます。
380
+ # - <b>通常注文</b> ※注文レートが設定されていれば通常取引となります。
381
+ # - <tt>:rate</tt> .. 注文レート(必須)
382
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
383
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
384
+ # - <b>OCO注文</b> ※逆指値番号が設定されていればOCO取引となります。
385
+ # - <tt>:stop_order_no</tt> .. 逆指値注文番号(必須)
386
+ # - <tt>:rate</tt> .. 注文レート(必須)
387
+ # - <tt>:stop_order_rate</tt> .. 逆指値レート(必須)
388
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
389
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
390
+ # - <b>IFD注文</b> ※決済取引の指定のみがあればIFD取引となります。
391
+ # - <tt>:rate</tt> .. 注文レート(必須)
392
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
393
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
394
+ # - <tt>:settle</tt> .. 決済取引の指定。マップで指定します。
395
+ # - <tt>:order_no</tt> .. 決済注文番号(必須)
396
+ # - <tt>:rate</tt> .. 決済取引の注文レート(必須)
397
+ # - <tt>:expiration_type</tt> .. 決済取引の有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
398
+ # - <tt>:expiration_date</tt> .. 決済取引の有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
399
+ # - <b>IFD-OCO注文</b> ※決済逆指値注文番号と決済取引の指定があればIFD-OCO取引となります。
400
+ # - <tt>:rate</tt> .. 注文レート(必須)
401
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
402
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
403
+ # - <tt>:settle</tt> .. 決済取引の指定。マップで指定します。
404
+ # - <tt>:order_no</tt> .. 決済注文番号(必須)
405
+ # - <tt>:stop_order_no</tt> .. 逆指値決済注文番号(必須)
406
+ # - <tt>:rate</tt> .. 決済取引の注文レート(必須)
407
+ # - <tt>:stop_order_rate</tt> .. 決済取引の逆指値レート(必須)
408
+ # - <tt>:expiration_type</tt> .. 決済取引の有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
409
+ # - <tt>:expiration_date</tt> .. 決済取引の有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
410
+ #<b>戻り値</b>:: なし
411
+ #
412
+ def edit_order ( order_no, options )
413
+
414
+ body = ""
415
+ path = nil
416
+ if ( options[:settle] != nil )
417
+ if ( options[:settle][:stop_order_no] != nil)
418
+ # 決済逆指値注文番号と決済取引の指定があればIFD-OCO取引
419
+ raise "options[:settle][:order_no] is required." if options[:settle][:order_no] == nil
420
+ raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
421
+ raise "options[:settle][:stop_order_rate] is required." if options[:settle][:stop_order_rate] == nil
422
+ path = "/ws/fx/ifdOcoChumonHenko.do"
423
+ body << "kc.sck=#{options[:settle][:order_no].to_s}"
424
+ body << "&kc.gck=#{options[:settle][:stop_order_no].to_s}"
425
+ body << "&kc.srp=#{options[:settle][:rate].to_s}"
426
+ body << "&kc.grp=#{options[:settle][:stop_order_rate].to_s}"
427
+ else
428
+ # 決済取引の指定のみがあればIFD取引
429
+ raise "options[:settle][:order_no] is required." if options[:settle][:order_no] == nil
430
+ raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
431
+ path = "/ws/fx/ifdChumonHenko.do"
432
+ body << "kc.cmk=#{options[:settle][:order_no].to_s}"
433
+ body << "&kc.crp=#{options[:settle][:rate].to_s}"
434
+ end
435
+ raise "options[:rate] is required." if options[:rate] == nil
436
+ raise "options[:expiration_type] is required." if options[:expiration_type] == nil
437
+ body << "&sc.cmk=#{order_no.to_s}"
438
+ body << "&sc.crp=#{options[:rate].to_s}"
439
+ body << "&sc.dat=#{options[:expiration_type].to_s}"
440
+ body << "&sc.ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
441
+
442
+ raise "options[:settle][:rate] is required." if options[:settle][:rate] == nil
443
+ raise "options[:settle][:expiration_type] is required." if options[:expiration_type] == nil
444
+ body << "&kc.dat=#{options[:settle][:expiration_type].to_s}"
445
+ body << "&kc.ykd=" << options[:settle][:expiration_date].strftime( "%Y%m%d%H" ) if options[:settle][:expiration_date] != nil
446
+ elsif ( options[:rate] != nil )
447
+ if ( options[:stop_order_no] != nil )
448
+ # 逆指値番号が指定されていればOCO取引
449
+ path = "/ws/fx/ocoChumonHenko.do"
450
+ body << "sck=#{order_no.to_s}"
451
+ body << "&gck=#{options[:stop_order_no].to_s}"
452
+ body << "&srp=#{options[:rate].to_s}"
453
+ body << "&grp=#{options[:stop_order_rate].to_s}"
454
+ else
455
+ # そうでなければ通常取引
456
+ raise "options[:rate] is required." if options[:rate] == nil
457
+ path = "/ws/fx/tsujoChumonHenko.do"
458
+ body << "cmk=#{order_no.to_s}"
459
+ body << "&crp=#{options[:rate].to_s}"
460
+ end
461
+ raise "options[:expiration_type] is required." if options[:expiration_type] == nil
462
+ body << "&dat=#{options[:expiration_type].to_s}"
463
+ body << "&ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
464
+ end
465
+
466
+ result = @client.post( @base_uri + path, body)
467
+ ClickClient.parse( result.content )
468
+ end
469
+
470
+ #
471
+ #=== 注文をキャンセルします。
472
+ #
473
+ #*order_no*:: 注文番号
474
+ #<b>戻り値</b>:: なし
475
+ #
476
+ def cancel_order ( order_no )
477
+ result = @client.post( @base_uri + "/ws/fx/chumonTorikeshi.do", "cmk=#{order_no.to_s}")
478
+ ClickClient.parse( result.content )
479
+ end
480
+
481
+ #
482
+ #=== 決済注文を行います。
483
+ #
484
+ #*open_interest_no*:: 決済する建玉番号
485
+ #*unit*:: 取引数量
486
+ #*options*:: 決済注文のオプション。注文方法に応じて以下の情報を設定できます。
487
+ # - <b>成り行き注文</b>
488
+ # - <tt>:slippage</tt> .. スリッページ (オプション)
489
+ # - <tt>:slippage_base_rate</tt> .. スリッページの基準となる取引レート(スリッページが指定された場合、必須。)
490
+ # - <b>通常注文</b> ※注文レートが設定されていれば通常取引となります。
491
+ # - <tt>:rate</tt> .. 注文レート(必須)
492
+ # - <tt>:execution_expression</tt> .. 執行条件。ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER等を指定します(必須)
493
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
494
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
495
+ # - <b>OCO注文</b> ※注文レートと逆指値レートが設定されていればOCO取引となります。
496
+ # - <tt>:rate</tt> .. 注文レート(必須)
497
+ # - <tt>:stop_order_rate</tt> .. 逆指値レート(必須)
498
+ # - <tt>:expiration_type</tt> .. 有効期限。ClickClient::FX::EXPIRATION_TYPE_TODAY等を指定します(必須)
499
+ # - <tt>:expiration_date</tt> .. 有効期限が「日付指定(ClickClient::FX::EXPIRATION_TYPE_SPECIFIED)」の場合の有効期限をDateで指定します。(有効期限が「日付指定」の場合、必須)
500
+ #<b>戻り値</b>:: ClickClient::FX::SettleResult
501
+ #
502
+ def settle ( open_interest_no, unit, options={} )
503
+ path = nil
504
+ body = "tga[0].tgk=#{open_interest_no.to_s}&tga[0].thn=#{unit.to_s}"
505
+ if ( options[:rate] != nil && options[:stop_order_rate] != nil )
506
+ # レートと逆指値レートが指定されていればOCO取引
507
+ path = "/ws/fx/ocoKessaiChumon.do"
508
+ raise "options[:expiration_type] is required." if options[:expiration_type] == nil
509
+ body << "&srp=#{options[:rate].to_s}"
510
+ body << "&grp=#{options[:stop_order_rate].to_s}"
511
+ body << "&dat=#{options[:expiration_type].to_s}"
512
+ body << "&ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
513
+ elsif ( options[:rate] != nil )
514
+ # レートが指定されていれば通常取引
515
+ path = "/ws/fx/tsujoKessaiChumon.do"
516
+ raise "options[:execution_expression] is required." if options[:execution_expression] == nil
517
+ raise "options[:expiration_type] is required." if options[:expiration_type] == nil
518
+ body << "&crp=#{options[:rate].to_s}"
519
+ body << "&sjt=#{options[:execution_expression].to_s}"
520
+ body << "&dat=#{options[:expiration_type].to_s}"
521
+ body << "&ykd=" << options[:expiration_date].strftime( "%Y%m%d%H" ) if options[:expiration_date] != nil
522
+ else
523
+ # 成り行き
524
+ path = "/ws/fx/nariyukiKessaiChumon.do"
525
+ if ( options[:slippage] != nil )
526
+ raise "if you use a slippage, options[:slippage_base_rate] is required." if options[:slippage_base_rate] == nil
527
+ body << "&slp=#{options[:slippage].to_s}&gnp=#{options[:slippage_base_rate].to_s}"
528
+ end
529
+ end
530
+ result = @client.post( @base_uri + path, body)
531
+ doc = ClickClient.parse( result.content )
532
+ elms = doc.get_elements("./*/kessaiChumonList/kessaiChumonListItem")
533
+ if ( elms == nil || elms.length <= 0 )
534
+ elms = doc.get_elements("./*/ocoKessaiChumonList/ocoKessaiChumonListItem")
535
+ end
536
+ return SettleResult.new( elms[0] )
537
+ end
538
+
539
+ #
540
+ #=== 建玉一覧を取得します。
541
+ #
542
+ #*currency_pair_code*:: 通貨ペアコード
543
+ #<b>戻り値</b>:: ClickClient::FX::OpenInterestの配列
544
+ #
545
+ def list_open_interests( currency_pair_code=nil )
546
+ body = currency_pair_code != nil ? "tkt=#{currency_pair_code.to_s}" : ""
547
+ result = @client.post( @base_uri + "/ws/fx/tategyokuList.do", body)
548
+ list = []
549
+ doc = ClickClient.parse( result.content )
550
+ doc.elements.each("./tategyokuListResponse/tategyokuList/tategyokuListItem") { |item|
551
+ list << OpenInterest.new( item )
552
+ }
553
+ return list
554
+ end
555
+
556
+ #
557
+ #=== 約定一覧を取得します。
558
+ #
559
+ #*from*:: 注文日期間開始日。Dateで指定。例) Date.new(2007, 1, 1)
560
+ #*to*:: 注文日期間終了日。Dateで指定。例) Date.new(2007, 1, 1)
561
+ #*trade_type*:: 取引種別
562
+ #*currency_pair_code*:: 通貨ペアコード
563
+ #<b>戻り値</b>:: ClickClient::FX::ExecutionResultの配列
564
+ #
565
+ def list_execution_results( from, to, trade_type=nil, currency_pair_code=nil )
566
+ raise "from is required." if from == nil
567
+ raise "to is required." if to == nil
568
+ body = "yfd=" << from.strftime( "%Y%m%d" )
569
+ body << "&ytd=" << to.strftime( "%Y%m%d" )
570
+ body << "&tkt=" << currency_pair_code.to_s if currency_pair_code != nil
571
+ body << "&tht=" << trade_type.to_s if trade_type != nil
572
+ result = @client.post( @base_uri + "/ws/fx/yakujoList.do", body)
573
+ list = []
574
+ doc = ClickClient.parse( result.content )
575
+ doc.elements.each("./yakujoListResponse/yakujoList/yakujoListItem") { |item|
576
+ list << ExecutionResult.new( item )
577
+ }
578
+ return list
579
+ end
580
+
581
+ #
582
+ #=== 余力情報を取得します。
583
+ #
584
+ #<b>戻り値</b>:: ClickClient::FX::Margin
585
+ #
586
+ def get_margin
587
+ result = @client.post( @base_uri + "/ws/fx/yoryokuJoho.do")
588
+ list = []
589
+ doc = ClickClient.parse( result.content )
590
+ return Margin.new( doc.root )
591
+ end
592
+
593
+ #
594
+ #=== お知らせ一覧を取得します。
595
+ #
596
+ #<b>戻り値</b>:: ClickClient::FX::Messageの配列
597
+ #
598
+ def list_messages
599
+ result = @client.post( @base_uri + "/ws/fx/messageList.do")
600
+ list = []
601
+ doc = ClickClient.parse( result.content )
602
+ doc.elements.each("./messageListResponse/messageList/messageListItem") { |item|
603
+ list << Message.new( item )
604
+ }
605
+ return list
606
+ end
607
+ end
608
+
609
+ #
610
+ #===通貨ペア
611
+ #
612
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
613
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
614
+ #
615
+ class CurrencyPair < ClickClient::Base
616
+ def initialize( item )
617
+ super(item)
618
+ @currency_pair_code = item.attributes["tsukaPairCode"].to_i
619
+ @name = item.attributes["tsukaPairName"]
620
+ @max_trade_quantity = item.text( "./maxTorihikiSuryo" ).to_i
621
+ @min_trade_quantity = item.text( "./minTorihikiSuryo" ).to_i
622
+ @trade_unit = item.text( "./torihikiTani" ).to_i
623
+ end
624
+ #通貨ペアコード
625
+ attr :currency_pair_code, true
626
+ #名前
627
+ attr :name, true
628
+ #最大取引数量
629
+ attr :max_trade_quantity, true
630
+ #最低取引数量
631
+ attr :min_trade_quantity, true
632
+ #取引単位
633
+ attr :trade_unit, true
634
+ end
635
+
636
+ #
637
+ #
638
+ #===レート
639
+ #
640
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
641
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
642
+ #
643
+ class Rate < ClickClient::Base
644
+
645
+ #
646
+ #=== コンストラクタ
647
+ #
648
+ #*item*:: 結果要素
649
+ #
650
+ def initialize( item )
651
+ super(item)
652
+ @currency_pair_code = item.get_elements("./tsukaPair")[0].attributes["tsukaPairCode"].to_i
653
+ @bid_rate = item.text( "./bid" ).to_f
654
+ @ask_rate = item.text( "./ask" ).to_f
655
+ @day_before_to = item.text( "./zenjitsuhi" ).to_f
656
+ @bid_high = item.text( "./bidHigh" ).to_f
657
+ @bid_low = item.text( "./bidLow" ).to_f
658
+ @buy_swap = item.text( "./kaiSwap" ).to_i
659
+ @sell_swap = item.text( "./uriSwap" ).to_i
660
+ @date = DateTime.strptime( item.text( "./hasseibi" ), "%Y-%m-%d")
661
+ @days_of_grant = item.text( "./fuyoNissu" ).to_i
662
+ end
663
+ #通貨ペアコード
664
+ attr :currency_pair_code, true
665
+ #Bidレート
666
+ attr :bid_rate, true
667
+ #Askレート
668
+ attr :ask_rate, true
669
+ #前日終値比。現在のBidレートと直近のNYクローズ時のBidレートとの差。
670
+ attr :day_before_to, true
671
+ #Bidレート高値
672
+ attr :bid_high, true
673
+ #Bidレート安値
674
+ attr :bid_low, true
675
+ #買スワップポイント(円)
676
+ attr :buy_swap, true
677
+ #売スワップポイント(円)
678
+ attr :sell_swap, true
679
+ #発生日
680
+ attr :date, true
681
+ #付与日数
682
+ attr :days_of_grant, true
683
+ end
684
+
685
+ #
686
+ #===注文
687
+ #
688
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
689
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
690
+ #
691
+ class Order < ClickClient::Base
692
+
693
+ #
694
+ #=== コンストラクタ
695
+ #
696
+ #*item*:: 結果要素
697
+ #
698
+ def initialize( item )
699
+ super(item)
700
+ @order_no = item.attributes["chumonBango"].to_i
701
+ @enable_change_or_cancel = item.text( "./henkoTorikeshiKano" ).to_i == 1
702
+ @trade_type = item.text( "./torihiki" ).to_i
703
+ @sell_or_buy = item.text( "./baibai" ).to_i
704
+ @trade_quantity = item.text( "./hatchuSuryo" ).to_i
705
+ @rate = item.text( "./chumonRate" ).to_f
706
+ @execution_expression = item.text( "./shikko" ).to_i
707
+ @date = DateTime.strptime( item.text( "./hatchuNichiji" ), "%Y-%m-%d %H:%M:%S")
708
+ @expiration_type = item.text( "./yukoKigen" ).to_i
709
+
710
+ str = item.text( "./yukoNichiji" )
711
+ @expiration_date = str != nil ? DateTime.strptime( str , "%Y-%m-%d %H:%M:%S") : nil
712
+
713
+ @order_state = item.text( "./chumonJotai" ).to_i
714
+ @failure_reason = item.text( "./fuseiritsuRiyu" ).to_i
715
+
716
+ str = item.text( "./yakujoRate" )
717
+ @settlement_rate = str != nil ? str.to_f : nil
718
+
719
+ str = item.text( "./yakujoNichiji" )
720
+ @settlement_date = str != nil ? DateTime.strptime( str , "%Y-%m-%d %H:%M:%S") : nil
721
+
722
+ end
723
+ #注文番号
724
+ attr :order_no, true
725
+ #注文の変更および取消が可能かどうか
726
+ attr :enable_change_or_cancel, true
727
+ #注文時の取引種類
728
+ attr :trade_type, true
729
+ #売買区分
730
+ attr :sell_or_buy, true
731
+ #取引数量
732
+ attr :trade_quantity, true
733
+ #レート。執行条件が「成行」の場合は約定レートと同値。
734
+ attr :rate, true
735
+ #執行条件
736
+ attr :execution_expression, true
737
+ #注文を受け付けた日時
738
+ attr :date, true
739
+ #注文時に指定した有効期限種別
740
+ attr :expiration_type, true
741
+ #注文時に有効期限を日時指定した場合の、日時
742
+ attr :expiration_date, true
743
+ #注文状態
744
+ attr :order_state, true
745
+ #不成立理由
746
+ attr :failure_reason, true
747
+ #約定レート。注文が不成立の場合はnil
748
+ attr :settlement_rate, true
749
+ #約定日時。注文が不成立の場合はnil
750
+ attr :settlement_date, true
751
+ end
752
+
753
+ #
754
+ #===注文結果
755
+ #
756
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
757
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
758
+ #
759
+ class OrderResult < ClickClient::Base
760
+
761
+ #
762
+ #===コンストラクタ
763
+ #
764
+ #*item*:: 結果要素
765
+ #
766
+ def initialize( item )
767
+ super(item)
768
+ str = item.text( "./chumonBango")
769
+ if str == nil || str.length <= 0
770
+ str = item.text( "./shinkiChumonBango")
771
+ end
772
+ @order_no = str != nil ? str.to_i : nil
773
+ str = item.text( "./kessaiChumonBango" )
774
+ @settlement_order_no = str != nil ? str.to_i : nil
775
+ str = item.text( "./tategyokuBango" )
776
+ @open_interest_no = str != nil ? str.to_i : nil
777
+
778
+ str = item.text( "./sashineChumonBango" )
779
+ @limit_order_no = str != nil ? str.to_i : nil
780
+ str = item.text( "./gyakusashiChumonBango" )
781
+ @stop_order_no = str != nil ? str.to_i : nil
782
+
783
+ end
784
+ #注文番号
785
+ attr :order_no, true
786
+ #建玉番号
787
+ attr :open_interest_no, true
788
+ #決済注文番号(IFD, IFD-OCO取引のみ)
789
+ attr :settlement_order_no, true
790
+ #指値注文番号(OCO取引のみ)
791
+ attr :limit_order_no, true
792
+ #逆指値注文番号(OCO取引のみ)
793
+ attr :stop_order_no, true
794
+ end
795
+
796
+ #
797
+ #===決済注文結果
798
+ #
799
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
800
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
801
+ #
802
+ class SettleResult < ClickClient::Base
803
+
804
+ #
805
+ #=== コンストラクタ
806
+ #
807
+ #*item*:: 結果要素
808
+ #
809
+ def initialize( item )
810
+ super(item)
811
+ str = item.text( "./chumonBango")
812
+ @settlement_order_no = str != nil ? str.to_i : nil
813
+ str = item.text( "./kessaiTategyokuBango" )
814
+ @open_interest_no = str != nil ? str.to_i : nil
815
+
816
+ str = item.text( "./sashineChumonBango" )
817
+ @limit_settlement_order_no = str != nil ? str.to_i : nil
818
+ str = item.text( "./gyakusashiChumonBango" )
819
+ @stop_settlement_order_no = str != nil ? str.to_i : nil
820
+ end
821
+ #決済注文番号
822
+ attr :settlement_order_no, true
823
+ #建玉番号
824
+ attr :open_interest_no, true
825
+ #決済指値注文番号(OCO取引のみ)
826
+ attr :limit_settlement_order_no, true
827
+ #決済逆指値注文番号(OCO取引のみ)
828
+ attr :stop_settlement_order_no, true
829
+ end
830
+
831
+ #
832
+ #===建玉
833
+ #
834
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
835
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
836
+ #
837
+ class OpenInterest < ClickClient::Base
838
+
839
+ #
840
+ #=== コンストラクタ
841
+ #
842
+ #*item*:: 結果要素
843
+ #
844
+ def initialize( item )
845
+ super(item)
846
+ @currency_pair_code = item.get_elements("./tsukaPair")[0].attributes["tsukaPairCode"].to_i
847
+ end
848
+ #通貨ペアコード
849
+ attr :currency_pair_code, true
850
+ end
851
+
852
+ #
853
+ #===約定
854
+ #
855
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
856
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
857
+ #
858
+ class ExecutionResult < ClickClient::Base
859
+
860
+ #
861
+ #=== コンストラクタ
862
+ #
863
+ #*item*:: 結果要素
864
+ #
865
+ def initialize( item )
866
+ super(item)
867
+ @currency_pair_code = item.get_elements("./tsukaPair")[0].attributes["tsukaPairCode"].to_i
868
+ end
869
+ #通貨ペアコード
870
+ attr :currency_pair_code, true
871
+ end
872
+
873
+ #
874
+ #===余力
875
+ #
876
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
877
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
878
+ #
879
+ class Margin < ClickClient::Base
880
+
881
+ #
882
+ #=== コンストラクタ
883
+ #
884
+ #*item*:: 結果要素
885
+ #
886
+ def initialize( item )
887
+ super(item)
888
+ @margin = item.text( "./yoryoku").to_i
889
+ @transferable_money_amount = item.text( "./furikaeKano" ).to_i
890
+ @guarantee_money_status = item.text( "./shokokinStatus" ).to_i
891
+ @guarantee_money_maintenance_ratio = item.text( "./shokokinIjiritsu" ).to_f
892
+ @market_value = item.text( "./jikaHyokaSogaku" ).to_i
893
+ @appraisal_profit_or_loss_of_open_interest = item.text( "./tategyokuHyokaSoneki" ).to_i
894
+ @balance_in_account = item.text( "./kozaZandaka" ).to_i
895
+ @balance_of_cach = item.text( "./genkinZandaka" ).to_i
896
+ @settlement_profit_or_loss_of_today = item.text( "./kessaiSonekiT" ).to_i
897
+ @settlement_profit_or_loss_of_next_business_day = item.text( "./kessaiSonekiT1" ).to_i
898
+ @settlement_profit_or_loss_of_next_next_business_day = item.text( "./kessaiSonekiT2" ).to_i
899
+ @swap_profit_or_loss = item.text( "./swapSoneki" ).to_i
900
+ @freezed_guarantee_money = item.text( "./kosokuShokokin" ).to_i
901
+ @required_guarantee_money = item.text( "./hitsuyoShokokin" ).to_i
902
+ @ordered_guarantee_money = item.text( "./chumonShokokin" ).to_i
903
+
904
+ @guarantee_money_list = []
905
+ item.elements.each( "./torihikiShokokinList/torihikiShokokinListItem" ) { |t|
906
+ @guarantee_money_list << GuaranteeMoney.new(t)
907
+ }
908
+ end
909
+ #余力
910
+ attr :margin, true
911
+ #振替可能額
912
+ attr :transferable_money_amount, true
913
+ #証拠金ステータス
914
+ attr :guarantee_money_status, true
915
+ #証拠金の維持率
916
+ attr :guarantee_money_maintenance_ratio, true
917
+ #時価評価の総額
918
+ attr :market_value, true
919
+ #建玉の評価損益
920
+ attr :appraisal_profit_or_loss_of_open_interest, true
921
+ #口座残高
922
+ attr :balance_in_account, true
923
+ #現金残高
924
+ attr :balance_of_cach, true
925
+ #当日既決済取引の損益
926
+ attr :settlement_profit_or_loss_of_today, true
927
+ #翌営業日既決済取引の損益
928
+ attr :settlement_profit_or_loss_of_next_business_day, true
929
+ #翌々営業日既決済取引の損益
930
+ attr :settlement_profit_or_loss_of_next_next_business_day, true
931
+ #スワップ損益
932
+ attr :swap_profit_or_loss, true
933
+ #拘束されている証拠金
934
+ attr :freezed_guarantee_money, true
935
+ #必要な証拠金
936
+ attr :required_guarantee_money, true
937
+ #注文中の証拠金
938
+ attr :ordered_guarantee_money, true
939
+ #証拠金一覧(ClickClient::FX::GuaranteeMoneyの配列)
940
+ attr :guarantee_money_list, true
941
+ end
942
+
943
+ #
944
+ #===証拠金
945
+ #
946
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
947
+ #レスポンスXMLについては、クリック証券提供のドキュメントを参照ください。
948
+ #
949
+ class GuaranteeMoney < ClickClient::Base
950
+
951
+ #
952
+ #=== コンストラクタ
953
+ #
954
+ #*item*:: 結果要素
955
+ #
956
+ def initialize( item )
957
+ super(item)
958
+ @currency_pair_code = item.attributes["tsukaPairCode"].to_i
959
+ @guarantee_money = item.text( "./torihikiShokokin" ).to_i
960
+ end
961
+ #通貨ペアコード
962
+ attr :currency_pair_code, true
963
+ #証拠金
964
+ attr :guarantee_money, true
965
+ end
966
+
967
+ #
968
+ #===お知らせ
969
+ #
970
+ #定義済みの属性の他に、レスポンスXMLの要素名、属性名でも値にアクセスできます。
971
+ #レスポンスXMLについては、ClickClientインターネット証券提供のドキュメントを参照ください。
972
+ #
973
+ class Message < ClickClient::Base
974
+
975
+ #
976
+ #=== コンストラクタ
977
+ #
978
+ #*item*:: 結果要素
979
+ #
980
+ def initialize( item )
981
+ super(item)
982
+ @title = item.text( "./title" )
983
+ @text = item.text( "./text" )
984
+ end
985
+ #タイトル
986
+ attr :title, true
987
+ #本文
988
+ attr :text, true
989
+ end
990
+ end
991
+
992
+ end