snaptrade-python-sdk 11.0.115__py3-none-any.whl → 11.0.117__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 -3
- snaptrade_client/apis/paths/accounts_account_id_trading_cancel.py +7 -0
- snaptrade_client/apis/paths/brokerages_brokerage_id_instruments.py +7 -0
- snaptrade_client/apis/tags/reference_data_api_generated.py +2 -0
- snaptrade_client/apis/tags/trading_api_generated.py +1 -1
- snaptrade_client/configuration.py +1 -1
- snaptrade_client/model/brokerage_id.py +25 -0
- snaptrade_client/model/brokerage_id.pyi +25 -0
- snaptrade_client/model/brokerage_instrument.py +197 -0
- snaptrade_client/model/brokerage_instrument.pyi +197 -0
- snaptrade_client/model/brokerage_instruments_response.py +103 -0
- snaptrade_client/model/brokerage_instruments_response.pyi +103 -0
- snaptrade_client/model/cancel_order_response.py +96 -0
- snaptrade_client/model/cancel_order_response.pyi +96 -0
- snaptrade_client/model/cancel_order_response_raw_response.py +62 -0
- snaptrade_client/model/cancel_order_response_raw_response.pyi +62 -0
- snaptrade_client/models/__init__.py +5 -0
- snaptrade_client/operation_parameter_map.py +9 -2
- snaptrade_client/paths/__init__.py +2 -1
- snaptrade_client/paths/{accounts_account_id_trading_simple_brokerage_order_id_cancel → accounts_account_id_trading_cancel}/__init__.py +2 -2
- snaptrade_client/paths/{accounts_account_id_trading_simple_brokerage_order_id_cancel → accounts_account_id_trading_cancel}/post.py +120 -19
- snaptrade_client/paths/{accounts_account_id_trading_simple_brokerage_order_id_cancel → accounts_account_id_trading_cancel}/post.pyi +120 -19
- snaptrade_client/paths/brokerages_brokerage_id_instruments/__init__.py +7 -0
- snaptrade_client/paths/brokerages_brokerage_id_instruments/get.py +417 -0
- snaptrade_client/paths/brokerages_brokerage_id_instruments/get.pyi +406 -0
- snaptrade_client/type/brokerage_id.py +19 -0
- snaptrade_client/type/brokerage_instrument.py +39 -0
- snaptrade_client/type/brokerage_instruments_response.py +27 -0
- snaptrade_client/type/cancel_order_response.py +29 -0
- snaptrade_client/type/cancel_order_response_raw_response.py +19 -0
- {snaptrade_python_sdk-11.0.115.dist-info → snaptrade_python_sdk-11.0.117.dist-info}/METADATA +41 -5
- {snaptrade_python_sdk-11.0.115.dist-info → snaptrade_python_sdk-11.0.117.dist-info}/RECORD +36 -17
- snaptrade_client/apis/paths/accounts_account_id_trading_simple_brokerage_order_id_cancel.py +0 -7
- {snaptrade_python_sdk-11.0.115.dist-info → snaptrade_python_sdk-11.0.117.dist-info}/LICENSE +0 -0
- {snaptrade_python_sdk-11.0.115.dist-info → snaptrade_python_sdk-11.0.117.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,417 @@
|
|
|
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.brokerage_instruments_response import BrokerageInstrumentsResponse as BrokerageInstrumentsResponseSchema
|
|
36
|
+
|
|
37
|
+
from snaptrade_client.type.brokerage_instruments_response import BrokerageInstrumentsResponse
|
|
38
|
+
|
|
39
|
+
from . import path
|
|
40
|
+
|
|
41
|
+
# Path params
|
|
42
|
+
BrokerageIdSchema = schemas.UUIDSchema
|
|
43
|
+
RequestRequiredPathParams = typing_extensions.TypedDict(
|
|
44
|
+
'RequestRequiredPathParams',
|
|
45
|
+
{
|
|
46
|
+
'brokerageId': typing.Union[BrokerageIdSchema, str, uuid.UUID, ],
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
RequestOptionalPathParams = typing_extensions.TypedDict(
|
|
50
|
+
'RequestOptionalPathParams',
|
|
51
|
+
{
|
|
52
|
+
},
|
|
53
|
+
total=False
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams):
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
request_path_brokerage_id = api_client.PathParameter(
|
|
62
|
+
name="brokerageId",
|
|
63
|
+
style=api_client.ParameterStyle.SIMPLE,
|
|
64
|
+
schema=BrokerageIdSchema,
|
|
65
|
+
required=True,
|
|
66
|
+
)
|
|
67
|
+
_auth = [
|
|
68
|
+
'PartnerClientId',
|
|
69
|
+
'PartnerSignature',
|
|
70
|
+
'PartnerTimestamp',
|
|
71
|
+
]
|
|
72
|
+
SchemaFor200ResponseBodyApplicationJson = BrokerageInstrumentsResponseSchema
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclass
|
|
76
|
+
class ApiResponseFor200(api_client.ApiResponse):
|
|
77
|
+
body: BrokerageInstrumentsResponse
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass
|
|
81
|
+
class ApiResponseFor200Async(api_client.AsyncApiResponse):
|
|
82
|
+
body: BrokerageInstrumentsResponse
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
_response_for_200 = api_client.OpenApiResponse(
|
|
86
|
+
response_cls=ApiResponseFor200,
|
|
87
|
+
response_cls_async=ApiResponseFor200Async,
|
|
88
|
+
content={
|
|
89
|
+
'application/json': api_client.MediaType(
|
|
90
|
+
schema=SchemaFor200ResponseBodyApplicationJson),
|
|
91
|
+
},
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@dataclass
|
|
96
|
+
class ApiResponseForDefault(api_client.ApiResponse):
|
|
97
|
+
body: schemas.Unset = schemas.unset
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class ApiResponseForDefaultAsync(api_client.AsyncApiResponse):
|
|
102
|
+
body: schemas.Unset = schemas.unset
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
_response_for_default = api_client.OpenApiResponse(
|
|
106
|
+
response_cls=ApiResponseForDefault,
|
|
107
|
+
)
|
|
108
|
+
_status_code_to_response = {
|
|
109
|
+
'200': _response_for_200,
|
|
110
|
+
'default': _response_for_default,
|
|
111
|
+
}
|
|
112
|
+
_all_accept_content_types = (
|
|
113
|
+
'application/json',
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class BaseApi(api_client.Api):
|
|
118
|
+
|
|
119
|
+
def _list_all_brokerage_instruments_mapped_args(
|
|
120
|
+
self,
|
|
121
|
+
brokerage_id: typing.Optional[str] = None,
|
|
122
|
+
path_params: typing.Optional[dict] = {},
|
|
123
|
+
) -> api_client.MappedArgs:
|
|
124
|
+
args: api_client.MappedArgs = api_client.MappedArgs()
|
|
125
|
+
_path_params = {}
|
|
126
|
+
if brokerage_id is not None:
|
|
127
|
+
_path_params["brokerageId"] = brokerage_id
|
|
128
|
+
args.path = path_params if path_params else _path_params
|
|
129
|
+
return args
|
|
130
|
+
|
|
131
|
+
async def _alist_all_brokerage_instruments_oapg(
|
|
132
|
+
self,
|
|
133
|
+
path_params: typing.Optional[dict] = {},
|
|
134
|
+
skip_deserialization: bool = True,
|
|
135
|
+
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
136
|
+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
137
|
+
stream: bool = False,
|
|
138
|
+
**kwargs,
|
|
139
|
+
) -> typing.Union[
|
|
140
|
+
ApiResponseFor200Async,
|
|
141
|
+
ApiResponseForDefaultAsync,
|
|
142
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
143
|
+
AsyncGeneratorResponse,
|
|
144
|
+
]:
|
|
145
|
+
"""
|
|
146
|
+
Get a list of instruments available on the brokerage.
|
|
147
|
+
:param skip_deserialization: If true then api_response.response will be set but
|
|
148
|
+
api_response.body and api_response.headers will not be deserialized into schema
|
|
149
|
+
class instances
|
|
150
|
+
"""
|
|
151
|
+
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
152
|
+
used_path = path.value
|
|
153
|
+
|
|
154
|
+
_path_params = {}
|
|
155
|
+
for parameter in (
|
|
156
|
+
request_path_brokerage_id,
|
|
157
|
+
):
|
|
158
|
+
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
159
|
+
if parameter_data is schemas.unset:
|
|
160
|
+
continue
|
|
161
|
+
serialized_data = parameter.serialize(parameter_data)
|
|
162
|
+
_path_params.update(serialized_data)
|
|
163
|
+
|
|
164
|
+
for k, v in _path_params.items():
|
|
165
|
+
used_path = used_path.replace('{%s}' % k, v)
|
|
166
|
+
|
|
167
|
+
_headers = HTTPHeaderDict()
|
|
168
|
+
# TODO add cookie handling
|
|
169
|
+
if accept_content_types:
|
|
170
|
+
for accept_content_type in accept_content_types:
|
|
171
|
+
_headers.add('Accept', accept_content_type)
|
|
172
|
+
method = 'get'.upper()
|
|
173
|
+
request_before_hook(
|
|
174
|
+
resource_path=used_path,
|
|
175
|
+
method=method,
|
|
176
|
+
configuration=self.api_client.configuration,
|
|
177
|
+
path_template='/brokerages/{brokerageId}/instruments',
|
|
178
|
+
auth_settings=_auth,
|
|
179
|
+
headers=_headers,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
response = await self.api_client.async_call_api(
|
|
183
|
+
resource_path=used_path,
|
|
184
|
+
method=method,
|
|
185
|
+
headers=_headers,
|
|
186
|
+
auth_settings=_auth,
|
|
187
|
+
timeout=timeout,
|
|
188
|
+
**kwargs
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
if stream:
|
|
192
|
+
if not 200 <= response.http_response.status <= 299:
|
|
193
|
+
body = (await response.http_response.content.read()).decode("utf-8")
|
|
194
|
+
raise exceptions.ApiStreamingException(
|
|
195
|
+
status=response.http_response.status,
|
|
196
|
+
reason=response.http_response.reason,
|
|
197
|
+
body=body,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
async def stream_iterator():
|
|
201
|
+
"""
|
|
202
|
+
iterates over response.http_response.content and closes connection once iteration has finished
|
|
203
|
+
"""
|
|
204
|
+
async for line in response.http_response.content:
|
|
205
|
+
if line == b'\r\n':
|
|
206
|
+
continue
|
|
207
|
+
yield line
|
|
208
|
+
response.http_response.close()
|
|
209
|
+
await response.session.close()
|
|
210
|
+
return AsyncGeneratorResponse(
|
|
211
|
+
content=stream_iterator(),
|
|
212
|
+
headers=response.http_response.headers,
|
|
213
|
+
status=response.http_response.status,
|
|
214
|
+
response=response.http_response
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
218
|
+
if response_for_status:
|
|
219
|
+
api_response = await response_for_status.deserialize_async(
|
|
220
|
+
response,
|
|
221
|
+
self.api_client.configuration,
|
|
222
|
+
skip_deserialization=skip_deserialization
|
|
223
|
+
)
|
|
224
|
+
else:
|
|
225
|
+
default_response = _status_code_to_response.get('default')
|
|
226
|
+
if default_response:
|
|
227
|
+
api_response = default_response.deserialize(
|
|
228
|
+
response,
|
|
229
|
+
self.api_client.configuration,
|
|
230
|
+
skip_deserialization=skip_deserialization
|
|
231
|
+
)
|
|
232
|
+
else:
|
|
233
|
+
api_response = api_client.ApiResponseWithoutDeserializationAsync(
|
|
234
|
+
response=response.http_response,
|
|
235
|
+
round_trip_time=response.round_trip_time,
|
|
236
|
+
status=response.http_response.status,
|
|
237
|
+
headers=response.http_response.headers,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
if not 200 <= api_response.status <= 299:
|
|
241
|
+
raise exceptions.ApiException(api_response=api_response)
|
|
242
|
+
|
|
243
|
+
# cleanup session / response
|
|
244
|
+
response.http_response.close()
|
|
245
|
+
await response.session.close()
|
|
246
|
+
|
|
247
|
+
return api_response
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _list_all_brokerage_instruments_oapg(
|
|
251
|
+
self,
|
|
252
|
+
path_params: typing.Optional[dict] = {},
|
|
253
|
+
skip_deserialization: bool = True,
|
|
254
|
+
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
255
|
+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
256
|
+
stream: bool = False,
|
|
257
|
+
) -> typing.Union[
|
|
258
|
+
ApiResponseFor200,
|
|
259
|
+
ApiResponseForDefault,
|
|
260
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
261
|
+
]:
|
|
262
|
+
"""
|
|
263
|
+
Get a list of instruments available on the brokerage.
|
|
264
|
+
:param skip_deserialization: If true then api_response.response will be set but
|
|
265
|
+
api_response.body and api_response.headers will not be deserialized into schema
|
|
266
|
+
class instances
|
|
267
|
+
"""
|
|
268
|
+
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
269
|
+
used_path = path.value
|
|
270
|
+
|
|
271
|
+
_path_params = {}
|
|
272
|
+
for parameter in (
|
|
273
|
+
request_path_brokerage_id,
|
|
274
|
+
):
|
|
275
|
+
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
276
|
+
if parameter_data is schemas.unset:
|
|
277
|
+
continue
|
|
278
|
+
serialized_data = parameter.serialize(parameter_data)
|
|
279
|
+
_path_params.update(serialized_data)
|
|
280
|
+
|
|
281
|
+
for k, v in _path_params.items():
|
|
282
|
+
used_path = used_path.replace('{%s}' % k, v)
|
|
283
|
+
|
|
284
|
+
_headers = HTTPHeaderDict()
|
|
285
|
+
# TODO add cookie handling
|
|
286
|
+
if accept_content_types:
|
|
287
|
+
for accept_content_type in accept_content_types:
|
|
288
|
+
_headers.add('Accept', accept_content_type)
|
|
289
|
+
method = 'get'.upper()
|
|
290
|
+
request_before_hook(
|
|
291
|
+
resource_path=used_path,
|
|
292
|
+
method=method,
|
|
293
|
+
configuration=self.api_client.configuration,
|
|
294
|
+
path_template='/brokerages/{brokerageId}/instruments',
|
|
295
|
+
auth_settings=_auth,
|
|
296
|
+
headers=_headers,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
response = self.api_client.call_api(
|
|
300
|
+
resource_path=used_path,
|
|
301
|
+
method=method,
|
|
302
|
+
headers=_headers,
|
|
303
|
+
auth_settings=_auth,
|
|
304
|
+
timeout=timeout,
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
308
|
+
if response_for_status:
|
|
309
|
+
api_response = response_for_status.deserialize(
|
|
310
|
+
response,
|
|
311
|
+
self.api_client.configuration,
|
|
312
|
+
skip_deserialization=skip_deserialization
|
|
313
|
+
)
|
|
314
|
+
else:
|
|
315
|
+
default_response = _status_code_to_response.get('default')
|
|
316
|
+
if default_response:
|
|
317
|
+
api_response = default_response.deserialize(
|
|
318
|
+
response,
|
|
319
|
+
self.api_client.configuration,
|
|
320
|
+
skip_deserialization=skip_deserialization
|
|
321
|
+
)
|
|
322
|
+
else:
|
|
323
|
+
api_response = api_client.ApiResponseWithoutDeserialization(
|
|
324
|
+
response=response.http_response,
|
|
325
|
+
round_trip_time=response.round_trip_time,
|
|
326
|
+
status=response.http_response.status,
|
|
327
|
+
headers=response.http_response.headers,
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
if not 200 <= api_response.status <= 299:
|
|
331
|
+
raise exceptions.ApiException(api_response=api_response)
|
|
332
|
+
|
|
333
|
+
return api_response
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
class ListAllBrokerageInstruments(BaseApi):
|
|
337
|
+
# this class is used by api classes that refer to endpoints with operationId fn names
|
|
338
|
+
|
|
339
|
+
async def alist_all_brokerage_instruments(
|
|
340
|
+
self,
|
|
341
|
+
brokerage_id: typing.Optional[str] = None,
|
|
342
|
+
path_params: typing.Optional[dict] = {},
|
|
343
|
+
**kwargs,
|
|
344
|
+
) -> typing.Union[
|
|
345
|
+
ApiResponseFor200Async,
|
|
346
|
+
ApiResponseForDefaultAsync,
|
|
347
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
348
|
+
AsyncGeneratorResponse,
|
|
349
|
+
]:
|
|
350
|
+
args = self._list_all_brokerage_instruments_mapped_args(
|
|
351
|
+
path_params=path_params,
|
|
352
|
+
brokerage_id=brokerage_id,
|
|
353
|
+
)
|
|
354
|
+
return await self._alist_all_brokerage_instruments_oapg(
|
|
355
|
+
path_params=args.path,
|
|
356
|
+
**kwargs,
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
def list_all_brokerage_instruments(
|
|
360
|
+
self,
|
|
361
|
+
brokerage_id: typing.Optional[str] = None,
|
|
362
|
+
path_params: typing.Optional[dict] = {},
|
|
363
|
+
) -> typing.Union[
|
|
364
|
+
ApiResponseFor200,
|
|
365
|
+
ApiResponseForDefault,
|
|
366
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
367
|
+
]:
|
|
368
|
+
""" Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. """
|
|
369
|
+
args = self._list_all_brokerage_instruments_mapped_args(
|
|
370
|
+
path_params=path_params,
|
|
371
|
+
brokerage_id=brokerage_id,
|
|
372
|
+
)
|
|
373
|
+
return self._list_all_brokerage_instruments_oapg(
|
|
374
|
+
path_params=args.path,
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
class ApiForget(BaseApi):
|
|
378
|
+
# this class is used by api classes that refer to endpoints by path and http method names
|
|
379
|
+
|
|
380
|
+
async def aget(
|
|
381
|
+
self,
|
|
382
|
+
brokerage_id: typing.Optional[str] = None,
|
|
383
|
+
path_params: typing.Optional[dict] = {},
|
|
384
|
+
**kwargs,
|
|
385
|
+
) -> typing.Union[
|
|
386
|
+
ApiResponseFor200Async,
|
|
387
|
+
ApiResponseForDefaultAsync,
|
|
388
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
389
|
+
AsyncGeneratorResponse,
|
|
390
|
+
]:
|
|
391
|
+
args = self._list_all_brokerage_instruments_mapped_args(
|
|
392
|
+
path_params=path_params,
|
|
393
|
+
brokerage_id=brokerage_id,
|
|
394
|
+
)
|
|
395
|
+
return await self._alist_all_brokerage_instruments_oapg(
|
|
396
|
+
path_params=args.path,
|
|
397
|
+
**kwargs,
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
def get(
|
|
401
|
+
self,
|
|
402
|
+
brokerage_id: typing.Optional[str] = None,
|
|
403
|
+
path_params: typing.Optional[dict] = {},
|
|
404
|
+
) -> typing.Union[
|
|
405
|
+
ApiResponseFor200,
|
|
406
|
+
ApiResponseForDefault,
|
|
407
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
408
|
+
]:
|
|
409
|
+
""" Returns a list of all brokerage instruments available for a given brokerage, optionally filtered by a search. Not all brokerages support this. The ones that don't will return an empty list. """
|
|
410
|
+
args = self._list_all_brokerage_instruments_mapped_args(
|
|
411
|
+
path_params=path_params,
|
|
412
|
+
brokerage_id=brokerage_id,
|
|
413
|
+
)
|
|
414
|
+
return self._list_all_brokerage_instruments_oapg(
|
|
415
|
+
path_params=args.path,
|
|
416
|
+
)
|
|
417
|
+
|