snaptrade-python-sdk 13.2.0__py3-none-any.whl → 13.3.0__py3-none-any.whl
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.
- snaptrade_client/__init__.py +2 -1
- snaptrade_client/api_client.py +1 -1
- snaptrade_client/apis/path_to_api.py +9 -9
- snaptrade_client/apis/tags/account_information_api_generated.py +6 -0
- snaptrade_client/apis/tags/experimental_endpoints_api_generated.py +0 -6
- snaptrade_client/configuration.py +1 -1
- snaptrade_client/oauth.py +267 -0
- snaptrade_client/operation_parameter_map.py +33 -33
- snaptrade_client/paths/__init__.py +3 -3
- snaptrade_client/paths/accounts_account_id_orders_all/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_orders_brokerage_order_id/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_orders_recent/get.py +2 -2
- {snaptrade_python_sdk-13.2.0.dist-info → snaptrade_python_sdk-13.3.0.dist-info}/METADATA +259 -232
- {snaptrade_python_sdk-13.2.0.dist-info → snaptrade_python_sdk-13.3.0.dist-info}/RECORD +16 -15
- {snaptrade_python_sdk-13.2.0.dist-info → snaptrade_python_sdk-13.3.0.dist-info}/LICENSE +0 -0
- {snaptrade_python_sdk-13.2.0.dist-info → snaptrade_python_sdk-13.3.0.dist-info}/WHEEL +0 -0
snaptrade_client/__init__.py
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
Created by: https://snaptrade.com/
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
__version__ = "13.
|
|
15
|
+
__version__ = "13.3.0"
|
|
16
16
|
|
|
17
17
|
# import ApiClient
|
|
18
18
|
from snaptrade_client.api_client import ApiClient
|
|
@@ -20,6 +20,7 @@ from snaptrade_client.api_client import ApiClient
|
|
|
20
20
|
# import Configuration
|
|
21
21
|
from snaptrade_client.configuration import Configuration
|
|
22
22
|
from snaptrade_client.auth import SnapTradeAuth, AuthMode, CommercialApiKeyAuth, PersonalApiKeyAuth, OAuthAuth
|
|
23
|
+
from snaptrade_client.oauth import SnapTradeOAuth, SnapTradeOAuthAuthorizationFlow, SnapTradeOAuthTokenResponse
|
|
23
24
|
from snaptrade_client.oauth_device import SnapTradeOAuthDevice, SnapTradeDeviceAuthorization, SnapTradeDeviceTokens, SnapTradeOAuthDeviceError
|
|
24
25
|
|
|
25
26
|
# import exceptions
|
snaptrade_client/api_client.py
CHANGED
|
@@ -1175,7 +1175,7 @@ class ApiClient(typing.Generic[TAuth]):
|
|
|
1175
1175
|
self.default_headers[header_name] = header_value
|
|
1176
1176
|
self.cookie = cookie
|
|
1177
1177
|
# Set default User-Agent.
|
|
1178
|
-
self.user_agent = 'Konfig/13.
|
|
1178
|
+
self.user_agent = 'Konfig/13.3.0/python'
|
|
1179
1179
|
|
|
1180
1180
|
def __enter__(self):
|
|
1181
1181
|
return self
|
|
@@ -25,11 +25,14 @@ from snaptrade_client.apis.paths.accounts_account_id_balances import AccountsAcc
|
|
|
25
25
|
from snaptrade_client.apis.paths.accounts_account_id_balances_v2 import AccountsAccountIdBalancesV2
|
|
26
26
|
from snaptrade_client.apis.paths.accounts_account_id_positions_all import AccountsAccountIdPositionsAll
|
|
27
27
|
from snaptrade_client.apis.paths.accounts_account_id_orders import AccountsAccountIdOrders
|
|
28
|
+
from snaptrade_client.apis.paths.accounts_account_id_orders_all import AccountsAccountIdOrdersAll
|
|
28
29
|
from snaptrade_client.apis.paths.accounts_account_id_balance_history import AccountsAccountIdBalanceHistory
|
|
29
30
|
from snaptrade_client.apis.paths.accounts_account_id_recent_orders import AccountsAccountIdRecentOrders
|
|
31
|
+
from snaptrade_client.apis.paths.accounts_account_id_orders_recent import AccountsAccountIdOrdersRecent
|
|
30
32
|
from snaptrade_client.apis.paths.accounts_account_id_return_rates import AccountsAccountIdReturnRates
|
|
31
33
|
from snaptrade_client.apis.paths.accounts_account_id_activities import AccountsAccountIdActivities
|
|
32
34
|
from snaptrade_client.apis.paths.accounts_account_id_orders_details import AccountsAccountIdOrdersDetails
|
|
35
|
+
from snaptrade_client.apis.paths.accounts_account_id_orders_brokerage_order_id import AccountsAccountIdOrdersBrokerageOrderId
|
|
33
36
|
from snaptrade_client.apis.paths.accounts_account_id_quotes import AccountsAccountIdQuotes
|
|
34
37
|
from snaptrade_client.apis.paths.trade_impact import TradeImpact
|
|
35
38
|
from snaptrade_client.apis.paths.accounts_account_id_trading_options_impact import AccountsAccountIdTradingOptionsImpact
|
|
@@ -50,9 +53,7 @@ from snaptrade_client.apis.paths.snap_trade_trade_detection_subscriptions_cancel
|
|
|
50
53
|
from snaptrade_client.apis.paths.management_stats import ManagementStats
|
|
51
54
|
from snaptrade_client.apis.paths.snap_trade_stats import SnapTradeStats
|
|
52
55
|
from snaptrade_client.apis.paths.accounts_account_id_orders_v2 import AccountsAccountIdOrdersV2
|
|
53
|
-
from snaptrade_client.apis.paths.accounts_account_id_orders_all import AccountsAccountIdOrdersAll
|
|
54
56
|
from snaptrade_client.apis.paths.accounts_account_id_recent_orders_v2 import AccountsAccountIdRecentOrdersV2
|
|
55
|
-
from snaptrade_client.apis.paths.accounts_account_id_orders_recent import AccountsAccountIdOrdersRecent
|
|
56
57
|
from snaptrade_client.apis.paths.accounts_account_id_symbols import AccountsAccountIdSymbols
|
|
57
58
|
from snaptrade_client.apis.paths.brokerages import Brokerages
|
|
58
59
|
from snaptrade_client.apis.paths.institutions import Institutions
|
|
@@ -63,7 +64,6 @@ from snaptrade_client.apis.paths.symbols import Symbols
|
|
|
63
64
|
from snaptrade_client.apis.paths.symbols_query import SymbolsQuery
|
|
64
65
|
from snaptrade_client.apis.paths.accounts_account_id_trading_simple import AccountsAccountIdTradingSimple
|
|
65
66
|
from snaptrade_client.apis.paths.accounts_account_id_orders_details_v2_brokerage_order_id import AccountsAccountIdOrdersDetailsV2BrokerageOrderId
|
|
66
|
-
from snaptrade_client.apis.paths.accounts_account_id_orders_brokerage_order_id import AccountsAccountIdOrdersBrokerageOrderId
|
|
67
67
|
|
|
68
68
|
PathToApi = typing_extensions.TypedDict(
|
|
69
69
|
'PathToApi',
|
|
@@ -92,11 +92,14 @@ PathToApi = typing_extensions.TypedDict(
|
|
|
92
92
|
PathValues.ACCOUNTS_ACCOUNT_ID_BALANCES_V2: AccountsAccountIdBalancesV2,
|
|
93
93
|
PathValues.ACCOUNTS_ACCOUNT_ID_POSITIONS_ALL: AccountsAccountIdPositionsAll,
|
|
94
94
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS: AccountsAccountIdOrders,
|
|
95
|
+
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_ALL: AccountsAccountIdOrdersAll,
|
|
95
96
|
PathValues.ACCOUNTS_ACCOUNT_ID_BALANCE_HISTORY: AccountsAccountIdBalanceHistory,
|
|
96
97
|
PathValues.ACCOUNTS_ACCOUNT_ID_RECENT_ORDERS: AccountsAccountIdRecentOrders,
|
|
98
|
+
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_RECENT: AccountsAccountIdOrdersRecent,
|
|
97
99
|
PathValues.ACCOUNTS_ACCOUNT_ID_RETURN_RATES: AccountsAccountIdReturnRates,
|
|
98
100
|
PathValues.ACCOUNTS_ACCOUNT_ID_ACTIVITIES: AccountsAccountIdActivities,
|
|
99
101
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_DETAILS: AccountsAccountIdOrdersDetails,
|
|
102
|
+
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_BROKERAGE_ORDER_ID: AccountsAccountIdOrdersBrokerageOrderId,
|
|
100
103
|
PathValues.ACCOUNTS_ACCOUNT_ID_QUOTES: AccountsAccountIdQuotes,
|
|
101
104
|
PathValues.TRADE_IMPACT: TradeImpact,
|
|
102
105
|
PathValues.ACCOUNTS_ACCOUNT_ID_TRADING_OPTIONS_IMPACT: AccountsAccountIdTradingOptionsImpact,
|
|
@@ -117,9 +120,7 @@ PathToApi = typing_extensions.TypedDict(
|
|
|
117
120
|
PathValues.MANAGEMENT_STATS: ManagementStats,
|
|
118
121
|
PathValues.SNAP_TRADE_STATS: SnapTradeStats,
|
|
119
122
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_V2: AccountsAccountIdOrdersV2,
|
|
120
|
-
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_ALL: AccountsAccountIdOrdersAll,
|
|
121
123
|
PathValues.ACCOUNTS_ACCOUNT_ID_RECENT_ORDERS_V2: AccountsAccountIdRecentOrdersV2,
|
|
122
|
-
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_RECENT: AccountsAccountIdOrdersRecent,
|
|
123
124
|
PathValues.ACCOUNTS_ACCOUNT_ID_SYMBOLS: AccountsAccountIdSymbols,
|
|
124
125
|
PathValues.BROKERAGES: Brokerages,
|
|
125
126
|
PathValues.INSTITUTIONS: Institutions,
|
|
@@ -130,7 +131,6 @@ PathToApi = typing_extensions.TypedDict(
|
|
|
130
131
|
PathValues.SYMBOLS_QUERY: SymbolsQuery,
|
|
131
132
|
PathValues.ACCOUNTS_ACCOUNT_ID_TRADING_SIMPLE: AccountsAccountIdTradingSimple,
|
|
132
133
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_DETAILS_V2_BROKERAGE_ORDER_ID: AccountsAccountIdOrdersDetailsV2BrokerageOrderId,
|
|
133
|
-
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_BROKERAGE_ORDER_ID: AccountsAccountIdOrdersBrokerageOrderId,
|
|
134
134
|
}
|
|
135
135
|
)
|
|
136
136
|
|
|
@@ -160,11 +160,14 @@ path_to_api = PathToApi(
|
|
|
160
160
|
PathValues.ACCOUNTS_ACCOUNT_ID_BALANCES_V2: AccountsAccountIdBalancesV2,
|
|
161
161
|
PathValues.ACCOUNTS_ACCOUNT_ID_POSITIONS_ALL: AccountsAccountIdPositionsAll,
|
|
162
162
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS: AccountsAccountIdOrders,
|
|
163
|
+
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_ALL: AccountsAccountIdOrdersAll,
|
|
163
164
|
PathValues.ACCOUNTS_ACCOUNT_ID_BALANCE_HISTORY: AccountsAccountIdBalanceHistory,
|
|
164
165
|
PathValues.ACCOUNTS_ACCOUNT_ID_RECENT_ORDERS: AccountsAccountIdRecentOrders,
|
|
166
|
+
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_RECENT: AccountsAccountIdOrdersRecent,
|
|
165
167
|
PathValues.ACCOUNTS_ACCOUNT_ID_RETURN_RATES: AccountsAccountIdReturnRates,
|
|
166
168
|
PathValues.ACCOUNTS_ACCOUNT_ID_ACTIVITIES: AccountsAccountIdActivities,
|
|
167
169
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_DETAILS: AccountsAccountIdOrdersDetails,
|
|
170
|
+
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_BROKERAGE_ORDER_ID: AccountsAccountIdOrdersBrokerageOrderId,
|
|
168
171
|
PathValues.ACCOUNTS_ACCOUNT_ID_QUOTES: AccountsAccountIdQuotes,
|
|
169
172
|
PathValues.TRADE_IMPACT: TradeImpact,
|
|
170
173
|
PathValues.ACCOUNTS_ACCOUNT_ID_TRADING_OPTIONS_IMPACT: AccountsAccountIdTradingOptionsImpact,
|
|
@@ -185,9 +188,7 @@ path_to_api = PathToApi(
|
|
|
185
188
|
PathValues.MANAGEMENT_STATS: ManagementStats,
|
|
186
189
|
PathValues.SNAP_TRADE_STATS: SnapTradeStats,
|
|
187
190
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_V2: AccountsAccountIdOrdersV2,
|
|
188
|
-
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_ALL: AccountsAccountIdOrdersAll,
|
|
189
191
|
PathValues.ACCOUNTS_ACCOUNT_ID_RECENT_ORDERS_V2: AccountsAccountIdRecentOrdersV2,
|
|
190
|
-
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_RECENT: AccountsAccountIdOrdersRecent,
|
|
191
192
|
PathValues.ACCOUNTS_ACCOUNT_ID_SYMBOLS: AccountsAccountIdSymbols,
|
|
192
193
|
PathValues.BROKERAGES: Brokerages,
|
|
193
194
|
PathValues.INSTITUTIONS: Institutions,
|
|
@@ -198,6 +199,5 @@ path_to_api = PathToApi(
|
|
|
198
199
|
PathValues.SYMBOLS_QUERY: SymbolsQuery,
|
|
199
200
|
PathValues.ACCOUNTS_ACCOUNT_ID_TRADING_SIMPLE: AccountsAccountIdTradingSimple,
|
|
200
201
|
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_DETAILS_V2_BROKERAGE_ORDER_ID: AccountsAccountIdOrdersDetailsV2BrokerageOrderId,
|
|
201
|
-
PathValues.ACCOUNTS_ACCOUNT_ID_ORDERS_BROKERAGE_ORDER_ID: AccountsAccountIdOrdersBrokerageOrderId,
|
|
202
202
|
}
|
|
203
203
|
)
|
|
@@ -13,7 +13,10 @@ from snaptrade_client.paths.accounts_account_id_activities.get import GetAccount
|
|
|
13
13
|
from snaptrade_client.paths.accounts_account_id_balance_history.get import GetAccountBalanceHistory
|
|
14
14
|
from snaptrade_client.paths.accounts_account_id_balances_v2.get import GetAccountBalancesV2
|
|
15
15
|
from snaptrade_client.paths.accounts_account_id_details.get import GetAccountDetails
|
|
16
|
+
from snaptrade_client.paths.accounts_account_id_orders_brokerage_order_id.get import GetAccountOrder
|
|
17
|
+
from snaptrade_client.paths.accounts_account_id_orders_all.get import GetAllAccountOrders
|
|
16
18
|
from snaptrade_client.paths.accounts_account_id_positions_all.get import GetAllAccountPositions
|
|
19
|
+
from snaptrade_client.paths.accounts_account_id_orders_recent.get import GetAllAccountRecentOrders
|
|
17
20
|
from snaptrade_client.paths.accounts_account_id_balances.get import GetUserAccountBalance
|
|
18
21
|
from snaptrade_client.paths.accounts_account_id.get import GetUserAccountDetails
|
|
19
22
|
from snaptrade_client.paths.accounts_account_id_orders_details.post import GetUserAccountOrderDetail
|
|
@@ -35,7 +38,10 @@ class AccountInformationApiGenerated(
|
|
|
35
38
|
GetAccountBalanceHistory[TAuth],
|
|
36
39
|
GetAccountBalancesV2[TAuth],
|
|
37
40
|
GetAccountDetails[TAuth],
|
|
41
|
+
GetAccountOrder[TAuth],
|
|
42
|
+
GetAllAccountOrders[TAuth],
|
|
38
43
|
GetAllAccountPositions[TAuth],
|
|
44
|
+
GetAllAccountRecentOrders[TAuth],
|
|
39
45
|
GetUserAccountBalance[TAuth],
|
|
40
46
|
GetUserAccountDetails[TAuth],
|
|
41
47
|
GetUserAccountOrderDetail[TAuth],
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
from snaptrade_client.paths.snap_trade_trade_detection_subscriptions.post import AddSubscription
|
|
13
13
|
from snaptrade_client.paths.snap_trade_trade_detection_subscriptions_cancel.post import CancelSubscription
|
|
14
|
-
from snaptrade_client.paths.accounts_account_id_orders_brokerage_order_id.get import GetAccountOrder
|
|
15
|
-
from snaptrade_client.paths.accounts_account_id_orders_all.get import GetAllAccountOrders
|
|
16
|
-
from snaptrade_client.paths.accounts_account_id_orders_recent.get import GetAllAccountRecentOrders
|
|
17
14
|
from snaptrade_client.paths.accounts_account_id_orders_details_v2_brokerage_order_id.get import GetUserAccountOrderDetailV2
|
|
18
15
|
from snaptrade_client.paths.accounts_account_id_orders_v2.get import GetUserAccountOrdersV2
|
|
19
16
|
from snaptrade_client.paths.accounts_account_id_recent_orders_v2.get import GetUserAccountRecentOrdersV2
|
|
@@ -28,9 +25,6 @@ TAuth = typing.TypeVar("TAuth", bound=AuthMode)
|
|
|
28
25
|
class ExperimentalEndpointsApiGenerated(
|
|
29
26
|
AddSubscription[TAuth],
|
|
30
27
|
CancelSubscription[TAuth],
|
|
31
|
-
GetAccountOrder[TAuth],
|
|
32
|
-
GetAllAccountOrders[TAuth],
|
|
33
|
-
GetAllAccountRecentOrders[TAuth],
|
|
34
28
|
GetUserAccountOrderDetailV2[TAuth],
|
|
35
29
|
GetUserAccountOrdersV2[TAuth],
|
|
36
30
|
GetUserAccountRecentOrdersV2[TAuth],
|
|
@@ -537,7 +537,7 @@ conf = snaptrade_client.Configuration(
|
|
|
537
537
|
"OS: {env}\n"\
|
|
538
538
|
"Python Version: {pyversion}\n"\
|
|
539
539
|
"Version of the API: 1.0.0\n"\
|
|
540
|
-
"SDK Package Version: 13.
|
|
540
|
+
"SDK Package Version: 13.3.0".\
|
|
541
541
|
format(env=sys.platform, pyversion=sys.version)
|
|
542
542
|
|
|
543
543
|
def get_host_settings(self):
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
SnapTrade
|
|
5
|
+
|
|
6
|
+
Connect brokerage accounts to your app for live positions and trading. ## Rate limiting Two limits apply to requests signed with your `clientId`. The stricter one wins, and exceeding either returns `429 Too Many Requests`. - **Customer-level** — 250 requests/minute by default, scoped to your `clientId` and applied across all endpoints. Reported in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. - **Account-level** — 10 requests/minute per account, scoped to (`clientId`, `accountId`). All covered operations for one account draw on the same bucket — reading balances and reading positions share it — and enforcement does not depend on the HTTP method, so updating an account consumes the same bucket as reading it. Only enforced for Personal users, and only for integrations it has been rolled out to — it is not yet in force for every Personal integration. It also does not apply on every operation that documents a 429 below. Where it applies it is reported in `X-RateLimit-Account-Limit`, `X-RateLimit-Account-Remaining` and `X-RateLimit-Account-Reset`. Do not read the absence of those headers as proof the limit is off — some configurations omit the rate limit headers while still enforcing the limit, so header absence tells you nothing about your allowance. On a 429, `X-RateLimit-Remaining: 0` means you hit the customer-level limit and `X-RateLimit-Account-Remaining: 0` means the account-level one. Wait for the corresponding `*-Reset` value (seconds) before retrying, or fall back to exponential backoff with jitter. Not every 429 is explained by those headers. A separate per-authenticated-user limit, reported in no `X-RateLimit-*` header, covers OAuth-authenticated requests and signed requests in configurations where the customer-level limit is not in effect — on the operations that use the default throttles. A few operations override those and are governed by the customer-level limit alone. The two do not stack: a signed request governed by the customer-level limit above is not additionally subject to the per-user one. If a 429 arrives with no header at zero — or with no `X-RateLimit-*` headers at all — honour `Retry-After` and back off. Treat the remaining counts as a hint, not a guarantee that the next request will succeed. Because the customer-level limit applies everywhere, any signed request can return 429. **OAuth-authenticated requests are an exception.** They are not subject to the customer-level limit and do not receive `X-RateLimit-Limit`, `X-RateLimit-Remaining` or `X-RateLimit-Reset` — do not wait on those headers or design around a customer-level allowance on this path. The account-level limit still applies to them on the account-data endpoints above, reported in the `X-RateLimit-Account-*` headers. On operations using the default throttles the per-user limit above applies to them as well, so an OAuth request can be rejected while the account headers still show capacity; on the few operations that override those throttles, OAuth callers have no per-user ceiling at all. Drive retries from `Retry-After` and exponential backoff with jitter rather than from the headers. See https://docs.snaptrade.com/docs/ratelimiting.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0
|
|
9
|
+
Contact: api@snaptrade.com
|
|
10
|
+
Created by: https://snaptrade.com/
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
import base64
|
|
15
|
+
import hashlib
|
|
16
|
+
import json
|
|
17
|
+
import secrets
|
|
18
|
+
import typing
|
|
19
|
+
import urllib.parse
|
|
20
|
+
import urllib.request
|
|
21
|
+
import urllib.error
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
SnapTradeOAuthScope = str
|
|
25
|
+
SnapTradeOAuthClientAuthMethod = typing.Literal["none", "client_secret_post", "client_secret_basic"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class SnapTradeOAuthAuthorizationFlow:
|
|
30
|
+
url: str
|
|
31
|
+
state: str
|
|
32
|
+
code_verifier: str
|
|
33
|
+
code_challenge: str
|
|
34
|
+
scope: str
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class SnapTradeOAuthTokenResponse:
|
|
39
|
+
access_token: str
|
|
40
|
+
refresh_token: typing.Optional[str]
|
|
41
|
+
token_type: typing.Optional[str]
|
|
42
|
+
expires_in: typing.Optional[int]
|
|
43
|
+
scope: typing.Optional[str]
|
|
44
|
+
raw: typing.Dict[str, typing.Any]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass
|
|
48
|
+
class _ResolvedEndpoints:
|
|
49
|
+
authorization_endpoint: str
|
|
50
|
+
token_endpoint: str
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _trim_trailing_slash(value: str) -> str:
|
|
54
|
+
return value.rstrip("/")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _origin(value: str) -> str:
|
|
58
|
+
parsed = urllib.parse.urlparse(value)
|
|
59
|
+
if not parsed.scheme or not parsed.netloc:
|
|
60
|
+
raise ValueError("OAuth issuer must be an absolute URL.")
|
|
61
|
+
return f"{parsed.scheme}://{parsed.netloc}"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _to_base64_url(data: bytes) -> str:
|
|
65
|
+
return base64.urlsafe_b64encode(data).decode("ascii").rstrip("=")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _random_base64_url(byte_length: int) -> str:
|
|
69
|
+
return _to_base64_url(secrets.token_bytes(byte_length))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _sha256_base64_url(value: str) -> str:
|
|
73
|
+
return _to_base64_url(hashlib.sha256(value.encode("utf-8")).digest())
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _encode_basic_auth(client_id: str, client_secret: str) -> str:
|
|
77
|
+
return base64.b64encode(f"{client_id}:{client_secret}".encode("utf-8")).decode("ascii")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _json_request(
|
|
81
|
+
url: str,
|
|
82
|
+
*,
|
|
83
|
+
method: str = "GET",
|
|
84
|
+
body: typing.Optional[typing.Union[typing.Dict[str, typing.Any], str]] = None,
|
|
85
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
86
|
+
timeout: typing.Optional[float] = None,
|
|
87
|
+
) -> typing.Dict[str, typing.Any]:
|
|
88
|
+
request_headers = dict(headers or {})
|
|
89
|
+
data = None
|
|
90
|
+
if isinstance(body, dict):
|
|
91
|
+
data = json.dumps(body).encode("utf-8")
|
|
92
|
+
request_headers.setdefault("Content-Type", "application/json")
|
|
93
|
+
elif isinstance(body, str):
|
|
94
|
+
data = body.encode("utf-8")
|
|
95
|
+
|
|
96
|
+
request = urllib.request.Request(url, data=data, headers=request_headers, method=method)
|
|
97
|
+
try:
|
|
98
|
+
urlopen_kwargs = {}
|
|
99
|
+
if timeout is not None:
|
|
100
|
+
urlopen_kwargs["timeout"] = timeout
|
|
101
|
+
with urllib.request.urlopen(request, **urlopen_kwargs) as response:
|
|
102
|
+
response_body = response.read()
|
|
103
|
+
except urllib.error.HTTPError as exc:
|
|
104
|
+
details = exc.read().decode("utf-8", errors="replace")
|
|
105
|
+
raise RuntimeError(f"OAuth request failed with status {exc.code}: {details}") from exc
|
|
106
|
+
|
|
107
|
+
parsed = json.loads(response_body or b"{}")
|
|
108
|
+
if not isinstance(parsed, dict):
|
|
109
|
+
raise RuntimeError("OAuth response body was not a JSON object.")
|
|
110
|
+
return parsed
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _normalize_token_response(raw: typing.Dict[str, typing.Any]) -> SnapTradeOAuthTokenResponse:
|
|
114
|
+
access_token = raw.get("access_token")
|
|
115
|
+
if not isinstance(access_token, str) or not access_token:
|
|
116
|
+
raise RuntimeError("OAuth token response did not include an access_token.")
|
|
117
|
+
return SnapTradeOAuthTokenResponse(
|
|
118
|
+
access_token=access_token,
|
|
119
|
+
refresh_token=raw.get("refresh_token") if isinstance(raw.get("refresh_token"), str) else None,
|
|
120
|
+
token_type=raw.get("token_type") if isinstance(raw.get("token_type"), str) else None,
|
|
121
|
+
expires_in=raw.get("expires_in") if isinstance(raw.get("expires_in"), int) else None,
|
|
122
|
+
scope=raw.get("scope") if isinstance(raw.get("scope"), str) else None,
|
|
123
|
+
raw=raw,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class SnapTradeOAuth:
|
|
128
|
+
def __init__(
|
|
129
|
+
self,
|
|
130
|
+
*,
|
|
131
|
+
client_id: str,
|
|
132
|
+
redirect_uri: str,
|
|
133
|
+
client_secret: typing.Optional[str] = None,
|
|
134
|
+
client_auth_method: typing.Optional[SnapTradeOAuthClientAuthMethod] = None,
|
|
135
|
+
issuer: typing.Optional[str] = None,
|
|
136
|
+
authorization_endpoint: typing.Optional[str] = None,
|
|
137
|
+
token_endpoint: typing.Optional[str] = None,
|
|
138
|
+
timeout: typing.Optional[float] = None,
|
|
139
|
+
):
|
|
140
|
+
self.issuer = _trim_trailing_slash(_origin(issuer or "https://api.snaptrade.com"))
|
|
141
|
+
self.authorization_endpoint = authorization_endpoint
|
|
142
|
+
self.token_endpoint = token_endpoint
|
|
143
|
+
self.client_id = client_id
|
|
144
|
+
self.redirect_uri = redirect_uri
|
|
145
|
+
self.client_secret = client_secret
|
|
146
|
+
self.client_auth_method = client_auth_method
|
|
147
|
+
self.timeout = timeout
|
|
148
|
+
self._endpoints: typing.Optional[_ResolvedEndpoints] = None
|
|
149
|
+
self._metadata: typing.Optional[typing.Dict[str, typing.Any]] = None
|
|
150
|
+
|
|
151
|
+
def create_authorization_url(
|
|
152
|
+
self,
|
|
153
|
+
*,
|
|
154
|
+
state: typing.Optional[str] = None,
|
|
155
|
+
scope: str = "read",
|
|
156
|
+
code_verifier: typing.Optional[str] = None,
|
|
157
|
+
) -> SnapTradeOAuthAuthorizationFlow:
|
|
158
|
+
endpoints = self._resolve_endpoints()
|
|
159
|
+
resolved_state = state or _random_base64_url(24)
|
|
160
|
+
resolved_code_verifier = code_verifier or _random_base64_url(32)
|
|
161
|
+
resolved_code_challenge = _sha256_base64_url(resolved_code_verifier)
|
|
162
|
+
query = urllib.parse.urlencode({
|
|
163
|
+
"response_type": "code",
|
|
164
|
+
"client_id": self.client_id,
|
|
165
|
+
"redirect_uri": self.redirect_uri,
|
|
166
|
+
"scope": scope,
|
|
167
|
+
"state": resolved_state,
|
|
168
|
+
"code_challenge": resolved_code_challenge,
|
|
169
|
+
"code_challenge_method": "S256",
|
|
170
|
+
})
|
|
171
|
+
separator = "&" if urllib.parse.urlparse(endpoints.authorization_endpoint).query else "?"
|
|
172
|
+
return SnapTradeOAuthAuthorizationFlow(
|
|
173
|
+
url=f"{endpoints.authorization_endpoint}{separator}{query}",
|
|
174
|
+
state=resolved_state,
|
|
175
|
+
code_verifier=resolved_code_verifier,
|
|
176
|
+
code_challenge=resolved_code_challenge,
|
|
177
|
+
scope=scope,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
def exchange_code(
|
|
181
|
+
self,
|
|
182
|
+
*,
|
|
183
|
+
code: str,
|
|
184
|
+
code_verifier: str,
|
|
185
|
+
) -> SnapTradeOAuthTokenResponse:
|
|
186
|
+
return self._post_token_request(
|
|
187
|
+
{
|
|
188
|
+
"grant_type": "authorization_code",
|
|
189
|
+
"code": code,
|
|
190
|
+
"client_id": self.client_id,
|
|
191
|
+
"redirect_uri": self.redirect_uri,
|
|
192
|
+
"code_verifier": code_verifier,
|
|
193
|
+
},
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
def refresh_token(
|
|
197
|
+
self,
|
|
198
|
+
*,
|
|
199
|
+
refresh_token: str,
|
|
200
|
+
) -> SnapTradeOAuthTokenResponse:
|
|
201
|
+
return self._post_token_request(
|
|
202
|
+
{
|
|
203
|
+
"grant_type": "refresh_token",
|
|
204
|
+
"refresh_token": refresh_token,
|
|
205
|
+
"client_id": self.client_id,
|
|
206
|
+
},
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
def _resolve_endpoints(self) -> _ResolvedEndpoints:
|
|
210
|
+
if self.authorization_endpoint and self.token_endpoint:
|
|
211
|
+
return _ResolvedEndpoints(
|
|
212
|
+
authorization_endpoint=self.authorization_endpoint,
|
|
213
|
+
token_endpoint=self.token_endpoint,
|
|
214
|
+
)
|
|
215
|
+
if self._endpoints is None:
|
|
216
|
+
self._endpoints = self._discover_endpoints()
|
|
217
|
+
return self._endpoints
|
|
218
|
+
|
|
219
|
+
def _discover_endpoints(self) -> _ResolvedEndpoints:
|
|
220
|
+
metadata = self._fetch_server_metadata()
|
|
221
|
+
authorization_endpoint = self.authorization_endpoint or metadata.get("authorization_endpoint")
|
|
222
|
+
token_endpoint = self.token_endpoint or metadata.get("token_endpoint")
|
|
223
|
+
if not authorization_endpoint or not token_endpoint:
|
|
224
|
+
raise RuntimeError("OAuth server metadata did not include authorization_endpoint and token_endpoint.")
|
|
225
|
+
return _ResolvedEndpoints(
|
|
226
|
+
authorization_endpoint=authorization_endpoint,
|
|
227
|
+
token_endpoint=token_endpoint,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
def _fetch_server_metadata(self) -> typing.Dict[str, typing.Any]:
|
|
231
|
+
if self._metadata is None:
|
|
232
|
+
self._metadata = _json_request(
|
|
233
|
+
f"{self.issuer}/.well-known/oauth-authorization-server",
|
|
234
|
+
timeout=self.timeout,
|
|
235
|
+
)
|
|
236
|
+
return self._metadata
|
|
237
|
+
|
|
238
|
+
def _post_token_request(
|
|
239
|
+
self,
|
|
240
|
+
body: typing.Dict[str, str],
|
|
241
|
+
) -> SnapTradeOAuthTokenResponse:
|
|
242
|
+
endpoints = self._resolve_endpoints()
|
|
243
|
+
client_id = self.client_id
|
|
244
|
+
client_secret = self.client_secret
|
|
245
|
+
resolved_client_auth_method = self.client_auth_method or ("client_secret_basic" if client_secret else "none")
|
|
246
|
+
request_body = dict(body)
|
|
247
|
+
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
248
|
+
|
|
249
|
+
if resolved_client_auth_method == "client_secret_post":
|
|
250
|
+
if not client_secret:
|
|
251
|
+
raise RuntimeError("client_secret is required when client_auth_method is client_secret_post.")
|
|
252
|
+
request_body["client_secret"] = client_secret
|
|
253
|
+
elif resolved_client_auth_method == "client_secret_basic":
|
|
254
|
+
if not client_secret:
|
|
255
|
+
raise RuntimeError("client_secret is required when client_auth_method is client_secret_basic.")
|
|
256
|
+
headers["Authorization"] = f"Basic {_encode_basic_auth(client_id, client_secret)}"
|
|
257
|
+
elif resolved_client_auth_method != "none":
|
|
258
|
+
raise RuntimeError(f"Unsupported OAuth client_auth_method: {resolved_client_auth_method}")
|
|
259
|
+
|
|
260
|
+
raw = _json_request(
|
|
261
|
+
endpoints.token_endpoint,
|
|
262
|
+
method="POST",
|
|
263
|
+
body=urllib.parse.urlencode(request_body),
|
|
264
|
+
headers=headers,
|
|
265
|
+
timeout=self.timeout,
|
|
266
|
+
)
|
|
267
|
+
return _normalize_token_response(raw)
|
|
@@ -42,6 +42,29 @@ operation_parameter_map = {
|
|
|
42
42
|
},
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
|
+
'/accounts/{accountId}/orders/{brokerageOrderId}-GET': {
|
|
46
|
+
'parameters': [
|
|
47
|
+
{
|
|
48
|
+
'name': 'accountId'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
'name': 'brokerageOrderId'
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
'/accounts/{accountId}/orders/all-GET': {
|
|
56
|
+
'parameters': [
|
|
57
|
+
{
|
|
58
|
+
'name': 'accountId'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
'name': 'state'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
'name': 'days'
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
},
|
|
45
68
|
'/accounts/{accountId}/positions/all-GET': {
|
|
46
69
|
'parameters': [
|
|
47
70
|
{
|
|
@@ -49,6 +72,16 @@ operation_parameter_map = {
|
|
|
49
72
|
},
|
|
50
73
|
]
|
|
51
74
|
},
|
|
75
|
+
'/accounts/{accountId}/orders/recent-GET': {
|
|
76
|
+
'parameters': [
|
|
77
|
+
{
|
|
78
|
+
'name': 'accountId'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
'name': 'only_executed'
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
},
|
|
52
85
|
'/accounts/{accountId}/balances-GET': {
|
|
53
86
|
'parameters': [
|
|
54
87
|
{
|
|
@@ -268,39 +301,6 @@ operation_parameter_map = {
|
|
|
268
301
|
},
|
|
269
302
|
]
|
|
270
303
|
},
|
|
271
|
-
'/accounts/{accountId}/orders/{brokerageOrderId}-GET': {
|
|
272
|
-
'parameters': [
|
|
273
|
-
{
|
|
274
|
-
'name': 'accountId'
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
'name': 'brokerageOrderId'
|
|
278
|
-
},
|
|
279
|
-
]
|
|
280
|
-
},
|
|
281
|
-
'/accounts/{accountId}/orders/all-GET': {
|
|
282
|
-
'parameters': [
|
|
283
|
-
{
|
|
284
|
-
'name': 'accountId'
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
'name': 'state'
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
'name': 'days'
|
|
291
|
-
},
|
|
292
|
-
]
|
|
293
|
-
},
|
|
294
|
-
'/accounts/{accountId}/orders/recent-GET': {
|
|
295
|
-
'parameters': [
|
|
296
|
-
{
|
|
297
|
-
'name': 'accountId'
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
'name': 'only_executed'
|
|
301
|
-
},
|
|
302
|
-
]
|
|
303
|
-
},
|
|
304
304
|
'/accounts/{accountId}/orders/details/v2/{brokerageOrderId}-GET': {
|
|
305
305
|
'parameters': [
|
|
306
306
|
{
|
|
@@ -30,11 +30,14 @@ class PathValues(str, enum.Enum):
|
|
|
30
30
|
ACCOUNTS_ACCOUNT_ID_BALANCES_V2 = "/accounts/{accountId}/balances/v2"
|
|
31
31
|
ACCOUNTS_ACCOUNT_ID_POSITIONS_ALL = "/accounts/{accountId}/positions/all"
|
|
32
32
|
ACCOUNTS_ACCOUNT_ID_ORDERS = "/accounts/{accountId}/orders"
|
|
33
|
+
ACCOUNTS_ACCOUNT_ID_ORDERS_ALL = "/accounts/{accountId}/orders/all"
|
|
33
34
|
ACCOUNTS_ACCOUNT_ID_BALANCE_HISTORY = "/accounts/{accountId}/balanceHistory"
|
|
34
35
|
ACCOUNTS_ACCOUNT_ID_RECENT_ORDERS = "/accounts/{accountId}/recentOrders"
|
|
36
|
+
ACCOUNTS_ACCOUNT_ID_ORDERS_RECENT = "/accounts/{accountId}/orders/recent"
|
|
35
37
|
ACCOUNTS_ACCOUNT_ID_RETURN_RATES = "/accounts/{accountId}/returnRates"
|
|
36
38
|
ACCOUNTS_ACCOUNT_ID_ACTIVITIES = "/accounts/{accountId}/activities"
|
|
37
39
|
ACCOUNTS_ACCOUNT_ID_ORDERS_DETAILS = "/accounts/{accountId}/orders/details"
|
|
40
|
+
ACCOUNTS_ACCOUNT_ID_ORDERS_BROKERAGE_ORDER_ID = "/accounts/{accountId}/orders/{brokerageOrderId}"
|
|
38
41
|
ACCOUNTS_ACCOUNT_ID_QUOTES = "/accounts/{accountId}/quotes"
|
|
39
42
|
TRADE_IMPACT = "/trade/impact"
|
|
40
43
|
ACCOUNTS_ACCOUNT_ID_TRADING_OPTIONS_IMPACT = "/accounts/{accountId}/trading/options/impact"
|
|
@@ -55,9 +58,7 @@ class PathValues(str, enum.Enum):
|
|
|
55
58
|
MANAGEMENT_STATS = "/management/stats"
|
|
56
59
|
SNAP_TRADE_STATS = "/snapTrade/stats"
|
|
57
60
|
ACCOUNTS_ACCOUNT_ID_ORDERS_V2 = "/accounts/{accountId}/orders/v2"
|
|
58
|
-
ACCOUNTS_ACCOUNT_ID_ORDERS_ALL = "/accounts/{accountId}/orders/all"
|
|
59
61
|
ACCOUNTS_ACCOUNT_ID_RECENT_ORDERS_V2 = "/accounts/{accountId}/recentOrders/v2"
|
|
60
|
-
ACCOUNTS_ACCOUNT_ID_ORDERS_RECENT = "/accounts/{accountId}/orders/recent"
|
|
61
62
|
ACCOUNTS_ACCOUNT_ID_SYMBOLS = "/accounts/{accountId}/symbols"
|
|
62
63
|
BROKERAGES = "/brokerages"
|
|
63
64
|
INSTITUTIONS = "/institutions"
|
|
@@ -68,4 +69,3 @@ class PathValues(str, enum.Enum):
|
|
|
68
69
|
SYMBOLS_QUERY = "/symbols/{query}"
|
|
69
70
|
ACCOUNTS_ACCOUNT_ID_TRADING_SIMPLE = "/accounts/{accountId}/trading/simple"
|
|
70
71
|
ACCOUNTS_ACCOUNT_ID_ORDERS_DETAILS_V2_BROKERAGE_ORDER_ID = "/accounts/{accountId}/orders/details/v2/{brokerageOrderId}"
|
|
71
|
-
ACCOUNTS_ACCOUNT_ID_ORDERS_BROKERAGE_ORDER_ID = "/accounts/{accountId}/orders/{brokerageOrderId}"
|
|
@@ -703,7 +703,7 @@ class GetAllAccountOrders(BaseApi, typing.Generic[TAuth]):
|
|
|
703
703
|
ApiResponseFor200,
|
|
704
704
|
api_client.ApiResponseWithoutDeserialization,
|
|
705
705
|
]:
|
|
706
|
-
""" Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`. Every order carries a `legs` list with at least one leg. Each leg's `instrument` uses the same `Instrument` union as positions; switch on `instrument.kind` to know which fields are present. Multi-leg orders (spreads, strangles, covered calls) are a single order with multiple legs. Orders that belong to a complex order group (OCO, OTO, OTOCO) share a `group.id`. `order_type` is an object discriminated by `kind`. Each kind declares the price fields it requires (`limit_price` on `limit`, `stop_price` on `stop`, both on `stop_limit`, `trail` on `trailing_stop`), so a consumer never has to null-check a price that cannot exist for that kind. When the brokerage reports an order type we cannot normalize, `kind` is `other` and the brokerage's own label is in `raw_type`. **
|
|
706
|
+
""" Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`. Every order carries a `legs` list with at least one leg. Each leg's `instrument` uses the same `Instrument` union as positions; switch on `instrument.kind` to know which fields are present. Multi-leg orders (spreads, strangles, covered calls) are a single order with multiple legs. Orders that belong to a complex order group (OCO, OTO, OTOCO) share a `group.id`. `order_type` is an object discriminated by `kind`. Each kind declares the price fields it requires (`limit_price` on `limit`, `stop_price` on `stop`, both on `stop_limit`, `trail` on `trailing_stop`), so a consumer never has to null-check a price that cannot exist for that kind. When the brokerage reports an order type we cannot normalize, `kind` is `other` and the brokerage's own label is in `raw_type`. **Beta:** this endpoint and its response schema may change. 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. """
|
|
707
707
|
args = self._get_all_account_orders_mapped_args(
|
|
708
708
|
query_params=query_params,
|
|
709
709
|
path_params=path_params,
|
|
@@ -770,7 +770,7 @@ class ApiForget(BaseApi, typing.Generic[TAuth]):
|
|
|
770
770
|
ApiResponseFor200,
|
|
771
771
|
api_client.ApiResponseWithoutDeserialization,
|
|
772
772
|
]:
|
|
773
|
-
""" Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`. Every order carries a `legs` list with at least one leg. Each leg's `instrument` uses the same `Instrument` union as positions; switch on `instrument.kind` to know which fields are present. Multi-leg orders (spreads, strangles, covered calls) are a single order with multiple legs. Orders that belong to a complex order group (OCO, OTO, OTOCO) share a `group.id`. `order_type` is an object discriminated by `kind`. Each kind declares the price fields it requires (`limit_price` on `limit`, `stop_price` on `stop`, both on `stop_limit`, `trail` on `trailing_stop`), so a consumer never has to null-check a price that cannot exist for that kind. When the brokerage reports an order type we cannot normalize, `kind` is `other` and the brokerage's own label is in `raw_type`. **
|
|
773
|
+
""" Returns a list of recent orders in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/positions/all`. Every order carries a `legs` list with at least one leg. Each leg's `instrument` uses the same `Instrument` union as positions; switch on `instrument.kind` to know which fields are present. Multi-leg orders (spreads, strangles, covered calls) are a single order with multiple legs. Orders that belong to a complex order group (OCO, OTO, OTOCO) share a `group.id`. `order_type` is an object discriminated by `kind`. Each kind declares the price fields it requires (`limit_price` on `limit`, `stop_price` on `stop`, both on `stop_limit`, `trail` on `trailing_stop`), so a consumer never has to null-check a price that cannot exist for that kind. When the brokerage reports an order type we cannot normalize, `kind` is `other` and the brokerage's own label is in `raw_type`. **Beta:** this endpoint and its response schema may change. 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. """
|
|
774
774
|
args = self._get_all_account_orders_mapped_args(
|
|
775
775
|
query_params=query_params,
|
|
776
776
|
path_params=path_params,
|
|
@@ -679,7 +679,7 @@ class GetAccountOrder(BaseApi, typing.Generic[TAuth]):
|
|
|
679
679
|
ApiResponseFor200,
|
|
680
680
|
api_client.ApiResponseWithoutDeserialization,
|
|
681
681
|
]:
|
|
682
|
-
""" Returns the detail of a single order, identified by the brokerage order ID in the path, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. The order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. Multi-leg orders are a single order with multiple legs. This endpoint is always realtime and does not rely on cached data, except that an order in a terminal state (executed, canceled, rejected, failed, expired, replaced) may be served from a short-lived cache since it can no longer change. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. **
|
|
682
|
+
""" Returns the detail of a single order, identified by the brokerage order ID in the path, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. The order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. Multi-leg orders are a single order with multiple legs. This endpoint is always realtime and does not rely on cached data, except that an order in a terminal state (executed, canceled, rejected, failed, expired, replaced) may be served from a short-lived cache since it can no longer change. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. **Beta:** this endpoint and its response schema may change. """
|
|
683
683
|
args = self._get_account_order_mapped_args(
|
|
684
684
|
path_params=path_params,
|
|
685
685
|
account_id=account_id,
|
|
@@ -740,7 +740,7 @@ class ApiForget(BaseApi, typing.Generic[TAuth]):
|
|
|
740
740
|
ApiResponseFor200,
|
|
741
741
|
api_client.ApiResponseWithoutDeserialization,
|
|
742
742
|
]:
|
|
743
|
-
""" Returns the detail of a single order, identified by the brokerage order ID in the path, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. The order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. Multi-leg orders are a single order with multiple legs. This endpoint is always realtime and does not rely on cached data, except that an order in a terminal state (executed, canceled, rejected, failed, expired, replaced) may be served from a short-lived cache since it can no longer change. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. **
|
|
743
|
+
""" Returns the detail of a single order, identified by the brokerage order ID in the path, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. The order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. Multi-leg orders are a single order with multiple legs. This endpoint is always realtime and does not rely on cached data, except that an order in a terminal state (executed, canceled, rejected, failed, expired, replaced) may be served from a short-lived cache since it can no longer change. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. **Beta:** this endpoint and its response schema may change. """
|
|
744
744
|
args = self._get_account_order_mapped_args(
|
|
745
745
|
path_params=path_params,
|
|
746
746
|
account_id=account_id,
|
|
@@ -700,7 +700,7 @@ class GetAllAccountRecentOrders(BaseApi, typing.Generic[TAuth]):
|
|
|
700
700
|
ApiResponseFor200,
|
|
701
701
|
api_client.ApiResponseWithoutDeserialization,
|
|
702
702
|
]:
|
|
703
|
-
""" A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. 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 `/accounts/{accountId}/orders/all` in that it is always realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. Every order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. `data_freshness.as_of` is the time of this live request. **
|
|
703
|
+
""" A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. 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 `/accounts/{accountId}/orders/all` in that it is always realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. Every order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. `data_freshness.as_of` is the time of this live request. **Beta:** this endpoint and its response schema may change. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** """
|
|
704
704
|
args = self._get_all_account_recent_orders_mapped_args(
|
|
705
705
|
query_params=query_params,
|
|
706
706
|
path_params=path_params,
|
|
@@ -763,7 +763,7 @@ class ApiForget(BaseApi, typing.Generic[TAuth]):
|
|
|
763
763
|
ApiResponseFor200,
|
|
764
764
|
api_client.ApiResponseWithoutDeserialization,
|
|
765
765
|
]:
|
|
766
|
-
""" A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. 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 `/accounts/{accountId}/orders/all` in that it is always realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. Every order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. `data_freshness.as_of` is the time of this live request. **
|
|
766
|
+
""" A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. 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 `/accounts/{accountId}/orders/all` in that it is always realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. Every order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. `data_freshness.as_of` is the time of this live request. **Beta:** this endpoint and its response schema may change. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)** """
|
|
767
767
|
args = self._get_all_account_recent_orders_mapped_args(
|
|
768
768
|
query_params=query_params,
|
|
769
769
|
path_params=path_params,
|