snaptrade 2.0.184 → 2.0.185

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 103e29df611463df5d79c9c4cc67b032e9443e14cea4e3221ccda71e1dd5efb1
4
- data.tar.gz: 05a8cc80097320d9ac15d82bf196266550462ad558c0ab577f75c17f80ea9d16
3
+ metadata.gz: c6e6686611e26579a7f5b299263c6f9473fc12564d388730380a0b14f992d01e
4
+ data.tar.gz: 72ccb9a03f1230f0de97978d4d09c549ee38c45b120990ecb3df75ed6874da93
5
5
  SHA512:
6
- metadata.gz: 8813a51c97da576469bce21f1109bb7e3a8bc7a9a2bb8d3b5aa392c46e56f6bd93c44b7c3475047d7d61f152a75fc7d26881cc0e87269736dbf9dd18ef62fd1f
7
- data.tar.gz: 7bb0cf6ae9dd1aac3281a03834cc9ac06a77f7156df6d155656b6941b7620189d0f9f5df7426b8998eb6fa9ff30177b2075ff342ea0748c217b331dee2bb260c
6
+ metadata.gz: cd9ec841ef44d08d5e4d2315937a3cd13dd99c49a7da6ee2a470e6151f684c20d78c47f21e79083f270c3e8b95ce17a9d076b97074a8055780f9085b195681ea
7
+ data.tar.gz: a8fb0e2f6ef2feb2369036a668643fcc0c11a208bbd604649e2687ced70a4a3db0e67f92f4ed5412246f46fa08dd95ca01fa52406a3bc8fe5f4ac7b8859b9d7f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snaptrade (2.0.184)
4
+ snaptrade (2.0.185)
5
5
  faraday (>= 1.0.1, < 3.0)
6
6
  faraday-multipart (~> 1.0, >= 1.0.4)
7
7
 
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Connect brokerage accounts to your app for live positions and trading
8
8
 
