snaptrade 1.12.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,290 @@
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
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module SnapTrade
15
+ class BrokerageSymbolSymbol
16
+ attr_accessor :id
17
+
18
+ attr_accessor :symbol
19
+
20
+ attr_accessor :raw_symbol
21
+
22
+ attr_accessor :description
23
+
24
+ attr_accessor :currency
25
+
26
+ attr_accessor :exchange
27
+
28
+ attr_accessor :type
29
+
30
+ attr_accessor :currencies
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'id' => :'id',
36
+ :'symbol' => :'symbol',
37
+ :'raw_symbol' => :'raw_symbol',
38
+ :'description' => :'description',
39
+ :'currency' => :'currency',
40
+ :'exchange' => :'exchange',
41
+ :'type' => :'type',
42
+ :'currencies' => :'currencies'
43
+ }
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'id' => :'String',
55
+ :'symbol' => :'String',
56
+ :'raw_symbol' => :'String',
57
+ :'description' => :'String',
58
+ :'currency' => :'Currency',
59
+ :'exchange' => :'Exchange',
60
+ :'type' => :'SecurityType',
61
+ :'currencies' => :'Array<Currency>'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ :'description',
69
+ ])
70
+ end
71
+
72
+ # List of class defined in allOf (OpenAPI v3)
73
+ def self.openapi_all_of
74
+ [
75
+ :'UniversalSymbol'
76
+ ]
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::BrokerageSymbolSymbol` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::BrokerageSymbolSymbol`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
+ end
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:'id')
95
+ self.id = attributes[:'id']
96
+ end
97
+
98
+ if attributes.key?(:'symbol')
99
+ self.symbol = attributes[:'symbol']
100
+ end
101
+
102
+ if attributes.key?(:'raw_symbol')
103
+ self.raw_symbol = attributes[:'raw_symbol']
104
+ end
105
+
106
+ if attributes.key?(:'description')
107
+ self.description = attributes[:'description']
108
+ end
109
+
110
+ if attributes.key?(:'currency')
111
+ self.currency = attributes[:'currency']
112
+ end
113
+
114
+ if attributes.key?(:'exchange')
115
+ self.exchange = attributes[:'exchange']
116
+ end
117
+
118
+ if attributes.key?(:'type')
119
+ self.type = attributes[:'type']
120
+ end
121
+
122
+ if attributes.key?(:'currencies')
123
+ if (value = attributes[:'currencies']).is_a?(Array)
124
+ self.currencies = value
125
+ end
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ invalid_properties = Array.new
133
+ invalid_properties
134
+ end
135
+
136
+ # Check to see if the all the properties in the model are valid
137
+ # @return true if the model is valid
138
+ def valid?
139
+ true
140
+ end
141
+
142
+ # Checks equality by comparing each attribute.
143
+ # @param [Object] Object to be compared
144
+ def ==(o)
145
+ return true if self.equal?(o)
146
+ self.class == o.class &&
147
+ id == o.id &&
148
+ symbol == o.symbol &&
149
+ raw_symbol == o.raw_symbol &&
150
+ description == o.description &&
151
+ currency == o.currency &&
152
+ exchange == o.exchange &&
153
+ type == o.type &&
154
+ currencies == o.currencies
155
+ end
156
+
157
+ # @see the `==` method
158
+ # @param [Object] Object to be compared
159
+ def eql?(o)
160
+ self == o
161
+ end
162
+
163
+ # Calculates hash code according to all attributes.
164
+ # @return [Integer] Hash code
165
+ def hash
166
+ [id, symbol, raw_symbol, description, currency, exchange, type, currencies].hash
167
+ end
168
+
169
+ # Builds the object from hash
170
+ # @param [Hash] attributes Model attributes in the form of hash
171
+ # @return [Object] Returns the model itself
172
+ def self.build_from_hash(attributes)
173
+ new.build_from_hash(attributes)
174
+ end
175
+
176
+ # Builds the object from hash
177
+ # @param [Hash] attributes Model attributes in the form of hash
178
+ # @return [Object] Returns the model itself
179
+ def build_from_hash(attributes)
180
+ return nil unless attributes.is_a?(Hash)
181
+ attributes = attributes.transform_keys(&:to_sym)
182
+ self.class.openapi_types.each_pair do |key, type|
183
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
184
+ self.send("#{key}=", nil)
185
+ elsif type =~ /\AArray<(.*)>/i
186
+ # check to ensure the input is an array given that the attribute
187
+ # is documented as an array but the input is not
188
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
189
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
190
+ end
191
+ elsif !attributes[self.class.attribute_map[key]].nil?
192
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
193
+ end
194
+ end
195
+
196
+ self
197
+ end
198
+
199
+ # Deserializes the data based on type
200
+ # @param string type Data type
201
+ # @param string value Value to be deserialized
202
+ # @return [Object] Deserialized data
203
+ def _deserialize(type, value)
204
+ case type.to_sym
205
+ when :Time
206
+ Time.parse(value)
207
+ when :Date
208
+ Date.parse(value)
209
+ when :String
210
+ value.to_s
211
+ when :Integer
212
+ value.to_i
213
+ when :Float
214
+ value.to_f
215
+ when :Boolean
216
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
217
+ true
218
+ else
219
+ false
220
+ end
221
+ when :Object
222
+ # generic object (usually a Hash), return directly
223
+ value
224
+ when /\AArray<(?<inner_type>.+)>\z/
225
+ inner_type = Regexp.last_match[:inner_type]
226
+ value.map { |v| _deserialize(inner_type, v) }
227
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
228
+ k_type = Regexp.last_match[:k_type]
229
+ v_type = Regexp.last_match[:v_type]
230
+ {}.tap do |hash|
231
+ value.each do |k, v|
232
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
233
+ end
234
+ end
235
+ else # model
236
+ # models (e.g. Pet) or oneOf
237
+ klass = SnapTrade.const_get(type)
238
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
239
+ end
240
+ end
241
+
242
+ # Returns the string representation of the object
243
+ # @return [String] String presentation of the object
244
+ def to_s
245
+ to_hash.to_s
246
+ end
247
+
248
+ # to_body is an alias to to_hash (backward compatibility)
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_body
251
+ to_hash
252
+ end
253
+
254
+ # Returns the object in the form of hash
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_hash
257
+ hash = {}
258
+ self.class.attribute_map.each_pair do |attr, param|
259
+ value = self.send(attr)
260
+ if value.nil?
261
+ is_nullable = self.class.openapi_nullable.include?(attr)
262
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
263
+ end
264
+
265
+ hash[param] = _to_hash(value)
266
+ end
267
+ hash
268
+ end
269
+
270
+ # Outputs non-array value in the form of hash
271
+ # For object, use to_hash. Otherwise, just return the value
272
+ # @param [Object] value Any valid value
273
+ # @return [Hash] Returns the value in the form of hash
274
+ def _to_hash(value)
275
+ if value.is_a?(Array)
276
+ value.compact.map { |v| _to_hash(v) }
277
+ elsif value.is_a?(Hash)
278
+ {}.tap do |hash|
279
+ value.each { |k, v| hash[k] = _to_hash(v) }
280
+ end
281
+ elsif value.respond_to? :to_hash
282
+ value.to_hash
283
+ else
284
+ value
285
+ end
286
+ end
287
+
288
+ end
289
+
290
+ end
@@ -16,10 +16,6 @@ module SnapTrade
16
16
  class OptionsPosition
