snaptrade 2.0.116 → 2.0.118
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 +2 -2
- data/README.md +37 -4
- data/lib/snaptrade/api/reference_data_api.rb +85 -0
- data/lib/snaptrade/api/trading_api.rb +36 -23
- data/lib/snaptrade/models/brokerage_instrument.rb +261 -0
- data/lib/snaptrade/models/brokerage_instruments_response.rb +218 -0
- data/lib/snaptrade/models/cancel_order_response.rb +235 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +3 -0
- data/spec/api/reference_data_api_spec.rb +12 -0
- data/spec/api/trading_api_spec.rb +3 -3
- data/spec/models/brokerage_instrument_spec.rb +53 -0
- data/spec/models/brokerage_instruments_response_spec.rb +29 -0
- data/spec/models/cancel_order_response_spec.rb +35 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eaa8a192b22fd8c36cafd97fdd0d530e53bc4c31808c01b6c8a5e521071fcba
|
4
|
+
data.tar.gz: 4ca620e1bed260b1b60e550156952bb1178c8db2c8d6496b871873c61e0e62e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a6ace54ffd9ed8996699d93fb408ad083b0269bf879a9ddb961b76b6da8191f7d8873b3f98f85fb4b14a28948d4b99468e65f709200b3ef17464c82ac08ac67
|
7
|
+
data.tar.gz: f747e4e76c31eb3bdbe9548a404ec3a28818a09cabd00d558274d605c87e02e42764f63f3243d0bf581e92f9c293ae0806696eb138b6eb6f088dc245889ed732
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
snaptrade (2.0.
|
4
|
+
snaptrade (2.0.118)
|
5
5
|
faraday (>= 1.0.1, < 3.0)
|
6
6
|
faraday-multipart (~> 1.0, >= 1.0.4)
|
7
7
|
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
method_source (1.1.0)
|
30
30
|
multipart-post (2.4.1)
|
31
31
|
parallel (1.27.0)
|
32
|
-
parser (3.3.
|
32
|
+
parser (3.3.9.0)
|
33
33
|
ast (~> 2.4.1)
|
34
34
|
racc
|
35
35
|
prism (1.4.0)
|
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.118)
|
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.118'
|
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, optionally filtered by a search. 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.
|
@@ -1603,13 +1633,16 @@ p result
|
|
1603
1633
|
##### user_secret: `String`<a id="user_secret-string"></a>
|
1604
1634
|
##### account_id: `String`<a id="account_id-string"></a>
|
1605
1635
|
##### brokerage_order_id: `String`<a id="brokerage_order_id-string"></a>
|
1636
|
+
Order ID returned by brokerage. This is the unique identifier for the order in
|
1637
|
+
the brokerage system.
|
1638
|
+
|
1606
1639
|
#### 🔄 Return<a id="🔄-return"></a>
|
1607
1640
|
|
1608
|
-
[
|
1641
|
+
[CancelOrderResponse](./lib/snaptrade/models/cancel_order_response.rb)
|
1609
1642
|
|
1610
1643
|
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
1611
1644
|
|
1612
|
-
`/accounts/{accountId}/trading/
|
1645
|
+
`/accounts/{accountId}/trading/cancel` `POST`
|
1613
1646
|
|
1614
1647
|
[🔙 **Back to Table of Contents**](#table-of-contents)
|
1615
1648
|
|
@@ -596,6 +596,91 @@ module SnapTrade
|
|
596
596
|
end
|
597
597
|
|
598
598
|
|
599
|
+
# Get a list of instruments available on the brokerage.
|
600
|
+
#
|
601
|
+
# Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. 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 a list of instruments available on the brokerage.
|
611
|
+
#
|
612
|
+
# Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. 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 a list of instruments available on the brokerage.
|
621
|
+
# Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. 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 a list of instruments available on the brokerage.
|
631
|
+
# Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. 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.
|
@@ -17,55 +17,63 @@ module SnapTrade
|
|
17
17
|
@api_client = api_client
|
18
18
|
end
|
19
19
|
|
20
|
-
# Cancel
|
20
|
+
# Cancel order
|
21
21
|
#
|
22
22
|
# Cancels an order in the specified account.
|
23
23
|
#
|
24
24
|
# @param user_id [String]
|
25
25
|
# @param user_secret [String]
|
26
26
|
# @param account_id [String]
|
27
|
-
# @param brokerage_order_id [String]
|
27
|
+
# @param brokerage_order_id [String] Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
|
28
|
+
# @param body [TradingCancelUserAccountOrderRequest]
|
28
29
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
29
|
-
def cancel_order(user_id:, user_secret:, account_id:, brokerage_order_id
|
30
|
-
|
30
|
+
def cancel_order(user_id:, user_secret:, account_id:, brokerage_order_id: SENTINEL, extra: {})
|
31
|
+
_body = {}
|
32
|
+
_body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL
|
33
|
+
trading_cancel_user_account_order_request = _body
|
34
|
+
data, _status_code, _headers = cancel_order_with_http_info_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, extra)
|
31
35
|
data
|
32
36
|
end
|
33
37
|
|
34
|
-
# Cancel
|
38
|
+
# Cancel order
|
35
39
|
#
|
36
40
|
# Cancels an order in the specified account.
|
37
41
|
#
|
38
42
|
# @param user_id [String]
|
39
43
|
# @param user_secret [String]
|
40
44
|
# @param account_id [String]
|
41
|
-
# @param brokerage_order_id [String]
|
45
|
+
# @param brokerage_order_id [String] Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
|
46
|
+
# @param body [TradingCancelUserAccountOrderRequest]
|
42
47
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
43
|
-
def cancel_order_with_http_info(user_id:, user_secret:, account_id:, brokerage_order_id
|
44
|
-
|
48
|
+
def cancel_order_with_http_info(user_id:, user_secret:, account_id:, brokerage_order_id: SENTINEL, extra: {})
|
49
|
+
_body = {}
|
50
|
+
_body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL
|
51
|
+
trading_cancel_user_account_order_request = _body
|
52
|
+
cancel_order_with_http_info_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, extra)
|
45
53
|
end
|
46
54
|
|
47
|
-
# Cancel
|
55
|
+
# Cancel order
|
48
56
|
# Cancels an order in the specified account.
|
49
57
|
# @param user_id [String]
|
50
58
|
# @param user_secret [String]
|
51
59
|
# @param account_id [String]
|
52
|
-
# @param
|
60
|
+
# @param trading_cancel_user_account_order_request [TradingCancelUserAccountOrderRequest]
|
53
61
|
# @param [Hash] opts the optional parameters
|
54
|
-
# @return [
|
55
|
-
private def cancel_order_impl(user_id, user_secret, account_id,
|
56
|
-
data, _status_code, _headers = cancel_order_with_http_info(user_id, user_secret, account_id,
|
62
|
+
# @return [CancelOrderResponse]
|
63
|
+
private def cancel_order_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, opts = {})
|
64
|
+
data, _status_code, _headers = cancel_order_with_http_info(user_id, user_secret, account_id, trading_cancel_user_account_order_request, opts)
|
57
65
|
data
|
58
66
|
end
|
59
67
|
|
60
|
-
# Cancel
|
68
|
+
# Cancel order
|
61
69
|
# Cancels an order in the specified account.
|
62
70
|
# @param user_id [String]
|
63
71
|
# @param user_secret [String]
|
64
72
|
# @param account_id [String]
|
65
|
-
# @param
|
73
|
+
# @param trading_cancel_user_account_order_request [TradingCancelUserAccountOrderRequest]
|
66
74
|
# @param [Hash] opts the optional parameters
|
67
|
-
# @return [Array<(
|
68
|
-
private def cancel_order_with_http_info_impl(user_id, user_secret, account_id,
|
75
|
+
# @return [Array<(CancelOrderResponse, Integer, Hash)>] CancelOrderResponse data, response status code and response headers
|
76
|
+
private def cancel_order_with_http_info_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, opts = {})
|
69
77
|
if @api_client.config.debugging
|
70
78
|
@api_client.config.logger.debug 'Calling API: TradingApi.cancel_order ...'
|
71
79
|
end
|
@@ -81,12 +89,12 @@ module SnapTrade
|
|
81
89
|
if @api_client.config.client_side_validation && account_id.nil?
|
82
90
|
fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.cancel_order"
|
83
91
|
end
|
84
|
-
# verify the required parameter '
|
85
|
-
if @api_client.config.client_side_validation &&
|
86
|
-
fail ArgumentError, "Missing the required parameter '
|
92
|
+
# verify the required parameter 'trading_cancel_user_account_order_request' is set
|
93
|
+
if @api_client.config.client_side_validation && trading_cancel_user_account_order_request.nil?
|
94
|
+
fail ArgumentError, "Missing the required parameter 'trading_cancel_user_account_order_request' when calling TradingApi.cancel_order"
|
87
95
|
end
|
88
96
|
# resource path
|
89
|
-
local_var_path = '/accounts/{accountId}/trading/
|
97
|
+
local_var_path = '/accounts/{accountId}/trading/cancel'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
|
90
98
|
|
91
99
|
# query parameters
|
92
100
|
query_params = opts[:query_params] || {}
|
@@ -97,15 +105,20 @@ module SnapTrade
|
|
97
105
|
header_params = opts[:header_params] || {}
|
98
106
|
# HTTP header 'Accept' (if needed)
|
99
107
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
108
|
+
# HTTP header 'Content-Type'
|
109
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
110
|
+
if !content_type.nil?
|
111
|
+
header_params['Content-Type'] = content_type
|
112
|
+
end
|
100
113
|
|
101
114
|
# form parameters
|
102
115
|
form_params = opts[:form_params] || {}
|
103
116
|
|
104
117
|
# http body (model)
|
105
|
-
post_body = opts[:debug_body]
|
118
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(trading_cancel_user_account_order_request)
|
106
119
|
|
107
120
|
# return_type
|
108
|
-
return_type = opts[:debug_return_type] || '
|
121
|
+
return_type = opts[:debug_return_type] || 'CancelOrderResponse'
|
109
122
|
|
110
123
|
# auth_names
|
111
124
|
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
@@ -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
|
@@ -0,0 +1,235 @@
|
|
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 CancelOrderResponse
|
15
|
+
# Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
|
16
|
+
attr_accessor :brokerage_order_id
|
17
|
+
|
18
|
+
# The raw response from the brokerage.
|
19
|
+
attr_accessor :raw_response
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'brokerage_order_id' => :'brokerage_order_id',
|
25
|
+
:'raw_response' => :'raw_response'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns all the JSON keys this model knows about
|
30
|
+
def self.acceptable_attributes
|
31
|
+
attribute_map.values
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.openapi_types
|
36
|
+
{
|
37
|
+
:'brokerage_order_id' => :'String',
|
38
|
+
:'raw_response' => :'Hash<String, Object>'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# List of attributes with nullable: true
|
43
|
+
def self.openapi_nullable
|
44
|
+
Set.new([
|
45
|
+
:'raw_response'
|
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::CancelOrderResponse` 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::CancelOrderResponse`. 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?(:'brokerage_order_id')
|
65
|
+
self.brokerage_order_id = attributes[:'brokerage_order_id']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'raw_response')
|
69
|
+
if (value = attributes[:'raw_response']).is_a?(Hash)
|
70
|
+
self.raw_response = value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
76
|
+
# @return Array for valid properties with the reasons
|
77
|
+
def list_invalid_properties
|
78
|
+
invalid_properties = Array.new
|
79
|
+
if @brokerage_order_id.nil?
|
80
|
+
invalid_properties.push('invalid value for "brokerage_order_id", brokerage_order_id cannot be nil.')
|
81
|
+
end
|
82
|
+
|
83
|
+
invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
return false if @brokerage_order_id.nil?
|
90
|
+
true
|
91
|
+
end
|
92
|
+
|
93
|
+
# Checks equality by comparing each attribute.
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def ==(o)
|
96
|
+
return true if self.equal?(o)
|
97
|
+
self.class == o.class &&
|
98
|
+
brokerage_order_id == o.brokerage_order_id &&
|
99
|
+
raw_response == o.raw_response
|
100
|
+
end
|
101
|
+
|
102
|
+
# @see the `==` method
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def eql?(o)
|
105
|
+
self == o
|
106
|
+
end
|
107
|
+
|
108
|
+
# Calculates hash code according to all attributes.
|
109
|
+
# @return [Integer] Hash code
|
110
|
+
def hash
|
111
|
+
[brokerage_order_id, raw_response].hash
|
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 self.build_from_hash(attributes)
|
118
|
+
new.build_from_hash(attributes)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Builds the object from hash
|
122
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
123
|
+
# @return [Object] Returns the model itself
|
124
|
+
def build_from_hash(attributes)
|
125
|
+
return nil unless attributes.is_a?(Hash)
|
126
|
+
attributes = attributes.transform_keys(&:to_sym)
|
127
|
+
self.class.openapi_types.each_pair do |key, type|
|
128
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
129
|
+
self.send("#{key}=", nil)
|
130
|
+
elsif type =~ /\AArray<(.*)>/i
|
131
|
+
# check to ensure the input is an array given that the attribute
|
132
|
+
# is documented as an array but the input is not
|
133
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
134
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
135
|
+
end
|
136
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
137
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
# Deserializes the data based on type
|
145
|
+
# @param string type Data type
|
146
|
+
# @param string value Value to be deserialized
|
147
|
+
# @return [Object] Deserialized data
|
148
|
+
def _deserialize(type, value)
|
149
|
+
case type.to_sym
|
150
|
+
when :Time
|
151
|
+
Time.parse(value)
|
152
|
+
when :Date
|
153
|
+
Date.parse(value)
|
154
|
+
when :String
|
155
|
+
value.to_s
|
156
|
+
when :Integer
|
157
|
+
value.to_i
|
158
|
+
when :Float
|
159
|
+
value.to_f
|
160
|
+
when :Boolean
|
161
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
162
|
+
true
|
163
|
+
else
|
164
|
+
false
|
165
|
+
end
|
166
|
+
when :Object
|
167
|
+
# generic object (usually a Hash), return directly
|
168
|
+
value
|
169
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
170
|
+
inner_type = Regexp.last_match[:inner_type]
|
171
|
+
value.map { |v| _deserialize(inner_type, v) }
|
172
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
173
|
+
k_type = Regexp.last_match[:k_type]
|
174
|
+
v_type = Regexp.last_match[:v_type]
|
175
|
+
{}.tap do |hash|
|
176
|
+
value.each do |k, v|
|
177
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
else # model
|
181
|
+
# models (e.g. Pet) or oneOf
|
182
|
+
klass = SnapTrade.const_get(type)
|
183
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the string representation of the object
|
188
|
+
# @return [String] String presentation of the object
|
189
|
+
def to_s
|
190
|
+
to_hash.to_s
|
191
|
+
end
|
192
|
+
|
193
|
+
# to_body is an alias to to_hash (backward compatibility)
|
194
|
+
# @return [Hash] Returns the object in the form of hash
|
195
|
+
def to_body
|
196
|
+
to_hash
|
197
|
+
end
|
198
|
+
|
199
|
+
# Returns the object in the form of hash
|
200
|
+
# @return [Hash] Returns the object in the form of hash
|
201
|
+
def to_hash
|
202
|
+
hash = {}
|
203
|
+
self.class.attribute_map.each_pair do |attr, param|
|
204
|
+
value = self.send(attr)
|
205
|
+
if value.nil?
|
206
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
207
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
208
|
+
end
|
209
|
+
|
210
|
+
hash[param] = _to_hash(value)
|
211
|
+
end
|
212
|
+
hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Outputs non-array value in the form of hash
|
216
|
+
# For object, use to_hash. Otherwise, just return the value
|
217
|
+
# @param [Object] value Any valid value
|
218
|
+
# @return [Hash] Returns the value in the form of hash
|
219
|
+
def _to_hash(value)
|
220
|
+
if value.is_a?(Array)
|
221
|
+
value.compact.map { |v| _to_hash(v) }
|
222
|
+
elsif value.is_a?(Hash)
|
223
|
+
{}.tap do |hash|
|
224
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
225
|
+
end
|
226
|
+
elsif value.respond_to? :to_hash
|
227
|
+
value.to_hash
|
228
|
+
else
|
229
|
+
value
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
data/lib/snaptrade/version.rb
CHANGED
data/lib/snaptrade.rb
CHANGED
@@ -47,7 +47,10 @@ 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'
|
53
|
+
require 'snaptrade/models/cancel_order_response'
|
51
54
|
require 'snaptrade/models/child_brokerage_order_ids'
|
52
55
|
require 'snaptrade/models/connection_portal_version'
|
53
56
|
require 'snaptrade/models/connection_type'
|
@@ -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 a list of instruments available on the brokerage.
|
113
|
+
# Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. 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.
|
@@ -28,14 +28,14 @@ describe 'TradingApi' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# unit tests for cancel_order
|
31
|
-
# Cancel
|
31
|
+
# Cancel order
|
32
32
|
# Cancels an order in the specified account.
|
33
33
|
# @param user_id
|
34
34
|
# @param user_secret
|
35
35
|
# @param account_id
|
36
|
-
# @param
|
36
|
+
# @param trading_cancel_user_account_order_request
|
37
37
|
# @param [Hash] opts the optional parameters
|
38
|
-
# @return [
|
38
|
+
# @return [CancelOrderResponse]
|
39
39
|
describe 'cancel_order test' do
|
40
40
|
it 'should work' do
|
41
41
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
@@ -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
|
@@ -0,0 +1,35 @@
|
|
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::CancelOrderResponse
|
15
|
+
describe SnapTrade::CancelOrderResponse do
|
16
|
+
let(:instance) { SnapTrade::CancelOrderResponse.new }
|
17
|
+
|
18
|
+
describe 'test an instance of CancelOrderResponse' do
|
19
|
+
it 'should create an instance of CancelOrderResponse' do
|
20
|
+
expect(instance).to be_instance_of(SnapTrade::CancelOrderResponse)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
describe 'test attribute "brokerage_order_id"' 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 "raw_response"' 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
|
+
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.118
|
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,7 +126,10 @@ 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
|
132
|
+
- lib/snaptrade/models/cancel_order_response.rb
|
130
133
|
- lib/snaptrade/models/child_brokerage_order_ids.rb
|
131
134
|
- lib/snaptrade/models/connection_portal_version.rb
|
132
135
|
- lib/snaptrade/models/connection_type.rb
|
@@ -286,8 +289,11 @@ files:
|
|
286
289
|
- spec/models/brokerage_authorization_spec.rb
|
287
290
|
- spec/models/brokerage_authorization_type_read_only_brokerage_spec.rb
|
288
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
|
289
294
|
- spec/models/brokerage_spec.rb
|
290
295
|
- spec/models/brokerage_type_spec.rb
|
296
|
+
- spec/models/cancel_order_response_spec.rb
|
291
297
|
- spec/models/child_brokerage_order_ids_spec.rb
|
292
298
|
- spec/models/connection_portal_version_spec.rb
|
293
299
|
- spec/models/connection_type_spec.rb
|
@@ -442,6 +448,7 @@ test_files:
|
|
442
448
|
- spec/api_client_spec.rb
|
443
449
|
- spec/configuration_spec.rb
|
444
450
|
- spec/getting_started_spec.rb
|
451
|
+
- spec/models/brokerage_instruments_response_spec.rb
|
445
452
|
- spec/models/underlying_symbol_type_spec.rb
|
446
453
|
- spec/models/action_strict_spec.rb
|
447
454
|
- spec/models/order_updated_response_spec.rb
|
@@ -449,6 +456,7 @@ test_files:
|
|
449
456
|
- spec/models/trading_search_cryptocurrency_pair_instruments200_response_spec.rb
|
450
457
|
- spec/models/account_order_record_quote_universal_symbol_spec.rb
|
451
458
|
- spec/models/session_event_spec.rb
|
459
|
+
- spec/models/cancel_order_response_spec.rb
|
452
460
|
- spec/models/manual_trade_impact_spec.rb
|
453
461
|
- spec/models/manual_trade_form_notional_value_spec.rb
|
454
462
|
- spec/models/symbol_query_spec.rb
|
@@ -491,6 +499,7 @@ test_files:
|
|
491
499
|
- spec/models/universal_symbol_spec.rb
|
492
500
|
- spec/models/model404_failed_request_response_spec.rb
|
493
501
|
- spec/models/model425_failed_request_response_spec.rb
|
502
|
+
- spec/models/brokerage_instrument_spec.rb
|
494
503
|
- spec/models/validated_trade_body_spec.rb
|
495
504
|
- spec/models/option_brokerage_symbol_spec.rb
|
496
505
|
- spec/models/option_chain_inner_chain_per_root_inner_chain_per_strike_price_inner_spec.rb
|