snaptrade-python-sdk 11.0.123__py3-none-any.whl → 11.0.124__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.
Files changed (23) hide show
  1. snaptrade_client/__init__.py +1 -1
  2. snaptrade_client/api_client.py +1 -1
  3. snaptrade_client/apis/path_to_api.py +0 -9
  4. snaptrade_client/apis/tags/options_api_generated.py +0 -6
  5. snaptrade_client/configuration.py +1 -1
  6. snaptrade_client/operation_parameter_map.py +0 -63
  7. snaptrade_client/paths/__init__.py +0 -3
  8. {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/METADATA +3 -156
  9. {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/RECORD +11 -23
  10. snaptrade_client/apis/paths/accounts_account_id_option_strategy.py +0 -7
  11. snaptrade_client/apis/paths/accounts_account_id_option_strategy_option_strategy_id.py +0 -7
  12. snaptrade_client/apis/paths/accounts_account_id_option_strategy_option_strategy_id_execute.py +0 -7
  13. snaptrade_client/paths/accounts_account_id_option_strategy/__init__.py +0 -7
  14. snaptrade_client/paths/accounts_account_id_option_strategy/post.py +0 -731
  15. snaptrade_client/paths/accounts_account_id_option_strategy/post.pyi +0 -714
  16. snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id/__init__.py +0 -7
  17. snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id/get.py +0 -537
  18. snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id/get.pyi +0 -526
  19. snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/__init__.py +0 -7
  20. snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/post.py +0 -723
  21. snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/post.pyi +0 -712
  22. {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/LICENSE +0 -0
  23. {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/WHEEL +0 -0
@@ -1,7 +0,0 @@
1
- # do not import all endpoints into this module because that uses a lot of memory and stack frames
2
- # if you need the ability to import all endpoints from this module, import them with
3
- # from snaptrade_client.paths.accounts_account_id_option_strategy_option_strategy_id import Api
4
-
5
- from snaptrade_client.paths import PathValues
6
-
7
- path = PathValues.ACCOUNTS_ACCOUNT_ID_OPTION_STRATEGY_OPTION_STRATEGY_ID
@@ -1,537 +0,0 @@
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.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse as Model500UnexpectedExceptionResponseSchema
36
- from snaptrade_client.model.strategy_quotes import StrategyQuotes as StrategyQuotesSchema
37
-
38
- from snaptrade_client.type.strategy_quotes import StrategyQuotes
39
- from snaptrade_client.type.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse
40
-
41
- from . import path
42
-
43
- # Query params
44
- UserIdSchema = schemas.StrSchema
45
- UserSecretSchema = schemas.StrSchema
46
- RequestRequiredQueryParams = typing_extensions.TypedDict(
47
- 'RequestRequiredQueryParams',
48
- {
49
- 'userId': typing.Union[UserIdSchema, str, ],
50
- 'userSecret': typing.Union[UserSecretSchema, str, ],
51
- }
52
- )
53
- RequestOptionalQueryParams = typing_extensions.TypedDict(
54
- 'RequestOptionalQueryParams',
55
- {
56
- },
57
- total=False
58
- )
59
-
60
-
61
- class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
62
- pass
63
-
64
-
65
- request_query_user_id = api_client.QueryParameter(
66
- name="userId",
67
- style=api_client.ParameterStyle.FORM,
68
- schema=UserIdSchema,
69
- required=True,
70
- explode=True,
71
- )
72
- request_query_user_secret = api_client.QueryParameter(
73
- name="userSecret",
74
- style=api_client.ParameterStyle.FORM,
75
- schema=UserSecretSchema,
76
- required=True,
77
- explode=True,
78
- )
79
- # Path params
80
- AccountIdSchema = schemas.UUIDSchema
81
- OptionStrategyIdSchema = schemas.UUIDSchema
82
- RequestRequiredPathParams = typing_extensions.TypedDict(
83
- 'RequestRequiredPathParams',
84
- {
85
- 'accountId': typing.Union[AccountIdSchema, str, uuid.UUID, ],
86
- 'optionStrategyId': typing.Union[OptionStrategyIdSchema, str, uuid.UUID, ],
87
- }
88
- )
89
- RequestOptionalPathParams = typing_extensions.TypedDict(
90
- 'RequestOptionalPathParams',
91
- {
92
- },
93
- total=False
94
- )
95
-
96
-
97
- class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams):
98
- pass
99
-
100
-
101
- request_path_account_id = api_client.PathParameter(
102
- name="accountId",
103
- style=api_client.ParameterStyle.SIMPLE,
104
- schema=AccountIdSchema,
105
- required=True,
106
- )
107
- request_path_option_strategy_id = api_client.PathParameter(
108
- name="optionStrategyId",
109
- style=api_client.ParameterStyle.SIMPLE,
110
- schema=OptionStrategyIdSchema,
111
- required=True,
112
- )
113
- _auth = [
114
- 'PartnerClientId',
115
- 'PartnerSignature',
116
- 'PartnerTimestamp',
117
- ]
118
- SchemaFor200ResponseBodyApplicationJson = StrategyQuotesSchema
119
-
120
-
121
- @dataclass
122
- class ApiResponseFor200(api_client.ApiResponse):
123
- body: StrategyQuotes
124
-
125
-
126
- @dataclass
127
- class ApiResponseFor200Async(api_client.AsyncApiResponse):
128
- body: StrategyQuotes
129
-
130
-
131
- _response_for_200 = api_client.OpenApiResponse(
132
- response_cls=ApiResponseFor200,
133
- response_cls_async=ApiResponseFor200Async,
134
- content={
135
- 'application/json': api_client.MediaType(
136
- schema=SchemaFor200ResponseBodyApplicationJson),
137
- },
138
- )
139
- SchemaFor500ResponseBodyApplicationJson = Model500UnexpectedExceptionResponseSchema
140
-
141
-
142
- @dataclass
143
- class ApiResponseFor500(api_client.ApiResponse):
144
- body: Model500UnexpectedExceptionResponse
145
-
146
-
147
- @dataclass
148
- class ApiResponseFor500Async(api_client.AsyncApiResponse):
149
- body: Model500UnexpectedExceptionResponse
150
-
151
-
152
- _response_for_500 = api_client.OpenApiResponse(
153
- response_cls=ApiResponseFor500,
154
- response_cls_async=ApiResponseFor500Async,
155
- content={
156
- 'application/json': api_client.MediaType(
157
- schema=SchemaFor500ResponseBodyApplicationJson),
158
- },
159
- )
160
- _status_code_to_response = {
161
- '200': _response_for_200,
162
- '500': _response_for_500,
163
- }
164
- _all_accept_content_types = (
165
- 'application/json',
166
- )
167
-
168
-
169
- class BaseApi(api_client.Api):
170
-
171
- def _get_options_strategy_quote_mapped_args(
172
- self,
173
- user_id: typing.Optional[str] = None,
174
- user_secret: typing.Optional[str] = None,
175
- account_id: typing.Optional[str] = None,
176
- option_strategy_id: typing.Optional[str] = None,
177
- query_params: typing.Optional[dict] = {},
178
- path_params: typing.Optional[dict] = {},
179
- ) -> api_client.MappedArgs:
180
- args: api_client.MappedArgs = api_client.MappedArgs()
181
- _query_params = {}
182
- _path_params = {}
183
- if user_id is not None:
184
- _query_params["userId"] = user_id
185
- if user_secret is not None:
186
- _query_params["userSecret"] = user_secret
187
- if account_id is not None:
188
- _path_params["accountId"] = account_id
189
- if option_strategy_id is not None:
190
- _path_params["optionStrategyId"] = option_strategy_id
191
- args.query = query_params if query_params else _query_params
192
- args.path = path_params if path_params else _path_params
193
- return args
194
-
195
- async def _aget_options_strategy_quote_oapg(
196
- self,
197
- query_params: typing.Optional[dict] = {},
198
- path_params: typing.Optional[dict] = {},
199
- skip_deserialization: bool = True,
200
- timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
201
- accept_content_types: typing.Tuple[str] = _all_accept_content_types,
202
- stream: bool = False,
203
- **kwargs,
204
- ) -> typing.Union[
205
- ApiResponseFor200Async,
206
- api_client.ApiResponseWithoutDeserializationAsync,
207
- AsyncGeneratorResponse,
208
- ]:
209
- """
210
- Get options strategy quotes
211
- :param skip_deserialization: If true then api_response.response will be set but
212
- api_response.body and api_response.headers will not be deserialized into schema
213
- class instances
214
- """
215
- self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
216
- self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
217
- used_path = path.value
218
-
219
- _path_params = {}
220
- for parameter in (
221
- request_path_account_id,
222
- request_path_option_strategy_id,
223
- ):
224
- parameter_data = path_params.get(parameter.name, schemas.unset)
225
- if parameter_data is schemas.unset:
226
- continue
227
- serialized_data = parameter.serialize(parameter_data)
228
- _path_params.update(serialized_data)
229
-
230
- for k, v in _path_params.items():
231
- used_path = used_path.replace('{%s}' % k, v)
232
-
233
- prefix_separator_iterator = None
234
- for parameter in (
235
- request_query_user_id,
236
- request_query_user_secret,
237
- ):
238
- parameter_data = query_params.get(parameter.name, schemas.unset)
239
- if parameter_data is schemas.unset:
240
- continue
241
- if prefix_separator_iterator is None:
242
- prefix_separator_iterator = parameter.get_prefix_separator_iterator()
243
- serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
244
- for serialized_value in serialized_data.values():
245
- used_path += serialized_value
246
-
247
- _headers = HTTPHeaderDict()
248
- # TODO add cookie handling
249
- if accept_content_types:
250
- for accept_content_type in accept_content_types:
251
- _headers.add('Accept', accept_content_type)
252
- method = 'get'.upper()
253
- request_before_hook(
254
- resource_path=used_path,
255
- method=method,
256
- configuration=self.api_client.configuration,
257
- path_template='/accounts/{accountId}/optionStrategy/{optionStrategyId}',
258
- auth_settings=_auth,
259
- headers=_headers,
260
- )
261
-
262
- response = await self.api_client.async_call_api(
263
- resource_path=used_path,
264
- method=method,
265
- headers=_headers,
266
- auth_settings=_auth,
267
- prefix_separator_iterator=prefix_separator_iterator,
268
- timeout=timeout,
269
- **kwargs
270
- )
271
-
272
- if stream:
273
- if not 200 <= response.http_response.status <= 299:
274
- body = (await response.http_response.content.read()).decode("utf-8")
275
- raise exceptions.ApiStreamingException(
276
- status=response.http_response.status,
277
- reason=response.http_response.reason,
278
- body=body,
279
- )
280
-
281
- async def stream_iterator():
282
- """
283
- iterates over response.http_response.content and closes connection once iteration has finished
284
- """
285
- async for line in response.http_response.content:
286
- if line == b'\r\n':
287
- continue
288
- yield line
289
- response.http_response.close()
290
- await response.session.close()
291
- return AsyncGeneratorResponse(
292
- content=stream_iterator(),
293
- headers=response.http_response.headers,
294
- status=response.http_response.status,
295
- response=response.http_response
296
- )
297
-
298
- response_for_status = _status_code_to_response.get(str(response.http_response.status))
299
- if response_for_status:
300
- api_response = await response_for_status.deserialize_async(
301
- response,
302
- self.api_client.configuration,
303
- skip_deserialization=skip_deserialization
304
- )
305
- else:
306
- # If response data is JSON then deserialize for SDK consumer convenience
307
- is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
308
- api_response = api_client.ApiResponseWithoutDeserializationAsync(
309
- body=await response.http_response.json() if is_json else await response.http_response.text(),
310
- response=response.http_response,
311
- round_trip_time=response.round_trip_time,
312
- status=response.http_response.status,
313
- headers=response.http_response.headers,
314
- )
315
-
316
- if not 200 <= api_response.status <= 299:
317
- raise exceptions.ApiException(api_response=api_response)
318
-
319
- # cleanup session / response
320
- response.http_response.close()
321
- await response.session.close()
322
-
323
- return api_response
324
-
325
-
326
- def _get_options_strategy_quote_oapg(
327
- self,
328
- query_params: typing.Optional[dict] = {},
329
- path_params: typing.Optional[dict] = {},
330
- skip_deserialization: bool = True,
331
- timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
332
- accept_content_types: typing.Tuple[str] = _all_accept_content_types,
333
- stream: bool = False,
334
- ) -> typing.Union[
335
- ApiResponseFor200,
336
- api_client.ApiResponseWithoutDeserialization,
337
- ]:
338
- """
339
- Get options strategy quotes
340
- :param skip_deserialization: If true then api_response.response will be set but
341
- api_response.body and api_response.headers will not be deserialized into schema
342
- class instances
343
- """
344
- self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
345
- self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
346
- used_path = path.value
347
-
348
- _path_params = {}
349
- for parameter in (
350
- request_path_account_id,
351
- request_path_option_strategy_id,
352
- ):
353
- parameter_data = path_params.get(parameter.name, schemas.unset)
354
- if parameter_data is schemas.unset:
355
- continue
356
- serialized_data = parameter.serialize(parameter_data)
357
- _path_params.update(serialized_data)
358
-
359
- for k, v in _path_params.items():
360
- used_path = used_path.replace('{%s}' % k, v)
361
-
362
- prefix_separator_iterator = None
363
- for parameter in (
364
- request_query_user_id,
365
- request_query_user_secret,
366
- ):
367
- parameter_data = query_params.get(parameter.name, schemas.unset)
368
- if parameter_data is schemas.unset:
369
- continue
370
- if prefix_separator_iterator is None:
371
- prefix_separator_iterator = parameter.get_prefix_separator_iterator()
372
- serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
373
- for serialized_value in serialized_data.values():
374
- used_path += serialized_value
375
-
376
- _headers = HTTPHeaderDict()
377
- # TODO add cookie handling
378
- if accept_content_types:
379
- for accept_content_type in accept_content_types:
380
- _headers.add('Accept', accept_content_type)
381
- method = 'get'.upper()
382
- request_before_hook(
383
- resource_path=used_path,
384
- method=method,
385
- configuration=self.api_client.configuration,
386
- path_template='/accounts/{accountId}/optionStrategy/{optionStrategyId}',
387
- auth_settings=_auth,
388
- headers=_headers,
389
- )
390
-
391
- response = self.api_client.call_api(
392
- resource_path=used_path,
393
- method=method,
394
- headers=_headers,
395
- auth_settings=_auth,
396
- prefix_separator_iterator=prefix_separator_iterator,
397
- timeout=timeout,
398
- )
399
-
400
- response_for_status = _status_code_to_response.get(str(response.http_response.status))
401
- if response_for_status:
402
- api_response = response_for_status.deserialize(
403
- response,
404
- self.api_client.configuration,
405
- skip_deserialization=skip_deserialization
406
- )
407
- else:
408
- # If response data is JSON then deserialize for SDK consumer convenience
409
- is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
410
- api_response = api_client.ApiResponseWithoutDeserialization(
411
- body=json.loads(response.http_response.data) if is_json else response.http_response.data,
412
- response=response.http_response,
413
- round_trip_time=response.round_trip_time,
414
- status=response.http_response.status,
415
- headers=response.http_response.headers,
416
- )
417
-
418
- if not 200 <= api_response.status <= 299:
419
- raise exceptions.ApiException(api_response=api_response)
420
-
421
- return api_response
422
-
423
-
424
- class GetOptionsStrategyQuote(BaseApi):
425
- # this class is used by api classes that refer to endpoints with operationId fn names
426
-
427
- async def aget_options_strategy_quote(
428
- self,
429
- user_id: typing.Optional[str] = None,
430
- user_secret: typing.Optional[str] = None,
431
- account_id: typing.Optional[str] = None,
432
- option_strategy_id: typing.Optional[str] = None,
433
- query_params: typing.Optional[dict] = {},
434
- path_params: typing.Optional[dict] = {},
435
- **kwargs,
436
- ) -> typing.Union[
437
- ApiResponseFor200Async,
438
- api_client.ApiResponseWithoutDeserializationAsync,
439
- AsyncGeneratorResponse,
440
- ]:
441
- args = self._get_options_strategy_quote_mapped_args(
442
- query_params=query_params,
443
- path_params=path_params,
444
- user_id=user_id,
445
- user_secret=user_secret,
446
- account_id=account_id,
447
- option_strategy_id=option_strategy_id,
448
- )
449
- return await self._aget_options_strategy_quote_oapg(
450
- query_params=args.query,
451
- path_params=args.path,
452
- **kwargs,
453
- )
454
-
455
- def get_options_strategy_quote(
456
- self,
457
- user_id: typing.Optional[str] = None,
458
- user_secret: typing.Optional[str] = None,
459
- account_id: typing.Optional[str] = None,
460
- option_strategy_id: typing.Optional[str] = None,
461
- query_params: typing.Optional[dict] = {},
462
- path_params: typing.Optional[dict] = {},
463
- ) -> typing.Union[
464
- ApiResponseFor200,
465
- api_client.ApiResponseWithoutDeserialization,
466
- ]:
467
- """ Returns a Strategy Quotes object which has latest market data of the specified option strategy. """
468
- args = self._get_options_strategy_quote_mapped_args(
469
- query_params=query_params,
470
- path_params=path_params,
471
- user_id=user_id,
472
- user_secret=user_secret,
473
- account_id=account_id,
474
- option_strategy_id=option_strategy_id,
475
- )
476
- return self._get_options_strategy_quote_oapg(
477
- query_params=args.query,
478
- path_params=args.path,
479
- )
480
-
481
- class ApiForget(BaseApi):
482
- # this class is used by api classes that refer to endpoints by path and http method names
483
-
484
- async def aget(
485
- self,
486
- user_id: typing.Optional[str] = None,
487
- user_secret: typing.Optional[str] = None,
488
- account_id: typing.Optional[str] = None,
489
- option_strategy_id: typing.Optional[str] = None,
490
- query_params: typing.Optional[dict] = {},
491
- path_params: typing.Optional[dict] = {},
492
- **kwargs,
493
- ) -> typing.Union[
494
- ApiResponseFor200Async,
495
- api_client.ApiResponseWithoutDeserializationAsync,
496
- AsyncGeneratorResponse,
497
- ]:
498
- args = self._get_options_strategy_quote_mapped_args(
499
- query_params=query_params,
500
- path_params=path_params,
501
- user_id=user_id,
502
- user_secret=user_secret,
503
- account_id=account_id,
504
- option_strategy_id=option_strategy_id,
505
- )
506
- return await self._aget_options_strategy_quote_oapg(
507
- query_params=args.query,
508
- path_params=args.path,
509
- **kwargs,
510
- )
511
-
512
- def get(
513
- self,
514
- user_id: typing.Optional[str] = None,
515
- user_secret: typing.Optional[str] = None,
516
- account_id: typing.Optional[str] = None,
517
- option_strategy_id: typing.Optional[str] = None,
518
- query_params: typing.Optional[dict] = {},
519
- path_params: typing.Optional[dict] = {},
520
- ) -> typing.Union[
521
- ApiResponseFor200,
522
- api_client.ApiResponseWithoutDeserialization,
523
- ]:
524
- """ Returns a Strategy Quotes object which has latest market data of the specified option strategy. """
525
- args = self._get_options_strategy_quote_mapped_args(
526
- query_params=query_params,
527
- path_params=path_params,
528
- user_id=user_id,
529
- user_secret=user_secret,
530
- account_id=account_id,
531
- option_strategy_id=option_strategy_id,
532
- )
533
- return self._get_options_strategy_quote_oapg(
534
- query_params=args.query,
535
- path_params=args.path,
536
- )
537
-