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,337 @@
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 OrderData
16
+ # 注文の種類(新規または決済)
17
+ attr_accessor :order_behavior
18
+
19
+ # 決済対象の建玉ID。決済注文の場合必須。
20
+ attr_accessor :position_id
21
+
22
+ # 売買方向(BUYまたはSELL)
23
+ attr_accessor :order_side
24
+
25
+ # 注文タイプ(LIMIT, MARKET, STOP)
26
+ attr_accessor :order_type
27
+
28
+ # 注文価格。指値注文や逆指値注文の場合必須。
29
+ attr_accessor :price
30
+
31
+ # 注文数量
32
+ attr_accessor :amount
33
+
34
+ # 注文有効期限(GTC, DAY)
35
+ attr_accessor :order_expire
36
+
37
+ # レバレッジ倍率。新規注文の場合のみ。
38
+ attr_accessor :leverage
39
+
40
+ # 建玉決済の挙動(CROSS, FIFO)
41
+ attr_accessor :close_behavior
42
+
43
+ # メイカー注文のみ許可するかどうか
44
+ attr_accessor :post_only
45
+
46
+ # IFD決済指値注文価格
47
+ attr_accessor :ifd_close_limit_price
48
+
49
+ # IFD決済逆指値注文価格
50
+ attr_accessor :ifd_close_stop_price
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'order_behavior' => :'orderBehavior',
56
+ :'position_id' => :'positionId',
57
+ :'order_side' => :'orderSide',
58
+ :'order_type' => :'orderType',
59
+ :'price' => :'price',
60
+ :'amount' => :'amount',
61
+ :'order_expire' => :'orderExpire',
62
+ :'leverage' => :'leverage',
63
+ :'close_behavior' => :'closeBehavior',
64
+ :'post_only' => :'postOnly',
65
+ :'ifd_close_limit_price' => :'ifdCloseLimitPrice',
66
+ :'ifd_close_stop_price' => :'ifdCloseStopPrice'
67
+ }
68
+ end
69
+
70
+ # Attribute type mapping.
71
+ def self.openapi_types
72
+ {
73
+ :'order_behavior' => :'Object',
74
+ :'position_id' => :'Object',
75
+ :'order_side' => :'Object',
76
+ :'order_type' => :'Object',
77
+ :'price' => :'Object',
78
+ :'amount' => :'Object',
79
+ :'order_expire' => :'Object',
80
+ :'leverage' => :'Object',
81
+ :'close_behavior' => :'Object',
82
+ :'post_only' => :'Object',
83
+ :'ifd_close_limit_price' => :'Object',
84
+ :'ifd_close_stop_price' => :'Object'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ ])
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `RakutenTrading::OrderData` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ attributes = attributes.each_with_object({}) { |(k, v), h|
103
+ if (!self.class.attribute_map.key?(k.to_sym))
104
+ fail ArgumentError, "`#{k}` is not a valid attribute in `RakutenTrading::OrderData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
105
+ end
106
+ h[k.to_sym] = v
107
+ }
108
+
109
+ if attributes.key?(:'order_behavior')
110
+ self.order_behavior = attributes[:'order_behavior']
111
+ end
112
+
113
+ if attributes.key?(:'position_id')
114
+ self.position_id = attributes[:'position_id']
115
+ end
116
+
117
+ if attributes.key?(:'order_side')
118
+ self.order_side = attributes[:'order_side']
119
+ end
120
+
121
+ if attributes.key?(:'order_type')
122
+ self.order_type = attributes[:'order_type']
123
+ end
124
+
125
+ if attributes.key?(:'price')
126
+ self.price = attributes[:'price']
127
+ end
128
+
129
+ if attributes.key?(:'amount')
130
+ self.amount = attributes[:'amount']
131
+ end
132
+
133
+ if attributes.key?(:'order_expire')
134
+ self.order_expire = attributes[:'order_expire']
135
+ end
136
+
137
+ if attributes.key?(:'leverage')
138
+ self.leverage = attributes[:'leverage']
139
+ end
140
+
141
+ if attributes.key?(:'close_behavior')
142
+ self.close_behavior = attributes[:'close_behavior']
143
+ end
144
+
145
+ if attributes.key?(:'post_only')
146
+ self.post_only = attributes[:'post_only']
147
+ end
148
+
149
+ if attributes.key?(:'ifd_close_limit_price')
150
+ self.ifd_close_limit_price = attributes[:'ifd_close_limit_price']
151
+ end
152
+
153
+ if attributes.key?(:'ifd_close_stop_price')
154
+ self.ifd_close_stop_price = attributes[:'ifd_close_stop_price']
155
+ end
156
+ end
157
+
158
+ # Show invalid properties with the reasons. Usually used together with valid?
159
+ # @return Array for valid properties with the reasons
160
+ def list_invalid_properties
161
+ invalid_properties = Array.new
162
+ if @order_behavior.nil?
163
+ invalid_properties.push('invalid value for "order_behavior", order_behavior cannot be nil.')
164
+ end
165
+
166
+ if @order_side.nil?
167
+ invalid_properties.push('invalid value for "order_side", order_side cannot be nil.')
168
+ end
169
+
170
+ if @order_type.nil?
171
+ invalid_properties.push('invalid value for "order_type", order_type cannot be nil.')
172
+ end
173
+
174
+ if @amount.nil?
175
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
176
+ end
177
+
178
+ invalid_properties
179
+ end
180
+
181
+ # Check to see if the all the properties in the model are valid
182
+ # @return true if the model is valid
183
+ def valid?
184
+ return false if @order_behavior.nil?
185
+ return false if @order_side.nil?
186
+ return false if @order_type.nil?
187
+ return false if @amount.nil?
188
+ true
189
+ end
190
+
191
+ # Checks equality by comparing each attribute.
192
+ # @param [Object] Object to be compared
193
+ def ==(o)
194
+ return true if self.equal?(o)
195
+ self.class == o.class &&
196
+ order_behavior == o.order_behavior &&
197
+ position_id == o.position_id &&
198
+ order_side == o.order_side &&
199
+ order_type == o.order_type &&
200
+ price == o.price &&
201
+ amount == o.amount &&
202
+ order_expire == o.order_expire &&
203
+ leverage == o.leverage &&
204
+ close_behavior == o.close_behavior &&
205
+ post_only == o.post_only &&
206
+ ifd_close_limit_price == o.ifd_close_limit_price &&
207
+ ifd_close_stop_price == o.ifd_close_stop_price
208
+ end
209
+
210
+ # @see the `==` method
211
+ # @param [Object] Object to be compared
212
+ def eql?(o)
213
+ self == o
214
+ end
215
+
216
+ # Calculates hash code according to all attributes.
217
+ # @return [Integer] Hash code
218
+ def hash
219
+ [order_behavior, position_id, order_side, order_type, price, amount, order_expire, leverage, close_behavior, post_only, ifd_close_limit_price, ifd_close_stop_price].hash
220
+ end
221
+
222
+ # Builds the object from hash
223
+ # @param [Hash] attributes Model attributes in the form of hash
224
+ # @return [Object] Returns the model itself
225
+ def self.build_from_hash(attributes)
226
+ new.build_from_hash(attributes)
227
+ end
228
+
229
+ # Builds the object from hash
230
+ # @param [Hash] attributes Model attributes in the form of hash
231
+ # @return [Object] Returns the model itself
232
+ def build_from_hash(attributes)
233
+ return nil unless attributes.is_a?(Hash)
234
+ self.class.openapi_types.each_pair do |key, type|
235
+ if type =~ /\AArray<(.*)>/i
236
+ # check to ensure the input is an array given that the attribute
237
+ # is documented as an array but the input is not
238
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
239
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
240
+ end
241
+ elsif !attributes[self.class.attribute_map[key]].nil?
242
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
243
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
244
+ self.send("#{key}=", nil)
245
+ end
246
+ end
247
+
248
+ self
249
+ end
250
+
251
+ # Deserializes the data based on type
252
+ # @param string type Data type
253
+ # @param string value Value to be deserialized
254
+ # @return [Object] Deserialized data
255
+ def _deserialize(type, value)
256
+ case type.to_sym
257
+ when :DateTime
258
+ DateTime.parse(value)
259
+ when :Date
260
+ Date.parse(value)
261
+ when :String
262
+ value.to_s
263
+ when :Integer
264
+ value.to_i
265
+ when :Float
266
+ value.to_f
267
+ when :Boolean
268
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
269
+ true
270
+ else
271
+ false
272
+ end
273
+ when :Object
274
+ # generic object (usually a Hash), return directly
275
+ value
276
+ when /\AArray<(?<inner_type>.+)>\z/
277
+ inner_type = Regexp.last_match[:inner_type]
278
+ value.map { |v| _deserialize(inner_type, v) }
279
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
280
+ k_type = Regexp.last_match[:k_type]
281
+ v_type = Regexp.last_match[:v_type]
282
+ {}.tap do |hash|
283
+ value.each do |k, v|
284
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
285
+ end
286
+ end
287
+ else # model
288
+ RakutenTrading.const_get(type).build_from_hash(value)
289
+ end
290
+ end
291
+
292
+ # Returns the string representation of the object
293
+ # @return [String] String presentation of the object
294
+ def to_s
295
+ to_hash.to_s
296
+ end
297
+
298
+ # to_body is an alias to to_hash (backward compatibility)
299
+ # @return [Hash] Returns the object in the form of hash
300
+ def to_body
301
+ to_hash
302
+ end
303
+
304
+ # Returns the object in the form of hash
305
+ # @return [Hash] Returns the object in the form of hash
306
+ def to_hash
307
+ hash = {}
308
+ self.class.attribute_map.each_pair do |attr, param|
309
+ value = self.send(attr)
310
+ if value.nil?
311
+ is_nullable = self.class.openapi_nullable.include?(attr)
312
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
313
+ end
314
+
315
+ hash[param] = _to_hash(value)
316
+ end
317
+ hash
318
+ end
319
+
320
+ # Outputs non-array value in the form of hash
321
+ # For object, use to_hash. Otherwise, just return the value
322
+ # @param [Object] value Any valid value
323
+ # @return [Hash] Returns the value in the form of hash
324
+ def _to_hash(value)
325
+ if value.is_a?(Array)
326
+ value.compact.map { |v| _to_hash(v) }
327
+ elsif value.is_a?(Hash)
328
+ {}.tap do |hash|
329
+ value.each { |k, v| hash[k] = _to_hash(v) }
330
+ end
331
+ elsif value.respond_to? :to_hash
332
+ value.to_hash
333
+ else
334
+ value
335
+ end
336
+ end end
337
+ end