rakuten_trading 1.0.0

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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +455 -0
  4. data/Rakefile +8 -0
  5. data/docs/CfdOrderBody.md +9 -0
  6. data/docs/CfdOrderBody1.md +9 -0
  7. data/docs/CfdTrade.md +28 -0
  8. data/docs/InlineResponse200.md +22 -0
  9. data/docs/InlineResponse2001.md +9 -0
  10. data/docs/InlineResponse2001Candlesticks.md +12 -0
  11. data/docs/InlineResponse2002.md +14 -0
  12. data/docs/InlineResponse2003.md +15 -0
  13. data/docs/InlineResponse2004.md +9 -0
  14. data/docs/InlineResponse2005.md +8 -0
  15. data/docs/InlineResponse2006.md +19 -0
  16. data/docs/InlineResponse2007.md +18 -0
  17. data/docs/Order.md +9 -0
  18. data/docs/OrderData.md +18 -0
  19. data/docs/OrderDetail.md +33 -0
  20. data/docs/OrderResponse.md +29 -0
  21. data/docs/PrivateApi.md +518 -0
  22. data/docs/PublicApi.md +304 -0
  23. data/docs/Trade.md +12 -0
  24. data/git_push.sh +55 -0
  25. data/lib/rakuten_trading/api/private_api.rb +537 -0
  26. data/lib/rakuten_trading/api/public_api.rb +315 -0
  27. data/lib/rakuten_trading/api_client.rb +388 -0
  28. data/lib/rakuten_trading/api_error.rb +57 -0
  29. data/lib/rakuten_trading/configuration.rb +212 -0
  30. data/lib/rakuten_trading/models/cfd_order_body.rb +224 -0
  31. data/lib/rakuten_trading/models/cfd_order_body_1.rb +224 -0
  32. data/lib/rakuten_trading/models/cfd_trade.rb +417 -0
  33. data/lib/rakuten_trading/models/inline_response_200.rb +357 -0
  34. data/lib/rakuten_trading/models/inline_response_200_1.rb +226 -0
  35. data/lib/rakuten_trading/models/inline_response_200_1_candlesticks.rb +251 -0
  36. data/lib/rakuten_trading/models/inline_response_200_2.rb +275 -0
  37. data/lib/rakuten_trading/models/inline_response_200_3.rb +281 -0
  38. data/lib/rakuten_trading/models/inline_response_200_4.rb +226 -0
  39. data/lib/rakuten_trading/models/inline_response_200_5.rb +217 -0
  40. data/lib/rakuten_trading/models/inline_response_200_6.rb +327 -0
  41. data/lib/rakuten_trading/models/inline_response_200_7.rb +317 -0
  42. data/lib/rakuten_trading/models/order.rb +224 -0
  43. data/lib/rakuten_trading/models/order_data.rb +337 -0
  44. data/lib/rakuten_trading/models/order_detail.rb +440 -0
  45. data/lib/rakuten_trading/models/order_response.rb +427 -0
  46. data/lib/rakuten_trading/models/trade.rb +253 -0
  47. data/lib/rakuten_trading/version.rb +14 -0
  48. data/lib/rakuten_trading.rb +57 -0
  49. data/rakuten_trading.gemspec +38 -0
  50. data/rakuten_trading_api.yml +1256 -0
  51. data/spec/api/private_api_spec.rb +151 -0
  52. data/spec/api/public_api_spec.rb +94 -0
  53. data/spec/api_client_spec.rb +225 -0
  54. data/spec/base_object_spec.rb +109 -0
  55. data/spec/configuration_spec.rb +41 -0
  56. data/spec/models/cfd_order_body_1_spec.rb +52 -0
  57. data/spec/models/cfd_order_body_spec.rb +52 -0
  58. data/spec/models/cfd_trade_spec.rb +166 -0
  59. data/spec/models/inline_response_200_1_candlesticks_spec.rb +70 -0
  60. data/spec/models/inline_response_200_1_spec.rb +52 -0
  61. data/spec/models/inline_response_200_2_spec.rb +82 -0
  62. data/spec/models/inline_response_200_3_spec.rb +88 -0
  63. data/spec/models/inline_response_200_4_spec.rb +52 -0
  64. data/spec/models/inline_response_200_5_spec.rb +46 -0
  65. data/spec/models/inline_response_200_6_spec.rb +112 -0
  66. data/spec/models/inline_response_200_7_spec.rb +106 -0
  67. data/spec/models/inline_response_200_spec.rb +130 -0
  68. data/spec/models/order_data_spec.rb +106 -0
  69. data/spec/models/order_detail_spec.rb +196 -0
  70. data/spec/models/order_response_spec.rb +172 -0
  71. data/spec/models/order_spec.rb +52 -0
  72. data/spec/models/trade_spec.rb +70 -0
  73. data/spec/spec_helper.rb +110 -0
  74. metadata +201 -0
