snaptrade-python-sdk 11.0.143__py3-none-any.whl → 11.0.145__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 +1 -1
- snaptrade_client/api_client.py +1 -1
- snaptrade_client/apis/path_to_api.py +6 -0
- snaptrade_client/apis/paths/accounts_account_id_orders_v2.py +7 -0
- snaptrade_client/apis/paths/accounts_account_id_recent_orders_v2.py +7 -0
- snaptrade_client/apis/tag_to_api.py +3 -0
- snaptrade_client/apis/tags/__init__.py +1 -0
- snaptrade_client/apis/tags/experimental_endpoints_api.py +6 -0
- snaptrade_client/apis/tags/experimental_endpoints_api_generated.py +23 -0
- snaptrade_client/client.py +2 -0
- snaptrade_client/client.pyi +2 -0
- snaptrade_client/configuration.py +1 -1
- snaptrade_client/model/account_order_record_leg.py +252 -0
- snaptrade_client/model/account_order_record_leg.pyi +252 -0
- snaptrade_client/model/account_order_record_leg_instrument.py +137 -0
- snaptrade_client/model/account_order_record_leg_instrument.pyi +137 -0
- snaptrade_client/model/account_order_record_status_v2.py +90 -0
- snaptrade_client/model/account_order_record_status_v2.pyi +75 -0
- snaptrade_client/model/account_order_record_status_v2_nullable.py +105 -0
- snaptrade_client/model/account_order_record_status_v2_nullable.pyi +105 -0
- snaptrade_client/model/account_order_record_v2.py +309 -0
- snaptrade_client/model/account_order_record_v2.pyi +309 -0
- snaptrade_client/model/account_orders_v2_response.py +110 -0
- snaptrade_client/model/account_orders_v2_response.pyi +110 -0
- snaptrade_client/model/action_strict_v2.py +25 -0
- snaptrade_client/model/action_strict_v2.pyi +25 -0
- snaptrade_client/models/__init__.py +7 -0
- snaptrade_client/operation_parameter_map.py +35 -0
- snaptrade_client/paths/__init__.py +2 -0
- snaptrade_client/paths/accounts/get.py +2 -2
- snaptrade_client/paths/accounts/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id/get.py +2 -2
- snaptrade_client/paths/accounts_account_id/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id_balances/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_balances/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id_holdings/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_holdings/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id_options/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_options/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id_orders/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_orders/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id_orders_v2/__init__.py +7 -0
- snaptrade_client/paths/accounts_account_id_orders_v2/get.py +592 -0
- snaptrade_client/paths/accounts_account_id_orders_v2/get.pyi +569 -0
- snaptrade_client/paths/accounts_account_id_positions/get.py +2 -2
- snaptrade_client/paths/accounts_account_id_positions/get.pyi +2 -2
- snaptrade_client/paths/accounts_account_id_recent_orders_v2/__init__.py +7 -0
- snaptrade_client/paths/accounts_account_id_recent_orders_v2/get.py +561 -0
- snaptrade_client/paths/accounts_account_id_recent_orders_v2/get.pyi +549 -0
- snaptrade_client/paths/authorizations_authorization_id_refresh/post.py +2 -2
- snaptrade_client/paths/authorizations_authorization_id_refresh/post.pyi +2 -2
- snaptrade_client/type/account_order_record_leg.py +48 -0
- snaptrade_client/type/account_order_record_leg_instrument.py +39 -0
- snaptrade_client/type/account_order_record_status_v2.py +19 -0
- snaptrade_client/type/account_order_record_status_v2_nullable.py +19 -0
- snaptrade_client/type/account_order_record_v2.py +58 -0
- snaptrade_client/type/account_orders_v2_response.py +28 -0
- snaptrade_client/type/action_strict_v2.py +19 -0
- {snaptrade_python_sdk-11.0.143.dist-info → snaptrade_python_sdk-11.0.145.dist-info}/METADATA +124 -11
- {snaptrade_python_sdk-11.0.143.dist-info → snaptrade_python_sdk-11.0.145.dist-info}/RECORD +62 -31
- {snaptrade_python_sdk-11.0.143.dist-info → snaptrade_python_sdk-11.0.145.dist-info}/LICENSE +0 -0
- {snaptrade_python_sdk-11.0.143.dist-info → snaptrade_python_sdk-11.0.145.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
SnapTrade
|
|
5
|
+
|
|
6
|
+
Connect brokerage accounts to your app for live positions and trading
|
|
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 typing_extensions
|
|
15
|
+
import urllib3
|
|
16
|
+
from snaptrade_client.request_before_hook import request_before_hook
|
|
17
|
+
import json
|
|
18
|
+
from urllib3._collections import HTTPHeaderDict
|
|
19
|
+
|
|
20
|
+
from snaptrade_client.api_response import AsyncGeneratorResponse
|
|
21
|
+
from snaptrade_client import api_client, exceptions
|
|
22
|
+
from datetime import date, datetime # noqa: F401
|
|
23
|
+
import decimal # noqa: F401
|
|
24
|
+
import functools # noqa: F401
|
|
25
|
+
import io # noqa: F401
|
|
26
|
+
import re # noqa: F401
|
|
27
|
+
import typing # noqa: F401
|
|
28
|
+
import typing_extensions # noqa: F401
|
|
29
|
+
import uuid # noqa: F401
|
|
30
|
+
|
|
31
|
+
import frozendict # noqa: F401
|
|
32
|
+
|
|
33
|
+
from snaptrade_client import schemas # noqa: F401
|
|
34
|
+
|
|
35
|
+
from snaptrade_client.model.account_orders_v2_response import AccountOrdersV2Response as AccountOrdersV2ResponseSchema
|
|
36
|
+
from snaptrade_client.model.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse as Model500UnexpectedExceptionResponseSchema
|
|
37
|
+
from snaptrade_client.model.model403_feature_not_enabled_response import Model403FeatureNotEnabledResponse as Model403FeatureNotEnabledResponseSchema
|
|
38
|
+
|
|
39
|
+
from snaptrade_client.type.account_orders_v2_response import AccountOrdersV2Response
|
|
40
|
+
from snaptrade_client.type.model403_feature_not_enabled_response import Model403FeatureNotEnabledResponse
|
|
41
|
+
from snaptrade_client.type.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse
|
|
42
|
+
|
|
43
|
+
# Query params
|
|
44
|
+
UserIdSchema = schemas.StrSchema
|
|
45
|
+
UserSecretSchema = schemas.StrSchema
|
|
46
|
+
OnlyExecutedSchema = schemas.BoolSchema
|
|
47
|
+
RequestRequiredQueryParams = typing_extensions.TypedDict(
|
|
48
|
+
'RequestRequiredQueryParams',
|
|
49
|
+
{
|
|
50
|
+
'userId': typing.Union[UserIdSchema, str, ],
|
|
51
|
+
'userSecret': typing.Union[UserSecretSchema, str, ],
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
RequestOptionalQueryParams = typing_extensions.TypedDict(
|
|
55
|
+
'RequestOptionalQueryParams',
|
|
56
|
+
{
|
|
57
|
+
'only_executed': typing.Union[OnlyExecutedSchema, bool, ],
|
|
58
|
+
},
|
|
59
|
+
total=False
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
request_query_user_id = api_client.QueryParameter(
|
|
68
|
+
name="userId",
|
|
69
|
+
style=api_client.ParameterStyle.FORM,
|
|
70
|
+
schema=UserIdSchema,
|
|
71
|
+
required=True,
|
|
72
|
+
explode=True,
|
|
73
|
+
)
|
|
74
|
+
request_query_user_secret = api_client.QueryParameter(
|
|
75
|
+
name="userSecret",
|
|
76
|
+
style=api_client.ParameterStyle.FORM,
|
|
77
|
+
schema=UserSecretSchema,
|
|
78
|
+
required=True,
|
|
79
|
+
explode=True,
|
|
80
|
+
)
|
|
81
|
+
request_query_only_executed = api_client.QueryParameter(
|
|
82
|
+
name="only_executed",
|
|
83
|
+
style=api_client.ParameterStyle.FORM,
|
|
84
|
+
schema=OnlyExecutedSchema,
|
|
85
|
+
explode=True,
|
|
86
|
+
)
|
|
87
|
+
# Path params
|
|
88
|
+
AccountIdSchema = schemas.UUIDSchema
|
|
89
|
+
RequestRequiredPathParams = typing_extensions.TypedDict(
|
|
90
|
+
'RequestRequiredPathParams',
|
|
91
|
+
{
|
|
92
|
+
'accountId': typing.Union[AccountIdSchema, str, uuid.UUID, ],
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
RequestOptionalPathParams = typing_extensions.TypedDict(
|
|
96
|
+
'RequestOptionalPathParams',
|
|
97
|
+
{
|
|
98
|
+
},
|
|
99
|
+
total=False
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams):
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
request_path_account_id = api_client.PathParameter(
|
|
108
|
+
name="accountId",
|
|
109
|
+
style=api_client.ParameterStyle.SIMPLE,
|
|
110
|
+
schema=AccountIdSchema,
|
|
111
|
+
required=True,
|
|
112
|
+
)
|
|
113
|
+
SchemaFor200ResponseBodyApplicationJson = AccountOrdersV2ResponseSchema
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@dataclass
|
|
117
|
+
class ApiResponseFor200(api_client.ApiResponse):
|
|
118
|
+
body: AccountOrdersV2Response
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@dataclass
|
|
122
|
+
class ApiResponseFor200Async(api_client.AsyncApiResponse):
|
|
123
|
+
body: AccountOrdersV2Response
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
_response_for_200 = api_client.OpenApiResponse(
|
|
127
|
+
response_cls=ApiResponseFor200,
|
|
128
|
+
response_cls_async=ApiResponseFor200Async,
|
|
129
|
+
content={
|
|
130
|
+
'application/json': api_client.MediaType(
|
|
131
|
+
schema=SchemaFor200ResponseBodyApplicationJson),
|
|
132
|
+
},
|
|
133
|
+
)
|
|
134
|
+
SchemaFor403ResponseBodyApplicationJson = Model403FeatureNotEnabledResponseSchema
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass
|
|
138
|
+
class ApiResponseFor403(api_client.ApiResponse):
|
|
139
|
+
body: Model403FeatureNotEnabledResponse
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@dataclass
|
|
143
|
+
class ApiResponseFor403Async(api_client.AsyncApiResponse):
|
|
144
|
+
body: Model403FeatureNotEnabledResponse
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
_response_for_403 = api_client.OpenApiResponse(
|
|
148
|
+
response_cls=ApiResponseFor403,
|
|
149
|
+
response_cls_async=ApiResponseFor403Async,
|
|
150
|
+
content={
|
|
151
|
+
'application/json': api_client.MediaType(
|
|
152
|
+
schema=SchemaFor403ResponseBodyApplicationJson),
|
|
153
|
+
},
|
|
154
|
+
)
|
|
155
|
+
SchemaFor500ResponseBodyApplicationJson = Model500UnexpectedExceptionResponseSchema
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@dataclass
|
|
159
|
+
class ApiResponseFor500(api_client.ApiResponse):
|
|
160
|
+
body: Model500UnexpectedExceptionResponse
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@dataclass
|
|
164
|
+
class ApiResponseFor500Async(api_client.AsyncApiResponse):
|
|
165
|
+
body: Model500UnexpectedExceptionResponse
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
_response_for_500 = api_client.OpenApiResponse(
|
|
169
|
+
response_cls=ApiResponseFor500,
|
|
170
|
+
response_cls_async=ApiResponseFor500Async,
|
|
171
|
+
content={
|
|
172
|
+
'application/json': api_client.MediaType(
|
|
173
|
+
schema=SchemaFor500ResponseBodyApplicationJson),
|
|
174
|
+
},
|
|
175
|
+
)
|
|
176
|
+
_all_accept_content_types = (
|
|
177
|
+
'application/json',
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class BaseApi(api_client.Api):
|
|
182
|
+
|
|
183
|
+
def _get_user_account_recent_orders_v2_mapped_args(
|
|
184
|
+
self,
|
|
185
|
+
user_id: typing.Optional[str] = None,
|
|
186
|
+
user_secret: typing.Optional[str] = None,
|
|
187
|
+
account_id: typing.Optional[str] = None,
|
|
188
|
+
only_executed: typing.Optional[bool] = None,
|
|
189
|
+
query_params: typing.Optional[dict] = {},
|
|
190
|
+
path_params: typing.Optional[dict] = {},
|
|
191
|
+
) -> api_client.MappedArgs:
|
|
192
|
+
args: api_client.MappedArgs = api_client.MappedArgs()
|
|
193
|
+
_query_params = {}
|
|
194
|
+
_path_params = {}
|
|
195
|
+
if user_id is not None:
|
|
196
|
+
_query_params["userId"] = user_id
|
|
197
|
+
if user_secret is not None:
|
|
198
|
+
_query_params["userSecret"] = user_secret
|
|
199
|
+
if only_executed is not None:
|
|
200
|
+
_query_params["only_executed"] = only_executed
|
|
201
|
+
if account_id is not None:
|
|
202
|
+
_path_params["accountId"] = account_id
|
|
203
|
+
args.query = query_params if query_params else _query_params
|
|
204
|
+
args.path = path_params if path_params else _path_params
|
|
205
|
+
return args
|
|
206
|
+
|
|
207
|
+
async def _aget_user_account_recent_orders_v2_oapg(
|
|
208
|
+
self,
|
|
209
|
+
query_params: typing.Optional[dict] = {},
|
|
210
|
+
path_params: typing.Optional[dict] = {},
|
|
211
|
+
skip_deserialization: bool = True,
|
|
212
|
+
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
213
|
+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
214
|
+
stream: bool = False,
|
|
215
|
+
**kwargs,
|
|
216
|
+
) -> typing.Union[
|
|
217
|
+
ApiResponseFor200Async,
|
|
218
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
219
|
+
AsyncGeneratorResponse,
|
|
220
|
+
]:
|
|
221
|
+
"""
|
|
222
|
+
List account recent orders (V2, last 24 hours only)
|
|
223
|
+
:param skip_deserialization: If true then api_response.response will be set but
|
|
224
|
+
api_response.body and api_response.headers will not be deserialized into schema
|
|
225
|
+
class instances
|
|
226
|
+
"""
|
|
227
|
+
self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
|
|
228
|
+
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
229
|
+
used_path = path.value
|
|
230
|
+
|
|
231
|
+
_path_params = {}
|
|
232
|
+
for parameter in (
|
|
233
|
+
request_path_account_id,
|
|
234
|
+
):
|
|
235
|
+
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
236
|
+
if parameter_data is schemas.unset:
|
|
237
|
+
continue
|
|
238
|
+
serialized_data = parameter.serialize(parameter_data)
|
|
239
|
+
_path_params.update(serialized_data)
|
|
240
|
+
|
|
241
|
+
for k, v in _path_params.items():
|
|
242
|
+
used_path = used_path.replace('{%s}' % k, v)
|
|
243
|
+
|
|
244
|
+
prefix_separator_iterator = None
|
|
245
|
+
for parameter in (
|
|
246
|
+
request_query_user_id,
|
|
247
|
+
request_query_user_secret,
|
|
248
|
+
request_query_only_executed,
|
|
249
|
+
):
|
|
250
|
+
parameter_data = query_params.get(parameter.name, schemas.unset)
|
|
251
|
+
if parameter_data is schemas.unset:
|
|
252
|
+
continue
|
|
253
|
+
if prefix_separator_iterator is None:
|
|
254
|
+
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
|
255
|
+
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
|
256
|
+
for serialized_value in serialized_data.values():
|
|
257
|
+
used_path += serialized_value
|
|
258
|
+
|
|
259
|
+
_headers = HTTPHeaderDict()
|
|
260
|
+
# TODO add cookie handling
|
|
261
|
+
if accept_content_types:
|
|
262
|
+
for accept_content_type in accept_content_types:
|
|
263
|
+
_headers.add('Accept', accept_content_type)
|
|
264
|
+
method = 'get'.upper()
|
|
265
|
+
request_before_hook(
|
|
266
|
+
resource_path=used_path,
|
|
267
|
+
method=method,
|
|
268
|
+
configuration=self.api_client.configuration,
|
|
269
|
+
path_template='/accounts/{accountId}/recentOrders/v2',
|
|
270
|
+
auth_settings=_auth,
|
|
271
|
+
headers=_headers,
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
response = await self.api_client.async_call_api(
|
|
275
|
+
resource_path=used_path,
|
|
276
|
+
method=method,
|
|
277
|
+
headers=_headers,
|
|
278
|
+
auth_settings=_auth,
|
|
279
|
+
prefix_separator_iterator=prefix_separator_iterator,
|
|
280
|
+
timeout=timeout,
|
|
281
|
+
**kwargs
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
if stream:
|
|
285
|
+
if not 200 <= response.http_response.status <= 299:
|
|
286
|
+
body = (await response.http_response.content.read()).decode("utf-8")
|
|
287
|
+
raise exceptions.ApiStreamingException(
|
|
288
|
+
status=response.http_response.status,
|
|
289
|
+
reason=response.http_response.reason,
|
|
290
|
+
body=body,
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
async def stream_iterator():
|
|
294
|
+
"""
|
|
295
|
+
iterates over response.http_response.content and closes connection once iteration has finished
|
|
296
|
+
"""
|
|
297
|
+
async for line in response.http_response.content:
|
|
298
|
+
if line == b'\r\n':
|
|
299
|
+
continue
|
|
300
|
+
yield line
|
|
301
|
+
response.http_response.close()
|
|
302
|
+
await response.session.close()
|
|
303
|
+
return AsyncGeneratorResponse(
|
|
304
|
+
content=stream_iterator(),
|
|
305
|
+
headers=response.http_response.headers,
|
|
306
|
+
status=response.http_response.status,
|
|
307
|
+
response=response.http_response
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
311
|
+
if response_for_status:
|
|
312
|
+
api_response = await response_for_status.deserialize_async(
|
|
313
|
+
response,
|
|
314
|
+
self.api_client.configuration,
|
|
315
|
+
skip_deserialization=skip_deserialization
|
|
316
|
+
)
|
|
317
|
+
else:
|
|
318
|
+
# If response data is JSON then deserialize for SDK consumer convenience
|
|
319
|
+
is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
|
|
320
|
+
api_response = api_client.ApiResponseWithoutDeserializationAsync(
|
|
321
|
+
body=await response.http_response.json() if is_json else await response.http_response.text(),
|
|
322
|
+
response=response.http_response,
|
|
323
|
+
round_trip_time=response.round_trip_time,
|
|
324
|
+
status=response.http_response.status,
|
|
325
|
+
headers=response.http_response.headers,
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
if not 200 <= api_response.status <= 299:
|
|
329
|
+
raise exceptions.ApiException(api_response=api_response)
|
|
330
|
+
|
|
331
|
+
# cleanup session / response
|
|
332
|
+
response.http_response.close()
|
|
333
|
+
await response.session.close()
|
|
334
|
+
|
|
335
|
+
return api_response
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _get_user_account_recent_orders_v2_oapg(
|
|
339
|
+
self,
|
|
340
|
+
query_params: typing.Optional[dict] = {},
|
|
341
|
+
path_params: typing.Optional[dict] = {},
|
|
342
|
+
skip_deserialization: bool = True,
|
|
343
|
+
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
344
|
+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
345
|
+
stream: bool = False,
|
|
346
|
+
) -> typing.Union[
|
|
347
|
+
ApiResponseFor200,
|
|
348
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
349
|
+
]:
|
|
350
|
+
"""
|
|
351
|
+
List account recent orders (V2, last 24 hours only)
|
|
352
|
+
:param skip_deserialization: If true then api_response.response will be set but
|
|
353
|
+
api_response.body and api_response.headers will not be deserialized into schema
|
|
354
|
+
class instances
|
|
355
|
+
"""
|
|
356
|
+
self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
|
|
357
|
+
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
358
|
+
used_path = path.value
|
|
359
|
+
|
|
360
|
+
_path_params = {}
|
|
361
|
+
for parameter in (
|
|
362
|
+
request_path_account_id,
|
|
363
|
+
):
|
|
364
|
+
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
365
|
+
if parameter_data is schemas.unset:
|
|
366
|
+
continue
|
|
367
|
+
serialized_data = parameter.serialize(parameter_data)
|
|
368
|
+
_path_params.update(serialized_data)
|
|
369
|
+
|
|
370
|
+
for k, v in _path_params.items():
|
|
371
|
+
used_path = used_path.replace('{%s}' % k, v)
|
|
372
|
+
|
|
373
|
+
prefix_separator_iterator = None
|
|
374
|
+
for parameter in (
|
|
375
|
+
request_query_user_id,
|
|
376
|
+
request_query_user_secret,
|
|
377
|
+
request_query_only_executed,
|
|
378
|
+
):
|
|
379
|
+
parameter_data = query_params.get(parameter.name, schemas.unset)
|
|
380
|
+
if parameter_data is schemas.unset:
|
|
381
|
+
continue
|
|
382
|
+
if prefix_separator_iterator is None:
|
|
383
|
+
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
|
384
|
+
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
|
385
|
+
for serialized_value in serialized_data.values():
|
|
386
|
+
used_path += serialized_value
|
|
387
|
+
|
|
388
|
+
_headers = HTTPHeaderDict()
|
|
389
|
+
# TODO add cookie handling
|
|
390
|
+
if accept_content_types:
|
|
391
|
+
for accept_content_type in accept_content_types:
|
|
392
|
+
_headers.add('Accept', accept_content_type)
|
|
393
|
+
method = 'get'.upper()
|
|
394
|
+
request_before_hook(
|
|
395
|
+
resource_path=used_path,
|
|
396
|
+
method=method,
|
|
397
|
+
configuration=self.api_client.configuration,
|
|
398
|
+
path_template='/accounts/{accountId}/recentOrders/v2',
|
|
399
|
+
auth_settings=_auth,
|
|
400
|
+
headers=_headers,
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
response = self.api_client.call_api(
|
|
404
|
+
resource_path=used_path,
|
|
405
|
+
method=method,
|
|
406
|
+
headers=_headers,
|
|
407
|
+
auth_settings=_auth,
|
|
408
|
+
prefix_separator_iterator=prefix_separator_iterator,
|
|
409
|
+
timeout=timeout,
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
413
|
+
if response_for_status:
|
|
414
|
+
api_response = response_for_status.deserialize(
|
|
415
|
+
response,
|
|
416
|
+
self.api_client.configuration,
|
|
417
|
+
skip_deserialization=skip_deserialization
|
|
418
|
+
)
|
|
419
|
+
else:
|
|
420
|
+
# If response data is JSON then deserialize for SDK consumer convenience
|
|
421
|
+
is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
|
|
422
|
+
api_response = api_client.ApiResponseWithoutDeserialization(
|
|
423
|
+
body=json.loads(response.http_response.data) if is_json else response.http_response.data,
|
|
424
|
+
response=response.http_response,
|
|
425
|
+
round_trip_time=response.round_trip_time,
|
|
426
|
+
status=response.http_response.status,
|
|
427
|
+
headers=response.http_response.headers,
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
if not 200 <= api_response.status <= 299:
|
|
431
|
+
raise exceptions.ApiException(api_response=api_response)
|
|
432
|
+
|
|
433
|
+
return api_response
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
class GetUserAccountRecentOrdersV2(BaseApi):
|
|
437
|
+
# this class is used by api classes that refer to endpoints with operationId fn names
|
|
438
|
+
|
|
439
|
+
async def aget_user_account_recent_orders_v2(
|
|
440
|
+
self,
|
|
441
|
+
user_id: typing.Optional[str] = None,
|
|
442
|
+
user_secret: typing.Optional[str] = None,
|
|
443
|
+
account_id: typing.Optional[str] = None,
|
|
444
|
+
only_executed: typing.Optional[bool] = None,
|
|
445
|
+
query_params: typing.Optional[dict] = {},
|
|
446
|
+
path_params: typing.Optional[dict] = {},
|
|
447
|
+
**kwargs,
|
|
448
|
+
) -> typing.Union[
|
|
449
|
+
ApiResponseFor200Async,
|
|
450
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
451
|
+
AsyncGeneratorResponse,
|
|
452
|
+
]:
|
|
453
|
+
args = self._get_user_account_recent_orders_v2_mapped_args(
|
|
454
|
+
query_params=query_params,
|
|
455
|
+
path_params=path_params,
|
|
456
|
+
user_id=user_id,
|
|
457
|
+
user_secret=user_secret,
|
|
458
|
+
account_id=account_id,
|
|
459
|
+
only_executed=only_executed,
|
|
460
|
+
)
|
|
461
|
+
return await self._aget_user_account_recent_orders_v2_oapg(
|
|
462
|
+
query_params=args.query,
|
|
463
|
+
path_params=args.path,
|
|
464
|
+
**kwargs,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
def get_user_account_recent_orders_v2(
|
|
468
|
+
self,
|
|
469
|
+
user_id: typing.Optional[str] = None,
|
|
470
|
+
user_secret: typing.Optional[str] = None,
|
|
471
|
+
account_id: typing.Optional[str] = None,
|
|
472
|
+
only_executed: typing.Optional[bool] = None,
|
|
473
|
+
query_params: typing.Optional[dict] = {},
|
|
474
|
+
path_params: typing.Optional[dict] = {},
|
|
475
|
+
) -> typing.Union[
|
|
476
|
+
ApiResponseFor200,
|
|
477
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
478
|
+
]:
|
|
479
|
+
""" A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is 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. **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)** """
|
|
480
|
+
args = self._get_user_account_recent_orders_v2_mapped_args(
|
|
481
|
+
query_params=query_params,
|
|
482
|
+
path_params=path_params,
|
|
483
|
+
user_id=user_id,
|
|
484
|
+
user_secret=user_secret,
|
|
485
|
+
account_id=account_id,
|
|
486
|
+
only_executed=only_executed,
|
|
487
|
+
)
|
|
488
|
+
return self._get_user_account_recent_orders_v2_oapg(
|
|
489
|
+
query_params=args.query,
|
|
490
|
+
path_params=args.path,
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
class ApiForget(BaseApi):
|
|
494
|
+
# this class is used by api classes that refer to endpoints by path and http method names
|
|
495
|
+
|
|
496
|
+
async def aget(
|
|
497
|
+
self,
|
|
498
|
+
user_id: typing.Optional[str] = None,
|
|
499
|
+
user_secret: typing.Optional[str] = None,
|
|
500
|
+
account_id: typing.Optional[str] = None,
|
|
501
|
+
only_executed: typing.Optional[bool] = None,
|
|
502
|
+
query_params: typing.Optional[dict] = {},
|
|
503
|
+
path_params: typing.Optional[dict] = {},
|
|
504
|
+
**kwargs,
|
|
505
|
+
) -> typing.Union[
|
|
506
|
+
ApiResponseFor200Async,
|
|
507
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
508
|
+
AsyncGeneratorResponse,
|
|
509
|
+
]:
|
|
510
|
+
args = self._get_user_account_recent_orders_v2_mapped_args(
|
|
511
|
+
query_params=query_params,
|
|
512
|
+
path_params=path_params,
|
|
513
|
+
user_id=user_id,
|
|
514
|
+
user_secret=user_secret,
|
|
515
|
+
account_id=account_id,
|
|
516
|
+
only_executed=only_executed,
|
|
517
|
+
)
|
|
518
|
+
return await self._aget_user_account_recent_orders_v2_oapg(
|
|
519
|
+
query_params=args.query,
|
|
520
|
+
path_params=args.path,
|
|
521
|
+
**kwargs,
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
def get(
|
|
525
|
+
self,
|
|
526
|
+
user_id: typing.Optional[str] = None,
|
|
527
|
+
user_secret: typing.Optional[str] = None,
|
|
528
|
+
account_id: typing.Optional[str] = None,
|
|
529
|
+
only_executed: typing.Optional[bool] = None,
|
|
530
|
+
query_params: typing.Optional[dict] = {},
|
|
531
|
+
path_params: typing.Optional[dict] = {},
|
|
532
|
+
) -> typing.Union[
|
|
533
|
+
ApiResponseFor200,
|
|
534
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
535
|
+
]:
|
|
536
|
+
""" A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is 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. **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)** """
|
|
537
|
+
args = self._get_user_account_recent_orders_v2_mapped_args(
|
|
538
|
+
query_params=query_params,
|
|
539
|
+
path_params=path_params,
|
|
540
|
+
user_id=user_id,
|
|
541
|
+
user_secret=user_secret,
|
|
542
|
+
account_id=account_id,
|
|
543
|
+
only_executed=only_executed,
|
|
544
|
+
)
|
|
545
|
+
return self._get_user_account_recent_orders_v2_oapg(
|
|
546
|
+
query_params=args.query,
|
|
547
|
+
path_params=args.path,
|
|
548
|
+
)
|
|
549
|
+
|
|
@@ -520,7 +520,7 @@ class RefreshBrokerageAuthorization(BaseApi):
|
|
|
520
520
|
ApiResponseFor200,
|
|
521
521
|
api_client.ApiResponseWithoutDeserialization,
|
|
522
522
|
]:
|
|
523
|
-
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **
|
|
523
|
+
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, 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)** """
|
|
524
524
|
args = self._refresh_brokerage_authorization_mapped_args(
|
|
525
525
|
query_params=query_params,
|
|
526
526
|
path_params=path_params,
|
|
@@ -573,7 +573,7 @@ class ApiForpost(BaseApi):
|
|
|
573
573
|
ApiResponseFor200,
|
|
574
574
|
api_client.ApiResponseWithoutDeserialization,
|
|
575
575
|
]:
|
|
576
|
-
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **
|
|
576
|
+
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, 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)** """
|
|
577
577
|
args = self._refresh_brokerage_authorization_mapped_args(
|
|
578
578
|
query_params=query_params,
|
|
579
579
|
path_params=path_params,
|
|
@@ -506,7 +506,7 @@ class RefreshBrokerageAuthorization(BaseApi):
|
|
|
506
506
|
ApiResponseFor200,
|
|
507
507
|
api_client.ApiResponseWithoutDeserialization,
|
|
508
508
|
]:
|
|
509
|
-
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **
|
|
509
|
+
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, 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)** """
|
|
510
510
|
args = self._refresh_brokerage_authorization_mapped_args(
|
|
511
511
|
query_params=query_params,
|
|
512
512
|
path_params=path_params,
|
|
@@ -559,7 +559,7 @@ class ApiForpost(BaseApi):
|
|
|
559
559
|
ApiResponseFor200,
|
|
560
560
|
api_client.ApiResponseWithoutDeserialization,
|
|
561
561
|
]:
|
|
562
|
-
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **
|
|
562
|
+
""" Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [`ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred. **Because of the cost of refreshing a connection, 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)** """
|
|
563
563
|
args = self._refresh_brokerage_authorization_mapped_args(
|
|
564
564
|
query_params=query_params,
|
|
565
565
|
path_params=path_params,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
SnapTrade
|
|
5
|
+
|
|
6
|
+
Connect brokerage accounts to your app for live positions and trading
|
|
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 datetime import datetime, date
|
|
14
|
+
import typing
|
|
15
|
+
from enum import Enum
|
|
16
|
+
from typing_extensions import TypedDict, Literal, TYPE_CHECKING
|
|
17
|
+
|
|
18
|
+
from snaptrade_client.type.account_order_record_leg_instrument import AccountOrderRecordLegInstrument
|
|
19
|
+
from snaptrade_client.type.account_order_record_status_v2_nullable import AccountOrderRecordStatusV2Nullable
|
|
20
|
+
|
|
21
|
+
class RequiredAccountOrderRecordLeg(TypedDict):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
class OptionalAccountOrderRecordLeg(TypedDict, total=False):
|
|
25
|
+
# Brokerage order identifier for this leg, if available.
|
|
26
|
+
leg_id: typing.Optional[str]
|
|
27
|
+
|
|
28
|
+
instrument: AccountOrderRecordLegInstrument
|
|
29
|
+
|
|
30
|
+
# The action describes the intent or side of a trade. - BUY - SELL - BUY_COVER - SELL_SHORT - BUY_TO_OPEN - BUY_TO_CLOSE - SELL_TO_OPEN - SELL_TO_CLOSE
|
|
31
|
+
action: str
|
|
32
|
+
|
|
33
|
+
# Execution price for this leg, if available.
|
|
34
|
+
execution_price: typing.Optional[typing.Union[int, float]]
|
|
35
|
+
|
|
36
|
+
# The total number of shares or contracts associated with this leg. Can be a decimal number for fractional shares.
|
|
37
|
+
total_quantity: typing.Optional[str]
|
|
38
|
+
|
|
39
|
+
# The number of shares or contracts that have been canceled for this leg.
|
|
40
|
+
canceled_quantity: typing.Optional[str]
|
|
41
|
+
|
|
42
|
+
# The number of shares or contracts that have been filled for this leg.
|
|
43
|
+
filled_quantity: typing.Optional[str]
|
|
44
|
+
|
|
45
|
+
status: typing.Optional[AccountOrderRecordStatusV2Nullable]
|
|
46
|
+
|
|
47
|
+
class AccountOrderRecordLeg(RequiredAccountOrderRecordLeg, OptionalAccountOrderRecordLeg):
|
|
48
|
+
pass
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
SnapTrade
|
|
5
|
+
|
|
6
|
+
Connect brokerage accounts to your app for live positions and trading
|
|
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 datetime import datetime, date
|
|
14
|
+
import typing
|
|
15
|
+
from enum import Enum
|
|
16
|
+
from typing_extensions import TypedDict, Literal, TYPE_CHECKING
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RequiredAccountOrderRecordLegInstrument(TypedDict):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
class OptionalAccountOrderRecordLegInstrument(TypedDict, total=False):
|
|
23
|
+
# The symbol or ticker for the security.
|
|
24
|
+
symbol: str
|
|
25
|
+
|
|
26
|
+
# Human-readable description of the security.
|
|
27
|
+
description: str
|
|
28
|
+
|
|
29
|
+
# Type of instrument for the leg. - EQUITY - OPTION - CRYPTO
|
|
30
|
+
asset_type: str
|
|
31
|
+
|
|
32
|
+
# Market Identifier Code (MIC) for the exchange on which the instrument trades.
|
|
33
|
+
exchange_mic_code: str
|
|
34
|
+
|
|
35
|
+
# Financial Instrument Global Identifier (FIGI) if available.
|
|
36
|
+
figi_code: typing.Optional[str]
|
|
37
|
+
|
|
38
|
+
class AccountOrderRecordLegInstrument(RequiredAccountOrderRecordLegInstrument, OptionalAccountOrderRecordLegInstrument):
|
|
39
|
+
pass
|