17
17
  attr_accessor :symbol
18
18
 
19
- attr_accessor :description
20
-
21
- attr_accessor :option_symbol
22
-
23
19
  # Trade Price if limit or stop limit order
24
20
  attr_accessor :price
25
21
 
@@ -30,16 +26,25 @@ module SnapTrade
30
26
  # Average purchase price for this position
31
27
  attr_accessor :average_purchase_price
32
28
 
29
+ attr_accessor :open_pnl
30
+
31
+ # Deprecated, use the units field for both fractional and integer units going forward
32
+ attr_accessor :fractional_units
33
+
34
+ # The book price of the asset
35
+ attr_accessor :book_price
36
+
33
37
  # Attribute mapping from ruby-style variable name to JSON key.
34
38
  def self.attribute_map
35
39
  {
36
40
  :'symbol' => :'symbol',
37
- :'description' => :'description',
38
- :'option_symbol' => :'option_symbol',
39
41
  :'price' => :'price',
40
42
  :'units' => :'units',
41
43
  :'currency' => :'currency',
42
- :'average_purchase_price' => :'average_purchase_price'
44
+ :'average_purchase_price' => :'average_purchase_price',
45
+ :'open_pnl' => :'open_pnl',
46
+ :'fractional_units' => :'fractional_units',
47
+ :'book_price' => :'book_price'
43
48
  }
44
49
  end
45
50
 
@@ -51,13 +56,14 @@ module SnapTrade
51
56
  # Attribute type mapping.
52
57
  def self.openapi_types
53
58
  {
54
- :'symbol' => :'String',
55
- :'description' => :'String',
56
- :'option_symbol' => :'OptionsSymbol',
59
+ :'symbol' => :'BrokerageSymbol',
57
60
  :'price' => :'Float',
58
61
  :'units' => :'Float',
59
- :'currency' => :'Currency',
60
- :'average_purchase_price' => :'Float'
62
+ :'currency' => :'OptionsPositionCurrency',
63
+ :'average_purchase_price' => :'Float',
64
+ :'open_pnl' => :'Float',
65
+ :'fractional_units' => :'Float',
66
+ :'book_price' => :'Float'
61
67
  }
