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.
- snaptrade_client/__init__.py +1 -1
- snaptrade_client/api_client.py +1 -1
- snaptrade_client/apis/path_to_api.py +0 -9
- snaptrade_client/apis/tags/options_api_generated.py +0 -6
- snaptrade_client/configuration.py +1 -1
- snaptrade_client/operation_parameter_map.py +0 -63
- snaptrade_client/paths/__init__.py +0 -3
- {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/METADATA +3 -156
- {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/RECORD +11 -23
- snaptrade_client/apis/paths/accounts_account_id_option_strategy.py +0 -7
- snaptrade_client/apis/paths/accounts_account_id_option_strategy_option_strategy_id.py +0 -7
- snaptrade_client/apis/paths/accounts_account_id_option_strategy_option_strategy_id_execute.py +0 -7
- snaptrade_client/paths/accounts_account_id_option_strategy/__init__.py +0 -7
- snaptrade_client/paths/accounts_account_id_option_strategy/post.py +0 -731
- snaptrade_client/paths/accounts_account_id_option_strategy/post.pyi +0 -714
- snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id/__init__.py +0 -7
- snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id/get.py +0 -537
- snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id/get.pyi +0 -526
- snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/__init__.py +0 -7
- snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/post.py +0 -723
- snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/post.pyi +0 -712
- {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/LICENSE +0 -0
- {snaptrade_python_sdk-11.0.123.dist-info → snaptrade_python_sdk-11.0.124.dist-info}/WHEEL +0 -0
snaptrade_client/paths/accounts_account_id_option_strategy_option_strategy_id_execute/post.py
DELETED
|
@@ -1,723 +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.strategy_order_record import StrategyOrderRecord as StrategyOrderRecordSchema
|
|
36
|
-
from snaptrade_client.model.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse as Model500UnexpectedExceptionResponseSchema
|
|
37
|
-
from snaptrade_client.model.price import Price as PriceSchema
|
|
38
|
-
from snaptrade_client.model.time_in_force_strict import TimeInForceStrict as TimeInForceStrictSchema
|
|
39
|
-
from snaptrade_client.model.order_type_strict import OrderTypeStrict as OrderTypeStrictSchema
|
|
40
|
-
|
|
41
|
-
from snaptrade_client.type.time_in_force_strict import TimeInForceStrict
|
|
42
|
-
from snaptrade_client.type.strategy_order_record import StrategyOrderRecord
|
|
43
|
-
from snaptrade_client.type.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse
|
|
44
|
-
from snaptrade_client.type.order_type_strict import OrderTypeStrict
|
|
45
|
-
from snaptrade_client.type.price import Price
|
|
46
|
-
|
|
47
|
-
from . import path
|
|
48
|
-
|
|
49
|
-
# Query params
|
|
50
|
-
UserIdSchema = schemas.StrSchema
|
|
51
|
-
UserSecretSchema = schemas.StrSchema
|
|
52
|
-
RequestRequiredQueryParams = typing_extensions.TypedDict(
|
|
53
|
-
'RequestRequiredQueryParams',
|
|
54
|
-
{
|
|
55
|
-
'userId': typing.Union[UserIdSchema, str, ],
|
|
56
|
-
'userSecret': typing.Union[UserSecretSchema, str, ],
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
RequestOptionalQueryParams = typing_extensions.TypedDict(
|
|
60
|
-
'RequestOptionalQueryParams',
|
|
61
|
-
{
|
|
62
|
-
},
|
|
63
|
-
total=False
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
|
|
68
|
-
pass
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
request_query_user_id = api_client.QueryParameter(
|
|
72
|
-
name="userId",
|
|
73
|
-
style=api_client.ParameterStyle.FORM,
|
|
74
|
-
schema=UserIdSchema,
|
|
75
|
-
required=True,
|
|
76
|
-
explode=True,
|
|
77
|
-
)
|
|
78
|
-
request_query_user_secret = api_client.QueryParameter(
|
|
79
|
-
name="userSecret",
|
|
80
|
-
style=api_client.ParameterStyle.FORM,
|
|
81
|
-
schema=UserSecretSchema,
|
|
82
|
-
required=True,
|
|
83
|
-
explode=True,
|
|
84
|
-
)
|
|
85
|
-
# Path params
|
|
86
|
-
AccountIdSchema = schemas.UUIDSchema
|
|
87
|
-
OptionStrategyIdSchema = schemas.UUIDSchema
|
|
88
|
-
RequestRequiredPathParams = typing_extensions.TypedDict(
|
|
89
|
-
'RequestRequiredPathParams',
|
|
90
|
-
{
|
|
91
|
-
'accountId': typing.Union[AccountIdSchema, str, uuid.UUID, ],
|
|
92
|
-
'optionStrategyId': typing.Union[OptionStrategyIdSchema, 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
|
-
request_path_option_strategy_id = api_client.PathParameter(
|
|
114
|
-
name="optionStrategyId",
|
|
115
|
-
style=api_client.ParameterStyle.SIMPLE,
|
|
116
|
-
schema=OptionStrategyIdSchema,
|
|
117
|
-
required=True,
|
|
118
|
-
)
|
|
119
|
-
# body param
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
class SchemaForRequestBodyApplicationJson(
|
|
123
|
-
schemas.DictSchema
|
|
124
|
-
):
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
class MetaOapg:
|
|
128
|
-
required = {
|
|
129
|
-
"time_in_force",
|
|
130
|
-
"order_type",
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
class properties:
|
|
134
|
-
|
|
135
|
-
@staticmethod
|
|
136
|
-
def order_type() -> typing.Type['OrderTypeStrict']:
|
|
137
|
-
return OrderTypeStrict
|
|
138
|
-
|
|
139
|
-
@staticmethod
|
|
140
|
-
def time_in_force() -> typing.Type['TimeInForceStrict']:
|
|
141
|
-
return TimeInForceStrict
|
|
142
|
-
|
|
143
|
-
@staticmethod
|
|
144
|
-
def price() -> typing.Type['Price']:
|
|
145
|
-
return Price
|
|
146
|
-
__annotations__ = {
|
|
147
|
-
"order_type": order_type,
|
|
148
|
-
"time_in_force": time_in_force,
|
|
149
|
-
"price": price,
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
time_in_force: 'TimeInForceStrict'
|
|
153
|
-
order_type: 'OrderTypeStrict'
|
|
154
|
-
|
|
155
|
-
@typing.overload
|
|
156
|
-
def __getitem__(self, name: typing_extensions.Literal["order_type"]) -> 'OrderTypeStrict': ...
|
|
157
|
-
|
|
158
|
-
@typing.overload
|
|
159
|
-
def __getitem__(self, name: typing_extensions.Literal["time_in_force"]) -> 'TimeInForceStrict': ...
|
|
160
|
-
|
|
161
|
-
@typing.overload
|
|
162
|
-
def __getitem__(self, name: typing_extensions.Literal["price"]) -> 'Price': ...
|
|
163
|
-
|
|
164
|
-
@typing.overload
|
|
165
|
-
def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
|
|
166
|
-
|
|
167
|
-
def __getitem__(self, name: typing.Union[typing_extensions.Literal["order_type", "time_in_force", "price", ], str]):
|
|
168
|
-
# dict_instance[name] accessor
|
|
169
|
-
return super().__getitem__(name)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
@typing.overload
|
|
173
|
-
def get_item_oapg(self, name: typing_extensions.Literal["order_type"]) -> 'OrderTypeStrict': ...
|
|
174
|
-
|
|
175
|
-
@typing.overload
|
|
176
|
-
def get_item_oapg(self, name: typing_extensions.Literal["time_in_force"]) -> 'TimeInForceStrict': ...
|
|
177
|
-
|
|
178
|
-
@typing.overload
|
|
179
|
-
def get_item_oapg(self, name: typing_extensions.Literal["price"]) -> typing.Union['Price', schemas.Unset]: ...
|
|
180
|
-
|
|
181
|
-
@typing.overload
|
|
182
|
-
def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
|
|
183
|
-
|
|
184
|
-
def get_item_oapg(self, name: typing.Union[typing_extensions.Literal["order_type", "time_in_force", "price", ], str]):
|
|
185
|
-
return super().get_item_oapg(name)
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
def __new__(
|
|
189
|
-
cls,
|
|
190
|
-
*args: typing.Union[dict, frozendict.frozendict, ],
|
|
191
|
-
time_in_force: 'TimeInForceStrict',
|
|
192
|
-
order_type: 'OrderTypeStrict',
|
|
193
|
-
price: typing.Union['Price', schemas.Unset] = schemas.unset,
|
|
194
|
-
_configuration: typing.Optional[schemas.Configuration] = None,
|
|
195
|
-
**kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
|
|
196
|
-
) -> 'SchemaForRequestBodyApplicationJson':
|
|
197
|
-
return super().__new__(
|
|
198
|
-
cls,
|
|
199
|
-
*args,
|
|
200
|
-
time_in_force=time_in_force,
|
|
201
|
-
order_type=order_type,
|
|
202
|
-
price=price,
|
|
203
|
-
_configuration=_configuration,
|
|
204
|
-
**kwargs,
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
request_body_typing_any = api_client.RequestBody(
|
|
209
|
-
content={
|
|
210
|
-
'application/json': api_client.MediaType(
|
|
211
|
-
schema=SchemaForRequestBodyApplicationJson),
|
|
212
|
-
},
|
|
213
|
-
required=True,
|
|
214
|
-
)
|
|
215
|
-
_auth = [
|
|
216
|
-
'PartnerClientId',
|
|
217
|
-
'PartnerSignature',
|
|
218
|
-
'PartnerTimestamp',
|
|
219
|
-
]
|
|
220
|
-
SchemaFor200ResponseBodyApplicationJson = StrategyOrderRecordSchema
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
@dataclass
|
|
224
|
-
class ApiResponseFor200(api_client.ApiResponse):
|
|
225
|
-
body: StrategyOrderRecord
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
@dataclass
|
|
229
|
-
class ApiResponseFor200Async(api_client.AsyncApiResponse):
|
|
230
|
-
body: StrategyOrderRecord
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
_response_for_200 = api_client.OpenApiResponse(
|
|
234
|
-
response_cls=ApiResponseFor200,
|
|
235
|
-
response_cls_async=ApiResponseFor200Async,
|
|
236
|
-
content={
|
|
237
|
-
'application/json': api_client.MediaType(
|
|
238
|
-
schema=SchemaFor200ResponseBodyApplicationJson),
|
|
239
|
-
},
|
|
240
|
-
)
|
|
241
|
-
SchemaFor500ResponseBodyApplicationJson = Model500UnexpectedExceptionResponseSchema
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
@dataclass
|
|
245
|
-
class ApiResponseFor500(api_client.ApiResponse):
|
|
246
|
-
body: Model500UnexpectedExceptionResponse
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
@dataclass
|
|
250
|
-
class ApiResponseFor500Async(api_client.AsyncApiResponse):
|
|
251
|
-
body: Model500UnexpectedExceptionResponse
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
_response_for_500 = api_client.OpenApiResponse(
|
|
255
|
-
response_cls=ApiResponseFor500,
|
|
256
|
-
response_cls_async=ApiResponseFor500Async,
|
|
257
|
-
content={
|
|
258
|
-
'application/json': api_client.MediaType(
|
|
259
|
-
schema=SchemaFor500ResponseBodyApplicationJson),
|
|
260
|
-
},
|
|
261
|
-
)
|
|
262
|
-
_status_code_to_response = {
|
|
263
|
-
'200': _response_for_200,
|
|
264
|
-
'500': _response_for_500,
|
|
265
|
-
}
|
|
266
|
-
_all_accept_content_types = (
|
|
267
|
-
'application/json',
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
class BaseApi(api_client.Api):
|
|
272
|
-
|
|
273
|
-
def _place_option_strategy_mapped_args(
|
|
274
|
-
self,
|
|
275
|
-
body: typing.Optional[typing.Any] = None,
|
|
276
|
-
order_type: typing.Optional[OrderTypeStrict] = None,
|
|
277
|
-
time_in_force: typing.Optional[TimeInForceStrict] = None,
|
|
278
|
-
user_id: typing.Optional[str] = None,
|
|
279
|
-
user_secret: typing.Optional[str] = None,
|
|
280
|
-
account_id: typing.Optional[str] = None,
|
|
281
|
-
option_strategy_id: typing.Optional[str] = None,
|
|
282
|
-
price: typing.Optional[Price] = None,
|
|
283
|
-
query_params: typing.Optional[dict] = {},
|
|
284
|
-
path_params: typing.Optional[dict] = {},
|
|
285
|
-
) -> api_client.MappedArgs:
|
|
286
|
-
args: api_client.MappedArgs = api_client.MappedArgs()
|
|
287
|
-
_query_params = {}
|
|
288
|
-
_path_params = {}
|
|
289
|
-
_body = {}
|
|
290
|
-
if order_type is not None:
|
|
291
|
-
_body["order_type"] = order_type
|
|
292
|
-
if time_in_force is not None:
|
|
293
|
-
_body["time_in_force"] = time_in_force
|
|
294
|
-
if price is not None:
|
|
295
|
-
_body["price"] = price
|
|
296
|
-
args.body = body if body is not None else _body
|
|
297
|
-
if user_id is not None:
|
|
298
|
-
_query_params["userId"] = user_id
|
|
299
|
-
if user_secret is not None:
|
|
300
|
-
_query_params["userSecret"] = user_secret
|
|
301
|
-
if account_id is not None:
|
|
302
|
-
_path_params["accountId"] = account_id
|
|
303
|
-
if option_strategy_id is not None:
|
|
304
|
-
_path_params["optionStrategyId"] = option_strategy_id
|
|
305
|
-
args.query = query_params if query_params else _query_params
|
|
306
|
-
args.path = path_params if path_params else _path_params
|
|
307
|
-
return args
|
|
308
|
-
|
|
309
|
-
async def _aplace_option_strategy_oapg(
|
|
310
|
-
self,
|
|
311
|
-
body: typing.Any = None,
|
|
312
|
-
query_params: typing.Optional[dict] = {},
|
|
313
|
-
path_params: typing.Optional[dict] = {},
|
|
314
|
-
skip_deserialization: bool = True,
|
|
315
|
-
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
316
|
-
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
317
|
-
content_type: str = 'application/json',
|
|
318
|
-
stream: bool = False,
|
|
319
|
-
**kwargs,
|
|
320
|
-
) -> typing.Union[
|
|
321
|
-
ApiResponseFor200Async,
|
|
322
|
-
api_client.ApiResponseWithoutDeserializationAsync,
|
|
323
|
-
AsyncGeneratorResponse,
|
|
324
|
-
]:
|
|
325
|
-
"""
|
|
326
|
-
Place an option strategy order
|
|
327
|
-
:param skip_deserialization: If true then api_response.response will be set but
|
|
328
|
-
api_response.body and api_response.headers will not be deserialized into schema
|
|
329
|
-
class instances
|
|
330
|
-
"""
|
|
331
|
-
self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
|
|
332
|
-
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
333
|
-
used_path = path.value
|
|
334
|
-
|
|
335
|
-
_path_params = {}
|
|
336
|
-
for parameter in (
|
|
337
|
-
request_path_account_id,
|
|
338
|
-
request_path_option_strategy_id,
|
|
339
|
-
):
|
|
340
|
-
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
341
|
-
if parameter_data is schemas.unset:
|
|
342
|
-
continue
|
|
343
|
-
serialized_data = parameter.serialize(parameter_data)
|
|
344
|
-
_path_params.update(serialized_data)
|
|
345
|
-
|
|
346
|
-
for k, v in _path_params.items():
|
|
347
|
-
used_path = used_path.replace('{%s}' % k, v)
|
|
348
|
-
|
|
349
|
-
prefix_separator_iterator = None
|
|
350
|
-
for parameter in (
|
|
351
|
-
request_query_user_id,
|
|
352
|
-
request_query_user_secret,
|
|
353
|
-
):
|
|
354
|
-
parameter_data = query_params.get(parameter.name, schemas.unset)
|
|
355
|
-
if parameter_data is schemas.unset:
|
|
356
|
-
continue
|
|
357
|
-
if prefix_separator_iterator is None:
|
|
358
|
-
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
|
359
|
-
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
|
360
|
-
for serialized_value in serialized_data.values():
|
|
361
|
-
used_path += serialized_value
|
|
362
|
-
|
|
363
|
-
_headers = HTTPHeaderDict()
|
|
364
|
-
# TODO add cookie handling
|
|
365
|
-
if accept_content_types:
|
|
366
|
-
for accept_content_type in accept_content_types:
|
|
367
|
-
_headers.add('Accept', accept_content_type)
|
|
368
|
-
method = 'post'.upper()
|
|
369
|
-
_headers.add('Content-Type', content_type)
|
|
370
|
-
|
|
371
|
-
if body is schemas.unset:
|
|
372
|
-
raise exceptions.ApiValueError(
|
|
373
|
-
'The required body parameter has an invalid value of: unset. Set a valid value instead')
|
|
374
|
-
_fields = None
|
|
375
|
-
_body = None
|
|
376
|
-
request_before_hook(
|
|
377
|
-
resource_path=used_path,
|
|
378
|
-
method=method,
|
|
379
|
-
configuration=self.api_client.configuration,
|
|
380
|
-
path_template='/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute',
|
|
381
|
-
body=body,
|
|
382
|
-
auth_settings=_auth,
|
|
383
|
-
headers=_headers,
|
|
384
|
-
)
|
|
385
|
-
serialized_data = request_body_typing_any.serialize(body, content_type)
|
|
386
|
-
if 'fields' in serialized_data:
|
|
387
|
-
_fields = serialized_data['fields']
|
|
388
|
-
elif 'body' in serialized_data:
|
|
389
|
-
_body = serialized_data['body']
|
|
390
|
-
|
|
391
|
-
response = await self.api_client.async_call_api(
|
|
392
|
-
resource_path=used_path,
|
|
393
|
-
method=method,
|
|
394
|
-
headers=_headers,
|
|
395
|
-
fields=_fields,
|
|
396
|
-
serialized_body=_body,
|
|
397
|
-
body=body,
|
|
398
|
-
auth_settings=_auth,
|
|
399
|
-
prefix_separator_iterator=prefix_separator_iterator,
|
|
400
|
-
timeout=timeout,
|
|
401
|
-
**kwargs
|
|
402
|
-
)
|
|
403
|
-
|
|
404
|
-
if stream:
|
|
405
|
-
if not 200 <= response.http_response.status <= 299:
|
|
406
|
-
body = (await response.http_response.content.read()).decode("utf-8")
|
|
407
|
-
raise exceptions.ApiStreamingException(
|
|
408
|
-
status=response.http_response.status,
|
|
409
|
-
reason=response.http_response.reason,
|
|
410
|
-
body=body,
|
|
411
|
-
)
|
|
412
|
-
|
|
413
|
-
async def stream_iterator():
|
|
414
|
-
"""
|
|
415
|
-
iterates over response.http_response.content and closes connection once iteration has finished
|
|
416
|
-
"""
|
|
417
|
-
async for line in response.http_response.content:
|
|
418
|
-
if line == b'\r\n':
|
|
419
|
-
continue
|
|
420
|
-
yield line
|
|
421
|
-
response.http_response.close()
|
|
422
|
-
await response.session.close()
|
|
423
|
-
return AsyncGeneratorResponse(
|
|
424
|
-
content=stream_iterator(),
|
|
425
|
-
headers=response.http_response.headers,
|
|
426
|
-
status=response.http_response.status,
|
|
427
|
-
response=response.http_response
|
|
428
|
-
)
|
|
429
|
-
|
|
430
|
-
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
431
|
-
if response_for_status:
|
|
432
|
-
api_response = await response_for_status.deserialize_async(
|
|
433
|
-
response,
|
|
434
|
-
self.api_client.configuration,
|
|
435
|
-
skip_deserialization=skip_deserialization
|
|
436
|
-
)
|
|
437
|
-
else:
|
|
438
|
-
# If response data is JSON then deserialize for SDK consumer convenience
|
|
439
|
-
is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
|
|
440
|
-
api_response = api_client.ApiResponseWithoutDeserializationAsync(
|
|
441
|
-
body=await response.http_response.json() if is_json else await response.http_response.text(),
|
|
442
|
-
response=response.http_response,
|
|
443
|
-
round_trip_time=response.round_trip_time,
|
|
444
|
-
status=response.http_response.status,
|
|
445
|
-
headers=response.http_response.headers,
|
|
446
|
-
)
|
|
447
|
-
|
|
448
|
-
if not 200 <= api_response.status <= 299:
|
|
449
|
-
raise exceptions.ApiException(api_response=api_response)
|
|
450
|
-
|
|
451
|
-
# cleanup session / response
|
|
452
|
-
response.http_response.close()
|
|
453
|
-
await response.session.close()
|
|
454
|
-
|
|
455
|
-
return api_response
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
def _place_option_strategy_oapg(
|
|
459
|
-
self,
|
|
460
|
-
body: typing.Any = None,
|
|
461
|
-
query_params: typing.Optional[dict] = {},
|
|
462
|
-
path_params: typing.Optional[dict] = {},
|
|
463
|
-
skip_deserialization: bool = True,
|
|
464
|
-
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
465
|
-
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
466
|
-
content_type: str = 'application/json',
|
|
467
|
-
stream: bool = False,
|
|
468
|
-
) -> typing.Union[
|
|
469
|
-
ApiResponseFor200,
|
|
470
|
-
api_client.ApiResponseWithoutDeserialization,
|
|
471
|
-
]:
|
|
472
|
-
"""
|
|
473
|
-
Place an option strategy order
|
|
474
|
-
:param skip_deserialization: If true then api_response.response will be set but
|
|
475
|
-
api_response.body and api_response.headers will not be deserialized into schema
|
|
476
|
-
class instances
|
|
477
|
-
"""
|
|
478
|
-
self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
|
|
479
|
-
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
480
|
-
used_path = path.value
|
|
481
|
-
|
|
482
|
-
_path_params = {}
|
|
483
|
-
for parameter in (
|
|
484
|
-
request_path_account_id,
|
|
485
|
-
request_path_option_strategy_id,
|
|
486
|
-
):
|
|
487
|
-
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
488
|
-
if parameter_data is schemas.unset:
|
|
489
|
-
continue
|
|
490
|
-
serialized_data = parameter.serialize(parameter_data)
|
|
491
|
-
_path_params.update(serialized_data)
|
|
492
|
-
|
|
493
|
-
for k, v in _path_params.items():
|
|
494
|
-
used_path = used_path.replace('{%s}' % k, v)
|
|
495
|
-
|
|
496
|
-
prefix_separator_iterator = None
|
|
497
|
-
for parameter in (
|
|
498
|
-
request_query_user_id,
|
|
499
|
-
request_query_user_secret,
|
|
500
|
-
):
|
|
501
|
-
parameter_data = query_params.get(parameter.name, schemas.unset)
|
|
502
|
-
if parameter_data is schemas.unset:
|
|
503
|
-
continue
|
|
504
|
-
if prefix_separator_iterator is None:
|
|
505
|
-
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
|
506
|
-
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
|
507
|
-
for serialized_value in serialized_data.values():
|
|
508
|
-
used_path += serialized_value
|
|
509
|
-
|
|
510
|
-
_headers = HTTPHeaderDict()
|
|
511
|
-
# TODO add cookie handling
|
|
512
|
-
if accept_content_types:
|
|
513
|
-
for accept_content_type in accept_content_types:
|
|
514
|
-
_headers.add('Accept', accept_content_type)
|
|
515
|
-
method = 'post'.upper()
|
|
516
|
-
_headers.add('Content-Type', content_type)
|
|
517
|
-
|
|
518
|
-
if body is schemas.unset:
|
|
519
|
-
raise exceptions.ApiValueError(
|
|
520
|
-
'The required body parameter has an invalid value of: unset. Set a valid value instead')
|
|
521
|
-
_fields = None
|
|
522
|
-
_body = None
|
|
523
|
-
request_before_hook(
|
|
524
|
-
resource_path=used_path,
|
|
525
|
-
method=method,
|
|
526
|
-
configuration=self.api_client.configuration,
|
|
527
|
-
path_template='/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute',
|
|
528
|
-
body=body,
|
|
529
|
-
auth_settings=_auth,
|
|
530
|
-
headers=_headers,
|
|
531
|
-
)
|
|
532
|
-
serialized_data = request_body_typing_any.serialize(body, content_type)
|
|
533
|
-
if 'fields' in serialized_data:
|
|
534
|
-
_fields = serialized_data['fields']
|
|
535
|
-
elif 'body' in serialized_data:
|
|
536
|
-
_body = serialized_data['body']
|
|
537
|
-
|
|
538
|
-
response = self.api_client.call_api(
|
|
539
|
-
resource_path=used_path,
|
|
540
|
-
method=method,
|
|
541
|
-
headers=_headers,
|
|
542
|
-
fields=_fields,
|
|
543
|
-
serialized_body=_body,
|
|
544
|
-
body=body,
|
|
545
|
-
auth_settings=_auth,
|
|
546
|
-
prefix_separator_iterator=prefix_separator_iterator,
|
|
547
|
-
timeout=timeout,
|
|
548
|
-
)
|
|
549
|
-
|
|
550
|
-
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
551
|
-
if response_for_status:
|
|
552
|
-
api_response = response_for_status.deserialize(
|
|
553
|
-
response,
|
|
554
|
-
self.api_client.configuration,
|
|
555
|
-
skip_deserialization=skip_deserialization
|
|
556
|
-
)
|
|
557
|
-
else:
|
|
558
|
-
# If response data is JSON then deserialize for SDK consumer convenience
|
|
559
|
-
is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
|
|
560
|
-
api_response = api_client.ApiResponseWithoutDeserialization(
|
|
561
|
-
body=json.loads(response.http_response.data) if is_json else response.http_response.data,
|
|
562
|
-
response=response.http_response,
|
|
563
|
-
round_trip_time=response.round_trip_time,
|
|
564
|
-
status=response.http_response.status,
|
|
565
|
-
headers=response.http_response.headers,
|
|
566
|
-
)
|
|
567
|
-
|
|
568
|
-
if not 200 <= api_response.status <= 299:
|
|
569
|
-
raise exceptions.ApiException(api_response=api_response)
|
|
570
|
-
|
|
571
|
-
return api_response
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
class PlaceOptionStrategy(BaseApi):
|
|
575
|
-
# this class is used by api classes that refer to endpoints with operationId fn names
|
|
576
|
-
|
|
577
|
-
async def aplace_option_strategy(
|
|
578
|
-
self,
|
|
579
|
-
body: typing.Optional[typing.Any] = None,
|
|
580
|
-
order_type: typing.Optional[OrderTypeStrict] = None,
|
|
581
|
-
time_in_force: typing.Optional[TimeInForceStrict] = None,
|
|
582
|
-
user_id: typing.Optional[str] = None,
|
|
583
|
-
user_secret: typing.Optional[str] = None,
|
|
584
|
-
account_id: typing.Optional[str] = None,
|
|
585
|
-
option_strategy_id: typing.Optional[str] = None,
|
|
586
|
-
price: typing.Optional[Price] = None,
|
|
587
|
-
query_params: typing.Optional[dict] = {},
|
|
588
|
-
path_params: typing.Optional[dict] = {},
|
|
589
|
-
**kwargs,
|
|
590
|
-
) -> typing.Union[
|
|
591
|
-
ApiResponseFor200Async,
|
|
592
|
-
api_client.ApiResponseWithoutDeserializationAsync,
|
|
593
|
-
AsyncGeneratorResponse,
|
|
594
|
-
]:
|
|
595
|
-
args = self._place_option_strategy_mapped_args(
|
|
596
|
-
body=body,
|
|
597
|
-
query_params=query_params,
|
|
598
|
-
path_params=path_params,
|
|
599
|
-
order_type=order_type,
|
|
600
|
-
time_in_force=time_in_force,
|
|
601
|
-
user_id=user_id,
|
|
602
|
-
user_secret=user_secret,
|
|
603
|
-
account_id=account_id,
|
|
604
|
-
option_strategy_id=option_strategy_id,
|
|
605
|
-
price=price,
|
|
606
|
-
)
|
|
607
|
-
return await self._aplace_option_strategy_oapg(
|
|
608
|
-
body=args.body,
|
|
609
|
-
query_params=args.query,
|
|
610
|
-
path_params=args.path,
|
|
611
|
-
**kwargs,
|
|
612
|
-
)
|
|
613
|
-
|
|
614
|
-
def place_option_strategy(
|
|
615
|
-
self,
|
|
616
|
-
body: typing.Optional[typing.Any] = None,
|
|
617
|
-
order_type: typing.Optional[OrderTypeStrict] = None,
|
|
618
|
-
time_in_force: typing.Optional[TimeInForceStrict] = None,
|
|
619
|
-
user_id: typing.Optional[str] = None,
|
|
620
|
-
user_secret: typing.Optional[str] = None,
|
|
621
|
-
account_id: typing.Optional[str] = None,
|
|
622
|
-
option_strategy_id: typing.Optional[str] = None,
|
|
623
|
-
price: typing.Optional[Price] = None,
|
|
624
|
-
query_params: typing.Optional[dict] = {},
|
|
625
|
-
path_params: typing.Optional[dict] = {},
|
|
626
|
-
) -> typing.Union[
|
|
627
|
-
ApiResponseFor200,
|
|
628
|
-
api_client.ApiResponseWithoutDeserialization,
|
|
629
|
-
]:
|
|
630
|
-
""" Places the option strategy order and returns the order record received from the brokerage. """
|
|
631
|
-
args = self._place_option_strategy_mapped_args(
|
|
632
|
-
body=body,
|
|
633
|
-
query_params=query_params,
|
|
634
|
-
path_params=path_params,
|
|
635
|
-
order_type=order_type,
|
|
636
|
-
time_in_force=time_in_force,
|
|
637
|
-
user_id=user_id,
|
|
638
|
-
user_secret=user_secret,
|
|
639
|
-
account_id=account_id,
|
|
640
|
-
option_strategy_id=option_strategy_id,
|
|
641
|
-
price=price,
|
|
642
|
-
)
|
|
643
|
-
return self._place_option_strategy_oapg(
|
|
644
|
-
body=args.body,
|
|
645
|
-
query_params=args.query,
|
|
646
|
-
path_params=args.path,
|
|
647
|
-
)
|
|
648
|
-
|
|
649
|
-
class ApiForpost(BaseApi):
|
|
650
|
-
# this class is used by api classes that refer to endpoints by path and http method names
|
|
651
|
-
|
|
652
|
-
async def apost(
|
|
653
|
-
self,
|
|
654
|
-
body: typing.Optional[typing.Any] = None,
|
|
655
|
-
order_type: typing.Optional[OrderTypeStrict] = None,
|
|
656
|
-
time_in_force: typing.Optional[TimeInForceStrict] = None,
|
|
657
|
-
user_id: typing.Optional[str] = None,
|
|
658
|
-
user_secret: typing.Optional[str] = None,
|
|
659
|
-
account_id: typing.Optional[str] = None,
|
|
660
|
-
option_strategy_id: typing.Optional[str] = None,
|
|
661
|
-
price: typing.Optional[Price] = None,
|
|
662
|
-
query_params: typing.Optional[dict] = {},
|
|
663
|
-
path_params: typing.Optional[dict] = {},
|
|
664
|
-
**kwargs,
|
|
665
|
-
) -> typing.Union[
|
|
666
|
-
ApiResponseFor200Async,
|
|
667
|
-
api_client.ApiResponseWithoutDeserializationAsync,
|
|
668
|
-
AsyncGeneratorResponse,
|
|
669
|
-
]:
|
|
670
|
-
args = self._place_option_strategy_mapped_args(
|
|
671
|
-
body=body,
|
|
672
|
-
query_params=query_params,
|
|
673
|
-
path_params=path_params,
|
|
674
|
-
order_type=order_type,
|
|
675
|
-
time_in_force=time_in_force,
|
|
676
|
-
user_id=user_id,
|
|
677
|
-
user_secret=user_secret,
|
|
678
|
-
account_id=account_id,
|
|
679
|
-
option_strategy_id=option_strategy_id,
|
|
680
|
-
price=price,
|
|
681
|
-
)
|
|
682
|
-
return await self._aplace_option_strategy_oapg(
|
|
683
|
-
body=args.body,
|
|
684
|
-
query_params=args.query,
|
|
685
|
-
path_params=args.path,
|
|
686
|
-
**kwargs,
|
|
687
|
-
)
|
|
688
|
-
|
|
689
|
-
def post(
|
|
690
|
-
self,
|
|
691
|
-
body: typing.Optional[typing.Any] = None,
|
|
692
|
-
order_type: typing.Optional[OrderTypeStrict] = None,
|
|
693
|
-
time_in_force: typing.Optional[TimeInForceStrict] = None,
|
|
694
|
-
user_id: typing.Optional[str] = None,
|
|
695
|
-
user_secret: typing.Optional[str] = None,
|
|
696
|
-
account_id: typing.Optional[str] = None,
|
|
697
|
-
option_strategy_id: typing.Optional[str] = None,
|
|
698
|
-
price: typing.Optional[Price] = None,
|
|
699
|
-
query_params: typing.Optional[dict] = {},
|
|
700
|
-
path_params: typing.Optional[dict] = {},
|
|
701
|
-
) -> typing.Union[
|
|
702
|
-
ApiResponseFor200,
|
|
703
|
-
api_client.ApiResponseWithoutDeserialization,
|
|
704
|
-
]:
|
|
705
|
-
""" Places the option strategy order and returns the order record received from the brokerage. """
|
|
706
|
-
args = self._place_option_strategy_mapped_args(
|
|
707
|
-
body=body,
|
|
708
|
-
query_params=query_params,
|
|
709
|
-
path_params=path_params,
|
|
710
|
-
order_type=order_type,
|
|
711
|
-
time_in_force=time_in_force,
|
|
712
|
-
user_id=user_id,
|
|
713
|
-
user_secret=user_secret,
|
|
714
|
-
account_id=account_id,
|
|
715
|
-
option_strategy_id=option_strategy_id,
|
|
716
|
-
price=price,
|
|
717
|
-
)
|
|
718
|
-
return self._place_option_strategy_oapg(
|
|
719
|
-
body=args.body,
|
|
720
|
-
query_params=args.query,
|
|
721
|
-
path_params=args.path,
|
|
722
|
-
)
|
|
723
|
-
|