snaptrade 2.0.117 → 2.0.119
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 +32 -2
- data/lib/snaptrade/api/reference_data_api.rb +85 -0
- data/lib/snaptrade/models/brokerage_instrument.rb +261 -0
- data/lib/snaptrade/models/brokerage_instruments_response.rb +218 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +2 -0
- data/spec/api/reference_data_api_spec.rb +12 -0
- data/spec/models/brokerage_instrument_spec.rb +53 -0
- data/spec/models/brokerage_instruments_response_spec.rb +29 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04544c3b4f3722e8f2bfc3b1a730fb3fc6ef65fd762afddf4d3e21556880faa4
|
4
|
+
data.tar.gz: 53521894f19e0f2bb52942845132b7f07dc3a0b9de436aa00d57b96d539c1041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e24567932a3cb2c2aa19c1219e3ebc26708beab6a2a5c84cf06b5f4468526c6466a4029202743227245a6d0eafea43fa02fdd7ddcb6e2b88bed363f7c1623fa0
|
7
|
+
data.tar.gz: b8409aaf5fcb21bd3a9a591f0cdaa93500211ad4bd359f6edd929fcbfac82450402a477f14c321b8d6cc73d44a491c85d7fc0b15da597b10f92e731e7c641432
|
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.119)
|
10
10
|
[](https://snaptrade.com/)
|
11
11
|
|
12
12
|
</div>
|
@@ -55,6 +55,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
55
55
|
* [`snaptrade.reference_data.get_symbols`](#snaptradereference_dataget_symbols)
|
56
56
|
* [`snaptrade.reference_data.get_symbols_by_ticker`](#snaptradereference_dataget_symbols_by_ticker)
|
57
57
|
* [`snaptrade.reference_data.list_all_brokerage_authorization_type`](#snaptradereference_datalist_all_brokerage_authorization_type)
|
58
|
+
* [`snaptrade.reference_data.list_all_brokerage_instruments`](#snaptradereference_datalist_all_brokerage_instruments)
|
58
59
|
* [`snaptrade.reference_data.list_all_brokerages`](#snaptradereference_datalist_all_brokerages)
|
59
60
|
* [`snaptrade.reference_data.list_all_currencies`](#snaptradereference_datalist_all_currencies)
|
60
61
|
* [`snaptrade.reference_data.list_all_currencies_rates`](#snaptradereference_datalist_all_currencies_rates)
|
@@ -82,7 +83,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
82
83
|
Add to Gemfile:
|
83
84
|
|
84
85
|
```ruby
|
85
|
-
gem 'snaptrade', '~> 2.0.
|
86
|
+
gem 'snaptrade', '~> 2.0.119'
|
86
87
|
```
|
87
88
|
|
88
89
|
## Getting Started<a id="getting-started"></a>
|
@@ -1468,6 +1469,35 @@ Comma separated value of brokerage slugs
|
|
1468
1469
|
---
|
1469
1470
|
|
1470
1471
|
|
1472
|
+
### `snaptrade.reference_data.list_all_brokerage_instruments`<a id="snaptradereference_datalist_all_brokerage_instruments"></a>
|
1473
|
+
|
1474
|
+
Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
|
1475
|
+
|
1476
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
1477
|
+
|
1478
|
+
```ruby
|
1479
|
+
result = snaptrade.reference_data.list_all_brokerage_instruments(
|
1480
|
+
brokerage_id: "87b24961-b51e-4db8-9226-f198f6518a89",
|
1481
|
+
)
|
1482
|
+
p result
|
1483
|
+
```
|
1484
|
+
|
1485
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
1486
|
+
|
1487
|
+
##### brokerage_id: `String`<a id="brokerage_id-string"></a>
|
1488
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
1489
|
+
|
1490
|
+
[BrokerageInstrumentsResponse](./lib/snaptrade/models/brokerage_instruments_response.rb)
|
1491
|
+
|
1492
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
1493
|
+
|
1494
|
+
`/brokerages/{brokerageId}/instruments` `GET`
|
1495
|
+
|
1496
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
1497
|
+
|
1498
|
+
---
|
1499
|
+
|
1500
|
+
|
1471
1501
|
### `snaptrade.reference_data.list_all_brokerages`<a id="snaptradereference_datalist_all_brokerages"></a>
|
1472
1502
|
|
1473
1503
|
Returns a list of all defined Brokerage objects.
|
@@ -596,6 +596,91 @@ module SnapTrade
|
|
596
596
|
end
|
597
597
|
|
598
598
|
|
599
|
+
# Get brokerage instruments
|
600
|
+
#
|
601
|
+
# Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
|
602
|
+
#
|
603
|
+
# @param brokerage_id [String]
|
604
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
605
|
+
def list_all_brokerage_instruments(brokerage_id:, extra: {})
|
606
|
+
data, _status_code, _headers = list_all_brokerage_instruments_with_http_info_impl(brokerage_id, extra)
|
607
|
+
data
|
608
|
+
end
|
609
|
+
|
610
|
+
# Get brokerage instruments
|
611
|
+
#
|
612
|
+
# Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
|
613
|
+
#
|
614
|
+
# @param brokerage_id [String]
|
615
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
616
|
+
def list_all_brokerage_instruments_with_http_info(brokerage_id:, extra: {})
|
617
|
+
list_all_brokerage_instruments_with_http_info_impl(brokerage_id, extra)
|
618
|
+
end
|
619
|
+
|
620
|
+
# Get brokerage instruments
|
621
|
+
# Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
|
622
|
+
# @param brokerage_id [String]
|
623
|
+
# @param [Hash] opts the optional parameters
|
624
|
+
# @return [BrokerageInstrumentsResponse]
|
625
|
+
private def list_all_brokerage_instruments_impl(brokerage_id, opts = {})
|
626
|
+
data, _status_code, _headers = list_all_brokerage_instruments_with_http_info(brokerage_id, opts)
|
627
|
+
data
|
628
|
+
end
|
629
|
+
|
630
|
+
# Get brokerage instruments
|
631
|
+
# Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
|
632
|
+
# @param brokerage_id [String]
|
633
|
+
# @param [Hash] opts the optional parameters
|
634
|
+
# @return [Array<(BrokerageInstrumentsResponse, Integer, Hash)>] BrokerageInstrumentsResponse data, response status code and response headers
|
635
|
+
private def list_all_brokerage_instruments_with_http_info_impl(brokerage_id, opts = {})
|
636
|
+
if @api_client.config.debugging
|
637
|
+
@api_client.config.logger.debug 'Calling API: ReferenceDataApi.list_all_brokerage_instruments ...'
|
638
|
+
end
|
639
|
+
# verify the required parameter 'brokerage_id' is set
|
640
|
+
if @api_client.config.client_side_validation && brokerage_id.nil?
|
641
|
+
fail ArgumentError, "Missing the required parameter 'brokerage_id' when calling ReferenceDataApi.list_all_brokerage_instruments"
|
642
|
+
end
|
643
|
+
# resource path
|
644
|
+
local_var_path = '/brokerages/{brokerageId}/instruments'.sub('{' + 'brokerageId' + '}', CGI.escape(brokerage_id.to_s))
|
645
|
+
|
646
|
+
# query parameters
|
647
|
+
query_params = opts[:query_params] || {}
|
648
|
+
|
649
|
+
# header parameters
|
650
|
+
header_params = opts[:header_params] || {}
|
651
|
+
# HTTP header 'Accept' (if needed)
|
652
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
653
|
+
|
654
|
+
# form parameters
|
655
|
+
form_params = opts[:form_params] || {}
|
656
|
+
|
657
|
+
# http body (model)
|
658
|
+
post_body = opts[:debug_body]
|
659
|
+
|
660
|
+
# return_type
|
661
|
+
return_type = opts[:debug_return_type] || 'BrokerageInstrumentsResponse'
|
662
|
+
|
663
|
+
# auth_names
|
664
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
665
|
+
|
666
|
+
new_options = opts.merge(
|
667
|
+
:operation => :"ReferenceDataApi.list_all_brokerage_instruments",
|
668
|
+
:header_params => header_params,
|
669
|
+
:query_params => query_params,
|
670
|
+
:form_params => form_params,
|
671
|
+
:body => post_body,
|
672
|
+
:auth_names => auth_names,
|
673
|
+
:return_type => return_type
|
674
|
+
)
|
675
|
+
|
676
|
+
data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
|
677
|
+
if @api_client.config.debugging
|
678
|
+
@api_client.config.logger.debug "API called: ReferenceDataApi#list_all_brokerage_instruments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
679
|
+
end
|
680
|
+
return data, status_code, headers, response
|
681
|
+
end
|
682
|
+
|
683
|
+
|
599
684
|
# Get brokerages
|
600
685
|
#
|
601
686
|
# Returns a list of all defined Brokerage objects.
|
@@ -0,0 +1,261 @@
|
|
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 BrokerageInstrument
|
15
|
+
# The instrument's trading symbol / ticker.
|
16
|
+
attr_accessor :symbol
|
17
|
+
|
18
|
+
# The MIC code of the exchange where the instrument is traded.
|
19
|
+
attr_accessor :exchange_mic
|
20
|
+
|
21
|
+
# Whether the instrument is tradeable through the brokerage. `null` if the tradeability is unknown.
|
22
|
+
attr_accessor :tradeable
|
23
|
+
|
24
|
+
# Whether the instrument allows fractional units. `null` if the fractionability is unknown.
|
25
|
+
attr_accessor :fractionable
|
26
|
+
|
27
|
+
# The universal symbol ID of the instrument. This is the ID used to reference the instrument in SnapTrade API calls.
|
28
|
+
attr_accessor :universal_symbol_id
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:'symbol' => :'symbol',
|
34
|
+
:'exchange_mic' => :'exchange_mic',
|
35
|
+
:'tradeable' => :'tradeable',
|
36
|
+
:'fractionable' => :'fractionable',
|
37
|
+
:'universal_symbol_id' => :'universal_symbol_id'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns all the JSON keys this model knows about
|
42
|
+
def self.acceptable_attributes
|
43
|
+
attribute_map.values
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attribute type mapping.
|
47
|
+
def self.openapi_types
|
48
|
+
{
|
49
|
+
:'symbol' => :'String',
|
50
|
+
:'exchange_mic' => :'String',
|
51
|
+
:'tradeable' => :'Boolean',
|
52
|
+
:'fractionable' => :'Boolean',
|
53
|
+
:'universal_symbol_id' => :'String'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
# List of attributes with nullable: true
|
58
|
+
def self.openapi_nullable
|
59
|
+
Set.new([
|
60
|
+
:'exchange_mic',
|
61
|
+
:'tradeable',
|
62
|
+
:'fractionable',
|
63
|
+
:'universal_symbol_id'
|
64
|
+
])
|
65
|
+
end
|
66
|
+
|
67
|
+
# Initializes the object
|
68
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
69
|
+
def initialize(attributes = {})
|
70
|
+
if (!attributes.is_a?(Hash))
|
71
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::BrokerageInstrument` initialize method"
|
72
|
+
end
|
73
|
+
|
74
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
75
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
76
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
77
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::BrokerageInstrument`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
78
|
+
end
|
79
|
+
h[k.to_sym] = v
|
80
|
+
}
|
81
|
+
|
82
|
+
if attributes.key?(:'symbol')
|
83
|
+
self.symbol = attributes[:'symbol']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'exchange_mic')
|
87
|
+
self.exchange_mic = attributes[:'exchange_mic']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'tradeable')
|
91
|
+
self.tradeable = attributes[:'tradeable']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'fractionable')
|
95
|
+
self.fractionable = attributes[:'fractionable']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'universal_symbol_id')
|
99
|
+
self.universal_symbol_id = attributes[:'universal_symbol_id']
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
104
|
+
# @return Array for valid properties with the reasons
|
105
|
+
def list_invalid_properties
|
106
|
+
invalid_properties = Array.new
|
107
|
+
invalid_properties
|
108
|
+
end
|
109
|
+
|
110
|
+
# Check to see if the all the properties in the model are valid
|
111
|
+
# @return true if the model is valid
|
112
|
+
def valid?
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
# Checks equality by comparing each attribute.
|
117
|
+
# @param [Object] Object to be compared
|
118
|
+
def ==(o)
|
119
|
+
return true if self.equal?(o)
|
120
|
+
self.class == o.class &&
|
121
|
+
symbol == o.symbol &&
|
122
|
+
exchange_mic == o.exchange_mic &&
|
123
|
+
tradeable == o.tradeable &&
|
124
|
+
fractionable == o.fractionable &&
|
125
|
+
universal_symbol_id == o.universal_symbol_id
|
126
|
+
end
|
127
|
+
|
128
|
+
# @see the `==` method
|
129
|
+
# @param [Object] Object to be compared
|
130
|
+
def eql?(o)
|
131
|
+
self == o
|
132
|
+
end
|
133
|
+
|
134
|
+
# Calculates hash code according to all attributes.
|
135
|
+
# @return [Integer] Hash code
|
136
|
+
def hash
|
137
|
+
[symbol, exchange_mic, tradeable, fractionable, universal_symbol_id].hash
|
138
|
+
end
|
139
|
+
|
140
|
+
# Builds the object from hash
|
141
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
142
|
+
# @return [Object] Returns the model itself
|
143
|
+
def self.build_from_hash(attributes)
|
144
|
+
new.build_from_hash(attributes)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Builds the object from hash
|
148
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
149
|
+
# @return [Object] Returns the model itself
|
150
|
+
def build_from_hash(attributes)
|
151
|
+
return nil unless attributes.is_a?(Hash)
|
152
|
+
attributes = attributes.transform_keys(&:to_sym)
|
153
|
+
self.class.openapi_types.each_pair do |key, type|
|
154
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
155
|
+
self.send("#{key}=", nil)
|
156
|
+
elsif type =~ /\AArray<(.*)>/i
|
157
|
+
# check to ensure the input is an array given that the attribute
|
158
|
+
# is documented as an array but the input is not
|
159
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
160
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
161
|
+
end
|
162
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
163
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
self
|
168
|
+
end
|
169
|
+
|
170
|
+
# Deserializes the data based on type
|
171
|
+
# @param string type Data type
|
172
|
+
# @param string value Value to be deserialized
|
173
|
+
# @return [Object] Deserialized data
|
174
|
+
def _deserialize(type, value)
|
175
|
+
case type.to_sym
|
176
|
+
when :Time
|
177
|
+
Time.parse(value)
|
178
|
+
when :Date
|
179
|
+
Date.parse(value)
|
180
|
+
when :String
|
181
|
+
value.to_s
|
182
|
+
when :Integer
|
183
|
+
value.to_i
|
184
|
+
when :Float
|
185
|
+
value.to_f
|
186
|
+
when :Boolean
|
187
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
188
|
+
true
|
189
|
+
else
|
190
|
+
false
|
191
|
+
end
|
192
|
+
when :Object
|
193
|
+
# generic object (usually a Hash), return directly
|
194
|
+
value
|
195
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
196
|
+
inner_type = Regexp.last_match[:inner_type]
|
197
|
+
value.map { |v| _deserialize(inner_type, v) }
|
198
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
199
|
+
k_type = Regexp.last_match[:k_type]
|
200
|
+
v_type = Regexp.last_match[:v_type]
|
201
|
+
{}.tap do |hash|
|
202
|
+
value.each do |k, v|
|
203
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
else # model
|
207
|
+
# models (e.g. Pet) or oneOf
|
208
|
+
klass = SnapTrade.const_get(type)
|
209
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the string representation of the object
|
214
|
+
# @return [String] String presentation of the object
|
215
|
+
def to_s
|
216
|
+
to_hash.to_s
|
217
|
+
end
|
218
|
+
|
219
|
+
# to_body is an alias to to_hash (backward compatibility)
|
220
|
+
# @return [Hash] Returns the object in the form of hash
|
221
|
+
def to_body
|
222
|
+
to_hash
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns the object in the form of hash
|
226
|
+
# @return [Hash] Returns the object in the form of hash
|
227
|
+
def to_hash
|
228
|
+
hash = {}
|
229
|
+
self.class.attribute_map.each_pair do |attr, param|
|
230
|
+
value = self.send(attr)
|
231
|
+
if value.nil?
|
232
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
233
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
234
|
+
end
|
235
|
+
|
236
|
+
hash[param] = _to_hash(value)
|
237
|
+
end
|
238
|
+
hash
|
239
|
+
end
|
240
|
+
|
241
|
+
# Outputs non-array value in the form of hash
|
242
|
+
# For object, use to_hash. Otherwise, just return the value
|
243
|
+
# @param [Object] value Any valid value
|
244
|
+
# @return [Hash] Returns the value in the form of hash
|
245
|
+
def _to_hash(value)
|
246
|
+
if value.is_a?(Array)
|
247
|
+
value.compact.map { |v| _to_hash(v) }
|
248
|
+
elsif value.is_a?(Hash)
|
249
|
+
{}.tap do |hash|
|
250
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
251
|
+
end
|
252
|
+
elsif value.respond_to? :to_hash
|
253
|
+
value.to_hash
|
254
|
+
else
|
255
|
+
value
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
@@ -0,0 +1,218 @@
|
|
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 BrokerageInstrumentsResponse
|
15
|
+
attr_accessor :instruments
|
16
|
+
|
17
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
18
|
+
def self.attribute_map
|
19
|
+
{
|
20
|
+
:'instruments' => :'instruments'
|
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
|
+
:'instruments' => :'Array<BrokerageInstrument>'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# List of attributes with nullable: true
|
37
|
+
def self.openapi_nullable
|
38
|
+
Set.new([
|
39
|
+
])
|
40
|
+
end
|
41
|
+
|
42
|
+
# Initializes the object
|
43
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
44
|
+
def initialize(attributes = {})
|
45
|
+
if (!attributes.is_a?(Hash))
|
46
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::BrokerageInstrumentsResponse` initialize method"
|
47
|
+
end
|
48
|
+
|
49
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
50
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
51
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
52
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::BrokerageInstrumentsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
53
|
+
end
|
54
|
+
h[k.to_sym] = v
|
55
|
+
}
|
56
|
+
|
57
|
+
if attributes.key?(:'instruments')
|
58
|
+
if (value = attributes[:'instruments']).is_a?(Array)
|
59
|
+
self.instruments = value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
65
|
+
# @return Array for valid properties with the reasons
|
66
|
+
def list_invalid_properties
|
67
|
+
invalid_properties = Array.new
|
68
|
+
invalid_properties
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check to see if the all the properties in the model are valid
|
72
|
+
# @return true if the model is valid
|
73
|
+
def valid?
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# Checks equality by comparing each attribute.
|
78
|
+
# @param [Object] Object to be compared
|
79
|
+
def ==(o)
|
80
|
+
return true if self.equal?(o)
|
81
|
+
self.class == o.class &&
|
82
|
+
instruments == o.instruments
|
83
|
+
end
|
84
|
+
|
85
|
+
# @see the `==` method
|
86
|
+
# @param [Object] Object to be compared
|
87
|
+
def eql?(o)
|
88
|
+
self == o
|
89
|
+
end
|
90
|
+
|
91
|
+
# Calculates hash code according to all attributes.
|
92
|
+
# @return [Integer] Hash code
|
93
|
+
def hash
|
94
|
+
[instruments].hash
|
95
|
+
end
|
96
|
+
|
97
|
+
# Builds the object from hash
|
98
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
99
|
+
# @return [Object] Returns the model itself
|
100
|
+
def self.build_from_hash(attributes)
|
101
|
+
new.build_from_hash(attributes)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Builds the object from hash
|
105
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
106
|
+
# @return [Object] Returns the model itself
|
107
|
+
def build_from_hash(attributes)
|
108
|
+
return nil unless attributes.is_a?(Hash)
|
109
|
+
attributes = attributes.transform_keys(&:to_sym)
|
110
|
+
self.class.openapi_types.each_pair do |key, type|
|
111
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
112
|
+
self.send("#{key}=", nil)
|
113
|
+
elsif type =~ /\AArray<(.*)>/i
|
114
|
+
# check to ensure the input is an array given that the attribute
|
115
|
+
# is documented as an array but the input is not
|
116
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
117
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
118
|
+
end
|
119
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
120
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
# Deserializes the data based on type
|
128
|
+
# @param string type Data type
|
129
|
+
# @param string value Value to be deserialized
|
130
|
+
# @return [Object] Deserialized data
|
131
|
+
def _deserialize(type, value)
|
132
|
+
case type.to_sym
|
133
|
+
when :Time
|
134
|
+
Time.parse(value)
|
135
|
+
when :Date
|
136
|
+
Date.parse(value)
|
137
|
+
when :String
|
138
|
+
value.to_s
|
139
|
+
when :Integer
|
140
|
+
value.to_i
|
141
|
+
when :Float
|
142
|
+
value.to_f
|
143
|
+
when :Boolean
|
144
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
145
|
+
true
|
146
|
+
else
|
147
|
+
false
|
148
|
+
end
|
149
|
+
when :Object
|
150
|
+
# generic object (usually a Hash), return directly
|
151
|
+
value
|
152
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
153
|
+
inner_type = Regexp.last_match[:inner_type]
|
154
|
+
value.map { |v| _deserialize(inner_type, v) }
|
155
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
156
|
+
k_type = Regexp.last_match[:k_type]
|
157
|
+
v_type = Regexp.last_match[:v_type]
|
158
|
+
{}.tap do |hash|
|
159
|
+
value.each do |k, v|
|
160
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
else # model
|
164
|
+
# models (e.g. Pet) or oneOf
|
165
|
+
klass = SnapTrade.const_get(type)
|
166
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Returns the string representation of the object
|
171
|
+
# @return [String] String presentation of the object
|
172
|
+
def to_s
|
173
|
+
to_hash.to_s
|
174
|
+
end
|
175
|
+
|
176
|
+
# to_body is an alias to to_hash (backward compatibility)
|
177
|
+
# @return [Hash] Returns the object in the form of hash
|
178
|
+
def to_body
|
179
|
+
to_hash
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the object in the form of hash
|
183
|
+
# @return [Hash] Returns the object in the form of hash
|
184
|
+
def to_hash
|
185
|
+
hash = {}
|
186
|
+
self.class.attribute_map.each_pair do |attr, param|
|
187
|
+
value = self.send(attr)
|
188
|
+
if value.nil?
|
189
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
190
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
191
|
+
end
|
192
|
+
|
193
|
+
hash[param] = _to_hash(value)
|
194
|
+
end
|
195
|
+
hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Outputs non-array value in the form of hash
|
199
|
+
# For object, use to_hash. Otherwise, just return the value
|
200
|
+
# @param [Object] value Any valid value
|
201
|
+
# @return [Hash] Returns the value in the form of hash
|
202
|
+
def _to_hash(value)
|
203
|
+
if value.is_a?(Array)
|
204
|
+
value.compact.map { |v| _to_hash(v) }
|
205
|
+
elsif value.is_a?(Hash)
|
206
|
+
{}.tap do |hash|
|
207
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
208
|
+
end
|
209
|
+
elsif value.respond_to? :to_hash
|
210
|
+
value.to_hash
|
211
|
+
else
|
212
|
+
value
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
data/lib/snaptrade/version.rb
CHANGED
data/lib/snaptrade.rb
CHANGED
@@ -47,6 +47,8 @@ require 'snaptrade/models/brokerage_authorization_disabled_confirmation'
|
|
47
47
|
require 'snaptrade/models/brokerage_authorization_refresh_confirmation'
|
48
48
|
require 'snaptrade/models/brokerage_authorization_type_read_only'
|
49
49
|
require 'snaptrade/models/brokerage_authorization_type_read_only_brokerage'
|
50
|
+
require 'snaptrade/models/brokerage_instrument'
|
51
|
+
require 'snaptrade/models/brokerage_instruments_response'
|
50
52
|
require 'snaptrade/models/brokerage_type'
|
51
53
|
require 'snaptrade/models/cancel_order_response'
|
52
54
|
require 'snaptrade/models/child_brokerage_order_ids'
|
@@ -108,6 +108,18 @@ describe 'ReferenceDataApi' do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
# unit tests for list_all_brokerage_instruments
|
112
|
+
# Get brokerage instruments
|
113
|
+
# Returns a list of all brokerage instruments available for a given brokerage. Not all brokerages support this. The ones that don't will return an empty list.
|
114
|
+
# @param brokerage_id
|
115
|
+
# @param [Hash] opts the optional parameters
|
116
|
+
# @return [BrokerageInstrumentsResponse]
|
117
|
+
describe 'list_all_brokerage_instruments test' do
|
118
|
+
it 'should work' do
|
119
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
111
123
|
# unit tests for list_all_brokerages
|
112
124
|
# Get brokerages
|
113
125
|
# Returns a list of all defined Brokerage objects.
|
@@ -0,0 +1,53 @@
|
|
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 'spec_helper'
|
11
|
+
require 'json'
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
# Unit tests for SnapTrade::BrokerageInstrument
|
15
|
+
describe SnapTrade::BrokerageInstrument do
|
16
|
+
let(:instance) { SnapTrade::BrokerageInstrument.new }
|
17
|
+
|
18
|
+
describe 'test an instance of BrokerageInstrument' do
|
19
|
+
it 'should create an instance of BrokerageInstrument' do
|
20
|
+
expect(instance).to be_instance_of(SnapTrade::BrokerageInstrument)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
describe 'test attribute "symbol"' do
|
24
|
+
it 'should work' do
|
25
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test attribute "exchange_mic"' do
|
30
|
+
it 'should work' do
|
31
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'test attribute "tradeable"' do
|
36
|
+
it 'should work' do
|
37
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'test attribute "fractionable"' do
|
42
|
+
it 'should work' do
|
43
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'test attribute "universal_symbol_id"' do
|
48
|
+
it 'should work' do
|
49
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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 'spec_helper'
|
11
|
+
require 'json'
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
# Unit tests for SnapTrade::BrokerageInstrumentsResponse
|
15
|
+
describe SnapTrade::BrokerageInstrumentsResponse do
|
16
|
+
let(:instance) { SnapTrade::BrokerageInstrumentsResponse.new }
|
17
|
+
|
18
|
+
describe 'test an instance of BrokerageInstrumentsResponse' do
|
19
|
+
it 'should create an instance of BrokerageInstrumentsResponse' do
|
20
|
+
expect(instance).to be_instance_of(SnapTrade::BrokerageInstrumentsResponse)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
describe 'test attribute "instruments"' do
|
24
|
+
it 'should work' do
|
25
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snaptrade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.119
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SnapTrade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -126,6 +126,8 @@ files:
|
|
126
126
|
- lib/snaptrade/models/brokerage_authorization_refresh_confirmation.rb
|
127
127
|
- lib/snaptrade/models/brokerage_authorization_type_read_only.rb
|
128
128
|
- lib/snaptrade/models/brokerage_authorization_type_read_only_brokerage.rb
|
129
|
+
- lib/snaptrade/models/brokerage_instrument.rb
|
130
|
+
- lib/snaptrade/models/brokerage_instruments_response.rb
|
129
131
|
- lib/snaptrade/models/brokerage_type.rb
|
130
132
|
- lib/snaptrade/models/cancel_order_response.rb
|
131
133
|
- lib/snaptrade/models/child_brokerage_order_ids.rb
|
@@ -287,6 +289,8 @@ files:
|
|
287
289
|
- spec/models/brokerage_authorization_spec.rb
|
288
290
|
- spec/models/brokerage_authorization_type_read_only_brokerage_spec.rb
|
289
291
|
- spec/models/brokerage_authorization_type_read_only_spec.rb
|
292
|
+
- spec/models/brokerage_instrument_spec.rb
|
293
|
+
- spec/models/brokerage_instruments_response_spec.rb
|
290
294
|
- spec/models/brokerage_spec.rb
|
291
295
|
- spec/models/brokerage_type_spec.rb
|
292
296
|
- spec/models/cancel_order_response_spec.rb
|
@@ -444,6 +448,7 @@ test_files:
|
|
444
448
|
- spec/api_client_spec.rb
|
445
449
|
- spec/configuration_spec.rb
|
446
450
|
- spec/getting_started_spec.rb
|
451
|
+
- spec/models/brokerage_instruments_response_spec.rb
|
447
452
|
- spec/models/underlying_symbol_type_spec.rb
|
448
453
|
- spec/models/action_strict_spec.rb
|
449
454
|
- spec/models/order_updated_response_spec.rb
|
@@ -494,6 +499,7 @@ test_files:
|
|
494
499
|
- spec/models/universal_symbol_spec.rb
|
495
500
|
- spec/models/model404_failed_request_response_spec.rb
|
496
501
|
- spec/models/model425_failed_request_response_spec.rb
|
502
|
+
- spec/models/brokerage_instrument_spec.rb
|
497
503
|
- spec/models/validated_trade_body_spec.rb
|
498
504
|
- spec/models/option_brokerage_symbol_spec.rb
|
499
505
|
- spec/models/option_chain_inner_chain_per_root_inner_chain_per_strike_price_inner_spec.rb
|