snaptrade 2.0.185 → 2.0.186

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 (53) 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_option_symbol.rb +1 -1
  6. data/lib/snaptrade/models/account_order_record_quote_universal_symbol.rb +1 -1
  7. data/lib/snaptrade/models/account_order_record_universal_symbol.rb +1 -1
  8. data/lib/snaptrade/models/account_position.rb +288 -0
  9. data/lib/snaptrade/models/account_universal_activity_option_symbol.rb +1 -1
  10. data/lib/snaptrade/models/account_universal_activity_symbol.rb +1 -1
  11. data/lib/snaptrade/models/all_account_positions_response.rb +262 -0
  12. data/lib/snaptrade/models/crypto_instrument.rb +311 -0
  13. data/lib/snaptrade/models/crypto_instrument_kind.rb +36 -0
  14. data/lib/snaptrade/models/etf_instrument.rb +311 -0
  15. data/lib/snaptrade/models/etf_instrument_kind.rb +36 -0
  16. data/lib/snaptrade/models/future_instrument.rb +326 -0
  17. data/lib/snaptrade/models/future_instrument_kind.rb +36 -0
  18. data/lib/snaptrade/models/instrument.rb +61 -0
  19. data/lib/snaptrade/models/kind.rb +36 -0
  20. data/lib/snaptrade/models/option_instrument.rb +322 -0
  21. data/lib/snaptrade/models/option_instrument_kind.rb +36 -0
  22. data/lib/snaptrade/models/options_symbol.rb +1 -1
  23. data/lib/snaptrade/models/options_symbol_option_type.rb +37 -0
  24. data/lib/snaptrade/models/other_instrument.rb +311 -0
  25. data/lib/snaptrade/models/other_instrument_kind.rb +36 -0
  26. data/lib/snaptrade/models/stock_instrument.rb +311 -0
  27. data/lib/snaptrade/models/{symbol_figi_instrument.rb → stock_instrument_figi_instrument.rb} +3 -3
  28. data/lib/snaptrade/models/symbol.rb +1 -1
  29. data/lib/snaptrade/models/underlying_option_instrument.rb +57 -0
  30. data/lib/snaptrade/models/underlying_symbol.rb +1 -1
  31. data/lib/snaptrade/models/universal_symbol.rb +1 -1
  32. data/lib/snaptrade/version.rb +1 -1
  33. data/lib/snaptrade.rb +18 -1
  34. data/spec/api/experimental_endpoints_api_spec.rb +16 -0
  35. data/spec/models/account_position_spec.rb +65 -0
  36. data/spec/models/all_account_positions_response_spec.rb +47 -0
  37. data/spec/models/crypto_instrument_kind_spec.rb +23 -0
  38. data/spec/models/crypto_instrument_spec.rb +71 -0
  39. data/spec/models/etf_instrument_kind_spec.rb +23 -0
  40. data/spec/models/etf_instrument_spec.rb +71 -0
  41. data/spec/models/future_instrument_kind_spec.rb +23 -0
  42. data/spec/models/future_instrument_spec.rb +77 -0
  43. data/spec/models/instrument_spec.rb +38 -0
  44. data/spec/models/kind_spec.rb +23 -0
  45. data/spec/models/option_instrument_kind_spec.rb +23 -0
  46. data/spec/models/option_instrument_spec.rb +71 -0
  47. data/spec/models/options_symbol_option_type_spec.rb +23 -0
  48. data/spec/models/other_instrument_kind_spec.rb +23 -0
  49. data/spec/models/other_instrument_spec.rb +71 -0
  50. data/spec/models/{symbol_figi_instrument_spec.rb → stock_instrument_figi_instrument_spec.rb} +6 -6
  51. data/spec/models/stock_instrument_spec.rb +71 -0
  52. data/spec/models/underlying_option_instrument_spec.rb +38 -0
  53. metadata +56 -5
@@ -0,0 +1,61 @@
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
+ # Instrument metadata for a V2 position. Use `kind` to determine which schema is present.
15
+ module Instrument
16
+ class << self
17
+ # List of class defined in oneOf (OpenAPI v3)
18
+ def openapi_one_of
19
+ [
20
+ :'CryptoInstrument',
21
+ :'EtfInstrument',
22
+ :'FutureInstrument',
23
+ :'OptionInstrument',
24
+ :'OtherInstrument',
25
+ :'StockInstrument'
26
+ ]
27
+ end
28
+
29
+ # Discriminator's property name (OpenAPI v3)
30
+ def openapi_discriminator_name
31
+ :'kind'
32
+ end
33
+
34
+ # Discriminator's mapping (OpenAPI v3)
35
+ def openapi_discriminator_mapping
36
+ {
37
+ :'crypto' => :'CryptoInstrument',
38
+ :'etf' => :'EtfInstrument',
39
+ :'future' => :'FutureInstrument',
40
+ :'option' => :'OptionInstrument',
41
+ :'other' => :'OtherInstrument',
42
+ :'stock' => :'StockInstrument'
43
+ }
44
+ end
45
+
46
+ # Builds the object
47
+ # @param [Mixed] Data to be matched against the list of oneOf items
48
+ # @return [Object] Returns the model or the data itself
49
+ def build(data)
50
+ discriminator_value = data[openapi_discriminator_name]
51
+ return nil if discriminator_value.nil?
52
+
53
+ klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
54
+ return nil unless klass
55
+
56
+ SnapTrade.const_get(klass).build_from_hash(data)
57
+ end
58
+ end
59
+ end
60
+
61
+ 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 Kind
15
+ STOCK = "stock".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [STOCK].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 Kind.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #Kind"
34
+ end
35
+ end
36
+ end
@@ -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