snaptrade 2.0.69 → 2.0.71
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +94 -8
- data/lib/snaptrade/api/account_information_api.rb +132 -0
- data/lib/snaptrade/api/trading_api.rb +14 -2
- data/lib/snaptrade/api/transactions_and_reporting_api.rb +4 -4
- data/lib/snaptrade/models/manual_trade_form_with_options.rb +36 -5
- data/lib/snaptrade/models/manual_trade_form_with_options_stop_loss.rb +233 -0
- data/lib/snaptrade/models/manual_trade_form_with_options_take_profit.rb +223 -0
- data/lib/snaptrade/models/order_class.rb +37 -0
- data/lib/snaptrade/models/stop_loss.rb +227 -0
- data/lib/snaptrade/models/take_profit.rb +217 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +5 -0
- data/spec/api/account_information_api_spec.rb +17 -0
- data/spec/api/transactions_and_reporting_api_spec.rb +1 -1
- data/spec/models/manual_trade_form_with_options_spec.rb +18 -0
- data/spec/models/manual_trade_form_with_options_stop_loss_spec.rb +35 -0
- data/spec/models/manual_trade_form_with_options_take_profit_spec.rb +29 -0
- data/spec/models/order_class_spec.rb +23 -0
- data/spec/models/stop_loss_spec.rb +35 -0
- data/spec/models/take_profit_spec.rb +29 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331918e282cbf30fde05e5a9c0712d94a220e0a0a4b6a2d1a2822c9123cd520b
|
4
|
+
data.tar.gz: 499926478a36d2e78583de8f30f01a51c587571aa7c38d4403c5876b55e94448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776323da13f42eb87522aeeceaac7ba3071f0a4c018f889c1cc004d02f3db9276c02dd3708c368fa856c05b4759055beb9af8429f86987c248ffe1e0d5081bf3
|
7
|
+
data.tar.gz: b380fd51c3000756d98d1fff33a5dd65df480fe1f0935b240ce79c60eff04cc25673abb41f0670977a072d4090927a71034c22d6dcabbf13541bc3ae5ef2b046
|
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.71)
|
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.26.3)
|
32
|
-
parser (3.3.
|
32
|
+
parser (3.3.7.0)
|
33
33
|
ast (~> 2.4.1)
|
34
34
|
racc
|
35
35
|
pry (0.14.2)
|
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.71)
|
10
10
|
[](https://snaptrade.com/)
|
11
11
|
|
12
12
|
</div>
|
@@ -19,6 +19,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
19
19
|
- [Getting Started](#getting-started)
|
20
20
|
- [Raw HTTP Response](#raw-http-response)
|
21
21
|
- [Reference](#reference)
|
22
|
+
* [`snaptrade.account_information.get_account_activities`](#snaptradeaccount_informationget_account_activities)
|
22
23
|
* [`snaptrade.account_information.get_all_user_holdings`](#snaptradeaccount_informationget_all_user_holdings)
|
23
24
|
* [`snaptrade.account_information.get_user_account_balance`](#snaptradeaccount_informationget_user_account_balance)
|
24
25
|
* [`snaptrade.account_information.get_user_account_details`](#snaptradeaccount_informationget_user_account_details)
|
@@ -73,7 +74,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
73
74
|
Add to Gemfile:
|
74
75
|
|
75
76
|
```ruby
|
76
|
-
gem 'snaptrade', '~> 2.0.
|
77
|
+
gem 'snaptrade', '~> 2.0.71'
|
77
78
|
```
|
78
79
|
|
79
80
|
## Getting Started<a id="getting-started"></a>
|
@@ -85,10 +86,13 @@ configuration = SnapTrade::Configuration.new
|
|
85
86
|
configuration.client_id = ENV["SNAPTRADE_CLIENT_ID"]
|
86
87
|
configuration.consumer_key = ENV["SNAPTRADE_CONSUMER_KEY"]
|
87
88
|
snaptrade = SnapTrade::Client.new(configuration)
|
88
|
-
result = snaptrade.account_information.
|
89
|
+
result = snaptrade.account_information.get_account_activities(
|
90
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
89
91
|
user_id: "snaptrade-user-123",
|
90
92
|
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
91
|
-
|
93
|
+
start_date: "2022-01-24",
|
94
|
+
end_date: "2022-01-24",
|
95
|
+
type: "BUY,SELL,DIVIDEND",
|
92
96
|
)
|
93
97
|
p result
|
94
98
|
```
|
@@ -98,12 +102,15 @@ p result
|
|
98
102
|
To access the raw HTTP response, suffix any method with `_with_http_info`.
|
99
103
|
|
100
104
|
```ruby
|
101
|
-
result = snaptrade.account_information.
|
105
|
+
result = snaptrade.account_information.get_account_activities_with_http_info(
|
106
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
102
107
|
user_id: "snaptrade-user-123",
|
103
108
|
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
104
|
-
|
109
|
+
start_date: "2022-01-24",
|
110
|
+
end_date: "2022-01-24",
|
111
|
+
type: "BUY,SELL,DIVIDEND",
|
105
112
|
)
|
106
|
-
p result[0] # [Array<
|
113
|
+
p result[0] # [Array<UniversalActivity>] Deserialized data
|
107
114
|
p.result[1] # [Integer] HTTP status code
|
108
115
|
p.result[2] # [Hash] HTTP headers
|
109
116
|
p.result[3] # [Faraday::Response] Raw HTTP response
|
@@ -112,6 +119,68 @@ p.result[3] # [Faraday::Response] Raw HTTP response
|
|
112
119
|
## Reference<a id="reference"></a>
|
113
120
|
|
114
121
|
|
122
|
+
### `snaptrade.account_information.get_account_activities`<a id="snaptradeaccount_informationget_account_activities"></a>
|
123
|
+
|
124
|
+
Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request.
|
125
|
+
|
126
|
+
There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order.
|
127
|
+
|
128
|
+
The data returned here is always cached and refreshed once a day.
|
129
|
+
|
130
|
+
|
131
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
result = snaptrade.account_information.get_account_activities(
|
135
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
136
|
+
user_id: "snaptrade-user-123",
|
137
|
+
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
138
|
+
start_date: "2022-01-24",
|
139
|
+
end_date: "2022-01-24",
|
140
|
+
type: "BUY,SELL,DIVIDEND",
|
141
|
+
)
|
142
|
+
p result
|
143
|
+
```
|
144
|
+
|
145
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
146
|
+
|
147
|
+
##### account_id: `String`<a id="account_id-string"></a>
|
148
|
+
##### user_id: `String`<a id="user_id-string"></a>
|
149
|
+
##### user_secret: `String`<a id="user_secret-string"></a>
|
150
|
+
##### start_date: `Date`<a id="start_date-date"></a>
|
151
|
+
The start date (inclusive) of the transaction history to retrieve. If not
|
152
|
+
provided, the default is the first transaction known to SnapTrade based on
|
153
|
+
`trade_date`.
|
154
|
+
|
155
|
+
##### end_date: `Date`<a id="end_date-date"></a>
|
156
|
+
The end date (inclusive) of the transaction history to retrieve. If not
|
157
|
+
provided, the default is the last transaction known to SnapTrade based on
|
158
|
+
`trade_date`.
|
159
|
+
|
160
|
+
##### type: `String`<a id="type-string"></a>
|
161
|
+
Optional comma separated list of transaction types to filter by. SnapTrade does
|
162
|
+
a best effort to categorize brokerage transaction types into a common set of
|
163
|
+
values. Here are some of the most popular values: - `BUY` - Asset bought. -
|
164
|
+
`SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash
|
165
|
+
contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment.
|
166
|
+
- `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from
|
167
|
+
the account. - `OPTIONEXPIRATION` - Option expiration event. -
|
168
|
+
`OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option
|
169
|
+
exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
170
|
+
|
171
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
172
|
+
|
173
|
+
[UniversalActivity](./lib/snaptrade/models/universal_activity.rb)
|
174
|
+
|
175
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
176
|
+
|
177
|
+
`/accounts/{accountId}/activities` `GET`
|
178
|
+
|
179
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
180
|
+
|
181
|
+
---
|
182
|
+
|
183
|
+
|
115
184
|
### `snaptrade.account_information.get_all_user_holdings`<a id="snaptradeaccount_informationget_all_user_holdings"></a>
|
116
185
|

|
117
186
|
|
@@ -1663,6 +1732,14 @@ result = snaptrade.trading.place_force_order(
|
|
1663
1732
|
stop: 31.33,
|
1664
1733
|
units: 10.5,
|
1665
1734
|
notional_value: None,
|
1735
|
+
order_class: "BRACKET",
|
1736
|
+
stop_loss: {
|
1737
|
+
"stop_price" => "48.55",
|
1738
|
+
"limit_price" => "48.50",
|
1739
|
+
},
|
1740
|
+
take_profit: {
|
1741
|
+
"limit_price" => "49.95",
|
1742
|
+
},
|
1666
1743
|
)
|
1667
1744
|
p result
|
1668
1745
|
```
|
@@ -1718,6 +1795,15 @@ provided. If placing an Option order, this field represents the number of
|
|
1718
1795
|
contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
1719
1796
|
|
1720
1797
|
##### notional_value: [`ManualTradeFormNotionalValue`](./lib/snaptrade/models/manual_trade_form_notional_value.rb)<a id="notional_value-manualtradeformnotionalvaluelibsnaptrademodelsmanual_trade_form_notional_valuerb"></a>
|
1798
|
+
##### order_class: [`OrderClass`](./lib/snaptrade/models/order_class.rb)<a id="order_class-orderclasslibsnaptrademodelsorder_classrb"></a>
|
1799
|
+
The class of order intended to be placed. Defaults to SIMPLE for regular, one
|
1800
|
+
legged trades. Set to BRACKET if looking to place a bracket
|
1801
|
+
(One-triggers-a-one-cancels-the-other) order, then specify take profit and stop
|
1802
|
+
loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and
|
1803
|
+
Tradestation, contact us for more details
|
1804
|
+
|
1805
|
+
##### stop_loss: [`ManualTradeFormWithOptionsStopLoss`](./lib/snaptrade/models/manual_trade_form_with_options_stop_loss.rb)<a id="stop_loss-manualtradeformwithoptionsstoplosslibsnaptrademodelsmanual_trade_form_with_options_stop_lossrb"></a>
|
1806
|
+
##### take_profit: [`ManualTradeFormWithOptionsTakeProfit`](./lib/snaptrade/models/manual_trade_form_with_options_take_profit.rb)<a id="take_profit-manualtradeformwithoptionstakeprofitlibsnaptrademodelsmanual_trade_form_with_options_take_profitrb"></a>
|
1721
1807
|
#### 🔄 Return<a id="🔄-return"></a>
|
1722
1808
|
|
1723
1809
|
[AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb)
|
@@ -1783,7 +1869,7 @@ Returns all historical transactions for the specified user and filtering criteri
|
|
1783
1869
|
|
1784
1870
|
There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order.
|
1785
1871
|
|
1786
|
-
The data returned here is always cached and refreshed once a day.
|
1872
|
+
The data returned here is always cached and refreshed once a day.
|
1787
1873
|
|
1788
1874
|
|
1789
1875
|
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
@@ -17,6 +17,138 @@ module SnapTrade
|
|
17
17
|
@api_client = api_client
|
18
18
|
end
|
19
19
|
|
20
|
+
# List account activities
|
21
|
+
#
|
22
|
+
# Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request.
|
23
|
+
#
|
24
|
+
# There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order.
|
25
|
+
#
|
26
|
+
# The data returned here is always cached and refreshed once a day.
|
27
|
+
#
|
28
|
+
# @param account_id [String]
|
29
|
+
# @param user_id [String]
|
30
|
+
# @param user_secret [String]
|
31
|
+
# @param start_date [Date] The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`.
|
32
|
+
# @param end_date [Date] The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`.
|
33
|
+
# @param type [String] Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
34
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
35
|
+
def get_account_activities(account_id:, user_id:, user_secret:, start_date: SENTINEL, end_date: SENTINEL, type: SENTINEL, extra: {})
|
36
|
+
extra[:start_date] = start_date if start_date != SENTINEL
|
37
|
+
extra[:end_date] = end_date if end_date != SENTINEL
|
38
|
+
extra[:type] = type if type != SENTINEL
|
39
|
+
data, _status_code, _headers = get_account_activities_with_http_info_impl(account_id, user_id, user_secret, extra)
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
43
|
+
# List account activities
|
44
|
+
#
|
45
|
+
# Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request.
|
46
|
+
#
|
47
|
+
# There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order.
|
48
|
+
#
|
49
|
+
# The data returned here is always cached and refreshed once a day.
|
50
|
+
#
|
51
|
+
# @param account_id [String]
|
52
|
+
# @param user_id [String]
|
53
|
+
# @param user_secret [String]
|
54
|
+
# @param start_date [Date] The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`.
|
55
|
+
# @param end_date [Date] The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`.
|
56
|
+
# @param type [String] Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
57
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
58
|
+
def get_account_activities_with_http_info(account_id:, user_id:, user_secret:, start_date: SENTINEL, end_date: SENTINEL, type: SENTINEL, extra: {})
|
59
|
+
extra[:start_date] = start_date if start_date != SENTINEL
|
60
|
+
extra[:end_date] = end_date if end_date != SENTINEL
|
61
|
+
extra[:type] = type if type != SENTINEL
|
62
|
+
get_account_activities_with_http_info_impl(account_id, user_id, user_secret, extra)
|
63
|
+
end
|
64
|
+
|
65
|
+
# List account activities
|
66
|
+
# Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day.
|
67
|
+
# @param account_id [String]
|
68
|
+
# @param user_id [String]
|
69
|
+
# @param user_secret [String]
|
70
|
+
# @param [Hash] opts the optional parameters
|
71
|
+
# @option opts [Date] :start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`.
|
72
|
+
# @option opts [Date] :end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`.
|
73
|
+
# @option opts [String] :type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
74
|
+
# @return [Array<UniversalActivity>]
|
75
|
+
private def get_account_activities_impl(account_id, user_id, user_secret, opts = {})
|
76
|
+
data, _status_code, _headers = get_account_activities_with_http_info(account_id, user_id, user_secret, opts)
|
77
|
+
data
|
78
|
+
end
|
79
|
+
|
80
|
+
# List account activities
|
81
|
+
# Returns all historical transactions for the specified account. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day.
|
82
|
+
# @param account_id [String]
|
83
|
+
# @param user_id [String]
|
84
|
+
# @param user_secret [String]
|
85
|
+
# @param [Hash] opts the optional parameters
|
86
|
+
# @option opts [Date] :start_date The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`.
|
87
|
+
# @option opts [Date] :end_date The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`.
|
88
|
+
# @option opts [String] :type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
89
|
+
# @return [Array<(Array<UniversalActivity>, Integer, Hash)>] Array<UniversalActivity> data, response status code and response headers
|
90
|
+
private def get_account_activities_with_http_info_impl(account_id, user_id, user_secret, opts = {})
|
91
|
+
if @api_client.config.debugging
|
92
|
+
@api_client.config.logger.debug 'Calling API: AccountInformationApi.get_account_activities ...'
|
93
|
+
end
|
94
|
+
# verify the required parameter 'account_id' is set
|
95
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
96
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling AccountInformationApi.get_account_activities"
|
97
|
+
end
|
98
|
+
# verify the required parameter 'user_id' is set
|
99
|
+
if @api_client.config.client_side_validation && user_id.nil?
|
100
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling AccountInformationApi.get_account_activities"
|
101
|
+
end
|
102
|
+
# verify the required parameter 'user_secret' is set
|
103
|
+
if @api_client.config.client_side_validation && user_secret.nil?
|
104
|
+
fail ArgumentError, "Missing the required parameter 'user_secret' when calling AccountInformationApi.get_account_activities"
|
105
|
+
end
|
106
|
+
# resource path
|
107
|
+
local_var_path = '/accounts/{accountId}/activities'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
|
108
|
+
|
109
|
+
# query parameters
|
110
|
+
query_params = opts[:query_params] || {}
|
111
|
+
query_params[:'userId'] = user_id
|
112
|
+
query_params[:'userSecret'] = user_secret
|
113
|
+
query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?
|
114
|
+
query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil?
|
115
|
+
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
|
116
|
+
|
117
|
+
# header parameters
|
118
|
+
header_params = opts[:header_params] || {}
|
119
|
+
# HTTP header 'Accept' (if needed)
|
120
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
121
|
+
|
122
|
+
# form parameters
|
123
|
+
form_params = opts[:form_params] || {}
|
124
|
+
|
125
|
+
# http body (model)
|
126
|
+
post_body = opts[:debug_body]
|
127
|
+
|
128
|
+
# return_type
|
129
|
+
return_type = opts[:debug_return_type] || 'Array<UniversalActivity>'
|
130
|
+
|
131
|
+
# auth_names
|
132
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
133
|
+
|
134
|
+
new_options = opts.merge(
|
135
|
+
:operation => :"AccountInformationApi.get_account_activities",
|
136
|
+
:header_params => header_params,
|
137
|
+
:query_params => query_params,
|
138
|
+
:form_params => form_params,
|
139
|
+
:body => post_body,
|
140
|
+
:auth_names => auth_names,
|
141
|
+
:return_type => return_type
|
142
|
+
)
|
143
|
+
|
144
|
+
data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
|
145
|
+
if @api_client.config.debugging
|
146
|
+
@api_client.config.logger.debug "API called: AccountInformationApi#get_account_activities\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
147
|
+
end
|
148
|
+
return data, status_code, headers, response
|
149
|
+
end
|
150
|
+
|
151
|
+
|
20
152
|
# List all accounts for the user, plus balances, positions, and orders for each account.
|
21
153
|
#
|
22
154
|
# **Deprecated, please use the account-specific holdings endpoint instead.**
|
@@ -428,9 +428,12 @@ module SnapTrade
|
|
428
428
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
429
429
|
# @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
430
430
|
# @param notional_value [ManualTradeFormNotionalValue]
|
431
|
+
# @param order_class [OrderClass] The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
|
432
|
+
# @param stop_loss [ManualTradeFormWithOptionsStopLoss]
|
433
|
+
# @param take_profit [ManualTradeFormWithOptionsTakeProfit]
|
431
434
|
# @param body [ManualTradeFormWithOptions]
|
432
435
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
433
|
-
def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
|
436
|
+
def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, order_class: SENTINEL, stop_loss: SENTINEL, take_profit: SENTINEL, extra: {})
|
434
437
|
_body = {}
|
435
438
|
_body[:account_id] = account_id if account_id != SENTINEL
|
436
439
|
_body[:action] = action if action != SENTINEL
|
@@ -442,6 +445,9 @@ module SnapTrade
|
|
442
445
|
_body[:stop] = stop if stop != SENTINEL
|
443
446
|
_body[:units] = units if units != SENTINEL
|
444
447
|
_body[:notional_value] = notional_value if notional_value != SENTINEL
|
448
|
+
_body[:order_class] = order_class if order_class != SENTINEL
|
449
|
+
_body[:stop_loss] = stop_loss if stop_loss != SENTINEL
|
450
|
+
_body[:take_profit] = take_profit if take_profit != SENTINEL
|
445
451
|
manual_trade_form_with_options = _body
|
446
452
|
data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
|
447
453
|
data
|
@@ -467,9 +473,12 @@ module SnapTrade
|
|
467
473
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
468
474
|
# @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
469
475
|
# @param notional_value [ManualTradeFormNotionalValue]
|
476
|
+
# @param order_class [OrderClass] The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
|
477
|
+
# @param stop_loss [ManualTradeFormWithOptionsStopLoss]
|
478
|
+
# @param take_profit [ManualTradeFormWithOptionsTakeProfit]
|
470
479
|
# @param body [ManualTradeFormWithOptions]
|
471
480
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
472
|
-
def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
|
481
|
+
def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, order_class: SENTINEL, stop_loss: SENTINEL, take_profit: SENTINEL, extra: {})
|
473
482
|
_body = {}
|
474
483
|
_body[:account_id] = account_id if account_id != SENTINEL
|
475
484
|
_body[:action] = action if action != SENTINEL
|
@@ -481,6 +490,9 @@ module SnapTrade
|
|
481
490
|
_body[:stop] = stop if stop != SENTINEL
|
482
491
|
_body[:units] = units if units != SENTINEL
|
483
492
|
_body[:notional_value] = notional_value if notional_value != SENTINEL
|
493
|
+
_body[:order_class] = order_class if order_class != SENTINEL
|
494
|
+
_body[:stop_loss] = stop_loss if stop_loss != SENTINEL
|
495
|
+
_body[:take_profit] = take_profit if take_profit != SENTINEL
|
484
496
|
manual_trade_form_with_options = _body
|
485
497
|
place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
|
486
498
|
end
|
@@ -23,7 +23,7 @@ module SnapTrade
|
|
23
23
|
#
|
24
24
|
# There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order.
|
25
25
|
#
|
26
|
-
# The data returned here is always cached and refreshed once a day.
|
26
|
+
# The data returned here is always cached and refreshed once a day.
|
27
27
|
#
|
28
28
|
# @param user_id [String]
|
29
29
|
# @param user_secret [String]
|
@@ -49,7 +49,7 @@ module SnapTrade
|
|
49
49
|
#
|
50
50
|
# There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order.
|
51
51
|
#
|
52
|
-
# The data returned here is always cached and refreshed once a day.
|
52
|
+
# The data returned here is always cached and refreshed once a day.
|
53
53
|
#
|
54
54
|
# @param user_id [String]
|
55
55
|
# @param user_secret [String]
|
@@ -69,7 +69,7 @@ module SnapTrade
|
|
69
69
|
end
|
70
70
|
|
71
71
|
# Get transaction history for a user
|
72
|
-
# Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day.
|
72
|
+
# Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day.
|
73
73
|
# @param user_id [String]
|
74
74
|
# @param user_secret [String]
|
75
75
|
# @param [Hash] opts the optional parameters
|
@@ -85,7 +85,7 @@ module SnapTrade
|
|
85
85
|
end
|
86
86
|
|
87
87
|
# Get transaction history for a user
|
88
|
-
# Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day.
|
88
|
+
# Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day.
|
89
89
|
# @param user_id [String]
|
90
90
|
# @param user_secret [String]
|
91
91
|
# @param [Hash] opts the optional parameters
|
@@ -42,6 +42,13 @@ module SnapTrade
|
|
42
42
|
|
43
43
|
attr_accessor :notional_value
|
44
44
|
|
45
|
+
# The class of order intended to be placed. Defaults to SIMPLE for regular, one legged trades. Set to BRACKET if looking to place a bracket (One-triggers-a-one-cancels-the-other) order, then specify take profit and stop loss conditions. Bracket orders currently only supported on Alpaca, Tradier, and Tradestation, contact us for more details
|
46
|
+
attr_accessor :order_class
|
47
|
+
|
48
|
+
attr_accessor :stop_loss
|
49
|
+
|
50
|
+
attr_accessor :take_profit
|
51
|
+
|
45
52
|
# Attribute mapping from ruby-style variable name to JSON key.
|
46
53
|
def self.attribute_map
|
47
54
|
{
|
@@ -54,7 +61,10 @@ module SnapTrade
|
|
54
61
|
:'price' => :'price',
|
55
62
|
:'stop' => :'stop',
|
56
63
|
:'units' => :'units',
|
57
|
-
:'notional_value' => :'notional_value'
|
64
|
+
:'notional_value' => :'notional_value',
|
65
|
+
:'order_class' => :'order_class',
|
66
|
+
:'stop_loss' => :'stop_loss',
|
67
|
+
:'take_profit' => :'take_profit'
|
58
68
|
}
|
59
69
|
end
|
60
70
|
|
@@ -75,7 +85,10 @@ module SnapTrade
|
|
75
85
|
:'price' => :'Float',
|
76
86
|
:'stop' => :'Float',
|
77
87
|
:'units' => :'Float',
|
78
|
-
:'notional_value' => :'ManualTradeFormNotionalValue'
|
88
|
+
:'notional_value' => :'ManualTradeFormNotionalValue',
|
89
|
+
:'order_class' => :'OrderClass',
|
90
|
+
:'stop_loss' => :'ManualTradeFormWithOptionsStopLoss',
|
91
|
+
:'take_profit' => :'ManualTradeFormWithOptionsTakeProfit'
|
79
92
|
}
|
80
93
|
end
|
81
94
|
|
@@ -87,7 +100,10 @@ module SnapTrade
|
|
87
100
|
:'price',
|
88
101
|
:'stop',
|
89
102
|
:'units',
|
90
|
-
:'notional_value'
|
103
|
+
:'notional_value',
|
104
|
+
:'order_class',
|
105
|
+
:'stop_loss',
|
106
|
+
:'take_profit'
|
91
107
|
])
|
92
108
|
end
|
93
109
|
|
@@ -145,6 +161,18 @@ module SnapTrade
|
|
145
161
|
if attributes.key?(:'notional_value')
|
146
162
|
self.notional_value = attributes[:'notional_value']
|
147
163
|
end
|
164
|
+
|
165
|
+
if attributes.key?(:'order_class')
|
166
|
+
self.order_class = attributes[:'order_class']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.key?(:'stop_loss')
|
170
|
+
self.stop_loss = attributes[:'stop_loss']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.key?(:'take_profit')
|
174
|
+
self.take_profit = attributes[:'take_profit']
|
175
|
+
end
|
148
176
|
end
|
149
177
|
|
150
178
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -194,7 +222,10 @@ module SnapTrade
|
|
194
222
|
price == o.price &&
|
195
223
|
stop == o.stop &&
|
196
224
|
units == o.units &&
|
197
|
-
notional_value == o.notional_value
|
225
|
+
notional_value == o.notional_value &&
|
226
|
+
order_class == o.order_class &&
|
227
|
+
stop_loss == o.stop_loss &&
|
228
|
+
take_profit == o.take_profit
|
198
229
|
end
|
199
230
|
|
200
231
|
# @see the `==` method
|
@@ -206,7 +237,7 @@ module SnapTrade
|
|
206
237
|
# Calculates hash code according to all attributes.
|
207
238
|
# @return [Integer] Hash code
|
208
239
|
def hash
|
209
|
-
[account_id, action, universal_symbol_id, symbol, order_type, time_in_force, price, stop, units, notional_value].hash
|
240
|
+
[account_id, action, universal_symbol_id, symbol, order_type, time_in_force, price, stop, units, notional_value, order_class, stop_loss, take_profit].hash
|
210
241
|
end
|
211
242
|
|
212
243
|
# Builds the object from hash
|