snaptrade 2.0.218 → 3.0.0
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 +3 -3
- data/README.md +20 -549
- data/lib/snaptrade/api/account_information_api.rb +0 -231
- data/lib/snaptrade/api/connections_api.rb +0 -201
- data/lib/snaptrade/api/experimental_endpoints_api.rb +123 -0
- data/lib/snaptrade/api/reference_data_api.rb +0 -316
- data/lib/snaptrade/api/trading_api.rb +0 -290
- data/lib/snaptrade/models/connection_account.rb +51 -0
- data/lib/snaptrade/models/{connections_session_events200_response_inner.rb → connection_account_sync_status.rb} +35 -77
- data/lib/snaptrade/models/investment_account.rb +372 -0
- data/lib/snaptrade/models/investment_account_market_value.rb +228 -0
- data/lib/snaptrade/models/kind.rb +2 -2
- data/lib/snaptrade/models/stock_instrument.rb +1 -1
- data/lib/snaptrade/models/stock_instrument_kind.rb +36 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +5 -7
- data/spec/api/account_information_api_spec.rb +0 -28
- data/spec/api/connections_api_spec.rb +0 -28
- data/spec/api/experimental_endpoints_api_spec.rb +14 -0
- data/spec/api/reference_data_api_spec.rb +0 -45
- data/spec/api/trading_api_spec.rb +0 -30
- data/spec/getting_started_spec.rb +6 -6
- data/spec/models/connection_account_spec.rb +38 -0
- data/spec/models/connection_account_sync_status_spec.rb +47 -0
- data/spec/models/investment_account_market_value_spec.rb +35 -0
- data/spec/models/investment_account_spec.rb +101 -0
- data/spec/models/stock_instrument_kind_spec.rb +23 -0
- metadata +212 -206
- data/lib/snaptrade/api/options_api.rb +0 -137
- data/lib/snaptrade/api/transactions_and_reporting_api.rb +0 -302
- data/spec/api/options_api_spec.rb +0 -44
- data/spec/api/transactions_and_reporting_api_spec.rb +0 -66
- data/spec/models/connections_session_events200_response_inner_spec.rb +0 -65
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
# Total market value of the account. Null when unknown (e.g. a real-time fetch failed and no cached value exists).
|
|
15
|
+
class InvestmentAccountMarketValue
|
|
16
|
+
attr_accessor :amount
|
|
17
|
+
|
|
18
|
+
attr_accessor :currency
|
|
19
|
+
|
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
21
|
+
def self.attribute_map
|
|
22
|
+
{
|
|
23
|
+
:'amount' => :'amount',
|
|
24
|
+
:'currency' => :'currency'
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns all the JSON keys this model knows about
|
|
29
|
+
def self.acceptable_attributes
|
|
30
|
+
attribute_map.values
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Attribute type mapping.
|
|
34
|
+
def self.openapi_types
|
|
35
|
+
{
|
|
36
|
+
:'amount' => :'Float',
|
|
37
|
+
:'currency' => :'String'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# List of attributes with nullable: true
|
|
42
|
+
def self.openapi_nullable
|
|
43
|
+
Set.new([
|
|
44
|
+
:'amount',
|
|
45
|
+
:'currency'
|
|
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::InvestmentAccountMarketValue` 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::InvestmentAccountMarketValue`. 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?(:'amount')
|
|
65
|
+
self.amount = attributes[:'amount']
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if attributes.key?(:'currency')
|
|
69
|
+
self.currency = attributes[:'currency']
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
74
|
+
# @return Array for valid properties with the reasons
|
|
75
|
+
def list_invalid_properties
|
|
76
|
+
invalid_properties = Array.new
|
|
77
|
+
invalid_properties
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Check to see if the all the properties in the model are valid
|
|
81
|
+
# @return true if the model is valid
|
|
82
|
+
def valid?
|
|
83
|
+
true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Checks equality by comparing each attribute.
|
|
87
|
+
# @param [Object] Object to be compared
|
|
88
|
+
def ==(o)
|
|
89
|
+
return true if self.equal?(o)
|
|
90
|
+
self.class == o.class &&
|
|
91
|
+
amount == o.amount &&
|
|
92
|
+
currency == o.currency
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# @see the `==` method
|
|
96
|
+
# @param [Object] Object to be compared
|
|
97
|
+
def eql?(o)
|
|
98
|
+
self == o
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Calculates hash code according to all attributes.
|
|
102
|
+
# @return [Integer] Hash code
|
|
103
|
+
def hash
|
|
104
|
+
[amount, currency].hash
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Builds the object from hash
|
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
109
|
+
# @return [Object] Returns the model itself
|
|
110
|
+
def self.build_from_hash(attributes)
|
|
111
|
+
new.build_from_hash(attributes)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Builds the object from hash
|
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
116
|
+
# @return [Object] Returns the model itself
|
|
117
|
+
def build_from_hash(attributes)
|
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
|
119
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
120
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
121
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
122
|
+
self.send("#{key}=", nil)
|
|
123
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
124
|
+
# check to ensure the input is an array given that the attribute
|
|
125
|
+
# is documented as an array but the input is not
|
|
126
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
127
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
128
|
+
end
|
|
129
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
130
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
self
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Deserializes the data based on type
|
|
138
|
+
# @param string type Data type
|
|
139
|
+
# @param string value Value to be deserialized
|
|
140
|
+
# @return [Object] Deserialized data
|
|
141
|
+
def _deserialize(type, value)
|
|
142
|
+
case type.to_sym
|
|
143
|
+
when :Time
|
|
144
|
+
Time.parse(value)
|
|
145
|
+
when :Date
|
|
146
|
+
Date.parse(value)
|
|
147
|
+
when :String
|
|
148
|
+
value.to_s
|
|
149
|
+
when :Integer
|
|
150
|
+
value.to_i
|
|
151
|
+
when :Float
|
|
152
|
+
value.to_f
|
|
153
|
+
when :Boolean
|
|
154
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
155
|
+
true
|
|
156
|
+
else
|
|
157
|
+
false
|
|
158
|
+
end
|
|
159
|
+
when :Object
|
|
160
|
+
# generic object (usually a Hash), return directly
|
|
161
|
+
value
|
|
162
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
163
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
164
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
165
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
166
|
+
k_type = Regexp.last_match[:k_type]
|
|
167
|
+
v_type = Regexp.last_match[:v_type]
|
|
168
|
+
{}.tap do |hash|
|
|
169
|
+
value.each do |k, v|
|
|
170
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
else # model
|
|
174
|
+
# models (e.g. Pet) or oneOf
|
|
175
|
+
klass = SnapTrade.const_get(type)
|
|
176
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Returns the string representation of the object
|
|
181
|
+
# @return [String] String presentation of the object
|
|
182
|
+
def to_s
|
|
183
|
+
to_hash.to_s
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
|
188
|
+
def to_body
|
|
189
|
+
to_hash
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Returns the object in the form of hash
|
|
193
|
+
# @return [Hash] Returns the object in the form of hash
|
|
194
|
+
def to_hash
|
|
195
|
+
hash = {}
|
|
196
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
197
|
+
value = self.send(attr)
|
|
198
|
+
if value.nil?
|
|
199
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
200
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
hash[param] = _to_hash(value)
|
|
204
|
+
end
|
|
205
|
+
hash
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Outputs non-array value in the form of hash
|
|
209
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
210
|
+
# @param [Object] value Any valid value
|
|
211
|
+
# @return [Hash] Returns the value in the form of hash
|
|
212
|
+
def _to_hash(value)
|
|
213
|
+
if value.is_a?(Array)
|
|
214
|
+
value.compact.map { |v| _to_hash(v) }
|
|
215
|
+
elsif value.is_a?(Hash)
|
|
216
|
+
{}.tap do |hash|
|
|
217
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
218
|
+
end
|
|
219
|
+
elsif value.respond_to? :to_hash
|
|
220
|
+
value.to_hash
|
|
221
|
+
else
|
|
222
|
+
value
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
end
|
|
@@ -12,10 +12,10 @@ require 'time'
|
|
|
12
12
|
|
|
13
13
|
module SnapTrade
|
|
14
14
|
class Kind
|
|
15
|
-
|
|
15
|
+
INVESTMENT = "investment".freeze
|
|
16
16
|
|
|
17
17
|
def self.all_vars
|
|
18
|
-
@all_vars ||= [
|
|
18
|
+
@all_vars ||= [INVESTMENT].freeze
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Builds the enum from string
|
|
@@ -0,0 +1,36 @@
|
|
|
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 StockInstrumentKind
|
|
15
|
+
STOCK = "stock".freeze
|
|
16
|
+
|
|
17
|
+
def self.all_vars
|
|
18
|
+
@all_vars ||= [STOCK].freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Builds the enum from string
|
|
22
|
+
# @param [String] The enum value in the form of the string
|
|
23
|
+
# @return [String] The enum value
|
|
24
|
+
def self.build_from_hash(value)
|
|
25
|
+
new.build_from_hash(value)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the enum from string
|
|
29
|
+
# @param [String] The enum value in the form of the string
|
|
30
|
+
# @return [String] The enum value
|
|
31
|
+
def build_from_hash(value)
|
|
32
|
+
return value if StockInstrumentKind.all_vars.include?(value)
|
|
33
|
+
raise "Invalid ENUM value #{value} for class #StockInstrumentKind"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/snaptrade/version.rb
CHANGED
data/lib/snaptrade.rb
CHANGED
|
@@ -79,9 +79,10 @@ require 'snaptrade/models/complex_order_leg'
|
|
|
79
79
|
require 'snaptrade/models/complex_order_leg_order_role'
|
|
80
80
|
require 'snaptrade/models/complex_order_response'
|
|
81
81
|
require 'snaptrade/models/complex_order_response_type'
|
|
82
|
+
require 'snaptrade/models/connection_account'
|
|
83
|
+
require 'snaptrade/models/connection_account_sync_status'
|
|
82
84
|
require 'snaptrade/models/connection_portal_version'
|
|
83
85
|
require 'snaptrade/models/connection_type'
|
|
84
|
-
require 'snaptrade/models/connections_session_events200_response_inner'
|
|
85
86
|
require 'snaptrade/models/crypto_instrument'
|
|
86
87
|
require 'snaptrade/models/crypto_instrument_kind'
|
|
87
88
|
require 'snaptrade/models/crypto_order_form'
|
|
@@ -108,6 +109,8 @@ require 'snaptrade/models/future_instrument'
|
|
|
108
109
|
require 'snaptrade/models/future_instrument_kind'
|
|
109
110
|
require 'snaptrade/models/holdings_status'
|
|
110
111
|
require 'snaptrade/models/instrument'
|
|
112
|
+
require 'snaptrade/models/investment_account'
|
|
113
|
+
require 'snaptrade/models/investment_account_market_value'
|
|
111
114
|
require 'snaptrade/models/kind'
|
|
112
115
|
require 'snaptrade/models/login_redirect_uri'
|
|
113
116
|
require 'snaptrade/models/manual_trade'
|
|
@@ -197,6 +200,7 @@ require 'snaptrade/models/snap_trade_register_user_request_body'
|
|
|
197
200
|
require 'snaptrade/models/status'
|
|
198
201
|
require 'snaptrade/models/stock_instrument'
|
|
199
202
|
require 'snaptrade/models/stock_instrument_figi_instrument'
|
|
203
|
+
require 'snaptrade/models/stock_instrument_kind'
|
|
200
204
|
require 'snaptrade/models/stop_loss'
|
|
201
205
|
require 'snaptrade/models/strategy_order_record'
|
|
202
206
|
require 'snaptrade/models/strategy_order_record_status'
|
|
@@ -241,10 +245,8 @@ require 'snaptrade/api/api_status_api'
|
|
|
241
245
|
require 'snaptrade/api/authentication_api'
|
|
242
246
|
require 'snaptrade/api/connections_api'
|
|
243
247
|
require 'snaptrade/api/experimental_endpoints_api'
|
|
244
|
-
require 'snaptrade/api/options_api'
|
|
245
248
|
require 'snaptrade/api/reference_data_api'
|
|
246
249
|
require 'snaptrade/api/trading_api'
|
|
247
|
-
require 'snaptrade/api/transactions_and_reporting_api'
|
|
248
250
|
|
|
249
251
|
module SnapTrade
|
|
250
252
|
@config = Configuration.default
|
|
@@ -315,10 +317,8 @@ module SnapTrade
|
|
|
315
317
|
attr_reader :authentication
|
|
316
318
|
attr_reader :connections
|
|
317
319
|
attr_reader :experimental_endpoints
|
|
318
|
-
attr_reader :options
|
|
319
320
|
attr_reader :reference_data
|
|
320
321
|
attr_reader :trading
|
|
321
|
-
attr_reader :transactions_and_reporting
|
|
322
322
|
|
|
323
323
|
def initialize(config = Configuration.default)
|
|
324
324
|
@api_client = ApiClient::new(config)
|
|
@@ -327,10 +327,8 @@ module SnapTrade
|
|
|
327
327
|
@authentication = SnapTrade::AuthenticationApi.new(@api_client)
|
|
328
328
|
@connections = SnapTrade::ConnectionsApi.new(@api_client)
|
|
329
329
|
@experimental_endpoints = SnapTrade::ExperimentalEndpointsApi.new(@api_client)
|
|
330
|
-
@options = SnapTrade::OptionsApi.new(@api_client)
|
|
331
330
|
@reference_data = SnapTrade::ReferenceDataApi.new(@api_client)
|
|
332
331
|
@trading = SnapTrade::TradingApi.new(@api_client)
|
|
333
|
-
@transactions_and_reporting = SnapTrade::TransactionsAndReportingApi.new(@api_client)
|
|
334
332
|
end
|
|
335
333
|
end
|
|
336
334
|
end
|
|
@@ -74,20 +74,6 @@ describe 'AccountInformationApi' do
|
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
# unit tests for get_all_user_holdings
|
|
78
|
-
# List all accounts for the user, plus balances, positions, and orders for each account.
|
|
79
|
-
# **Deprecated.** Use the account-specific holdings endpoint instead. This endpoint will return HTTP 410 Gone for all customers that sign up after April 25, 2026. List all accounts for the user, plus balances, positions, and orders for each account.
|
|
80
|
-
# @param user_id
|
|
81
|
-
# @param user_secret
|
|
82
|
-
# @param [Hash] opts the optional parameters
|
|
83
|
-
# @option opts [String] :brokerage_authorizations Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations).
|
|
84
|
-
# @return [Array<AccountHoldings>]
|
|
85
|
-
describe 'get_all_user_holdings test' do
|
|
86
|
-
it 'should work' do
|
|
87
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
77
|
# unit tests for get_user_account_balance
|
|
92
78
|
# List account balances
|
|
93
79
|
# Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade [allows holding multiple currencies in the same account](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
|
|
@@ -147,20 +133,6 @@ describe 'AccountInformationApi' do
|
|
|
147
133
|
end
|
|
148
134
|
end
|
|
149
135
|
|
|
150
|
-
# unit tests for get_user_account_positions
|
|
151
|
-
# List account positions
|
|
152
|
-
# **Deprecated.** Use the newer [unified positions endpoint](/reference/Account%20Information/AccountInformation_getAllAccountPositions) instead. This will allow you to get both equity and option positions in a single call, as well as additional asset classes such as futures. Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the [options endpoint](/reference/Options/Options_listOptionHoldings). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
|
|
153
|
-
# @param user_id
|
|
154
|
-
# @param user_secret
|
|
155
|
-
# @param account_id
|
|
156
|
-
# @param [Hash] opts the optional parameters
|
|
157
|
-
# @return [Array<Position>]
|
|
158
|
-
describe 'get_user_account_positions test' do
|
|
159
|
-
it 'should work' do
|
|
160
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
136
|
# unit tests for get_user_account_recent_orders
|
|
165
137
|
# List account recent orders (last 24 hours only)
|
|
166
138
|
# A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders Differs from /orders in that it is always realtime, and only checks the last 24 hours By default only returns executed orders, but that can be changed by setting *only_executed* to false
|
|
@@ -110,20 +110,6 @@ describe 'ConnectionsApi' do
|
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
# unit tests for remove_brokerage_authorization
|
|
114
|
-
# Delete connection
|
|
115
|
-
# Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted.
|
|
116
|
-
# @param authorization_id
|
|
117
|
-
# @param user_id
|
|
118
|
-
# @param user_secret
|
|
119
|
-
# @param [Hash] opts the optional parameters
|
|
120
|
-
# @return [nil]
|
|
121
|
-
describe 'remove_brokerage_authorization test' do
|
|
122
|
-
it 'should work' do
|
|
123
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
113
|
# unit tests for return_rates
|
|
128
114
|
# List connection rate of returns
|
|
129
115
|
# Returns a list of rate of return percents for a given connection.
|
|
@@ -139,20 +125,6 @@ describe 'ConnectionsApi' do
|
|
|
139
125
|
end
|
|
140
126
|
end
|
|
141
127
|
|
|
142
|
-
# unit tests for session_events
|
|
143
|
-
# Get all session events for a user
|
|
144
|
-
# Returns a list of session events associated with a user.
|
|
145
|
-
# @param partner_client_id
|
|
146
|
-
# @param [Hash] opts the optional parameters
|
|
147
|
-
# @option opts [String] :user_id Optional comma separated list of user IDs used to filter the request on specific users
|
|
148
|
-
# @option opts [String] :session_id Optional comma separated list of session IDs used to filter the request on specific users
|
|
149
|
-
# @return [Array<ConnectionsSessionEvents200ResponseInner>]
|
|
150
|
-
describe 'session_events test' do
|
|
151
|
-
it 'should work' do
|
|
152
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
128
|
# unit tests for sync_brokerage_authorization_transactions
|
|
157
129
|
# Sync transactions for a connection
|
|
158
130
|
# Trigger a transactions sync for all accounts under this connection. Updates will be queued asynchronously. Transactions are not updated intra-day, but calling this endpoint can ensure that the previous day's transactions have been synced. For more information on sync behaviour, see: https://docs.snaptrade.com/docs/syncing
|
|
@@ -99,6 +99,20 @@ describe 'ExperimentalEndpointsApi' do
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
+
# unit tests for list_connection_accounts
|
|
103
|
+
# List accounts for a connection (discriminated union)
|
|
104
|
+
# Experimental and subject to change without notice. Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape. Each item in the response carries a `kind` field (currently only `investment` is implemented) that determines which additional fields are present -- see the `ConnectionAccount` schema. On Pay as you Go / Real-time, this endpoint refreshes each account's opening date, funding date, and market value live from the brokerage on each call. On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see whether your plan includes real-time data.
|
|
105
|
+
# @param authorization_id
|
|
106
|
+
# @param user_id
|
|
107
|
+
# @param user_secret
|
|
108
|
+
# @param [Hash] opts the optional parameters
|
|
109
|
+
# @return [Array<ConnectionAccount>]
|
|
110
|
+
describe 'list_connection_accounts test' do
|
|
111
|
+
it 'should work' do
|
|
112
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
102
116
|
# unit tests for list_subscriptions
|
|
103
117
|
# List active Trade Detection subscriptions
|
|
104
118
|
# Returns active Trade Detection subscriptions for your Client ID. Cancelled subscriptions are not returned.
|
|
@@ -27,18 +27,6 @@ describe 'ReferenceDataApi' do
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
# unit tests for get_currency_exchange_rate_pair
|
|
31
|
-
# Get exchange rate of a currency pair
|
|
32
|
-
# Returns an Exchange Rate Pair object for the specified Currency Pair.
|
|
33
|
-
# @param currency_pair A currency pair based on currency code for example, {CAD-USD}
|
|
34
|
-
# @param [Hash] opts the optional parameters
|
|
35
|
-
# @return [ExchangeRatePairs]
|
|
36
|
-
describe 'get_currency_exchange_rate_pair test' do
|
|
37
|
-
it 'should work' do
|
|
38
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
30
|
# unit tests for get_partner_info
|
|
43
31
|
# Get Client Info
|
|
44
32
|
# Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access.
|
|
@@ -50,17 +38,6 @@ describe 'ReferenceDataApi' do
|
|
|
50
38
|
end
|
|
51
39
|
end
|
|
52
40
|
|
|
53
|
-
# unit tests for get_security_types
|
|
54
|
-
# List security types
|
|
55
|
-
# Return all available security types supported by SnapTrade.
|
|
56
|
-
# @param [Hash] opts the optional parameters
|
|
57
|
-
# @return [Array<SecurityType>]
|
|
58
|
-
describe 'get_security_types test' do
|
|
59
|
-
it 'should work' do
|
|
60
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
41
|
# unit tests for get_stock_exchanges
|
|
65
42
|
# Get exchanges
|
|
66
43
|
# Returns a list of all supported Exchanges.
|
|
@@ -131,28 +108,6 @@ describe 'ReferenceDataApi' do
|
|
|
131
108
|
end
|
|
132
109
|
end
|
|
133
110
|
|
|
134
|
-
# unit tests for list_all_currencies
|
|
135
|
-
# Get currencies
|
|
136
|
-
# Returns a list of all defined Currency objects.
|
|
137
|
-
# @param [Hash] opts the optional parameters
|
|
138
|
-
# @return [Array<Currency>]
|
|
139
|
-
describe 'list_all_currencies test' do
|
|
140
|
-
it 'should work' do
|
|
141
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# unit tests for list_all_currencies_rates
|
|
146
|
-
# Get currency exchange rates
|
|
147
|
-
# Returns a list of all Exchange Rate Pairs for all supported Currencies.
|
|
148
|
-
# @param [Hash] opts the optional parameters
|
|
149
|
-
# @return [Array<ExchangeRatePairs>]
|
|
150
|
-
describe 'list_all_currencies_rates test' do
|
|
151
|
-
it 'should work' do
|
|
152
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
111
|
# unit tests for symbol_search_user_account
|
|
157
112
|
# Search account symbols
|
|
158
113
|
# Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned. The search results are further limited to the symbols supported by the brokerage for which the account is under.
|
|
@@ -42,21 +42,6 @@ describe 'TradingApi' do
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
# unit tests for cancel_user_account_order
|
|
46
|
-
# Cancel equity order
|
|
47
|
-
# **Deprecated.** Use [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) instead. Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected.
|
|
48
|
-
# @param user_id
|
|
49
|
-
# @param user_secret
|
|
50
|
-
# @param account_id
|
|
51
|
-
# @param account_information_get_user_account_order_detail_request
|
|
52
|
-
# @param [Hash] opts the optional parameters
|
|
53
|
-
# @return [AccountOrderRecord]
|
|
54
|
-
describe 'cancel_user_account_order test' do
|
|
55
|
-
it 'should work' do
|
|
56
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
45
|
# unit tests for get_cryptocurrency_pair_quote
|
|
61
46
|
# Get crypto pair quote
|
|
62
47
|
# Gets a quote for the specified account.
|
|
@@ -132,21 +117,6 @@ describe 'TradingApi' do
|
|
|
132
117
|
end
|
|
133
118
|
end
|
|
134
119
|
|
|
135
|
-
# unit tests for place_bracket_order
|
|
136
|
-
# Place bracket order
|
|
137
|
-
# **Deprecated.** Use [the new complex order endpoint](/reference/Trading/Trading_placeComplexOrder) instead. Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages
|
|
138
|
-
# @param account_id The ID of the account to execute the trade on.
|
|
139
|
-
# @param user_id
|
|
140
|
-
# @param user_secret
|
|
141
|
-
# @param manual_trade_form_bracket
|
|
142
|
-
# @param [Hash] opts the optional parameters
|
|
143
|
-
# @return [AccountOrderRecord]
|
|
144
|
-
describe 'place_bracket_order test' do
|
|
145
|
-
it 'should work' do
|
|
146
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
120
|
# unit tests for place_complex_order
|
|
151
121
|
# Place complex order
|
|
152
122
|
# Places a complex conditional order (OCO, OTO, or OTOCO). Only supported on certain brokerages. Please refer to the [brokerage trading support page](https://support.snaptrade.com/brokerages) for details on which brokerages support complex orders and which types they support. - **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.
|
|
@@ -63,9 +63,9 @@ describe 'GettingStarted' do
|
|
|
63
63
|
redirect_uri = SnapTrade::Authentication.login_snap_trade_user(user_id: user_id, user_secret: response.user_secret)
|
|
64
64
|
puts redirect_uri
|
|
65
65
|
|
|
66
|
-
# 5)
|
|
67
|
-
|
|
68
|
-
puts
|
|
66
|
+
# 5) List the user's accounts
|
|
67
|
+
accounts = SnapTrade::AccountInformation.list_user_accounts(user_id: user_id, user_secret: response.user_secret)
|
|
68
|
+
puts accounts
|
|
69
69
|
|
|
70
70
|
# 6) Deleting a user
|
|
71
71
|
deleted_response = SnapTrade::Authentication.delete_snap_trade_user(user_id: user_id)
|
|
@@ -95,9 +95,9 @@ describe 'GettingStarted' do
|
|
|
95
95
|
redirect_uri = snaptrade.authentication.login_snap_trade_user(user_id: user_id, user_secret: response.user_secret)
|
|
96
96
|
puts redirect_uri
|
|
97
97
|
|
|
98
|
-
# 5)
|
|
99
|
-
|
|
100
|
-
puts
|
|
98
|
+
# 5) List the user's accounts
|
|
99
|
+
accounts = snaptrade.account_information.list_user_accounts(user_id: user_id, user_secret: response.user_secret)
|
|
100
|
+
puts accounts
|
|
101
101
|
|
|
102
102
|
# 6) Deleting a user
|
|
103
103
|
deleted_response = snaptrade.authentication.delete_snap_trade_user(user_id: user_id)
|
|
@@ -0,0 +1,38 @@
|
|
|
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::ConnectionAccount
|
|
15
|
+
describe SnapTrade::ConnectionAccount do
|
|
16
|
+
describe '.openapi_one_of' do
|
|
17
|
+
it 'lists the items referenced in the oneOf array' do
|
|
18
|
+
expect(described_class.openapi_one_of).to_not be_empty
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '.openapi_discriminator_name' do
|
|
23
|
+
it 'returns the value of the "discriminator" property' do
|
|
24
|
+
expect(described_class.openapi_discriminator_name).to_not be_empty
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '.openapi_discriminator_mapping' do
|
|
29
|
+
it 'returns the key/values of the "mapping" property' do
|
|
30
|
+
expect(described_class.openapi_discriminator_mapping.values.sort).to eq(described_class.openapi_one_of.sort)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '.build' do
|
|
35
|
+
it 'returns the correct model' do
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|