snaptrade 2.0.69 → 2.0.70
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +19 -2
- data/lib/snaptrade/api/trading_api.rb +14 -2
- data/lib/snaptrade/models/manual_trade_form_with_options.rb +36 -5
- data/lib/snaptrade/models/manual_trade_form_with_options_stop_loss.rb +233 -0
- data/lib/snaptrade/models/manual_trade_form_with_options_take_profit.rb +223 -0
- data/lib/snaptrade/models/order_class.rb +37 -0
- data/lib/snaptrade/models/stop_loss.rb +227 -0
- data/lib/snaptrade/models/take_profit.rb +217 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +5 -0
- data/spec/models/manual_trade_form_with_options_spec.rb +18 -0
- data/spec/models/manual_trade_form_with_options_stop_loss_spec.rb +35 -0
- data/spec/models/manual_trade_form_with_options_take_profit_spec.rb +29 -0
- data/spec/models/order_class_spec.rb +23 -0
- data/spec/models/stop_loss_spec.rb +35 -0
- data/spec/models/take_profit_spec.rb +29 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da123b4dad2c9f58ab7798b61dbb8ef30a91d460b07812d6b543379566060604
|
4
|
+
data.tar.gz: 6d6cc15423db03518ce7f72bcc41c2b7c9b83480031dcaf00e93ea61088868a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b86acfca1bba55bb392ac96f1a0af69832463a8a58c4d91e667e4249e20d408d901e4011884c93742f2922e0673a84319810d6f2690f3cb447b4aa10266ee8e
|
7
|
+
data.tar.gz: 11a7c70a57fabbbe2ebce450c78e1bf0e24c7a5742444ae539deee0e5f6f0ed80e446dbe3918ba04a89288b163deb6badc71dde655c01da6e04732bfaabd732b
|
data/Gemfile.lock
CHANGED
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
|
-
[](https://rubygems.org/gems/snaptrade/versions/2.0.70)
|
10
10
|
[](https://snaptrade.com/)
|
11
11
|
|
12
12
|
</div>
|
@@ -73,7 +73,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
73
73
|
Add to Gemfile:
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
gem 'snaptrade', '~> 2.0.
|
76
|
+
gem 'snaptrade', '~> 2.0.70'
|
77
77
|
```
|
78
78
|
|
79
79
|
## Getting Started<a id="getting-started"></a>
|
@@ -1663,6 +1663,14 @@ result = snaptrade.trading.place_force_order(
|
|
1663
1663
|
stop: 31.33,
|
1664
1664
|
units: 10.5,
|
1665
1665
|
notional_value: None,
|
1666
|
+
order_class: "BRACKET",
|
1667
|
+
stop_loss: {
|
1668
|
+
"stop_price" => "48.55",
|
1669
|
+
"limit_price" => "48.50",
|
1670
|
+
},
|
1671
|
+
take_profit: {
|
1672
|
+
"limit_price" => "49.95",
|
1673
|
+
},
|
1666
1674
|
)
|
1667
1675
|
p result
|
1668
1676
|
```
|
@@ -1718,6 +1726,15 @@ provided. If placing an Option order, this field represents the number of
|
|
1718
1726
|
contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
1719
1727
|
|
1720
1728
|
##### notional_value: [`ManualTradeFormNotionalValue`](./lib/snaptrade/models/manual_trade_form_notional_value.rb)<a id="notional_value-manualtradeformnotionalvaluelibsnaptrademodelsmanual_trade_form_notional_valuerb"></a>
|
1729
|
+
##### order_class: [`OrderClass`](./lib/snaptrade/models/order_class.rb)<a id="order_class-orderclasslibsnaptrademodelsorder_classrb"></a>
|
1730
|
+
The class of order intended to be placed. Defaults to SIMPLE for regular, one
|
1731
|
+
legged trades. Set to BRACKET if looking to place a bracket
|
1732
|
+
(One-triggers-a-one-cancels-the-other) order, then specify take profit and stop
|
1733
|
+
loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and
|
1734
|
+
Tradestation, contact us for more details
|
1735
|
+
|
1736
|
+
##### stop_loss: [`ManualTradeFormWithOptionsStopLoss`](./lib/snaptrade/models/manual_trade_form_with_options_stop_loss.rb)<a id="stop_loss-manualtradeformwithoptionsstoplosslibsnaptrademodelsmanual_trade_form_with_options_stop_lossrb"></a>
|
1737
|
+
##### take_profit: [`ManualTradeFormWithOptionsTakeProfit`](./lib/snaptrade/models/manual_trade_form_with_options_take_profit.rb)<a id="take_profit-manualtradeformwithoptionstakeprofitlibsnaptrademodelsmanual_trade_form_with_options_take_profitrb"></a>
|
1721
1738
|
#### 🔄 Return<a id="🔄-return"></a>
|
1722
1739
|
|
1723
1740
|
[AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb)
|
@@ -428,9 +428,12 @@ module SnapTrade
|
|
428
428
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
429
429
|
# @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
430
430
|
# @param notional_value [ManualTradeFormNotionalValue]
|
431
|
+
# @param order_class [OrderClass] The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
|
432
|
+
# @param stop_loss [ManualTradeFormWithOptionsStopLoss]
|
433
|
+
# @param take_profit [ManualTradeFormWithOptionsTakeProfit]
|
431
434
|
# @param body [ManualTradeFormWithOptions]
|
432
435
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
433
|
-
def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
|
436
|
+
def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, order_class: SENTINEL, stop_loss: SENTINEL, take_profit: SENTINEL, extra: {})
|
434
437
|
_body = {}
|
435
438
|
_body[:account_id] = account_id if account_id != SENTINEL
|
436
439
|
_body[:action] = action if action != SENTINEL
|
@@ -442,6 +445,9 @@ module SnapTrade
|
|
442
445
|
_body[:stop] = stop if stop != SENTINEL
|
443
446
|
_body[:units] = units if units != SENTINEL
|
444
447
|
_body[:notional_value] = notional_value if notional_value != SENTINEL
|
448
|
+
_body[:order_class] = order_class if order_class != SENTINEL
|
449
|
+
_body[:stop_loss] = stop_loss if stop_loss != SENTINEL
|
450
|
+
_body[:take_profit] = take_profit if take_profit != SENTINEL
|
445
451
|
manual_trade_form_with_options = _body
|
446
452
|
data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
|
447
453
|
data
|
@@ -467,9 +473,12 @@ module SnapTrade
|
|
467
473
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
468
474
|
# @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
469
475
|
# @param notional_value [ManualTradeFormNotionalValue]
|
476
|
+
# @param order_class [OrderClass] The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
|
477
|
+
# @param stop_loss [ManualTradeFormWithOptionsStopLoss]
|
478
|
+
# @param take_profit [ManualTradeFormWithOptionsTakeProfit]
|
470
479
|
# @param body [ManualTradeFormWithOptions]
|
471
480
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
472
|
-
def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
|
481
|
+
def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, order_class: SENTINEL, stop_loss: SENTINEL, take_profit: SENTINEL, extra: {})
|
473
482
|
_body = {}
|
474
483
|
_body[:account_id] = account_id if account_id != SENTINEL
|
475
484
|
_body[:action] = action if action != SENTINEL
|
@@ -481,6 +490,9 @@ module SnapTrade
|
|
481
490
|
_body[:stop] = stop if stop != SENTINEL
|
482
491
|
_body[:units] = units if units != SENTINEL
|
483
492
|
_body[:notional_value] = notional_value if notional_value != SENTINEL
|
493
|
+
_body[:order_class] = order_class if order_class != SENTINEL
|
494
|
+
_body[:stop_loss] = stop_loss if stop_loss != SENTINEL
|
495
|
+
_body[:take_profit] = take_profit if take_profit != SENTINEL
|
484
496
|
manual_trade_form_with_options = _body
|
485
497
|
place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
|
486
498
|
end
|
@@ -42,6 +42,13 @@ module SnapTrade
|
|
42
42
|
|
43
43
|
attr_accessor :notional_value
|
44
44
|
|
45
|
+
# The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
|
46
|
+
attr_accessor :order_class
|
47
|
+
|
48
|
+
attr_accessor :stop_loss
|
49
|
+
|
50
|
+
attr_accessor :take_profit
|
51
|
+
|
45
52
|
# Attribute mapping from ruby-style variable name to JSON key.
|
46
53
|
def self.attribute_map
|
47
54
|
{
|
@@ -54,7 +61,10 @@ module SnapTrade
|
|
54
61
|
:'price' => :'price',
|
55
62
|
:'stop' => :'stop',
|
56
63
|
:'units' => :'units',
|
57
|
-
:'notional_value' => :'notional_value'
|
64
|
+
:'notional_value' => :'notional_value',
|
65
|
+
:'order_class' => :'order_class',
|
66
|
+
:'stop_loss' => :'stop_loss',
|
67
|
+
:'take_profit' => :'take_profit'
|
58
68
|
}
|
59
69
|
end
|
60
70
|
|
@@ -75,7 +85,10 @@ module SnapTrade
|
|
75
85
|
:'price' => :'Float',
|
76
86
|
:'stop' => :'Float',
|
77
87
|
:'units' => :'Float',
|
78
|
-
:'notional_value' => :'ManualTradeFormNotionalValue'
|
88
|
+
:'notional_value' => :'ManualTradeFormNotionalValue',
|
89
|
+
:'order_class' => :'OrderClass',
|
90
|
+
:'stop_loss' => :'ManualTradeFormWithOptionsStopLoss',
|
91
|
+
:'take_profit' => :'ManualTradeFormWithOptionsTakeProfit'
|
79
92
|
}
|
80
93
|
end
|
81
94
|
|
@@ -87,7 +100,10 @@ module SnapTrade
|
|
87
100
|
:'price',
|
88
101
|
:'stop',
|
89
102
|
:'units',
|
90
|
-
:'notional_value'
|
103
|
+
:'notional_value',
|
104
|
+
:'order_class',
|
105
|
+
:'stop_loss',
|
106
|
+
:'take_profit'
|
91
107
|
])
|
92
108
|
end
|
93
109
|
|
@@ -145,6 +161,18 @@ module SnapTrade
|
|
145
161
|
if attributes.key?(:'notional_value')
|
146
162
|
self.notional_value = attributes[:'notional_value']
|
147
163
|
end
|
164
|
+
|
165
|
+
if attributes.key?(:'order_class')
|
166
|
+
self.order_class = attributes[:'order_class']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.key?(:'stop_loss')
|
170
|
+
self.stop_loss = attributes[:'stop_loss']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.key?(:'take_profit')
|
174
|
+
self.take_profit = attributes[:'take_profit']
|
175
|
+
end
|
148
176
|
end
|
149
177
|
|
150
178
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -194,7 +222,10 @@ module SnapTrade
|
|
194
222
|
price == o.price &&
|
195
223
|
stop == o.stop &&
|
196
224
|
units == o.units &&
|
197
|
-
notional_value == o.notional_value
|
225
|
+
notional_value == o.notional_value &&
|
226
|
+
order_class == o.order_class &&
|
227
|
+
stop_loss == o.stop_loss &&
|
228
|
+
take_profit == o.take_profit
|
198
229
|
end
|
199
230
|
|
200
231
|
# @see the `==` method
|
@@ -206,7 +237,7 @@ module SnapTrade
|
|
206
237
|
# Calculates hash code according to all attributes.
|
207
238
|
# @return [Integer] Hash code
|
208
239
|
def hash
|
209
|
-
[account_id, action, universal_symbol_id, symbol, order_type, time_in_force, price, stop, units, notional_value].hash
|
240
|
+
[account_id, action, universal_symbol_id, symbol, order_type, time_in_force, price, stop, units, notional_value, order_class, stop_loss, take_profit].hash
|
210
241
|
end
|
211
242
|
|
212
243
|
# Builds the object from hash
|
@@ -0,0 +1,233 @@
|
|
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 ManualTradeFormWithOptionsStopLoss
|
15
|
+
attr_accessor :stop_price
|
16
|
+
|
17
|
+
attr_accessor :limit_price
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'stop_price' => :'stop_price',
|
23
|
+
:'limit_price' => :'limit_price'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.openapi_types
|
34
|
+
{
|
35
|
+
:'stop_price' => :'String',
|
36
|
+
:'limit_price' => :'String'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# List of attributes with nullable: true
|
41
|
+
def self.openapi_nullable
|
42
|
+
Set.new([
|
43
|
+
:'limit_price'
|
44
|
+
])
|
45
|
+
end
|
46
|
+
|
47
|
+
# List of class defined in allOf (OpenAPI v3)
|
48
|
+
def self.openapi_all_of
|
49
|
+
[
|
50
|
+
:'StopLoss'
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
# Initializes the object
|
55
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
56
|
+
def initialize(attributes = {})
|
57
|
+
if (!attributes.is_a?(Hash))
|
58
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ManualTradeFormWithOptionsStopLoss` initialize method"
|
59
|
+
end
|
60
|
+
|
61
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
62
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
63
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
64
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ManualTradeFormWithOptionsStopLoss`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
65
|
+
end
|
66
|
+
h[k.to_sym] = v
|
67
|
+
}
|
68
|
+
|
69
|
+
if attributes.key?(:'stop_price')
|
70
|
+
self.stop_price = attributes[:'stop_price']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.key?(:'limit_price')
|
74
|
+
self.limit_price = attributes[:'limit_price']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
79
|
+
# @return Array for valid properties with the reasons
|
80
|
+
def list_invalid_properties
|
81
|
+
invalid_properties = Array.new
|
82
|
+
invalid_properties
|
83
|
+
end
|
84
|
+
|
85
|
+
# Check to see if the all the properties in the model are valid
|
86
|
+
# @return true if the model is valid
|
87
|
+
def valid?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
stop_price == o.stop_price &&
|
97
|
+
limit_price == o.limit_price
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see the `==` method
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def eql?(o)
|
103
|
+
self == o
|
104
|
+
end
|
105
|
+
|
106
|
+
# Calculates hash code according to all attributes.
|
107
|
+
# @return [Integer] Hash code
|
108
|
+
def hash
|
109
|
+
[stop_price, limit_price].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# Builds the object from hash
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
114
|
+
# @return [Object] Returns the model itself
|
115
|
+
def self.build_from_hash(attributes)
|
116
|
+
new.build_from_hash(attributes)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Builds the object from hash
|
120
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
121
|
+
# @return [Object] Returns the model itself
|
122
|
+
def build_from_hash(attributes)
|
123
|
+
return nil unless attributes.is_a?(Hash)
|
124
|
+
attributes = attributes.transform_keys(&:to_sym)
|
125
|
+
self.class.openapi_types.each_pair do |key, type|
|
126
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
127
|
+
self.send("#{key}=", nil)
|
128
|
+
elsif type =~ /\AArray<(.*)>/i
|
129
|
+
# check to ensure the input is an array given that the attribute
|
130
|
+
# is documented as an array but the input is not
|
131
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
132
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
133
|
+
end
|
134
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
135
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
142
|
+
# Deserializes the data based on type
|
143
|
+
# @param string type Data type
|
144
|
+
# @param string value Value to be deserialized
|
145
|
+
# @return [Object] Deserialized data
|
146
|
+
def _deserialize(type, value)
|
147
|
+
case type.to_sym
|
148
|
+
when :Time
|
149
|
+
Time.parse(value)
|
150
|
+
when :Date
|
151
|
+
Date.parse(value)
|
152
|
+
when :String
|
153
|
+
value.to_s
|
154
|
+
when :Integer
|
155
|
+
value.to_i
|
156
|
+
when :Float
|
157
|
+
value.to_f
|
158
|
+
when :Boolean
|
159
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
160
|
+
true
|
161
|
+
else
|
162
|
+
false
|
163
|
+
end
|
164
|
+
when :Object
|
165
|
+
# generic object (usually a Hash), return directly
|
166
|
+
value
|
167
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
168
|
+
inner_type = Regexp.last_match[:inner_type]
|
169
|
+
value.map { |v| _deserialize(inner_type, v) }
|
170
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
171
|
+
k_type = Regexp.last_match[:k_type]
|
172
|
+
v_type = Regexp.last_match[:v_type]
|
173
|
+
{}.tap do |hash|
|
174
|
+
value.each do |k, v|
|
175
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
else # model
|
179
|
+
# models (e.g. Pet) or oneOf
|
180
|
+
klass = SnapTrade.const_get(type)
|
181
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the string representation of the object
|
186
|
+
# @return [String] String presentation of the object
|
187
|
+
def to_s
|
188
|
+
to_hash.to_s
|
189
|
+
end
|
190
|
+
|
191
|
+
# to_body is an alias to to_hash (backward compatibility)
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_body
|
194
|
+
to_hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the object in the form of hash
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_hash
|
200
|
+
hash = {}
|
201
|
+
self.class.attribute_map.each_pair do |attr, param|
|
202
|
+
value = self.send(attr)
|
203
|
+
if value.nil?
|
204
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
205
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
206
|
+
end
|
207
|
+
|
208
|
+
hash[param] = _to_hash(value)
|
209
|
+
end
|
210
|
+
hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Outputs non-array value in the form of hash
|
214
|
+
# For object, use to_hash. Otherwise, just return the value
|
215
|
+
# @param [Object] value Any valid value
|
216
|
+
# @return [Hash] Returns the value in the form of hash
|
217
|
+
def _to_hash(value)
|
218
|
+
if value.is_a?(Array)
|
219
|
+
value.compact.map { |v| _to_hash(v) }
|
220
|
+
elsif value.is_a?(Hash)
|
221
|
+
{}.tap do |hash|
|
222
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
223
|
+
end
|
224
|
+
elsif value.respond_to? :to_hash
|
225
|
+
value.to_hash
|
226
|
+
else
|
227
|
+
value
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
@@ -0,0 +1,223 @@
|
|
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 ManualTradeFormWithOptionsTakeProfit
|
15
|
+
attr_accessor :limit_price
|
16
|
+
|
17
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
18
|
+
def self.attribute_map
|
19
|
+
{
|
20
|
+
:'limit_price' => :'limit_price'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns all the JSON keys this model knows about
|
25
|
+
def self.acceptable_attributes
|
26
|
+
attribute_map.values
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.openapi_types
|
31
|
+
{
|
32
|
+
:'limit_price' => :'String'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# List of attributes with nullable: true
|
37
|
+
def self.openapi_nullable
|
38
|
+
Set.new([
|
39
|
+
])
|
40
|
+
end
|
41
|
+
|
42
|
+
# List of class defined in allOf (OpenAPI v3)
|
43
|
+
def self.openapi_all_of
|
44
|
+
[
|
45
|
+
:'TakeProfit'
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ManualTradeFormWithOptionsTakeProfit` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ManualTradeFormWithOptionsTakeProfit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'limit_price')
|
65
|
+
self.limit_price = attributes[:'limit_price']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
70
|
+
# @return Array for valid properties with the reasons
|
71
|
+
def list_invalid_properties
|
72
|
+
invalid_properties = Array.new
|
73
|
+
invalid_properties
|
74
|
+
end
|
75
|
+
|
76
|
+
# Check to see if the all the properties in the model are valid
|
77
|
+
# @return true if the model is valid
|
78
|
+
def valid?
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Checks equality by comparing each attribute.
|
83
|
+
# @param [Object] Object to be compared
|
84
|
+
def ==(o)
|
85
|
+
return true if self.equal?(o)
|
86
|
+
self.class == o.class &&
|
87
|
+
limit_price == o.limit_price
|
88
|
+
end
|
89
|
+
|
90
|
+
# @see the `==` method
|
91
|
+
# @param [Object] Object to be compared
|
92
|
+
def eql?(o)
|
93
|
+
self == o
|
94
|
+
end
|
95
|
+
|
96
|
+
# Calculates hash code according to all attributes.
|
97
|
+
# @return [Integer] Hash code
|
98
|
+
def hash
|
99
|
+
[limit_price].hash
|
100
|
+
end
|
101
|
+
|
102
|
+
# Builds the object from hash
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
# @return [Object] Returns the model itself
|
105
|
+
def self.build_from_hash(attributes)
|
106
|
+
new.build_from_hash(attributes)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
attributes = attributes.transform_keys(&:to_sym)
|
115
|
+
self.class.openapi_types.each_pair do |key, type|
|
116
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
117
|
+
self.send("#{key}=", nil)
|
118
|
+
elsif type =~ /\AArray<(.*)>/i
|
119
|
+
# check to ensure the input is an array given that the attribute
|
120
|
+
# is documented as an array but the input is not
|
121
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
122
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
123
|
+
end
|
124
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
125
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deserializes the data based on type
|
133
|
+
# @param string type Data type
|
134
|
+
# @param string value Value to be deserialized
|
135
|
+
# @return [Object] Deserialized data
|
136
|
+
def _deserialize(type, value)
|
137
|
+
case type.to_sym
|
138
|
+
when :Time
|
139
|
+
Time.parse(value)
|
140
|
+
when :Date
|
141
|
+
Date.parse(value)
|
142
|
+
when :String
|
143
|
+
value.to_s
|
144
|
+
when :Integer
|
145
|
+
value.to_i
|
146
|
+
when :Float
|
147
|
+
value.to_f
|
148
|
+
when :Boolean
|
149
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
150
|
+
true
|
151
|
+
else
|
152
|
+
false
|
153
|
+
end
|
154
|
+
when :Object
|
155
|
+
# generic object (usually a Hash), return directly
|
156
|
+
value
|
157
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
158
|
+
inner_type = Regexp.last_match[:inner_type]
|
159
|
+
value.map { |v| _deserialize(inner_type, v) }
|
160
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
161
|
+
k_type = Regexp.last_match[:k_type]
|
162
|
+
v_type = Regexp.last_match[:v_type]
|
163
|
+
{}.tap do |hash|
|
164
|
+
value.each do |k, v|
|
165
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
else # model
|
169
|
+
# models (e.g. Pet) or oneOf
|
170
|
+
klass = SnapTrade.const_get(type)
|
171
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the string representation of the object
|
176
|
+
# @return [String] String presentation of the object
|
177
|
+
def to_s
|
178
|
+
to_hash.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_body
|
184
|
+
to_hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the object in the form of hash
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
if value.nil?
|
194
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
195
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
196
|
+
end
|
197
|
+
|
198
|
+
hash[param] = _to_hash(value)
|
199
|
+
end
|
200
|
+
hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Outputs non-array value in the form of hash
|
204
|
+
# For object, use to_hash. Otherwise, just return the value
|
205
|
+
# @param [Object] value Any valid value
|
206
|
+
# @return [Hash] Returns the value in the form of hash
|
207
|
+
def _to_hash(value)
|
208
|
+
if value.is_a?(Array)
|
209
|
+
value.compact.map { |v| _to_hash(v) }
|
210
|
+
elsif value.is_a?(Hash)
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
213
|
+
end
|
214
|
+
elsif value.respond_to? :to_hash
|
215
|
+
value.to_hash
|
216
|
+
else
|
217
|
+
value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|