@@ -0,0 +1,417 @@
1
+ =begin
2
+ #API(証拠金取引所)
3
+
4
+ #本APIを利用することにより、取り扱っている銘柄一覧の取得、ローソク足データの取得、板の取得、歩値の取得、注文、残高照会といった操作を行う事ができます。 ## 留意事項 - APIキーはお客様のアカウント情報と紐付いております。もし第三者がお客様のAPIキーを知った場合、遠隔で売買注文の操作が可能となります。APIキーを第三者へ渡す事はセキュリティリスクを鑑みお控えください。 - 他社が提供するAPI機能を使用した自動売買取引ツールは、ご自身の判断と責任でご利用ください。 - リクエストパラメーターやレスポンスの日時についてはミリ秒のtimestamp(Unix Time)を用います。 - 日時の範囲検索は「以上・未満」で検索します。
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.54
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module RakutenTrading
15
+ class CfdTrade
16
+ # トレードID
17
+ attr_accessor :id
18
+
19
+ # シンボルID
20
+ attr_accessor :symbol_id
21
+
22
+ # 新規注文または決済注文
23
+ attr_accessor :order_behavior
24
+
25
+ # 新規約定または決済約定
26
+ attr_accessor :trade_behavior
27
+
28
+ # 売買方向
29
+ attr_accessor :order_side
30
+
31
+ # 注文方法
32
+ attr_accessor :order_pattern
33
+
34
+ # 執行条件
35
+ attr_accessor :order_type
36
+
37
+ # 約定アクション
38
+ attr_accessor :trade_action
39
+
40
+ # 約定価格
41
+ attr_accessor :price
42
+
43
+ # 約定数量
44
+ attr_accessor :amount
45
+
46
+ # 売買損益
47
+ attr_accessor :profit
48
+
49
+ # 約定手数料
50
+ attr_accessor :fee
51
+
52
+ # 実現建玉管理料(円)
53
+ attr_accessor :position_fee
54
+
55
+ # 決済損益(円)
56
+ attr_accessor :close_trade_profit
57
+
58
+ # 約定代金(円)
59
+ attr_accessor :asset_amount
60
+
61
+ # 建値
62
+ attr_accessor :open_price
63
+
64
+ # 円換算価格(約定時点)
65
+ attr_accessor :jpy_conversion
66
+
67
+ # 注文ID
68
+ attr_accessor :order_id
69
+
70
+ # 建玉ID
71
+ attr_accessor :position_id
72
+
73
+ # 取引日
74
+ attr_accessor :business_date
75
+
76
+ # 作成日時
77
+ attr_accessor :created_at
78
+
79
+ # 更新日時
80
+ attr_accessor :updated_at
81
+
82
+ # Attribute mapping from ruby-style variable name to JSON key.
83
+ def self.attribute_map
84
+ {
85
+ :'id' => :'id',
86
+ :'symbol_id' => :'symbolId',
87
+ :'order_behavior' => :'orderBehavior',
88
+ :'trade_behavior' => :'tradeBehavior',
89
+ :'order_side' => :'orderSide',
90
+ :'order_pattern' => :'orderPattern',
91
+ :'order_type' => :'orderType',
92
+ :'trade_action' => :'tradeAction',
93
+ :'price' => :'price',
94
+ :'amount' => :'amount',
95
+ :'profit' => :'profit',
96
+ :'fee' => :'fee',
97
+ :'position_fee' => :'positionFee',
98
+ :'close_trade_profit' => :'closeTradeProfit',
99
+ :'asset_amount' => :'assetAmount',
100
+ :'open_price' => :'openPrice',
101
+ :'jpy_conversion' => :'jpyConversion',
102
+ :'order_id' => :'orderId',
103
+ :'position_id' => :'positionId',
104
+ :'business_date' => :'businessDate',
105
+ :'created_at' => :'createdAt',
106
+ :'updated_at' => :'updatedAt'
107
+ }
108
+ end
109
+
110
+ # Attribute type mapping.
111
+ def self.openapi_types
112
+ {
113
+ :'id' => :'Object',
114
+ :'symbol_id' => :'Object',
115
+ :'order_behavior' => :'Object',
116
+ :'trade_behavior' => :'Object',
117
+ :'order_side' => :'Object',
118
+ :'order_pattern' => :'Object',
119
+ :'order_type' => :'Object',
120
+ :'trade_action' => :'Object',
121
+ :'price' => :'Object',
122
+ :'amount' => :'Object',
123
+ :'profit' => :'Object',
124
+ :'fee' => :'Object',
125
+ :'position_fee' => :'Object',
126
+ :'close_trade_profit' => :'Object',
127
+ :'asset_amount' => :'Object',
128
+ :'open_price' => :'Object',
129
+ :'jpy_conversion' => :'Object',
130
+ :'order_id' => :'Object',
131
+ :'position_id' => :'Object',
132
+ :'business_date' => :'Object',
133
+ :'created_at' => :'Object',
134
+ :'updated_at' => :'Object'
135
+ }
136
+ end
137
+
138
+ # List of attributes with nullable: true
139
+ def self.openapi_nullable
140
+ Set.new([
141
+ ])
142
+ end
143
+
144
+ # Initializes the object
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ def initialize(attributes = {})
147
+ if (!attributes.is_a?(Hash))
148
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RakutenTrading::CfdTrade` initialize method"
149
+ end
150
+
151
+ # check to see if the attribute exists and convert string to symbol for hash key
152
+ attributes = attributes.each_with_object({}) { |(k, v), h|
153
+ if (!self.class.attribute_map.key?(k.to_sym))
154
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RakutenTrading::CfdTrade`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
155
+ end
156
+ h[k.to_sym] = v
157
+ }
158
+
159
+ if attributes.key?(:'id')
160
+ self.id = attributes[:'id']
161
+ end
162
+
163
+ if attributes.key?(:'symbol_id')
164
+ self.symbol_id = attributes[:'symbol_id']
165
+ end
166
+
167
+ if attributes.key?(:'order_behavior')
168
+ self.order_behavior = attributes[:'order_behavior']
169
+ end
170
+
171
+ if attributes.key?(:'trade_behavior')
172
+ self.trade_behavior = attributes[:'trade_behavior']
173
+ end
174
+
175
+ if attributes.key?(:'order_side')
176
+ self.order_side = attributes[:'order_side']
177
+ end
178
+
179
+ if attributes.key?(:'order_pattern')
180
+ self.order_pattern = attributes[:'order_pattern']
181
+ end
182
+
183
+ if attributes.key?(:'order_type')
184
+ self.order_type = attributes[:'order_type']
185
+ end
186
+
187
+ if attributes.key?(:'trade_action')
188
+ self.trade_action = attributes[:'trade_action']
189
+ end
190
+
191
+ if attributes.key?(:'price')
192
+ self.price = attributes[:'price']
193
+ end
194
+
195
+ if attributes.key?(:'amount')
196
+ self.amount = attributes[:'amount']
197
+ end
198
+
199
+ if attributes.key?(:'profit')
200
+ self.profit = attributes[:'profit']
201
+ end
202
+
203
+ if attributes.key?(:'fee')
204
+ self.fee = attributes[:'fee']
205
+ end
206
+
207
+ if attributes.key?(:'position_fee')
208
+ self.position_fee = attributes[:'position_fee']
209
+ end
210
+
211
+ if attributes.key?(:'close_trade_profit')
212
+ self.close_trade_profit = attributes[:'close_trade_profit']
213
+ end
214
+
215
+ if attributes.key?(:'asset_amount')
216
+ self.asset_amount = attributes[:'asset_amount']
217
+ end
218
+
219
+ if attributes.key?(:'open_price')
220
+ self.open_price = attributes[:'open_price']
221
+ end
222
+
223
+ if attributes.key?(:'jpy_conversion')
224
+ self.jpy_conversion = attributes[:'jpy_conversion']
225
+ end
226
+
227
+ if attributes.key?(:'order_id')
228
+ self.order_id = attributes[:'order_id']
229
+ end
230
+
231
+ if attributes.key?(:'position_id')
232
+ self.position_id = attributes[:'position_id']
233
+ end
234
+
235
+ if attributes.key?(:'business_date')
236
+ self.business_date = attributes[:'business_date']
237
+ end
238
+
239
+ if attributes.key?(:'created_at')
240
+ self.created_at = attributes[:'created_at']
241
+ end
242
+
243
+ if attributes.key?(:'updated_at')
244
+ self.updated_at = attributes[:'updated_at']
245
+ end
246
+ end
247
+
248
+ # Show invalid properties with the reasons. Usually used together with valid?
249
+ # @return Array for valid properties with the reasons
250
+ def list_invalid_properties
251
+ invalid_properties = Array.new
252
+ invalid_properties
253
+ end
254
+
255
+ # Check to see if the all the properties in the model are valid
256
+ # @return true if the model is valid
257
+ def valid?
258
+ true
259
+ end
260
+
261
+ # Checks equality by comparing each attribute.
262
+ # @param [Object] Object to be compared
263
+ def ==(o)
264
+ return true if self.equal?(o)
265
+ self.class == o.class &&
266
+ id == o.id &&
267
+ symbol_id == o.symbol_id &&
268
+ order_behavior == o.order_behavior &&
269
+ trade_behavior == o.trade_behavior &&
270
+ order_side == o.order_side &&
271
+ order_pattern == o.order_pattern &&
272
+ order_type == o.order_type &&
273
+ trade_action == o.trade_action &&
274
+ price == o.price &&
275
+ amount == o.amount &&
276
+ profit == o.profit &&
277
+ fee == o.fee &&
278
+ position_fee == o.position_fee &&
279
+ close_trade_profit == o.close_trade_profit &&
280
+ asset_amount == o.asset_amount &&
281
+ open_price == o.open_price &&
282
+ jpy_conversion == o.jpy_conversion &&
283
+ order_id == o.order_id &&
284
+ position_id == o.position_id &&
285
+ business_date == o.business_date &&
286
+ created_at == o.created_at &&
287
+ updated_at == o.updated_at
288
+ end
289
+
290
+ # @see the `==` method
291
+ # @param [Object] Object to be compared
292
+ def eql?(o)
293
+ self == o
294
+ end
295
+
296
+ # Calculates hash code according to all attributes.
297
+ # @return [Integer] Hash code
298
+ def hash
299
+ [id, symbol_id, order_behavior, trade_behavior, order_side, order_pattern, order_type, trade_action, price, amount, profit, fee, position_fee, close_trade_profit, asset_amount, open_price, jpy_conversion, order_id, position_id, business_date, created_at, updated_at].hash
300
+ end
301
+
302
+ # Builds the object from hash
303
+ # @param [Hash] attributes Model attributes in the form of hash
304
+ # @return [Object] Returns the model itself
305
+ def self.build_from_hash(attributes)
306
+ new.build_from_hash(attributes)
307
+ end
308
+
309
+ # Builds the object from hash
310
+ # @param [Hash] attributes Model attributes in the form of hash
311
+ # @return [Object] Returns the model itself
312
+ def build_from_hash(attributes)
313
+ return nil unless attributes.is_a?(Hash)
314
+ self.class.openapi_types.each_pair do |key, type|
315
+ if type =~ /\AArray<(.*)>/i
316
+ # check to ensure the input is an array given that the attribute
317
+ # is documented as an array but the input is not
318
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
319
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
320
+ end
321
+ elsif !attributes[self.class.attribute_map[key]].nil?
322
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
323
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
324
+ self.send("#{key}=", nil)
325
+ end
326
+ end
327
+
328
+ self
329
+ end
330
+
331
+ # Deserializes the data based on type
332
+ # @param string type Data type
333
+ # @param string value Value to be deserialized
334
+ # @return [Object] Deserialized data
335
+ def _deserialize(type, value)
336
+ case type.to_sym
337
+ when :DateTime
338
+ DateTime.parse(value)
339
+ when :Date
340
+ Date.parse(value)
341
+ when :String
342
+ value.to_s
343
+ when :Integer
344
+ value.to_i
345
+ when :Float
346
+ value.to_f
347
+ when :Boolean
348
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
349
+ true
350
+ else
351
+ false
352
+ end
353
+ when :Object
354
+ # generic object (usually a Hash), return directly
355
+ value
356
+ when /\AArray<(?<inner_type>.+)>\z/
357
+ inner_type = Regexp.last_match[:inner_type]
358
+ value.map { |v| _deserialize(inner_type, v) }
359
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
360
+ k_type = Regexp.last_match[:k_type]
361
+ v_type = Regexp.last_match[:v_type]
362
+ {}.tap do |hash|
363
+ value.each do |k, v|
364
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
365
+ end
366
+ end
367
+ else # model
368
+ RakutenTrading.const_get(type).build_from_hash(value)
369
+ end
370
+ end
371
+
372
+ # Returns the string representation of the object
373
+ # @return [String] String presentation of the object
374
+ def to_s
375
+ to_hash.to_s
376
+ end
377
+
378
+ # to_body is an alias to to_hash (backward compatibility)
379
+ # @return [Hash] Returns the object in the form of hash
380
+ def to_body
381
+ to_hash
382
+ end
383
+
384
+ # Returns the object in the form of hash
385
+ # @return [Hash] Returns the object in the form of hash
386
+ def to_hash
387
+ hash = {}
388
+ self.class.attribute_map.each_pair do |attr, param|
389
+ value = self.send(attr)
390
+ if value.nil?
391
+ is_nullable = self.class.openapi_nullable.include?(attr)
392
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
393
+ end
394
+
395
+ hash[param] = _to_hash(value)
396
+ end
397
+ hash
398
+ end
399
+
400
+ # Outputs non-array value in the form of hash
401
+ # For object, use to_hash. Otherwise, just return the value
402
+ # @param [Object] value Any valid value
403
+ # @return [Hash] Returns the value in the form of hash
404
+ def _to_hash(value)
405
+ if value.is_a?(Array)
406
+ value.compact.map { |v| _to_hash(v) }
407
+ elsif value.is_a?(Hash)
408
+ {}.tap do |hash|
409
+ value.each { |k, v| hash[k] = _to_hash(v) }
410
+ end
411
+ elsif value.respond_to? :to_hash
412
+ value.to_hash
413
+ else
414
+ value
415
+ end
416
+ end end
417
+ end