snaptrade 2.0.185 → 2.0.187

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +52 -2
  4. data/lib/snaptrade/api/experimental_endpoints_api.rb +141 -0
  5. data/lib/snaptrade/models/account_order_record.rb +23 -1
  6. data/lib/snaptrade/models/account_order_record_option_symbol.rb +1 -1
  7. data/lib/snaptrade/models/account_order_record_quote_universal_symbol.rb +1 -1
  8. data/lib/snaptrade/models/account_order_record_universal_symbol.rb +1 -1
  9. data/lib/snaptrade/models/account_order_record_v2.rb +57 -1
  10. data/lib/snaptrade/models/account_position.rb +288 -0
  11. data/lib/snaptrade/models/account_universal_activity_option_symbol.rb +1 -1
  12. data/lib/snaptrade/models/account_universal_activity_symbol.rb +1 -1
  13. data/lib/snaptrade/models/all_account_positions_response.rb +262 -0
  14. data/lib/snaptrade/models/complex_order_leg.rb +1 -1
  15. data/lib/snaptrade/models/complex_order_leg_order_role.rb +38 -0
  16. data/lib/snaptrade/models/crypto_instrument.rb +311 -0
  17. data/lib/snaptrade/models/crypto_instrument_kind.rb +36 -0
  18. data/lib/snaptrade/models/etf_instrument.rb +311 -0
  19. data/lib/snaptrade/models/etf_instrument_kind.rb +36 -0
  20. data/lib/snaptrade/models/future_instrument.rb +326 -0
  21. data/lib/snaptrade/models/future_instrument_kind.rb +36 -0
  22. data/lib/snaptrade/models/instrument.rb +61 -0
  23. data/lib/snaptrade/models/kind.rb +36 -0
  24. data/lib/snaptrade/models/option_instrument.rb +322 -0
  25. data/lib/snaptrade/models/option_instrument_kind.rb +36 -0
  26. data/lib/snaptrade/models/options_symbol.rb +1 -1
  27. data/lib/snaptrade/models/options_symbol_option_type.rb +37 -0
  28. data/lib/snaptrade/models/order_updated_response_order.rb +23 -1
  29. data/lib/snaptrade/models/other_instrument.rb +311 -0
  30. data/lib/snaptrade/models/other_instrument_kind.rb +36 -0
  31. data/lib/snaptrade/models/stock_instrument.rb +311 -0
  32. data/lib/snaptrade/models/{symbol_figi_instrument.rb → stock_instrument_figi_instrument.rb} +3 -3
  33. data/lib/snaptrade/models/symbol.rb +1 -1
  34. data/lib/snaptrade/models/underlying_option_instrument.rb +57 -0
  35. data/lib/snaptrade/models/underlying_symbol.rb +1 -1
  36. data/lib/snaptrade/models/universal_symbol.rb +1 -1
  37. data/lib/snaptrade/version.rb +1 -1
  38. data/lib/snaptrade.rb +19 -1
  39. data/spec/api/experimental_endpoints_api_spec.rb +16 -0
  40. data/spec/models/account_order_record_spec.rb +12 -0
  41. data/spec/models/account_order_record_v2_spec.rb +16 -0
  42. data/spec/models/account_position_spec.rb +65 -0
  43. data/spec/models/all_account_positions_response_spec.rb +47 -0
  44. data/spec/models/complex_order_leg_order_role_spec.rb +23 -0
  45. data/spec/models/crypto_instrument_kind_spec.rb +23 -0
  46. data/spec/models/crypto_instrument_spec.rb +71 -0
  47. data/spec/models/etf_instrument_kind_spec.rb +23 -0
  48. data/spec/models/etf_instrument_spec.rb +71 -0
  49. data/spec/models/future_instrument_kind_spec.rb +23 -0
  50. data/spec/models/future_instrument_spec.rb +77 -0
  51. data/spec/models/instrument_spec.rb +38 -0
  52. data/spec/models/kind_spec.rb +23 -0
  53. data/spec/models/option_instrument_kind_spec.rb +23 -0
  54. data/spec/models/option_instrument_spec.rb +71 -0
  55. data/spec/models/options_symbol_option_type_spec.rb +23 -0
  56. data/spec/models/order_updated_response_order_spec.rb +12 -0
  57. data/spec/models/other_instrument_kind_spec.rb +23 -0
  58. data/spec/models/other_instrument_spec.rb +71 -0
  59. data/spec/models/{symbol_figi_instrument_spec.rb → stock_instrument_figi_instrument_spec.rb} +6 -6
  60. data/spec/models/stock_instrument_spec.rb +71 -0
  61. data/spec/models/underlying_option_instrument_spec.rb +38 -0
  62. metadata +222 -168