62
68
  end
63
69
 
@@ -65,7 +71,11 @@ module SnapTrade
65
71
  def self.openapi_nullable
66
72
  Set.new([
67
73
  :'price',
68
- :'average_purchase_price'
74
+ :'currency',
75
+ :'average_purchase_price',
76
+ :'open_pnl',
77
+ :'fractional_units',
78
+ :'book_price'
69
79
  ])
70
80
  end
71
81
 
@@ -88,14 +98,6 @@ module SnapTrade
88
98
  self.symbol = attributes[:'symbol']
89
99
  end
90
100
 
91
- if attributes.key?(:'description')
92
- self.description = attributes[:'description']
93
- end
94
-
95
- if attributes.key?(:'option_symbol')
96
- self.option_symbol = attributes[:'option_symbol']
97
- end
98
-
99
101
  if attributes.key?(:'price')
100
102
  self.price = attributes[:'price']
101
103
  end
@@ -111,6 +113,18 @@ module SnapTrade
111
113
  if attributes.key?(:'average_purchase_price')
112
114
  self.average_purchase_price = attributes[:'average_purchase_price']
113
115
  end
116
+
117
+ if attributes.key?(:'open_pnl')
118
+ self.open_pnl = attributes[:'open_pnl']
119
+ end
120
+
121
+ if attributes.key?(:'fractional_units')
122
+ self.fractional_units = attributes[:'fractional_units']
123
+ end
124
+
125
+ if attributes.key?(:'book_price')
126
+ self.book_price = attributes[:'book_price']
127
+ end
114
128
  end
115
129
 
116
130
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -132,12 +146,13 @@ module SnapTrade
132
146
  return true if self.equal?(o)
133
147
  self.class == o.class &&
134
148
  symbol == o.symbol &&
135
- description == o.description &&
136
- option_symbol == o.option_symbol &&
137
149
  price == o.price &&
138
150
  units == o.units &&
139
151
  currency == o.currency &&
140
- average_purchase_price == o.average_purchase_price
152
+ average_purchase_price == o.average_purchase_price &&
153
+ open_pnl == o.open_pnl &&
154
+ fractional_units == o.fractional_units &&
155
+ book_price == o.book_price
141
156
  end
142
157
 
143
158
  # @see the `==` method
@@ -149,7 +164,7 @@ module SnapTrade
149
164
  # Calculates hash code according to all attributes.
150
165
  # @return [Integer] Hash code
151
166
  def hash
152
- [symbol, description, option_symbol, price, units, currency, average_purchase_price].hash
167
+ [symbol, price, units, currency, average_purchase_price, open_pnl, fractional_units, book_price].hash
153
168
  end
154
169
 
155
170
  # Builds the object from hash
@@ -0,0 +1,242 @@
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
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module SnapTrade
15
+ class OptionsPositionCurrency
16
+ attr_accessor :id
17
+
18
+ attr_accessor :code
19
+
20
+ attr_accessor :name
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'id' => :'id',
26
+ :'code' => :'code',
27
+ :'name' => :'name'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'id' => :'String',
40
+ :'code' => :'String',
41
+ :'name' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # List of class defined in allOf (OpenAPI v3)
52
+ def self.openapi_all_of
53
+ [
54
+ :'Currency'
55
+ ]
56
+ end
57
+
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
60
+ def initialize(attributes = {})
61
+ if (!attributes.is_a?(Hash))
62
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::OptionsPositionCurrency` initialize method"
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!self.class.attribute_map.key?(k.to_sym))
68
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::OptionsPositionCurrency`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
69
+ end
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:'id')
74
+ self.id = attributes[:'id']
75
+ end
76
+
77
+ if attributes.key?(:'code')
78
+ self.code = attributes[:'code']
79
+ end
80
+
81
+ if attributes.key?(:'name')
82
+ self.name = attributes[:'name']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ id == o.id &&
105
+ code == o.code &&
106
+ name == o.name
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [id, code, name].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ new.build_from_hash(attributes)
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ attributes = attributes.transform_keys(&:to_sym)
134
+ self.class.openapi_types.each_pair do |key, type|
135
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
136
+ self.send("#{key}=", nil)
137
+ elsif type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :Time
158
+ Time.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ # models (e.g. Pet) or oneOf
189
+ klass = SnapTrade.const_get(type)
190
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map { |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+
240
+ end
241
+
242
+ end