snaptrade 2.0.144 → 2.0.146

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.
@@ -0,0 +1,259 @@
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 an order leg.
15
+ class AccountOrderRecordLegInstrument
16
+ # The symbol or ticker for the security.
17
+ attr_accessor :symbol
18
+
19
+ # Human-readable description of the security.
20
+ attr_accessor :description
21
+
22
+ # Type of instrument for the leg. - EQUITY - OPTION - CRYPTO
23
+ attr_accessor :asset_type
24
+
25
+ # Market Identifier Code (MIC) for the exchange on which the instrument trades.
26
+ attr_accessor :exchange_mic_code
27
+
28
+ # Financial Instrument Global Identifier (FIGI) if available.
29
+ attr_accessor :figi_code
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'symbol' => :'symbol',
35
+ :'description' => :'description',
36
+ :'asset_type' => :'asset_type',
37
+ :'exchange_mic_code' => :'exchange_mic_code',
38
+ :'figi_code' => :'figi_code'
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'symbol' => :'String',
51
+ :'description' => :'String',
52
+ :'asset_type' => :'String',
53
+ :'exchange_mic_code' => :'String',
54
+ :'figi_code' => :'String'
55
+ }
56
+ end
57
+
58
+ # List of attributes with nullable: true
59
+ def self.openapi_nullable
60
+ Set.new([
61
+ :'figi_code'
62
+ ])
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AccountOrderRecordLegInstrument` initialize method"
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AccountOrderRecordLegInstrument`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'symbol')
81
+ self.symbol = attributes[:'symbol']
82
+ end
83
+
84
+ if attributes.key?(:'description')
85
+ self.description = attributes[:'description']
86
+ end
87
+
88
+ if attributes.key?(:'asset_type')
89
+ self.asset_type = attributes[:'asset_type']
90
+ end
91
+
92
+ if attributes.key?(:'exchange_mic_code')
93
+ self.exchange_mic_code = attributes[:'exchange_mic_code']
94
+ end
95
+
96
+ if attributes.key?(:'figi_code')
97
+ self.figi_code = attributes[:'figi_code']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ symbol == o.symbol &&
120
+ description == o.description &&
121
+ asset_type == o.asset_type &&
122
+ exchange_mic_code == o.exchange_mic_code &&
123
+ figi_code == o.figi_code
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [symbol, description, asset_type, exchange_mic_code, figi_code].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ new.build_from_hash(attributes)
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def build_from_hash(attributes)
149
+ return nil unless attributes.is_a?(Hash)
150
+ attributes = attributes.transform_keys(&:to_sym)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
153
+ self.send("#{key}=", nil)
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :Time
175
+ Time.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ # models (e.g. Pet) or oneOf
206
+ klass = SnapTrade.const_get(type)
207
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
208
+ end
209
+ end
210
+
211
+ # Returns the string representation of the object
212
+ # @return [String] String presentation of the object
213
+ def to_s
214
+ to_hash.to_s
215
+ end
216
+
217
+ # to_body is an alias to to_hash (backward compatibility)
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_body
220
+ to_hash
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map { |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end
@@ -0,0 +1,45 @@
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 AccountOrderRecordStatusV2
15
+ PENDING = "PENDING".freeze
16
+ REJECTED = "REJECTED".freeze
17
+ CANCELED = "CANCELED".freeze
18
+ CANCEL_PENDING = "CANCEL_PENDING".freeze
19
+ PARTIAL_CANCELED = "PARTIAL_CANCELED".freeze
20
+ EXECUTED = "EXECUTED".freeze
21
+ PARTIALLY_EXECUTED = "PARTIALLY_EXECUTED".freeze
22
+ REPLACED = "REPLACED".freeze
23
+ REPLACE_PENDING = "REPLACE_PENDING".freeze
24
+ EXPIRED = "EXPIRED".freeze
25
+
26
+ def self.all_vars
27
+ @all_vars ||= [PENDING, REJECTED, CANCELED, CANCEL_PENDING, PARTIAL_CANCELED, EXECUTED, PARTIALLY_EXECUTED, REPLACED, REPLACE_PENDING, EXPIRED].freeze
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def self.build_from_hash(value)
34
+ new.build_from_hash(value)
35
+ end
36
+
37
+ # Builds the enum from string
38
+ # @param [String] The enum value in the form of the string
39
+ # @return [String] The enum value
40
+ def build_from_hash(value)
41
+ return value if AccountOrderRecordStatusV2.all_vars.include?(value)
42
+ raise "Invalid ENUM value #{value} for class #AccountOrderRecordStatusV2"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,325 @@
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
+ # Describes a single order in the standardized V2 format.
15
+ class AccountOrderRecordV2
16
+ # Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
17
+ attr_accessor :brokerage_order_id
18
+
19
+ # 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
20
+ attr_accessor :status
21
+
22
+ # The type of order placed. - `MARKET` - `LIMIT` - `STOP` - `STOP_LIMIT`
23
+ attr_accessor :order_type
24
+
25
+ # The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. We try our best to map brokerage time in force values to the following. When mapping fails, we will return the brokerage's time in force value. - `DAY` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date. - `MOO` - Market On Open. The order is to be executed at the day's opening price. - `EHP` - Extended Hours P.M. The order is to be placed during extended hour trading, after markets close.
26
+ attr_accessor :time_in_force
27
+
28
+ # The time the order was placed. This is the time the order was submitted to the brokerage.
29
+ attr_accessor :time_placed
30
+
31
+ # The time the order was executed in the brokerage system. This value is not always available from the brokerage.
32
+ attr_accessor :time_executed
33
+
34
+ # Quote currency code for the order.
35
+ attr_accessor :quote_currency
36
+
37
+ # The price at which the order was executed.
38
+ attr_accessor :execution_price
39
+
40
+ # The limit price is maximum price one is willing to pay for a buy order or the minimum price one is willing to accept for a sell order. Should only apply to `Limit` and `StopLimit` orders.
41
+ attr_accessor :limit_price
42
+
43
+ # The stop price is the price at which a stop order is triggered. Should only apply to `Stop` and `StopLimit` orders.
44
+ attr_accessor :stop_price
45
+
46
+ # List of legs that make up the order.
47
+ attr_accessor :legs
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'brokerage_order_id' => :'brokerage_order_id',
53
+ :'status' => :'status',
54
+ :'order_type' => :'order_type',
55
+ :'time_in_force' => :'time_in_force',
56
+ :'time_placed' => :'time_placed',
57
+ :'time_executed' => :'time_executed',
58
+ :'quote_currency' => :'quote_currency',
59
+ :'execution_price' => :'execution_price',
60
+ :'limit_price' => :'limit_price',
61
+ :'stop_price' => :'stop_price',
62
+ :'legs' => :'legs'
63
+ }
64
+ end
65
+
66
+ # Returns all the JSON keys this model knows about
67
+ def self.acceptable_attributes
68
+ attribute_map.values
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'brokerage_order_id' => :'String',
75
+ :'status' => :'AccountOrderRecordStatus',
76
+ :'order_type' => :'String',
77
+ :'time_in_force' => :'String',
78
+ :'time_placed' => :'Time',
79
+ :'time_executed' => :'Time',
80
+ :'quote_currency' => :'String',
81
+ :'execution_price' => :'Float',
82
+ :'limit_price' => :'Float',
83
+ :'stop_price' => :'Float',
84
+ :'legs' => :'Array<AccountOrderRecordLeg>'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ :'order_type',
92
+ :'time_executed',
93
+ :'execution_price',
94
+ :'limit_price',
95
+ :'stop_price',
96
+ ])
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ if (!attributes.is_a?(Hash))
103
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AccountOrderRecordV2` initialize method"
104
+ end
105
+
106
+ # check to see if the attribute exists and convert string to symbol for hash key
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!self.class.attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AccountOrderRecordV2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'brokerage_order_id')
115
+ self.brokerage_order_id = attributes[:'brokerage_order_id']
116
+ end
117
+
118
+ if attributes.key?(:'status')
119
+ self.status = attributes[:'status']
120
+ end
121
+
122
+ if attributes.key?(:'order_type')
123
+ self.order_type = attributes[:'order_type']
124
+ end
125
+
126
+ if attributes.key?(:'time_in_force')
127
+ self.time_in_force = attributes[:'time_in_force']
128
+ end
129
+
130
+ if attributes.key?(:'time_placed')
131
+ self.time_placed = attributes[:'time_placed']
132
+ end
133
+
134
+ if attributes.key?(:'time_executed')
135
+ self.time_executed = attributes[:'time_executed']
136
+ end
137
+
138
+ if attributes.key?(:'quote_currency')
139
+ self.quote_currency = attributes[:'quote_currency']
140
+ end
141
+
142
+ if attributes.key?(:'execution_price')
143
+ self.execution_price = attributes[:'execution_price']
144
+ end
145
+
146
+ if attributes.key?(:'limit_price')
147
+ self.limit_price = attributes[:'limit_price']
148
+ end
149
+
150
+ if attributes.key?(:'stop_price')
151
+ self.stop_price = attributes[:'stop_price']
152
+ end
153
+
154
+ if attributes.key?(:'legs')
155
+ if (value = attributes[:'legs']).is_a?(Array)
156
+ self.legs = value
157
+ end
158
+ end
159
+ end
160
+
161
+ # Show invalid properties with the reasons. Usually used together with valid?
162
+ # @return Array for valid properties with the reasons
163
+ def list_invalid_properties
164
+ invalid_properties = Array.new
165
+ invalid_properties
166
+ end
167
+
168
+ # Check to see if the all the properties in the model are valid
169
+ # @return true if the model is valid
170
+ def valid?
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
+ brokerage_order_id == o.brokerage_order_id &&
180
+ status == o.status &&
181
+ order_type == o.order_type &&
182
+ time_in_force == o.time_in_force &&
183
+ time_placed == o.time_placed &&
184
+ time_executed == o.time_executed &&
185
+ quote_currency == o.quote_currency &&
186
+ execution_price == o.execution_price &&
187
+ limit_price == o.limit_price &&
188
+ stop_price == o.stop_price &&
189
+ legs == o.legs
190
+ end
191
+
192
+ # @see the `==` method
193
+ # @param [Object] Object to be compared
194
+ def eql?(o)
195
+ self == o
196
+ end
197
+
198
+ # Calculates hash code according to all attributes.
199
+ # @return [Integer] Hash code
200
+ def hash
201
+ [brokerage_order_id, status, order_type, time_in_force, time_placed, time_executed, quote_currency, execution_price, limit_price, stop_price, legs].hash
202
+ end
203
+
204
+ # Builds the object from hash
205
+ # @param [Hash] attributes Model attributes in the form of hash
206
+ # @return [Object] Returns the model itself
207
+ def self.build_from_hash(attributes)
208
+ new.build_from_hash(attributes)
209
+ end
210
+
211
+ # Builds the object from hash
212
+ # @param [Hash] attributes Model attributes in the form of hash
213
+ # @return [Object] Returns the model itself
214
+ def build_from_hash(attributes)
215
+ return nil unless attributes.is_a?(Hash)
216
+ attributes = attributes.transform_keys(&:to_sym)
217
+ self.class.openapi_types.each_pair do |key, type|
218
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
219
+ self.send("#{key}=", nil)
220
+ elsif type =~ /\AArray<(.*)>/i
221
+ # check to ensure the input is an array given that the attribute
222
+ # is documented as an array but the input is not
223
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
224
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
225
+ end
226
+ elsif !attributes[self.class.attribute_map[key]].nil?
227
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
228
+ end
229
+ end
230
+
231
+ self
232
+ end
233
+
234
+ # Deserializes the data based on type
235
+ # @param string type Data type
236
+ # @param string value Value to be deserialized
237
+ # @return [Object] Deserialized data
238
+ def _deserialize(type, value)
239
+ case type.to_sym
240
+ when :Time
241
+ Time.parse(value)
242
+ when :Date
243
+ Date.parse(value)
244
+ when :String
245
+ value.to_s
246
+ when :Integer
247
+ value.to_i
248
+ when :Float
249
+ value.to_f
250
+ when :Boolean
251
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
252
+ true
253
+ else
254
+ false
255
+ end
256
+ when :Object
257
+ # generic object (usually a Hash), return directly
258
+ value
259
+ when /\AArray<(?<inner_type>.+)>\z/
260
+ inner_type = Regexp.last_match[:inner_type]
261
+ value.map { |v| _deserialize(inner_type, v) }
262
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
263
+ k_type = Regexp.last_match[:k_type]
264
+ v_type = Regexp.last_match[:v_type]
265
+ {}.tap do |hash|
266
+ value.each do |k, v|
267
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
268
+ end
269
+ end
270
+ else # model
271
+ # models (e.g. Pet) or oneOf
272
+ klass = SnapTrade.const_get(type)
273
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
274
+ end
275
+ end
276
+
277
+ # Returns the string representation of the object
278
+ # @return [String] String presentation of the object
279
+ def to_s
280
+ to_hash.to_s
281
+ end
282
+
283
+ # to_body is an alias to to_hash (backward compatibility)
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_body
286
+ to_hash
287
+ end
288
+
289
+ # Returns the object in the form of hash
290
+ # @return [Hash] Returns the object in the form of hash
291
+ def to_hash
292
+ hash = {}
293
+ self.class.attribute_map.each_pair do |attr, param|
294
+ value = self.send(attr)
295
+ if value.nil?
296
+ is_nullable = self.class.openapi_nullable.include?(attr)
297
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
298
+ end
299
+
300
+ hash[param] = _to_hash(value)
301
+ end
302
+ hash
303
+ end
304
+
305
+ # Outputs non-array value in the form of hash
306
+ # For object, use to_hash. Otherwise, just return the value
307
+ # @param [Object] value Any valid value
308
+ # @return [Hash] Returns the value in the form of hash
309
+ def _to_hash(value)
310
+ if value.is_a?(Array)
311
+ value.compact.map { |v| _to_hash(v) }
312
+ elsif value.is_a?(Hash)
313
+ {}.tap do |hash|
314
+ value.each { |k, v| hash[k] = _to_hash(v) }
315
+ end
316
+ elsif value.respond_to? :to_hash
317
+ value.to_hash
318
+ else
319
+ value
320
+ end
321
+ end
322
+
323
+ end
324
+
325
+ end