@@ -0,0 +1,322 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'date'
11
+ require 'time'
12
+
13
+ module SnapTrade
14
+ # Option instrument metadata for a V2 position.
15
+ class OptionInstrument
16
+ attr_accessor :kind
17
+
18
+ # Unique identifier for the option instrument.
19
+ attr_accessor :id
20
+
21
+ # OCC symbol for the option contract.
22
+ attr_accessor :symbol
23
+
24
+ # Whether the contract is a call or put.
25
+ attr_accessor :option_type
26
+
27
+ # Strike price for the option contract.
28
+ attr_accessor :strike_price
29
+
30
+ # Expiration date of the option contract.
31
+ attr_accessor :expiration_date
32
+
33
+ # Human-readable description of the option contract.
34
+ attr_accessor :description
35
+
36
+ attr_accessor :underlying
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'kind' => :'kind',
42
+ :'id' => :'id',
43
+ :'symbol' => :'symbol',
44
+ :'option_type' => :'option_type',
45
+ :'strike_price' => :'strike_price',
46
+ :'expiration_date' => :'expiration_date',
47
+ :'description' => :'description',
48
+ :'underlying' => :'underlying'
49
+ }
50
+ end
51
+
52
+ # Returns all the JSON keys this model knows about
53
+ def self.acceptable_attributes
54
+ attribute_map.values
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'kind' => :'OptionInstrumentKind',
61
+ :'id' => :'String',
62
+ :'symbol' => :'String',
63
+ :'option_type' => :'OptionType',
64
+ :'strike_price' => :'Float',
65
+ :'expiration_date' => :'Date',
66
+ :'description' => :'String',
67
+ :'underlying' => :'UnderlyingOptionInstrument'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ :'description',
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::OptionInstrument` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::OptionInstrument`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'kind')
94
+ self.kind = attributes[:'kind']
95
+ end
96
+
97
+ if attributes.key?(:'id')
98
+ self.id = attributes[:'id']
99
+ end
100
+
101
+ if attributes.key?(:'symbol')
102
+ self.symbol = attributes[:'symbol']
103
+ end
104
+
105
+ if attributes.key?(:'option_type')
106
+ self.option_type = attributes[:'option_type']
107
+ end
108
+
109
+ if attributes.key?(:'strike_price')
110
+ self.strike_price = attributes[:'strike_price']
111
+ end
112
+
113
+ if attributes.key?(:'expiration_date')
114
+ self.expiration_date = attributes[:'expiration_date']
115
+ end
116
+
117
+ if attributes.key?(:'description')
118
+ self.description = attributes[:'description']
119
+ end
120
+
121
+ if attributes.key?(:'underlying')
122
+ self.underlying = attributes[:'underlying']
123
+ end
124
+ end
125
+
126
+ # Show invalid properties with the reasons. Usually used together with valid?
127
+ # @return Array for valid properties with the reasons
128
+ def list_invalid_properties
129
+ invalid_properties = Array.new
130
+ if @kind.nil?
131
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
132
+ end
133
+
134
+ if @id.nil?
135
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
136
+ end
137
+
138
+ if @symbol.nil?
139
+ invalid_properties.push('invalid value for "symbol", symbol cannot be nil.')
140
+ end
141
+
142
+ if @option_type.nil?
143
+ invalid_properties.push('invalid value for "option_type", option_type cannot be nil.')
144
+ end
145
+
146
+ if @strike_price.nil?
147
+ invalid_properties.push('invalid value for "strike_price", strike_price cannot be nil.')
148
+ end
149
+
150
+ if @expiration_date.nil?
151
+ invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.')
152
+ end
153
+
154
+ if @underlying.nil?
155
+ invalid_properties.push('invalid value for "underlying", underlying cannot be nil.')
156
+ end
157
+
158
+ invalid_properties
159
+ end
160
+
161
+ # Check to see if the all the properties in the model are valid
162
+ # @return true if the model is valid
163
+ def valid?
164
+ return false if @kind.nil?
165
+ return false if @id.nil?
166
+ return false if @symbol.nil?
167
+ return false if @option_type.nil?
168
+ return false if @strike_price.nil?
169
+ return false if @expiration_date.nil?
170
+ return false if @underlying.nil?
171
+ true
172
+ end
173
+
174
+ # Checks equality by comparing each attribute.
175
+ # @param [Object] Object to be compared
176
+ def ==(o)
177
+ return true if self.equal?(o)
178
+ self.class == o.class &&
179
+ kind == o.kind &&
180
+ id == o.id &&
181
+ symbol == o.symbol &&
182
+ option_type == o.option_type &&
183
+ strike_price == o.strike_price &&
184
+ expiration_date == o.expiration_date &&
185
+ description == o.description &&
186
+ underlying == o.underlying
187
+ end
188
+
189
+ # @see the `==` method
190
+ # @param [Object] Object to be compared
191
+ def eql?(o)
192
+ self == o
193
+ end
194
+
195
+ # Calculates hash code according to all attributes.
196
+ # @return [Integer] Hash code
197
+ def hash
198
+ [kind, id, symbol, option_type, strike_price, expiration_date, description, underlying].hash
199
+ end
200
+
201
+ # Builds the object from hash
202
+ # @param [Hash] attributes Model attributes in the form of hash
203
+ # @return [Object] Returns the model itself
204
+ def self.build_from_hash(attributes)
205
+ new.build_from_hash(attributes)
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def build_from_hash(attributes)
212
+ return nil unless attributes.is_a?(Hash)
213
+ attributes = attributes.transform_keys(&:to_sym)
214
+ self.class.openapi_types.each_pair do |key, type|
215
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
216
+ self.send("#{key}=", nil)
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
221
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
222
+ end
223
+ elsif !attributes[self.class.attribute_map[key]].nil?
224
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
225
+ end
226
+ end
227
+
228
+ self
229
+ end
230
+
231
+ # Deserializes the data based on type
232
+ # @param string type Data type
233
+ # @param string value Value to be deserialized
234
+ # @return [Object] Deserialized data
235
+ def _deserialize(type, value)
236
+ case type.to_sym
237
+ when :Time
238
+ Time.parse(value)
239
+ when :Date
240
+ Date.parse(value)
241
+ when :String
242
+ value.to_s
243
+ when :Integer
244
+ value.to_i
245
+ when :Float
246
+ value.to_f
247
+ when :Boolean
248
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
249
+ true
250
+ else
251
+ false
252
+ end
253
+ when :Object
254
+ # generic object (usually a Hash), return directly
255
+ value
256
+ when /\AArray<(?<inner_type>.+)>\z/
257
+ inner_type = Regexp.last_match[:inner_type]
258
+ value.map { |v| _deserialize(inner_type, v) }
259
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
260
+ k_type = Regexp.last_match[:k_type]
261
+ v_type = Regexp.last_match[:v_type]
262
+ {}.tap do |hash|
263
+ value.each do |k, v|
264
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
265
+ end
266
+ end
267
+ else # model
268
+ # models (e.g. Pet) or oneOf
269
+ klass = SnapTrade.const_get(type)
270
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ if value.nil?
293
+ is_nullable = self.class.openapi_nullable.include?(attr)
294
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
295
+ end
296
+
297
+ hash[param] = _to_hash(value)
298
+ end
299
+ hash
300
+ end
301
+
302
+ # Outputs non-array value in the form of hash
303
+ # For object, use to_hash. Otherwise, just return the value
304
+ # @param [Object] value Any valid value
305
+ # @return [Hash] Returns the value in the form of hash
306
+ def _to_hash(value)
307
+ if value.is_a?(Array)
308
+ value.compact.map { |v| _to_hash(v) }
309
+ elsif value.is_a?(Hash)
310
+ {}.tap do |hash|
311
+ value.each { |k, v| hash[k] = _to_hash(v) }
312
+ end
313
+ elsif value.respond_to? :to_hash
314
+ value.to_hash
315
+ else
316
+ value
317
+ end
318
+ end
319
+
320
+ end
321
+
322
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'date'
11
+ require 'time'
12
+
13
+ module SnapTrade
14
+ class OptionInstrumentKind
15
+ OPTION = "option".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [OPTION].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if OptionInstrumentKind.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #OptionInstrumentKind"
34
+ end
35
+ end
36
+ end
@@ -56,7 +56,7 @@ module SnapTrade
56
56
  {
57
57
  :'id' => :'String',
58
58
  :'ticker' => :'String',
59
- :'option_type' => :'OptionType',
59
+ :'option_type' => :'OptionsSymbolOptionType',
60
60
  :'strike_price' => :'Float',
61
61
  :'expiration_date' => :'Date',
62
62
  :'is_mini_option' => :'Boolean',
@@ -0,0 +1,37 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'date'
11
+ require 'time'
12
+
13
+ module SnapTrade
14
+ class OptionsSymbolOptionType
15
+ CALL = "CALL".freeze
16
+ PUT = "PUT".freeze
17
+
18
+ def self.all_vars
19
+ @all_vars ||= [CALL, PUT].freeze
20
+ end
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def self.build_from_hash(value)
26
+ new.build_from_hash(value)
27
+ end
28
+
29
+ # Builds the enum from string
30
+ # @param [String] The enum value in the form of the string
31
+ # @return [String] The enum value
32
+ def build_from_hash(value)
33
+ return value if OptionsSymbolOptionType.all_vars.include?(value)
34
+ raise "Invalid ENUM value #{value} for class #OptionsSymbolOptionType"
35
+ end
36
+ end
37
+ end
@@ -15,6 +15,12 @@ module SnapTrade
15
15
  # Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
16
16
  attr_accessor :brokerage_order_id
17
17
 
18
+ # The brokerage-assigned identifier that links all orders within a complex order (OCO, OTO, OTOCO) together. Null for non-complex orders or when the brokerage does not return a group identifier.
19
+ attr_accessor :brokerage_group_order_id
20
+
21
+ # The role of this order within a complex order group (OCO, OTO, OTOCO). Null for non-complex orders.
22
+ attr_accessor :order_role
23
+
18
24
  # Indicates the status of an order. SnapTrade does a best effort to map brokerage statuses to statuses in this enum. Possible values include: - NONE - PENDING - ACCEPTED - FAILED - REJECTED - CANCELED - PARTIAL_CANCELED - CANCEL_PENDING - EXECUTED - PARTIAL - REPLACE_PENDING - REPLACED - EXPIRED - QUEUED - TRIGGERED - ACTIVATED
19
25
  attr_accessor :status
20
26
 
@@ -79,6 +85,8 @@ module SnapTrade
79
85
  def self.attribute_map
80
86
  {
81
87
  :'brokerage_order_id' => :'brokerage_order_id',
88
+ :'brokerage_group_order_id' => :'brokerage_group_order_id',
89
+ :'order_role' => :'order_role',
82
90
  :'status' => :'status',
83
91
  :'universal_symbol' => :'universal_symbol',
84
92
  :'option_symbol' => :'option_symbol',
@@ -113,6 +121,8 @@ module SnapTrade
113
121
  def self.openapi_types
114
122
  {
115
123
  :'brokerage_order_id' => :'String',
124
+ :'brokerage_group_order_id' => :'String',
125
+ :'order_role' => :'OrderRole',
116
126
  :'status' => :'AccountOrderRecordStatus',
117
127
  :'universal_symbol' => :'AccountOrderRecordUniversalSymbol',
118
128
  :'option_symbol' => :'AccountOrderRecordOptionSymbol',
@@ -141,6 +151,8 @@ module SnapTrade
141
151
  # List of attributes with nullable: true
142
152
  def self.openapi_nullable
143
153
  Set.new([
154
+ :'brokerage_group_order_id',
155
+ :'order_role',
144
156
  :'total_quantity',
145
157
  :'open_quantity',
146
158
  :'canceled_quantity',
@@ -183,6 +195,14 @@ module SnapTrade
183
195
  self.brokerage_order_id = attributes[:'brokerage_order_id']
184
196
  end
185
197
 
198
+ if attributes.key?(:'brokerage_group_order_id')
199
+ self.brokerage_group_order_id = attributes[:'brokerage_group_order_id']
200
+ end
201
+
202
+ if attributes.key?(:'order_role')
203
+ self.order_role = attributes[:'order_role']
204
+ end
205
+
186
206
  if attributes.key?(:'status')
187
207
  self.status = attributes[:'status']
188
208
  end
@@ -291,6 +311,8 @@ module SnapTrade
291
311
  return true if self.equal?(o)
292
312
  self.class == o.class &&
293
313
  brokerage_order_id == o.brokerage_order_id &&
314
+ brokerage_group_order_id == o.brokerage_group_order_id &&
315
+ order_role == o.order_role &&
294
316
  status == o.status &&
295
317
  universal_symbol == o.universal_symbol &&
296
318
  option_symbol == o.option_symbol &&
@@ -324,7 +346,7 @@ module SnapTrade
324
346
  # Calculates hash code according to all attributes.
325
347
  # @return [Integer] Hash code
326
348
  def hash
327
- [brokerage_order_id, status, universal_symbol, option_symbol, quote_universal_symbol, quote_currency, action, total_quantity, open_quantity, canceled_quantity, filled_quantity, execution_price, limit_price, stop_price, trailing_stop, order_type, time_in_force, time_placed, time_updated, time_executed, expiry_date, symbol, child_brokerage_order_ids].hash
349
+ [brokerage_order_id, brokerage_group_order_id, order_role, status, universal_symbol, option_symbol, quote_universal_symbol, quote_currency, action, total_quantity, open_quantity, canceled_quantity, filled_quantity, execution_price, limit_price, stop_price, trailing_stop, order_type, time_in_force, time_placed, time_updated, time_executed, expiry_date, symbol, child_brokerage_order_ids].hash
328
350
  end
329
351
 
330
352
  # Builds the object from hash