9
- [![npm](https://img.shields.io/badge/gem-v2.0.184-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.184)
9
+ [![npm](https://img.shields.io/badge/gem-v2.0.185-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.185)
10
10
  [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/)
11
11
 
12
12
  </div>
@@ -71,6 +71,7 @@ Connect brokerage accounts to your app for live positions and trading
71
71
  * [`snaptrade.trading.get_user_account_option_quotes`](#snaptradetradingget_user_account_option_quotes)
72
72
  * [`snaptrade.trading.get_user_account_quotes`](#snaptradetradingget_user_account_quotes)
73
73
  * [`snaptrade.trading.place_bracket_order`](#snaptradetradingplace_bracket_order)
74
+ * [`snaptrade.trading.place_complex_order`](#snaptradetradingplace_complex_order)
74
75
  * [`snaptrade.trading.place_crypto_order`](#snaptradetradingplace_crypto_order)
75
76
  * [`snaptrade.trading.place_force_order`](#snaptradetradingplace_force_order)
76
77
  * [`snaptrade.trading.place_mleg_order`](#snaptradetradingplace_mleg_order)
@@ -88,7 +89,7 @@ Connect brokerage accounts to your app for live positions and trading
88
89
  Add to Gemfile:
89
90
 
90
91
  ```ruby
91
- gem 'snaptrade', '~> 2.0.184'
92
+ gem 'snaptrade', '~> 2.0.185'
92
93
  ```
93
94
 
94
95
  ## Getting Started<a id="getting-started"></a>
@@ -2205,6 +2206,79 @@ Must be `null` if `notional_value` is provided.
2205
2206
  ---
2206
2207
 
2207
2208
 
2209
+ ### `snaptrade.trading.place_complex_order`<a id="snaptradetradingplace_complex_order"></a>
2210
+
2211
+ Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
2212
+ Only supported on certain brokerages.
2213
+
2214
+ - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
2215
+ - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
2216
+ - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
2217
+
2218
+
2219
+ #### 🛠️ Usage<a id="🛠️-usage"></a>
2220
+
2221
+ ```ruby
2222
+ result = snaptrade.trading.place_complex_order(
2223
+ type: "OTO",
2224
+ orders: [
2225
+ {
2226
+ "order_role" => "TRIGGER",
2227
+ "action" => "BUY",
2228
+ "instrument" => {
2229
+ "symbol" => "AAPL",
2230
+ "type" => "EQUITY",
2231
+ },
2232
+ "order_type" => "Market",
2233
+ "units" => 10.5,
2234
+ "time_in_force" => "Day",
2235
+ "price" => 31.33,
2236
+ "stop" => 29.5,
2237
+ }
2238
+ ],
2239
+ account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
2240
+ user_id: "snaptrade-user-123",
2241
+ user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
2242
+ client_order_id: "my-order-123",
2243
+ )
2244
+ p result
2245
+ ```
2246
+
2247
+ #### ⚙️ Parameters<a id="⚙️-parameters"></a>
2248
+
2249
+ ##### type: [`ManualTradeFormComplexType`](./lib/snaptrade/models/manual_trade_form_complex_type.rb)<a id="type-manualtradeformcomplextypelibsnaptrademodelsmanual_trade_form_complex_typerb"></a>
2250
+ The complex order type. - `OCO`: One Cancels the Other — two peer orders. -
2251
+ `OTO`: One Triggers the Other — a trigger order and a conditional order. -
2252
+ `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer
2253
+ orders.
2254
+
2255
+ ##### orders: Array<[`ComplexOrderLeg`](./lib/snaptrade/models/complex_order_leg.rb)><a id="orders-array"></a>
2256
+ The orders that make up the complex order. Required counts and roles per type: -
2257
+ `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER`
2258
+ and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
2259
+
2260
+ ##### account_id: `String`<a id="account_id-string"></a>
2261
+ The ID of the account to execute the trade on.
2262
+
2263
+ ##### user_id: `String`<a id="user_id-string"></a>
2264
+ ##### user_secret: `String`<a id="user_secret-string"></a>
2265
+ ##### client_order_id: `String`<a id="client_order_id-string"></a>
2266
+ An optional client-provided identifier for this complex order. Passed through to
2267
+ the brokerage and returned in the response.
2268
+
2269
+ #### 🔄 Return<a id="🔄-return"></a>
2270
+
2271
+ [ComplexOrderResponse](./lib/snaptrade/models/complex_order_response.rb)
2272
+
2273
+ #### 🌐 Endpoint<a id="🌐-endpoint"></a>
2274
+
2275
+ `/accounts/{accountId}/trading/complex` `POST`
2276
+
2277
+ [🔙 **Back to Table of Contents**](#table-of-contents)
2278
+
2279
+ ---
2280
+
2281
+
2208
2282
  ### `snaptrade.trading.place_crypto_order`<a id="snaptradetradingplace_crypto_order"></a>
2209
2283
 
2210
2284
  Places an order in the specified account.
@@ -1079,6 +1079,148 @@ module SnapTrade
1079
1079
  end
1080
1080
 
1081
1081
 
1082
+ # Place complex order
1083
+ #
1084
+ # Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
1085
+ # Only supported on certain brokerages.
1086
+ #
1087
+ # - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
1088
+ # - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
1089
+ # - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
1090
+ #
1091
+ # @param type [ManualTradeFormComplexType] The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
1092
+ # @param orders [Array<ComplexOrderLeg>] The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
1093
+ # @param account_id [String] The ID of the account to execute the trade on.
1094
+ # @param user_id [String]
1095
+ # @param user_secret [String]
1096
+ # @param client_order_id [String] An optional client-provided identifier for this complex order. Passed through to the brokerage and returned in the response.
1097
+ # @param body [ManualTradeFormComplex]
1098
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1099
+ def place_complex_order(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {})
1100
+ _body = {}
1101
+ _body[:type] = type if type != SENTINEL
1102
+ _body[:orders] = orders if orders != SENTINEL
1103
+ _body[:client_order_id] = client_order_id if client_order_id != SENTINEL
1104
+ manual_trade_form_complex = _body
1105
+ data, _status_code, _headers = place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, extra)
1106
+ data
1107
+ end
1108
+
1109
+ # Place complex order
1110
+ #
1111
+ # Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
1112
+ # Only supported on certain brokerages.
1113
+ #
1114
+ # - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
1115
+ # - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
1116
+ # - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
1117
+ #
1118
+ # @param type [ManualTradeFormComplexType] The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
1119
+ # @param orders [Array<ComplexOrderLeg>] The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
1120
+ # @param account_id [String] The ID of the account to execute the trade on.
1121
+ # @param user_id [String]
1122
+ # @param user_secret [String]
1123
+ # @param client_order_id [String] An optional client-provided identifier for this complex order. Passed through to the brokerage and returned in the response.
1124
+ # @param body [ManualTradeFormComplex]
1125
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1126
+ def place_complex_order_with_http_info(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {})
1127
+ _body = {}
1128
+ _body[:type] = type if type != SENTINEL
1129
+ _body[:orders] = orders if orders != SENTINEL
1130
+ _body[:client_order_id] = client_order_id if client_order_id != SENTINEL
1131
+ manual_trade_form_complex = _body
1132
+ place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, extra)
1133
+ end
1134
+
1135
+ # Place complex order
1136
+ # Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable. Only supported on certain brokerages. - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled. - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order. - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
1137
+ # @param account_id [String] The ID of the account to execute the trade on.
1138
+ # @param user_id [String]
1139
+ # @param user_secret [String]
1140
+ # @param manual_trade_form_complex [ManualTradeFormComplex]
1141
+ # @param [Hash] opts the optional parameters
1142
+ # @return [ComplexOrderResponse]
1143
+ private def place_complex_order_impl(account_id, user_id, user_secret, manual_trade_form_complex, opts = {})
1144
+ data, _status_code, _headers = place_complex_order_with_http_info(account_id, user_id, user_secret, manual_trade_form_complex, opts)
1145
+ data
1146
+ end
1147
+
1148
+ # Place complex order
1149
+ # Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable. Only supported on certain brokerages. - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled. - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order. - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
1150
+ # @param account_id [String] The ID of the account to execute the trade on.
1151
+ # @param user_id [String]
1152
+ # @param user_secret [String]
1153
+ # @param manual_trade_form_complex [ManualTradeFormComplex]
1154
+ # @param [Hash] opts the optional parameters
1155
+ # @return [Array<(ComplexOrderResponse, Integer, Hash)>] ComplexOrderResponse data, response status code and response headers
1156
+ private def place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, opts = {})
1157
+ if @api_client.config.debugging
1158
+ @api_client.config.logger.debug 'Calling API: TradingApi.place_complex_order ...'
1159
+ end
1160
+ # verify the required parameter 'account_id' is set
1161
+ if @api_client.config.client_side_validation && account_id.nil?
1162
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.place_complex_order"
1163
+ end
1164
+ # verify the required parameter 'user_id' is set
1165
+ if @api_client.config.client_side_validation && user_id.nil?
1166
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.place_complex_order"
1167
+ end
1168
+ # verify the required parameter 'user_secret' is set
1169
+ if @api_client.config.client_side_validation && user_secret.nil?
1170
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.place_complex_order"
1171
+ end
1172
+ # verify the required parameter 'manual_trade_form_complex' is set
1173
+ if @api_client.config.client_side_validation && manual_trade_form_complex.nil?
1174
+ fail ArgumentError, "Missing the required parameter 'manual_trade_form_complex' when calling TradingApi.place_complex_order"
1175
+ end
1176
+ # resource path
1177
+ local_var_path = '/accounts/{accountId}/trading/complex'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
1178
+
1179
+ # query parameters
1180
+ query_params = opts[:query_params] || {}
1181
+ query_params[:'userId'] = user_id
1182
+ query_params[:'userSecret'] = user_secret
1183
+
1184
+ # header parameters
1185
+ header_params = opts[:header_params] || {}
1186
+ # HTTP header 'Accept' (if needed)
1187
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1188
+ # HTTP header 'Content-Type'
1189
+ content_type = @api_client.select_header_content_type(['application/json'])
1190
+ if !content_type.nil?
1191
+ header_params['Content-Type'] = content_type
1192
+ end
1193
+
1194
+ # form parameters
1195
+ form_params = opts[:form_params] || {}
1196
+
1197
+ # http body (model)
1198
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(manual_trade_form_complex)
1199
+
1200
+ # return_type
1201
+ return_type = opts[:debug_return_type] || 'ComplexOrderResponse'
1202
+
1203
+ # auth_names
1204
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
1205
+
1206
+ new_options = opts.merge(
1207
+ :operation => :"TradingApi.place_complex_order",
1208
+ :header_params => header_params,
1209
+ :query_params => query_params,
1210
+ :form_params => form_params,
1211
+ :body => post_body,
1212
+ :auth_names => auth_names,
1213
+ :return_type => return_type
1214
+ )
1215
+
1216
+ data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
1217
+ if @api_client.config.debugging
1218
+ @api_client.config.logger.debug "API called: TradingApi#place_complex_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1219
+ end
1220
+ return data, status_code, headers, response
1221
+ end
1222
+
1223
+
1082
1224
  # Place crypto order
1083
1225
  #
1084
1226
  # Places an order in the specified account.
@@ -0,0 +1,319 @@
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
+ # A single leg within a complex order.
15
+ class ComplexOrderLeg
16
+ # The role of this leg within the complex order.
17
+ attr_accessor :order_role
18
+
19
+ # The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
20
+ attr_accessor :action
21
+
22
+ attr_accessor :instrument
23
+
24
+ # The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
25
+ attr_accessor :order_type
26
+
27
+ # Number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided.
28
+ attr_accessor :units
29
+
30
+ # The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `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.
31
+ attr_accessor :time_in_force
32
+
33
+ # The limit price. Required when `order_type` is `Limit` or `StopLimit`.
34
+ attr_accessor :price
35
+
36
+ # The stop trigger price. Required when `order_type` is `Stop` or `StopLimit`.
37
+ attr_accessor :stop
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'order_role' => :'order_role',
43
+ :'action' => :'action',
44
+ :'instrument' => :'instrument',
45
+ :'order_type' => :'order_type',
46
+ :'units' => :'units',
47
+ :'time_in_force' => :'time_in_force',
48
+ :'price' => :'price',
49
+ :'stop' => :'stop'
50
+ }
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'order_role' => :'OrderRole',
62
+ :'action' => :'ActionStrict',
63
+ :'instrument' => :'TradingInstrument',
64
+ :'order_type' => :'OrderTypeStrict',
65
+ :'units' => :'Float',
66
+ :'time_in_force' => :'TimeInForceStrict',
67
+ :'price' => :'Float',
68
+ :'stop' => :'Float'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ :'price',
76
+ :'stop'
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ComplexOrderLeg` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ComplexOrderLeg`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'order_role')
96
+ self.order_role = attributes[:'order_role']
97
+ end
98
+
99
+ if attributes.key?(:'action')
100
+ self.action = attributes[:'action']
101
+ end
102
+
103
+ if attributes.key?(:'instrument')
104
+ self.instrument = attributes[:'instrument']
105
+ end
106
+
107
+ if attributes.key?(:'order_type')
108
+ self.order_type = attributes[:'order_type']
109
+ end
110
+
111
+ if attributes.key?(:'units')
112
+ self.units = attributes[:'units']
113
+ end
114
+
115
+ if attributes.key?(:'time_in_force')
116
+ self.time_in_force = attributes[:'time_in_force']
117
+ end
118
+
119
+ if attributes.key?(:'price')
120
+ self.price = attributes[:'price']
121
+ end
122
+
123
+ if attributes.key?(:'stop')
124
+ self.stop = attributes[:'stop']
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ invalid_properties = Array.new
132
+ if @order_role.nil?
133
+ invalid_properties.push('invalid value for "order_role", order_role cannot be nil.')
134
+ end
135
+
136
+ if @action.nil?
137
+ invalid_properties.push('invalid value for "action", action cannot be nil.')
138
+ end
139
+
140
+ if @instrument.nil?
141
+ invalid_properties.push('invalid value for "instrument", instrument cannot be nil.')
142
+ end
143
+
144
+ if @order_type.nil?
145
+ invalid_properties.push('invalid value for "order_type", order_type cannot be nil.')
146
+ end
147
+
148
+ if @units.nil?
149
+ invalid_properties.push('invalid value for "units", units cannot be nil.')
150
+ end
151
+
152
+ if @time_in_force.nil?
153
+ invalid_properties.push('invalid value for "time_in_force", time_in_force cannot be nil.')
154
+ end
155
+
156
+ invalid_properties
157
+ end
158
+
159
+ # Check to see if the all the properties in the model are valid
160
+ # @return true if the model is valid
161
+ def valid?
162
+ return false if @order_role.nil?
163
+ return false if @action.nil?
164
+ return false if @instrument.nil?
165
+ return false if @order_type.nil?
166
+ return false if @units.nil?
167
+ return false if @time_in_force.nil?
168
+ true
169
+ end
170
+
171
+ # Checks equality by comparing each attribute.
172
+ # @param [Object] Object to be compared
173
+ def ==(o)
174
+ return true if self.equal?(o)
175
+ self.class == o.class &&
176
+ order_role == o.order_role &&
177
+ action == o.action &&
178
+ instrument == o.instrument &&
179
+ order_type == o.order_type &&
180
+ units == o.units &&
181
+ time_in_force == o.time_in_force &&
182
+ price == o.price &&
183
+ stop == o.stop
184
+ end
185
+
186
+ # @see the `==` method
187
+ # @param [Object] Object to be compared
188
+ def eql?(o)
189
+ self == o
190
+ end
191
+
192
+ # Calculates hash code according to all attributes.
193
+ # @return [Integer] Hash code
194
+ def hash
195
+ [order_role, action, instrument, order_type, units, time_in_force, price, stop].hash
196
+ end
197
+
198
+ # Builds the object from hash
199
+ # @param [Hash] attributes Model attributes in the form of hash
200
+ # @return [Object] Returns the model itself
201
+ def self.build_from_hash(attributes)
202
+ new.build_from_hash(attributes)
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ attributes = attributes.transform_keys(&:to_sym)
211
+ self.class.openapi_types.each_pair do |key, type|
212
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
213
+ self.send("#{key}=", nil)
214
+ elsif type =~ /\AArray<(.*)>/i
215
+ # check to ensure the input is an array given that the attribute
216
+ # is documented as an array but the input is not
217
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
218
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
219
+ end
220
+ elsif !attributes[self.class.attribute_map[key]].nil?
221
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
222
+ end
223
+ end
224
+
225
+ self
226
+ end
227
+
228
+ # Deserializes the data based on type
229
+ # @param string type Data type
230
+ # @param string value Value to be deserialized
231
+ # @return [Object] Deserialized data
232
+ def _deserialize(type, value)
233
+ case type.to_sym
234
+ when :Time
235
+ Time.parse(value)
236
+ when :Date
237
+ Date.parse(value)
238
+ when :String
239
+ value.to_s
240
+ when :Integer
241
+ value.to_i
242
+ when :Float
243
+ value.to_f
244
+ when :Boolean
245
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
246
+ true
247
+ else
248
+ false
249
+ end
250
+ when :Object
251
+ # generic object (usually a Hash), return directly
252
+ value
253
+ when /\AArray<(?<inner_type>.+)>\z/
254
+ inner_type = Regexp.last_match[:inner_type]
255
+ value.map { |v| _deserialize(inner_type, v) }
256
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
257
+ k_type = Regexp.last_match[:k_type]
258
+ v_type = Regexp.last_match[:v_type]
259
+ {}.tap do |hash|
260
+ value.each do |k, v|
261
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
262
+ end
263
+ end
264
+ else # model
265
+ # models (e.g. Pet) or oneOf
266
+ klass = SnapTrade.const_get(type)
267
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
268
+ end
269
+ end
270
+
271
+ # Returns the string representation of the object
272
+ # @return [String] String presentation of the object
273
+ def to_s
274
+ to_hash.to_s
275
+ end
276
+
277
+ # to_body is an alias to to_hash (backward compatibility)
278
+ # @return [Hash] Returns the object in the form of hash
279
+ def to_body
280
+ to_hash
281
+ end
282
+
283
+ # Returns the object in the form of hash
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_hash
286
+ hash = {}
287
+ self.class.attribute_map.each_pair do |attr, param|
288
+ value = self.send(attr)
289
+ if value.nil?
290
+ is_nullable = self.class.openapi_nullable.include?(attr)
291
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
292
+ end
293
+
294
+ hash[param] = _to_hash(value)
295
+ end
296
+ hash
297
+ end
298
+
299
+ # Outputs non-array value in the form of hash
300
+ # For object, use to_hash. Otherwise, just return the value
301
+ # @param [Object] value Any valid value
302
+ # @return [Hash] Returns the value in the form of hash
303
+ def _to_hash(value)
304
+ if value.is_a?(Array)
305
+ value.compact.map { |v| _to_hash(v) }
306
+ elsif value.is_a?(Hash)
307
+ {}.tap do |hash|
308
+ value.each { |k, v| hash[k] = _to_hash(v) }
309
+ end
310
+ elsif value.respond_to? :to_hash
311
+ value.to_hash
312
+ else
313
+ value
314
+ end
315
+ end
316
+
317
+ end
318
+
319
+ end