rakuten_trading 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,440 @@
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 OrderDetail
16
+ attr_accessor :id
17
+
18
+ attr_accessor :symbol_id
19
+
20
+ attr_accessor :order_behavior
21
+
22
+ attr_accessor :order_side
23
+
24
+ attr_accessor :order_pattern
25
+
26
+ attr_accessor :order_type
27
+
28
+ attr_accessor :close_behavior
29
+
30
+ attr_accessor :price
31
+
32
+ attr_accessor :average_price
33
+
34
+ attr_accessor :amount
35
+
36
+ attr_accessor :remaining_amount
37
+
38
+ attr_accessor :order_status
39
+
40
+ attr_accessor :post_only
41
+
42
+ attr_accessor :oco1_order_id
43
+
44
+ attr_accessor :oco2_order_id
45
+
46
+ attr_accessor :ifd_open_order_id
47
+
48
+ attr_accessor :ifd_close_limit_price
49
+
50
+ attr_accessor :ifd_close_stop_price
51
+
52
+ attr_accessor :position_id
53
+
54
+ attr_accessor :order_expire
55
+
56
+ attr_accessor :expire_business_date
57
+
58
+ attr_accessor :leverage
59
+
60
+ attr_accessor :necessary_margin
61
+
62
+ attr_accessor :business_date
63
+
64
+ attr_accessor :order_created_at
65
+
66
+ attr_accessor :created_at
67
+
68
+ attr_accessor :updated_at
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'id' => :'id',
74
+ :'symbol_id' => :'symbolId',
75
+ :'order_behavior' => :'orderBehavior',
76
+ :'order_side' => :'orderSide',
77
+ :'order_pattern' => :'orderPattern',
78
+ :'order_type' => :'orderType',
79
+ :'close_behavior' => :'closeBehavior',
80
+ :'price' => :'price',
81
+ :'average_price' => :'averagePrice',
82
+ :'amount' => :'amount',
83
+ :'remaining_amount' => :'remainingAmount',
84
+ :'order_status' => :'orderStatus',
85
+ :'post_only' => :'postOnly',
86
+ :'oco1_order_id' => :'oco1OrderId',
87
+ :'oco2_order_id' => :'oco2OrderId',
88
+ :'ifd_open_order_id' => :'ifdOpenOrderId',
89
+ :'ifd_close_limit_price' => :'ifdCloseLimitPrice',
90
+ :'ifd_close_stop_price' => :'ifdCloseStopPrice',
91
+ :'position_id' => :'positionId',
92
+ :'order_expire' => :'orderExpire',
93
+ :'expire_business_date' => :'expireBusinessDate',
94
+ :'leverage' => :'leverage',
95
+ :'necessary_margin' => :'necessaryMargin',
96
+ :'business_date' => :'businessDate',
97
+ :'order_created_at' => :'orderCreatedAt',
98
+ :'created_at' => :'createdAt',
99
+ :'updated_at' => :'updatedAt'
100
+ }
101
+ end
102
+
103
+ # Attribute type mapping.
104
+ def self.openapi_types
105
+ {
106
+ :'id' => :'Object',
107
+ :'symbol_id' => :'Object',
108
+ :'order_behavior' => :'Object',
109
+ :'order_side' => :'Object',
110
+ :'order_pattern' => :'Object',
111
+ :'order_type' => :'Object',
112
+ :'close_behavior' => :'Object',
113
+ :'price' => :'Object',
114
+ :'average_price' => :'Object',
115
+ :'amount' => :'Object',
116
+ :'remaining_amount' => :'Object',
117
+ :'order_status' => :'Object',
118
+ :'post_only' => :'Object',
119
+ :'oco1_order_id' => :'Object',
120
+ :'oco2_order_id' => :'Object',
121
+ :'ifd_open_order_id' => :'Object',
122
+ :'ifd_close_limit_price' => :'Object',
123
+ :'ifd_close_stop_price' => :'Object',
124
+ :'position_id' => :'Object',
125
+ :'order_expire' => :'Object',
126
+ :'expire_business_date' => :'Object',
127
+ :'leverage' => :'Object',
128
+ :'necessary_margin' => :'Object',
129
+ :'business_date' => :'Object',
130
+ :'order_created_at' => :'Object',
131
+ :'created_at' => :'Object',
132
+ :'updated_at' => :'Object'
133
+ }
134
+ end
135
+
136
+ # List of attributes with nullable: true
137
+ def self.openapi_nullable
138
+ Set.new([
139
+ ])
140
+ end
141
+
142
+ # Initializes the object
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ def initialize(attributes = {})
145
+ if (!attributes.is_a?(Hash))
146
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RakutenTrading::OrderDetail` initialize method"
147
+ end
148
+
149
+ # check to see if the attribute exists and convert string to symbol for hash key
150
+ attributes = attributes.each_with_object({}) { |(k, v), h|
151
+ if (!self.class.attribute_map.key?(k.to_sym))
152
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RakutenTrading::OrderDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
153
+ end
154
+ h[k.to_sym] = v
155
+ }
156
+
157
+ if attributes.key?(:'id')
158
+ self.id = attributes[:'id']
159
+ end
160
+
161
+ if attributes.key?(:'symbol_id')
162
+ self.symbol_id = attributes[:'symbol_id']
163
+ end
164
+
165
+ if attributes.key?(:'order_behavior')
166
+ self.order_behavior = attributes[:'order_behavior']
167
+ end
168
+
169
+ if attributes.key?(:'order_side')
170
+ self.order_side = attributes[:'order_side']
171
+ end
172
+
173
+ if attributes.key?(:'order_pattern')
174
+ self.order_pattern = attributes[:'order_pattern']
175
+ end
176
+
177
+ if attributes.key?(:'order_type')
178
+ self.order_type = attributes[:'order_type']
179
+ end
180
+
181
+ if attributes.key?(:'close_behavior')
182
+ self.close_behavior = attributes[:'close_behavior']
183
+ end
184
+
185
+ if attributes.key?(:'price')
186
+ self.price = attributes[:'price']
187
+ end
188
+
189
+ if attributes.key?(:'average_price')
190
+ self.average_price = attributes[:'average_price']
191
+ end
192
+
193
+ if attributes.key?(:'amount')
194
+ self.amount = attributes[:'amount']
195
+ end
196
+
197
+ if attributes.key?(:'remaining_amount')
198
+ self.remaining_amount = attributes[:'remaining_amount']
199
+ end
200
+
201
+ if attributes.key?(:'order_status')
202
+ self.order_status = attributes[:'order_status']
203
+ end
204
+
205
+ if attributes.key?(:'post_only')
206
+ self.post_only = attributes[:'post_only']
207
+ end
208
+
209
+ if attributes.key?(:'oco1_order_id')
210
+ self.oco1_order_id = attributes[:'oco1_order_id']
211
+ end
212
+
213
+ if attributes.key?(:'oco2_order_id')
214
+ self.oco2_order_id = attributes[:'oco2_order_id']
215
+ end
216
+
217
+ if attributes.key?(:'ifd_open_order_id')
218
+ self.ifd_open_order_id = attributes[:'ifd_open_order_id']
219
+ end
220
+
221
+ if attributes.key?(:'ifd_close_limit_price')
222
+ self.ifd_close_limit_price = attributes[:'ifd_close_limit_price']
223
+ end
224
+
225
+ if attributes.key?(:'ifd_close_stop_price')
226
+ self.ifd_close_stop_price = attributes[:'ifd_close_stop_price']
227
+ end
228
+
229
+ if attributes.key?(:'position_id')
230
+ self.position_id = attributes[:'position_id']
231
+ end
232
+
233
+ if attributes.key?(:'order_expire')
234
+ self.order_expire = attributes[:'order_expire']
235
+ end
236
+
237
+ if attributes.key?(:'expire_business_date')
238
+ self.expire_business_date = attributes[:'expire_business_date']
239
+ end
240
+
241
+ if attributes.key?(:'leverage')
242
+ self.leverage = attributes[:'leverage']
243
+ end
244
+
245
+ if attributes.key?(:'necessary_margin')
246
+ self.necessary_margin = attributes[:'necessary_margin']
247
+ end
248
+
249
+ if attributes.key?(:'business_date')
250
+ self.business_date = attributes[:'business_date']
251
+ end
252
+
253
+ if attributes.key?(:'order_created_at')
254
+ self.order_created_at = attributes[:'order_created_at']
255
+ end
256
+
257
+ if attributes.key?(:'created_at')
258
+ self.created_at = attributes[:'created_at']
259
+ end
260
+
261
+ if attributes.key?(:'updated_at')
262
+ self.updated_at = attributes[:'updated_at']
263
+ end
264
+ end
265
+
266
+ # Show invalid properties with the reasons. Usually used together with valid?
267
+ # @return Array for valid properties with the reasons
268
+ def list_invalid_properties
269
+ invalid_properties = Array.new
270
+ invalid_properties
271
+ end
272
+
273
+ # Check to see if the all the properties in the model are valid
274
+ # @return true if the model is valid
275
+ def valid?
276
+ true
277
+ end
278
+
279
+ # Checks equality by comparing each attribute.
280
+ # @param [Object] Object to be compared
281
+ def ==(o)
282
+ return true if self.equal?(o)
283
+ self.class == o.class &&
284
+ id == o.id &&
285
+ symbol_id == o.symbol_id &&
286
+ order_behavior == o.order_behavior &&
287
+ order_side == o.order_side &&
288
+ order_pattern == o.order_pattern &&
289
+ order_type == o.order_type &&
290
+ close_behavior == o.close_behavior &&
291
+ price == o.price &&
292
+ average_price == o.average_price &&
293
+ amount == o.amount &&
294
+ remaining_amount == o.remaining_amount &&
295
+ order_status == o.order_status &&
296
+ post_only == o.post_only &&
297
+ oco1_order_id == o.oco1_order_id &&
298
+ oco2_order_id == o.oco2_order_id &&
299
+ ifd_open_order_id == o.ifd_open_order_id &&
300
+ ifd_close_limit_price == o.ifd_close_limit_price &&
301
+ ifd_close_stop_price == o.ifd_close_stop_price &&
302
+ position_id == o.position_id &&
303
+ order_expire == o.order_expire &&
304
+ expire_business_date == o.expire_business_date &&
305
+ leverage == o.leverage &&
306
+ necessary_margin == o.necessary_margin &&
307
+ business_date == o.business_date &&
308
+ order_created_at == o.order_created_at &&
309
+ created_at == o.created_at &&
310
+ updated_at == o.updated_at
311
+ end
312
+
313
+ # @see the `==` method
314
+ # @param [Object] Object to be compared
315
+ def eql?(o)
316
+ self == o
317
+ end
318
+
319
+ # Calculates hash code according to all attributes.
320
+ # @return [Integer] Hash code
321
+ def hash
322
+ [id, symbol_id, order_behavior, order_side, order_pattern, order_type, close_behavior, price, average_price, amount, remaining_amount, order_status, post_only, oco1_order_id, oco2_order_id, ifd_open_order_id, ifd_close_limit_price, ifd_close_stop_price, position_id, order_expire, expire_business_date, leverage, necessary_margin, business_date, order_created_at, created_at, updated_at].hash
323
+ end
324
+
325
+ # Builds the object from hash
326
+ # @param [Hash] attributes Model attributes in the form of hash
327
+ # @return [Object] Returns the model itself
328
+ def self.build_from_hash(attributes)
329
+ new.build_from_hash(attributes)
330
+ end
331
+
332
+ # Builds the object from hash
333
+ # @param [Hash] attributes Model attributes in the form of hash
334
+ # @return [Object] Returns the model itself
335
+ def build_from_hash(attributes)
336
+ return nil unless attributes.is_a?(Hash)
337
+ self.class.openapi_types.each_pair do |key, type|
338
+ if type =~ /\AArray<(.*)>/i
339
+ # check to ensure the input is an array given that the attribute
340
+ # is documented as an array but the input is not
341
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
342
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
343
+ end
344
+ elsif !attributes[self.class.attribute_map[key]].nil?
345
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
346
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
347
+ self.send("#{key}=", nil)
348
+ end
349
+ end
350
+
351
+ self
352
+ end
353
+
354
+ # Deserializes the data based on type
355
+ # @param string type Data type
356
+ # @param string value Value to be deserialized
357
+ # @return [Object] Deserialized data
358
+ def _deserialize(type, value)
359
+ case type.to_sym
360
+ when :DateTime
361
+ DateTime.parse(value)
362
+ when :Date
363
+ Date.parse(value)
364
+ when :String
365
+ value.to_s
366
+ when :Integer
367
+ value.to_i
368
+ when :Float
369
+ value.to_f
370
+ when :Boolean
371
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
372
+ true
373
+ else
374
+ false
375
+ end
376
+ when :Object
377
+ # generic object (usually a Hash), return directly
378
+ value
379
+ when /\AArray<(?<inner_type>.+)>\z/
380
+ inner_type = Regexp.last_match[:inner_type]
381
+ value.map { |v| _deserialize(inner_type, v) }
382
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
383
+ k_type = Regexp.last_match[:k_type]
384
+ v_type = Regexp.last_match[:v_type]
385
+ {}.tap do |hash|
386
+ value.each do |k, v|
387
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
388
+ end
389
+ end
390
+ else # model
391
+ RakutenTrading.const_get(type).build_from_hash(value)
392
+ end
393
+ end
394
+
395
+ # Returns the string representation of the object
396
+ # @return [String] String presentation of the object
397
+ def to_s
398
+ to_hash.to_s
399
+ end
400
+
401
+ # to_body is an alias to to_hash (backward compatibility)
402
+ # @return [Hash] Returns the object in the form of hash
403
+ def to_body
404
+ to_hash
405
+ end
406
+
407
+ # Returns the object in the form of hash
408
+ # @return [Hash] Returns the object in the form of hash
409
+ def to_hash
410
+ hash = {}
411
+ self.class.attribute_map.each_pair do |attr, param|
412
+ value = self.send(attr)
413
+ if value.nil?
414
+ is_nullable = self.class.openapi_nullable.include?(attr)
415
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
416
+ end
417
+
418
+ hash[param] = _to_hash(value)
419
+ end
420
+ hash
421
+ end
422
+
423
+ # Outputs non-array value in the form of hash
424
+ # For object, use to_hash. Otherwise, just return the value
425
+ # @param [Object] value Any valid value
426
+ # @return [Hash] Returns the value in the form of hash
427
+ def _to_hash(value)
428
+ if value.is_a?(Array)
429
+ value.compact.map { |v| _to_hash(v) }
430
+ elsif value.is_a?(Hash)
431
+ {}.tap do |hash|
432
+ value.each { |k, v| hash[k] = _to_hash(v) }
433
+ end
434
+ elsif value.respond_to? :to_hash
435
+ value.to_hash
436
+ else
437
+ value
438
+ end
439
+ end end
440
+ end