diff --git a/end_to_end_tests/__init__.py b/end_to_end_tests/__init__.py index 3793e0395..f165cc2c5 100644 --- a/end_to_end_tests/__init__.py +++ b/end_to_end_tests/__init__.py @@ -1,4 +1,5 @@ -""" Generate a complete client and verify that it is correct """ +"""Generate a complete client and verify that it is correct""" + import pytest pytest.register_assert_rewrite("end_to_end_tests.end_to_end_test_helpers") diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py index e09dee3e3..ef90e48e4 100644 --- a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py +++ b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/responses/__init__.py @@ -2,7 +2,11 @@ import types -from . import post_responses_unions_simple_before_complex, reference_response, text_response +from . import ( + post_responses_unions_simple_before_complex, + reference_response, + text_response, +) class ResponsesEndpoints: diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py index e05334a5f..c6e6296ed 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py @@ -34,9 +34,15 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -157,9 +163,15 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -206,7 +218,9 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": def get_httpx_client(self) -> httpx.Client: """Get the underlying httpx.Client, constructing a new one if not previously set""" if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._client = httpx.Client( base_url=self._base_url, cookies=self._cookies, @@ -227,7 +241,9 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client( + self, async_client: httpx.AsyncClient + ) -> "AuthenticatedClient": """Manually the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -238,7 +254,9 @@ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Authentica def get_async_httpx_client(self) -> httpx.AsyncClient: """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._async_client = httpx.AsyncClient( base_url=self._base_url, cookies=self._cookies, diff --git a/end_to_end_tests/functional_tests/generated_code_execution/test_arrays.py b/end_to_end_tests/functional_tests/generated_code_execution/test_arrays.py index 443d764c5..ce0ebd005 100644 --- a/end_to_end_tests/functional_tests/generated_code_execution/test_arrays.py +++ b/end_to_end_tests/functional_tests/generated_code_execution/test_arrays.py @@ -9,7 +9,7 @@ @with_generated_client_fixture( -""" + """ components: schemas: SimpleObject: @@ -31,7 +31,8 @@ arrayProp: type: array items: {"$ref": "#/components/schemas/SimpleObject"} -""") +""" +) @with_generated_code_imports( ".models.ModelWithArrayOfAny", ".models.ModelWithArrayOfInts", @@ -61,17 +62,27 @@ def test_array_of_object(self, ModelWithArrayOfObjects, SimpleObject): assert_model_decode_encode( ModelWithArrayOfObjects, {"arrayProp": [{"name": "a"}, {"name": "b"}]}, - ModelWithArrayOfObjects(array_prop=[SimpleObject(name="a"), SimpleObject(name="b")]), + ModelWithArrayOfObjects( + array_prop=[SimpleObject(name="a"), SimpleObject(name="b")] + ), ) - def test_type_hints(self, ModelWithArrayOfAny, ModelWithArrayOfInts, ModelWithArrayOfObjects, Unset): - assert_model_property_type_hint(ModelWithArrayOfAny, "array_prop", Union[list[Any], Unset]) - assert_model_property_type_hint(ModelWithArrayOfInts, "array_prop", Union[list[int], Unset]) - assert_model_property_type_hint(ModelWithArrayOfObjects, "array_prop", Union[list["SimpleObject"], Unset]) + def test_type_hints( + self, ModelWithArrayOfAny, ModelWithArrayOfInts, ModelWithArrayOfObjects, Unset + ): + assert_model_property_type_hint( + ModelWithArrayOfAny, "array_prop", Union[list[Any], Unset] + ) + assert_model_property_type_hint( + ModelWithArrayOfInts, "array_prop", Union[list[int], Unset] + ) + assert_model_property_type_hint( + ModelWithArrayOfObjects, "array_prop", Union[list["SimpleObject"], Unset] + ) @with_generated_client_fixture( -""" + """ components: schemas: SimpleObject: @@ -102,7 +113,8 @@ def test_type_hints(self, ModelWithArrayOfAny, ModelWithArrayOfInts, ModelWithAr - $ref: "#/components/schemas/SimpleObject" items: type: string -""") +""" +) @with_generated_code_imports( ".models.ModelWithSinglePrefixItem", ".models.ModelWithPrefixItems", @@ -132,8 +144,16 @@ def test_prefix_items_and_regular_items(self, ModelWithMixedItems, SimpleObject) ModelWithMixedItems(array_prop=[SimpleObject(name="a"), "b"]), ) - def test_type_hints(self, ModelWithSinglePrefixItem, ModelWithPrefixItems, ModelWithMixedItems, Unset): - assert_model_property_type_hint(ModelWithSinglePrefixItem, "array_prop", Union[list[str], Unset]) + def test_type_hints( + self, + ModelWithSinglePrefixItem, + ModelWithPrefixItems, + ModelWithMixedItems, + Unset, + ): + assert_model_property_type_hint( + ModelWithSinglePrefixItem, "array_prop", Union[list[str], Unset] + ) assert_model_property_type_hint( ModelWithPrefixItems, "array_prop", diff --git a/end_to_end_tests/functional_tests/generated_code_execution/test_defaults.py b/end_to_end_tests/functional_tests/generated_code_execution/test_defaults.py index 5f8affb25..06311c03b 100644 --- a/end_to_end_tests/functional_tests/generated_code_execution/test_defaults.py +++ b/end_to_end_tests/functional_tests/generated_code_execution/test_defaults.py @@ -8,7 +8,7 @@ @with_generated_client_fixture( -""" + """ components: schemas: MyModel: @@ -38,7 +38,8 @@ unionWithValidDefaultForType2: anyOf: [{"type": "boolean"}, {"type": "integer"}] default: 3 -""") +""" +) @with_generated_code_imports(".models.MyModel") class TestSimpleDefaults: # Note, the null/None type is not covered here due to a known bug: @@ -51,7 +52,9 @@ def test_defaults_in_initializer(self, MyModel): number_prop=1.5, int_prop=2, date_prop=datetime.date(2024, 1, 2), - date_time_prop=datetime.datetime(2024, 1, 2, 3, 4, 5, tzinfo=datetime.timezone.utc), + date_time_prop=datetime.datetime( + 2024, 1, 2, 3, 4, 5, tzinfo=datetime.timezone.utc + ), uuid_prop=uuid.UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41"), any_prop_with_string="b", any_prop_with_int=3, @@ -69,9 +72,8 @@ def test_defaults_in_initializer(self, MyModel): ) - @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -85,7 +87,8 @@ def test_defaults_in_initializer(self, MyModel): - $ref: "#/components/schemas/MyEnum" default: "a" -""") +""" +) @with_generated_code_imports(".models.MyEnum", ".models.MyModel") class TestEnumDefaults: def test_enum_default(self, MyEnum, MyModel): @@ -93,7 +96,7 @@ def test_enum_default(self, MyEnum, MyModel): @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: diff --git a/end_to_end_tests/functional_tests/generated_code_execution/test_docstrings.py b/end_to_end_tests/functional_tests/generated_code_execution/test_docstrings.py index d2d560780..faed1dcf9 100644 --- a/end_to_end_tests/functional_tests/generated_code_execution/test_docstrings.py +++ b/end_to_end_tests/functional_tests/generated_code_execution/test_docstrings.py @@ -13,12 +13,12 @@ def __init__(self, item: Any): self.lines = [line.lstrip() for line in item.__doc__.split("\n")] def get_section(self, header_line: str) -> list[str]: - lines = self.lines[self.lines.index(header_line)+1:] - return lines[0:lines.index("")] + lines = self.lines[self.lines.index(header_line) + 1 :] + return lines[0 : lines.index("")] @with_generated_client_fixture( -""" + """ components: schemas: MyModel: @@ -34,7 +34,8 @@ def get_section(self, header_line: str) -> list[str]: undescribedProp: type: string required: ["reqStr", "undescribedProp"] -""") +""" +) @with_generated_code_import(".models.MyModel") class TestSchemaDocstrings: def test_model_description(self, MyModel): @@ -49,7 +50,7 @@ def test_model_properties(self, MyModel): @with_generated_client_fixture( -""" + """ tags: - name: service1 paths: @@ -130,10 +131,17 @@ def test_model_properties(self, MyModel): Thing: type: object description: The thing. -""") -@with_generated_code_import(".api.service1.get_simple_thing.sync", alias="get_simple_thing_sync") -@with_generated_code_import(".api.service1.post_simple_thing.sync", alias="post_simple_thing_sync") -@with_generated_code_import(".api.service1.get_attribute_by_index.sync", alias="get_attribute_by_index_sync") +""" +) +@with_generated_code_import( + ".api.service1.get_simple_thing.sync", alias="get_simple_thing_sync" +) +@with_generated_code_import( + ".api.service1.post_simple_thing.sync", alias="post_simple_thing_sync" +) +@with_generated_code_import( + ".api.service1.get_attribute_by_index.sync", alias="get_attribute_by_index_sync" +) class TestEndpointDocstrings: def test_description(self, get_simple_thing_sync): assert DocstringParser(get_simple_thing_sync).lines[0] == "Get a simple thing." @@ -144,7 +152,9 @@ def test_response_single_type(self, get_simple_thing_sync): ] def test_response_union_type(self, post_simple_thing_sync): - returns_line = DocstringParser(post_simple_thing_sync).get_section("Returns:")[0] + returns_line = DocstringParser(post_simple_thing_sync).get_section("Returns:")[ + 0 + ] assert returns_line in ( "Union[GoodResponse, ErrorResponse]", "Union[ErrorResponse, GoodResponse]", diff --git a/end_to_end_tests/functional_tests/generated_code_execution/test_enums_and_consts.py b/end_to_end_tests/functional_tests/generated_code_execution/test_enums_and_consts.py index 605e47e7b..3cd0985f4 100644 --- a/end_to_end_tests/functional_tests/generated_code_execution/test_enums_and_consts.py +++ b/end_to_end_tests/functional_tests/generated_code_execution/test_enums_and_consts.py @@ -10,7 +10,7 @@ @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -26,7 +26,8 @@ properties: enumProp: {"$ref": "#/components/schemas/MyEnum"} required: ["enumProp"] -""") +""" +) @with_generated_code_imports( ".models.MyEnum", ".models.MyModel", @@ -46,12 +47,14 @@ class TestStringEnumClass: ("A_THING_WITH_SPACES", "a Thing WIth spaces"), ("VALUE_6", ""), ], - ) + ) def test_enum_values(self, MyEnum, expected_name, expected_value): assert getattr(MyEnum, expected_name) == MyEnum(expected_value) def test_enum_prop_in_object(self, MyEnum, MyModel, MyModelInlineEnumProp): - assert_model_decode_encode(MyModel, {"enumProp": "B"}, MyModel(enum_prop=MyEnum.B)) + assert_model_decode_encode( + MyModel, {"enumProp": "B"}, MyModel(enum_prop=MyEnum.B) + ) assert_model_decode_encode( MyModel, {"inlineEnumProp": "a"}, @@ -60,7 +63,7 @@ def test_enum_prop_in_object(self, MyEnum, MyModel, MyModelInlineEnumProp): def test_type_hints(self, MyModel, MyModelWithRequired, MyEnum, Unset): optional_type = Union[Unset, MyEnum] - assert_model_property_type_hint(MyModel,"enum_prop", optional_type) + assert_model_property_type_hint(MyModel, "enum_prop", optional_type) assert_model_property_type_hint(MyModelWithRequired, "enum_prop", MyEnum) def test_invalid_values(self, MyModel): @@ -73,7 +76,7 @@ def test_invalid_values(self, MyModel): @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -89,7 +92,8 @@ def test_invalid_values(self, MyModel): properties: enumProp: {"$ref": "#/components/schemas/MyEnum"} required: ["enumProp"] -""") +""" +) @with_generated_code_imports( ".models.MyEnum", ".models.MyModel", @@ -105,12 +109,14 @@ class TestIntEnumClass: ("VALUE_3", 3), ("VALUE_NEGATIVE_4", -4), ], - ) + ) def test_enum_values(self, MyEnum, expected_name, expected_value): assert getattr(MyEnum, expected_name) == MyEnum(expected_value) def test_enum_prop_in_object(self, MyEnum, MyModel, MyModelInlineEnumProp): - assert_model_decode_encode(MyModel, {"enumProp": 2}, MyModel(enum_prop=MyEnum.VALUE_2)) + assert_model_decode_encode( + MyModel, {"enumProp": 2}, MyModel(enum_prop=MyEnum.VALUE_2) + ) assert_model_decode_encode( MyModel, {"inlineEnumProp": 2}, @@ -119,7 +125,7 @@ def test_enum_prop_in_object(self, MyEnum, MyModel, MyModelInlineEnumProp): def test_type_hints(self, MyModel, MyModelWithRequired, MyEnum, Unset): optional_type = Union[Unset, MyEnum] - assert_model_property_type_hint(MyModel,"enum_prop", optional_type) + assert_model_property_type_hint(MyModel, "enum_prop", optional_type) assert_model_property_type_hint(MyModelWithRequired, "enum_prop", MyEnum) def test_invalid_values(self, MyModel): @@ -130,7 +136,7 @@ def test_invalid_values(self, MyModel): @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -141,7 +147,8 @@ def test_invalid_values(self, MyModel): "Three", "Negative Four" ] -""") +""" +) @with_generated_code_imports( ".models.MyEnum", ) @@ -159,7 +166,7 @@ def test_enum_values(self, MyEnum, expected_name, expected_value): @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -178,10 +185,11 @@ def test_enum_values(self, MyEnum, expected_name, expected_value): - type: "null" enumIncludingNullProp: {"$ref": "#/components/schemas/MyEnumIncludingNull"} nullOnlyEnumProp: {"$ref": "#/components/schemas/MyNullOnlyEnum"} -""") +""" +) @with_generated_code_imports( ".models.MyEnum", - ".models.MyEnumIncludingNullType1", # see comment in test_nullable_enum_prop + ".models.MyEnumIncludingNullType1", # see comment in test_nullable_enum_prop ".models.MyModel", ".types.Unset", ) @@ -189,23 +197,33 @@ class TestNullableEnums: def test_nullable_enum_prop(self, MyModel, MyEnum, MyEnumIncludingNullType1): # Note, MyEnumIncludingNullType1 should be named just MyEnumIncludingNull - # known bug: https://github.com/openapi-generators/openapi-python-client/issues/1120 - assert_model_decode_encode(MyModel, {"nullableEnumProp": "b"}, MyModel(nullable_enum_prop=MyEnum.B)) - assert_model_decode_encode(MyModel, {"nullableEnumProp": None}, MyModel(nullable_enum_prop=None)) + assert_model_decode_encode( + MyModel, {"nullableEnumProp": "b"}, MyModel(nullable_enum_prop=MyEnum.B) + ) + assert_model_decode_encode( + MyModel, {"nullableEnumProp": None}, MyModel(nullable_enum_prop=None) + ) assert_model_decode_encode( MyModel, {"enumIncludingNullProp": "a"}, MyModel(enum_including_null_prop=MyEnumIncludingNullType1.A), ) - assert_model_decode_encode( MyModel, {"enumIncludingNullProp": None}, MyModel(enum_including_null_prop=None)) - assert_model_decode_encode(MyModel, {"nullOnlyEnumProp": None}, MyModel(null_only_enum_prop=None)) - + assert_model_decode_encode( + MyModel, + {"enumIncludingNullProp": None}, + MyModel(enum_including_null_prop=None), + ) + assert_model_decode_encode( + MyModel, {"nullOnlyEnumProp": None}, MyModel(null_only_enum_prop=None) + ) + def test_type_hints(self, MyModel, MyEnum, Unset): expected_type = Union[MyEnum, None, Unset] assert_model_property_type_hint(MyModel, "nullable_enum_prop", expected_type) - + @with_generated_client_fixture( -""" + """ components: schemas: MyModel: @@ -244,8 +262,9 @@ def test_invalid_int(self, MyModel): # The following tests of literal enums use basically the same specs as the tests above, but # the "literal_enums" option is enabled in the test configuration. + @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -273,8 +292,10 @@ class TestStringLiteralEnum: def test_enum_prop(self, MyModel): assert_model_decode_encode(MyModel, {"enumProp": "a"}, MyModel(enum_prop="a")) assert_model_decode_encode(MyModel, {"enumProp": "A"}, MyModel(enum_prop="A")) - assert_model_decode_encode(MyModel, {"inlineEnumProp": "a"}, MyModel(inline_enum_prop="a")) - + assert_model_decode_encode( + MyModel, {"inlineEnumProp": "a"}, MyModel(inline_enum_prop="a") + ) + def test_type_hints(self, MyModel, MyModelWithRequired, Unset): literal_type = Literal["a", "A", "b"] optional_type = Union[Unset, literal_type] @@ -289,7 +310,7 @@ def test_invalid_values(self, MyModel): @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -317,8 +338,10 @@ class TestIntLiteralEnum: def test_enum_prop(self, MyModel): assert_model_decode_encode(MyModel, {"enumProp": 2}, MyModel(enum_prop=2)) assert_model_decode_encode(MyModel, {"enumProp": -4}, MyModel(enum_prop=-4)) - assert_model_decode_encode(MyModel, {"inlineEnumProp": 2}, MyModel(inline_enum_prop=2)) - + assert_model_decode_encode( + MyModel, {"inlineEnumProp": 2}, MyModel(inline_enum_prop=2) + ) + def test_type_hints(self, MyModel, MyModelWithRequired, Unset): literal_type = Literal[2, 3, -4] optional_type = Union[Unset, literal_type] @@ -333,7 +356,7 @@ def test_invalid_values(self, MyModel): @with_generated_client_fixture( -""" + """ components: schemas: MyEnum: @@ -359,8 +382,22 @@ def test_invalid_values(self, MyModel): @with_generated_code_imports(".models.MyModel") class TestNullableLiteralEnum: def test_nullable_enum_prop(self, MyModel): - assert_model_decode_encode(MyModel, {"nullableEnumProp": "B"}, MyModel(nullable_enum_prop="B")) - assert_model_decode_encode(MyModel, {"nullableEnumProp": None}, MyModel(nullable_enum_prop=None)) - assert_model_decode_encode(MyModel, {"enumIncludingNullProp": "a"}, MyModel(enum_including_null_prop="a")) - assert_model_decode_encode(MyModel, {"enumIncludingNullProp": None}, MyModel(enum_including_null_prop=None)) - assert_model_decode_encode(MyModel, {"nullOnlyEnumProp": None}, MyModel(null_only_enum_prop=None)) + assert_model_decode_encode( + MyModel, {"nullableEnumProp": "B"}, MyModel(nullable_enum_prop="B") + ) + assert_model_decode_encode( + MyModel, {"nullableEnumProp": None}, MyModel(nullable_enum_prop=None) + ) + assert_model_decode_encode( + MyModel, + {"enumIncludingNullProp": "a"}, + MyModel(enum_including_null_prop="a"), + ) + assert_model_decode_encode( + MyModel, + {"enumIncludingNullProp": None}, + MyModel(enum_including_null_prop=None), + ) + assert_model_decode_encode( + MyModel, {"nullOnlyEnumProp": None}, MyModel(null_only_enum_prop=None) + ) diff --git a/end_to_end_tests/functional_tests/generated_code_execution/test_properties.py b/end_to_end_tests/functional_tests/generated_code_execution/test_properties.py index e1cfce9a5..017915a9d 100644 --- a/end_to_end_tests/functional_tests/generated_code_execution/test_properties.py +++ b/end_to_end_tests/functional_tests/generated_code_execution/test_properties.py @@ -12,7 +12,7 @@ @with_generated_client_fixture( -""" + """ components: schemas: MyModel: @@ -29,7 +29,8 @@ properties: req3: {"type": "string"} required: ["req3"] -""") +""" +) @with_generated_code_imports( ".models.MyModel", ".models.DerivedModel", @@ -74,7 +75,7 @@ def test_type_hints(self, MyModel, Unset): @with_generated_client_fixture( -""" + """ components: schemas: MyModel: @@ -89,7 +90,8 @@ def test_type_hints(self, MyModel, Unset): anyProp: {} AnyObject: type: object -""") +""" +) @with_generated_code_imports( ".models.MyModel", ".models.AnyObject", @@ -104,7 +106,7 @@ def test_decode_encode(self, MyModel, AnyObject): "intProp": 2, "anyObjectProp": {"d": 3}, "nullProp": None, - "anyProp": "e" + "anyProp": "e", } expected_any_object = AnyObject() expected_any_object.additional_properties = {"d": 3} @@ -116,10 +118,10 @@ def test_decode_encode(self, MyModel, AnyObject): string_prop="a", number_prop=1.5, int_prop=2, - any_object_prop = expected_any_object, + any_object_prop=expected_any_object, null_prop=None, any_prop="e", - ) + ), ) @pytest.mark.parametrize( @@ -138,13 +140,15 @@ def test_type_hints(self, MyModel, Unset): assert_model_property_type_hint(MyModel, "string_prop", Union[str, Unset]) assert_model_property_type_hint(MyModel, "number_prop", Union[float, Unset]) assert_model_property_type_hint(MyModel, "int_prop", Union[int, Unset]) - assert_model_property_type_hint(MyModel, "any_object_prop", Union[ForwardRef("AnyObject"), Unset]) + assert_model_property_type_hint( + MyModel, "any_object_prop", Union[ForwardRef("AnyObject"), Unset] + ) assert_model_property_type_hint(MyModel, "null_prop", Union[None, Unset]) assert_model_property_type_hint(MyModel, "any_prop", Union[Any, Unset]) @with_generated_client_fixture( -""" + """ components: schemas: MyModel: @@ -154,7 +158,8 @@ def test_type_hints(self, MyModel, Unset): dateTimeProp: {"type": "string", "format": "date-time"} uuidProp: {"type": "string", "format": "uuid"} unknownFormatProp: {"type": "string", "format": "weird"} -""") +""" +) @with_generated_code_imports( ".models.MyModel", ".types.Unset", @@ -168,7 +173,9 @@ def test_date(self, MyModel): def test_date_time(self, MyModel): date_time_value = datetime.datetime.now(datetime.timezone.utc) json_data = {"dateTimeProp": date_time_value.isoformat()} - assert_model_decode_encode(MyModel, json_data, MyModel(date_time_prop=date_time_value)) + assert_model_decode_encode( + MyModel, json_data, MyModel(date_time_prop=date_time_value) + ) def test_uuid(self, MyModel): uuid_value = uuid.uuid1() @@ -177,10 +184,18 @@ def test_uuid(self, MyModel): def test_unknown_format(self, MyModel): json_data = {"unknownFormatProp": "whatever"} - assert_model_decode_encode(MyModel, json_data, MyModel(unknown_format_prop="whatever")) + assert_model_decode_encode( + MyModel, json_data, MyModel(unknown_format_prop="whatever") + ) def test_type_hints(self, MyModel, Unset): - assert_model_property_type_hint(MyModel, "date_prop", Union[datetime.date, Unset]) - assert_model_property_type_hint(MyModel, "date_time_prop", Union[datetime.datetime, Unset]) + assert_model_property_type_hint( + MyModel, "date_prop", Union[datetime.date, Unset] + ) + assert_model_property_type_hint( + MyModel, "date_time_prop", Union[datetime.datetime, Unset] + ) assert_model_property_type_hint(MyModel, "uuid_prop", Union[uuid.UUID, Unset]) - assert_model_property_type_hint(MyModel, "unknown_format_prop", Union[str, Unset]) + assert_model_property_type_hint( + MyModel, "unknown_format_prop", Union[str, Unset] + ) diff --git a/end_to_end_tests/functional_tests/generated_code_execution/test_unions.py b/end_to_end_tests/functional_tests/generated_code_execution/test_unions.py index 9a9b49e4c..28e7ee099 100644 --- a/end_to_end_tests/functional_tests/generated_code_execution/test_unions.py +++ b/end_to_end_tests/functional_tests/generated_code_execution/test_unions.py @@ -9,7 +9,7 @@ @with_generated_client_fixture( -""" + """ components: schemas: StringOrInt: @@ -21,21 +21,24 @@ type: ["string", "integer"] """ ) -@with_generated_code_imports( - ".models.MyModel", - ".types.Unset" -) +@with_generated_code_imports(".models.MyModel", ".types.Unset") class TestSimpleTypeList: def test_decode_encode(self, MyModel): - assert_model_decode_encode(MyModel, {"stringOrIntProp": "a"}, MyModel(string_or_int_prop="a")) - assert_model_decode_encode(MyModel, {"stringOrIntProp": 1}, MyModel(string_or_int_prop=1)) + assert_model_decode_encode( + MyModel, {"stringOrIntProp": "a"}, MyModel(string_or_int_prop="a") + ) + assert_model_decode_encode( + MyModel, {"stringOrIntProp": 1}, MyModel(string_or_int_prop=1) + ) def test_type_hints(self, MyModel, Unset): - assert_model_property_type_hint(MyModel, "string_or_int_prop", Union[str, int, Unset]) + assert_model_property_type_hint( + MyModel, "string_or_int_prop", Union[str, int, Unset] + ) @with_generated_client_fixture( -""" + """ components: schemas: ThingA: @@ -84,7 +87,8 @@ def test_type_hints(self, MyModel, Unset): oneOf: - $ref: "#/components/schemas/ThingA" required: ["requiredThing"] -""") +""" +) @with_generated_code_imports( ".models.ThingA", ".models.ThingB", @@ -92,10 +96,12 @@ def test_type_hints(self, MyModel, Unset): ".models.ModelWithRequiredUnion", ".models.ModelWithNestedUnion", ".models.ModelWithUnionOfOne", - ".types.Unset" + ".types.Unset", ) class TestOneOf: - def test_disambiguate_objects_via_required_properties(self, ThingA, ThingB, ModelWithUnion): + def test_disambiguate_objects_via_required_properties( + self, ThingA, ThingB, ModelWithUnion + ): assert_model_decode_encode( ModelWithUnion, {"thing": {"propA": "x"}}, @@ -118,7 +124,7 @@ def test_disambiguate_object_and_non_object(self, ThingA, ModelWithUnion): {"thingOrString": "x"}, ModelWithUnion(thing_or_string="x"), ) - + def test_disambiguate_nested_union(self, ThingA, ThingB, ModelWithNestedUnion): assert_model_decode_encode( ModelWithNestedUnion, @@ -131,7 +137,9 @@ def test_disambiguate_nested_union(self, ThingA, ThingB, ModelWithNestedUnion): ModelWithNestedUnion(thing_or_value=3), ) - def test_type_hints(self, ModelWithUnion, ModelWithRequiredUnion, ModelWithUnionOfOne, ThingA, Unset): + def test_type_hints( + self, ModelWithUnion, ModelWithRequiredUnion, ModelWithUnionOfOne, ThingA, Unset + ): assert_model_property_type_hint( ModelWithUnion, "thing", @@ -145,6 +153,4 @@ def test_type_hints(self, ModelWithUnion, ModelWithRequiredUnion, ModelWithUnion assert_model_property_type_hint( ModelWithUnionOfOne, "thing", Union[ForwardRef("ThingA"), Unset] ) - assert_model_property_type_hint( - ModelWithUnionOfOne, "required_thing", "ThingA" - ) + assert_model_property_type_hint(ModelWithUnionOfOne, "required_thing", "ThingA") diff --git a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_arrays.py b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_arrays.py index e4ef0cffd..026742b5d 100644 --- a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_arrays.py +++ b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_arrays.py @@ -1,10 +1,13 @@ import pytest -from end_to_end_tests.functional_tests.helpers import assert_bad_schema, with_generated_client_fixture +from end_to_end_tests.functional_tests.helpers import ( + assert_bad_schema, + with_generated_client_fixture, +) @with_generated_client_fixture( -""" + """ components: schemas: ArrayWithNoItems: @@ -13,11 +16,19 @@ type: array items: $ref: "#/components/schemas/DoesntExist" -""" +""" ) class TestArrayInvalidSchemas: def test_no_items(self, generated_client): - assert_bad_schema(generated_client, "ArrayWithNoItems", "must have items or prefixItems defined") + assert_bad_schema( + generated_client, + "ArrayWithNoItems", + "must have items or prefixItems defined", + ) def test_invalid_items_ref(self, generated_client): - assert_bad_schema(generated_client, "ArrayWithInvalidItemsRef", "invalid data in items of array") + assert_bad_schema( + generated_client, + "ArrayWithInvalidItemsRef", + "invalid data in items of array", + ) diff --git a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_defaults.py b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_defaults.py index 93f5e11d4..49331e9dc 100644 --- a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_defaults.py +++ b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_defaults.py @@ -1,10 +1,13 @@ import pytest -from end_to_end_tests.functional_tests.helpers import assert_bad_schema, with_generated_client_fixture +from end_to_end_tests.functional_tests.helpers import ( + assert_bad_schema, + with_generated_client_fixture, +) @with_generated_client_fixture( -""" + """ components: schemas: WithBadBoolean: @@ -82,7 +85,7 @@ class TestInvalidDefaultValues: ("WithBadEnum", "Value x is not valid for enum"), ("OverriddenEnumWithBadDefault", "Value x is not valid for enum"), ("UnionWithNoValidDefault", "Invalid int value"), - ] + ], ) def test_bad_default_warning(self, model_name, message, generated_client): assert_bad_schema(generated_client, model_name, message) diff --git a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_enums_and_consts.py b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_enums_and_consts.py index 7f1586f29..7eefb0762 100644 --- a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_enums_and_consts.py +++ b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_enums_and_consts.py @@ -6,7 +6,7 @@ @with_generated_client_fixture( -""" + """ components: schemas: WithBadDefaultValue: @@ -32,31 +32,44 @@ properties: "2": enum: ["c", "d"] -""" +""" ) class TestEnumAndConstInvalidSchemas: def test_enum_bad_default_value(self, generated_client): - assert_bad_schema(generated_client, "WithBadDefaultValue", "Value B is not valid") + assert_bad_schema( + generated_client, "WithBadDefaultValue", "Value B is not valid" + ) def test_enum_bad_default_type(self, generated_client): - assert_bad_schema(generated_client, "WithBadDefaultType", "Cannot convert 123 to enum") + assert_bad_schema( + generated_client, "WithBadDefaultType", "Cannot convert 123 to enum" + ) def test_enum_mixed_types(self, generated_client): - assert_bad_schema(generated_client, "WithMixedTypes", "Enum values must all be the same type") + assert_bad_schema( + generated_client, "WithMixedTypes", "Enum values must all be the same type" + ) def test_enum_unsupported_type(self, generated_client): - assert_bad_schema(generated_client, "WithUnsupportedType", "Unsupported enum type") + assert_bad_schema( + generated_client, "WithUnsupportedType", "Unsupported enum type" + ) def test_const_default_not_matching(self, generated_client): - assert_bad_schema(generated_client, "DefaultNotMatchingConst", "Invalid value for const") + assert_bad_schema( + generated_client, "DefaultNotMatchingConst", "Invalid value for const" + ) def test_conflicting_inline_class_names(self, generated_client): - assert "Found conflicting enums named WithConflictingInlineNames12 with incompatible values" in generated_client.generator_result.output + assert ( + "Found conflicting enums named WithConflictingInlineNames12 with incompatible values" + in generated_client.generator_result.output + ) def test_enum_duplicate_values(self): # This one currently causes a full generator failure rather than a warning result = inline_spec_should_fail( -""" + """ components: schemas: WithDuplicateValues: @@ -67,7 +80,7 @@ def test_enum_duplicate_values(self): @with_generated_client_fixture( -""" + """ components: schemas: WithBadDefaultValue: @@ -94,31 +107,44 @@ def test_enum_duplicate_values(self): "2": enum: ["c", "d"] """, - config="literal_enums: true", + config="literal_enums: true", ) class TestLiteralEnumInvalidSchemas: def test_literal_enum_bad_default_value(self, generated_client): - assert_bad_schema(generated_client, "WithBadDefaultValue", "Value B is not valid") + assert_bad_schema( + generated_client, "WithBadDefaultValue", "Value B is not valid" + ) def test_literal_enum_bad_default_type(self, generated_client): - assert_bad_schema(generated_client, "WithBadDefaultType", "Cannot convert 123 to enum") + assert_bad_schema( + generated_client, "WithBadDefaultType", "Cannot convert 123 to enum" + ) def test_literal_enum_mixed_types(self, generated_client): - assert_bad_schema(generated_client, "WithMixedTypes", "Enum values must all be the same type") + assert_bad_schema( + generated_client, "WithMixedTypes", "Enum values must all be the same type" + ) def test_literal_enum_unsupported_type(self, generated_client): - assert_bad_schema(generated_client, "WithUnsupportedType", "Unsupported enum type") + assert_bad_schema( + generated_client, "WithUnsupportedType", "Unsupported enum type" + ) def test_const_default_not_matching(self, generated_client): - assert_bad_schema(generated_client, "DefaultNotMatchingConst", "Invalid value for const") + assert_bad_schema( + generated_client, "DefaultNotMatchingConst", "Invalid value for const" + ) def test_conflicting_inline_literal_enum_names(self, generated_client): - assert "Found conflicting enums named WithConflictingInlineNames12 with incompatible values" in generated_client.generator_result.output + assert ( + "Found conflicting enums named WithConflictingInlineNames12 with incompatible values" + in generated_client.generator_result.output + ) def test_literal_enum_duplicate_values(self): # This one currently causes a full generator failure rather than a warning result = inline_spec_should_fail( -""" + """ components: schemas: WithDuplicateValues: diff --git a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_spec_format.py b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_spec_format.py index 2b0dfdda9..9f8e9c3d5 100644 --- a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_spec_format.py +++ b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_spec_format.py @@ -8,19 +8,25 @@ class TestInvalidSpecFormats: @pytest.mark.parametrize( ("filename_suffix", "content", "expected_error"), ( - (".yaml", "not a valid openapi document", "Failed to parse OpenAPI document"), + ( + ".yaml", + "not a valid openapi document", + "Failed to parse OpenAPI document", + ), (".json", "Invalid JSON", "Invalid JSON"), (".yaml", "{", "Invalid YAML"), ), ids=("invalid_openapi", "invalid_json", "invalid_yaml"), ) def test_unparseable_file(self, filename_suffix, content, expected_error): - result = inline_spec_should_fail(content, filename_suffix=filename_suffix, add_missing_sections=False) + result = inline_spec_should_fail( + content, filename_suffix=filename_suffix, add_missing_sections=False + ) assert expected_error in result.output - + def test_missing_openapi_version(self): result = inline_spec_should_fail( -""" + """ info: title: My API version: "1.0" @@ -28,12 +34,16 @@ def test_missing_openapi_version(self): """, add_missing_sections=False, ) - for text in ["Failed to parse OpenAPI document", "1 validation error", "openapi"]: + for text in [ + "Failed to parse OpenAPI document", + "1 validation error", + "openapi", + ]: assert text in result.output def test_missing_title(self): result = inline_spec_should_fail( -""" + """ info: version: "1.0" openapi: "3.1.0" @@ -46,7 +56,7 @@ def test_missing_title(self): def test_missing_version(self): result = inline_spec_should_fail( -""" + """ info: title: My API openapi: "3.1.0" @@ -54,12 +64,16 @@ def test_missing_version(self): """, add_missing_sections=False, ) - for text in ["Failed to parse OpenAPI document", "1 validation error", "version"]: + for text in [ + "Failed to parse OpenAPI document", + "1 validation error", + "version", + ]: assert text in result.output def test_missing_paths(self): result = inline_spec_should_fail( -""" + """ info: title: My API version: "1.0" @@ -72,7 +86,7 @@ def test_missing_paths(self): def test_swagger_unsupported(self): result = inline_spec_should_fail( -""" + """ swagger: "2.0" info: title: My API @@ -83,4 +97,7 @@ def test_swagger_unsupported(self): """, add_missing_sections=False, ) - assert "You may be trying to use a Swagger document; this is not supported by this project." in result.output + assert ( + "You may be trying to use a Swagger document; this is not supported by this project." + in result.output + ) diff --git a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_unions.py b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_unions.py index 75621a094..03288c0b5 100644 --- a/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_unions.py +++ b/end_to_end_tests/functional_tests/generator_failure_cases/test_invalid_unions.py @@ -1,8 +1,11 @@ -from end_to_end_tests.functional_tests.helpers import assert_bad_schema, with_generated_client_fixture +from end_to_end_tests.functional_tests.helpers import ( + assert_bad_schema, + with_generated_client_fixture, +) @with_generated_client_fixture( -""" + """ components: schemas: UnionWithInvalidReference: @@ -15,14 +18,20 @@ anyOf: - type: string - type: array # invalid because no items -""" +""" ) class TestUnionInvalidSchemas: def test_invalid_reference(self, generated_client): - assert_bad_schema(generated_client, "UnionWithInvalidReference", "Could not find reference") + assert_bad_schema( + generated_client, "UnionWithInvalidReference", "Could not find reference" + ) def test_invalid_default(self, generated_client): - assert_bad_schema(generated_client, "UnionWithInvalidDefault", "Invalid int value: aaa") + assert_bad_schema( + generated_client, "UnionWithInvalidDefault", "Invalid int value: aaa" + ) def test_invalid_property(self, generated_client): - assert_bad_schema(generated_client, "UnionWithMalformedVariant", "Invalid property in union") + assert_bad_schema( + generated_client, "UnionWithMalformedVariant", "Invalid property in union" + ) diff --git a/end_to_end_tests/functional_tests/helpers.py b/end_to_end_tests/functional_tests/helpers.py index cb63da11b..5320c7fe8 100644 --- a/end_to_end_tests/functional_tests/helpers.py +++ b/end_to_end_tests/functional_tests/helpers.py @@ -1,28 +1,36 @@ -from typing import Any, Dict +from typing import Any import re from typing import Optional from click.testing import Result import pytest -from end_to_end_tests.generated_client import generate_client_from_inline_spec, GeneratedClientContext +from end_to_end_tests.generated_client import ( + generate_client_from_inline_spec, + GeneratedClientContext, +) def with_generated_client_fixture( openapi_spec: str, - name: str="generated_client", - config: str="", + name: str = "generated_client", + config: str = "", extra_args: list[str] = [], ): """Decorator to apply to a test class to create a fixture inside it called 'generated_client'. - + The fixture value will be a GeneratedClientContext created by calling generate_client_from_inline_spec(). """ + def _decorator(cls): def generated_client(self): - with generate_client_from_inline_spec(openapi_spec, extra_args=extra_args, config=config) as g: - print(g.generator_result.stdout) # so we'll see the output if a test failed + with generate_client_from_inline_spec( + openapi_spec, extra_args=extra_args, config=config + ) as g: + print( + g.generator_result.stdout + ) # so we'll see the output if a test failed yield g setattr(cls, name, pytest.fixture(scope="class")(generated_client)) @@ -33,7 +41,7 @@ def generated_client(self): def with_generated_code_import(import_path: str, alias: Optional[str] = None): """Decorator to apply to a test class to create a fixture from a generated code import. - + The 'generated_client' fixture must also be present. If import_path is "a.b.c", then the fixture's value is equal to "from a.b import c", and @@ -48,12 +56,12 @@ def _decorator(cls): def _func(self, generated_client): return generated_client.import_symbol(module_name, import_name) - + alias = alias or import_name _func.__name__ = alias setattr(cls, alias, pytest.fixture(scope="class")(_func)) return cls - + return _decorator @@ -67,13 +75,17 @@ def _decorator(cls): return _decorator -def assert_model_decode_encode(model_class: Any, json_data: dict, expected_instance: Any) -> None: +def assert_model_decode_encode( + model_class: Any, json_data: dict, expected_instance: Any +) -> None: instance = model_class.from_dict(json_data) assert instance == expected_instance assert instance.to_dict() == json_data -def assert_model_property_type_hint(model_class: Any, name: str, expected_type_hint: Any) -> None: +def assert_model_property_type_hint( + model_class: Any, name: str, expected_type_hint: Any +) -> None: assert model_class.__annotations__[name] == expected_type_hint @@ -82,10 +94,10 @@ def inline_spec_should_fail( extra_args: list[str] = [], config: str = "", filename_suffix: str = "", - add_missing_sections = True, + add_missing_sections=True, ) -> Result: """Asserts that the generator could not process the spec. - + Returns the command result, which could include stdout data or an exception. """ with generate_client_from_inline_spec( @@ -106,13 +118,15 @@ def assert_bad_schema( expected_message_str: str, ) -> None: warnings = _GeneratorWarningsParser(generated_client) - assert schema_name in warnings.by_schema, f"Did not find warning for schema {schema_name} in output: {warnings.output}" + assert ( + schema_name in warnings.by_schema + ), f"Did not find warning for schema {schema_name} in output: {warnings.output}" assert expected_message_str in warnings.by_schema[schema_name] class _GeneratorWarningsParser: output: str - by_schema: Dict[str, str] + by_schema: dict[str, str] def __init__(self, generated_client: GeneratedClientContext) -> None: """Runs the generator, asserts that it printed warnings, and parses the warnings.""" @@ -128,8 +142,8 @@ def __init__(self, generated_client: GeneratedClientContext) -> None: if not (match := re.search(bad_schema_regex, output)): break if last_name: - self.by_schema[last_name] = output[0:match.start()] - output = output[match.end():] + self.by_schema[last_name] = output[0 : match.start()] + output = output[match.end() :] last_name = match.group(2) if last_name: self.by_schema[last_name] = output diff --git a/end_to_end_tests/generated_client.py b/end_to_end_tests/generated_client.py index d7cb16fc7..63daa5cb9 100644 --- a/end_to_end_tests/generated_client.py +++ b/end_to_end_tests/generated_client.py @@ -18,7 +18,7 @@ @define class GeneratedClientContext: """A context manager with helpers for tests that run against generated client code. - + On entering this context, sys.path is changed to include the root directory of the generated code, so its modules can be imported. On exit, the original sys.path is restored, and any modules that were loaded within the context are removed. @@ -50,13 +50,16 @@ def import_symbol(self, module_path: str, name: str) -> Any: try: return getattr(module, name) except AttributeError: - existing = ", ".join(name for name in dir(module) if not name.startswith("_")) + existing = ", ".join( + name for name in dir(module) if not name.startswith("_") + ) assert False, ( - f"Couldn't find import \"{name}\" in \"{self.base_module}{module_path}\".\n" + f'Couldn\'t find import "{name}" in "{self.base_module}{module_path}".\n' f"Available imports in that module are: {existing}\n" f"Output from generator was: {self.generator_result.stdout}" ) + def _run_command( command: str, extra_args: Optional[list[str]] = None, @@ -78,7 +81,11 @@ def _run_command( args.extend(extra_args) result = runner.invoke(app, args) if result.exit_code != 0 and raise_on_error: - message = f"{result.stdout}\n{result.exception}" if result.exception else result.stdout + message = ( + f"{result.stdout}\n{result.exception}" + if result.exception + else result.stdout + ) raise Exception(message) return result @@ -101,7 +108,9 @@ def generate_client( args = [*args, "--output-path", str(full_output_path)] if overwrite: args = [*args, "--overwrite"] - generator_result = _run_command("generate", args, openapi_document, raise_on_error=raise_on_error) + generator_result = _run_command( + "generate", args, openapi_document, raise_on_error=raise_on_error + ) return GeneratedClientContext( full_output_path, generator_result, @@ -116,11 +125,11 @@ def generate_client_from_inline_spec( config: str = "", filename_suffix: Optional[str] = None, base_module: str = "testapi_client", - add_missing_sections = True, + add_missing_sections=True, raise_on_error: bool = True, ) -> GeneratedClientContext: """Run the generator on a temporary file created with the specified contents. - + You can also optionally tell it to create a temporary config file. """ if add_missing_sections: @@ -133,12 +142,12 @@ def generate_client_from_inline_spec( output_path = tempfile.mkdtemp() file = tempfile.NamedTemporaryFile(suffix=filename_suffix, delete=False) - file.write(openapi_spec.encode('utf-8')) + file.write(openapi_spec.encode("utf-8")) file.close() if config: config_file = tempfile.NamedTemporaryFile(delete=False) - config_file.write(config.encode('utf-8')) + config_file.write(config.encode("utf-8")) config_file.close() extra_args = [*extra_args, "--config", config_file.name] diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py index e49c19427..25518c70a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py index 652e2c6db..740683d7e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py @@ -48,7 +48,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -57,7 +59,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py index 81812cdea..fa6e3860f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py b/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py index d2757f759..bc22ac97f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py @@ -27,7 +27,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[str]: if response.status_code == 200: response_200 = cast(str, response.json()) return response_200 @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[str]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index 7de222f55..46b5b00e1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -27,7 +27,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -36,7 +38,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py index 85f68fb7c..1f82d3aa7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py @@ -26,26 +26,34 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] + Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + ] ]: if response.status_code == 200: def _parse_response_200( data: object, ) -> Union[ - "GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1" + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", ]: try: if not isinstance(data, dict): raise TypeError() - response_200_type_0 = GetModelsOneofWithRequiredConstResponse200Type0.from_dict(data) + response_200_type_0 = ( + GetModelsOneofWithRequiredConstResponse200Type0.from_dict(data) + ) return response_200_type_0 except: # noqa: E722 pass if not isinstance(data, dict): raise TypeError() - response_200_type_1 = GetModelsOneofWithRequiredConstResponse200Type1.from_dict(data) + response_200_type_1 = ( + GetModelsOneofWithRequiredConstResponse200Type1.from_dict(data) + ) return response_200_type_1 @@ -61,7 +69,10 @@ def _parse_response_200( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Response[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] + Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + ] ]: return Response( status_code=HTTPStatus(response.status_code), @@ -75,7 +86,10 @@ def sync_detailed( *, client: Union[AuthenticatedClient, Client], ) -> Response[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] + Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + ] ]: """ Raises: @@ -99,7 +113,10 @@ def sync( *, client: Union[AuthenticatedClient, Client], ) -> Optional[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] + Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + ] ]: """ Raises: @@ -119,7 +136,10 @@ async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], ) -> Response[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] + Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + ] ]: """ Raises: @@ -141,7 +161,10 @@ async def asyncio( *, client: Union[AuthenticatedClient, Client], ) -> Optional[ - Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"] + Union[ + "GetModelsOneofWithRequiredConstResponse200Type0", + "GetModelsOneofWithRequiredConstResponse200Type1", + ] ]: """ Raises: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index 5bd941c69..16fc81c9f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -27,7 +27,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -36,7 +38,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py index fe7adf04c..cf68128fc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py @@ -30,7 +30,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -39,7 +41,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py index 52385855c..6da45ec10 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -27,7 +27,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -36,7 +38,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py index 26c3729fe..f45f96976 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -29,7 +29,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -38,7 +40,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py index ad9428a72..43040de58 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -5,8 +5,12 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader -from ...models.get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from ...models.get_location_header_types_int_enum_header import ( + GetLocationHeaderTypesIntEnumHeader, +) +from ...models.get_location_header_types_string_enum_header import ( + GetLocationHeaderTypesStringEnumHeader, +) from ...types import UNSET, Response, Unset @@ -47,7 +51,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -56,7 +62,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index e28e37a36..9682664ec 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -53,7 +53,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -62,7 +64,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py index a0caba2d6..5276b2589 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py @@ -19,7 +19,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -28,7 +30,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py index bf1ebf6ca..6f849f0a6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py @@ -5,7 +5,9 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.post_naming_property_conflict_with_import_body import PostNamingPropertyConflictWithImportBody +from ...models.post_naming_property_conflict_with_import_body import ( + PostNamingPropertyConflictWithImportBody, +) from ...models.post_naming_property_conflict_with_import_response_200 import ( PostNamingPropertyConflictWithImportResponse200, ) @@ -35,7 +37,9 @@ def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[PostNamingPropertyConflictWithImportResponse200]: if response.status_code == 200: - response_200 = PostNamingPropertyConflictWithImportResponse200.from_dict(response.json()) + response_200 = PostNamingPropertyConflictWithImportResponse200.from_dict( + response.json() + ) return response_200 if client.raise_on_unexpected_status: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py index e7a8e2712..17c44c125 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -43,7 +43,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -52,7 +54,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index 704996107..f3023e05f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index b6efbba9b..aad25b05b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index 6a7ed7fd5..9d6a6d020 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -40,7 +40,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -49,7 +51,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index 44345aa26..230365a33 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -22,7 +22,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -31,7 +33,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index cf0599306..74754346d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -24,7 +24,9 @@ def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[PostResponsesUnionsSimpleBeforeComplexResponse200]: if response.status_code == 200: - response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json()) + response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict( + response.json() + ) return response_200 if client.raise_on_unexpected_status: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py index ac71e9e50..eddfa3b65 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/reference_response.py @@ -18,7 +18,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[AModel]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[AModel]: if response.status_code == 200: response_200 = AModel.from_dict(response.json()) @@ -29,7 +31,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[AModel]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[AModel]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py index 057ceb2de..fc2f2bdaa 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[str]: if response.status_code == 200: response_200 = response.text return response_200 @@ -27,7 +29,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[str]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index 62631355f..f8fdc0555 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -26,7 +28,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py index 62631355f..f8fdc0555 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag2/get_tag_with_number.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -26,7 +28,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index e7cd44f70..e36149671 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -26,7 +28,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index 147eed3a7..735df7873 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[bool]]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[list[bool]]: if response.status_code == 200: response_200 = cast(list[bool], response.json()) @@ -28,7 +30,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[bool]]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[list[bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index 02b3abb1f..0b1a38bbf 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[float]]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[list[float]]: if response.status_code == 200: response_200 = cast(list[float], response.json()) @@ -28,7 +30,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[float]]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[list[float]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index e71537363..c9706d1a5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[int]]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[list[int]]: if response.status_code == 200: response_200 = cast(list[int], response.json()) @@ -28,7 +30,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[int]]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[list[int]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 70f153829..25d2397a6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[str]]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[list[str]]: if response.status_code == 200: response_200 = cast(list[str], response.json()) @@ -28,7 +30,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[str]]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[list[str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index 586947f49..eb5909daa 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -26,7 +28,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index efb0f4ae5..30a6f02fa 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -18,7 +18,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[File]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[File]: if response.status_code == 200: response_200 = File(payload=BytesIO(response.content)) @@ -29,7 +31,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[File]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[File]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py index bf4a1fcb0..33e355a9a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py @@ -6,7 +6,9 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.http_validation_error import HTTPValidationError -from ...models.octet_stream_tests_octet_stream_post_response_200 import OctetStreamTestsOctetStreamPostResponse200 +from ...models.octet_stream_tests_octet_stream_post_response_200 import ( + OctetStreamTestsOctetStreamPostResponse200, +) from ...types import File, Response @@ -33,7 +35,9 @@ def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[HTTPValidationError, OctetStreamTestsOctetStreamPostResponse200]]: if response.status_code == 200: - response_200 = OctetStreamTestsOctetStreamPostResponse200.from_dict(response.json()) + response_200 = OctetStreamTestsOctetStreamPostResponse200.from_dict( + response.json() + ) return response_200 if response.status_code == 422: diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index 41610afc0..94ff03d01 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py index 9bb3cd7c0..9eae179da 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -37,7 +39,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index 22ac00650..6d8dd617a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -24,7 +24,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if response.status_code == 401: @@ -35,7 +37,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index 61e8434e6..db910c797 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -17,7 +17,9 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -26,7 +28,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index b46550153..1836efbf1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -27,7 +27,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -36,7 +38,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/golden-record/my_test_api_client/client.py b/end_to_end_tests/golden-record/my_test_api_client/client.py index e80446f10..eeffd00c8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/golden-record/my_test_api_client/client.py @@ -38,9 +38,15 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -168,9 +174,15 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -214,7 +226,9 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": def get_httpx_client(self) -> httpx.Client: """Get the underlying httpx.Client, constructing a new one if not previously set""" if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._client = httpx.Client( base_url=self._base_url, cookies=self._cookies, @@ -235,7 +249,9 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client( + self, async_client: httpx.AsyncClient + ) -> "AuthenticatedClient": """Manually the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -246,7 +262,9 @@ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Authentica def get_async_httpx_client(self) -> httpx.AsyncClient: """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._async_client = httpx.AsyncClient( base_url=self._base_url, cookies=self._cookies, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py index 4d7471400..1c528ec8c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py @@ -4,24 +4,34 @@ from .a_discriminated_union_type_2 import ADiscriminatedUnionType2 from .a_form_data import AFormData from .a_model import AModel -from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject +from .a_model_with_properties_reference_that_are_not_object import ( + AModelWithPropertiesReferenceThatAreNotObject, +) from .all_of_has_properties_but_no_type import AllOfHasPropertiesButNoType -from .all_of_has_properties_but_no_type_type_enum import AllOfHasPropertiesButNoTypeTypeEnum +from .all_of_has_properties_but_no_type_type_enum import ( + AllOfHasPropertiesButNoTypeTypeEnum, +) from .all_of_sub_model import AllOfSubModel from .all_of_sub_model_type_enum import AllOfSubModelTypeEnum from .an_all_of_enum import AnAllOfEnum -from .an_array_with_a_circular_ref_in_items_object_a_item import AnArrayWithACircularRefInItemsObjectAItem +from .an_array_with_a_circular_ref_in_items_object_a_item import ( + AnArrayWithACircularRefInItemsObjectAItem, +) from .an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, ) from .an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, ) -from .an_array_with_a_circular_ref_in_items_object_b_item import AnArrayWithACircularRefInItemsObjectBItem +from .an_array_with_a_circular_ref_in_items_object_b_item import ( + AnArrayWithACircularRefInItemsObjectBItem, +) from .an_array_with_a_recursive_ref_in_items_object_additional_properties_item import ( AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem, ) -from .an_array_with_a_recursive_ref_in_items_object_item import AnArrayWithARecursiveRefInItemsObjectItem +from .an_array_with_a_recursive_ref_in_items_object_item import ( + AnArrayWithARecursiveRefInItemsObjectItem, +) from .an_enum import AnEnum from .an_enum_with_null import AnEnumWithNull from .an_int_enum import AnIntEnum @@ -29,18 +39,34 @@ from .another_all_of_sub_model_type import AnotherAllOfSubModelType from .another_all_of_sub_model_type_enum import AnotherAllOfSubModelTypeEnum from .body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost -from .body_upload_file_tests_upload_post_additional_property import BodyUploadFileTestsUploadPostAdditionalProperty -from .body_upload_file_tests_upload_post_some_nullable_object import BodyUploadFileTestsUploadPostSomeNullableObject -from .body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject -from .body_upload_file_tests_upload_post_some_optional_object import BodyUploadFileTestsUploadPostSomeOptionalObject +from .body_upload_file_tests_upload_post_additional_property import ( + BodyUploadFileTestsUploadPostAdditionalProperty, +) +from .body_upload_file_tests_upload_post_some_nullable_object import ( + BodyUploadFileTestsUploadPostSomeNullableObject, +) +from .body_upload_file_tests_upload_post_some_object import ( + BodyUploadFileTestsUploadPostSomeObject, +) +from .body_upload_file_tests_upload_post_some_optional_object import ( + BodyUploadFileTestsUploadPostSomeOptionalObject, +) from .different_enum import DifferentEnum from .extended import Extended from .free_form_model import FreeFormModel -from .get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader -from .get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader +from .get_location_header_types_int_enum_header import ( + GetLocationHeaderTypesIntEnumHeader, +) +from .get_location_header_types_string_enum_header import ( + GetLocationHeaderTypesStringEnumHeader, +) from .get_models_allof_response_200 import GetModelsAllofResponse200 -from .get_models_oneof_with_required_const_response_200_type_0 import GetModelsOneofWithRequiredConstResponse200Type0 -from .get_models_oneof_with_required_const_response_200_type_1 import GetModelsOneofWithRequiredConstResponse200Type1 +from .get_models_oneof_with_required_const_response_200_type_0 import ( + GetModelsOneofWithRequiredConstResponse200Type0, +) +from .get_models_oneof_with_required_const_response_200_type_1 import ( + GetModelsOneofWithRequiredConstResponse200Type1, +) from .http_validation_error import HTTPValidationError from .import_ import Import from .json_like_body import JsonLikeBody @@ -48,41 +74,69 @@ from .model_from_all_of import ModelFromAllOf from .model_name import ModelName from .model_reference_with_periods import ModelReferenceWithPeriods -from .model_with_additional_properties_inlined import ModelWithAdditionalPropertiesInlined +from .model_with_additional_properties_inlined import ( + ModelWithAdditionalPropertiesInlined, +) from .model_with_additional_properties_inlined_additional_property import ( ModelWithAdditionalPropertiesInlinedAdditionalProperty, ) from .model_with_additional_properties_refed import ModelWithAdditionalPropertiesRefed from .model_with_any_json_properties import ModelWithAnyJsonProperties -from .model_with_any_json_properties_additional_property_type_0 import ModelWithAnyJsonPropertiesAdditionalPropertyType0 +from .model_with_any_json_properties_additional_property_type_0 import ( + ModelWithAnyJsonPropertiesAdditionalPropertyType0, +) from .model_with_backslash_in_description import ModelWithBackslashInDescription from .model_with_circular_ref_a import ModelWithCircularRefA from .model_with_circular_ref_b import ModelWithCircularRefB -from .model_with_circular_ref_in_additional_properties_a import ModelWithCircularRefInAdditionalPropertiesA -from .model_with_circular_ref_in_additional_properties_b import ModelWithCircularRefInAdditionalPropertiesB +from .model_with_circular_ref_in_additional_properties_a import ( + ModelWithCircularRefInAdditionalPropertiesA, +) +from .model_with_circular_ref_in_additional_properties_b import ( + ModelWithCircularRefInAdditionalPropertiesB, +) from .model_with_date_time_property import ModelWithDateTimeProperty from .model_with_discriminated_union import ModelWithDiscriminatedUnion from .model_with_merged_properties import ModelWithMergedProperties -from .model_with_merged_properties_string_to_enum import ModelWithMergedPropertiesStringToEnum +from .model_with_merged_properties_string_to_enum import ( + ModelWithMergedPropertiesStringToEnum, +) from .model_with_no_properties import ModelWithNoProperties -from .model_with_primitive_additional_properties import ModelWithPrimitiveAdditionalProperties -from .model_with_primitive_additional_properties_a_date_holder import ModelWithPrimitiveAdditionalPropertiesADateHolder +from .model_with_primitive_additional_properties import ( + ModelWithPrimitiveAdditionalProperties, +) +from .model_with_primitive_additional_properties_a_date_holder import ( + ModelWithPrimitiveAdditionalPropertiesADateHolder, +) from .model_with_property_ref import ModelWithPropertyRef from .model_with_recursive_ref import ModelWithRecursiveRef -from .model_with_recursive_ref_in_additional_properties import ModelWithRecursiveRefInAdditionalProperties +from .model_with_recursive_ref_in_additional_properties import ( + ModelWithRecursiveRefInAdditionalProperties, +) from .model_with_union_property import ModelWithUnionProperty from .model_with_union_property_inlined import ModelWithUnionPropertyInlined -from .model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples -from .model_with_union_property_inlined_bananas import ModelWithUnionPropertyInlinedBananas +from .model_with_union_property_inlined_apples import ( + ModelWithUnionPropertyInlinedApples, +) +from .model_with_union_property_inlined_bananas import ( + ModelWithUnionPropertyInlinedBananas, +) from .none import None_ -from .octet_stream_tests_octet_stream_post_response_200 import OctetStreamTestsOctetStreamPostResponse200 +from .octet_stream_tests_octet_stream_post_response_200 import ( + OctetStreamTestsOctetStreamPostResponse200, +) from .post_bodies_multiple_data_body import PostBodiesMultipleDataBody from .post_bodies_multiple_files_body import PostBodiesMultipleFilesBody from .post_bodies_multiple_json_body import PostBodiesMultipleJsonBody from .post_form_data_inline_body import PostFormDataInlineBody -from .post_naming_property_conflict_with_import_body import PostNamingPropertyConflictWithImportBody -from .post_naming_property_conflict_with_import_response_200 import PostNamingPropertyConflictWithImportResponse200 -from .post_responses_unions_simple_before_complex_response_200 import PostResponsesUnionsSimpleBeforeComplexResponse200 +from .post_naming_property_conflict_with_import_body import ( + PostNamingPropertyConflictWithImportBody, +) +from .post_naming_property_conflict_with_import_response_200 import ( + PostNamingPropertyConflictWithImportResponse200, +) +from .post_responses_unions_simple_before_complex_response_200 import ( + PostResponsesUnionsSimpleBeforeComplexResponse200, +) from .post_responses_unions_simple_before_complex_response_200a_type_1 import ( PostResponsesUnionsSimpleBeforeComplexResponse200AType1, ) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py index db3c56629..8cf1a1a28 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py @@ -74,8 +74,12 @@ class AModel: attr_leading_underscore: Union[Unset, str] = UNSET not_required_nullable: Union[None, Unset, str] = UNSET not_required_not_nullable: Union[Unset, str] = UNSET - not_required_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Unset] = UNSET - not_required_nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str] = UNSET + not_required_one_of_models: Union[ + "FreeFormModel", "ModelWithUnionProperty", Unset + ] = UNSET + not_required_nullable_one_of_models: Union[ + "FreeFormModel", "ModelWithUnionProperty", None, Unset, str + ] = UNSET not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET @@ -85,7 +89,9 @@ def to_dict(self) -> dict[str, Any]: an_enum_value = self.an_enum_value.value - an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default.value + an_allof_enum_with_overridden_default = ( + self.an_allof_enum_with_overridden_default.value + ) a_camel_date_time: str if isinstance(self.a_camel_date_time, datetime.datetime): @@ -149,8 +155,12 @@ def to_dict(self) -> dict[str, Any]: nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: nested_list_of_enums_item = [] - for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: - nested_list_of_enums_item_item = nested_list_of_enums_item_item_data.value + for ( + nested_list_of_enums_item_item_data + ) in nested_list_of_enums_item_data: + nested_list_of_enums_item_item = ( + nested_list_of_enums_item_item_data.value + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) nested_list_of_enums.append(nested_list_of_enums_item) @@ -187,11 +197,19 @@ def to_dict(self) -> dict[str, Any]: if isinstance(self.not_required_nullable_one_of_models, Unset): not_required_nullable_one_of_models = UNSET elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() - elif isinstance(self.not_required_nullable_one_of_models, ModelWithUnionProperty): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() + not_required_nullable_one_of_models = ( + self.not_required_nullable_one_of_models.to_dict() + ) + elif isinstance( + self.not_required_nullable_one_of_models, ModelWithUnionProperty + ): + not_required_nullable_one_of_models = ( + self.not_required_nullable_one_of_models.to_dict() + ) else: - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models + not_required_nullable_one_of_models = ( + self.not_required_nullable_one_of_models + ) not_required_model: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.not_required_model, Unset): @@ -245,7 +263,9 @@ def to_dict(self) -> dict[str, Any]: if not_required_one_of_models is not UNSET: field_dict["not_required_one_of_models"] = not_required_one_of_models if not_required_nullable_one_of_models is not UNSET: - field_dict["not_required_nullable_one_of_models"] = not_required_nullable_one_of_models + field_dict["not_required_nullable_one_of_models"] = ( + not_required_nullable_one_of_models + ) if not_required_model is not UNSET: field_dict["not_required_model"] = not_required_model if not_required_nullable_model is not UNSET: @@ -261,9 +281,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) an_enum_value = AnEnum(d.pop("an_enum_value")) - an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default")) + an_allof_enum_with_overridden_default = AnAllOfEnum( + d.pop("an_allof_enum_with_overridden_default") + ) - def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]: + def _parse_a_camel_date_time( + data: object, + ) -> Union[datetime.date, datetime.datetime]: try: if not isinstance(data, str): raise TypeError() @@ -323,7 +347,9 @@ def _parse_required_nullable(data: object) -> Union[None, str]: required_not_nullable = d.pop("required_not_nullable") - def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: + def _parse_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: try: if not isinstance(data, dict): raise TypeError() @@ -344,7 +370,9 @@ def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnion one_of_models = _parse_one_of_models(d.pop("one_of_models")) - def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: + def _parse_nullable_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: if data is None: return data try: @@ -365,11 +393,15 @@ def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "Model pass return cast(Union["FreeFormModel", "ModelWithUnionProperty", None], data) - nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models")) + nullable_one_of_models = _parse_nullable_one_of_models( + d.pop("nullable_one_of_models") + ) model = ModelWithUnionProperty.from_dict(d.pop("model")) - def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]: + def _parse_nullable_model( + data: object, + ) -> Union["ModelWithUnionProperty", None]: if data is None: return data try: @@ -399,7 +431,9 @@ def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None] nested_list_of_enums_item = [] _nested_list_of_enums_item = nested_list_of_enums_item_data for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: - nested_list_of_enums_item_item = DifferentEnum(nested_list_of_enums_item_item_data) + nested_list_of_enums_item_item = DifferentEnum( + nested_list_of_enums_item_item_data + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) @@ -430,11 +464,15 @@ def _parse_not_required_nullable(data: object) -> Union[None, Unset, str]: return data return cast(Union[None, Unset, str], data) - not_required_nullable = _parse_not_required_nullable(d.pop("not_required_nullable", UNSET)) + not_required_nullable = _parse_not_required_nullable( + d.pop("not_required_nullable", UNSET) + ) not_required_not_nullable = d.pop("not_required_not_nullable", UNSET) - def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: + def _parse_not_required_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: if isinstance(data, Unset): return data try: @@ -451,7 +489,9 @@ def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "M return not_required_one_of_models_type_1 - not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET)) + not_required_one_of_models = _parse_not_required_one_of_models( + d.pop("not_required_one_of_models", UNSET) + ) def _parse_not_required_nullable_one_of_models( data: object, @@ -463,7 +503,9 @@ def _parse_not_required_nullable_one_of_models( try: if not isinstance(data, dict): raise TypeError() - not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) + not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict( + data + ) return not_required_nullable_one_of_models_type_0 except: # noqa: E722 @@ -471,15 +513,21 @@ def _parse_not_required_nullable_one_of_models( try: if not isinstance(data, dict): raise TypeError() - not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + not_required_nullable_one_of_models_type_1 = ( + ModelWithUnionProperty.from_dict(data) + ) return not_required_nullable_one_of_models_type_1 except: # noqa: E722 pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data) - - not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models( - d.pop("not_required_nullable_one_of_models", UNSET) + return cast( + Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data + ) + + not_required_nullable_one_of_models = ( + _parse_not_required_nullable_one_of_models( + d.pop("not_required_nullable_one_of_models", UNSET) + ) ) _not_required_model = d.pop("not_required_model", UNSET) @@ -489,7 +537,9 @@ def _parse_not_required_nullable_one_of_models( else: not_required_model = ModelWithUnionProperty.from_dict(_not_required_model) - def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionProperty", None, Unset]: + def _parse_not_required_nullable_model( + data: object, + ) -> Union["ModelWithUnionProperty", None, Unset]: if data is None: return data if isinstance(data, Unset): @@ -497,14 +547,18 @@ def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionPro try: if not isinstance(data, dict): raise TypeError() - not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) + not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict( + data + ) return not_required_nullable_model_type_1 except: # noqa: E722 pass return cast(Union["ModelWithUnionProperty", None, Unset], data) - not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) + not_required_nullable_model = _parse_not_required_nullable_model( + d.pop("not_required_nullable_model", UNSET) + ) a_model = cls( an_enum_value=an_enum_value, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py index 2d165b50e..90b0e7029 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py @@ -83,25 +83,35 @@ class AModelWithPropertiesReferenceThatAreNotObject: def to_dict(self) -> dict[str, Any]: enum_properties_ref = [] - for componentsschemas_an_other_array_of_enum_item_data in self.enum_properties_ref: - componentsschemas_an_other_array_of_enum_item = componentsschemas_an_other_array_of_enum_item_data.value + for ( + componentsschemas_an_other_array_of_enum_item_data + ) in self.enum_properties_ref: + componentsschemas_an_other_array_of_enum_item = ( + componentsschemas_an_other_array_of_enum_item_data.value + ) enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) str_properties_ref = self.str_properties_ref date_properties_ref = [] - for componentsschemas_an_other_array_of_date_item_data in self.date_properties_ref: + for ( + componentsschemas_an_other_array_of_date_item_data + ) in self.date_properties_ref: componentsschemas_an_other_array_of_date_item = ( componentsschemas_an_other_array_of_date_item_data.isoformat() ) date_properties_ref.append(componentsschemas_an_other_array_of_date_item) datetime_properties_ref = [] - for componentsschemas_an_other_array_of_date_time_item_data in self.datetime_properties_ref: + for ( + componentsschemas_an_other_array_of_date_time_item_data + ) in self.datetime_properties_ref: componentsschemas_an_other_array_of_date_time_item = ( componentsschemas_an_other_array_of_date_time_item_data.isoformat() ) - datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) + datetime_properties_ref.append( + componentsschemas_an_other_array_of_date_time_item + ) int32_properties_ref = self.int32_properties_ref @@ -112,7 +122,9 @@ def to_dict(self) -> dict[str, Any]: double_properties_ref = self.double_properties_ref file_properties_ref = [] - for componentsschemas_an_other_array_of_file_item_data in self.file_properties_ref: + for ( + componentsschemas_an_other_array_of_file_item_data + ) in self.file_properties_ref: componentsschemas_an_other_array_of_file_item = ( componentsschemas_an_other_array_of_file_item_data.to_tuple() ) @@ -123,19 +135,27 @@ def to_dict(self) -> dict[str, Any]: enum_properties = [] for componentsschemas_an_array_of_enum_item_data in self.enum_properties: - componentsschemas_an_array_of_enum_item = componentsschemas_an_array_of_enum_item_data.value + componentsschemas_an_array_of_enum_item = ( + componentsschemas_an_array_of_enum_item_data.value + ) enum_properties.append(componentsschemas_an_array_of_enum_item) str_properties = self.str_properties date_properties = [] for componentsschemas_an_array_of_date_item_data in self.date_properties: - componentsschemas_an_array_of_date_item = componentsschemas_an_array_of_date_item_data.isoformat() + componentsschemas_an_array_of_date_item = ( + componentsschemas_an_array_of_date_item_data.isoformat() + ) date_properties.append(componentsschemas_an_array_of_date_item) datetime_properties = [] - for componentsschemas_an_array_of_date_time_item_data in self.datetime_properties: - componentsschemas_an_array_of_date_time_item = componentsschemas_an_array_of_date_time_item_data.isoformat() + for ( + componentsschemas_an_array_of_date_time_item_data + ) in self.datetime_properties: + componentsschemas_an_array_of_date_time_item = ( + componentsschemas_an_array_of_date_time_item_data.isoformat() + ) datetime_properties.append(componentsschemas_an_array_of_date_time_item) int32_properties = self.int32_properties @@ -148,7 +168,9 @@ def to_dict(self) -> dict[str, Any]: file_properties = [] for componentsschemas_an_array_of_file_item_data in self.file_properties: - componentsschemas_an_array_of_file_item = componentsschemas_an_array_of_file_item_data.to_tuple() + componentsschemas_an_array_of_file_item = ( + componentsschemas_an_array_of_file_item_data.to_tuple() + ) file_properties.append(componentsschemas_an_array_of_file_item) @@ -219,7 +241,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: enum_properties_ref = [] _enum_properties_ref = d.pop("enum_properties_ref") for componentsschemas_an_other_array_of_enum_item_data in _enum_properties_ref: - componentsschemas_an_other_array_of_enum_item = AnEnum(componentsschemas_an_other_array_of_enum_item_data) + componentsschemas_an_other_array_of_enum_item = AnEnum( + componentsschemas_an_other_array_of_enum_item_data + ) enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) @@ -236,12 +260,16 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: datetime_properties_ref = [] _datetime_properties_ref = d.pop("datetime_properties_ref") - for componentsschemas_an_other_array_of_date_time_item_data in _datetime_properties_ref: + for ( + componentsschemas_an_other_array_of_date_time_item_data + ) in _datetime_properties_ref: componentsschemas_an_other_array_of_date_time_item = isoparse( componentsschemas_an_other_array_of_date_time_item_data ) - datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) + datetime_properties_ref.append( + componentsschemas_an_other_array_of_date_time_item + ) int32_properties_ref = cast(list[int], d.pop("int32_properties_ref")) @@ -265,7 +293,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: enum_properties = [] _enum_properties = d.pop("enum_properties") for componentsschemas_an_array_of_enum_item_data in _enum_properties: - componentsschemas_an_array_of_enum_item = AnEnum(componentsschemas_an_array_of_enum_item_data) + componentsschemas_an_array_of_enum_item = AnEnum( + componentsschemas_an_array_of_enum_item_data + ) enum_properties.append(componentsschemas_an_array_of_enum_item) @@ -274,14 +304,18 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: date_properties = [] _date_properties = d.pop("date_properties") for componentsschemas_an_array_of_date_item_data in _date_properties: - componentsschemas_an_array_of_date_item = isoparse(componentsschemas_an_array_of_date_item_data).date() + componentsschemas_an_array_of_date_item = isoparse( + componentsschemas_an_array_of_date_item_data + ).date() date_properties.append(componentsschemas_an_array_of_date_item) datetime_properties = [] _datetime_properties = d.pop("datetime_properties") for componentsschemas_an_array_of_date_time_item_data in _datetime_properties: - componentsschemas_an_array_of_date_time_item = isoparse(componentsschemas_an_array_of_date_time_item_data) + componentsschemas_an_array_of_date_time_item = isoparse( + componentsschemas_an_array_of_date_time_item_data + ) datetime_properties.append(componentsschemas_an_array_of_date_time_item) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py index 7ff816bd4..1bb9de0f2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py @@ -4,7 +4,9 @@ from attrs import define as _attrs_define from attrs import field as _attrs_field -from ..models.all_of_has_properties_but_no_type_type_enum import AllOfHasPropertiesButNoTypeTypeEnum +from ..models.all_of_has_properties_but_no_type_type_enum import ( + AllOfHasPropertiesButNoTypeTypeEnum, +) from ..types import UNSET, Unset T = TypeVar("T", bound="AllOfHasPropertiesButNoType") diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py index 54c4da080..dfe56ab9d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py @@ -7,7 +7,9 @@ from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.an_array_with_a_circular_ref_in_items_object_b_item import AnArrayWithACircularRefInItemsObjectBItem + from ..models.an_array_with_a_circular_ref_in_items_object_b_item import ( + AnArrayWithACircularRefInItemsObjectBItem, + ) T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectAItem") @@ -27,11 +29,13 @@ def to_dict(self) -> dict[str, Any]: circular: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.circular, Unset): circular = [] - for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in self.circular: + for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in (self.circular): componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = ( componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data.to_dict() ) - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) + circular.append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item + ) field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -50,14 +54,16 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) circular = [] _circular = d.pop("circular", UNSET) - for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in _circular or []: - componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = ( - AnArrayWithACircularRefInItemsObjectBItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data - ) + for ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data + ) in (_circular or []): + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item = AnArrayWithACircularRefInItemsObjectBItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data ) - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) + circular.append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item + ) an_array_with_a_circular_ref_in_items_object_a_item = cls( circular=circular, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py index 70aa27507..968f53b6e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py @@ -17,18 +17,18 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem: """ """ - additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]] = ( - _attrs_field(init=False, factory=dict) - ) + additional_properties: dict[ + str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"] + ] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data - ) in prop: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data.to_dict() + for componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data in (prop): + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data.to_dict() + ) field_dict[prop_name].append( componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item ) @@ -42,19 +42,17 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = cls() + an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = ( + cls() + ) additional_properties = {} for prop_name, prop_dict in d.items(): additional_property = [] _additional_property = prop_dict - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data - ) in _additional_property: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data - ) + for componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data in (_additional_property): + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item_data ) additional_property.append( @@ -72,11 +70,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]: + def __getitem__( + self, key: str + ) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]: return self.additional_properties[key] def __setitem__( - self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"] + self, + key: str, + value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"], ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py index 119557650..f63ee6324 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py @@ -17,18 +17,18 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem: """ """ - additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]] = ( - _attrs_field(init=False, factory=dict) - ) + additional_properties: dict[ + str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"] + ] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data - ) in prop: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data.to_dict() + for componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data in (prop): + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data.to_dict() + ) field_dict[prop_name].append( componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item ) @@ -42,19 +42,17 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = cls() + an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = ( + cls() + ) additional_properties = {} for prop_name, prop_dict in d.items(): additional_property = [] _additional_property = prop_dict - for ( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data - ) in _additional_property: - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data - ) + for componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data in (_additional_property): + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item_data ) additional_property.append( @@ -72,11 +70,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]: + def __getitem__( + self, key: str + ) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]: return self.additional_properties[key] def __setitem__( - self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"] + self, + key: str, + value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"], ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py index e9b891737..84acd9cfb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py @@ -7,7 +7,9 @@ from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.an_array_with_a_circular_ref_in_items_object_a_item import AnArrayWithACircularRefInItemsObjectAItem + from ..models.an_array_with_a_circular_ref_in_items_object_a_item import ( + AnArrayWithACircularRefInItemsObjectAItem, + ) T = TypeVar("T", bound="AnArrayWithACircularRefInItemsObjectBItem") @@ -27,11 +29,13 @@ def to_dict(self) -> dict[str, Any]: circular: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.circular, Unset): circular = [] - for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in self.circular: + for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in (self.circular): componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = ( componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data.to_dict() ) - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) + circular.append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item + ) field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -50,14 +54,16 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) circular = [] _circular = d.pop("circular", UNSET) - for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in _circular or []: - componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = ( - AnArrayWithACircularRefInItemsObjectAItem.from_dict( - componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data - ) + for ( + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data + ) in (_circular or []): + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item = AnArrayWithACircularRefInItemsObjectAItem.from_dict( + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data ) - circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) + circular.append( + componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item + ) an_array_with_a_circular_ref_in_items_object_b_item = cls( circular=circular, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py index 262617c7a..f4dfef8bc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py @@ -11,16 +11,18 @@ class AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem: """ """ - additional_properties: dict[str, list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]] = ( - _attrs_field(init=False, factory=dict) - ) + additional_properties: dict[ + str, list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"] + ] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] - for componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data in prop: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data.to_dict() + for componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data in (prop): + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = ( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data.to_dict() + ) field_dict[prop_name].append( componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item ) @@ -36,13 +38,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: for prop_name, prop_dict in d.items(): additional_property = [] _additional_property = prop_dict - for ( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data - ) in _additional_property: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = ( - AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.from_dict( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data - ) + for componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data in (_additional_property): + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item = AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem.from_dict( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data ) additional_property.append( @@ -60,11 +58,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]: + def __getitem__( + self, key: str + ) -> list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]: return self.additional_properties[key] def __setitem__( - self, key: str, value: list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"] + self, + key: str, + value: list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"], ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py index 792994018..2e9140606 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py @@ -23,11 +23,13 @@ def to_dict(self) -> dict[str, Any]: recursive: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.recursive, Unset): recursive = [] - for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in self.recursive: + for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in (self.recursive): componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = ( componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data.to_dict() ) - recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) + recursive.append( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item + ) field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) @@ -42,14 +44,16 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) recursive = [] _recursive = d.pop("recursive", UNSET) - for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in _recursive or []: - componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = ( - AnArrayWithARecursiveRefInItemsObjectItem.from_dict( - componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data - ) + for ( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data + ) in (_recursive or []): + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item = AnArrayWithARecursiveRefInItemsObjectItem.from_dict( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data ) - recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) + recursive.append( + componentsschemas_an_array_with_a_recursive_ref_in_items_object_item + ) an_array_with_a_recursive_ref_in_items_object_item = cls( recursive=recursive, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py index 5dcb8c936..316c0bed4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py @@ -20,7 +20,9 @@ from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( BodyUploadFileTestsUploadPostSomeNullableObject, ) - from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject + from ..models.body_upload_file_tests_upload_post_some_object import ( + BodyUploadFileTestsUploadPostSomeObject, + ) from ..models.body_upload_file_tests_upload_post_some_optional_object import ( BodyUploadFileTestsUploadPostSomeOptionalObject, ) @@ -61,11 +63,13 @@ class BodyUploadFileTestsUploadPost: some_nullable_number: Union[None, Unset, float] = UNSET some_int_array: Union[Unset, list[Union[None, int]]] = UNSET some_array: Union[None, Unset, list["AFormData"]] = UNSET - some_optional_object: Union[Unset, "BodyUploadFileTestsUploadPostSomeOptionalObject"] = UNSET + some_optional_object: Union[ + Unset, "BodyUploadFileTestsUploadPostSomeOptionalObject" + ] = UNSET some_enum: Union[Unset, DifferentEnum] = UNSET - additional_properties: dict[str, "BodyUploadFileTestsUploadPostAdditionalProperty"] = _attrs_field( - init=False, factory=dict - ) + additional_properties: dict[ + str, "BodyUploadFileTestsUploadPostAdditionalProperty" + ] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( @@ -79,7 +83,9 @@ def to_dict(self) -> dict[str, Any]: some_object = self.some_object.to_dict() some_nullable_object: Union[None, dict[str, Any]] - if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): + if isinstance( + self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject + ): some_nullable_object = self.some_nullable_object.to_dict() else: some_nullable_object = self.some_nullable_object @@ -174,47 +180,111 @@ def to_multipart(self) -> types.RequestFiles: files.append(("some_file", self.some_file.to_tuple())) - files.append(("some_required_number", (None, str(self.some_required_number).encode(), "text/plain"))) + files.append( + ( + "some_required_number", + (None, str(self.some_required_number).encode(), "text/plain"), + ) + ) - files.append(("some_object", (None, json.dumps(self.some_object.to_dict()).encode(), "application/json"))) + files.append( + ( + "some_object", + ( + None, + json.dumps(self.some_object.to_dict()).encode(), + "application/json", + ), + ) + ) - if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): + if isinstance( + self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject + ): files.append( ( "some_nullable_object", - (None, json.dumps(self.some_nullable_object.to_dict()).encode(), "application/json"), + ( + None, + json.dumps(self.some_nullable_object.to_dict()).encode(), + "application/json", + ), ) ) else: - files.append(("some_nullable_object", (None, str(self.some_nullable_object).encode(), "text/plain"))) + files.append( + ( + "some_nullable_object", + (None, str(self.some_nullable_object).encode(), "text/plain"), + ) + ) if not isinstance(self.some_optional_file, Unset): files.append(("some_optional_file", self.some_optional_file.to_tuple())) if not isinstance(self.some_string, Unset): - files.append(("some_string", (None, str(self.some_string).encode(), "text/plain"))) + files.append( + ("some_string", (None, str(self.some_string).encode(), "text/plain")) + ) if not isinstance(self.a_datetime, Unset): - files.append(("a_datetime", (None, self.a_datetime.isoformat().encode(), "text/plain"))) + files.append( + ( + "a_datetime", + (None, self.a_datetime.isoformat().encode(), "text/plain"), + ) + ) if not isinstance(self.a_date, Unset): - files.append(("a_date", (None, self.a_date.isoformat().encode(), "text/plain"))) + files.append( + ("a_date", (None, self.a_date.isoformat().encode(), "text/plain")) + ) if not isinstance(self.some_number, Unset): - files.append(("some_number", (None, str(self.some_number).encode(), "text/plain"))) + files.append( + ("some_number", (None, str(self.some_number).encode(), "text/plain")) + ) if not isinstance(self.some_nullable_number, Unset): if isinstance(self.some_nullable_number, float): - files.append(("some_nullable_number", (None, str(self.some_nullable_number).encode(), "text/plain"))) + files.append( + ( + "some_nullable_number", + (None, str(self.some_nullable_number).encode(), "text/plain"), + ) + ) else: - files.append(("some_nullable_number", (None, str(self.some_nullable_number).encode(), "text/plain"))) + files.append( + ( + "some_nullable_number", + (None, str(self.some_nullable_number).encode(), "text/plain"), + ) + ) if not isinstance(self.some_int_array, Unset): for some_int_array_item_element in self.some_int_array: if isinstance(some_int_array_item_element, int): - files.append(("some_int_array", (None, str(some_int_array_item_element).encode(), "text/plain"))) + files.append( + ( + "some_int_array", + ( + None, + str(some_int_array_item_element).encode(), + "text/plain", + ), + ) + ) else: - files.append(("some_int_array", (None, str(some_int_array_item_element).encode(), "text/plain"))) + files.append( + ( + "some_int_array", + ( + None, + str(some_int_array_item_element).encode(), + "text/plain", + ), + ) + ) if not isinstance(self.some_array, Unset): if isinstance(self.some_array, list): @@ -222,25 +292,44 @@ def to_multipart(self) -> types.RequestFiles: files.append( ( "some_array", - (None, json.dumps(some_array_type_0_item_element.to_dict()).encode(), "application/json"), + ( + None, + json.dumps( + some_array_type_0_item_element.to_dict() + ).encode(), + "application/json", + ), ) ) else: - files.append(("some_array", (None, str(self.some_array).encode(), "text/plain"))) + files.append( + ("some_array", (None, str(self.some_array).encode(), "text/plain")) + ) if not isinstance(self.some_optional_object, Unset): files.append( ( "some_optional_object", - (None, json.dumps(self.some_optional_object.to_dict()).encode(), "application/json"), + ( + None, + json.dumps(self.some_optional_object.to_dict()).encode(), + "application/json", + ), ) ) if not isinstance(self.some_enum, Unset): - files.append(("some_enum", (None, str(self.some_enum.value).encode(), "text/plain"))) + files.append( + ("some_enum", (None, str(self.some_enum.value).encode(), "text/plain")) + ) for prop_name, prop in self.additional_properties.items(): - files.append((prop_name, (None, json.dumps(prop.to_dict()).encode(), "application/json"))) + files.append( + ( + prop_name, + (None, json.dumps(prop.to_dict()).encode(), "application/json"), + ) + ) return files @@ -253,7 +342,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( BodyUploadFileTestsUploadPostSomeNullableObject, ) - from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject + from ..models.body_upload_file_tests_upload_post_some_object import ( + BodyUploadFileTestsUploadPostSomeObject, + ) from ..models.body_upload_file_tests_upload_post_some_optional_object import ( BodyUploadFileTestsUploadPostSomeOptionalObject, ) @@ -263,22 +354,32 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: some_required_number = d.pop("some_required_number") - some_object = BodyUploadFileTestsUploadPostSomeObject.from_dict(d.pop("some_object")) + some_object = BodyUploadFileTestsUploadPostSomeObject.from_dict( + d.pop("some_object") + ) - def _parse_some_nullable_object(data: object) -> Union["BodyUploadFileTestsUploadPostSomeNullableObject", None]: + def _parse_some_nullable_object( + data: object, + ) -> Union["BodyUploadFileTestsUploadPostSomeNullableObject", None]: if data is None: return data try: if not isinstance(data, dict): raise TypeError() - some_nullable_object_type_0 = BodyUploadFileTestsUploadPostSomeNullableObject.from_dict(data) + some_nullable_object_type_0 = ( + BodyUploadFileTestsUploadPostSomeNullableObject.from_dict(data) + ) return some_nullable_object_type_0 except: # noqa: E722 pass - return cast(Union["BodyUploadFileTestsUploadPostSomeNullableObject", None], data) + return cast( + Union["BodyUploadFileTestsUploadPostSomeNullableObject", None], data + ) - some_nullable_object = _parse_some_nullable_object(d.pop("some_nullable_object")) + some_nullable_object = _parse_some_nullable_object( + d.pop("some_nullable_object") + ) _some_optional_file = d.pop("some_optional_file", UNSET) some_optional_file: Union[Unset, File] @@ -312,7 +413,9 @@ def _parse_some_nullable_number(data: object) -> Union[None, Unset, float]: return data return cast(Union[None, Unset, float], data) - some_nullable_number = _parse_some_nullable_number(d.pop("some_nullable_number", UNSET)) + some_nullable_number = _parse_some_nullable_number( + d.pop("some_nullable_number", UNSET) + ) some_int_array = [] _some_int_array = d.pop("some_int_array", UNSET) @@ -338,7 +441,9 @@ def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: some_array_type_0 = [] _some_array_type_0 = data for some_array_type_0_item_data in _some_array_type_0: - some_array_type_0_item = AFormData.from_dict(some_array_type_0_item_data) + some_array_type_0_item = AFormData.from_dict( + some_array_type_0_item_data + ) some_array_type_0.append(some_array_type_0_item) @@ -350,11 +455,17 @@ def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: some_array = _parse_some_array(d.pop("some_array", UNSET)) _some_optional_object = d.pop("some_optional_object", UNSET) - some_optional_object: Union[Unset, BodyUploadFileTestsUploadPostSomeOptionalObject] + some_optional_object: Union[ + Unset, BodyUploadFileTestsUploadPostSomeOptionalObject + ] if isinstance(_some_optional_object, Unset): some_optional_object = UNSET else: - some_optional_object = BodyUploadFileTestsUploadPostSomeOptionalObject.from_dict(_some_optional_object) + some_optional_object = ( + BodyUploadFileTestsUploadPostSomeOptionalObject.from_dict( + _some_optional_object + ) + ) _some_enum = d.pop("some_enum", UNSET) some_enum: Union[Unset, DifferentEnum] @@ -382,7 +493,9 @@ def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: additional_properties = {} for prop_name, prop_dict in d.items(): - additional_property = BodyUploadFileTestsUploadPostAdditionalProperty.from_dict(prop_dict) + additional_property = ( + BodyUploadFileTestsUploadPostAdditionalProperty.from_dict(prop_dict) + ) additional_properties[prop_name] = additional_property @@ -393,10 +506,14 @@ def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> "BodyUploadFileTestsUploadPostAdditionalProperty": + def __getitem__( + self, key: str + ) -> "BodyUploadFileTestsUploadPostAdditionalProperty": return self.additional_properties[key] - def __setitem__(self, key: str, value: "BodyUploadFileTestsUploadPostAdditionalProperty") -> None: + def __setitem__( + self, key: str, value: "BodyUploadFileTestsUploadPostAdditionalProperty" + ) -> None: self.additional_properties[key] = value def __delitem__(self, key: str) -> None: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py index b04e030aa..3fac02e39 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py @@ -39,7 +39,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: bar=bar, ) - body_upload_file_tests_upload_post_some_nullable_object.additional_properties = d + body_upload_file_tests_upload_post_some_nullable_object.additional_properties = ( + d + ) return body_upload_file_tests_upload_post_some_nullable_object @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py index 8e6eb4e83..85d1d0d8f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py @@ -39,7 +39,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: foo=foo, ) - body_upload_file_tests_upload_post_some_optional_object.additional_properties = d + body_upload_file_tests_upload_post_some_optional_object.additional_properties = ( + d + ) return body_upload_file_tests_upload_post_some_optional_object @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/extended.py b/end_to_end_tests/golden-record/my_test_api_client/models/extended.py index a3d2773a4..00143ca43 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/extended.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/extended.py @@ -75,8 +75,12 @@ class Extended: attr_leading_underscore: Union[Unset, str] = UNSET not_required_nullable: Union[None, Unset, str] = UNSET not_required_not_nullable: Union[Unset, str] = UNSET - not_required_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", Unset] = UNSET - not_required_nullable_one_of_models: Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str] = UNSET + not_required_one_of_models: Union[ + "FreeFormModel", "ModelWithUnionProperty", Unset + ] = UNSET + not_required_nullable_one_of_models: Union[ + "FreeFormModel", "ModelWithUnionProperty", None, Unset, str + ] = UNSET not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET from_extended: Union[Unset, str] = UNSET @@ -88,7 +92,9 @@ def to_dict(self) -> dict[str, Any]: an_enum_value = self.an_enum_value.value - an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default.value + an_allof_enum_with_overridden_default = ( + self.an_allof_enum_with_overridden_default.value + ) a_camel_date_time: str if isinstance(self.a_camel_date_time, datetime.datetime): @@ -152,8 +158,12 @@ def to_dict(self) -> dict[str, Any]: nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: nested_list_of_enums_item = [] - for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: - nested_list_of_enums_item_item = nested_list_of_enums_item_item_data.value + for ( + nested_list_of_enums_item_item_data + ) in nested_list_of_enums_item_data: + nested_list_of_enums_item_item = ( + nested_list_of_enums_item_item_data.value + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) nested_list_of_enums.append(nested_list_of_enums_item) @@ -190,11 +200,19 @@ def to_dict(self) -> dict[str, Any]: if isinstance(self.not_required_nullable_one_of_models, Unset): not_required_nullable_one_of_models = UNSET elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() - elif isinstance(self.not_required_nullable_one_of_models, ModelWithUnionProperty): - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models.to_dict() + not_required_nullable_one_of_models = ( + self.not_required_nullable_one_of_models.to_dict() + ) + elif isinstance( + self.not_required_nullable_one_of_models, ModelWithUnionProperty + ): + not_required_nullable_one_of_models = ( + self.not_required_nullable_one_of_models.to_dict() + ) else: - not_required_nullable_one_of_models = self.not_required_nullable_one_of_models + not_required_nullable_one_of_models = ( + self.not_required_nullable_one_of_models + ) not_required_model: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.not_required_model, Unset): @@ -250,7 +268,9 @@ def to_dict(self) -> dict[str, Any]: if not_required_one_of_models is not UNSET: field_dict["not_required_one_of_models"] = not_required_one_of_models if not_required_nullable_one_of_models is not UNSET: - field_dict["not_required_nullable_one_of_models"] = not_required_nullable_one_of_models + field_dict["not_required_nullable_one_of_models"] = ( + not_required_nullable_one_of_models + ) if not_required_model is not UNSET: field_dict["not_required_model"] = not_required_model if not_required_nullable_model is not UNSET: @@ -268,9 +288,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) an_enum_value = AnEnum(d.pop("an_enum_value")) - an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default")) + an_allof_enum_with_overridden_default = AnAllOfEnum( + d.pop("an_allof_enum_with_overridden_default") + ) - def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]: + def _parse_a_camel_date_time( + data: object, + ) -> Union[datetime.date, datetime.datetime]: try: if not isinstance(data, str): raise TypeError() @@ -330,7 +354,9 @@ def _parse_required_nullable(data: object) -> Union[None, str]: required_not_nullable = d.pop("required_not_nullable") - def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: + def _parse_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", Any]: try: if not isinstance(data, dict): raise TypeError() @@ -351,7 +377,9 @@ def _parse_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnion one_of_models = _parse_one_of_models(d.pop("one_of_models")) - def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: + def _parse_nullable_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", None]: if data is None: return data try: @@ -372,11 +400,15 @@ def _parse_nullable_one_of_models(data: object) -> Union["FreeFormModel", "Model pass return cast(Union["FreeFormModel", "ModelWithUnionProperty", None], data) - nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models")) + nullable_one_of_models = _parse_nullable_one_of_models( + d.pop("nullable_one_of_models") + ) model = ModelWithUnionProperty.from_dict(d.pop("model")) - def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None]: + def _parse_nullable_model( + data: object, + ) -> Union["ModelWithUnionProperty", None]: if data is None: return data try: @@ -406,7 +438,9 @@ def _parse_nullable_model(data: object) -> Union["ModelWithUnionProperty", None] nested_list_of_enums_item = [] _nested_list_of_enums_item = nested_list_of_enums_item_data for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: - nested_list_of_enums_item_item = DifferentEnum(nested_list_of_enums_item_item_data) + nested_list_of_enums_item_item = DifferentEnum( + nested_list_of_enums_item_item_data + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) @@ -437,11 +471,15 @@ def _parse_not_required_nullable(data: object) -> Union[None, Unset, str]: return data return cast(Union[None, Unset, str], data) - not_required_nullable = _parse_not_required_nullable(d.pop("not_required_nullable", UNSET)) + not_required_nullable = _parse_not_required_nullable( + d.pop("not_required_nullable", UNSET) + ) not_required_not_nullable = d.pop("not_required_not_nullable", UNSET) - def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: + def _parse_not_required_one_of_models( + data: object, + ) -> Union["FreeFormModel", "ModelWithUnionProperty", Unset]: if isinstance(data, Unset): return data try: @@ -458,7 +496,9 @@ def _parse_not_required_one_of_models(data: object) -> Union["FreeFormModel", "M return not_required_one_of_models_type_1 - not_required_one_of_models = _parse_not_required_one_of_models(d.pop("not_required_one_of_models", UNSET)) + not_required_one_of_models = _parse_not_required_one_of_models( + d.pop("not_required_one_of_models", UNSET) + ) def _parse_not_required_nullable_one_of_models( data: object, @@ -470,7 +510,9 @@ def _parse_not_required_nullable_one_of_models( try: if not isinstance(data, dict): raise TypeError() - not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(data) + not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict( + data + ) return not_required_nullable_one_of_models_type_0 except: # noqa: E722 @@ -478,15 +520,21 @@ def _parse_not_required_nullable_one_of_models( try: if not isinstance(data, dict): raise TypeError() - not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data) + not_required_nullable_one_of_models_type_1 = ( + ModelWithUnionProperty.from_dict(data) + ) return not_required_nullable_one_of_models_type_1 except: # noqa: E722 pass - return cast(Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data) - - not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models( - d.pop("not_required_nullable_one_of_models", UNSET) + return cast( + Union["FreeFormModel", "ModelWithUnionProperty", None, Unset, str], data + ) + + not_required_nullable_one_of_models = ( + _parse_not_required_nullable_one_of_models( + d.pop("not_required_nullable_one_of_models", UNSET) + ) ) _not_required_model = d.pop("not_required_model", UNSET) @@ -496,7 +544,9 @@ def _parse_not_required_nullable_one_of_models( else: not_required_model = ModelWithUnionProperty.from_dict(_not_required_model) - def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionProperty", None, Unset]: + def _parse_not_required_nullable_model( + data: object, + ) -> Union["ModelWithUnionProperty", None, Unset]: if data is None: return data if isinstance(data, Unset): @@ -504,14 +554,18 @@ def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionPro try: if not isinstance(data, dict): raise TypeError() - not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict(data) + not_required_nullable_model_type_1 = ModelWithUnionProperty.from_dict( + data + ) return not_required_nullable_model_type_1 except: # noqa: E722 pass return cast(Union["ModelWithUnionProperty", None, Unset], data) - not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) + not_required_nullable_model = _parse_not_required_nullable_model( + d.pop("not_required_nullable_model", UNSET) + ) from_extended = d.pop("fromExtended", UNSET) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py index 54531a7f8..0f7b4b8da 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py @@ -52,7 +52,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: color=color, ) - get_models_oneof_with_required_const_response_200_type_0.additional_properties = d + get_models_oneof_with_required_const_response_200_type_0.additional_properties = ( + d + ) return get_models_oneof_with_required_const_response_200_type_0 @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py index 69f11cca0..4a37460e4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py @@ -52,7 +52,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: texture=texture, ) - get_models_oneof_with_required_const_response_200_type_1.additional_properties = d + get_models_oneof_with_required_const_response_200_type_1.additional_properties = ( + d + ) return get_models_oneof_with_required_const_response_200_type_1 @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py index bb70f94a8..4aac0aa27 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py @@ -23,9 +23,9 @@ class ModelWithAdditionalPropertiesInlined: """ a_number: Union[Unset, float] = UNSET - additional_properties: dict[str, "ModelWithAdditionalPropertiesInlinedAdditionalProperty"] = _attrs_field( - init=False, factory=dict - ) + additional_properties: dict[ + str, "ModelWithAdditionalPropertiesInlinedAdditionalProperty" + ] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: a_number = self.a_number @@ -55,21 +55,31 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties = {} for prop_name, prop_dict in d.items(): - additional_property = ModelWithAdditionalPropertiesInlinedAdditionalProperty.from_dict(prop_dict) + additional_property = ( + ModelWithAdditionalPropertiesInlinedAdditionalProperty.from_dict( + prop_dict + ) + ) additional_properties[prop_name] = additional_property - model_with_additional_properties_inlined.additional_properties = additional_properties + model_with_additional_properties_inlined.additional_properties = ( + additional_properties + ) return model_with_additional_properties_inlined @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> "ModelWithAdditionalPropertiesInlinedAdditionalProperty": + def __getitem__( + self, key: str + ) -> "ModelWithAdditionalPropertiesInlinedAdditionalProperty": return self.additional_properties[key] - def __setitem__(self, key: str, value: "ModelWithAdditionalPropertiesInlinedAdditionalProperty") -> None: + def __setitem__( + self, key: str, value: "ModelWithAdditionalPropertiesInlinedAdditionalProperty" + ) -> None: self.additional_properties[key] = value def __delitem__(self, key: str) -> None: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py index e4fc6a09f..26113d4f7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py @@ -39,7 +39,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: extra_props_prop=extra_props_prop, ) - model_with_additional_properties_inlined_additional_property.additional_properties = d + model_with_additional_properties_inlined_additional_property.additional_properties = ( + d + ) return model_with_additional_properties_inlined_additional_property @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py index 2bbd16327..1d18d70b2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py @@ -33,7 +33,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_additional_properties_refed.additional_properties = additional_properties + model_with_additional_properties_refed.additional_properties = ( + additional_properties + ) return model_with_additional_properties_refed @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py index e1aa63d45..1799ec8d7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py @@ -18,7 +18,15 @@ class ModelWithAnyJsonProperties: """ """ additional_properties: dict[ - str, Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str] + str, + Union[ + "ModelWithAnyJsonPropertiesAdditionalPropertyType0", + bool, + float, + int, + list[str], + str, + ], ] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -52,11 +60,22 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: def _parse_additional_property( data: object, - ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: + ) -> Union[ + "ModelWithAnyJsonPropertiesAdditionalPropertyType0", + bool, + float, + int, + list[str], + str, + ]: try: if not isinstance(data, dict): raise TypeError() - additional_property_type_0 = ModelWithAnyJsonPropertiesAdditionalPropertyType0.from_dict(data) + additional_property_type_0 = ( + ModelWithAnyJsonPropertiesAdditionalPropertyType0.from_dict( + data + ) + ) return additional_property_type_0 except: # noqa: E722 @@ -70,7 +89,15 @@ def _parse_additional_property( except: # noqa: E722 pass return cast( - Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], data + Union[ + "ModelWithAnyJsonPropertiesAdditionalPropertyType0", + bool, + float, + int, + list[str], + str, + ], + data, ) additional_property = _parse_additional_property(prop_dict) @@ -84,15 +111,27 @@ def _parse_additional_property( def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__( - self, key: str - ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: + def __getitem__(self, key: str) -> Union[ + "ModelWithAnyJsonPropertiesAdditionalPropertyType0", + bool, + float, + int, + list[str], + str, + ]: return self.additional_properties[key] def __setitem__( self, key: str, - value: Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], + value: Union[ + "ModelWithAnyJsonPropertiesAdditionalPropertyType0", + bool, + float, + int, + list[str], + str, + ], ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py index 9cdda2b79..09c5a25a1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py @@ -24,7 +24,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) model_with_any_json_properties_additional_property_type_0 = cls() - model_with_any_json_properties_additional_property_type_0.additional_properties = d + model_with_any_json_properties_additional_property_type_0.additional_properties = ( + d + ) return model_with_any_json_properties_additional_property_type_0 @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py index b5c3ca2e1..3d4f4dba9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py @@ -5,7 +5,9 @@ from attrs import field as _attrs_field if TYPE_CHECKING: - from ..models.model_with_circular_ref_in_additional_properties_b import ModelWithCircularRefInAdditionalPropertiesB + from ..models.model_with_circular_ref_in_additional_properties_b import ( + ModelWithCircularRefInAdditionalPropertiesB, + ) T = TypeVar("T", bound="ModelWithCircularRefInAdditionalPropertiesA") @@ -15,8 +17,8 @@ class ModelWithCircularRefInAdditionalPropertiesA: """ """ - additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesB"] = _attrs_field( - init=False, factory=dict + additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesB"] = ( + _attrs_field(init=False, factory=dict) ) def to_dict(self) -> dict[str, Any]: @@ -37,11 +39,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties = {} for prop_name, prop_dict in d.items(): - additional_property = ModelWithCircularRefInAdditionalPropertiesB.from_dict(prop_dict) + additional_property = ModelWithCircularRefInAdditionalPropertiesB.from_dict( + prop_dict + ) additional_properties[prop_name] = additional_property - model_with_circular_ref_in_additional_properties_a.additional_properties = additional_properties + model_with_circular_ref_in_additional_properties_a.additional_properties = ( + additional_properties + ) return model_with_circular_ref_in_additional_properties_a @property @@ -51,7 +57,9 @@ def additional_keys(self) -> list[str]: def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesB": return self.additional_properties[key] - def __setitem__(self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesB") -> None: + def __setitem__( + self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesB" + ) -> None: self.additional_properties[key] = value def __delitem__(self, key: str) -> None: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py index a6e963ca6..67ee04656 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py @@ -5,7 +5,9 @@ from attrs import field as _attrs_field if TYPE_CHECKING: - from ..models.model_with_circular_ref_in_additional_properties_a import ModelWithCircularRefInAdditionalPropertiesA + from ..models.model_with_circular_ref_in_additional_properties_a import ( + ModelWithCircularRefInAdditionalPropertiesA, + ) T = TypeVar("T", bound="ModelWithCircularRefInAdditionalPropertiesB") @@ -15,8 +17,8 @@ class ModelWithCircularRefInAdditionalPropertiesB: """ """ - additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesA"] = _attrs_field( - init=False, factory=dict + additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesA"] = ( + _attrs_field(init=False, factory=dict) ) def to_dict(self) -> dict[str, Any]: @@ -37,11 +39,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties = {} for prop_name, prop_dict in d.items(): - additional_property = ModelWithCircularRefInAdditionalPropertiesA.from_dict(prop_dict) + additional_property = ModelWithCircularRefInAdditionalPropertiesA.from_dict( + prop_dict + ) additional_properties[prop_name] = additional_property - model_with_circular_ref_in_additional_properties_b.additional_properties = additional_properties + model_with_circular_ref_in_additional_properties_b.additional_properties = ( + additional_properties + ) return model_with_circular_ref_in_additional_properties_b @property @@ -51,7 +57,9 @@ def additional_keys(self) -> list[str]: def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesA": return self.additional_properties[key] - def __setitem__(self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesA") -> None: + def __setitem__( + self, key: str, value: "ModelWithCircularRefInAdditionalPropertiesA" + ) -> None: self.additional_properties[key] = value def __delitem__(self, key: str) -> None: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py index 203e321dd..ed8b54569 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py @@ -21,7 +21,9 @@ class ModelWithDiscriminatedUnion: discriminated_union (Union['ADiscriminatedUnionType1', 'ADiscriminatedUnionType2', None, Unset]): """ - discriminated_union: Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset] = UNSET + discriminated_union: Union[ + "ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset + ] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -63,7 +65,9 @@ def _parse_discriminated_union( try: if not isinstance(data, dict): raise TypeError() - componentsschemas_a_discriminated_union_type_0 = ADiscriminatedUnionType1.from_dict(data) + componentsschemas_a_discriminated_union_type_0 = ( + ADiscriminatedUnionType1.from_dict(data) + ) return componentsschemas_a_discriminated_union_type_0 except: # noqa: E722 @@ -71,14 +75,23 @@ def _parse_discriminated_union( try: if not isinstance(data, dict): raise TypeError() - componentsschemas_a_discriminated_union_type_1 = ADiscriminatedUnionType2.from_dict(data) + componentsschemas_a_discriminated_union_type_1 = ( + ADiscriminatedUnionType2.from_dict(data) + ) return componentsschemas_a_discriminated_union_type_1 except: # noqa: E722 pass - return cast(Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset], data) - - discriminated_union = _parse_discriminated_union(d.pop("discriminated_union", UNSET)) + return cast( + Union[ + "ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset + ], + data, + ) + + discriminated_union = _parse_discriminated_union( + d.pop("discriminated_union", UNSET) + ) model_with_discriminated_union = cls( discriminated_union=discriminated_union, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py index a740022a6..86c0abf7e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py @@ -6,7 +6,9 @@ from attrs import field as _attrs_field from dateutil.parser import isoparse -from ..models.model_with_merged_properties_string_to_enum import ModelWithMergedPropertiesStringToEnum +from ..models.model_with_merged_properties_string_to_enum import ( + ModelWithMergedPropertiesStringToEnum, +) from ..types import UNSET, Unset T = TypeVar("T", bound="ModelWithMergedProperties") @@ -25,7 +27,9 @@ class ModelWithMergedProperties: """ simple_string: Union[Unset, str] = "new default" - string_to_enum: Union[Unset, ModelWithMergedPropertiesStringToEnum] = ModelWithMergedPropertiesStringToEnum.A + string_to_enum: Union[Unset, ModelWithMergedPropertiesStringToEnum] = ( + ModelWithMergedPropertiesStringToEnum.A + ) string_to_date: Union[Unset, datetime.date] = UNSET number_to_int: Union[Unset, int] = UNSET any_to_string: Union[Unset, str] = "x" diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py index ccd515142..51ae3443f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py @@ -22,7 +22,9 @@ class ModelWithPrimitiveAdditionalProperties: a_date_holder (Union[Unset, ModelWithPrimitiveAdditionalPropertiesADateHolder]): """ - a_date_holder: Union[Unset, "ModelWithPrimitiveAdditionalPropertiesADateHolder"] = UNSET + a_date_holder: Union[Unset, "ModelWithPrimitiveAdditionalPropertiesADateHolder"] = ( + UNSET + ) additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -50,7 +52,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: if isinstance(_a_date_holder, Unset): a_date_holder = UNSET else: - a_date_holder = ModelWithPrimitiveAdditionalPropertiesADateHolder.from_dict(_a_date_holder) + a_date_holder = ModelWithPrimitiveAdditionalPropertiesADateHolder.from_dict( + _a_date_holder + ) model_with_primitive_additional_properties = cls( a_date_holder=a_date_holder, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py index 9d2776403..b4a462e6b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py @@ -13,7 +13,9 @@ class ModelWithPrimitiveAdditionalPropertiesADateHolder: """ """ - additional_properties: dict[str, datetime.datetime] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, datetime.datetime] = _attrs_field( + init=False, factory=dict + ) def to_dict(self) -> dict[str, Any]: field_dict: dict[str, Any] = {} @@ -33,7 +35,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_primitive_additional_properties_a_date_holder.additional_properties = additional_properties + model_with_primitive_additional_properties_a_date_holder.additional_properties = ( + additional_properties + ) return model_with_primitive_additional_properties_a_date_holder @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py index 208111a60..375d3ac0d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py @@ -11,8 +11,8 @@ class ModelWithRecursiveRefInAdditionalProperties: """ """ - additional_properties: dict[str, "ModelWithRecursiveRefInAdditionalProperties"] = _attrs_field( - init=False, factory=dict + additional_properties: dict[str, "ModelWithRecursiveRefInAdditionalProperties"] = ( + _attrs_field(init=False, factory=dict) ) def to_dict(self) -> dict[str, Any]: @@ -29,11 +29,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties = {} for prop_name, prop_dict in d.items(): - additional_property = ModelWithRecursiveRefInAdditionalProperties.from_dict(prop_dict) + additional_property = ModelWithRecursiveRefInAdditionalProperties.from_dict( + prop_dict + ) additional_properties[prop_name] = additional_property - model_with_recursive_ref_in_additional_properties.additional_properties = additional_properties + model_with_recursive_ref_in_additional_properties.additional_properties = ( + additional_properties + ) return model_with_recursive_ref_in_additional_properties @property @@ -43,7 +47,9 @@ def additional_keys(self) -> list[str]: def __getitem__(self, key: str) -> "ModelWithRecursiveRefInAdditionalProperties": return self.additional_properties[key] - def __setitem__(self, key: str, value: "ModelWithRecursiveRefInAdditionalProperties") -> None: + def __setitem__( + self, key: str, value: "ModelWithRecursiveRefInAdditionalProperties" + ) -> None: self.additional_properties[key] = value def __delitem__(self, key: str) -> None: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py index 420405539..d509aec1a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py @@ -6,8 +6,12 @@ from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples - from ..models.model_with_union_property_inlined_bananas import ModelWithUnionPropertyInlinedBananas + from ..models.model_with_union_property_inlined_apples import ( + ModelWithUnionPropertyInlinedApples, + ) + from ..models.model_with_union_property_inlined_bananas import ( + ModelWithUnionPropertyInlinedBananas, + ) T = TypeVar("T", bound="ModelWithUnionPropertyInlined") @@ -20,10 +24,16 @@ class ModelWithUnionPropertyInlined: fruit (Union['ModelWithUnionPropertyInlinedApples', 'ModelWithUnionPropertyInlinedBananas', Unset]): """ - fruit: Union["ModelWithUnionPropertyInlinedApples", "ModelWithUnionPropertyInlinedBananas", Unset] = UNSET + fruit: Union[ + "ModelWithUnionPropertyInlinedApples", + "ModelWithUnionPropertyInlinedBananas", + Unset, + ] = UNSET def to_dict(self) -> dict[str, Any]: - from ..models.model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples + from ..models.model_with_union_property_inlined_apples import ( + ModelWithUnionPropertyInlinedApples, + ) fruit: Union[Unset, dict[str, Any]] if isinstance(self.fruit, Unset): @@ -43,14 +53,22 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples - from ..models.model_with_union_property_inlined_bananas import ModelWithUnionPropertyInlinedBananas + from ..models.model_with_union_property_inlined_apples import ( + ModelWithUnionPropertyInlinedApples, + ) + from ..models.model_with_union_property_inlined_bananas import ( + ModelWithUnionPropertyInlinedBananas, + ) d = dict(src_dict) def _parse_fruit( data: object, - ) -> Union["ModelWithUnionPropertyInlinedApples", "ModelWithUnionPropertyInlinedBananas", Unset]: + ) -> Union[ + "ModelWithUnionPropertyInlinedApples", + "ModelWithUnionPropertyInlinedBananas", + Unset, + ]: if isinstance(data, Unset): return data try: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py index 66717f670..dc612aac3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py @@ -52,16 +52,25 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - def _parse_a(data: object) -> Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str]: + def _parse_a( + data: object, + ) -> Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str]: try: if not isinstance(data, dict): raise TypeError() - a_type_1 = PostResponsesUnionsSimpleBeforeComplexResponse200AType1.from_dict(data) + a_type_1 = ( + PostResponsesUnionsSimpleBeforeComplexResponse200AType1.from_dict( + data + ) + ) return a_type_1 except: # noqa: E722 pass - return cast(Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str], data) + return cast( + Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str], + data, + ) a = _parse_a(d.pop("a")) @@ -69,7 +78,9 @@ def _parse_a(data: object) -> Union["PostResponsesUnionsSimpleBeforeComplexRespo a=a, ) - post_responses_unions_simple_before_complex_response_200.additional_properties = d + post_responses_unions_simple_before_complex_response_200.additional_properties = ( + d + ) return post_responses_unions_simple_before_complex_response_200 @property diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py index f2c1d3216..11a3ae351 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py @@ -24,7 +24,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) post_responses_unions_simple_before_complex_response_200a_type_1 = cls() - post_responses_unions_simple_before_complex_response_200a_type_1.additional_properties = d + post_responses_unions_simple_before_complex_response_200a_type_1.additional_properties = ( + d + ) return post_responses_unions_simple_before_complex_response_200a_type_1 @property diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py index 52385855c..6da45ec10 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -27,7 +27,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -36,7 +38,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py index af4c4ca22..0b4979d08 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -29,7 +29,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == 200: return None if client.raise_on_unexpected_status: @@ -38,7 +40,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py index e80446f10..eeffd00c8 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py @@ -38,9 +38,15 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -168,9 +174,15 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -214,7 +226,9 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": def get_httpx_client(self) -> httpx.Client: """Get the underlying httpx.Client, constructing a new one if not previously set""" if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._client = httpx.Client( base_url=self._base_url, cookies=self._cookies, @@ -235,7 +249,9 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client( + self, async_client: httpx.AsyncClient + ) -> "AuthenticatedClient": """Manually the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -246,7 +262,9 @@ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Authentica def get_async_httpx_client(self) -> httpx.AsyncClient: """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._async_client = httpx.AsyncClient( base_url=self._base_url, cookies=self._cookies, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py index 5c3508cf5..023c20c74 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py @@ -32,7 +32,9 @@ class AModel: def to_dict(self) -> dict[str, Any]: an_enum_value: str = self.an_enum_value - an_allof_enum_with_overridden_default: str = self.an_allof_enum_with_overridden_default + an_allof_enum_with_overridden_default: str = ( + self.an_allof_enum_with_overridden_default + ) any_value = self.any_value @@ -45,8 +47,12 @@ def to_dict(self) -> dict[str, Any]: nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: nested_list_of_enums_item = [] - for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: - nested_list_of_enums_item_item: str = nested_list_of_enums_item_item_data + for ( + nested_list_of_enums_item_item_data + ) in nested_list_of_enums_item_data: + nested_list_of_enums_item_item: str = ( + nested_list_of_enums_item_item_data + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) nested_list_of_enums.append(nested_list_of_enums_item) @@ -73,7 +79,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) an_enum_value = check_an_enum(d.pop("an_enum_value")) - an_allof_enum_with_overridden_default = check_an_all_of_enum(d.pop("an_allof_enum_with_overridden_default")) + an_allof_enum_with_overridden_default = check_an_all_of_enum( + d.pop("an_allof_enum_with_overridden_default") + ) any_value = d.pop("any_value", UNSET) @@ -90,7 +98,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: nested_list_of_enums_item = [] _nested_list_of_enums_item = nested_list_of_enums_item_data for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: - nested_list_of_enums_item_item = check_different_enum(nested_list_of_enums_item_item_data) + nested_list_of_enums_item_item = check_different_enum( + nested_list_of_enums_item_item_data + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py index 3455e04d0..0f9a4d734 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py @@ -13,4 +13,6 @@ def check_an_all_of_enum(value: str) -> AnAllOfEnum: if value in AN_ALL_OF_ENUM_VALUES: return cast(AnAllOfEnum, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {AN_ALL_OF_ENUM_VALUES!r}") + raise TypeError( + f"Unexpected value {value!r}. Expected one of {AN_ALL_OF_ENUM_VALUES!r}" + ) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py index 4203876de..4e540a6b1 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py @@ -11,4 +11,6 @@ def check_an_enum_with_null(value: str) -> AnEnumWithNull: if value in AN_ENUM_WITH_NULL_VALUES: return cast(AnEnumWithNull, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {AN_ENUM_WITH_NULL_VALUES!r}") + raise TypeError( + f"Unexpected value {value!r}. Expected one of {AN_ENUM_WITH_NULL_VALUES!r}" + ) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py index 9d0abd942..91babdc5f 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py @@ -12,4 +12,6 @@ def check_an_int_enum(value: int) -> AnIntEnum: if value in AN_INT_ENUM_VALUES: return cast(AnIntEnum, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {AN_INT_ENUM_VALUES!r}") + raise TypeError( + f"Unexpected value {value!r}. Expected one of {AN_INT_ENUM_VALUES!r}" + ) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py index e672a9821..17a58b561 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py @@ -11,4 +11,6 @@ def check_different_enum(value: str) -> DifferentEnum: if value in DIFFERENT_ENUM_VALUES: return cast(DifferentEnum, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {DIFFERENT_ENUM_VALUES!r}") + raise TypeError( + f"Unexpected value {value!r}. Expected one of {DIFFERENT_ENUM_VALUES!r}" + ) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py index 845d6c2a0..d92980fce 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py @@ -12,4 +12,6 @@ def check_get_user_list_int_enum_header(value: int) -> GetUserListIntEnumHeader: if value in GET_USER_LIST_INT_ENUM_HEADER_VALUES: return cast(GetUserListIntEnumHeader, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {GET_USER_LIST_INT_ENUM_HEADER_VALUES!r}") + raise TypeError( + f"Unexpected value {value!r}. Expected one of {GET_USER_LIST_INT_ENUM_HEADER_VALUES!r}" + ) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py index 55dbbad62..a40c1da10 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py @@ -12,4 +12,6 @@ def check_get_user_list_string_enum_header(value: str) -> GetUserListStringEnumHeader: if value in GET_USER_LIST_STRING_ENUM_HEADER_VALUES: return cast(GetUserListStringEnumHeader, value) - raise TypeError(f"Unexpected value {value!r}. Expected one of {GET_USER_LIST_STRING_ENUM_HEADER_VALUES!r}") + raise TypeError( + f"Unexpected value {value!r}. Expected one of {GET_USER_LIST_STRING_ENUM_HEADER_VALUES!r}" + ) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py index 86212c124..19edb7ddb 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py @@ -29,7 +29,9 @@ class PostUserListBody: an_enum_value: Union[Unset, list[AnEnum]] = UNSET an_enum_value_with_null: Union[Unset, list[Union[AnEnumWithNull, None]]] = UNSET an_enum_value_with_only_null: Union[Unset, list[None]] = UNSET - an_allof_enum_with_overridden_default: Union[Unset, AnAllOfEnum] = "overridden_default" + an_allof_enum_with_overridden_default: Union[Unset, AnAllOfEnum] = ( + "overridden_default" + ) an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -59,7 +61,9 @@ def to_dict(self) -> dict[str, Any]: an_allof_enum_with_overridden_default: Union[Unset, str] = UNSET if not isinstance(self.an_allof_enum_with_overridden_default, Unset): - an_allof_enum_with_overridden_default = self.an_allof_enum_with_overridden_default + an_allof_enum_with_overridden_default = ( + self.an_allof_enum_with_overridden_default + ) an_optional_allof_enum: Union[Unset, str] = UNSET if not isinstance(self.an_optional_allof_enum, Unset): @@ -70,8 +74,12 @@ def to_dict(self) -> dict[str, Any]: nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: nested_list_of_enums_item = [] - for nested_list_of_enums_item_item_data in nested_list_of_enums_item_data: - nested_list_of_enums_item_item: str = nested_list_of_enums_item_item_data + for ( + nested_list_of_enums_item_item_data + ) in nested_list_of_enums_item_data: + nested_list_of_enums_item_item: str = ( + nested_list_of_enums_item_item_data + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) nested_list_of_enums.append(nested_list_of_enums_item) @@ -86,7 +94,9 @@ def to_dict(self) -> dict[str, Any]: if an_enum_value_with_only_null is not UNSET: field_dict["an_enum_value_with_only_null"] = an_enum_value_with_only_null if an_allof_enum_with_overridden_default is not UNSET: - field_dict["an_allof_enum_with_overridden_default"] = an_allof_enum_with_overridden_default + field_dict["an_allof_enum_with_overridden_default"] = ( + an_allof_enum_with_overridden_default + ) if an_optional_allof_enum is not UNSET: field_dict["an_optional_allof_enum"] = an_optional_allof_enum if nested_list_of_enums is not UNSET: @@ -99,7 +109,12 @@ def to_multipart(self) -> types.RequestFiles: if not isinstance(self.an_enum_value, Unset): for an_enum_value_item_element in self.an_enum_value: - files.append(("an_enum_value", (None, str(an_enum_value_item_element).encode(), "text/plain"))) + files.append( + ( + "an_enum_value", + (None, str(an_enum_value_item_element).encode(), "text/plain"), + ) + ) if not isinstance(self.an_enum_value_with_null, Unset): for an_enum_value_with_null_item_element in self.an_enum_value_with_null: @@ -107,23 +122,37 @@ def to_multipart(self) -> types.RequestFiles: files.append( ( "an_enum_value_with_null", - (None, str(an_enum_value_with_null_item_element).encode(), "text/plain"), + ( + None, + str(an_enum_value_with_null_item_element).encode(), + "text/plain", + ), ) ) else: files.append( ( "an_enum_value_with_null", - (None, str(an_enum_value_with_null_item_element).encode(), "text/plain"), + ( + None, + str(an_enum_value_with_null_item_element).encode(), + "text/plain", + ), ) ) if not isinstance(self.an_enum_value_with_only_null, Unset): - for an_enum_value_with_only_null_item_element in self.an_enum_value_with_only_null: + for ( + an_enum_value_with_only_null_item_element + ) in self.an_enum_value_with_only_null: files.append( ( "an_enum_value_with_only_null", - (None, str(an_enum_value_with_only_null_item_element).encode(), "text/plain"), + ( + None, + str(an_enum_value_with_only_null_item_element).encode(), + "text/plain", + ), ) ) @@ -131,20 +160,35 @@ def to_multipart(self) -> types.RequestFiles: files.append( ( "an_allof_enum_with_overridden_default", - (None, str(self.an_allof_enum_with_overridden_default).encode(), "text/plain"), + ( + None, + str(self.an_allof_enum_with_overridden_default).encode(), + "text/plain", + ), ) ) if not isinstance(self.an_optional_allof_enum, Unset): - files.append(("an_optional_allof_enum", (None, str(self.an_optional_allof_enum).encode(), "text/plain"))) + files.append( + ( + "an_optional_allof_enum", + (None, str(self.an_optional_allof_enum).encode(), "text/plain"), + ) + ) if not isinstance(self.nested_list_of_enums, Unset): for nested_list_of_enums_item_element in self.nested_list_of_enums: - for nested_list_of_enums_item_item_element in nested_list_of_enums_item_element: + for ( + nested_list_of_enums_item_item_element + ) in nested_list_of_enums_item_element: files.append( ( "nested_list_of_enums", - (None, str(nested_list_of_enums_item_item_element).encode(), "text/plain"), + ( + None, + str(nested_list_of_enums_item_item_element).encode(), + "text/plain", + ), ) ) @@ -167,31 +211,43 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: _an_enum_value_with_null = d.pop("an_enum_value_with_null", UNSET) for an_enum_value_with_null_item_data in _an_enum_value_with_null or []: - def _parse_an_enum_value_with_null_item(data: object) -> Union[AnEnumWithNull, None]: + def _parse_an_enum_value_with_null_item( + data: object, + ) -> Union[AnEnumWithNull, None]: if data is None: return data try: if not isinstance(data, str): raise TypeError() - componentsschemas_an_enum_with_null_type_1 = check_an_enum_with_null(data) + componentsschemas_an_enum_with_null_type_1 = ( + check_an_enum_with_null(data) + ) return componentsschemas_an_enum_with_null_type_1 except: # noqa: E722 pass return cast(Union[AnEnumWithNull, None], data) - an_enum_value_with_null_item = _parse_an_enum_value_with_null_item(an_enum_value_with_null_item_data) + an_enum_value_with_null_item = _parse_an_enum_value_with_null_item( + an_enum_value_with_null_item_data + ) an_enum_value_with_null.append(an_enum_value_with_null_item) - an_enum_value_with_only_null = cast(list[None], d.pop("an_enum_value_with_only_null", UNSET)) + an_enum_value_with_only_null = cast( + list[None], d.pop("an_enum_value_with_only_null", UNSET) + ) - _an_allof_enum_with_overridden_default = d.pop("an_allof_enum_with_overridden_default", UNSET) + _an_allof_enum_with_overridden_default = d.pop( + "an_allof_enum_with_overridden_default", UNSET + ) an_allof_enum_with_overridden_default: Union[Unset, AnAllOfEnum] if isinstance(_an_allof_enum_with_overridden_default, Unset): an_allof_enum_with_overridden_default = UNSET else: - an_allof_enum_with_overridden_default = check_an_all_of_enum(_an_allof_enum_with_overridden_default) + an_allof_enum_with_overridden_default = check_an_all_of_enum( + _an_allof_enum_with_overridden_default + ) _an_optional_allof_enum = d.pop("an_optional_allof_enum", UNSET) an_optional_allof_enum: Union[Unset, AnAllOfEnum] @@ -206,7 +262,9 @@ def _parse_an_enum_value_with_null_item(data: object) -> Union[AnEnumWithNull, N nested_list_of_enums_item = [] _nested_list_of_enums_item = nested_list_of_enums_item_data for nested_list_of_enums_item_item_data in _nested_list_of_enums_item: - nested_list_of_enums_item_item = check_different_enum(nested_list_of_enums_item_item_data) + nested_list_of_enums_item_item = check_different_enum( + nested_list_of_enums_item_item_data + ) nested_list_of_enums_item.append(nested_list_of_enums_item_item) diff --git a/end_to_end_tests/metadata_snapshots/setup.py b/end_to_end_tests/metadata_snapshots/setup.py index 312241bb8..507c1d71b 100644 --- a/end_to_end_tests/metadata_snapshots/setup.py +++ b/end_to_end_tests/metadata_snapshots/setup.py @@ -13,6 +13,10 @@ long_description_content_type="text/markdown", packages=find_packages(), python_requires=">=3.9, <4", - install_requires=["httpx >= 0.23.0, < 0.29.0", "attrs >= 22.2.0", "python-dateutil >= 2.8.0, < 3"], + install_requires=[ + "httpx >= 0.23.0, < 0.29.0", + "attrs >= 22.2.0", + "python-dateutil >= 2.8.0, < 3", + ], package_data={"test_3_1_features_client": ["py.typed"]}, ) diff --git a/end_to_end_tests/regen_golden_record.py b/end_to_end_tests/regen_golden_record.py index ba608dfa3..86fdab1de 100644 --- a/end_to_end_tests/regen_golden_record.py +++ b/end_to_end_tests/regen_golden_record.py @@ -1,4 +1,5 @@ -""" Regenerate golden-record """ +"""Regenerate golden-record""" + import filecmp import shutil from pathlib import Path @@ -15,7 +16,7 @@ def _regenerate( output_dir: str = "my-test-api-client", golden_record_dir: Optional[str] = None, config_file_name: str = "config.yml", - extra_args: Optional[list[str]] = None + extra_args: Optional[list[str]] = None, ) -> None: end_to_end_tests_base_path = Path(__file__).parent project_base_path = end_to_end_tests_base_path.parent @@ -31,7 +32,9 @@ def _regenerate( args.append(f"--config={config_path}") if extra_args: args.extend(extra_args) - print(f"Using {spec_file_name}{f' and {config_file_name}' if config_file_name else ''}") + print( + f"Using {spec_file_name}{f' and {config_file_name}' if config_file_name else ''}" + ) result = runner.invoke(app, args) @@ -73,7 +76,12 @@ def regen_metadata_snapshots(): output_path = Path.cwd() / "test-3-1-features-client" snapshots_dir = Path(__file__).parent / "metadata_snapshots" - for (meta, file, rename_to) in (("setup", "setup.py", "setup.py"), ("pdm", "pyproject.toml", "pdm.pyproject.toml"), ("poetry", "pyproject.toml", "poetry.pyproject.toml"), ("uv", "pyproject.toml", "uv.pyproject.toml")): + for meta, file, rename_to in ( + ("setup", "setup.py", "setup.py"), + ("pdm", "pyproject.toml", "pdm.pyproject.toml"), + ("poetry", "pyproject.toml", "poetry.pyproject.toml"), + ("uv", "pyproject.toml", "uv.pyproject.toml"), + ): _regenerate( spec_file_name="3.1_specific.openapi.yaml", output_dir="test-3-1-features-client", diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py index 1bb532823..a71dd24a8 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py @@ -44,7 +44,9 @@ def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Literal["Why have a fixed response? I dunno"]]: if response.status_code == 200: - response_200 = cast(Literal["Why have a fixed response? I dunno"], response.json()) + response_200 = cast( + Literal["Why have a fixed response? I dunno"], response.json() + ) if response_200 != "Why have a fixed response? I dunno": raise ValueError( f"response_200 must match const 'Why have a fixed response? I dunno', got '{response_200}'" diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py index 48a2c1733..6e14134d8 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py @@ -28,7 +28,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[str]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[str]: if response.status_code == 200: response_200 = cast(str, response.json()) return response_200 @@ -38,7 +40,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[str]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[str]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py index e80446f10..eeffd00c8 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py @@ -38,9 +38,15 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -168,9 +174,15 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -214,7 +226,9 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": def get_httpx_client(self) -> httpx.Client: """Get the underlying httpx.Client, constructing a new one if not previously set""" if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._client = httpx.Client( base_url=self._base_url, cookies=self._cookies, @@ -235,7 +249,9 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client( + self, async_client: httpx.AsyncClient + ) -> "AuthenticatedClient": """Manually the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -246,7 +262,9 @@ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Authentica def get_async_httpx_client(self) -> httpx.AsyncClient: """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._async_client = httpx.AsyncClient( base_url=self._base_url, cookies=self._cookies, diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py index 3f910dc89..5a29ba283 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py @@ -49,9 +49,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) required = cast(Literal["this always goes in the body"], d.pop("required")) if required != "this always goes in the body": - raise ValueError(f"required must match const 'this always goes in the body', got '{required}'") + raise ValueError( + f"required must match const 'this always goes in the body', got '{required}'" + ) - def _parse_nullable(data: object) -> Union[Literal["this or null goes in the body"], None]: + def _parse_nullable( + data: object, + ) -> Union[Literal["this or null goes in the body"], None]: if data is None: return data nullable_type_1 = cast(Literal["this or null goes in the body"], data) @@ -64,9 +68,16 @@ def _parse_nullable(data: object) -> Union[Literal["this or null goes in the bod nullable = _parse_nullable(d.pop("nullable")) - optional = cast(Union[Literal["this sometimes goes in the body"], Unset], d.pop("optional", UNSET)) - if optional != "this sometimes goes in the body" and not isinstance(optional, Unset): - raise ValueError(f"optional must match const 'this sometimes goes in the body', got '{optional}'") + optional = cast( + Union[Literal["this sometimes goes in the body"], Unset], + d.pop("optional", UNSET), + ) + if optional != "this sometimes goes in the body" and not isinstance( + optional, Unset + ): + raise ValueError( + f"optional must match const 'this sometimes goes in the body', got '{optional}'" + ) post_const_path_body = cls( required=required, diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py index 655c607d8..74721f66c 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py @@ -17,12 +17,16 @@ class PostPrefixItemsBody: prefix_items_only (Union[Unset, list[Union[float, str]]]): """ - prefix_items_and_items: Union[Unset, list[Union[Literal["prefix"], float, str]]] = UNSET + prefix_items_and_items: Union[Unset, list[Union[Literal["prefix"], float, str]]] = ( + UNSET + ) prefix_items_only: Union[Unset, list[Union[float, str]]] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - prefix_items_and_items: Union[Unset, list[Union[Literal["prefix"], float, str]]] = UNSET + prefix_items_and_items: Union[ + Unset, list[Union[Literal["prefix"], float, str]] + ] = UNSET if not isinstance(self.prefix_items_and_items, Unset): prefix_items_and_items = [] for prefix_items_and_items_item_data in self.prefix_items_and_items: @@ -55,7 +59,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: _prefix_items_and_items = d.pop("prefixItemsAndItems", UNSET) for prefix_items_and_items_item_data in _prefix_items_and_items or []: - def _parse_prefix_items_and_items_item(data: object) -> Union[Literal["prefix"], float, str]: + def _parse_prefix_items_and_items_item( + data: object, + ) -> Union[Literal["prefix"], float, str]: prefix_items_and_items_item_type_0 = cast(Literal["prefix"], data) if prefix_items_and_items_item_type_0 != "prefix": raise ValueError( @@ -64,7 +70,9 @@ def _parse_prefix_items_and_items_item(data: object) -> Union[Literal["prefix"], return prefix_items_and_items_item_type_0 return cast(Union[Literal["prefix"], float, str], data) - prefix_items_and_items_item = _parse_prefix_items_and_items_item(prefix_items_and_items_item_data) + prefix_items_and_items_item = _parse_prefix_items_and_items_item( + prefix_items_and_items_item_data + ) prefix_items_and_items.append(prefix_items_and_items_item) @@ -75,7 +83,9 @@ def _parse_prefix_items_and_items_item(data: object) -> Union[Literal["prefix"], def _parse_prefix_items_only_item(data: object) -> Union[float, str]: return cast(Union[float, str], data) - prefix_items_only_item = _parse_prefix_items_only_item(prefix_items_only_item_data) + prefix_items_only_item = _parse_prefix_items_only_item( + prefix_items_only_item_data + ) prefix_items_only.append(prefix_items_only_item) diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index 347f72f7e..60c243edc 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -8,7 +8,9 @@ from typer.testing import CliRunner from end_to_end_tests.generated_client import ( - _run_command, generate_client, generate_client_from_inline_spec, + _run_command, + generate_client, + generate_client_from_inline_spec, ) from openapi_python_client.cli import app @@ -32,7 +34,9 @@ def _compare_directories( """ first_printable = record.relative_to(Path.cwd()) second_printable = test_subject.relative_to(Path.cwd()) - dc = dircmp(record, test_subject, ignore=[".ruff_cache", "__pycache__"] + (ignore or [])) + dc = dircmp( + record, test_subject, ignore=[".ruff_cache", "__pycache__"] + (ignore or []) + ) missing_files = set(dc.left_only + dc.right_only) - (expected_missing or set()) if missing_files: pytest.fail( @@ -88,16 +92,25 @@ def run_e2e_test( expected_missing: Optional[set[str]] = None, specify_output_path_explicitly: bool = True, ) -> Result: - with generate_client(openapi_document, extra_args, output_path, specify_output_path_explicitly=specify_output_path_explicitly) as g: + with generate_client( + openapi_document, + extra_args, + output_path, + specify_output_path_explicitly=specify_output_path_explicitly, + ) as g: gr_path = Path(__file__).parent / golden_record_path expected_differences = expected_differences or {} # Use absolute paths for expected differences for easier comparisons expected_differences = { - g.output_path.joinpath(key): value for key, value in expected_differences.items() + g.output_path.joinpath(key): value + for key, value in expected_differences.items() } _compare_directories( - gr_path, g.output_path, expected_differences=expected_differences, expected_missing=expected_missing + gr_path, + g.output_path, + expected_differences=expected_differences, + expected_missing=expected_missing, ) import mypy.api @@ -133,7 +146,7 @@ def test_literal_enums_end_to_end(): [f"--config={config_path}"], {}, "literal-enums-golden-record", - "my-enum-api-client" + "my-enum-api-client", ) @@ -144,7 +157,7 @@ def test_literal_enums_end_to_end(): ("pdm", "pyproject.toml", "pdm.pyproject.toml"), ("poetry", "pyproject.toml", "poetry.pyproject.toml"), ("uv", "pyproject.toml", "uv.pyproject.toml"), - ) + ), ) def test_meta(meta: str, generated_file: Optional[str], expected_file: Optional[str]): with generate_client( @@ -154,10 +167,9 @@ def test_meta(meta: str, generated_file: Optional[str], expected_file: Optional[ ) as g: if generated_file and expected_file: assert (g.output_path / generated_file).exists() - assert ( - (g.output_path / generated_file).read_text() == - (Path(__file__).parent / "metadata_snapshots" / expected_file).read_text() - ) + assert (g.output_path / generated_file).read_text() == ( + Path(__file__).parent / "metadata_snapshots" / expected_file + ).read_text() def test_none_meta(): @@ -224,10 +236,16 @@ def test_bad_url(): assert "Could not get OpenAPI document from provided URL" in result.stdout -ERROR_DOCUMENTS = [path for path in Path(__file__).parent.joinpath("documents_with_errors").iterdir() if path.is_file()] +ERROR_DOCUMENTS = [ + path + for path in Path(__file__).parent.joinpath("documents_with_errors").iterdir() + if path.is_file() +] -@pytest.mark.parametrize("document", ERROR_DOCUMENTS, ids=[path.stem for path in ERROR_DOCUMENTS]) +@pytest.mark.parametrize( + "document", ERROR_DOCUMENTS, ids=[path.stem for path in ERROR_DOCUMENTS] +) def test_documents_with_errors(snapshot, document): with generate_client( document, @@ -237,7 +255,9 @@ def test_documents_with_errors(snapshot, document): ) as g: result = g.generator_result assert result.exit_code == 1 - output = result.stdout.replace(str(g.output_path), "/test-documents-with-errors") + output = result.stdout.replace( + str(g.output_path), "/test-documents-with-errors" + ) assert output == snapshot @@ -279,7 +299,7 @@ def test_update_integration_tests(): "generate", extra_args=["--overwrite", "--meta=pdm", f"--output-path={temp_dir}"], url=url, - config_path=config_path + config_path=config_path, ) _compare_directories(source_path, temp_dir, ignore=["pyproject.toml"]) import mypy.api diff --git a/fix_builtin_shadowing.py b/fix_builtin_shadowing.py new file mode 100644 index 000000000..cc41e74f7 --- /dev/null +++ b/fix_builtin_shadowing.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +import argparse +import re +import sys +from pathlib import Path + + +def fix_builtin_shadowing_in_file(file_path: Path, write: bool = False) -> bool: + """ + Fix builtin shadowing issues in a Python file. + Currently handles: id -> id_ + Also fixes trailing commas in imports. + """ + try: + content = file_path.read_text(encoding="utf-8") + except Exception as e: + print(f"[skip] {file_path}: {e}", file=sys.stderr) + return False + + original_content = content + + # Fix id shadowing - look for id = assignments but not id_ = (already fixed) + # Use regex to match id = but not id_ = or id. (attribute access) + content = re.sub(r"\bid\s*=\s*(?!_)", "id_ =", content) + + # Also fix id in function parameters and type hints + # Match id: but not id_: (already fixed) + content = re.sub(r"\bid:\s*(?!_)", "id_: ", content) + + # Fix id in class attributes + # Match id: but not id_: in class definitions + content = re.sub(r"\bid:\s*(?!_)", "id_: ", content) + + # Fix id in return type hints + # Match -> id but not -> id_ + content = re.sub(r"->\s*id\b(?!_)", "-> id_", content) + + # Fix id in import statements (less common but possible) + # Match import id but not import id_ + content = re.sub(r"import\s+id\b(?!_)", "import id_", content) + content = re.sub( + r"from\s+\S+\s+import\s+.*\bid\b(?!_)", + lambda m: m.group(0).replace(" id", " id_"), + content, + ) + + # Fix id in constructor calls (e.g., id=id, -> id_=id_,) + content = re.sub(r"\bid\s*=\s*id\b(?!_)", "id_=id_", content) + + # Fix id in field_dict assignments (e.g., if id is not UNSET: -> if id_ is not UNSET:) + content = re.sub(r"\bid\s+is\s+not\s+UNSET(?!_)", "id_ is not UNSET", content) + content = re.sub(r"\bid\s+is\s+UNSET(?!_)", "id_ is UNSET", content) + + # Fix spacing issues that might have been created + content = re.sub(r"id_\s*=\s*self\.id\b(?!_)", "id_ = self.id_", content) + content = re.sub(r'id_\s*=\s*d\.pop\("id"', 'id_ = d.pop("id"', content) + content = re.sub(r"id_\s*=\s*id\b(?!_)", "id_=id_", content) + + # Fix id in docstrings (e.g., id (Unset | int): -> id_ (Unset | int):) + content = re.sub( + r"\bid\s+\(Unset\s*\|\s*int\):(?!_)", "id_ (Unset | int):", content + ) + content = re.sub( + r"\bid\s+\(Unset\s*\|\s*str\):(?!_)", "id_ (Unset | str):", content + ) + + # Fix trailing commas in import statements + # Pattern: import SomeClass, followed by newline or whitespace + content = re.sub( + r"import\s+([A-Za-z_][A-Za-z0-9_]*)\s*,\s*$", + r"import \1", + content, + flags=re.MULTILINE, + ) + + if content != original_content: + if write: + file_path.write_text(content, encoding="utf-8") + print(f"[fixed] {file_path}") + else: + print(f"[would fix] {file_path}") + return True + + return False + + +def main(): + ap = argparse.ArgumentParser( + description="Fix builtin shadowing issues in Python files." + ) + ap.add_argument("root", type=Path, help="Folder to process") + ap.add_argument( + "--write", action="store_true", help="Apply changes in-place (default: dry-run)" + ) + ap.add_argument( + "--include-glob", + default="**/*.py", + help="Glob of files to include (default: **/*.py)", + ) + ap.add_argument( + "--exclude", + action="append", + default=[".venv", "venv", "__pycache__", ".git", "site-packages"], + help="Directories to skip (repeatable)", + ) + args = ap.parse_args() + + root = args.root.resolve() + if not root.exists(): + print(f"Root not found: {root}", file=sys.stderr) + sys.exit(2) + + changed = 0 + for path in root.glob(args.include_glob): + if not path.is_file(): + continue + # Exclusions + p = path + skip = False + for ex in args.exclude: + if ex and ex in p.parts: + skip = True + break + if skip: + continue + if fix_builtin_shadowing_in_file(path, args.write): + changed += 1 + + if not args.write: + print(f"\nDry-run complete. Files to change: {changed}") + else: + print(f"Fixed files: {changed}") + + +if __name__ == "__main__": + main() diff --git a/integration-tests/integration_tests/api/parameters/post_parameters_header.py b/integration-tests/integration_tests/api/parameters/post_parameters_header.py index 0981585cc..a8fdf6928 100644 --- a/integration-tests/integration_tests/api/parameters/post_parameters_header.py +++ b/integration-tests/integration_tests/api/parameters/post_parameters_header.py @@ -5,7 +5,9 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.post_parameters_header_response_200 import PostParametersHeaderResponse200 +from ...models.post_parameters_header_response_200 import ( + PostParametersHeaderResponse200, +) from ...models.public_error import PublicError from ...types import Response diff --git a/integration-tests/integration_tests/client.py b/integration-tests/integration_tests/client.py index e80446f10..eeffd00c8 100644 --- a/integration-tests/integration_tests/client.py +++ b/integration-tests/integration_tests/client.py @@ -38,9 +38,15 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -168,9 +174,15 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -214,7 +226,9 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": def get_httpx_client(self) -> httpx.Client: """Get the underlying httpx.Client, constructing a new one if not previously set""" if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._client = httpx.Client( base_url=self._base_url, cookies=self._cookies, @@ -235,7 +249,9 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client( + self, async_client: httpx.AsyncClient + ) -> "AuthenticatedClient": """Manually the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -246,7 +262,9 @@ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Authentica def get_async_httpx_client(self) -> httpx.AsyncClient: """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._async_client = httpx.AsyncClient( base_url=self._base_url, cookies=self._cookies, diff --git a/integration-tests/integration_tests/models/post_body_multipart_body.py b/integration-tests/integration_tests/models/post_body_multipart_body.py index cb73d1d8b..de926263b 100644 --- a/integration-tests/integration_tests/models/post_body_multipart_body.py +++ b/integration-tests/integration_tests/models/post_body_multipart_body.py @@ -79,13 +79,26 @@ def to_multipart(self) -> types.RequestFiles: for files_item_element in self.files: files.append(("files", files_item_element.to_tuple())) - files.append(("description", (None, str(self.description).encode(), "text/plain"))) + files.append( + ("description", (None, str(self.description).encode(), "text/plain")) + ) for objects_item_element in self.objects: - files.append(("objects", (None, json.dumps(objects_item_element.to_dict()).encode(), "application/json"))) + files.append( + ( + "objects", + ( + None, + json.dumps(objects_item_element.to_dict()).encode(), + "application/json", + ), + ) + ) for times_item_element in self.times: - files.append(("times", (None, times_item_element.isoformat().encode(), "text/plain"))) + files.append( + ("times", (None, times_item_element.isoformat().encode(), "text/plain")) + ) for prop_name, prop in self.additional_properties.items(): files.append((prop_name, (None, str(prop).encode(), "text/plain"))) diff --git a/integration-tests/tests/test_api/test_body/test_post_body_multipart.py b/integration-tests/tests/test_api/test_body/test_post_body_multipart.py index 52ac5dd00..eafe93166 100644 --- a/integration-tests/tests/test_api/test_body/test_post_body_multipart.py +++ b/integration-tests/tests/test_api/test_body/test_post_body_multipart.py @@ -8,7 +8,9 @@ from integration_tests.client import Client from integration_tests.models import AnObject, PublicError from integration_tests.models.post_body_multipart_body import PostBodyMultipartBody -from integration_tests.models.post_body_multipart_response_200 import PostBodyMultipartResponse200 +from integration_tests.models.post_body_multipart_response_200 import ( + PostBodyMultipartResponse200, +) from integration_tests.types import File, Response body = PostBodyMultipartBody( @@ -40,10 +42,14 @@ ) -def check_response(response: Response[Union[PostBodyMultipartResponse200, PublicError]]) -> None: +def check_response( + response: Response[Union[PostBodyMultipartResponse200, PublicError]], +) -> None: content = response.parsed if not isinstance(content, PostBodyMultipartResponse200): - raise AssertionError(f"Received status {response.status_code} from test server with payload: {content!r}") + raise AssertionError( + f"Received status {response.status_code} from test server with payload: {content!r}" + ) assert content.a_string == body.a_string assert content.description == body.description @@ -79,7 +85,10 @@ def log_response(*_: Any, **__: Any) -> None: response_hook_called = True client = Client( - "http://localhost:3000", httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}} + "http://localhost:3000", + httpx_args={ + "event_hooks": {"request": [log_request], "response": [log_response]} + }, ) post_body_multipart.sync_detailed( diff --git a/integration-tests/tests/test_api/test_parameters/test_post_parameters_header.py b/integration-tests/tests/test_api/test_parameters/test_post_parameters_header.py index 2403ca417..93d2d4ce7 100644 --- a/integration-tests/tests/test_api/test_parameters/test_post_parameters_header.py +++ b/integration-tests/tests/test_api/test_parameters/test_post_parameters_header.py @@ -1,6 +1,8 @@ from integration_tests.api.parameters.post_parameters_header import sync_detailed from integration_tests.client import Client -from integration_tests.models.post_parameters_header_response_200 import PostParametersHeaderResponse200 +from integration_tests.models.post_parameters_header_response_200 import ( + PostParametersHeaderResponse200, +) def test(client: Client) -> None: diff --git a/openapi/README_internal.md b/openapi/README_internal.md new file mode 100644 index 000000000..8cf114abf --- /dev/null +++ b/openapi/README_internal.md @@ -0,0 +1,20 @@ +pip install openapi-python-client + +preprocess json or yaml in your + +To gen client +cd openAPI + +# still in your venv +python -m openapi_python_client generate ` + --overwrite ` + --config openapi\class_overrides.yaml ` + --custom-template-path openapi\templates ` + --path openapi\swagger_cleaned.json + +or +openapi-python-client generate --overwrite --path ./openapiv3.yaml + +Remove gitignore/pyproject +rm openapi_project\.gitignore +rm openapi_project\pyproject.toml diff --git a/openapi/class_overrides.yaml b/openapi/class_overrides.yaml new file mode 100644 index 000000000..d6b228e4a --- /dev/null +++ b/openapi/class_overrides.yaml @@ -0,0 +1,11 @@ +class_overrides: + Any: + class_name: AnyModel + module_name: any_model +project_name_override: openapi_project +package_name_override: openapi_package +field_prefix: attr_ +use_path_prefixes_for_title_model_names: false +post_hooks: + - "black ." + - "ruff check . --fix --unsafe-fixes" \ No newline at end of file diff --git a/openapi/openapi.cleaned.yaml b/openapi/openapi.cleaned.yaml new file mode 100644 index 000000000..603ec3e0c --- /dev/null +++ b/openapi/openapi.cleaned.yaml @@ -0,0 +1,7117 @@ +openapi: 3.1.0 + +info: + title: Theta Data v3 + description: Real-time and historic stock, options, and index data! + version: 3.0.0 + x-java-package: net.thetadata.generated + +servers: +- url: 'https://localhost:25503/v3' + description: dev + +security: [] + + +paths: +# +# STOCK ENDPOINTS +# + /stock/list/symbols: + x-min-subscription: free + get: + summary: Symbols + operationId: stock_list_symbols + tags: + - Stock + - List + description: | + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also include: root, ticker, and underlying. This endpoint returns all traded symbols for stocks. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/stock/list/symbols + description: "List all stock symbols" + parameters: + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all stock symbols + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + required: + - symbol + example: + symbol: + - A + - AA + - AAA + - AAAA + - AAAP + /stock/list/dates/{request_type}: + x-min-subscription: free + get: + summary: Dates + operationId: stock_list_dates + tags: + - Stock + - List + description: | + Lists all dates of data that are available for a stock with a given request type and symbol. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/stock/list/dates/quote?symbol=AAPL + description: "List all dates for a stock quote for a given symbol" + - url: http://localhost:25503/v3/stock/list/dates/trade?symbol=AAPL,SPY + description: "List all dates for a stock trade for multiple symbols" + - url: http://localhost:25503/v3/stock/list/dates/trade?symbol=* + description: "List all dates for a stock trade for all symbols" + parameters: + - $ref: "#/components/parameters/request_type" + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all dates for a stock quote for a given symbol + content: + application/json: + schema: + type: array + items: + type: object + properties: + date: + type: string + symbol: + type: string + required: + - date + - symbol + example: + date: + - '2016-08-19' + - '2016-08-18' + - '2016-08-17' + - '2016-08-16' + - '2016-08-23' + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + /stock/snapshot/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: stock_snapshot_ohlc + tags: + - Stock + - Snapshot + description: |2 + + Provides a real-time Open, High, Low, Close for the current day. + * Returns a real-time session OHLC from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed session OHLC from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs) if the account has the stocks value subscription. + * ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a weekend where there were no eligible messages sent over exchange feeds. We recommend using historic requests during the weekend. + x-sample-urls: + - url: http://localhost:25503/v3/stock/snapshot/ohlc?symbol=* + description: "Returns OHLC for stocks for all symbols" + - url: http://localhost:25503/v3/stock/snapshot/ohlc?symbol=AAPL&venue=nqb + description: "Returns OHLC for a given stock trade from the Nasdaq Basic feed" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for stocks for all symbols + content: + application/json: + schema: + type: array + items: + type: object + properties: + volume: + type: integer + symbol: + type: string + high: + type: number + low: + type: number + count: + type: integer + close: + type: number + open: + type: number + timestamp: + type: string + required: + - volume + - symbol + - high + - low + - count + - close + - open + - timestamp + example: + volume: + - 119656 + - 57048 + - 9 + - 3648 + - 992620 + symbol: + - CVCO + - IFRX + - KLXY + - HCOW + - SCS + high: + - 492.0 + - 0.9199 + - 0.0 + - 23.6976 + - 16.32 + low: + - 480.5477 + - 0.8529 + - 0.0 + - 23.56 + - 16.155 + count: + - 7684 + - 138 + - 6 + - 44 + - 7690 + close: + - 485.11 + - 0.8929 + - 0.0 + - 23.6616 + - 16.18 + open: + - 492.0 + - 0.89 + - 0.0 + - 23.56 + - 16.2 + timestamp: + - '2025-08-20T16:10:04.43' + - '2025-08-20T16:11:13.962' + - '2025-08-20T16:04:10.564' + - '2025-08-20T16:04:07.554' + - '2025-08-20T16:22:32.726' + /stock/snapshot/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: stock_snapshot_trade + tags: + - Stock + - Snapshot + description: |2 + + Returns a real-time last trade from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a weekend where there were no eligible messages sent over exchange feeds. We recommend using historic requests during the weekend. + x-sample-urls: + - url: http://localhost:25503/v3/stock/snapshot/trade?symbol=AAPL + description: "Returns last trade for stocks for a given symbol" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last trade for stocks for a given symbol + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + timestamp: + type: string + required: + - symbol + - sequence + - condition + - size + - price + - timestamp + example: + symbol: + - AAPL + sequence: + - 63539137 + condition: + - 1 + size: + - 23 + price: + - 225.75 + timestamp: + - '2025-08-20T16:36:05.549' + /stock/snapshot/quote: + x-min-subscription: value + get: + summary: Quote + operationId: stock_snapshot_quote + tags: + - Stock + - Snapshot + description: | + * Returns a real-time last BBO quote from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed NBBO quote from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a weekend where there were no eligible messages sent over exchange feeds. We recommend using historic requests during the weekend. + x-sample-urls: + - url: http://localhost:25503/v3/stock/snapshot/quote?symbol=* + description: "Returns last quote for stocks for all symbols" + - url: + http://localhost:25503/v3/stock/snapshot/quote?symbol=AAPL&venue=nqb + description: "Returns OHLC for a given stock trade from the Nasdaq Basic feed" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last quote for stocks for all symbols + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + bid_size: + type: integer + ask_exchange: + type: integer + ask_condition: + type: integer + bid_exchange: + type: integer + ask: + type: number + bid: + type: number + bid_condition: + type: integer + timestamp: + type: string + required: + - symbol + - ask_size + - bid_size + - ask_exchange + - ask_condition + - bid_exchange + - ask + - bid + - bid_condition + - timestamp + example: + symbol: + - CVCO + - KLXY + - IFRX + - SCS + - BBC + ask_size: + - 3 + - 200 + - 45 + - 100 + - 2800 + bid_size: + - 1 + - 200 + - 100 + - 100 + - 100 + ask_exchange: + - 29 + - 29 + - 29 + - 29 + - 29 + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + bid_exchange: + - 29 + - 29 + - 29 + - 29 + - 29 + ask: + - 494.33 + - 37.18 + - 0.95 + - 17.6 + - 24.06 + bid: + - 475.75 + - 12.4 + - 0.751 + - 14.64 + - 13.29 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + timestamp: + - '2025-08-20T16:03:05.142' + - '2025-08-20T16:10:05.032' + - '2025-08-20T16:21:05.781' + - '2025-08-20T16:19:55.101' + - '2025-08-20T16:33:50.877' + /stock/history/eod: + x-min-subscription: free + get: + summary: End of Day + operationId: stock_history_eod + tags: + - Stock + - History + description: |2 + + Since [the equity SIPs](/Articles/Data-And-Requests/The-SIPs.html) only generate a partial EOD report, Theta Data generates a national EOD report at 17:15 ET each day. ``created`` represents the datetime the report was generated and ``last_trade`` represents the datetime of the last trade. The quote in the response represents the last NBBO reported by [CTA or UTP](/Articles/Data-And-Requests/The-SIPs.html) at the time of report generation. You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). Theta Data plans to avail SIP EOD reports in the near future. + x-sample-urls: + - url: + http://localhost:25503/v3/stock/history/eod?symbol=AAPL&start_date=20240101&end_date=20240131 + description: "Returns EOD report for a given symbol between specified dates + (inclusive)" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for a given symbol between specified + dates (inclusive) + content: + application/json: + schema: + type: array + items: + type: object + properties: + ask_size: + type: integer + last_trade: + type: string + created: + type: string + ask_condition: + type: integer + count: + type: integer + volume: + type: integer + high: + type: number + low: + type: number + bid_size: + type: integer + ask_exchange: + type: integer + bid_exchange: + type: integer + ask: + type: number + bid: + type: number + bid_condition: + type: integer + close: + type: number + open: + type: number + required: + - ask_size + - last_trade + - created + - ask_condition + - count + - volume + - high + - low + - bid_size + - ask_exchange + - bid_exchange + - ask + - bid + - bid_condition + - close + - open + example: + ask_size: + - 2 + - 2 + - 2 + - 3 + - 1 + last_trade: + - '2024-01-02T17:17:51.877' + - '2024-01-03T17:16:28.586' + - '2024-01-04T17:17:02.445' + - '2024-01-05T17:16:49.821' + - '2024-01-08T17:17:01.484' + created: + - '2024-01-02T17:17:53.606' + - '2024-01-03T17:16:29.883' + - '2024-01-04T17:17:06.02' + - '2024-01-05T17:16:57.032' + - '2024-01-08T17:17:01.83' + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + count: + - 1003582 + - 654127 + - 709246 + - 679405 + - 665626 + volume: + - 80680243 + - 58308345 + - 71197269 + - 61949135 + - 59029146 + high: + - 188.44 + - 185.88 + - 183.0872 + - 182.76 + - 185.6 + low: + - 183.885 + - 183.43 + - 180.88 + - 180.17 + - 181.5 + bid_size: + - 2 + - 5 + - 8 + - 3 + - 4 + ask_exchange: + - 1 + - 1 + - 7 + - 7 + - 65 + bid_exchange: + - 7 + - 7 + - 60 + - 1 + - 1 + ask: + - 18.536 + - 18.41 + - 1.8179 + - 18.105 + - 18.537 + bid: + - 18.534 + - 18.405 + - 1.8176 + - 18.103 + - 18.528 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + close: + - 185.64 + - 184.25 + - 181.91 + - 181.18 + - 185.56 + open: + - 187.03 + - 184.2 + - 182.0 + - 181.9 + - 182.0 + /stock/history/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: stock_history_ohlc + tags: + - Stock + - History + description: | + Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: ``bar time`` <= ``trade time`` < ``bar timestamp + ivl``, where ivl is the specified interval size in milliseconds. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: + http://localhost:25503/v3/stock/history/ohlc?symbol=AAPL&date=20240102&interval=1m + description: "Returns OHLC for a given symbol between specified dates (inclusive) + with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given symbol between specified dates + (inclusive) with a one minute interval + content: + application/json: + schema: + type: array + items: + type: object + properties: + volume: + type: integer + high: + type: number + low: + type: number + vwap: + type: number + count: + type: integer + close: + type: number + open: + type: number + timestamp: + type: string + required: + - volume + - high + - low + - vwap + - count + - close + - open + - timestamp + example: + volume: + - 3256708 + - 809707 + - 687086 + - 485275 + - 415948 + high: + - 188.05 + - 188.12 + - 188.44 + - 188.31 + - 188.15 + low: + - 186.35 + - 187.63 + - 187.73 + - 187.81 + - 187.67 + vwap: + - 187.25 + - 187.38 + - 187.48 + - 187.53 + - 187.55 + count: + - 37886 + - 7481 + - 7103 + - 6245 + - 5942 + close: + - 187.83 + - 187.765 + - 188.2984 + - 188.16 + - 187.73 + open: + - 187.15 + - 187.83 + - 187.77 + - 188.305 + - 188.15 + timestamp: + - '2024-01-02T09:30:00' + - '2024-01-02T09:31:00' + - '2024-01-02T09:32:00' + - '2024-01-02T09:33:00' + - '2024-01-02T09:34:00' + /stock/history/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: stock_history_trade + tags: + - Stock + - History + description: | + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs). Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: + http://localhost:25503/v3/stock/history/trade?symbol=AAPL&date=20240102 + description: "Returns every trade for a given symbol between specified dates + (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade for a given symbol between specified + dates (inclusive) with a one minute interval + content: {} + /stock/history/quote: + x-min-subscription: value + get: + summary: Quote + operationId: stock_history_quote + tags: + - Stock + - History + description: | + Returns every NBBO quote reported by [UTP and CTA](/Articles/Data-And-Requests/The-SIPs). If the ``interval`` parameter is specified, the quote for each interval represents the last quote prior to the interval's timestamp. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: + http://localhost:25503/v3/stock/history/quote?symbol=AAPL&date=20240102&interval=1m + description: "Returns every quote for a given symbol between specified dates + (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every quote for a given symbol between specified + dates (inclusive) with a one minute interval + content: + application/json: + schema: + type: array + items: + type: object + properties: + ask_size: + type: integer + bid_size: + type: integer + ask_exchange: + type: integer + ask_condition: + type: integer + bid_exchange: + type: integer + ask: + type: number + bid: + type: number + bid_condition: + type: integer + timestamp: + type: string + required: + - ask_size + - bid_size + - ask_exchange + - ask_condition + - bid_exchange + - ask + - bid + - bid_condition + - timestamp + example: + ask_size: + - 1 + - 4 + - 1 + - 2 + - 2 + bid_size: + - 30 + - 2 + - 2 + - 2 + - 5 + ask_exchange: + - 1 + - 1 + - 73 + - 73 + - 7 + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + bid_exchange: + - 7 + - 1 + - 60 + - 60 + - 1 + ask: + - 187.2 + - 187.86 + - 187.77 + - 188.32 + - 188.16 + bid: + - 187.1 + - 187.83 + - 187.74 + - 188.29 + - 188.14 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + timestamp: + - '2024-01-02T09:30:00' + - '2024-01-02T09:31:00' + - '2024-01-02T09:32:00' + - '2024-01-02T09:33:00' + - '2024-01-02T09:34:00' + /stock/history/trade_quote: + x-min-subscription: standard + get: + summary: Trade Quote + operationId: stock_history_trade_quote + tags: + - Stock + - History + description: | + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs) paired with the last BBO quote reported by [UTP or CTA](/Articles/Data-And-Requests/The-SIPs) at the time of trade. A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. If you prefer to match quotes with timestamps that are ``<`` the trade timestamp, specify the ``exclusive`` parameter to ``true``. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: + http://localhost:25503/v3/stock/history/trade_quote?symbol=AAPL&date=20240102 + description: "Returns every trade quote for a given symbol between specified + dates (inclusive)" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/exclusive" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade quote for a given symbol between + specified dates (inclusive) + content: {} + /stock/at_time/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: stock_at_time_trade + tags: + - Stock + - At-Time + description: | + #### Real-time request: + - Returns a real-time session from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + - Returns a 15-minute delayed session from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last trade reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) at a specified millisecond of the day. + Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + x-sample-urls: + - url: + http://localhost:25503/v3/stock/at_time/trade?symbol=SPY&start_date=20240116&end_date=20240116&time_of_day=09:30:00.100 + description: "Returns the last trade for a given symbol and specified time + of day" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last trade for a given symbol and specified + time of day + content: + application/json: + schema: + type: array + items: + type: object + properties: + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + timestamp: + type: string + required: + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - ext_condition4 + - exchange + - ext_condition3 + - timestamp + example: + sequence: + - 405549 + condition: + - 115 + size: + - 1 + price: + - 475.28 + ext_condition2: + - 255 + ext_condition1: + - 255 + ext_condition4: + - 115 + exchange: + - 57 + ext_condition3: + - 255 + timestamp: + - '2024-01-16T09:30:00.088' + /stock/at_time/quote: + x-min-subscription: value + get: + summary: Quote + operationId: stock_at_time_quote + tags: + - Stock + - At-Time + description: | + #### Real-time request: + - Subscription tier standard or higher will default to NQB. + - Real-time last BBO quote at-time_of_day-time from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + - 15-minute delayed NBBO quote at-time_of_day-time from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last NBBO quote reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) at a specified millisecond of the day. + x-sample-urls: + - url: + http://localhost:25503/v3/stock/at_time/quote?symbol=SPY&start_date=20240116&end_date=20240116&time_of_day=09:30:00.100 + description: "Returns the last quote for a given symbol between specified + dates (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last quote for a given symbol between + specified dates (inclusive) with a one minute interval + content: + application/json: + schema: + type: array + items: + type: object + properties: + ask_size: + type: integer + bid_size: + type: integer + ask_exchange: + type: integer + ask_condition: + type: integer + bid_exchange: + type: integer + ask: + type: number + bid: + type: number + bid_condition: + type: integer + timestamp: + type: string + required: + - ask_size + - bid_size + - ask_exchange + - ask_condition + - bid_exchange + - ask + - bid + - bid_condition + - timestamp + example: + ask_size: + - 8 + bid_size: + - 15 + ask_exchange: + - 7 + ask_condition: + - 0 + bid_exchange: + - 1 + ask: + - 475.28 + bid: + - 475.28 + bid_condition: + - 0 + timestamp: + - '2024-01-16T09:30:00.1' + /option/list/symbols: + x-min-subscription: free + get: + summary: Symbols + operationId: option_list_symbols + tags: + - Option + - List + description: | + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/symbols + description: "List all symbols for options" + parameters: + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all symbols for options + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + required: + - symbol + example: + symbol: + - A + - AA + - AAAP + - AAAU + - AABA + /option/list/dates/{request_type}: + x-min-subscription: free + get: + summary: Dates + operationId: option_list_dates + tags: + - Option + - List + description: | + Lists all dates of data that are available for an option with a given symbol, request type, and expiration. + This endpoint is updated overnight. + x-sample-urls: + - url: + http://localhost:25503/v3/option/list/dates/quote?symbol=AAPL&expiration=20220930 + description: "List all dates for an option quote for a given symbol and expiration + date" + - url: + http://localhost:25503/v3/option/list/dates/trade?symbol=AAPL&expiration=20220930 + description: "List all dates for an option trade for a given symbol with any + expiration date" + parameters: + - $ref: "#/components/parameters/request_type" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all dates for an option quote for a given symbol and + expiration date + content: + application/json: + schema: + type: array + items: + type: object + properties: + date: + type: string + symbol: + type: string + strike: + type: number + expiration: + type: string + right: + type: string + required: + - date + - symbol + - strike + - expiration + - right + example: + date: + - '2022-09-16' + - '2022-09-19' + - '2022-09-12' + - '2022-09-13' + - '2022-09-14' + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + strike: + - 80.0 + - 80.0 + - 80.0 + - 80.0 + - 80.0 + expiration: + - '2022-09-30' + - '2022-09-30' + - '2022-09-30' + - '2022-09-30' + - '2022-09-30' + right: + - CALL + - CALL + - CALL + - CALL + - CALL + /option/list/expirations: + x-min-subscription: free + get: + summary: Expirations + operationId: option_list_expirations + tags: + - Option + - List + description: | + Lists all dates of expirations that are available for an option with a given symbol. + This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/expirations?symbol=AAPL + description: "List all expirations for an option with a given symbol" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all expirations for an option with a given symbol + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + expiration: + type: string + required: + - symbol + - expiration + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + expiration: + - '2012-06-01' + - '2012-06-08' + - '2012-06-16' + - '2012-06-22' + - '2012-06-29' + /option/list/strikes: + x-min-subscription: free + get: + summary: Strikes + operationId: option_list_strikes + tags: + - Option + - List + description: | + Lists all strikes that are available for an option with a given symbol and expiration date. + This endpoint is updated overnight. + x-sample-urls: + - url: + http://localhost:25503/v3/option/list/strikes?symbol=AAPL&expiration=20220930 + description: "List all strikes for an option with a given symbol and expiration + date" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all strikes for an option with a given symbol and + expiration date + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + required: + - symbol + - strike + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + strike: + - 80.0 + - 128.0 + - 160.0 + - 144.0 + - 240.0 + /option/list/contracts/{request_type}: + x-min-subscription: value + get: + summary: Contracts + operationId: option_list_contracts + tags: + - Option + - List + description: | + Lists all contracts that were traded or quoted on a particular date. + + If the ``symbol`` parameter is specified, the returned contracts will be filtered to match the symbol. + Multiple symbols can be specified by separating them with commas such as ``symbol=AAPL,SPY,AMD`` + This endpoint is updated real-time. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/contracts/trade?date=20220930 + description: "List all contracts for an option trade with a given date" + - url: + http://localhost:25503/v3/option/list/contracts/quote?symbol=AAPL&date=20220930 + description: "List all contracts for an option quote with a given symbol and + date" + parameters: + - $ref: "#/components/parameters/request_type" + - $ref: "#/components/parameters/opt_multi_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all contracts for an option trade with a given date + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + expiration: + type: string + right: + type: string + required: + - symbol + - strike + - expiration + - right + example: + symbol: + - ABNB + - AAPL + - AAL + - ABNB + - AAPL + strike: + - 260.0 + - 260.0 + - 14.5 + - 80.0 + - 80.0 + expiration: + - '2023-06-16' + - '2023-06-16' + - '2022-09-30' + - '2022-11-04' + - '2022-11-04' + right: + - CALL + - CALL + - CALL + - PUT + - PUT + /option/snapshot/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: option_snapshot_ohlc + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last ohlc of an option contract for the trading day. + - You might need to change the default expiration date to a different date if it is past the current date. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/ohlc?symbol=AAPL&expiration=20260116&right=call&strike=275.000 + description: "Returns OHLC for a given option contract" + - url: + http://localhost:25503/v3/option/snapshot/ohlc?symbol=AAPL&expiration=* + description: "Returns OHLC for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + volume: + type: integer + symbol: + type: string + high: + type: number + low: + type: number + strike: + type: number + count: + type: integer + expiration: + type: string + right: + type: string + close: + type: number + open: + type: number + timestamp: + type: string + required: + - volume + - symbol + - high + - low + - strike + - count + - expiration + - right + - close + - open + - timestamp + example: + volume: + - 202 + symbol: + - AAPL + high: + - 1.78 + low: + - 1.51 + strike: + - 275.0 + count: + - 29 + expiration: + - '2026-01-16' + right: + - CALL + close: + - 1.51 + open: + - 1.78 + timestamp: + - '2025-08-20T15:25:31.03' + /option/snapshot/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: option_snapshot_trade + tags: + - Option + - Snapshot + description: | + - Retrieve the real-time last trade of an option contract. + - You might need to change the default expiration date to a different date if it is past the current date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/trade?symbol=AAPL&expiration=2026-01-16&right=call&strike=275.000 + description: "Returns last trade for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/trade?symbol=AAPL&expiration=2026-01-16 + description: "Returns last trade for all option contracts with an expiration + of 2026-01-16" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last NBBO quote for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + right: + type: string + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + timestamp: + type: string + required: + - symbol + - strike + - right + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - timestamp + example: + symbol: + - AAPL + strike: + - 220.0 + right: + - CALL + sequence: + - 18902138 + condition: + - 130 + size: + - 2 + price: + - 3.9 + ext_condition2: + - 255 + ext_condition1: + - 255 + expiration: + - '2024-11-08' + ext_condition4: + - 255 + exchange: + - 22 + ext_condition3: + - 255 + timestamp: + - '2024-11-04T09:30:00.471' + /option/snapshot/quote: + x-min-subscription: value + get: + summary: Quote + operationId: option_snapshot_quote + tags: + - Option + - Snapshot + description: |2 + + - Retrieve a real-time last NBBO quote of an option contract. + - You might need to change the default expiration date to a different date if it is past the current date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/quote?symbol=AAPL&expiration=20260116&right=call&strike=275.000 + description: "Returns last NBBO quote for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/quote?symbol=AAPL&expiration=* + description: "Returns last NBBO quote for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last NBBO quote for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + ask_condition: + type: integer + strike: + type: number + right: + type: string + bid_size: + type: integer + ask_exchange: + type: integer + bid_exchange: + type: integer + ask: + type: number + expiration: + type: string + bid: + type: number + bid_condition: + type: integer + timestamp: + type: string + required: + - symbol + - ask_size + - ask_condition + - strike + - right + - bid_size + - ask_exchange + - bid_exchange + - ask + - expiration + - bid + - bid_condition + - timestamp + example: + symbol: + - AAPL + ask_size: + - 25 + ask_condition: + - 50 + strike: + - 275.0 + right: + - CALL + bid_size: + - 5 + ask_exchange: + - 6 + bid_exchange: + - 6 + ask: + - 1.5 + expiration: + - '2026-01-16' + bid: + - 1.47 + bid_condition: + - 50 + timestamp: + - '2025-08-20T15:59:59.805' + /option/snapshot/open_interest: + x-min-subscription: value + get: + summary: Open Interest + operationId: option_snapshot_open_interest + tags: + - Option + - Snapshot + description: | + - Retrieve the last open interest message of an option contract. + - Open interest is reported around 06:30 ET every morning by OPRA and reflects the open interest at the of the previous trading day. + - You might need to change the default expiration date to a different date if it is past the current date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/open_interest?symbol=AAPL&expiration=20260116&right=call&strike=275.00 + description: "Returns open interest for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/open_interest?symbol=AAPL&expiration=* + description: "Returns open interest for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns open interest for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + open_interest: + type: integer + expiration: + type: string + right: + type: string + timestamp: + type: string + required: + - symbol + - strike + - open_interest + - expiration + - right + - timestamp + example: + symbol: + - AAPL + strike: + - 275.0 + open_interest: + - 8066 + expiration: + - '2026-01-16' + right: + - CALL + timestamp: + - '2025-08-20T06:30:13' + /option/snapshot/greeks/implied_volatility: + x-min-subscription: standard + get: + summary: Implied Volatility + operationId: option_snapshot_greeks_implied_volatility + tags: + - Option + - Snapshot + description: | + Returns implied volatilies calculated using the national best bid, mid, and ask price + of the option respectively. The underlying price represents whatever the last underlying price was at the + ``underlying_timestamp`` field. You can read more about how Thetadata calculates greeks + [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/greeks/implied_volatility?symbol=AAPL&expiration=20260116&strike=275.000&right=call + description: "Returns implied volatility for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/greeks/implied_volatility?symbol=AAPL&expiration=* + description: "Returns implied volatility for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns implied volatility for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + ask: + type: number + expiration: + type: string + right: + type: string + implied_vol: + type: number + bid: + type: number + underlying_timestamp: + type: string + iv_error: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - ask + - expiration + - right + - implied_vol + - bid + - underlying_timestamp + - iv_error + - timestamp + example: + symbol: + - AAPL + underlying_price: + - 225.74 + strike: + - 275.0 + ask: + - 1.5 + expiration: + - '2026-01-16' + right: + - CALL + implied_vol: + - 0.2142 + bid: + - 1.47 + underlying_timestamp: + - '2025-08-20T16:36:52.257' + iv_error: + - -0.0003 + timestamp: + - '2025-08-20T15:59:59.805' + /option/snapshot/greeks/all: + x-min-subscription: professional + get: + summary: All Greeks + operationId: option_snapshot_greeks_all + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/greeks/all?symbol=AAPL&expiration=2026-05-15&strike=170.00&right=call + description: "Returns all greeks for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/greeks/all?symbol=AAPL&expiration=* + description: "Returns all greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns all greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + dual_delta: + type: number + color: + type: number + zomma: + type: number + delta: + type: number + implied_vol: + type: number + theta: + type: number + d1: + type: number + speed: + type: number + d2: + type: number + epsilon: + type: number + lambda: + type: number + vomma: + type: number + underlying_timestamp: + type: string + timestamp: + type: string + underlying_price: + type: number + strike: + type: number + vera: + type: number + right: + type: string + veta: + type: number + iv_error: + type: number + ultima: + type: number + charm: + type: number + ask: + type: number + rho: + type: number + expiration: + type: string + vanna: + type: number + dual_gamma: + type: number + bid: + type: number + vega: + type: number + gamma: + type: number + required: + - symbol + - dual_delta + - color + - zomma + - delta + - implied_vol + - theta + - d1 + - speed + - d2 + - epsilon + - lambda + - vomma + - underlying_timestamp + - timestamp + - underlying_price + - strike + - vera + - right + - veta + - iv_error + - ultima + - charm + - ask + - rho + - expiration + - vanna + - dual_gamma + - bid + - vega + - gamma + example: + symbol: + - AAPL + dual_delta: + - -0.8302 + color: + - -0.0816 + zomma: + - 0.0 + delta: + - 0.9085 + implied_vol: + - 0.3075 + theta: + - -0.0352 + d1: + - 1.3319 + speed: + - 0.0 + d2: + - 1.0689 + epsilon: + - -150.0314 + lambda: + - 3.2071 + vomma: + - 146.8562 + underlying_timestamp: + - '2025-08-20T16:36:52.257' + timestamp: + - '2025-08-20T15:59:59.677' + underlying_price: + - 225.74 + strike: + - 170.0 + vera: + - 0.0 + right: + - CALL + veta: + - 22.9525 + iv_error: + - 0.0 + ultima: + - -100.0 + charm: + - 0.0925 + ask: + - 64.25 + rho: + - 103.2513 + expiration: + - '2026-05-15' + vanna: + - -0.571 + dual_gamma: + - 0.0003 + bid: + - 63.65 + vega: + - 31.7235 + gamma: + - 0.0027 + /option/snapshot/greeks/first_order: + x-min-subscription: standard + get: + summary: First Order Greeks + operationId: option_snapshot_greeks_first_order + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/greeks/first_order?symbol=AAPL&expiration=20260116&strike=275.000&right=call + description: "Returns first order greeks for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/greeks/first_order?symbol=AAPL&expiration=* + description: "Returns first order greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns first order greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + delta: + type: number + right: + type: string + implied_vol: + type: number + theta: + type: number + iv_error: + type: number + epsilon: + type: number + lambda: + type: number + ask: + type: number + rho: + type: number + expiration: + type: string + bid: + type: number + underlying_timestamp: + type: string + vega: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - delta + - right + - implied_vol + - theta + - iv_error + - epsilon + - lambda + - ask + - rho + - expiration + - bid + - underlying_timestamp + - vega + - timestamp + example: + symbol: + - AAPL + underlying_price: + - 225.74 + strike: + - 275.0 + delta: + - 0.106 + right: + - CALL + implied_vol: + - 0.2142 + theta: + - -0.0217 + iv_error: + - -0.0003 + epsilon: + - -9.7049 + lambda: + - 16.1782 + ask: + - 1.5 + rho: + - 9.105 + expiration: + - '2026-01-16' + bid: + - 1.47 + underlying_timestamp: + - '2025-08-20T16:37:06.988' + vega: + - 26.3226 + timestamp: + - '2025-08-20T15:59:59.805' + /option/snapshot/greeks/second_order: + x-min-subscription: professional + get: + summary: Second Order Greeks + operationId: option_snapshot_greeks_second_order + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last second order greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/greeks/second_order?symbol=AAPL&expiration=20260116&strike=275.00 + description: "Returns second order greeks for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/greeks/second_order?symbol=AAPL&expiration=* + description: "Returns second order greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns second order greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + right: + type: string + veta: + type: number + implied_vol: + type: number + iv_error: + type: number + charm: + type: number + ask: + type: number + expiration: + type: string + vanna: + type: number + vomma: + type: number + bid: + type: number + underlying_timestamp: + type: string + gamma: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - right + - veta + - implied_vol + - iv_error + - charm + - ask + - expiration + - vanna + - vomma + - bid + - underlying_timestamp + - gamma + - timestamp + example: + symbol: + - AAPL + - AAPL + underlying_price: + - 225.74 + - 225.74 + strike: + - 275.0 + - 275.0 + right: + - CALL + - PUT + veta: + - 18.8522 + - 18.2234 + implied_vol: + - 0.2142 + - 0.3106 + iv_error: + - -0.0003 + - 0.0 + charm: + - -0.3716 + - -0.421 + ask: + - 1.5 + - 49.7 + expiration: + - '2026-01-16' + - '2026-01-16' + vanna: + - 1.1833 + - 0.932 + vomma: + - 212.267 + - 108.3415 + bid: + - 1.47 + - 48.75 + underlying_timestamp: + - '2025-08-20T16:37:06.988' + - '2025-08-20T16:37:06.988' + gamma: + - 0.0059 + - 0.0064 + timestamp: + - '2025-08-20T15:59:59.805' + - '2025-08-20T15:59:59.839' + /option/snapshot/greeks/third_order: + x-min-subscription: professional + get: + summary: Third Order Greeks + operationId: option_snapshot_greeks_third_order + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last third order greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: + http://localhost:25503/v3/option/snapshot/greeks/third_order?symbol=AAPL&expiration=20260116&strike=275.00 + description: "Returns third order greeks for an option contract" + - url: + http://localhost:25503/v3/option/snapshot/greeks/third_order?symbol=AAPL&expiration=* + description: "Returns third order greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns third order greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + color: + type: number + strike: + type: number + zomma: + type: number + right: + type: string + implied_vol: + type: number + iv_error: + type: number + speed: + type: number + ultima: + type: number + ask: + type: number + expiration: + type: string + bid: + type: number + underlying_timestamp: + type: string + timestamp: + type: string + required: + - symbol + - underlying_price + - color + - strike + - zomma + - right + - implied_vol + - iv_error + - speed + - ultima + - ask + - expiration + - bid + - underlying_timestamp + - timestamp + example: + symbol: + - AAPL + - AAPL + underlying_price: + - 225.74 + - 225.74 + color: + - -0.3832 + - -1.8378 + strike: + - 275.0 + - 275.0 + zomma: + - 0.0 + - 0.0 + right: + - CALL + - PUT + implied_vol: + - 0.2142 + - 0.3106 + iv_error: + - -0.0003 + - 0.0 + speed: + - 0.0 + - 0.0 + ultima: + - -100.0 + - -100.0 + ask: + - 1.5 + - 49.7 + expiration: + - '2026-01-16' + - '2026-01-16' + bid: + - 1.47 + - 48.75 + underlying_timestamp: + - '2025-08-20T16:37:06.988' + - '2025-08-20T16:37:06.988' + timestamp: + - '2025-08-20T15:59:59.805' + - '2025-08-20T15:59:59.839' + /option/history/eod: + x-min-subscription: free + get: + summary: End of Day + operationId: option_history_eod + tags: + - Option + - History + description: | + - Since [OPRA](/Articles/Data-And-Requests/The-SIPs.html) does not provide a national EOD report for options, Thetadata generates a national EOD report at 17:15 ET each day. + - ``created`` represents the datetime the report was generated and ``last_trade`` represents the datetime of the last trade. + - The quote in the response represents the last NBBO reported by OPRA at the time of report generation. + - You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We will expose further history for the EOD quote in the near future. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/eod?symbol=AAPL&expiration=20241115&strike=170.000&right=call&start_date=20241104&end_date=20241104 + description: "Returns EOD report for an option contract" + - url: + http://localhost:25503/v3/option/history/eod?symbol=AAPL&expiration=*&start_date=20241104&end_date=20241104 + description: "Returns EOD report for all option contracts" + parameters: + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + last_trade: + type: string + created: + type: string + ask_condition: + type: integer + strike: + type: number + count: + type: integer + right: + type: string + volume: + type: integer + high: + type: number + low: + type: number + bid_size: + type: integer + ask_exchange: + type: integer + bid_exchange: + type: integer + ask: + type: number + expiration: + type: string + bid: + type: number + bid_condition: + type: integer + close: + type: number + open: + type: number + required: + - symbol + - ask_size + - last_trade + - created + - ask_condition + - strike + - count + - right + - volume + - high + - low + - bid_size + - ask_exchange + - bid_exchange + - ask + - expiration + - bid + - bid_condition + - close + - open + example: + symbol: + - AAPL + ask_size: + - 15 + last_trade: + - '2024-11-04T15:48:12.005' + created: + - '2024-11-04T17:16:56.205' + ask_condition: + - 50 + strike: + - 170.0 + count: + - 3 + right: + - CALL + volume: + - 10 + high: + - 52.75 + low: + - 52.4 + bid_size: + - 70 + ask_exchange: + - 47 + bid_exchange: + - 60 + ask: + - 52.45 + expiration: + - '2024-11-15' + bid: + - 52.05 + bid_condition: + - 50 + close: + - 52.4 + open: + - 52.54 + /option/history/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: option_history_ohlc + tags: + - Option + - History + description: | + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/ohlc?symbol=AAPL&expiration=20231103&strike=170.000&right=call&date=20231103&interval=1m + description: "Returns OHLC for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + volume: + type: integer + symbol: + type: string + high: + type: number + low: + type: number + strike: + type: number + vwap: + type: number + count: + type: integer + expiration: + type: string + right: + type: string + close: + type: number + open: + type: number + timestamp: + type: string + required: + - volume + - symbol + - high + - low + - strike + - vwap + - count + - expiration + - right + - close + - open + - timestamp + example: + volume: + - 147 + - 39 + - 45 + - 142 + - 29 + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + high: + - 7.05 + - 4.65 + - 5.2 + - 5.05 + - 5.05 + low: + - 3.6 + - 3.65 + - 4.65 + - 4.48 + - 4.5 + strike: + - 170.0 + - 170.0 + - 170.0 + - 170.0 + - 170.0 + vwap: + - 4.39 + - 4.31 + - 4.45 + - 4.53 + - 4.56 + count: + - 24 + - 19 + - 14 + - 23 + - 11 + expiration: + - '2023-11-03' + - '2023-11-03' + - '2023-11-03' + - '2023-11-03' + - '2023-11-03' + right: + - CALL + - CALL + - CALL + - CALL + - CALL + close: + - 4.0 + - 4.65 + - 5.0 + - 4.49 + - 4.73 + open: + - 4.48 + - 3.85 + - 4.75 + - 4.95 + - 4.5 + timestamp: + - '2023-11-03T09:30:00' + - '2023-11-03T09:31:00' + - '2023-11-03T09:32:00' + - '2023-11-03T09:33:00' + - '2023-11-03T09:34:00' + /option/history/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: option_history_trade + tags: + - Option + - History + description: | + - Returns every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) for options, so they can be ignored. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns every trade for an option contract" + - url: + http://localhost:25503/v3/option/history/trade?symbol=AAPL&expiration=*&date=20241104 + description: "Returns every trade for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + # - $ref: "#/components/parameters/interval" # NOT CURRENTLY SUPPORTED IN v2 + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + right: + type: string + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + timestamp: + type: string + required: + - symbol + - strike + - right + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + sequence: + - 18902138 + - 19368856 + - 19403970 + - 19598457 + - 19598464 + condition: + - 130 + - 130 + - 130 + - 18 + - 18 + size: + - 2 + - 1 + - 1 + - 1 + - 1 + price: + - 3.9 + - 4.25 + - 4.22 + - 4.15 + - 4.15 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 22 + - 6 + - 6 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + timestamp: + - '2024-11-04T09:30:00.471' + - '2024-11-04T09:30:01.626' + - '2024-11-04T09:30:01.698' + - '2024-11-04T09:30:02.064' + - '2024-11-04T09:30:02.064' + /option/history/quote: + x-min-subscription: value + get: + summary: Quote + operationId: option_history_quote + tags: + - Option + - History + description: | + - Returns every NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - If the ``interval`` parameter is specified, the quote for each interval represents the last quote at the interval's timestamp. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/quote?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104&interval=1m + description: "Returns every quote for an option contract" + - url: + http://localhost:25503/v3/option/history/quote?symbol=AAPL&expiration=*&date=20241104&interval=1m + description: "Returns every quote for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every quote for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + ask_condition: + type: integer + strike: + type: number + right: + type: string + bid_size: + type: integer + ask_exchange: + type: integer + bid_exchange: + type: integer + ask: + type: number + expiration: + type: string + bid: + type: number + bid_condition: + type: integer + timestamp: + type: string + required: + - symbol + - ask_size + - ask_condition + - strike + - right + - bid_size + - ask_exchange + - bid_exchange + - ask + - expiration + - bid + - bid_condition + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + ask_size: + - 0 + - 424 + - 221 + - 45 + - 121 + ask_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + bid_size: + - 0 + - 598 + - 58 + - 394 + - 194 + ask_exchange: + - 42 + - 9 + - 11 + - 47 + - 11 + bid_exchange: + - 42 + - 5 + - 46 + - 43 + - 11 + ask: + - 0.0 + - 4.7 + - 4.4 + - 4.0 + - 4.3 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + bid: + - 0.0 + - 4.55 + - 4.3 + - 3.9 + - 4.15 + bid_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:31:00' + - '2024-11-04T09:32:00' + - '2024-11-04T09:33:00' + - '2024-11-04T09:34:00' + /option/history/trade_quote: + x-min-subscription: standard + get: + summary: Trade Quote + operationId: option_history_trade_quote + tags: + - Option + - History + description: | + - Returns every [trade](/operations/option_history_trade.html) reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) paired with the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at the time of trade. + - A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. + - To match trades with quotes timestamps that are ``<`` the trade timestamp, specify the ``exclusive``parameter to ``true``. After thorough testing, we have determined that using ``exclusive=true`` might yield better results for various applications. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade_quote?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns every trade quote for an option contract" + - url: + http://localhost:25503/v3/option/history/trade_quote?symbol=AAPL&expiration=*&date=20241104 + description: "Returns every trade quote for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/exclusive" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade quote for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + trade_timestamp: + type: string + ask_condition: + type: integer + strike: + type: number + right: + type: string + sequence: + type: integer + condition: + type: integer + size: + type: integer + bid_size: + type: integer + ask_exchange: + type: integer + price: + type: number + ext_condition2: + type: integer + bid_exchange: + type: integer + ask: + type: number + quote_timestamp: + type: string + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + bid: + type: number + bid_condition: + type: integer + required: + - symbol + - ask_size + - trade_timestamp + - ask_condition + - strike + - right + - sequence + - condition + - size + - bid_size + - ask_exchange + - price + - ext_condition2 + - bid_exchange + - ask + - quote_timestamp + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - bid + - bid_condition + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + ask_size: + - 14 + - 35 + - 59 + - 81 + - 81 + trade_timestamp: + - '2024-11-04T09:30:00.471' + - '2024-11-04T09:30:01.626' + - '2024-11-04T09:30:01.698' + - '2024-11-04T09:30:02.064' + - '2024-11-04T09:30:02.064' + ask_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + sequence: + - 18902138 + - 19368856 + - 19403970 + - 19598457 + - 19598464 + condition: + - 130 + - 130 + - 130 + - 18 + - 18 + size: + - 2 + - 1 + - 1 + - 1 + - 1 + bid_size: + - 14 + - 93 + - 59 + - 31 + - 31 + ask_exchange: + - 47 + - 73 + - 69 + - 11 + - 11 + price: + - 3.9 + - 4.25 + - 4.22 + - 4.15 + - 4.15 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + bid_exchange: + - 47 + - 76 + - 69 + - 69 + - 69 + ask: + - 4.05 + - 4.3 + - 4.3 + - 4.3 + - 4.3 + quote_timestamp: + - '2024-11-04T09:30:00.396' + - '2024-11-04T09:30:01.594' + - '2024-11-04T09:30:01.643' + - '2024-11-04T09:30:02.039' + - '2024-11-04T09:30:02.039' + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 22 + - 6 + - 6 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + bid: + - 3.9 + - 4.15 + - 4.15 + - 4.15 + - 4.15 + bid_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + /option/history/open_interest: + x-min-subscription: value + get: + summary: Open Interest + operationId: option_history_open_interest + tags: + - Option + - History + description: | + - Open Interest is normally reported once per day by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at approximately 06:30 ET. + - A new open interest message might not be sent by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) if there is no open interest for the option contract. + - The reported open interest represents the open interest at the end of the previous trading day. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/open_interest?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns open interest for an option contract" + - url: + http://localhost:25503/v3/option/history/open_interest?symbol=AAPL&expiration=*&date=20241104 + description: "Returns open interest for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns open interest for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + open_interest: + type: integer + expiration: + type: string + right: + type: string + timestamp: + type: string + required: + - symbol + - strike + - open_interest + - expiration + - right + - timestamp + example: + symbol: + - AAPL + strike: + - 220.0 + open_interest: + - 2732 + expiration: + - '2024-11-08' + right: + - CALL + timestamp: + - '2024-11-04T06:30:04' + /option/history/greeks/eod: + x-min-subscription: standard + get: + summary: End of Day Greeks + operationId: option_history_greeks_eod + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Uses Theta Data's EOD reports that get generated at 17:15 ET each day. The closing option price and closing underlying price are used for the greeks calculation. + - **Set `expiration` to ``*`` if you want to retrieve data for every option that shares the same ``symbol``. (note: Any ``expiration=*`` must be requested day by day)** + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We are working to expose this over the coming months. Obtaining the quote at the end of the day requires much more processing than the trades, so we initially generated our history for trades. + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/greeks/eod?symbol=AAPL&expiration=20241108&strike=220.000&right=call&start_date=20241104&end_date=20241104 + description: "Returns EOD report for an option contract" + - url: + http://localhost:25503/v3/option/history/greeks/eod?symbol=AAPL&expiration=*&start_date=20241104&end_date=20241104 + description: "Returns EOD report for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + dual_delta: + type: number + color: + type: number + zomma: + type: number + delta: + type: number + implied_vol: + type: number + theta: + type: number + d1: + type: number + speed: + type: number + d2: + type: number + epsilon: + type: number + high: + type: number + lambda: + type: number + low: + type: number + ask_exchange: + type: integer + bid_exchange: + type: integer + vomma: + type: number + bid_condition: + type: integer + underlying_timestamp: + type: string + close: + type: number + timestamp: + type: string + underlying_price: + type: number + ask_condition: + type: integer + strike: + type: number + count: + type: integer + vera: + type: number + right: + type: string + veta: + type: number + iv_error: + type: number + ultima: + type: number + volume: + type: integer + charm: + type: number + bid_size: + type: integer + ask: + type: number + rho: + type: number + expiration: + type: string + vanna: + type: number + dual_gamma: + type: number + bid: + type: number + open: + type: number + vega: + type: number + gamma: + type: number + required: + - symbol + - ask_size + - dual_delta + - color + - zomma + - delta + - implied_vol + - theta + - d1 + - speed + - d2 + - epsilon + - high + - lambda + - low + - ask_exchange + - bid_exchange + - vomma + - bid_condition + - underlying_timestamp + - close + - timestamp + - underlying_price + - ask_condition + - strike + - count + - vera + - right + - veta + - iv_error + - ultima + - volume + - charm + - bid_size + - ask + - rho + - expiration + - vanna + - dual_gamma + - bid + - open + - vega + - gamma + example: + symbol: + - AAPL + ask_size: + - 12 + dual_delta: + - -0.5945 + color: + - -0.0163 + zomma: + - 0.0 + delta: + - 0.6083 + implied_vol: + - 0.3334 + theta: + - -0.3892 + d1: + - 0.275 + speed: + - 0.0 + d2: + - 0.2401 + epsilon: + - -1.4791 + high: + - 4.85 + lambda: + - 32.3623 + low: + - 3.35 + ask_exchange: + - 5 + bid_exchange: + - 11 + vomma: + - 1.7667 + bid_condition: + - 50 + underlying_timestamp: + - '2024-11-04T17:15:28.71' + close: + - 4.15 + timestamp: + - '2024-11-04T15:59:59.828' + underlying_price: + - 221.87 + ask_condition: + - 50 + strike: + - 220.0 + count: + - 1511 + vera: + - 0.0 + right: + - CALL + veta: + - 0.0149 + iv_error: + - 0.0001 + ultima: + - -15.6407 + volume: + - 7425 + charm: + - 3.6779 + bid_size: + - 9 + ask: + - 4.25 + rho: + - 1.4334 + expiration: + - '2024-11-08' + vanna: + - -0.2765 + dual_gamma: + - 0.0 + bid: + - 4.1 + open: + - 3.9 + vega: + - 8.9221 + gamma: + - 0.0495 + /option/history/greeks/all: + x-min-subscription: professional + get: + summary: All Greeks + operationId: option_history_greeks_all + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/greeks/all?symbol=AAPL&expiration=20241108&date=20241104&interval=10m + description: "Returns all greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns all greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + dual_delta: + type: number + color: + type: number + zomma: + type: number + delta: + type: number + implied_vol: + type: number + theta: + type: number + d1: + type: number + speed: + type: number + d2: + type: number + epsilon: + type: number + lambda: + type: number + vomma: + type: number + underlying_timestamp: + type: string + timestamp: + type: string + underlying_price: + type: number + strike: + type: number + vera: + type: number + right: + type: string + veta: + type: number + iv_error: + type: number + ultima: + type: number + charm: + type: number + ask: + type: number + rho: + type: number + expiration: + type: string + vanna: + type: number + dual_gamma: + type: number + bid: + type: number + vega: + type: number + gamma: + type: number + required: + - symbol + - dual_delta + - color + - zomma + - delta + - implied_vol + - theta + - d1 + - speed + - d2 + - epsilon + - lambda + - vomma + - underlying_timestamp + - timestamp + - underlying_price + - strike + - vera + - right + - veta + - iv_error + - ultima + - charm + - ask + - rho + - expiration + - vanna + - dual_gamma + - bid + - vega + - gamma + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + dual_delta: + - 0.0 + - -0.0021 + - -0.002 + - -0.0021 + - 0.0 + color: + - 0.0 + - -0.0005 + - -0.0005 + - -0.0005 + - 0.0 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + delta: + - 0.0 + - 0.0026 + - 0.0025 + - 0.0025 + - 0.0 + implied_vol: + - 0.25 + - 0.5874 + - 0.5749 + - 0.5625 + - 0.25 + theta: + - 0.0 + - -0.0138 + - -0.013 + - -0.0129 + - 0.0 + d1: + - -6.5422 + - -2.7911 + - -2.805 + - -2.8027 + - -6.3404 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + d2: + - -6.5683 + - -2.8526 + - -2.8652 + - -2.8616 + - -6.3666 + epsilon: + - 0.0 + - -0.0063 + - -0.006 + - -0.0061 + - 0.0 + lambda: + - 261.9304 + - 55.3974 + - 56.7822 + - 57.99 + - 254.5285 + vomma: + - 0.0 + - 2.5389 + - 2.5262 + - 2.6034 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:50:00' + - '2024-11-04T10:00:00' + - '2024-11-04T10:10:00' + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:50:00' + - '2024-11-04T10:00:00' + - '2024-11-04T10:10:00' + underlying_price: + - 221.0 + - 220.56 + - 221.2 + - 222.06 + - 222.17 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + vera: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.0 + - 0.0136 + - 0.0133 + - 0.0136 + - 0.0 + iv_error: + - 100.0 + - 0.0455 + - -0.0199 + - -0.0299 + - 100.0 + ultima: + - 0.0001 + - 21.4427 + - 22.1272 + - 23.2345 + - 0.0004 + charm: + - 0.0 + - -1.0623 + - -1.0265 + - -1.0319 + - 0.0 + ask: + - 0.0 + - 0.02 + - 0.02 + - 0.02 + - 0.01 + rho: + - 0.0 + - 0.0062 + - 0.0059 + - 0.006 + - 0.0 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + vanna: + - 0.0 + - 0.0393 + - 0.0388 + - 0.0399 + - 0.0 + dual_gamma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + vega: + - 0.0 + - 0.1873 + - 0.1807 + - 0.1825 + - 0.0 + gamma: + - 0.0 + - 0.0005 + - 0.0005 + - 0.0006 + - 0.0 + /option/history/trade_greeks/all: + x-min-subscription: professional + get: + summary: All Trade Greeks + operationId: option_history_trade_greeks_all + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade_greeks/all?symbol=AAPL&expiration=20231117&date=20231110 + description: "Returns all trade greeks for an option contract" + - url: + http://localhost:25503/v3/option/history/trade_greeks/all?symbol=AAPL&expiration=*&date=20231110 + description: "Returns all trade greeks for an full chain of option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns all trade greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + dual_delta: + type: number + color: + type: number + zomma: + type: number + delta: + type: number + implied_vol: + type: number + theta: + type: number + d1: + type: number + speed: + type: number + d2: + type: number + epsilon: + type: number + lambda: + type: number + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + ext_condition4: + type: integer + vomma: + type: number + ext_condition3: + type: integer + underlying_timestamp: + type: string + timestamp: + type: string + underlying_price: + type: number + strike: + type: number + vera: + type: number + right: + type: string + veta: + type: number + iv_error: + type: number + ultima: + type: number + sequence: + type: integer + condition: + type: integer + size: + type: integer + charm: + type: number + rho: + type: number + expiration: + type: string + exchange: + type: integer + vanna: + type: number + dual_gamma: + type: number + vega: + type: number + gamma: + type: number + required: + - symbol + - dual_delta + - color + - zomma + - delta + - implied_vol + - theta + - d1 + - speed + - d2 + - epsilon + - lambda + - price + - ext_condition2 + - ext_condition1 + - ext_condition4 + - vomma + - ext_condition3 + - underlying_timestamp + - timestamp + - underlying_price + - strike + - vera + - right + - veta + - iv_error + - ultima + - sequence + - condition + - size + - charm + - rho + - expiration + - exchange + - vanna + - dual_gamma + - vega + - gamma + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + dual_delta: + - -0.2213 + - -0.2213 + - -0.2093 + - -0.2182 + - -0.2231 + color: + - -0.0129 + - -0.0129 + - -0.0118 + - -0.0126 + - -0.013 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + delta: + - 0.2289 + - 0.2289 + - 0.2162 + - 0.2256 + - 0.2308 + implied_vol: + - 0.1762 + - 0.1762 + - 0.1669 + - 0.1738 + - 0.1777 + theta: + - -0.1031 + - -0.1031 + - -0.0947 + - -0.1009 + - -0.1044 + d1: + - -0.7424 + - -0.7424 + - -0.7849 + - -0.7531 + - -0.736 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + d2: + - -0.7668 + - -0.7668 + - -0.8081 + - -0.7772 + - -0.7607 + epsilon: + - -0.8073 + - -0.8073 + - -0.7625 + - -0.7958 + - -0.814 + lambda: + - 71.4109 + - 71.4109 + - 76.6064 + - 72.7109 + - 70.6522 + price: + - 0.59 + - 0.59 + - 0.52 + - 0.57 + - 0.6 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + vomma: + - 24.9086 + - 24.9086 + - 28.3594 + - 25.765 + - 24.4114 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + timestamp: + - '2023-11-10T09:30:00.004' + - '2023-11-10T09:30:00.154' + - '2023-11-10T09:30:00.22' + - '2023-11-10T09:30:00.221' + - '2023-11-10T09:30:00.452' + underlying_price: + - 183.89 + - 183.89 + - 183.89 + - 183.89 + - 183.89 + strike: + - 187.5 + - 187.5 + - 187.5 + - 187.5 + - 187.5 + vera: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.3553 + - 0.3553 + - 0.3755 + - 0.3605 + - 0.3523 + iv_error: + - -0.0008 + - -0.0008 + - -0.0018 + - 0.0012 + - 0.0013 + ultima: + - -100.0 + - -100.0 + - -100.0 + - -100.0 + - -100.0 + sequence: + - -1391330475 + - -1391317465 + - -1391313694 + - -1391313652 + - -1391297309 + condition: + - 18 + - 18 + - 18 + - 130 + - 18 + size: + - 1 + - 1 + - 8 + - 1 + - 6 + charm: + - -6.7146 + - -6.7146 + - -6.8508 + - -6.7516 + - -6.692 + rho: + - 0.796 + - 0.796 + - 0.7526 + - 0.7849 + - 0.8025 + expiration: + - '2023-11-17' + - '2023-11-17' + - '2023-11-17' + - '2023-11-17' + - '2023-11-17' + exchange: + - 9 + - 47 + - 6 + - 6 + - 31 + vanna: + - 1.3174 + - 1.3174 + - 1.4186 + - 1.3432 + - 1.3022 + dual_gamma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + vega: + - 7.7122 + - 7.7122 + - 7.4656 + - 7.6504 + - 7.7484 + gamma: + - 0.0674 + - 0.0674 + - 0.0689 + - 0.0678 + - 0.0672 + /option/history/greeks/first_order: + x-min-subscription: standard + get: + summary: First Order Greeks + operationId: option_history_greeks_first_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/greeks/first_order?symbol=AAPL&expiration=20241108&date=20241104&interval=5m + description: "Returns first order greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns first order greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + delta: + type: number + right: + type: string + implied_vol: + type: number + theta: + type: number + iv_error: + type: number + epsilon: + type: number + lambda: + type: number + ask: + type: number + rho: + type: number + expiration: + type: string + bid: + type: number + underlying_timestamp: + type: string + vega: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - delta + - right + - implied_vol + - theta + - iv_error + - epsilon + - lambda + - ask + - rho + - expiration + - bid + - underlying_timestamp + - vega + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 220.66 + - 220.56 + - 220.86 + - 221.2 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + delta: + - 0.0 + - 0.0026 + - 0.0026 + - 0.0025 + - 0.0025 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.25 + - 0.5874 + - 0.5874 + - 0.5812 + - 0.5749 + theta: + - 0.0 + - -0.0141 + - -0.0138 + - -0.0133 + - -0.013 + iv_error: + - 100.0 + - 0.0721 + - 0.0455 + - 0.0075 + - -0.0199 + epsilon: + - 0.0 + - -0.0064 + - -0.0063 + - -0.0061 + - -0.006 + lambda: + - 261.9304 + - 55.293 + - 55.3974 + - 56.1024 + - 56.7822 + ask: + - 0.0 + - 0.02 + - 0.02 + - 0.02 + - 0.02 + rho: + - 0.0 + - 0.0063 + - 0.0062 + - 0.006 + - 0.0059 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + vega: + - 0.0 + - 0.1913 + - 0.1873 + - 0.1832 + - 0.1807 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + /option/history/trade_greeks/first_order: + x-min-subscription: professional + get: + summary: First Order Trade Greeks + operationId: option_history_trade_greeks_first_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade_greeks/first_order?symbol=AAPL&expiration=20241108&date=20241104 + description: "Returns first order trade greeks for an option contract" + - url: + http://localhost:25503/v3/option/history/trade_greeks/first_order?symbol=AAPL&expiration=*&date=20241104 + description: "Returns first order trade greeks for an full chain of option + contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns first order trade greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + delta: + type: number + right: + type: string + implied_vol: + type: number + theta: + type: number + iv_error: + type: number + epsilon: + type: number + sequence: + type: integer + condition: + type: integer + lambda: + type: number + size: + type: integer + price: + type: number + ext_condition2: + type: integer + rho: + type: number + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + underlying_timestamp: + type: string + vega: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - delta + - right + - implied_vol + - theta + - iv_error + - epsilon + - sequence + - condition + - lambda + - size + - price + - ext_condition2 + - rho + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - underlying_timestamp + - vega + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.33 + - 221.22 + - 221.18 + - 221.16 + - 221.19 + strike: + - 262.5 + - 140.0 + - 140.0 + - 140.0 + - 140.0 + delta: + - 0.0025 + - 0.9976 + - 1.0 + - 0.9976 + - 0.9993 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.5749 + - 1.5937 + - 0.0 + - 1.5937 + - 1.3968 + theta: + - -0.0134 + - -0.052 + - 0.0 + - -0.0522 + - -0.0279 + iv_error: + - 0.0132 + - 0.0 + - 0.0011 + - 0.0 + - 0.0 + epsilon: + - -0.0062 + - -2.4186 + - 0.0 + - -2.4179 + - -2.4223 + sequence: + - 156249981 + - 546105677 + - 548097371 + - 548397162 + - 550463381 + condition: + - 125 + - 131 + - 130 + - 130 + - 131 + lambda: + - 56.6408 + - 2.7139 + - 0.0 + - 2.7152 + - 2.7198 + size: + - 1 + - 2 + - 3 + - 3 + - 1 + price: + - 0.01 + - 81.32 + - 81.16 + - 81.26 + - 81.27 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + rho: + - 0.0061 + - 1.5274 + - 0.0 + - 1.5274 + - 1.5317 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 9 + - 5 + - 7 + - 6 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:53:54' + - '2024-11-04T11:47:14' + - '2024-11-04T11:47:56' + - '2024-11-04T11:48:03' + - '2024-11-04T11:48:51' + vega: + - 0.1858 + - 0.169 + - 0.0 + - 0.1697 + - 0.0544 + timestamp: + - '2024-11-04T09:53:54.069' + - '2024-11-04T11:47:14.764' + - '2024-11-04T11:47:56.669' + - '2024-11-04T11:48:03.852' + - '2024-11-04T11:48:51.11' + /option/history/greeks/second_order: + x-min-subscription: professional + get: + summary: Second Order Greeks + operationId: option_history_greeks_second_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/greeks/second_order?symbol=AAPL&expiration=20241108&date=20241104&interval=1h + description: "Returns second order greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns second order greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + right: + type: string + veta: + type: number + implied_vol: + type: number + iv_error: + type: number + charm: + type: number + ask: + type: number + expiration: + type: string + vanna: + type: number + vomma: + type: number + bid: + type: number + underlying_timestamp: + type: string + gamma: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - right + - veta + - implied_vol + - iv_error + - charm + - ask + - expiration + - vanna + - vomma + - bid + - underlying_timestamp + - gamma + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 221.73 + - 221.49 + - 221.11 + - 222.03 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + implied_vol: + - 0.25 + - 0.25 + - 0.25 + - 0.25 + - 0.25 + iv_error: + - 100.0 + - 100.0 + - 100.0 + - 100.0 + - 100.0 + charm: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + ask: + - 0.0 + - 0.01 + - 0.01 + - 0.01 + - 0.01 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + vanna: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + vomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + gamma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + /option/history/trade_greeks/second_order: + x-min-subscription: professional + get: + summary: Second Order Trade Greeks + operationId: option_history_trade_greeks_second_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade_greeks/second_order?symbol=AAPL&expiration=20241108&date=20241104 + description: "Returns second order trade greeks for an option contract" + - url: + http://localhost:25503/v3/option/history/trade_greeks/second_order?symbol=AAPL&expiration=*&date=20241104 + description: "Returns second order trade greeks for an full chain of option + contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns second order trade greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + right: + type: string + veta: + type: number + implied_vol: + type: number + iv_error: + type: number + sequence: + type: integer + condition: + type: integer + size: + type: integer + charm: + type: number + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + vanna: + type: number + vomma: + type: number + ext_condition3: + type: integer + underlying_timestamp: + type: string + gamma: + type: number + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - right + - veta + - implied_vol + - iv_error + - sequence + - condition + - size + - charm + - price + - ext_condition2 + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - vanna + - vomma + - ext_condition3 + - underlying_timestamp + - gamma + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.33 + - 221.22 + - 221.18 + - 221.16 + - 221.19 + strike: + - 262.5 + - 140.0 + - 140.0 + - 140.0 + - 140.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.0137 + - 0.0063 + - 0.0 + - 0.0064 + - 0.0025 + implied_vol: + - 0.5749 + - 1.5937 + - 0.0 + - 1.5937 + - 1.3968 + iv_error: + - 0.0132 + - 0.0 + - 0.0011 + - 0.0 + - 0.0 + sequence: + - 156249981 + - 546105677 + - 548097371 + - 548397162 + - 550463381 + condition: + - 125 + - 131 + - 130 + - 130 + - 131 + size: + - 1 + - 2 + - 3 + - 3 + - 1 + charm: + - -1.0514 + - 0.8843 + - 0.0 + - 0.8879 + - 0.3271 + price: + - 0.01 + - 81.32 + - 81.16 + - 81.26 + - 81.27 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 9 + - 5 + - 7 + - 6 + - 5 + vanna: + - 0.0398 + - -0.0121 + - 0.0 + - -0.0122 + - -0.0051 + vomma: + - 2.5798 + - 0.7986 + - 0.0 + - 0.8011 + - 0.3817 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:53:54' + - '2024-11-04T11:47:14' + - '2024-11-04T11:47:56' + - '2024-11-04T11:48:03' + - '2024-11-04T11:48:51' + gamma: + - 0.0006 + - 0.0001 + - 0.0 + - 0.0001 + - 0.0 + timestamp: + - '2024-11-04T09:53:54.069' + - '2024-11-04T11:47:14.764' + - '2024-11-04T11:47:56.669' + - '2024-11-04T11:48:03.852' + - '2024-11-04T11:48:51.11' + /option/history/greeks/third_order: + x-min-subscription: professional + get: + summary: Third Order Greeks + operationId: option_history_greeks_third_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/greeks/third_order?symbol=AAPL&expiration=20241108&date=20241104&interval=1h + description: "Returns third order greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns third order greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + color: + type: number + strike: + type: number + zomma: + type: number + right: + type: string + implied_vol: + type: number + iv_error: + type: number + speed: + type: number + ultima: + type: number + ask: + type: number + expiration: + type: string + bid: + type: number + underlying_timestamp: + type: string + timestamp: + type: string + required: + - symbol + - underlying_price + - color + - strike + - zomma + - right + - implied_vol + - iv_error + - speed + - ultima + - ask + - expiration + - bid + - underlying_timestamp + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 221.73 + - 221.49 + - 221.11 + - 222.03 + color: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.25 + - 0.25 + - 0.25 + - 0.25 + - 0.25 + iv_error: + - 100.0 + - 100.0 + - 100.0 + - 100.0 + - 100.0 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + ultima: + - 0.0001 + - 0.0002 + - 0.0002 + - 0.0001 + - 0.0003 + ask: + - 0.0 + - 0.01 + - 0.01 + - 0.01 + - 0.01 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + /option/history/trade_greeks/third_order: + x-min-subscription: professional + get: + summary: Third Order Trade Greeks + operationId: option_history_trade_greeks_third_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade_greeks/third_order?symbol=AAPL&expiration=20241108&date=20241104 + description: "Returns third order trade greeks for an option contract" + - url: + http://localhost:25503/v3/option/history/trade_greeks/third_order?symbol=AAPL&expiration=*&date=20241104 + description: "Returns third order trade greeks for an full chain of option + contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns third order trade greeks for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + color: + type: number + strike: + type: number + zomma: + type: number + right: + type: string + implied_vol: + type: number + iv_error: + type: number + speed: + type: number + ultima: + type: number + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + underlying_timestamp: + type: string + timestamp: + type: string + required: + - symbol + - underlying_price + - color + - strike + - zomma + - right + - implied_vol + - iv_error + - speed + - ultima + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - underlying_timestamp + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.33 + - 221.22 + - 221.18 + - 221.16 + - 221.19 + color: + - -0.0005 + - -0.0013 + - 0.0 + - -0.0013 + - -0.0003 + strike: + - 262.5 + - 140.0 + - 140.0 + - 140.0 + - 140.0 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.5749 + - 1.5937 + - 0.0 + - 1.5937 + - 1.3968 + iv_error: + - 0.0132 + - 0.0 + - 0.0011 + - 0.0 + - 0.0 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + ultima: + - 22.3494 + - 2.2683 + - 0.0 + - 2.2709 + - 1.8578 + sequence: + - 156249981 + - 546105677 + - 548097371 + - 548397162 + - 550463381 + condition: + - 125 + - 131 + - 130 + - 130 + - 131 + size: + - 1 + - 2 + - 3 + - 3 + - 1 + price: + - 0.01 + - 81.32 + - 81.16 + - 81.26 + - 81.27 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 9 + - 5 + - 7 + - 6 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:53:54' + - '2024-11-04T11:47:14' + - '2024-11-04T11:47:56' + - '2024-11-04T11:48:03' + - '2024-11-04T11:48:51' + timestamp: + - '2024-11-04T09:53:54.069' + - '2024-11-04T11:47:14.764' + - '2024-11-04T11:47:56.669' + - '2024-11-04T11:48:03.852' + - '2024-11-04T11:48:51.11' + /option/history/greeks/implied_volatility: + x-min-subscription: standard + get: + summary: Implied Volatility + operationId: option_history_greeks_implied_volatility + tags: + - Option + - History + description: | + - Returns implied volatilies calculated using the national best bid, mid, and ask price of the option respectively. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/greeks/implied_volatility?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104&interval=5m + description: "Returns 5m interval implied volatility for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns 5m interval implied volatility for an option + contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + right: + type: string + implied_vol: + type: number + iv_error: + type: number + bid_implied_vol: + type: number + ask: + type: number + midpoint: + type: number + expiration: + type: string + ask_implied_vol: + type: number + bid: + type: number + underlying_timestamp: + type: string + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - right + - implied_vol + - iv_error + - bid_implied_vol + - ask + - midpoint + - expiration + - ask_implied_vol + - bid + - underlying_timestamp + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 220.66 + - 220.56 + - 220.86 + - 221.2 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.0 + - 0.3693 + - 0.3698 + - 0.3574 + - 0.3474 + iv_error: + - 100.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid_implied_vol: + - 0.0 + - 0.364 + - 0.3643 + - 0.3518 + - 0.3417 + ask: + - 0.0 + - 3.85 + - 3.8 + - 3.85 + - 3.95 + midpoint: + - 0.0 + - 3.8 + - 3.75 + - 3.8 + - 3.9 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ask_implied_vol: + - 0.0 + - 0.3747 + - 0.3752 + - 0.3627 + - 0.3527 + bid: + - 0.0 + - 3.75 + - 3.7 + - 3.75 + - 3.85 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + /option/history/trade_greeks/implied_volatility: + x-min-subscription: professional + get: + summary: Trade Implied Volatility + operationId: option_history_trade_greeks_implied_volatility + tags: + - Option + - History + description: | + - Returns implied volatilies calculated using the trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: + http://localhost:25503/v3/option/history/trade_greeks/implied_volatility?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns implied volatility for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns implied volatility for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + underlying_price: + type: number + strike: + type: number + right: + type: string + implied_vol: + type: number + iv_error: + type: number + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + underlying_timestamp: + type: string + timestamp: + type: string + required: + - symbol + - underlying_price + - strike + - right + - implied_vol + - iv_error + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - underlying_timestamp + - timestamp + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 221.17 + - 221.17 + - 221.37 + - 221.37 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.3598 + - 0.3876 + - 0.3842 + - 0.364 + - 0.364 + iv_error: + - 0.0002 + - 0.0 + - -0.0002 + - -0.0001 + - -0.0001 + sequence: + - 18902138 + - 19368856 + - 19403970 + - 19598457 + - 19598464 + condition: + - 130 + - 130 + - 130 + - 18 + - 18 + size: + - 2 + - 1 + - 1 + - 1 + - 1 + price: + - 3.9 + - 4.25 + - 4.22 + - 4.15 + - 4.15 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 22 + - 6 + - 6 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:30:01' + - '2024-11-04T09:30:01' + - '2024-11-04T09:30:02' + - '2024-11-04T09:30:02' + timestamp: + - '2024-11-04T09:30:00.471' + - '2024-11-04T09:30:01.626' + - '2024-11-04T09:30:01.698' + - '2024-11-04T09:30:02.064' + - '2024-11-04T09:30:02.064' + /option/at_time/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: option_at_time_trade + tags: + - Option + - At-Time + description: | + - Returns the last trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a specified millisecond of the day. + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) for options, so they can be ignored. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the trade should be provided for. + x-sample-urls: + - url: + http://localhost:25503/v3/option/at_time/trade?symbol=AAPL&expiration=20241108&strike=220.000&right=call&start_date=20241104&end_date=20241104&time_of_day=09:30:01.000 + description: "Returns the last trade for an option contract" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last trade for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + strike: + type: number + right: + type: string + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + expiration: + type: string + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + timestamp: + type: string + required: + - symbol + - strike + - right + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - expiration + - ext_condition4 + - exchange + - ext_condition3 + - timestamp + example: + symbol: + - AAPL + strike: + - 220.0 + right: + - CALL + sequence: + - 18902138 + condition: + - 130 + size: + - 2 + price: + - 3.9 + ext_condition2: + - 255 + ext_condition1: + - 255 + expiration: + - '2024-11-08' + ext_condition4: + - 255 + exchange: + - 22 + ext_condition3: + - 255 + timestamp: + - '2024-11-04T09:30:00.471' + /option/at_time/quote: + x-min-subscription: value + get: + summary: Quote + operationId: option_at_time_quote + tags: + - Option + - At-Time + description: | + - Returns the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a specified millisecond of the day. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the quote should be provided for. + x-sample-urls: + - url: + http://localhost:25503/v3/option/at_time/quote?symbol=AAPL&expiration=20241108&strike=220.000&right=call&start_date=20241104&end_date=20241104&time_of_day=09:30:01.000 + description: "Returns the last quote for an option contract" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last quote for an option contract + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + ask_size: + type: integer + ask_condition: + type: integer + strike: + type: number + right: + type: string + bid_size: + type: integer + ask_exchange: + type: integer + bid_exchange: + type: integer + ask: + type: number + expiration: + type: string + bid: + type: number + bid_condition: + type: integer + timestamp: + type: string + required: + - symbol + - ask_size + - ask_condition + - strike + - right + - bid_size + - ask_exchange + - bid_exchange + - ask + - expiration + - bid + - bid_condition + - timestamp + example: + symbol: + - AAPL + ask_size: + - 14 + ask_condition: + - 50 + strike: + - 220.0 + right: + - CALL + bid_size: + - 129 + ask_exchange: + - 47 + bid_exchange: + - 69 + ask: + - 4.1 + expiration: + - '2024-11-08' + bid: + - 3.95 + bid_condition: + - 50 + timestamp: + - '2024-11-04T09:30:00.91' + /index/list/symbols: + x-min-subscription: free + get: + summary: Symbols + operationId: index_list_symbols + tags: + - Index + - List + description: | + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/index/list/symbols + description: "List all symbols for indices" + parameters: + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all symbols for indices + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + required: + - symbol + example: + symbol: + - AASGI + - AASUS + - ACNAC + - ACNIT + - ACNRE + /index/list/dates: + x-min-subscription: free + get: + summary: Dates + operationId: index_list_dates + tags: + - Index + - List + description: | + Lists all dates of data that are available for a index with a given request type and symbol. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/index/list/dates?symbol=SPX + description: "List all dates for a index for a given symbol" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all dates for a index for a given symbol + content: + application/json: + schema: + type: array + items: + type: object + properties: + date: + type: string + symbol: + type: string + required: + - date + - symbol + example: + date: + - '2023-04-20' + - '2023-04-21' + - '2023-04-17' + - '2023-04-18' + - '2023-04-19' + symbol: + - SPX + - SPX + - SPX + - SPX + - SPX + /index/snapshot/ohlc: + x-min-subscription: standard + get: + summary: Open High Low Close + operationId: index_snapshot_ohlc + tags: + - Index + - Snapshot + description: | + - Retrieves the real-time current day OHLC. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + x-sample-urls: + - url: http://localhost:25503/v3/index/snapshot/ohlc?symbol=SPX + description: "Returns OHLC for a given index price change" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given index price change + content: + application/json: + schema: + type: array + items: + type: object + properties: + volume: + type: integer + symbol: + type: string + high: + type: number + low: + type: number + count: + type: integer + close: + type: number + open: + type: number + timestamp: + type: string + required: + - volume + - symbol + - high + - low + - count + - close + - open + - timestamp + example: + volume: + - 0 + symbol: + - SPX + high: + - 6408.4 + low: + - 6343.86 + count: + - 0 + close: + - 6395.78 + open: + - 6406.62 + timestamp: + - '2025-08-20T16:02:06' + /index/snapshot/price: + x-min-subscription: standard + get: + summary: Price + operationId: index_snapshot_price + tags: + - Index + - Snapshot + description: | + - Retrieves a real-time last index price. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + x-sample-urls: + - url: http://localhost:25503/v3/index/snapshot/price?symbol=SPX + description: "Returns last index price" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last index price + content: + application/json: + schema: + type: array + items: + type: object + properties: + symbol: + type: string + price: + type: number + timestamp: + type: string + required: + - symbol + - price + - timestamp + example: + symbol: + - SPX + price: + - 6395.78 + timestamp: + - '2025-08-20T16:02:06' + /index/history/eod: + x-min-subscription: free + get: + summary: End of Day + operationId: index_history_eod + tags: + - Index + - History + description: | + - Since [the indices feeds](/Articles/Data-And-Requests/The-SIPs.html) do not provide a national EOD report, Theta Data generates a national EOD report at 17:15 each day. + x-sample-urls: + - url: + http://localhost:25503/v3/index/history/eod?symbol=SPX&start_date=20241104&end_date=20241108 + description: "Returns EOD report for a given symbol between specified dates + (inclusive)" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for a given symbol between specified + dates (inclusive) + content: + application/json: + schema: + type: array + items: + type: object + properties: + ask_size: + type: integer + last_trade: + type: string + created: + type: string + ask_condition: + type: integer + count: + type: integer + volume: + type: integer + high: + type: number + low: + type: number + bid_size: + type: integer + ask_exchange: + type: integer + bid_exchange: + type: integer + ask: + type: number + bid: + type: number + bid_condition: + type: integer + close: + type: number + open: + type: number + required: + - ask_size + - last_trade + - created + - ask_condition + - count + - volume + - high + - low + - bid_size + - ask_exchange + - bid_exchange + - ask + - bid + - bid_condition + - close + - open + example: + ask_size: + - 0 + - 0 + - 0 + - 0 + - 0 + last_trade: + - '2024-11-04T16:03:03' + - '2024-11-05T16:02:30' + - '2024-11-06T16:01:37' + - '2024-11-07T16:02:49' + - '2024-11-08T16:01:15' + created: + - '2024-11-04T17:19:50.198' + - '2024-11-05T17:15:03.061' + - '2024-11-06T17:16:28.297' + - '2024-11-07T17:17:17.218' + - '2024-11-08T17:21:08.187' + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + count: + - 0 + - 0 + - 0 + - 0 + - 0 + volume: + - 0 + - 0 + - 0 + - 0 + - 0 + high: + - 5741.43 + - 5783.44 + - 5936.14 + - 5983.84 + - 6012.45 + low: + - 5696.51 + - 5722.1 + - 5864.89 + - 5947.21 + - 5976.76 + bid_size: + - 0 + - 0 + - 0 + - 0 + - 0 + ask_exchange: + - 0 + - 0 + - 0 + - 0 + - 0 + bid_exchange: + - 0 + - 0 + - 0 + - 0 + - 0 + ask: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + close: + - 5712.69 + - 5782.76 + - 5929.04 + - 5973.1 + - 5995.54 + open: + - 5725.15 + - 5722.43 + - 5864.89 + - 5947.21 + - 5976.76 + /index/history/ohlc: + x-min-subscription: standard + get: + summary: Open High Low Close + operationId: index_history_ohlc + tags: + - Index + - History + description: | + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + x-sample-urls: + - url: + http://localhost:25503/v3/index/history/ohlc?symbol=SPX&start_date=20241104&end_date=20241104&interval=1m + description: "Returns OHLC for a given symbol between specified dates (inclusive) + with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given symbol between specified dates + (inclusive) with a one minute interval + content: + application/json: + schema: + type: array + items: + type: object + properties: + volume: + type: integer + high: + type: number + low: + type: number + vwap: + type: number + count: + type: integer + close: + type: number + open: + type: number + timestamp: + type: string + required: + - volume + - high + - low + - vwap + - count + - close + - open + - timestamp + example: + volume: + - 0 + - 0 + - 0 + - 0 + - 0 + high: + - 5731.27 + - 5730.4 + - 5729.2 + - 5726.71 + - 5723.33 + low: + - 5725.15 + - 5724.53 + - 5723.55 + - 5723.13 + - 5717.35 + vwap: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + count: + - 0 + - 0 + - 0 + - 0 + - 0 + close: + - 5728.56 + - 5725.42 + - 5726.54 + - 5723.13 + - 5717.64 + open: + - 5725.15 + - 5728.9 + - 5725.48 + - 5726.57 + - 5722.88 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:31:00' + - '2024-11-04T09:32:00' + - '2024-11-04T09:33:00' + - '2024-11-04T09:34:00' + /index/history/price: + x-min-subscription: value + get: + summary: Price + operationId: index_history_price + tags: + - Index + - History + description: | + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + - When the ``interval`` parameter is specified, the returned data represents the price at the exact time of each timestamp. If the timestamp in the response is 10:30:00, the price field represents the price at that exact time of the day. + - A price update from the exchange is omitted if the price remained the same from the previous update. + x-sample-urls: + - url: + http://localhost:25503/v3/index/history/price?symbol=SPX&date=20241104&interval=1m + description: "Returns historical index price reports" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns historical index price reports + content: + application/json: + schema: + type: array + items: + type: object + properties: + price: + type: number + timestamp: + type: string + required: + - price + - timestamp + example: + price: + - 0.0 + - 5728.56 + - 5725.48 + - 5726.57 + - 5722.88 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:31:00' + - '2024-11-04T09:32:00' + - '2024-11-04T09:33:00' + - '2024-11-04T09:34:00' + /index/at_time/price: + x-min-subscription: value + get: + summary: Price + operationId: index_at_time_price + tags: + - Index + - At-Time + description: | + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + - The ``time_of_day`` parameter represents the 00:00:00.000 ET that the price should be provided for. + x-sample-urls: + - url: + http://localhost:25503/v3/index/at_time/price?symbol=SPX&start_date=20241104&end_date=20241108&time_of_day=09:30:01.000 + description: "Returns specific at time historical index price reports" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns specific at time historical index price reports + content: + application/json: + schema: + type: array + items: + type: object + properties: + sequence: + type: integer + condition: + type: integer + size: + type: integer + price: + type: number + ext_condition2: + type: integer + ext_condition1: + type: integer + ext_condition4: + type: integer + exchange: + type: integer + ext_condition3: + type: integer + timestamp: + type: string + required: + - sequence + - condition + - size + - price + - ext_condition2 + - ext_condition1 + - ext_condition4 + - exchange + - ext_condition3 + - timestamp + example: + sequence: + - 0 + - 0 + - 0 + - 0 + - 0 + condition: + - 0 + - 0 + - 0 + - 0 + - 0 + size: + - 0 + - 0 + - 0 + - 0 + - 0 + price: + - 5725.15 + - 5722.43 + - 5864.89 + - 5947.21 + - 5976.76 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 5 + - 5 + - 5 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + timestamp: + - '2024-11-04T09:30:01' + - '2024-11-05T09:30:01' + - '2024-11-06T09:30:01' + - '2024-11-07T09:30:01' + - '2024-11-08T09:30:01' +components: + parameters: + # required parameters + single_symbol: + name: symbol + in: query + description: The stock or index symbol, or underlying symbol for options. + required: true + schema: + type: string + + multi_symbol: + name: symbol + in: query + description: The stock or index symbol, or underlying symbol for options. + Specify '*' for all symbols or a comma separated list when appropriate. + required: true + schema: + type: array + items: + type: string + + opt_multi_symbol: + name: symbol + in: query + description: The stock or index symbol, or underlying symbol for options. + required: false + schema: + type: array + items: + type: string + + date: + name: date + in: query + description: The date to fetch data for. + required: true + schema: + type: string + format: date + + end_date: + name: end_date + in: query + description: The end date (inclusive). + required: true + schema: + type: string + format: date + + start_date: + name: start_date + in: query + description: The start date (inclusive). + required: true + schema: + type: string + format: date + + opt_end_date: + name: end_date + in: query + description: The end date (inclusive). + required: false + schema: + type: string + format: date + + opt_start_date: + name: start_date + in: query + description: The start date (inclusive). + required: false + schema: + type: string + format: date + + time_of_day: + name: time_of_day + in: query + description: The time of the day to fetch data for; assumed to be + America/New_York. + required: true + schema: + type: string + format: time + + expiration: + name: expiration + in: query + description: The expiration of the contract in `YYYY-MM-DD` or `YYYYMMDD` + format, or `*` for all expirations. + required: true + schema: + type: string + format: date + + expiration_no_star: + name: expiration + in: query + description: The expiration of the contract in `YYYY-MM-DD` or `YYYYMMDD` + format. + required: true + schema: + type: string + format: date + + strike: + name: strike + in: query + description: The strike price of the contract in dollars (ie `100.00` for + `$100.00`), or `*` for all strikes. + required: false + schema: + type: string + default: "*" + + interval: + name: interval + in: query + description: The size of the time interval must be one of the available + options listed below. + required: true + schema: + type: string + enum: + - tick + - 10ms + - 100ms + - 500ms + - 1s + - 5s + - 10s + - 15s + - 30s + - 1m + - 5m + - 10m + - 15m + - 30m + - 1h + default: 1s + + security_type: + name: security_type + in: path + description: The security type. + required: true + schema: + type: string + enum: + - stock + - option + - index + + request_type: + name: request_type + in: path + description: The request type. + required: true + schema: + type: string + enum: + - trade + - quote + + + # non-required parameters + annual_dividend: + name: annual_dividend + in: query + description: The annualized expected dividend amount to be used in Greeks + calculations. + required: false + schema: + type: number + format: float + + end_time: + name: end_time + in: query + description: The end time (inclusive) in the specified day. + required: false + schema: + type: string + format: time + default: "16:00:00" + + exclusive: + name: exclusive + in: query + description: If you prefer to match quotes with timestamps that are < the + trade timestamp. + required: false + schema: + type: boolean + default: true + + format: + name: format + in: query + description: The format of the data when returned to the user. + required: false + schema: + type: string + enum: + - json + default: json + + rate_type: + name: rate_type + in: query + description: The interest rate type to be used in a Greeks calculation. + required: false + schema: + type: string + enum: + - sofr + - treasury_m1 + - treasury_m3 + - treasury_m6 + - treasury_y1 + - treasury_y2 + - treasury_y3 + - treasury_y5 + - treasury_y7 + - treasury_y10 + - treasury_y20 + - treasury_y30 + default: sofr + + rate_value: + name: rate_value + in: query + description: The interest rate, as a percent, to be used in a Greeks + calculation. + required: false + schema: + type: number + format: float + example: 5.0 + + right: + name: right + in: query + description: The right (call or put) of the contract. + required: false + schema: + type: string + enum: + - call + - put + - both + default: both + + start_time: + name: start_time + in: query + description: The start time (inclusive) in the specified day. + required: false + schema: + type: string + format: time + default: "09:30:00" + + stock_price: + name: stock_price + in: query + description: The underlying stock price to be used in the Greeks + calculation. + required: false + schema: + type: number + format: float + + venue: + name: venue + in: query + description: Used to specify the venue of the real time or historic + request. ``nqb`` = Nasdaq Basic; ``utp_cta`` = merged UTP & CTA. + required: false + schema: + type: string + enum: + - nqb + - utp_cta + default: nqb + + responses: + 200_OK: + description: "" + content: + text/csv: + schema: + type: string + + diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml new file mode 100644 index 000000000..85f3672d8 --- /dev/null +++ b/openapi/openapiv3.yaml @@ -0,0 +1,8260 @@ +openapi: 3.1.0 + +info: + title: Theta Data v3 + description: Real-time and historic stock, options, and index data! + version: 3.0.0 + x-java-package: net.thetadata.generated + +servers: + - url: 'https://localhost:25503/v3' + description: dev + +security: [] + + +paths: +# +# STOCK ENDPOINTS +# + /stock/list/symbols: + x-min-subscription: free + get: + summary: Symbols + operationId: stock_list_symbols + tags: + - Stock + - List + description: | + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also include: root, ticker, and underlying. This endpoint returns all traded symbols for stocks. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/stock/list/symbols + description: "List all stock symbols" + parameters: + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all stock symbols + content: + text/csv: + schema: + type: array + items: &id001 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + example: "symbol\r\nA\r\nAA\r\nAAA\r\nAAAA\r\nAAAP\r\n" + application/json: + schema: &id002 + type: array + items: *id001 + example: + symbol: + - A + - AA + - AAA + - AAAA + - AAAP + application/x-ndjson: + schema: *id002 + example: '{"symbol":"A"} + + {"symbol":"AA"} + + {"symbol":"AAA"} + + {"symbol":"AAAA"} + + {"symbol":"AAAP"}' + + /stock/list/dates/{request_type}: + x-min-subscription: free + get: + summary: Dates + operationId: stock_list_dates + tags: + - Stock + - List + description: | + Lists all dates of data that are available for a stock with a given request type and symbol. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/stock/list/dates/quote?symbol=AAPL + description: "List all dates for a stock quote for a given symbol" + - url: http://localhost:25503/v3/stock/list/dates/trade?symbol=AAPL,SPY + description: "List all dates for a stock trade for multiple symbols" + - url: http://localhost:25503/v3/stock/list/dates/trade?symbol=* + description: "List all dates for a stock trade for all symbols" + parameters: + - $ref: "#/components/parameters/request_type" + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all dates for a stock quote for a given symbol + content: + text/csv: + schema: + type: array + items: &id003 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + date: + type: string + format: date + description: The date formated as YYYY-MM-DD. + example: "symbol,date\r\nAAPL,2016-08-19\r\nAAPL,2016-08-18\r\nAAPL,2016-08-17\r\nAAPL,2016-08-16\r\nAAPL,2016-08-23\r\ + \n" + application/json: + schema: &id004 + type: array + items: *id003 + example: + date: + - '2016-08-19' + - '2016-08-18' + - '2016-08-17' + - '2016-08-16' + - '2016-08-23' + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + application/x-ndjson: + schema: *id004 + example: '{"date":"2016-08-19","symbol":"AAPL"} + + {"date":"2016-08-18","symbol":"AAPL"} + + {"date":"2016-08-17","symbol":"AAPL"} + + {"date":"2016-08-16","symbol":"AAPL"} + + {"date":"2016-08-23","symbol":"AAPL"}' + + /stock/snapshot/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: stock_snapshot_ohlc + tags: + - Stock + - Snapshot + description: | + + Provides a real-time Open, High, Low, Close for the current day. + * Returns a real-time session OHLC from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed session OHLC from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs) if the account has the stocks value subscription. + * ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a weekend where there were no eligible messages sent over exchange feeds. We recommend using historic requests during the weekend. + x-sample-urls: + - url: http://localhost:25503/v3/stock/snapshot/ohlc?symbol=* + description: "Returns OHLC for stocks for all symbols" + - url: http://localhost:25503/v3/stock/snapshot/ohlc?symbol=AAPL&venue=nqb + description: "Returns OHLC for a given stock trade from the Nasdaq Basic feed" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for stocks for all symbols + content: + text/csv: + schema: + type: array + items: &id005 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + example: "timestamp,symbol,open,high,low,close,volume,count\r\n2025-08-20T16:10:04.43,CVCO,492.0000,492.0000,480.5477,485.1100,119656,7684\r\ + \n2025-08-20T16:11:13.962,IFRX,0.8900,0.9199,0.8529,0.8929,57048,138\r\n2025-08-20T16:04:10.564,KLXY,0.0000,0.0000,0.0000,0.0000,9,6\r\ + \n2025-08-20T16:04:07.554,HCOW,23.5600,23.6976,23.5600,23.6616,3648,44\r\n2025-08-20T16:22:32.726,SCS,16.2000,16.3200,16.1550,16.1800,992620,7690\r\ + \n" + application/json: + schema: &id006 + type: array + items: *id005 + example: + volume: + - 119656 + - 57048 + - 9 + - 3648 + - 992620 + symbol: + - CVCO + - IFRX + - KLXY + - HCOW + - SCS + high: + - 492.0 + - 0.9199 + - 0.0 + - 23.6976 + - 16.32 + low: + - 480.5477 + - 0.8529 + - 0.0 + - 23.56 + - 16.155 + count: + - 7684 + - 138 + - 6 + - 44 + - 7690 + close: + - 485.11 + - 0.8929 + - 0.0 + - 23.6616 + - 16.18 + open: + - 492.0 + - 0.89 + - 0.0 + - 23.56 + - 16.2 + timestamp: + - '2025-08-20T16:10:04.43' + - '2025-08-20T16:11:13.962' + - '2025-08-20T16:04:10.564' + - '2025-08-20T16:04:07.554' + - '2025-08-20T16:22:32.726' + application/x-ndjson: + schema: *id006 + example: '{"volume":119656,"symbol":"CVCO","high":492.0000,"low":480.5477,"count":7684,"close":485.1100,"open":492.0000,"timestamp":"2025-08-20T16:10:04.43"} + + {"volume":57048,"symbol":"IFRX","high":0.9199,"low":0.8529,"count":138,"close":0.8929,"open":0.8900,"timestamp":"2025-08-20T16:11:13.962"} + + {"volume":9,"symbol":"KLXY","high":0.0000,"low":0.0000,"count":6,"close":0.0000,"open":0.0000,"timestamp":"2025-08-20T16:04:10.564"} + + {"volume":3648,"symbol":"HCOW","high":23.6976,"low":23.5600,"count":44,"close":23.6616,"open":23.5600,"timestamp":"2025-08-20T16:04:07.554"} + + {"volume":992620,"symbol":"SCS","high":16.3200,"low":16.1550,"count":7690,"close":16.1800,"open":16.2000,"timestamp":"2025-08-20T16:22:32.726"}' + + /stock/snapshot/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: stock_snapshot_trade + tags: + - Stock + - Snapshot + description: | + + Returns a real-time last trade from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a weekend where there were no eligible messages sent over exchange feeds. We recommend using historic requests during the weekend. + x-sample-urls: + - url: http://localhost:25503/v3/stock/snapshot/trade?symbol=AAPL + description: "Returns last trade for stocks for a given symbol" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last trade for stocks for a given symbol + content: + text/csv: + schema: + type: array + items: &id007 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + size: + type: integer + description: The amount of contracts / shares traded. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + price: + type: number + description: The trade price. + example: "timestamp,symbol,sequence,size,condition,price\r\n2025-08-20T16:36:05.549,AAPL,63539137,23,1,225.7500\r\ + \n" + application/json: + schema: &id008 + type: array + items: *id007 + example: + symbol: + - AAPL + sequence: + - 63539137 + condition: + - 1 + size: + - 23 + price: + - 225.75 + timestamp: + - '2025-08-20T16:36:05.549' + application/x-ndjson: + schema: *id008 + example: '{"symbol":"AAPL","sequence":63539137,"condition":1,"size":23,"price":225.7500,"timestamp":"2025-08-20T16:36:05.549"}' + + /stock/snapshot/quote: + x-min-subscription: value + get: + summary: Quote + operationId: stock_snapshot_quote + tags: + - Stock + - Snapshot + description: | + * Returns a real-time last BBO quote from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed NBBO quote from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a weekend where there were no eligible messages sent over exchange feeds. We recommend using historic requests during the weekend. + x-sample-urls: + - url: http://localhost:25503/v3/stock/snapshot/quote?symbol=* + description: "Returns last quote for stocks for all symbols" + - url: http://localhost:25503/v3/stock/snapshot/quote?symbol=AAPL&venue=nqb + description: "Returns OHLC for a given stock trade from the Nasdaq Basic feed" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last quote for stocks for all symbols + content: + text/csv: + schema: + type: array + items: &id009 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "timestamp,symbol,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \n2025-08-20T16:03:05.142,CVCO,1,29,475.75,0,3,29,494.33,0\r\n2025-08-20T16:10:05.032,KLXY,200,29,12.40,0,200,29,37.18,0\r\ + \n2025-08-20T16:21:05.781,IFRX,100,29,0.7510,0,45,29,0.9500,0\r\n2025-08-20T16:19:55.101,SCS,100,29,14.64,0,100,29,17.60,0\r\ + \n2025-08-20T16:33:50.877,BBC,100,29,13.29,0,2800,29,24.06,0\r\n" + application/json: + schema: &id010 + type: array + items: *id009 + example: + symbol: + - CVCO + - KLXY + - IFRX + - SCS + - BBC + ask_size: + - 3 + - 200 + - 45 + - 100 + - 2800 + bid_size: + - 1 + - 200 + - 100 + - 100 + - 100 + ask_exchange: + - 29 + - 29 + - 29 + - 29 + - 29 + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + bid_exchange: + - 29 + - 29 + - 29 + - 29 + - 29 + ask: + - 494.33 + - 37.18 + - 0.95 + - 17.6 + - 24.06 + bid: + - 475.75 + - 12.4 + - 0.751 + - 14.64 + - 13.29 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + timestamp: + - '2025-08-20T16:03:05.142' + - '2025-08-20T16:10:05.032' + - '2025-08-20T16:21:05.781' + - '2025-08-20T16:19:55.101' + - '2025-08-20T16:33:50.877' + application/x-ndjson: + schema: *id010 + example: '{"symbol":"CVCO","ask_size":3,"bid_size":1,"ask_exchange":29,"ask_condition":0,"bid_exchange":29,"ask":494.33,"bid":475.75,"bid_condition":0,"timestamp":"2025-08-20T16:03:05.142"} + + {"symbol":"KLXY","ask_size":200,"bid_size":200,"ask_exchange":29,"ask_condition":0,"bid_exchange":29,"ask":37.18,"bid":12.40,"bid_condition":0,"timestamp":"2025-08-20T16:10:05.032"} + + {"symbol":"IFRX","ask_size":45,"bid_size":100,"ask_exchange":29,"ask_condition":0,"bid_exchange":29,"ask":0.9500,"bid":0.7510,"bid_condition":0,"timestamp":"2025-08-20T16:21:05.781"} + + {"symbol":"SCS","ask_size":100,"bid_size":100,"ask_exchange":29,"ask_condition":0,"bid_exchange":29,"ask":17.60,"bid":14.64,"bid_condition":0,"timestamp":"2025-08-20T16:19:55.101"} + + {"symbol":"BBC","ask_size":2800,"bid_size":100,"ask_exchange":29,"ask_condition":0,"bid_exchange":29,"ask":24.06,"bid":13.29,"bid_condition":0,"timestamp":"2025-08-20T16:33:50.877"}' + + /stock/history/eod: + x-min-subscription: free + get: + summary: End of Day + operationId: stock_history_eod + tags: + - Stock + - History + description: | + + Since [the equity SIPs](/Articles/Data-And-Requests/The-SIPs.html) only generate a partial EOD report, Theta Data generates a national EOD report at 17:15 ET each day. ``created`` represents the datetime the report was generated and ``last_trade`` represents the datetime of the last trade. The quote in the response represents the last NBBO reported by [CTA or UTP](/Articles/Data-And-Requests/The-SIPs.html) at the time of report generation. You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). Theta Data plans to avail SIP EOD reports in the near future. + x-sample-urls: + - url: http://localhost:25503/v3/stock/history/eod?symbol=AAPL&start_date=20240101&end_date=20240131 + description: "Returns EOD report for a given symbol between specified dates (inclusive)" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for a given symbol between specified dates (inclusive) + content: + text/csv: + schema: + type: array + items: &id011 + type: object + properties: + created: + type: string + format: date-time + description: The date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + last_trade: + type: string + format: date-time + description: The last trade date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "created,last_trade,open,high,low,close,volume,count,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \n2024-01-02T17:17:53.606,2024-01-02T17:17:51.877,187.030,188.440,183.885,185.640,80680243,1003582,2,7,18.534,0,2,1,18.536,0\r\ + \n2024-01-03T17:16:29.883,2024-01-03T17:16:28.586,184.200,185.880,183.430,184.250,58308345,654127,5,7,18.405,0,2,1,18.410,0\r\ + \n2024-01-04T17:17:06.02,2024-01-04T17:17:02.445,182.0000,183.0872,180.8800,181.9100,71197269,709246,8,60,1.8176,0,2,7,1.8179,0\r\ + \n2024-01-05T17:16:57.032,2024-01-05T17:16:49.821,181.900,182.760,180.170,181.180,61949135,679405,3,1,18.103,0,3,7,18.105,0\r\ + \n2024-01-08T17:17:01.83,2024-01-08T17:17:01.484,182.000,185.600,181.500,185.560,59029146,665626,4,1,18.528,0,1,65,18.537,0\r\ + \n" + application/json: + schema: &id012 + type: array + items: *id011 + example: + ask_size: + - 2 + - 2 + - 2 + - 3 + - 1 + last_trade: + - '2024-01-02T17:17:51.877' + - '2024-01-03T17:16:28.586' + - '2024-01-04T17:17:02.445' + - '2024-01-05T17:16:49.821' + - '2024-01-08T17:17:01.484' + created: + - '2024-01-02T17:17:53.606' + - '2024-01-03T17:16:29.883' + - '2024-01-04T17:17:06.02' + - '2024-01-05T17:16:57.032' + - '2024-01-08T17:17:01.83' + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + count: + - 1003582 + - 654127 + - 709246 + - 679405 + - 665626 + volume: + - 80680243 + - 58308345 + - 71197269 + - 61949135 + - 59029146 + high: + - 188.44 + - 185.88 + - 183.0872 + - 182.76 + - 185.6 + low: + - 183.885 + - 183.43 + - 180.88 + - 180.17 + - 181.5 + bid_size: + - 2 + - 5 + - 8 + - 3 + - 4 + ask_exchange: + - 1 + - 1 + - 7 + - 7 + - 65 + bid_exchange: + - 7 + - 7 + - 60 + - 1 + - 1 + ask: + - 18.536 + - 18.41 + - 1.8179 + - 18.105 + - 18.537 + bid: + - 18.534 + - 18.405 + - 1.8176 + - 18.103 + - 18.528 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + close: + - 185.64 + - 184.25 + - 181.91 + - 181.18 + - 185.56 + open: + - 187.03 + - 184.2 + - 182.0 + - 181.9 + - 182.0 + application/x-ndjson: + schema: *id012 + example: '{"ask_size":2,"last_trade":"2024-01-02T17:17:51.877","created":"2024-01-02T17:17:53.606","ask_condition":0,"count":1003582,"volume":80680243,"high":188.440,"low":183.885,"bid_size":2,"ask_exchange":1,"bid_exchange":7,"ask":18.536,"bid":18.534,"bid_condition":0,"close":185.640,"open":187.030} + + {"ask_size":2,"last_trade":"2024-01-03T17:16:28.586","created":"2024-01-03T17:16:29.883","ask_condition":0,"count":654127,"volume":58308345,"high":185.880,"low":183.430,"bid_size":5,"ask_exchange":1,"bid_exchange":7,"ask":18.410,"bid":18.405,"bid_condition":0,"close":184.250,"open":184.200} + + {"ask_size":2,"last_trade":"2024-01-04T17:17:02.445","created":"2024-01-04T17:17:06.02","ask_condition":0,"count":709246,"volume":71197269,"high":183.0872,"low":180.8800,"bid_size":8,"ask_exchange":7,"bid_exchange":60,"ask":1.8179,"bid":1.8176,"bid_condition":0,"close":181.9100,"open":182.0000} + + {"ask_size":3,"last_trade":"2024-01-05T17:16:49.821","created":"2024-01-05T17:16:57.032","ask_condition":0,"count":679405,"volume":61949135,"high":182.760,"low":180.170,"bid_size":3,"ask_exchange":7,"bid_exchange":1,"ask":18.105,"bid":18.103,"bid_condition":0,"close":181.180,"open":181.900} + + {"ask_size":1,"last_trade":"2024-01-08T17:17:01.484","created":"2024-01-08T17:17:01.83","ask_condition":0,"count":665626,"volume":59029146,"high":185.600,"low":181.500,"bid_size":4,"ask_exchange":65,"bid_exchange":1,"ask":18.537,"bid":18.528,"bid_condition":0,"close":185.560,"open":182.000}' + + /stock/history/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: stock_history_ohlc + tags: + - Stock + - History + description: | + Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: ``bar time`` <= ``trade time`` < ``bar timestamp + ivl``, where ivl is the specified interval size in milliseconds. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: http://localhost:25503/v3/stock/history/ohlc?symbol=AAPL&date=20240102&interval=1m + description: "Returns OHLC for a given symbol between specified dates (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given symbol between specified dates (inclusive) with a one minute interval + content: + text/csv: + schema: + type: array + items: &id013 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + vwap: + type: number + description: The volume weighted average price of the given interval. + example: "timestamp,open,high,low,close,volume,count,vwap\r\n2024-01-02T09:30:00,187.1500,188.050,186.350,187.830,3256708,37886,187.25\r\ + \n2024-01-02T09:31:00,187.830,188.120,187.630,187.765,809707,7481,187.38\r\n2024-01-02T09:32:00,187.770,188.440,187.730,188.2984,687086,7103,187.48\r\ + \n2024-01-02T09:33:00,188.3050,188.310,187.810,188.160,485275,6245,187.53\r\n2024-01-02T09:34:00,188.150,188.150,187.670,187.730,415948,5942,187.55\r\ + \n" + application/json: + schema: &id014 + type: array + items: *id013 + example: + volume: + - 3256708 + - 809707 + - 687086 + - 485275 + - 415948 + high: + - 188.05 + - 188.12 + - 188.44 + - 188.31 + - 188.15 + low: + - 186.35 + - 187.63 + - 187.73 + - 187.81 + - 187.67 + vwap: + - 187.25 + - 187.38 + - 187.48 + - 187.53 + - 187.55 + count: + - 37886 + - 7481 + - 7103 + - 6245 + - 5942 + close: + - 187.83 + - 187.765 + - 188.2984 + - 188.16 + - 187.73 + open: + - 187.15 + - 187.83 + - 187.77 + - 188.305 + - 188.15 + timestamp: + - '2024-01-02T09:30:00' + - '2024-01-02T09:31:00' + - '2024-01-02T09:32:00' + - '2024-01-02T09:33:00' + - '2024-01-02T09:34:00' + application/x-ndjson: + schema: *id014 + example: '{"volume":3256708,"high":188.050,"low":186.350,"vwap":187.25,"count":37886,"close":187.830,"open":187.1500,"timestamp":"2024-01-02T09:30:00"} + + {"volume":809707,"high":188.120,"low":187.630,"vwap":187.38,"count":7481,"close":187.765,"open":187.830,"timestamp":"2024-01-02T09:31:00"} + + {"volume":687086,"high":188.440,"low":187.730,"vwap":187.48,"count":7103,"close":188.2984,"open":187.770,"timestamp":"2024-01-02T09:32:00"} + + {"volume":485275,"high":188.310,"low":187.810,"vwap":187.53,"count":6245,"close":188.160,"open":188.3050,"timestamp":"2024-01-02T09:33:00"} + + {"volume":415948,"high":188.150,"low":187.670,"vwap":187.55,"count":5942,"close":187.730,"open":188.150,"timestamp":"2024-01-02T09:34:00"}' + + /stock/history/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: stock_history_trade + tags: + - Stock + - History + description: | + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs). Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: http://localhost:25503/v3/stock/history/trade?symbol=AAPL&date=20240102 + description: "Returns every trade for a given symbol between specified dates (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade for a given symbol between specified dates (inclusive) with a one minute interval + content: + text/csv: + schema: + type: array + items: &id015 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + example: "timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price\r\ + \n2024-01-02T09:30:00.011,14920,32,95,1,115,1,2,7,187.1800\r\n2024-01-02T09:30:00.014,8931,32,255,1,115,1,1,1,187.1800\r\ + \n2024-01-02T09:30:00.014,8932,32,255,1,115,1,5,1,187.1800\r\n2024-01-02T09:30:00.014,8933,32,255,1,115,1,3,1,187.1900\r\ + \n2024-01-02T09:30:00.014,8934,32,255,1,115,1,91,1,187.1900\r\n" + application/x-ndjson: + schema: + type: array + items: *id015 + example: '{"sequence":14920,"condition":1,"size":2,"price":187.1800,"ext_condition2":95,"ext_condition1":32,"ext_condition4":115,"exchange":7,"ext_condition3":1,"timestamp":"2024-01-02T09:30:00.011"} + + {"sequence":8931,"condition":1,"size":1,"price":187.1800,"ext_condition2":255,"ext_condition1":32,"ext_condition4":115,"exchange":1,"ext_condition3":1,"timestamp":"2024-01-02T09:30:00.014"} + + {"sequence":8932,"condition":1,"size":5,"price":187.1800,"ext_condition2":255,"ext_condition1":32,"ext_condition4":115,"exchange":1,"ext_condition3":1,"timestamp":"2024-01-02T09:30:00.014"} + + {"sequence":8933,"condition":1,"size":3,"price":187.1900,"ext_condition2":255,"ext_condition1":32,"ext_condition4":115,"exchange":1,"ext_condition3":1,"timestamp":"2024-01-02T09:30:00.014"} + + {"sequence":8934,"condition":1,"size":91,"price":187.1900,"ext_condition2":255,"ext_condition1":32,"ext_condition4":115,"exchange":1,"ext_condition3":1,"timestamp":"2024-01-02T09:30:00.014"}' + + /stock/history/quote: + x-min-subscription: value + get: + summary: Quote + operationId: stock_history_quote + tags: + - Stock + - History + description: | + Returns every NBBO quote reported by [UTP and CTA](/Articles/Data-And-Requests/The-SIPs). If the ``interval`` parameter is specified, the quote for each interval represents the last quote prior to the interval's timestamp. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: http://localhost:25503/v3/stock/history/quote?symbol=AAPL&date=20240102&interval=1m + description: "Returns every quote for a given symbol between specified dates (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every quote for a given symbol between specified dates (inclusive) with a one minute interval + content: + text/csv: + schema: + type: array + items: &id016 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "timestamp,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\n2024-01-02T09:30:00,30,7,187.10,0,1,1,187.20,0\r\ + \n2024-01-02T09:31:00,2,1,187.83,0,4,1,187.86,0\r\n2024-01-02T09:32:00,2,60,187.74,0,1,73,187.77,0\r\n2024-01-02T09:33:00,2,60,188.29,0,2,73,188.32,0\r\ + \n2024-01-02T09:34:00,5,1,188.14,0,2,7,188.16,0\r\n" + application/json: + schema: &id017 + type: array + items: *id016 + example: + ask_size: + - 1 + - 4 + - 1 + - 2 + - 2 + bid_size: + - 30 + - 2 + - 2 + - 2 + - 5 + ask_exchange: + - 1 + - 1 + - 73 + - 73 + - 7 + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + bid_exchange: + - 7 + - 1 + - 60 + - 60 + - 1 + ask: + - 187.2 + - 187.86 + - 187.77 + - 188.32 + - 188.16 + bid: + - 187.1 + - 187.83 + - 187.74 + - 188.29 + - 188.14 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + timestamp: + - '2024-01-02T09:30:00' + - '2024-01-02T09:31:00' + - '2024-01-02T09:32:00' + - '2024-01-02T09:33:00' + - '2024-01-02T09:34:00' + application/x-ndjson: + schema: *id017 + example: '{"ask_size":1,"bid_size":30,"ask_exchange":1,"ask_condition":0,"bid_exchange":7,"ask":187.20,"bid":187.10,"bid_condition":0,"timestamp":"2024-01-02T09:30:00"} + + {"ask_size":4,"bid_size":2,"ask_exchange":1,"ask_condition":0,"bid_exchange":1,"ask":187.86,"bid":187.83,"bid_condition":0,"timestamp":"2024-01-02T09:31:00"} + + {"ask_size":1,"bid_size":2,"ask_exchange":73,"ask_condition":0,"bid_exchange":60,"ask":187.77,"bid":187.74,"bid_condition":0,"timestamp":"2024-01-02T09:32:00"} + + {"ask_size":2,"bid_size":2,"ask_exchange":73,"ask_condition":0,"bid_exchange":60,"ask":188.32,"bid":188.29,"bid_condition":0,"timestamp":"2024-01-02T09:33:00"} + + {"ask_size":2,"bid_size":5,"ask_exchange":7,"ask_condition":0,"bid_exchange":1,"ask":188.16,"bid":188.14,"bid_condition":0,"timestamp":"2024-01-02T09:34:00"}' + + /stock/history/trade_quote: + x-min-subscription: standard + get: + summary: Trade Quote + operationId: stock_history_trade_quote + tags: + - Stock + - History + description: | + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs) paired with the last BBO quote reported by [UTP or CTA](/Articles/Data-And-Requests/The-SIPs) at the time of trade. A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. If you prefer to match quotes with timestamps that are ``<`` the trade timestamp, specify the ``exclusive`` parameter to ``true``. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + x-sample-urls: + - url: http://localhost:25503/v3/stock/history/trade_quote?symbol=AAPL&date=20240102 + description: "Returns every trade quote for a given symbol between specified dates (inclusive)" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/exclusive" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade quote for a given symbol between specified dates (inclusive) + content: + text/csv: + schema: + type: array + items: &id018 + type: object + properties: + trade_timestamp: + type: string + format: date-time + description: The trade date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + quote_timestamp: + type: string + format: date-time + description: The quote date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "trade_timestamp,quote_timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \n2023-01-03T09:30:00.002,2023-01-03T09:30:00.001,562,32,255,255,115,115,1,60,130.3300,4,7,130.2600,0,1,7,130.4000,0\r\ + \n2023-01-03T09:30:00.003,2023-01-03T09:30:00.002,563,32,255,255,115,115,24,60,130.3300,4,7,130.2600,0,1,7,130.4000,0\r\ + \n2023-01-03T09:30:00.003,2023-01-03T09:30:00.002,564,32,255,255,115,115,40,60,130.3300,4,7,130.2600,0,1,7,130.4000,0\r\ + \n2023-01-03T09:30:00.036,2023-01-03T09:30:00.017,6081,32,95,1,115,1,19,1,130.2500,4,7,130.2600,0,1,1,130.3900,0\r\ + \n2023-01-03T09:30:00.057,2023-01-03T09:30:00.017,6082,32,255,1,115,1,30,1,130.2500,4,7,130.2600,0,1,1,130.3900,0\r\ + \n" + application/x-ndjson: + schema: + type: array + items: *id018 + example: '{"ask_size":1,"trade_timestamp":"2023-01-03T09:30:00.002","ask_condition":0,"sequence":562,"condition":115,"size":1,"bid_size":4,"ask_exchange":7,"price":130.3300,"ext_condition2":255,"bid_exchange":7,"ask":130.4000,"quote_timestamp":"2023-01-03T09:30:00.001","ext_condition1":32,"ext_condition4":115,"exchange":60,"ext_condition3":255,"bid":130.2600,"bid_condition":0} + + {"ask_size":1,"trade_timestamp":"2023-01-03T09:30:00.003","ask_condition":0,"sequence":563,"condition":115,"size":24,"bid_size":4,"ask_exchange":7,"price":130.3300,"ext_condition2":255,"bid_exchange":7,"ask":130.4000,"quote_timestamp":"2023-01-03T09:30:00.002","ext_condition1":32,"ext_condition4":115,"exchange":60,"ext_condition3":255,"bid":130.2600,"bid_condition":0} + + {"ask_size":1,"trade_timestamp":"2023-01-03T09:30:00.003","ask_condition":0,"sequence":564,"condition":115,"size":40,"bid_size":4,"ask_exchange":7,"price":130.3300,"ext_condition2":255,"bid_exchange":7,"ask":130.4000,"quote_timestamp":"2023-01-03T09:30:00.002","ext_condition1":32,"ext_condition4":115,"exchange":60,"ext_condition3":255,"bid":130.2600,"bid_condition":0} + + {"ask_size":1,"trade_timestamp":"2023-01-03T09:30:00.036","ask_condition":0,"sequence":6081,"condition":1,"size":19,"bid_size":4,"ask_exchange":1,"price":130.2500,"ext_condition2":95,"bid_exchange":7,"ask":130.3900,"quote_timestamp":"2023-01-03T09:30:00.017","ext_condition1":32,"ext_condition4":115,"exchange":1,"ext_condition3":1,"bid":130.2600,"bid_condition":0} + + {"ask_size":1,"trade_timestamp":"2023-01-03T09:30:00.057","ask_condition":0,"sequence":6082,"condition":1,"size":30,"bid_size":4,"ask_exchange":1,"price":130.2500,"ext_condition2":255,"bid_exchange":7,"ask":130.3900,"quote_timestamp":"2023-01-03T09:30:00.017","ext_condition1":32,"ext_condition4":115,"exchange":1,"ext_condition3":1,"bid":130.2600,"bid_condition":0}' + + /stock/at_time/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: stock_at_time_trade + tags: + - Stock + - At-Time + description: | + #### Real-time request: + - Returns a real-time session from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + - Returns a 15-minute delayed session from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last trade reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) at a specified millisecond of the day. + Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + x-sample-urls: + - url: http://localhost:25503/v3/stock/at_time/trade?symbol=SPY&start_date=20240116&end_date=20240116&time_of_day=09:30:00.100 + description: "Returns the last trade for a given symbol and specified time of day" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last trade for a given symbol and specified time of day + content: + text/csv: + schema: + type: array + items: &id019 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + example: "timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price\r\ + \n2024-01-16T09:30:00.088,405549,255,255,255,115,115,1,57,475.280\r\n" + application/json: + schema: &id020 + type: array + items: *id019 + example: + sequence: + - 405549 + condition: + - 115 + size: + - 1 + price: + - 475.28 + ext_condition2: + - 255 + ext_condition1: + - 255 + ext_condition4: + - 115 + exchange: + - 57 + ext_condition3: + - 255 + timestamp: + - '2024-01-16T09:30:00.088' + application/x-ndjson: + schema: *id020 + example: '{"sequence":405549,"condition":115,"size":1,"price":475.280,"ext_condition2":255,"ext_condition1":255,"ext_condition4":115,"exchange":57,"ext_condition3":255,"timestamp":"2024-01-16T09:30:00.088"}' + + /stock/at_time/quote: + x-min-subscription: value + get: + summary: Quote + operationId: stock_at_time_quote + tags: + - Stock + - At-Time + description: | + #### Real-time request: + - Subscription tier standard or higher will default to NQB. + - Real-time last BBO quote at-time_of_day-time from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + - 15-minute delayed NBBO quote at-time_of_day-time from the [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last NBBO quote reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The-SIPs.html#equities-cta-utp) at a specified millisecond of the day. + x-sample-urls: + - url: http://localhost:25503/v3/stock/at_time/quote?symbol=SPY&start_date=20240116&end_date=20240116&time_of_day=09:30:00.100 + description: "Returns the last quote for a given symbol between specified dates (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/venue" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last quote for a given symbol between specified dates (inclusive) with a one minute interval + content: + text/csv: + schema: + type: array + items: &id021 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "timestamp,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\n2024-01-16T09:30:00.1,15,1,475.28,0,8,7,475.28,0\r\ + \n" + application/json: + schema: &id022 + type: array + items: *id021 + example: + ask_size: + - 8 + bid_size: + - 15 + ask_exchange: + - 7 + ask_condition: + - 0 + bid_exchange: + - 1 + ask: + - 475.28 + bid: + - 475.28 + bid_condition: + - 0 + timestamp: + - '2024-01-16T09:30:00.1' + application/x-ndjson: + schema: *id022 + example: '{"ask_size":8,"bid_size":15,"ask_exchange":7,"ask_condition":0,"bid_exchange":1,"ask":475.28,"bid":475.28,"bid_condition":0,"timestamp":"2024-01-16T09:30:00.1"}' + +# +# OPTIONS ENDPOINTS +# + + /option/list/symbols: + x-min-subscription: free + get: + summary: Symbols + operationId: option_list_symbols + tags: + - Option + - List + description: | + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/symbols + description: "List all symbols for options" + parameters: + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all symbols for options + content: + text/csv: + schema: + type: array + items: &id023 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + example: "symbol\r\nA\r\nAA\r\nAAAP\r\nAAAU\r\nAABA\r\n" + application/json: + schema: &id024 + type: array + items: *id023 + example: + symbol: + - A + - AA + - AAAP + - AAAU + - AABA + application/x-ndjson: + schema: *id024 + example: '{"symbol":"A"} + + {"symbol":"AA"} + + {"symbol":"AAAP"} + + {"symbol":"AAAU"} + + {"symbol":"AABA"}' + + /option/list/dates/{request_type}: + x-min-subscription: free + get: + summary: Dates + operationId: option_list_dates + tags: + - Option + - List + description: | + Lists all dates of data that are available for an option with a given symbol, request type, and expiration. + This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/dates/quote?symbol=AAPL&expiration=20220930 + description: "List all dates for an option quote for a given symbol and expiration date" + - url: http://localhost:25503/v3/option/list/dates/trade?symbol=AAPL&expiration=20220930 + description: "List all dates for an option trade for a given symbol with any expiration date" + parameters: + - $ref: "#/components/parameters/request_type" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all dates for an option quote for a given symbol and expiration date + content: + text/csv: + schema: + type: array + items: &id025 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + date: + type: string + format: date + description: The date formated as YYYY-MM-DD. + example: "symbol,expiration,strike,right,date\r\nAAPL,2022-09-30,80.000,CALL,2022-09-16\r\nAAPL,2022-09-30,80.000,CALL,2022-09-19\r\ + \nAAPL,2022-09-30,80.000,CALL,2022-09-12\r\nAAPL,2022-09-30,80.000,CALL,2022-09-13\r\nAAPL,2022-09-30,80.000,CALL,2022-09-14\r\ + \n" + application/json: + schema: &id026 + type: array + items: *id025 + example: + date: + - '2022-09-16' + - '2022-09-19' + - '2022-09-12' + - '2022-09-13' + - '2022-09-14' + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + strike: + - 80.0 + - 80.0 + - 80.0 + - 80.0 + - 80.0 + expiration: + - '2022-09-30' + - '2022-09-30' + - '2022-09-30' + - '2022-09-30' + - '2022-09-30' + right: + - CALL + - CALL + - CALL + - CALL + - CALL + application/x-ndjson: + schema: *id026 + example: '{"date":"2022-09-16","symbol":"AAPL","strike":80.000,"expiration":"2022-09-30","right":"CALL"} + + {"date":"2022-09-19","symbol":"AAPL","strike":80.000,"expiration":"2022-09-30","right":"CALL"} + + {"date":"2022-09-12","symbol":"AAPL","strike":80.000,"expiration":"2022-09-30","right":"CALL"} + + {"date":"2022-09-13","symbol":"AAPL","strike":80.000,"expiration":"2022-09-30","right":"CALL"} + + {"date":"2022-09-14","symbol":"AAPL","strike":80.000,"expiration":"2022-09-30","right":"CALL"}' + + /option/list/expirations: + x-min-subscription: free + get: + summary: Expirations + operationId: option_list_expirations + tags: + - Option + - List + description: | + Lists all dates of expirations that are available for an option with a given symbol. + This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/expirations?symbol=AAPL + description: "List all expirations for an option with a given symbol" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all expirations for an option with a given symbol + content: + text/csv: + schema: + type: array + items: &id027 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + example: "symbol,expiration\r\nAAPL,2012-06-01\r\nAAPL,2012-06-08\r\nAAPL,2012-06-16\r\nAAPL,2012-06-22\r\n\ + AAPL,2012-06-29\r\n" + application/json: + schema: &id028 + type: array + items: *id027 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + expiration: + - '2012-06-01' + - '2012-06-08' + - '2012-06-16' + - '2012-06-22' + - '2012-06-29' + application/x-ndjson: + schema: *id028 + example: '{"symbol":"AAPL","expiration":"2012-06-01"} + + {"symbol":"AAPL","expiration":"2012-06-08"} + + {"symbol":"AAPL","expiration":"2012-06-16"} + + {"symbol":"AAPL","expiration":"2012-06-22"} + + {"symbol":"AAPL","expiration":"2012-06-29"}' + + /option/list/strikes: + x-min-subscription: free + get: + summary: Strikes + operationId: option_list_strikes + tags: + - Option + - List + description: | + Lists all strikes that are available for an option with a given symbol and expiration date. + This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/strikes?symbol=AAPL&expiration=20220930 + description: "List all strikes for an option with a given symbol and expiration date" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all strikes for an option with a given symbol and expiration date + content: + text/csv: + schema: + type: array + items: &id029 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + example: "symbol,strike\r\nAAPL,80.000\r\nAAPL,128.000\r\nAAPL,160.000\r\nAAPL,144.000\r\nAAPL,240.000\r\n" + application/json: + schema: &id030 + type: array + items: *id029 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + strike: + - 80.0 + - 128.0 + - 160.0 + - 144.0 + - 240.0 + application/x-ndjson: + schema: *id030 + example: '{"symbol":"AAPL","strike":80.000} + + {"symbol":"AAPL","strike":128.000} + + {"symbol":"AAPL","strike":160.000} + + {"symbol":"AAPL","strike":144.000} + + {"symbol":"AAPL","strike":240.000}' + + /option/list/contracts/{request_type}: + x-min-subscription: value + get: + summary: Contracts + operationId: option_list_contracts + tags: + - Option + - List + description: | + Lists all contracts that were traded or quoted on a particular date. + + If the ``symbol`` parameter is specified, the returned contracts will be filtered to match the symbol. + Multiple symbols can be specified by separating them with commas such as ``symbol=AAPL,SPY,AMD`` + This endpoint is updated real-time. + x-sample-urls: + - url: http://localhost:25503/v3/option/list/contracts/trade?date=20220930 + description: "List all contracts for an option trade with a given date" + - url: http://localhost:25503/v3/option/list/contracts/quote?symbol=AAPL&date=20220930 + description: "List all contracts for an option quote with a given symbol and date" + parameters: + - $ref: "#/components/parameters/request_type" + - $ref: "#/components/parameters/opt_multi_symbol" + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all contracts for an option trade with a given date + content: + text/csv: + schema: + type: array + items: &id031 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + example: "symbol,expiration,strike,right\r\nABNB,2023-06-16,260.000,CALL\r\nAAPL,2023-06-16,260.000,CALL\r\n\ + AAL,2022-09-30,14.500,CALL\r\nABNB,2022-11-04,80.000,PUT\r\nAAPL,2022-11-04,80.000,PUT\r\n" + application/json: + schema: &id032 + type: array + items: *id031 + example: + symbol: + - ABNB + - AAPL + - AAL + - ABNB + - AAPL + strike: + - 260.0 + - 260.0 + - 14.5 + - 80.0 + - 80.0 + expiration: + - '2023-06-16' + - '2023-06-16' + - '2022-09-30' + - '2022-11-04' + - '2022-11-04' + right: + - CALL + - CALL + - CALL + - PUT + - PUT + application/x-ndjson: + schema: *id032 + example: '{"symbol":"ABNB","strike":260.000,"expiration":"2023-06-16","right":"CALL"} + + {"symbol":"AAPL","strike":260.000,"expiration":"2023-06-16","right":"CALL"} + + {"symbol":"AAL","strike":14.500,"expiration":"2022-09-30","right":"CALL"} + + {"symbol":"ABNB","strike":80.000,"expiration":"2022-11-04","right":"PUT"} + + {"symbol":"AAPL","strike":80.000,"expiration":"2022-11-04","right":"PUT"}' + + /option/snapshot/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: option_snapshot_ohlc + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last ohlc of an option contract for the trading day. + - You might need to change the default expiration date to a different date if it is past the current date. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/ohlc?symbol=AAPL&expiration=20260116&right=call&strike=275.000 + description: "Returns OHLC for a given option contract" + - url: http://localhost:25503/v3/option/snapshot/ohlc?symbol=AAPL&expiration=* + description: "Returns OHLC for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given option contract + content: + text/csv: + schema: + type: array + items: &id033 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + example: "timestamp,symbol,expiration,strike,right,open,high,low,close,volume,count\r\n2025-08-20T15:25:31.03,AAPL,2026-01-16,275.000,CALL,1.78,1.78,1.51,1.51,202,29\r\ + \n" + application/json: + schema: &id034 + type: array + items: *id033 + example: + volume: + - 202 + symbol: + - AAPL + high: + - 1.78 + low: + - 1.51 + strike: + - 275.0 + count: + - 29 + expiration: + - '2026-01-16' + right: + - CALL + close: + - 1.51 + open: + - 1.78 + timestamp: + - '2025-08-20T15:25:31.03' + application/x-ndjson: + schema: *id034 + example: '{"volume":202,"symbol":"AAPL","high":1.78,"low":1.51,"strike":275.000,"count":29,"expiration":"2026-01-16","right":"CALL","close":1.51,"open":1.78,"timestamp":"2025-08-20T15:25:31.03"}' + + /option/snapshot/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: option_snapshot_trade + tags: + - Option + - Snapshot + description: | + - Retrieve the real-time last trade of an option contract. + - You might need to change the default expiration date to a different date if it is past the current date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/trade?symbol=AAPL&expiration=2026-01-16&right=call&strike=275.000 + description: "Returns last trade for an option contract" + - url: http://localhost:25503/v3/option/snapshot/trade?symbol=AAPL&expiration=2026-01-16 + description: "Returns last trade for all option contracts with an expiration of 2026-01-16" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last NBBO quote for an option contract + content: + text/csv: + schema: + type: array + items: &id035 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00.471,18902138,255,255,255,255,130,2,22,3.90\r\n" + application/json: + schema: &id036 + type: array + items: *id035 + example: + symbol: + - AAPL + strike: + - 220.0 + right: + - CALL + sequence: + - 18902138 + condition: + - 130 + size: + - 2 + price: + - 3.9 + ext_condition2: + - 255 + ext_condition1: + - 255 + expiration: + - '2024-11-08' + ext_condition4: + - 255 + exchange: + - 22 + ext_condition3: + - 255 + timestamp: + - '2024-11-04T09:30:00.471' + application/x-ndjson: + schema: *id036 + example: '{"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":18902138,"condition":130,"size":2,"price":3.90,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":22,"ext_condition3":255,"timestamp":"2024-11-04T09:30:00.471"}' + + /option/snapshot/quote: + x-min-subscription: value + get: + summary: Quote + operationId: option_snapshot_quote + tags: + - Option + - Snapshot + description: | + + - Retrieve a real-time last NBBO quote of an option contract. + - You might need to change the default expiration date to a different date if it is past the current date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/quote?symbol=AAPL&expiration=20260116&right=call&strike=275.000 + description: "Returns last NBBO quote for an option contract" + - url: http://localhost:25503/v3/option/snapshot/quote?symbol=AAPL&expiration=* + description: "Returns last NBBO quote for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last NBBO quote for an option contract + content: + text/csv: + schema: + type: array + items: &id104 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "timestamp,symbol,expiration,strike,right,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \n2025-08-20T15:59:59.805,AAPL,2026-01-16,275.000,CALL,5,6,1.47,50,25,6,1.50,50\r\n" + application/json: + schema: &id105 + type: array + items: *id104 + example: + symbol: + - AAPL + ask_size: + - 25 + ask_condition: + - 50 + strike: + - 275.0 + right: + - CALL + bid_size: + - 5 + ask_exchange: + - 6 + bid_exchange: + - 6 + ask: + - 1.5 + expiration: + - '2026-01-16' + bid: + - 1.47 + bid_condition: + - 50 + timestamp: + - '2025-08-20T15:59:59.805' + application/x-ndjson: + schema: *id105 + example: '{"symbol":"AAPL","ask_size":25,"ask_condition":50,"strike":275.000,"right":"CALL","bid_size":5,"ask_exchange":6,"bid_exchange":6,"ask":1.50,"expiration":"2026-01-16","bid":1.47,"bid_condition":50,"timestamp":"2025-08-20T15:59:59.805"}' + + /option/snapshot/open_interest: + x-min-subscription: value + get: + summary: Open Interest + operationId: option_snapshot_open_interest + tags: + - Option + - Snapshot + description: | + - Retrieve the last open interest message of an option contract. + - Open interest is reported around 06:30 ET every morning by OPRA and reflects the open interest at the of the previous trading day. + - You might need to change the default expiration date to a different date if it is past the current date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/open_interest?symbol=AAPL&expiration=20260116&right=call&strike=275.00 + description: "Returns open interest for an option contract" + - url: http://localhost:25503/v3/option/snapshot/open_interest?symbol=AAPL&expiration=* + description: "Returns open interest for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns open interest for an option contract + content: + text/csv: + schema: + type: array + items: &id037 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + open_interest: + type: integer + description: The total amount of outstanding contracts. + example: "timestamp,symbol,expiration,strike,right,open_interest\r\n2025-08-20T06:30:13,AAPL,2026-01-16,275.000,CALL,8066\r\ + \n" + application/json: + schema: &id038 + type: array + items: *id037 + example: + symbol: + - AAPL + strike: + - 275.0 + open_interest: + - 8066 + expiration: + - '2026-01-16' + right: + - CALL + timestamp: + - '2025-08-20T06:30:13' + application/x-ndjson: + schema: *id038 + example: '{"symbol":"AAPL","strike":275.000,"open_interest":8066,"expiration":"2026-01-16","right":"CALL","timestamp":"2025-08-20T06:30:13"}' + + /option/snapshot/greeks/implied_volatility: + x-min-subscription: standard + get: + summary: Implied Volatility + operationId: option_snapshot_greeks_implied_volatility + tags: + - Option + - Snapshot + description: | + Returns implied volatilies calculated using the national best bid, mid, and ask price + of the option respectively. The underlying price represents whatever the last underlying price was at the + ``underlying_timestamp`` field. You can read more about how Thetadata calculates greeks + [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/greeks/implied_volatility?symbol=AAPL&expiration=20260116&strike=275.000&right=call + description: "Returns implied volatility for an option contract" + - url: http://localhost:25503/v3/option/snapshot/greeks/implied_volatility?symbol=AAPL&expiration=* + description: "Returns implied volatility for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns implied volatility for an option contract + content: + text/csv: + schema: + type: array + items: &id039 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: string + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2026-01-16,275.000,CALL,2025-08-20T15:59:59.805,1.47,1.50,0.2142,-0.0003,2025-08-20T16:36:52.257,225.74\r\ + \n" + application/json: + schema: &id040 + type: array + items: *id039 + example: + symbol: + - AAPL + underlying_price: + - 225.74 + strike: + - 275.0 + ask: + - 1.5 + expiration: + - '2026-01-16' + right: + - CALL + implied_vol: + - 0.2142 + bid: + - 1.47 + underlying_timestamp: + - '2025-08-20T16:36:52.257' + iv_error: + - -0.0003 + timestamp: + - '2025-08-20T15:59:59.805' + application/x-ndjson: + schema: *id040 + example: '{"symbol":"AAPL","underlying_price":225.74,"strike":275.000,"ask":1.50,"expiration":"2026-01-16","right":"CALL","implied_vol":0.2142,"bid":1.47,"underlying_timestamp":"2025-08-20T16:36:52.257","iv_error":-0.0003,"timestamp":"2025-08-20T15:59:59.805"}' + + # /option/snapshot/trade_greeks/implied_volatility: + # x-min-subscription: professional + # get: + # operationId: option_snapshot_trade_greeks_implied_volatility + # tags: + # - Option + # - Snapshot + # description: "" + # parameters: + # - $ref: "#/components/parameters/single_symbol" + # - $ref: "#/components/parameters/expiration" + # - $ref: "#/components/parameters/strike" + # - $ref: "#/components/parameters/right" + # - $ref: "#/components/parameters/annual_dividend" + # - $ref: "#/components/parameters/rate_type" + # - $ref: "#/components/parameters/rate_value" + # - $ref: "#/components/parameters/stock_price" + # - $ref: "#/components/parameters/format" + # responses: + # "200": + # $ref: "#/components/responses/200_OK" + + /option/snapshot/greeks/all: + x-min-subscription: professional + get: + summary: All Greeks + operationId: option_snapshot_greeks_all + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/greeks/all?symbol=AAPL&expiration=2026-05-15&strike=170.00&right=call + description: "Returns all greeks for an option contract" + - url: http://localhost:25503/v3/option/snapshot/greeks/all?symbol=AAPL&expiration=* + description: "Returns all greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns all greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id041 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + delta: + type: number + description: The delta. + theta: + type: string + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: string + description: The epsilon. + lambda: + type: number + description: The lambda. + gamma: + type: number + description: The gamma. + vanna: + type: string + description: The vanna. + charm: + type: number + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + vera: + type: number + description: The vera. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: string + description: The color. + ultima: + type: string + description: The ultima. + d1: + type: number + description: The d1. + d2: + type: number + description: The d2. + dual_delta: + type: string + description: The dual delta. + dual_gamma: + type: number + description: The dual gamma. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,delta,theta,vega,rho,epsilon,lambda,gamma,vanna,charm,vomma,veta,vera,speed,zomma,color,ultima,d1,d2,dual_delta,dual_gamma,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2026-05-15,170.000,CALL,2025-08-20T15:59:59.677,63.65,64.25,0.9085,-0.0352,31.7235,103.2513,-150.0314,3.2071,0.0027,-0.5710,0.0925,146.8562,22.9525,0.0000,0.0000,0.0000,-0.0816,-100.0000,1.3319,1.0689,-0.8302,0.0003,0.3075,0.0000,2025-08-20T16:36:52.257,225.74\r\ + \n" + application/json: + schema: &id042 + type: array + items: *id041 + example: + symbol: + - AAPL + dual_delta: + - -0.8302 + color: + - -0.0816 + zomma: + - 0.0 + delta: + - 0.9085 + implied_vol: + - 0.3075 + theta: + - -0.0352 + d1: + - 1.3319 + speed: + - 0.0 + d2: + - 1.0689 + epsilon: + - -150.0314 + lambda: + - 3.2071 + vomma: + - 146.8562 + underlying_timestamp: + - '2025-08-20T16:36:52.257' + timestamp: + - '2025-08-20T15:59:59.677' + underlying_price: + - 225.74 + strike: + - 170.0 + vera: + - 0.0 + right: + - CALL + veta: + - 22.9525 + iv_error: + - 0.0 + ultima: + - -100.0 + charm: + - 0.0925 + ask: + - 64.25 + rho: + - 103.2513 + expiration: + - '2026-05-15' + vanna: + - -0.571 + dual_gamma: + - 0.0003 + bid: + - 63.65 + vega: + - 31.7235 + gamma: + - 0.0027 + application/x-ndjson: + schema: *id042 + example: '{"symbol":"AAPL","dual_delta":-0.8302,"color":-0.0816,"zomma":0.0000,"delta":0.9085,"implied_vol":0.3075,"theta":-0.0352,"d1":1.3319,"speed":0.0000,"d2":1.0689,"epsilon":-150.0314,"lambda":3.2071,"vomma":146.8562,"underlying_timestamp":"2025-08-20T16:36:52.257","timestamp":"2025-08-20T15:59:59.677","underlying_price":225.74,"strike":170.000,"vera":0.0000,"right":"CALL","veta":22.9525,"iv_error":0.0000,"ultima":-100.0000,"charm":0.0925,"ask":64.25,"rho":103.2513,"expiration":"2026-05-15","vanna":-0.5710,"dual_gamma":0.0003,"bid":63.65,"vega":31.7235,"gamma":0.0027}' + + # /option/snapshot/trade_greeks/all: + # x-min-subscription: professional + # get: + # operationId: option_snapshot_trade_greeks_all + # tags: + # - Option + # - Snapshot + # description: "" + # parameters: + # - $ref: "#/components/parameters/single_symbol" + # - $ref: "#/components/parameters/expiration" + # - $ref: "#/components/parameters/strike" + # - $ref: "#/components/parameters/right" + # - $ref: "#/components/parameters/annual_dividend" + # - $ref: "#/components/parameters/rate_type" + # - $ref: "#/components/parameters/rate_value" + # - $ref: "#/components/parameters/stock_price" + # - $ref: "#/components/parameters/format" + # responses: + # "200": + # $ref: "#/components/responses/200_OK" + + /option/snapshot/greeks/first_order: + x-min-subscription: standard + get: + summary: First Order Greeks + operationId: option_snapshot_greeks_first_order + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/greeks/first_order?symbol=AAPL&expiration=20260116&strike=275.000&right=call + description: "Returns first order greeks for an option contract" + - url: http://localhost:25503/v3/option/snapshot/greeks/first_order?symbol=AAPL&expiration=* + description: "Returns first order greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns first order greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id043 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + delta: + type: number + description: The delta. + theta: + type: string + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: string + description: The epsilon. + lambda: + type: number + description: The lambda. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: string + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,delta,theta,vega,rho,epsilon,lambda,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2026-01-16,275.000,CALL,2025-08-20T15:59:59.805,1.47,1.50,0.1060,-0.0217,26.3226,9.1050,-9.7049,16.1782,0.2142,-0.0003,2025-08-20T16:37:06.988,225.74\r\ + \n" + application/json: + schema: &id044 + type: array + items: *id043 + example: + symbol: + - AAPL + underlying_price: + - 225.74 + strike: + - 275.0 + delta: + - 0.106 + right: + - CALL + implied_vol: + - 0.2142 + theta: + - -0.0217 + iv_error: + - -0.0003 + epsilon: + - -9.7049 + lambda: + - 16.1782 + ask: + - 1.5 + rho: + - 9.105 + expiration: + - '2026-01-16' + bid: + - 1.47 + underlying_timestamp: + - '2025-08-20T16:37:06.988' + vega: + - 26.3226 + timestamp: + - '2025-08-20T15:59:59.805' + application/x-ndjson: + schema: *id044 + example: '{"symbol":"AAPL","underlying_price":225.74,"strike":275.000,"delta":0.1060,"right":"CALL","implied_vol":0.2142,"theta":-0.0217,"iv_error":-0.0003,"epsilon":-9.7049,"lambda":16.1782,"ask":1.50,"rho":9.1050,"expiration":"2026-01-16","bid":1.47,"underlying_timestamp":"2025-08-20T16:37:06.988","vega":26.3226,"timestamp":"2025-08-20T15:59:59.805"}' + + # /option/snapshot/trade_greeks/first_order: + # x-min-subscription: professional + # get: + # operationId: option_snapshot_trade_greeks_first_order + # tags: + # - Option + # - Snapshot + # description: "" + # parameters: + # - $ref: "#/components/parameters/single_symbol" + # - $ref: "#/components/parameters/expiration" + # - $ref: "#/components/parameters/strike" + # - $ref: "#/components/parameters/right" + # - $ref: "#/components/parameters/annual_dividend" + # - $ref: "#/components/parameters/rate_type" + # - $ref: "#/components/parameters/rate_value" + # - $ref: "#/components/parameters/stock_price" + # - $ref: "#/components/parameters/format" + # responses: + # "200": + # $ref: "#/components/responses/200_OK" + + /option/snapshot/greeks/second_order: + x-min-subscription: professional + get: + summary: Second Order Greeks + operationId: option_snapshot_greeks_second_order + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last second order greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/greeks/second_order?symbol=AAPL&expiration=20260116&strike=275.00 + description: "Returns second order greeks for an option contract" + - url: http://localhost:25503/v3/option/snapshot/greeks/second_order?symbol=AAPL&expiration=* + description: "Returns second order greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns second order greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id045 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + gamma: + type: number + description: The gamma. + vanna: + type: number + description: The vanna. + charm: + type: string + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: string + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,gamma,vanna,charm,vomma,veta,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2026-01-16,275.000,CALL,2025-08-20T15:59:59.805,1.47,1.50,0.0059,1.1833,-0.3716,212.2670,18.8522,0.2142,-0.0003,2025-08-20T16:37:06.988,225.74\r\ + \nAAPL,2026-01-16,275.000,PUT,2025-08-20T15:59:59.839,48.75,49.70,0.0064,0.9320,-0.4210,108.3415,18.2234,0.3106,0.0000,2025-08-20T16:37:06.988,225.74\r\ + \n" + application/json: + schema: &id046 + type: array + items: *id045 + example: + symbol: + - AAPL + - AAPL + underlying_price: + - 225.74 + - 225.74 + strike: + - 275.0 + - 275.0 + right: + - CALL + - PUT + veta: + - 18.8522 + - 18.2234 + implied_vol: + - 0.2142 + - 0.3106 + iv_error: + - -0.0003 + - 0.0 + charm: + - -0.3716 + - -0.421 + ask: + - 1.5 + - 49.7 + expiration: + - '2026-01-16' + - '2026-01-16' + vanna: + - 1.1833 + - 0.932 + vomma: + - 212.267 + - 108.3415 + bid: + - 1.47 + - 48.75 + underlying_timestamp: + - '2025-08-20T16:37:06.988' + - '2025-08-20T16:37:06.988' + gamma: + - 0.0059 + - 0.0064 + timestamp: + - '2025-08-20T15:59:59.805' + - '2025-08-20T15:59:59.839' + application/x-ndjson: + schema: *id046 + example: '{"symbol":"AAPL","underlying_price":225.74,"strike":275.000,"right":"CALL","veta":18.8522,"implied_vol":0.2142,"iv_error":-0.0003,"charm":-0.3716,"ask":1.50,"expiration":"2026-01-16","vanna":1.1833,"vomma":212.2670,"bid":1.47,"underlying_timestamp":"2025-08-20T16:37:06.988","gamma":0.0059,"timestamp":"2025-08-20T15:59:59.805"} + + {"symbol":"AAPL","underlying_price":225.74,"strike":275.000,"right":"PUT","veta":18.2234,"implied_vol":0.3106,"iv_error":0.0000,"charm":-0.4210,"ask":49.70,"expiration":"2026-01-16","vanna":0.9320,"vomma":108.3415,"bid":48.75,"underlying_timestamp":"2025-08-20T16:37:06.988","gamma":0.0064,"timestamp":"2025-08-20T15:59:59.839"}' + + # /option/snapshot/trade_greeks/second_order: + # x-min-subscription: professional + # get: + # operationId: option_snapshot_trade_greeks_second_order + # tags: + # - Option + # - Snapshot + # description: "" + # parameters: + # - $ref: "#/components/parameters/single_symbol" + # - $ref: "#/components/parameters/expiration" + # - $ref: "#/components/parameters/strike" + # - $ref: "#/components/parameters/right" + # - $ref: "#/components/parameters/annual_dividend" + # - $ref: "#/components/parameters/rate_type" + # - $ref: "#/components/parameters/rate_value" + # - $ref: "#/components/parameters/stock_price" + # - $ref: "#/components/parameters/format" + # responses: + # "200": + # $ref: "#/components/responses/200_OK" + + /option/snapshot/greeks/third_order: + x-min-subscription: professional + get: + summary: Third Order Greeks + operationId: option_snapshot_greeks_third_order + tags: + - Option + - Snapshot + description: | + - Retrieve a real-time last third order greeks calculation for all option contracts that lie on a provided expiration. + - You might need to change the default expiration date to a different date if it is past the current date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the snapshot cache at midnight ET every night. + x-sample-urls: + - url: http://localhost:25503/v3/option/snapshot/greeks/third_order?symbol=AAPL&expiration=20260116&strike=275.00 + description: "Returns third order greeks for an option contract" + - url: http://localhost:25503/v3/option/snapshot/greeks/third_order?symbol=AAPL&expiration=* + description: "Returns third order greeks for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/stock_price" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns third order greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id047 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: string + description: The color. + ultima: + type: string + description: The ultima. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: string + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,speed,zomma,color,ultima,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2026-01-16,275.000,CALL,2025-08-20T15:59:59.805,1.47,1.50,0.0000,0.0000,-0.3832,-100.0000,0.2142,-0.0003,2025-08-20T16:37:06.988,225.74\r\ + \nAAPL,2026-01-16,275.000,PUT,2025-08-20T15:59:59.839,48.75,49.70,0.0000,0.0000,-1.8378,-100.0000,0.3106,0.0000,2025-08-20T16:37:06.988,225.74\r\ + \n" + application/json: + schema: &id048 + type: array + items: *id047 + example: + symbol: + - AAPL + - AAPL + underlying_price: + - 225.74 + - 225.74 + color: + - -0.3832 + - -1.8378 + strike: + - 275.0 + - 275.0 + zomma: + - 0.0 + - 0.0 + right: + - CALL + - PUT + implied_vol: + - 0.2142 + - 0.3106 + iv_error: + - -0.0003 + - 0.0 + speed: + - 0.0 + - 0.0 + ultima: + - -100.0 + - -100.0 + ask: + - 1.5 + - 49.7 + expiration: + - '2026-01-16' + - '2026-01-16' + bid: + - 1.47 + - 48.75 + underlying_timestamp: + - '2025-08-20T16:37:06.988' + - '2025-08-20T16:37:06.988' + timestamp: + - '2025-08-20T15:59:59.805' + - '2025-08-20T15:59:59.839' + application/x-ndjson: + schema: *id048 + example: '{"symbol":"AAPL","underlying_price":225.74,"color":-0.3832,"strike":275.000,"zomma":0.0000,"right":"CALL","implied_vol":0.2142,"iv_error":-0.0003,"speed":0.0000,"ultima":-100.0000,"ask":1.50,"expiration":"2026-01-16","bid":1.47,"underlying_timestamp":"2025-08-20T16:37:06.988","timestamp":"2025-08-20T15:59:59.805"} + + {"symbol":"AAPL","underlying_price":225.74,"color":-1.8378,"strike":275.000,"zomma":0.0000,"right":"PUT","implied_vol":0.3106,"iv_error":0.0000,"speed":0.0000,"ultima":-100.0000,"ask":49.70,"expiration":"2026-01-16","bid":48.75,"underlying_timestamp":"2025-08-20T16:37:06.988","timestamp":"2025-08-20T15:59:59.839"}' + + # /option/snapshot/trade_greeks/third_order: + # x-min-subscription: professional + # get: + # operationId: option_snapshot_trade_greeks_third_order + # tags: + # - Option + # - Snapshot + # description: "" + # parameters: + # - $ref: "#/components/parameters/single_symbol" + # - $ref: "#/components/parameters/expiration" + # - $ref: "#/components/parameters/strike" + # - $ref: "#/components/parameters/right" + # - $ref: "#/components/parameters/annual_dividend" + # - $ref: "#/components/parameters/rate_type" + # - $ref: "#/components/parameters/rate_value" + # - $ref: "#/components/parameters/stock_price" + # - $ref: "#/components/parameters/format" + # responses: + # "200": + # $ref: "#/components/responses/200_OK" + + /option/history/eod: + x-min-subscription: free + get: + summary: End of Day + operationId: option_history_eod + tags: + - Option + - History + description: | + - Since [OPRA](/Articles/Data-And-Requests/The-SIPs.html) does not provide a national EOD report for options, Thetadata generates a national EOD report at 17:15 ET each day. + - ``created`` represents the datetime the report was generated and ``last_trade`` represents the datetime of the last trade. + - The quote in the response represents the last NBBO reported by OPRA at the time of report generation. + - You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We will expose further history for the EOD quote in the near future. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/eod?symbol=AAPL&expiration=20241115&strike=170.000&right=call&start_date=20241104&end_date=20241104 + description: "Returns EOD report for an option contract" + - url: http://localhost:25503/v3/option/history/eod?symbol=AAPL&expiration=*&start_date=20241104&end_date=20241104 + description: "Returns EOD report for all option contracts" + parameters: + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for an option contract + content: + text/csv: + schema: + type: array + items: &id049 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + created: + type: string + format: date-time + description: The date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + last_trade: + type: string + format: date-time + description: The last trade date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "symbol,expiration,strike,right,created,last_trade,open,high,low,close,volume,count,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \nAAPL,2024-11-15,170.000,CALL,2024-11-04T17:16:56.205,2024-11-04T15:48:12.005,52.54,52.75,52.40,52.40,10,3,70,60,52.05,50,15,47,52.45,50\r\ + \n" + application/json: + schema: &id050 + type: array + items: *id049 + example: + symbol: + - AAPL + ask_size: + - 15 + last_trade: + - '2024-11-04T15:48:12.005' + created: + - '2024-11-04T17:16:56.205' + ask_condition: + - 50 + strike: + - 170.0 + count: + - 3 + right: + - CALL + volume: + - 10 + high: + - 52.75 + low: + - 52.4 + bid_size: + - 70 + ask_exchange: + - 47 + bid_exchange: + - 60 + ask: + - 52.45 + expiration: + - '2024-11-15' + bid: + - 52.05 + bid_condition: + - 50 + close: + - 52.4 + open: + - 52.54 + application/x-ndjson: + schema: *id050 + example: '{"symbol":"AAPL","ask_size":15,"last_trade":"2024-11-04T15:48:12.005","created":"2024-11-04T17:16:56.205","ask_condition":50,"strike":170.000,"count":3,"right":"CALL","volume":10,"high":52.75,"low":52.40,"bid_size":70,"ask_exchange":47,"bid_exchange":60,"ask":52.45,"expiration":"2024-11-15","bid":52.05,"bid_condition":50,"close":52.40,"open":52.54}' + + /option/history/ohlc: + x-min-subscription: value + get: + summary: Open High Low Close + operationId: option_history_ohlc + tags: + - Option + - History + description: | + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/ohlc?symbol=AAPL&expiration=20231103&strike=170.000&right=call&date=20231103&interval=1m + description: "Returns OHLC for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for an option contract + content: + text/csv: + schema: + type: array + items: &id051 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + vwap: + type: number + description: The volume weighted average price of the given interval. + example: "symbol,expiration,strike,right,timestamp,open,high,low,close,volume,count,vwap\r\nAAPL,2023-11-03,170.000,CALL,2023-11-03T09:30:00,4.48,7.05,3.60,4.00,147,24,4.39\r\ + \nAAPL,2023-11-03,170.000,CALL,2023-11-03T09:31:00,3.85,4.65,3.65,4.65,39,19,4.31\r\nAAPL,2023-11-03,170.000,CALL,2023-11-03T09:32:00,4.75,5.20,4.65,5.00,45,14,4.45\r\ + \nAAPL,2023-11-03,170.000,CALL,2023-11-03T09:33:00,4.95,5.05,4.48,4.49,142,23,4.53\r\nAAPL,2023-11-03,170.000,CALL,2023-11-03T09:34:00,4.50,5.05,4.50,4.73,29,11,4.56\r\ + \n" + application/json: + schema: &id052 + type: array + items: *id051 + example: + volume: + - 147 + - 39 + - 45 + - 142 + - 29 + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + high: + - 7.05 + - 4.65 + - 5.2 + - 5.05 + - 5.05 + low: + - 3.6 + - 3.65 + - 4.65 + - 4.48 + - 4.5 + strike: + - 170.0 + - 170.0 + - 170.0 + - 170.0 + - 170.0 + vwap: + - 4.39 + - 4.31 + - 4.45 + - 4.53 + - 4.56 + count: + - 24 + - 19 + - 14 + - 23 + - 11 + expiration: + - '2023-11-03' + - '2023-11-03' + - '2023-11-03' + - '2023-11-03' + - '2023-11-03' + right: + - CALL + - CALL + - CALL + - CALL + - CALL + close: + - 4.0 + - 4.65 + - 5.0 + - 4.49 + - 4.73 + open: + - 4.48 + - 3.85 + - 4.75 + - 4.95 + - 4.5 + timestamp: + - '2023-11-03T09:30:00' + - '2023-11-03T09:31:00' + - '2023-11-03T09:32:00' + - '2023-11-03T09:33:00' + - '2023-11-03T09:34:00' + application/x-ndjson: + schema: *id052 + example: '{"volume":147,"symbol":"AAPL","high":7.05,"low":3.60,"strike":170.000,"vwap":4.39,"count":24,"expiration":"2023-11-03","right":"CALL","close":4.00,"open":4.48,"timestamp":"2023-11-03T09:30:00"} + + {"volume":39,"symbol":"AAPL","high":4.65,"low":3.65,"strike":170.000,"vwap":4.31,"count":19,"expiration":"2023-11-03","right":"CALL","close":4.65,"open":3.85,"timestamp":"2023-11-03T09:31:00"} + + {"volume":45,"symbol":"AAPL","high":5.20,"low":4.65,"strike":170.000,"vwap":4.45,"count":14,"expiration":"2023-11-03","right":"CALL","close":5.00,"open":4.75,"timestamp":"2023-11-03T09:32:00"} + + {"volume":142,"symbol":"AAPL","high":5.05,"low":4.48,"strike":170.000,"vwap":4.53,"count":23,"expiration":"2023-11-03","right":"CALL","close":4.49,"open":4.95,"timestamp":"2023-11-03T09:33:00"} + + {"volume":29,"symbol":"AAPL","high":5.05,"low":4.50,"strike":170.000,"vwap":4.56,"count":11,"expiration":"2023-11-03","right":"CALL","close":4.73,"open":4.50,"timestamp":"2023-11-03T09:34:00"}' + + /option/history/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: option_history_trade + tags: + - Option + - History + description: | + - Returns every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) for options, so they can be ignored. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns every trade for an option contract" + - url: http://localhost:25503/v3/option/history/trade?symbol=AAPL&expiration=*&date=20241104 + description: "Returns every trade for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + # - $ref: "#/components/parameters/interval" # NOT CURRENTLY SUPPORTED IN v2 + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade for an option contract + content: + text/csv: + schema: + type: array + items: &id053 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00.471,18902138,255,255,255,255,130,2,22,3.90\r\nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:01.626,19368856,255,255,255,255,130,1,6,4.25\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:01.698,19403970,255,255,255,255,130,1,6,4.22\r\nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:02.064,19598457,255,255,255,255,18,1,5,4.15\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:02.064,19598464,255,255,255,255,18,1,5,4.15\r\n" + application/json: + schema: &id054 + type: array + items: *id053 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + sequence: + - 18902138 + - 19368856 + - 19403970 + - 19598457 + - 19598464 + condition: + - 130 + - 130 + - 130 + - 18 + - 18 + size: + - 2 + - 1 + - 1 + - 1 + - 1 + price: + - 3.9 + - 4.25 + - 4.22 + - 4.15 + - 4.15 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 22 + - 6 + - 6 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + timestamp: + - '2024-11-04T09:30:00.471' + - '2024-11-04T09:30:01.626' + - '2024-11-04T09:30:01.698' + - '2024-11-04T09:30:02.064' + - '2024-11-04T09:30:02.064' + application/x-ndjson: + schema: *id054 + example: '{"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":18902138,"condition":130,"size":2,"price":3.90,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":22,"ext_condition3":255,"timestamp":"2024-11-04T09:30:00.471"} + + {"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":19368856,"condition":130,"size":1,"price":4.25,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"timestamp":"2024-11-04T09:30:01.626"} + + {"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":19403970,"condition":130,"size":1,"price":4.22,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"timestamp":"2024-11-04T09:30:01.698"} + + {"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":19598457,"condition":18,"size":1,"price":4.15,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-04T09:30:02.064"} + + {"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":19598464,"condition":18,"size":1,"price":4.15,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-04T09:30:02.064"}' + + /option/history/quote: + x-min-subscription: value + get: + summary: Quote + operationId: option_history_quote + tags: + - Option + - History + description: | + - Returns every NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - If the ``interval`` parameter is specified, the quote for each interval represents the last quote at the interval's timestamp. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/quote?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104&interval=1m + description: "Returns every quote for an option contract" + - url: http://localhost:25503/v3/option/history/quote?symbol=AAPL&expiration=*&date=20241104&interval=1m + description: "Returns every quote for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every quote for an option contract + content: + text/csv: + schema: + type: array + items: &id055 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "symbol,expiration,strike,right,timestamp,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00,0,42,0.00,50,0,42,0.00,50\r\nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:31:00,598,5,4.55,50,424,9,4.70,50\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:32:00,58,46,4.30,50,221,11,4.40,50\r\nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:33:00,394,43,3.90,50,45,47,4.00,50\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:34:00,194,11,4.15,50,121,11,4.30,50\r\n" + application/json: + schema: &id056 + type: array + items: *id055 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + ask_size: + - 0 + - 424 + - 221 + - 45 + - 121 + ask_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + bid_size: + - 0 + - 598 + - 58 + - 394 + - 194 + ask_exchange: + - 42 + - 9 + - 11 + - 47 + - 11 + bid_exchange: + - 42 + - 5 + - 46 + - 43 + - 11 + ask: + - 0.0 + - 4.7 + - 4.4 + - 4.0 + - 4.3 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + bid: + - 0.0 + - 4.55 + - 4.3 + - 3.9 + - 4.15 + bid_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:31:00' + - '2024-11-04T09:32:00' + - '2024-11-04T09:33:00' + - '2024-11-04T09:34:00' + application/x-ndjson: + schema: *id056 + example: '{"symbol":"AAPL","ask_size":0,"ask_condition":50,"strike":220.000,"right":"CALL","bid_size":0,"ask_exchange":42,"bid_exchange":42,"ask":0.00,"expiration":"2024-11-08","bid":0.00,"bid_condition":50,"timestamp":"2024-11-04T09:30:00"} + + {"symbol":"AAPL","ask_size":424,"ask_condition":50,"strike":220.000,"right":"CALL","bid_size":598,"ask_exchange":9,"bid_exchange":5,"ask":4.70,"expiration":"2024-11-08","bid":4.55,"bid_condition":50,"timestamp":"2024-11-04T09:31:00"} + + {"symbol":"AAPL","ask_size":221,"ask_condition":50,"strike":220.000,"right":"CALL","bid_size":58,"ask_exchange":11,"bid_exchange":46,"ask":4.40,"expiration":"2024-11-08","bid":4.30,"bid_condition":50,"timestamp":"2024-11-04T09:32:00"} + + {"symbol":"AAPL","ask_size":45,"ask_condition":50,"strike":220.000,"right":"CALL","bid_size":394,"ask_exchange":47,"bid_exchange":43,"ask":4.00,"expiration":"2024-11-08","bid":3.90,"bid_condition":50,"timestamp":"2024-11-04T09:33:00"} + + {"symbol":"AAPL","ask_size":121,"ask_condition":50,"strike":220.000,"right":"CALL","bid_size":194,"ask_exchange":11,"bid_exchange":11,"ask":4.30,"expiration":"2024-11-08","bid":4.15,"bid_condition":50,"timestamp":"2024-11-04T09:34:00"}' + + /option/history/trade_quote: + x-min-subscription: standard + get: + summary: Trade Quote + operationId: option_history_trade_quote + tags: + - Option + - History + description: | + - Returns every [trade](/operations/option_history_trade.html) reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) paired with the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at the time of trade. + - A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. + - To match trades with quotes timestamps that are ``<`` the trade timestamp, specify the ``exclusive``parameter to ``true``. After thorough testing, we have determined that using ``exclusive=true`` might yield better results for various applications. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade_quote?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns every trade quote for an option contract" + - url: http://localhost:25503/v3/option/history/trade_quote?symbol=AAPL&expiration=*&date=20241104 + description: "Returns every trade quote for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/exclusive" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns every trade quote for an option contract + content: + text/csv: + schema: + type: array + items: &id057 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + trade_timestamp: + type: string + format: date-time + description: The trade date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + quote_timestamp: + type: string + format: date-time + description: The quote date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "symbol,expiration,strike,right,trade_timestamp,quote_timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00.471,2024-11-04T09:30:00.396,18902138,255,255,255,255,130,2,22,3.90,14,47,3.90,50,14,47,4.05,50\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:01.626,2024-11-04T09:30:01.594,19368856,255,255,255,255,130,1,6,4.25,93,76,4.15,50,35,73,4.30,50\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:01.698,2024-11-04T09:30:01.643,19403970,255,255,255,255,130,1,6,4.22,59,69,4.15,50,59,69,4.30,50\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:02.064,2024-11-04T09:30:02.039,19598457,255,255,255,255,18,1,5,4.15,31,69,4.15,50,81,11,4.30,50\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:02.064,2024-11-04T09:30:02.039,19598464,255,255,255,255,18,1,5,4.15,31,69,4.15,50,81,11,4.30,50\r\ + \n" + application/json: + schema: &id058 + type: array + items: *id057 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + ask_size: + - 14 + - 35 + - 59 + - 81 + - 81 + trade_timestamp: + - '2024-11-04T09:30:00.471' + - '2024-11-04T09:30:01.626' + - '2024-11-04T09:30:01.698' + - '2024-11-04T09:30:02.064' + - '2024-11-04T09:30:02.064' + ask_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + sequence: + - 18902138 + - 19368856 + - 19403970 + - 19598457 + - 19598464 + condition: + - 130 + - 130 + - 130 + - 18 + - 18 + size: + - 2 + - 1 + - 1 + - 1 + - 1 + bid_size: + - 14 + - 93 + - 59 + - 31 + - 31 + ask_exchange: + - 47 + - 73 + - 69 + - 11 + - 11 + price: + - 3.9 + - 4.25 + - 4.22 + - 4.15 + - 4.15 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + bid_exchange: + - 47 + - 76 + - 69 + - 69 + - 69 + ask: + - 4.05 + - 4.3 + - 4.3 + - 4.3 + - 4.3 + quote_timestamp: + - '2024-11-04T09:30:00.396' + - '2024-11-04T09:30:01.594' + - '2024-11-04T09:30:01.643' + - '2024-11-04T09:30:02.039' + - '2024-11-04T09:30:02.039' + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 22 + - 6 + - 6 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + bid: + - 3.9 + - 4.15 + - 4.15 + - 4.15 + - 4.15 + bid_condition: + - 50 + - 50 + - 50 + - 50 + - 50 + application/x-ndjson: + schema: *id058 + example: '{"symbol":"AAPL","ask_size":14,"trade_timestamp":"2024-11-04T09:30:00.471","ask_condition":50,"strike":220.000,"right":"CALL","sequence":18902138,"condition":130,"size":2,"bid_size":14,"ask_exchange":47,"price":3.90,"ext_condition2":255,"bid_exchange":47,"ask":4.05,"quote_timestamp":"2024-11-04T09:30:00.396","ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":22,"ext_condition3":255,"bid":3.90,"bid_condition":50} + + {"symbol":"AAPL","ask_size":35,"trade_timestamp":"2024-11-04T09:30:01.626","ask_condition":50,"strike":220.000,"right":"CALL","sequence":19368856,"condition":130,"size":1,"bid_size":93,"ask_exchange":73,"price":4.25,"ext_condition2":255,"bid_exchange":76,"ask":4.30,"quote_timestamp":"2024-11-04T09:30:01.594","ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"bid":4.15,"bid_condition":50} + + {"symbol":"AAPL","ask_size":59,"trade_timestamp":"2024-11-04T09:30:01.698","ask_condition":50,"strike":220.000,"right":"CALL","sequence":19403970,"condition":130,"size":1,"bid_size":59,"ask_exchange":69,"price":4.22,"ext_condition2":255,"bid_exchange":69,"ask":4.30,"quote_timestamp":"2024-11-04T09:30:01.643","ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"bid":4.15,"bid_condition":50} + + {"symbol":"AAPL","ask_size":81,"trade_timestamp":"2024-11-04T09:30:02.064","ask_condition":50,"strike":220.000,"right":"CALL","sequence":19598457,"condition":18,"size":1,"bid_size":31,"ask_exchange":11,"price":4.15,"ext_condition2":255,"bid_exchange":69,"ask":4.30,"quote_timestamp":"2024-11-04T09:30:02.039","ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"bid":4.15,"bid_condition":50} + + {"symbol":"AAPL","ask_size":81,"trade_timestamp":"2024-11-04T09:30:02.064","ask_condition":50,"strike":220.000,"right":"CALL","sequence":19598464,"condition":18,"size":1,"bid_size":31,"ask_exchange":11,"price":4.15,"ext_condition2":255,"bid_exchange":69,"ask":4.30,"quote_timestamp":"2024-11-04T09:30:02.039","ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"bid":4.15,"bid_condition":50}' + + /option/history/open_interest: + x-min-subscription: value + get: + summary: Open Interest + operationId: option_history_open_interest + tags: + - Option + - History + description: | + - Open Interest is normally reported once per day by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at approximately 06:30 ET. + - A new open interest message might not be sent by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) if there is no open interest for the option contract. + - The reported open interest represents the open interest at the end of the previous trading day. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/open_interest?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns open interest for an option contract" + - url: http://localhost:25503/v3/option/history/open_interest?symbol=AAPL&expiration=*&date=20241104 + description: "Returns open interest for all option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns open interest for an option contract + content: + text/csv: + schema: + type: array + items: &id059 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + open_interest: + type: integer + description: The total amount of outstanding contracts. + example: "symbol,expiration,strike,right,timestamp,open_interest\r\nAAPL,2024-11-08,220.000,CALL,2024-11-04T06:30:04,2732\r\ + \n" + application/json: + schema: &id060 + type: array + items: *id059 + example: + symbol: + - AAPL + strike: + - 220.0 + open_interest: + - 2732 + expiration: + - '2024-11-08' + right: + - CALL + timestamp: + - '2024-11-04T06:30:04' + application/x-ndjson: + schema: *id060 + example: '{"symbol":"AAPL","strike":220.000,"open_interest":2732,"expiration":"2024-11-08","right":"CALL","timestamp":"2024-11-04T06:30:04"}' + + /option/history/greeks/eod: + x-min-subscription: standard + get: + summary: End of Day Greeks + operationId: option_history_greeks_eod + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Uses Theta Data's EOD reports that get generated at 17:15 ET each day. The closing option price and closing underlying price are used for the greeks calculation. + - **Set `expiration` to ``*`` if you want to retrieve data for every option that shares the same ``symbol``. (note: Any ``expiration=*`` must be requested day by day)** + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We are working to expose this over the coming months. Obtaining the quote at the end of the day requires much more processing than the trades, so we initially generated our history for trades. + x-sample-urls: + - url: http://localhost:25503/v3/option/history/greeks/eod?symbol=AAPL&expiration=20241108&strike=220.000&right=call&start_date=20241104&end_date=20241104 + description: "Returns EOD report for an option contract" + - url: http://localhost:25503/v3/option/history/greeks/eod?symbol=AAPL&expiration=*&start_date=20241104&end_date=20241104 + description: "Returns EOD report for all option contracts" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for an option contract + content: + text/csv: + schema: + type: array + items: &id061 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + delta: + type: number + description: The delta. + theta: + type: string + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: string + description: The epsilon. + lambda: + type: number + description: The lambda. + gamma: + type: number + description: The gamma. + vanna: + type: string + description: The vanna. + charm: + type: number + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + vera: + type: number + description: The vera. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: string + description: The color. + ultima: + type: string + description: The ultima. + d1: + type: number + description: The d1. + d2: + type: number + description: The d2. + dual_delta: + type: string + description: The dual delta. + dual_gamma: + type: number + description: The dual gamma. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,open,high,low,close,volume,count,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition,delta,theta,vega,rho,epsilon,lambda,gamma,vanna,charm,vomma,veta,vera,speed,zomma,color,ultima,d1,d2,dual_delta,dual_gamma,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T15:59:59.828,3.90,4.85,3.35,4.15,7425,1511,9,11,4.10,50,12,5,4.25,50,0.6083,-0.3892,8.9221,1.4334,-1.4791,32.3623,0.0495,-0.2765,3.6779,1.7667,0.0149,0.0000,0.0000,0.0000,-0.0163,-15.6407,0.2750,0.2401,-0.5945,0.0000,0.3334,0.0001,2024-11-04T17:15:28.71,221.870\r\ + \n" + application/json: + schema: &id062 + type: array + items: *id061 + example: + symbol: + - AAPL + ask_size: + - 12 + dual_delta: + - -0.5945 + color: + - -0.0163 + zomma: + - 0.0 + delta: + - 0.6083 + implied_vol: + - 0.3334 + theta: + - -0.3892 + d1: + - 0.275 + speed: + - 0.0 + d2: + - 0.2401 + epsilon: + - -1.4791 + high: + - 4.85 + lambda: + - 32.3623 + low: + - 3.35 + ask_exchange: + - 5 + bid_exchange: + - 11 + vomma: + - 1.7667 + bid_condition: + - 50 + underlying_timestamp: + - '2024-11-04T17:15:28.71' + close: + - 4.15 + timestamp: + - '2024-11-04T15:59:59.828' + underlying_price: + - 221.87 + ask_condition: + - 50 + strike: + - 220.0 + count: + - 1511 + vera: + - 0.0 + right: + - CALL + veta: + - 0.0149 + iv_error: + - 0.0001 + ultima: + - -15.6407 + volume: + - 7425 + charm: + - 3.6779 + bid_size: + - 9 + ask: + - 4.25 + rho: + - 1.4334 + expiration: + - '2024-11-08' + vanna: + - -0.2765 + dual_gamma: + - 0.0 + bid: + - 4.1 + open: + - 3.9 + vega: + - 8.9221 + gamma: + - 0.0495 + application/x-ndjson: + schema: *id062 + example: '{"symbol":"AAPL","ask_size":12,"dual_delta":-0.5945,"color":-0.0163,"zomma":0.0000,"delta":0.6083,"implied_vol":0.3334,"theta":-0.3892,"d1":0.2750,"speed":0.0000,"d2":0.2401,"epsilon":-1.4791,"high":4.85,"lambda":32.3623,"low":3.35,"ask_exchange":5,"bid_exchange":11,"vomma":1.7667,"bid_condition":50,"underlying_timestamp":"2024-11-04T17:15:28.71","close":4.15,"timestamp":"2024-11-04T15:59:59.828","underlying_price":221.870,"ask_condition":50,"strike":220.000,"count":1511,"vera":0.0000,"right":"CALL","veta":0.0149,"iv_error":0.0001,"ultima":-15.6407,"volume":7425,"charm":3.6779,"bid_size":9,"ask":4.25,"rho":1.4334,"expiration":"2024-11-08","vanna":-0.2765,"dual_gamma":0.0000,"bid":4.10,"open":3.90,"vega":8.9221,"gamma":0.0495}' + + /option/history/greeks/all: + x-min-subscription: professional + get: + summary: All Greeks + operationId: option_history_greeks_all + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/greeks/all?symbol=AAPL&expiration=20241108&date=20241104&interval=10m + description: "Returns all greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns all greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id063 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + delta: + type: number + description: The delta. + theta: + type: number + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: number + description: The epsilon. + lambda: + type: number + description: The lambda. + gamma: + type: number + description: The gamma. + vanna: + type: number + description: The vanna. + charm: + type: number + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + vera: + type: number + description: The vera. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: number + description: The color. + ultima: + type: number + description: The ultima. + d1: + type: string + description: The d1. + d2: + type: string + description: The d2. + dual_delta: + type: number + description: The dual delta. + dual_gamma: + type: number + description: The dual gamma. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,delta,theta,vega,rho,epsilon,lambda,gamma,vanna,charm,vomma,veta,vera,speed,zomma,color,ultima,d1,d2,dual_delta,dual_gamma,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:30:00,0.00,0.00,0.0000,0.0000,0.0000,0.0000,0.0000,261.9304,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0001,-6.5422,-6.5683,0.0000,0.0000,0.2500,100.0000,2024-11-04T09:30:00,221.00\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:40:00,0.00,0.02,0.0026,-0.0138,0.1873,0.0062,-0.0063,55.3974,0.0005,0.0393,-1.0623,2.5389,0.0136,0.0000,0.0000,0.0000,-0.0005,21.4427,-2.7911,-2.8526,-0.0021,0.0000,0.5874,0.0455,2024-11-04T09:40:00,220.56\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:50:00,0.00,0.02,0.0025,-0.0130,0.1807,0.0059,-0.0060,56.7822,0.0005,0.0388,-1.0265,2.5262,0.0133,0.0000,0.0000,0.0000,-0.0005,22.1272,-2.8050,-2.8652,-0.0020,0.0000,0.5749,-0.0199,2024-11-04T09:50:00,221.20\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T10:00:00,0.00,0.02,0.0025,-0.0129,0.1825,0.0060,-0.0061,57.9900,0.0006,0.0399,-1.0319,2.6034,0.0136,0.0000,0.0000,0.0000,-0.0005,23.2345,-2.8027,-2.8616,-0.0021,0.0000,0.5625,-0.0299,2024-11-04T10:00:00,222.06\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T10:10:00,0.00,0.01,0.0000,0.0000,0.0000,0.0000,0.0000,254.5285,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0004,-6.3404,-6.3666,0.0000,0.0000,0.2500,100.0000,2024-11-04T10:10:00,222.17\r\ + \n" + application/json: + schema: &id064 + type: array + items: *id063 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + dual_delta: + - 0.0 + - -0.0021 + - -0.002 + - -0.0021 + - 0.0 + color: + - 0.0 + - -0.0005 + - -0.0005 + - -0.0005 + - 0.0 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + delta: + - 0.0 + - 0.0026 + - 0.0025 + - 0.0025 + - 0.0 + implied_vol: + - 0.25 + - 0.5874 + - 0.5749 + - 0.5625 + - 0.25 + theta: + - 0.0 + - -0.0138 + - -0.013 + - -0.0129 + - 0.0 + d1: + - -6.5422 + - -2.7911 + - -2.805 + - -2.8027 + - -6.3404 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + d2: + - -6.5683 + - -2.8526 + - -2.8652 + - -2.8616 + - -6.3666 + epsilon: + - 0.0 + - -0.0063 + - -0.006 + - -0.0061 + - 0.0 + lambda: + - 261.9304 + - 55.3974 + - 56.7822 + - 57.99 + - 254.5285 + vomma: + - 0.0 + - 2.5389 + - 2.5262 + - 2.6034 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:50:00' + - '2024-11-04T10:00:00' + - '2024-11-04T10:10:00' + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:50:00' + - '2024-11-04T10:00:00' + - '2024-11-04T10:10:00' + underlying_price: + - 221.0 + - 220.56 + - 221.2 + - 222.06 + - 222.17 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + vera: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.0 + - 0.0136 + - 0.0133 + - 0.0136 + - 0.0 + iv_error: + - 100.0 + - 0.0455 + - -0.0199 + - -0.0299 + - 100.0 + ultima: + - 0.0001 + - 21.4427 + - 22.1272 + - 23.2345 + - 0.0004 + charm: + - 0.0 + - -1.0623 + - -1.0265 + - -1.0319 + - 0.0 + ask: + - 0.0 + - 0.02 + - 0.02 + - 0.02 + - 0.01 + rho: + - 0.0 + - 0.0062 + - 0.0059 + - 0.006 + - 0.0 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + vanna: + - 0.0 + - 0.0393 + - 0.0388 + - 0.0399 + - 0.0 + dual_gamma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + vega: + - 0.0 + - 0.1873 + - 0.1807 + - 0.1825 + - 0.0 + gamma: + - 0.0 + - 0.0005 + - 0.0005 + - 0.0006 + - 0.0 + application/x-ndjson: + schema: *id064 + example: '{"symbol":"AAPL","dual_delta":0.0000,"color":0.0000,"zomma":0.0000,"delta":0.0000,"implied_vol":0.2500,"theta":0.0000,"d1":-6.5422,"speed":0.0000,"d2":-6.5683,"epsilon":0.0000,"lambda":261.9304,"vomma":0.0000,"underlying_timestamp":"2024-11-04T09:30:00","timestamp":"2024-11-04T09:30:00","underlying_price":221.00,"strike":262.500,"vera":0.0000,"right":"CALL","veta":0.0000,"iv_error":100.0000,"ultima":0.0001,"charm":0.0000,"ask":0.00,"rho":0.0000,"expiration":"2024-11-08","vanna":0.0000,"dual_gamma":0.0000,"bid":0.00,"vega":0.0000,"gamma":0.0000} + + {"symbol":"AAPL","dual_delta":-0.0021,"color":-0.0005,"zomma":0.0000,"delta":0.0026,"implied_vol":0.5874,"theta":-0.0138,"d1":-2.7911,"speed":0.0000,"d2":-2.8526,"epsilon":-0.0063,"lambda":55.3974,"vomma":2.5389,"underlying_timestamp":"2024-11-04T09:40:00","timestamp":"2024-11-04T09:40:00","underlying_price":220.56,"strike":262.500,"vera":0.0000,"right":"CALL","veta":0.0136,"iv_error":0.0455,"ultima":21.4427,"charm":-1.0623,"ask":0.02,"rho":0.0062,"expiration":"2024-11-08","vanna":0.0393,"dual_gamma":0.0000,"bid":0.00,"vega":0.1873,"gamma":0.0005} + + {"symbol":"AAPL","dual_delta":-0.0020,"color":-0.0005,"zomma":0.0000,"delta":0.0025,"implied_vol":0.5749,"theta":-0.0130,"d1":-2.8050,"speed":0.0000,"d2":-2.8652,"epsilon":-0.0060,"lambda":56.7822,"vomma":2.5262,"underlying_timestamp":"2024-11-04T09:50:00","timestamp":"2024-11-04T09:50:00","underlying_price":221.20,"strike":262.500,"vera":0.0000,"right":"CALL","veta":0.0133,"iv_error":-0.0199,"ultima":22.1272,"charm":-1.0265,"ask":0.02,"rho":0.0059,"expiration":"2024-11-08","vanna":0.0388,"dual_gamma":0.0000,"bid":0.00,"vega":0.1807,"gamma":0.0005} + + {"symbol":"AAPL","dual_delta":-0.0021,"color":-0.0005,"zomma":0.0000,"delta":0.0025,"implied_vol":0.5625,"theta":-0.0129,"d1":-2.8027,"speed":0.0000,"d2":-2.8616,"epsilon":-0.0061,"lambda":57.9900,"vomma":2.6034,"underlying_timestamp":"2024-11-04T10:00:00","timestamp":"2024-11-04T10:00:00","underlying_price":222.06,"strike":262.500,"vera":0.0000,"right":"CALL","veta":0.0136,"iv_error":-0.0299,"ultima":23.2345,"charm":-1.0319,"ask":0.02,"rho":0.0060,"expiration":"2024-11-08","vanna":0.0399,"dual_gamma":0.0000,"bid":0.00,"vega":0.1825,"gamma":0.0006} + + {"symbol":"AAPL","dual_delta":0.0000,"color":0.0000,"zomma":0.0000,"delta":0.0000,"implied_vol":0.2500,"theta":0.0000,"d1":-6.3404,"speed":0.0000,"d2":-6.3666,"epsilon":0.0000,"lambda":254.5285,"vomma":0.0000,"underlying_timestamp":"2024-11-04T10:10:00","timestamp":"2024-11-04T10:10:00","underlying_price":222.17,"strike":262.500,"vera":0.0000,"right":"CALL","veta":0.0000,"iv_error":100.0000,"ultima":0.0004,"charm":0.0000,"ask":0.01,"rho":0.0000,"expiration":"2024-11-08","vanna":0.0000,"dual_gamma":0.0000,"bid":0.00,"vega":0.0000,"gamma":0.0000}' + + /option/history/trade_greeks/all: + x-min-subscription: professional + get: + summary: All Trade Greeks + operationId: option_history_trade_greeks_all + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade_greeks/all?symbol=AAPL&expiration=20231117&date=20231110 + description: "Returns all trade greeks for an option contract" + - url: http://localhost:25503/v3/option/history/trade_greeks/all?symbol=AAPL&expiration=*&date=20231110 + description: "Returns all trade greeks for an full chain of option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns all trade greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id065 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: string + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + delta: + type: number + description: The delta. + theta: + type: string + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: string + description: The epsilon. + lambda: + type: number + description: The lambda. + gamma: + type: number + description: The gamma. + vanna: + type: number + description: The vanna. + charm: + type: string + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + vera: + type: number + description: The vera. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: string + description: The color. + ultima: + type: string + description: The ultima. + d1: + type: string + description: The d1. + d2: + type: string + description: The d2. + dual_delta: + type: string + description: The dual delta. + dual_gamma: + type: number + description: The dual gamma. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: string + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,delta,theta,vega,rho,epsilon,lambda,gamma,vanna,charm,vomma,veta,vera,speed,zomma,color,ultima,d1,d2,dual_delta,dual_gamma,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2023-11-17,187.500,CALL,2023-11-10T09:30:00.004,-1391330475,255,255,255,255,18,1,9,0.59,0.2289,-0.1031,7.7122,0.7960,-0.8073,71.4109,0.0674,1.3174,-6.7146,24.9086,0.3553,0.0000,0.0000,0.0000,-0.0129,-100.0000,-0.7424,-0.7668,-0.2213,0.0000,0.1762,-0.0008,2023-11-10T09:30:00,183.89\r\ + \nAAPL,2023-11-17,187.500,CALL,2023-11-10T09:30:00.154,-1391317465,255,255,255,255,18,1,47,0.59,0.2289,-0.1031,7.7122,0.7960,-0.8073,71.4109,0.0674,1.3174,-6.7146,24.9086,0.3553,0.0000,0.0000,0.0000,-0.0129,-100.0000,-0.7424,-0.7668,-0.2213,0.0000,0.1762,-0.0008,2023-11-10T09:30:00,183.89\r\ + \nAAPL,2023-11-17,187.500,CALL,2023-11-10T09:30:00.22,-1391313694,255,255,255,255,18,8,6,0.52,0.2162,-0.0947,7.4656,0.7526,-0.7625,76.6064,0.0689,1.4186,-6.8508,28.3594,0.3755,0.0000,0.0000,0.0000,-0.0118,-100.0000,-0.7849,-0.8081,-0.2093,0.0000,0.1669,-0.0018,2023-11-10T09:30:00,183.89\r\ + \nAAPL,2023-11-17,187.500,CALL,2023-11-10T09:30:00.221,-1391313652,255,255,255,255,130,1,6,0.57,0.2256,-0.1009,7.6504,0.7849,-0.7958,72.7109,0.0678,1.3432,-6.7516,25.7650,0.3605,0.0000,0.0000,0.0000,-0.0126,-100.0000,-0.7531,-0.7772,-0.2182,0.0000,0.1738,0.0012,2023-11-10T09:30:00,183.89\r\ + \nAAPL,2023-11-17,187.500,CALL,2023-11-10T09:30:00.452,-1391297309,255,255,255,255,18,6,31,0.60,0.2308,-0.1044,7.7484,0.8025,-0.8140,70.6522,0.0672,1.3022,-6.6920,24.4114,0.3523,0.0000,0.0000,0.0000,-0.0130,-100.0000,-0.7360,-0.7607,-0.2231,0.0000,0.1777,0.0013,2023-11-10T09:30:00,183.89\r\ + \n" + application/json: + schema: &id066 + type: array + items: *id065 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + dual_delta: + - -0.2213 + - -0.2213 + - -0.2093 + - -0.2182 + - -0.2231 + color: + - -0.0129 + - -0.0129 + - -0.0118 + - -0.0126 + - -0.013 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + delta: + - 0.2289 + - 0.2289 + - 0.2162 + - 0.2256 + - 0.2308 + implied_vol: + - 0.1762 + - 0.1762 + - 0.1669 + - 0.1738 + - 0.1777 + theta: + - -0.1031 + - -0.1031 + - -0.0947 + - -0.1009 + - -0.1044 + d1: + - -0.7424 + - -0.7424 + - -0.7849 + - -0.7531 + - -0.736 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + d2: + - -0.7668 + - -0.7668 + - -0.8081 + - -0.7772 + - -0.7607 + epsilon: + - -0.8073 + - -0.8073 + - -0.7625 + - -0.7958 + - -0.814 + lambda: + - 71.4109 + - 71.4109 + - 76.6064 + - 72.7109 + - 70.6522 + price: + - 0.59 + - 0.59 + - 0.52 + - 0.57 + - 0.6 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + vomma: + - 24.9086 + - 24.9086 + - 28.3594 + - 25.765 + - 24.4114 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + - '2023-11-10T09:30:00' + timestamp: + - '2023-11-10T09:30:00.004' + - '2023-11-10T09:30:00.154' + - '2023-11-10T09:30:00.22' + - '2023-11-10T09:30:00.221' + - '2023-11-10T09:30:00.452' + underlying_price: + - 183.89 + - 183.89 + - 183.89 + - 183.89 + - 183.89 + strike: + - 187.5 + - 187.5 + - 187.5 + - 187.5 + - 187.5 + vera: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.3553 + - 0.3553 + - 0.3755 + - 0.3605 + - 0.3523 + iv_error: + - -0.0008 + - -0.0008 + - -0.0018 + - 0.0012 + - 0.0013 + ultima: + - -100.0 + - -100.0 + - -100.0 + - -100.0 + - -100.0 + sequence: + - -1391330475 + - -1391317465 + - -1391313694 + - -1391313652 + - -1391297309 + condition: + - 18 + - 18 + - 18 + - 130 + - 18 + size: + - 1 + - 1 + - 8 + - 1 + - 6 + charm: + - -6.7146 + - -6.7146 + - -6.8508 + - -6.7516 + - -6.692 + rho: + - 0.796 + - 0.796 + - 0.7526 + - 0.7849 + - 0.8025 + expiration: + - '2023-11-17' + - '2023-11-17' + - '2023-11-17' + - '2023-11-17' + - '2023-11-17' + exchange: + - 9 + - 47 + - 6 + - 6 + - 31 + vanna: + - 1.3174 + - 1.3174 + - 1.4186 + - 1.3432 + - 1.3022 + dual_gamma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + vega: + - 7.7122 + - 7.7122 + - 7.4656 + - 7.6504 + - 7.7484 + gamma: + - 0.0674 + - 0.0674 + - 0.0689 + - 0.0678 + - 0.0672 + application/x-ndjson: + schema: *id066 + example: '{"symbol":"AAPL","dual_delta":-0.2213,"color":-0.0129,"zomma":0.0000,"delta":0.2289,"implied_vol":0.1762,"theta":-0.1031,"d1":-0.7424,"speed":0.0000,"d2":-0.7668,"epsilon":-0.8073,"lambda":71.4109,"price":0.59,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"vomma":24.9086,"ext_condition3":255,"underlying_timestamp":"2023-11-10T09:30:00","timestamp":"2023-11-10T09:30:00.004","underlying_price":183.89,"strike":187.500,"vera":0.0000,"right":"CALL","veta":0.3553,"iv_error":-0.0008,"ultima":-100.0000,"sequence":-1391330475,"condition":18,"size":1,"charm":-6.7146,"rho":0.7960,"expiration":"2023-11-17","exchange":9,"vanna":1.3174,"dual_gamma":0.0000,"vega":7.7122,"gamma":0.0674} + + {"symbol":"AAPL","dual_delta":-0.2213,"color":-0.0129,"zomma":0.0000,"delta":0.2289,"implied_vol":0.1762,"theta":-0.1031,"d1":-0.7424,"speed":0.0000,"d2":-0.7668,"epsilon":-0.8073,"lambda":71.4109,"price":0.59,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"vomma":24.9086,"ext_condition3":255,"underlying_timestamp":"2023-11-10T09:30:00","timestamp":"2023-11-10T09:30:00.154","underlying_price":183.89,"strike":187.500,"vera":0.0000,"right":"CALL","veta":0.3553,"iv_error":-0.0008,"ultima":-100.0000,"sequence":-1391317465,"condition":18,"size":1,"charm":-6.7146,"rho":0.7960,"expiration":"2023-11-17","exchange":47,"vanna":1.3174,"dual_gamma":0.0000,"vega":7.7122,"gamma":0.0674} + + {"symbol":"AAPL","dual_delta":-0.2093,"color":-0.0118,"zomma":0.0000,"delta":0.2162,"implied_vol":0.1669,"theta":-0.0947,"d1":-0.7849,"speed":0.0000,"d2":-0.8081,"epsilon":-0.7625,"lambda":76.6064,"price":0.52,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"vomma":28.3594,"ext_condition3":255,"underlying_timestamp":"2023-11-10T09:30:00","timestamp":"2023-11-10T09:30:00.22","underlying_price":183.89,"strike":187.500,"vera":0.0000,"right":"CALL","veta":0.3755,"iv_error":-0.0018,"ultima":-100.0000,"sequence":-1391313694,"condition":18,"size":8,"charm":-6.8508,"rho":0.7526,"expiration":"2023-11-17","exchange":6,"vanna":1.4186,"dual_gamma":0.0000,"vega":7.4656,"gamma":0.0689} + + {"symbol":"AAPL","dual_delta":-0.2182,"color":-0.0126,"zomma":0.0000,"delta":0.2256,"implied_vol":0.1738,"theta":-0.1009,"d1":-0.7531,"speed":0.0000,"d2":-0.7772,"epsilon":-0.7958,"lambda":72.7109,"price":0.57,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"vomma":25.7650,"ext_condition3":255,"underlying_timestamp":"2023-11-10T09:30:00","timestamp":"2023-11-10T09:30:00.221","underlying_price":183.89,"strike":187.500,"vera":0.0000,"right":"CALL","veta":0.3605,"iv_error":0.0012,"ultima":-100.0000,"sequence":-1391313652,"condition":130,"size":1,"charm":-6.7516,"rho":0.7849,"expiration":"2023-11-17","exchange":6,"vanna":1.3432,"dual_gamma":0.0000,"vega":7.6504,"gamma":0.0678} + + {"symbol":"AAPL","dual_delta":-0.2231,"color":-0.0130,"zomma":0.0000,"delta":0.2308,"implied_vol":0.1777,"theta":-0.1044,"d1":-0.7360,"speed":0.0000,"d2":-0.7607,"epsilon":-0.8140,"lambda":70.6522,"price":0.60,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"vomma":24.4114,"ext_condition3":255,"underlying_timestamp":"2023-11-10T09:30:00","timestamp":"2023-11-10T09:30:00.452","underlying_price":183.89,"strike":187.500,"vera":0.0000,"right":"CALL","veta":0.3523,"iv_error":0.0013,"ultima":-100.0000,"sequence":-1391297309,"condition":18,"size":6,"charm":-6.6920,"rho":0.8025,"expiration":"2023-11-17","exchange":31,"vanna":1.3022,"dual_gamma":0.0000,"vega":7.7484,"gamma":0.0672}' + + /option/history/greeks/first_order: + x-min-subscription: standard + get: + summary: First Order Greeks + operationId: option_history_greeks_first_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/greeks/first_order?symbol=AAPL&expiration=20241108&date=20241104&interval=5m + description: "Returns first order greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns first order greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id067 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + delta: + type: number + description: The delta. + theta: + type: number + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: number + description: The epsilon. + lambda: + type: number + description: The lambda. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,delta,theta,vega,rho,epsilon,lambda,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:30:00,0.00,0.00,0.0000,0.0000,0.0000,0.0000,0.0000,261.9304,0.2500,100.0000,2024-11-04T09:30:00,221.00\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:35:00,0.00,0.02,0.0026,-0.0141,0.1913,0.0063,-0.0064,55.2930,0.5874,0.0721,2024-11-04T09:35:00,220.66\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:40:00,0.00,0.02,0.0026,-0.0138,0.1873,0.0062,-0.0063,55.3974,0.5874,0.0455,2024-11-04T09:40:00,220.56\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:45:00,0.00,0.02,0.0025,-0.0133,0.1832,0.0060,-0.0061,56.1024,0.5812,0.0075,2024-11-04T09:45:00,220.86\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:50:00,0.00,0.02,0.0025,-0.0130,0.1807,0.0059,-0.0060,56.7822,0.5749,-0.0199,2024-11-04T09:50:00,221.20\r\ + \n" + application/json: + schema: &id068 + type: array + items: *id067 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 220.66 + - 220.56 + - 220.86 + - 221.2 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + delta: + - 0.0 + - 0.0026 + - 0.0026 + - 0.0025 + - 0.0025 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.25 + - 0.5874 + - 0.5874 + - 0.5812 + - 0.5749 + theta: + - 0.0 + - -0.0141 + - -0.0138 + - -0.0133 + - -0.013 + iv_error: + - 100.0 + - 0.0721 + - 0.0455 + - 0.0075 + - -0.0199 + epsilon: + - 0.0 + - -0.0064 + - -0.0063 + - -0.0061 + - -0.006 + lambda: + - 261.9304 + - 55.293 + - 55.3974 + - 56.1024 + - 56.7822 + ask: + - 0.0 + - 0.02 + - 0.02 + - 0.02 + - 0.02 + rho: + - 0.0 + - 0.0063 + - 0.0062 + - 0.006 + - 0.0059 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + vega: + - 0.0 + - 0.1913 + - 0.1873 + - 0.1832 + - 0.1807 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + application/x-ndjson: + schema: *id068 + example: '{"symbol":"AAPL","underlying_price":221.00,"strike":262.500,"delta":0.0000,"right":"CALL","implied_vol":0.2500,"theta":0.0000,"iv_error":100.0000,"epsilon":0.0000,"lambda":261.9304,"ask":0.00,"rho":0.0000,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T09:30:00","vega":0.0000,"timestamp":"2024-11-04T09:30:00"} + + {"symbol":"AAPL","underlying_price":220.66,"strike":262.500,"delta":0.0026,"right":"CALL","implied_vol":0.5874,"theta":-0.0141,"iv_error":0.0721,"epsilon":-0.0064,"lambda":55.2930,"ask":0.02,"rho":0.0063,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T09:35:00","vega":0.1913,"timestamp":"2024-11-04T09:35:00"} + + {"symbol":"AAPL","underlying_price":220.56,"strike":262.500,"delta":0.0026,"right":"CALL","implied_vol":0.5874,"theta":-0.0138,"iv_error":0.0455,"epsilon":-0.0063,"lambda":55.3974,"ask":0.02,"rho":0.0062,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T09:40:00","vega":0.1873,"timestamp":"2024-11-04T09:40:00"} + + {"symbol":"AAPL","underlying_price":220.86,"strike":262.500,"delta":0.0025,"right":"CALL","implied_vol":0.5812,"theta":-0.0133,"iv_error":0.0075,"epsilon":-0.0061,"lambda":56.1024,"ask":0.02,"rho":0.0060,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T09:45:00","vega":0.1832,"timestamp":"2024-11-04T09:45:00"} + + {"symbol":"AAPL","underlying_price":221.20,"strike":262.500,"delta":0.0025,"right":"CALL","implied_vol":0.5749,"theta":-0.0130,"iv_error":-0.0199,"epsilon":-0.0060,"lambda":56.7822,"ask":0.02,"rho":0.0059,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T09:50:00","vega":0.1807,"timestamp":"2024-11-04T09:50:00"}' + + /option/history/trade_greeks/first_order: + x-min-subscription: professional + get: + summary: First Order Trade Greeks + operationId: option_history_trade_greeks_first_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade_greeks/first_order?symbol=AAPL&expiration=20241108&date=20241104 + description: "Returns first order trade greeks for an option contract" + - url: http://localhost:25503/v3/option/history/trade_greeks/first_order?symbol=AAPL&expiration=*&date=20241104 + description: "Returns first order trade greeks for an full chain of option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns first order trade greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id069 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + delta: + type: number + description: The delta. + theta: + type: string + description: The Theta. + vega: + type: number + description: The vega. + rho: + type: number + description: The rho. + epsilon: + type: string + description: The epsilon. + lambda: + type: number + description: The lambda. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,delta,theta,vega,rho,epsilon,lambda,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:53:54.069,156249981,255,255,255,255,125,1,9,0.01,0.0025,-0.0134,0.1858,0.0061,-0.0062,56.6408,0.5749,0.0132,2024-11-04T09:53:54,221.33\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:47:14.764,546105677,255,255,255,255,131,2,5,81.32,0.9976,-0.0520,0.1690,1.5274,-2.4186,2.7139,1.5937,0.0000,2024-11-04T11:47:14,221.22\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:47:56.669,548097371,255,255,255,255,130,3,7,81.16,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0011,2024-11-04T11:47:56,221.18\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:48:03.852,548397162,255,255,255,255,130,3,6,81.26,0.9976,-0.0522,0.1697,1.5274,-2.4179,2.7152,1.5937,0.0000,2024-11-04T11:48:03,221.16\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:48:51.11,550463381,255,255,255,255,131,1,5,81.27,0.9993,-0.0279,0.0544,1.5317,-2.4223,2.7198,1.3968,0.0000,2024-11-04T11:48:51,221.19\r\ + \n" + application/json: + schema: &id070 + type: array + items: *id069 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.33 + - 221.22 + - 221.18 + - 221.16 + - 221.19 + strike: + - 262.5 + - 140.0 + - 140.0 + - 140.0 + - 140.0 + delta: + - 0.0025 + - 0.9976 + - 1.0 + - 0.9976 + - 0.9993 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.5749 + - 1.5937 + - 0.0 + - 1.5937 + - 1.3968 + theta: + - -0.0134 + - -0.052 + - 0.0 + - -0.0522 + - -0.0279 + iv_error: + - 0.0132 + - 0.0 + - 0.0011 + - 0.0 + - 0.0 + epsilon: + - -0.0062 + - -2.4186 + - 0.0 + - -2.4179 + - -2.4223 + sequence: + - 156249981 + - 546105677 + - 548097371 + - 548397162 + - 550463381 + condition: + - 125 + - 131 + - 130 + - 130 + - 131 + lambda: + - 56.6408 + - 2.7139 + - 0.0 + - 2.7152 + - 2.7198 + size: + - 1 + - 2 + - 3 + - 3 + - 1 + price: + - 0.01 + - 81.32 + - 81.16 + - 81.26 + - 81.27 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + rho: + - 0.0061 + - 1.5274 + - 0.0 + - 1.5274 + - 1.5317 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 9 + - 5 + - 7 + - 6 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:53:54' + - '2024-11-04T11:47:14' + - '2024-11-04T11:47:56' + - '2024-11-04T11:48:03' + - '2024-11-04T11:48:51' + vega: + - 0.1858 + - 0.169 + - 0.0 + - 0.1697 + - 0.0544 + timestamp: + - '2024-11-04T09:53:54.069' + - '2024-11-04T11:47:14.764' + - '2024-11-04T11:47:56.669' + - '2024-11-04T11:48:03.852' + - '2024-11-04T11:48:51.11' + application/x-ndjson: + schema: *id070 + example: '{"symbol":"AAPL","underlying_price":221.33,"strike":262.500,"delta":0.0025,"right":"CALL","implied_vol":0.5749,"theta":-0.0134,"iv_error":0.0132,"epsilon":-0.0062,"sequence":156249981,"condition":125,"lambda":56.6408,"size":1,"price":0.01,"ext_condition2":255,"rho":0.0061,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":9,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:53:54","vega":0.1858,"timestamp":"2024-11-04T09:53:54.069"} + + {"symbol":"AAPL","underlying_price":221.22,"strike":140.000,"delta":0.9976,"right":"CALL","implied_vol":1.5937,"theta":-0.0520,"iv_error":0.0000,"epsilon":-2.4186,"sequence":546105677,"condition":131,"lambda":2.7139,"size":2,"price":81.32,"ext_condition2":255,"rho":1.5274,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:47:14","vega":0.1690,"timestamp":"2024-11-04T11:47:14.764"} + + {"symbol":"AAPL","underlying_price":221.18,"strike":140.000,"delta":1.0000,"right":"CALL","implied_vol":0.0000,"theta":0.0000,"iv_error":0.0011,"epsilon":0.0000,"sequence":548097371,"condition":130,"lambda":0.0000,"size":3,"price":81.16,"ext_condition2":255,"rho":0.0000,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":7,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:47:56","vega":0.0000,"timestamp":"2024-11-04T11:47:56.669"} + + {"symbol":"AAPL","underlying_price":221.16,"strike":140.000,"delta":0.9976,"right":"CALL","implied_vol":1.5937,"theta":-0.0522,"iv_error":0.0000,"epsilon":-2.4179,"sequence":548397162,"condition":130,"lambda":2.7152,"size":3,"price":81.26,"ext_condition2":255,"rho":1.5274,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:48:03","vega":0.1697,"timestamp":"2024-11-04T11:48:03.852"} + + {"symbol":"AAPL","underlying_price":221.19,"strike":140.000,"delta":0.9993,"right":"CALL","implied_vol":1.3968,"theta":-0.0279,"iv_error":0.0000,"epsilon":-2.4223,"sequence":550463381,"condition":131,"lambda":2.7198,"size":1,"price":81.27,"ext_condition2":255,"rho":1.5317,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:48:51","vega":0.0544,"timestamp":"2024-11-04T11:48:51.11"}' + + /option/history/greeks/second_order: + x-min-subscription: professional + get: + summary: Second Order Greeks + operationId: option_history_greeks_second_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/greeks/second_order?symbol=AAPL&expiration=20241108&date=20241104&interval=1h + description: "Returns second order greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns second order greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id071 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + gamma: + type: number + description: The gamma. + vanna: + type: number + description: The vanna. + charm: + type: number + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,gamma,vanna,charm,vomma,veta,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:30:00,0.00,0.00,0.0000,0.0000,0.0000,0.0000,0.0000,0.2500,100.0000,2024-11-04T09:30:00,221.00\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T10:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0000,0.0000,0.2500,100.0000,2024-11-04T10:30:00,221.73\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T11:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0000,0.0000,0.2500,100.0000,2024-11-04T11:30:00,221.49\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T12:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0000,0.0000,0.2500,100.0000,2024-11-04T12:30:00,221.11\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T13:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0000,0.0000,0.2500,100.0000,2024-11-04T13:30:00,222.03\r\ + \n" + application/json: + schema: &id072 + type: array + items: *id071 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 221.73 + - 221.49 + - 221.11 + - 222.03 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + implied_vol: + - 0.25 + - 0.25 + - 0.25 + - 0.25 + - 0.25 + iv_error: + - 100.0 + - 100.0 + - 100.0 + - 100.0 + - 100.0 + charm: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + ask: + - 0.0 + - 0.01 + - 0.01 + - 0.01 + - 0.01 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + vanna: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + vomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + gamma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + application/x-ndjson: + schema: *id072 + example: '{"symbol":"AAPL","underlying_price":221.00,"strike":262.500,"right":"CALL","veta":0.0000,"implied_vol":0.2500,"iv_error":100.0000,"charm":0.0000,"ask":0.00,"expiration":"2024-11-08","vanna":0.0000,"vomma":0.0000,"bid":0.00,"underlying_timestamp":"2024-11-04T09:30:00","gamma":0.0000,"timestamp":"2024-11-04T09:30:00"} + + {"symbol":"AAPL","underlying_price":221.73,"strike":262.500,"right":"CALL","veta":0.0000,"implied_vol":0.2500,"iv_error":100.0000,"charm":0.0000,"ask":0.01,"expiration":"2024-11-08","vanna":0.0000,"vomma":0.0000,"bid":0.00,"underlying_timestamp":"2024-11-04T10:30:00","gamma":0.0000,"timestamp":"2024-11-04T10:30:00"} + + {"symbol":"AAPL","underlying_price":221.49,"strike":262.500,"right":"CALL","veta":0.0000,"implied_vol":0.2500,"iv_error":100.0000,"charm":0.0000,"ask":0.01,"expiration":"2024-11-08","vanna":0.0000,"vomma":0.0000,"bid":0.00,"underlying_timestamp":"2024-11-04T11:30:00","gamma":0.0000,"timestamp":"2024-11-04T11:30:00"} + + {"symbol":"AAPL","underlying_price":221.11,"strike":262.500,"right":"CALL","veta":0.0000,"implied_vol":0.2500,"iv_error":100.0000,"charm":0.0000,"ask":0.01,"expiration":"2024-11-08","vanna":0.0000,"vomma":0.0000,"bid":0.00,"underlying_timestamp":"2024-11-04T12:30:00","gamma":0.0000,"timestamp":"2024-11-04T12:30:00"} + + {"symbol":"AAPL","underlying_price":222.03,"strike":262.500,"right":"CALL","veta":0.0000,"implied_vol":0.2500,"iv_error":100.0000,"charm":0.0000,"ask":0.01,"expiration":"2024-11-08","vanna":0.0000,"vomma":0.0000,"bid":0.00,"underlying_timestamp":"2024-11-04T13:30:00","gamma":0.0000,"timestamp":"2024-11-04T13:30:00"}' + + /option/history/trade_greeks/second_order: + x-min-subscription: professional + get: + summary: Second Order Trade Greeks + operationId: option_history_trade_greeks_second_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade_greeks/second_order?symbol=AAPL&expiration=20241108&date=20241104 + description: "Returns second order trade greeks for an option contract" + - url: http://localhost:25503/v3/option/history/trade_greeks/second_order?symbol=AAPL&expiration=*&date=20241104 + description: "Returns second order trade greeks for an full chain of option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns second order trade greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id073 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + gamma: + type: number + description: The gamma. + vanna: + type: number + description: The vanna. + charm: + type: string + description: The charm. + vomma: + type: number + description: The vomma. + veta: + type: number + description: The veta. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,gamma,vanna,charm,vomma,veta,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:53:54.069,156249981,255,255,255,255,125,1,9,0.01,0.0006,0.0398,-1.0514,2.5798,0.0137,0.5749,0.0132,2024-11-04T09:53:54,221.33\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:47:14.764,546105677,255,255,255,255,131,2,5,81.32,0.0001,-0.0121,0.8843,0.7986,0.0063,1.5937,0.0000,2024-11-04T11:47:14,221.22\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:47:56.669,548097371,255,255,255,255,130,3,7,81.16,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0011,2024-11-04T11:47:56,221.18\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:48:03.852,548397162,255,255,255,255,130,3,6,81.26,0.0001,-0.0122,0.8879,0.8011,0.0064,1.5937,0.0000,2024-11-04T11:48:03,221.16\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:48:51.11,550463381,255,255,255,255,131,1,5,81.27,0.0000,-0.0051,0.3271,0.3817,0.0025,1.3968,0.0000,2024-11-04T11:48:51,221.19\r\ + \n" + application/json: + schema: &id074 + type: array + items: *id073 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.33 + - 221.22 + - 221.18 + - 221.16 + - 221.19 + strike: + - 262.5 + - 140.0 + - 140.0 + - 140.0 + - 140.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + veta: + - 0.0137 + - 0.0063 + - 0.0 + - 0.0064 + - 0.0025 + implied_vol: + - 0.5749 + - 1.5937 + - 0.0 + - 1.5937 + - 1.3968 + iv_error: + - 0.0132 + - 0.0 + - 0.0011 + - 0.0 + - 0.0 + sequence: + - 156249981 + - 546105677 + - 548097371 + - 548397162 + - 550463381 + condition: + - 125 + - 131 + - 130 + - 130 + - 131 + size: + - 1 + - 2 + - 3 + - 3 + - 1 + charm: + - -1.0514 + - 0.8843 + - 0.0 + - 0.8879 + - 0.3271 + price: + - 0.01 + - 81.32 + - 81.16 + - 81.26 + - 81.27 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 9 + - 5 + - 7 + - 6 + - 5 + vanna: + - 0.0398 + - -0.0121 + - 0.0 + - -0.0122 + - -0.0051 + vomma: + - 2.5798 + - 0.7986 + - 0.0 + - 0.8011 + - 0.3817 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:53:54' + - '2024-11-04T11:47:14' + - '2024-11-04T11:47:56' + - '2024-11-04T11:48:03' + - '2024-11-04T11:48:51' + gamma: + - 0.0006 + - 0.0001 + - 0.0 + - 0.0001 + - 0.0 + timestamp: + - '2024-11-04T09:53:54.069' + - '2024-11-04T11:47:14.764' + - '2024-11-04T11:47:56.669' + - '2024-11-04T11:48:03.852' + - '2024-11-04T11:48:51.11' + application/x-ndjson: + schema: *id074 + example: '{"symbol":"AAPL","underlying_price":221.33,"strike":262.500,"right":"CALL","veta":0.0137,"implied_vol":0.5749,"iv_error":0.0132,"sequence":156249981,"condition":125,"size":1,"charm":-1.0514,"price":0.01,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":9,"vanna":0.0398,"vomma":2.5798,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:53:54","gamma":0.0006,"timestamp":"2024-11-04T09:53:54.069"} + + {"symbol":"AAPL","underlying_price":221.22,"strike":140.000,"right":"CALL","veta":0.0063,"implied_vol":1.5937,"iv_error":0.0000,"sequence":546105677,"condition":131,"size":2,"charm":0.8843,"price":81.32,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"vanna":-0.0121,"vomma":0.7986,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:47:14","gamma":0.0001,"timestamp":"2024-11-04T11:47:14.764"} + + {"symbol":"AAPL","underlying_price":221.18,"strike":140.000,"right":"CALL","veta":0.0000,"implied_vol":0.0000,"iv_error":0.0011,"sequence":548097371,"condition":130,"size":3,"charm":0.0000,"price":81.16,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":7,"vanna":0.0000,"vomma":0.0000,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:47:56","gamma":0.0000,"timestamp":"2024-11-04T11:47:56.669"} + + {"symbol":"AAPL","underlying_price":221.16,"strike":140.000,"right":"CALL","veta":0.0064,"implied_vol":1.5937,"iv_error":0.0000,"sequence":548397162,"condition":130,"size":3,"charm":0.8879,"price":81.26,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"vanna":-0.0122,"vomma":0.8011,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:48:03","gamma":0.0001,"timestamp":"2024-11-04T11:48:03.852"} + + {"symbol":"AAPL","underlying_price":221.19,"strike":140.000,"right":"CALL","veta":0.0025,"implied_vol":1.3968,"iv_error":0.0000,"sequence":550463381,"condition":131,"size":1,"charm":0.3271,"price":81.27,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"vanna":-0.0051,"vomma":0.3817,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:48:51","gamma":0.0000,"timestamp":"2024-11-04T11:48:51.11"}' + + /option/history/greeks/third_order: + x-min-subscription: professional + get: + summary: Third Order Greeks + operationId: option_history_greeks_third_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified (*highly recommended*), the option quote used in the calculation follows the same rules as the [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/greeks/third_order?symbol=AAPL&expiration=20241108&date=20241104&interval=1h + description: "Returns third order greeks for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns third order greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id075 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + ask: + type: number + description: The last NBBO ask price. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: number + description: The color. + ultima: + type: number + description: The ultima. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,ask,speed,zomma,color,ultima,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:30:00,0.00,0.00,0.0000,0.0000,0.0000,0.0001,0.2500,100.0000,2024-11-04T09:30:00,221.00\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T10:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0002,0.2500,100.0000,2024-11-04T10:30:00,221.73\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T11:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0002,0.2500,100.0000,2024-11-04T11:30:00,221.49\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T12:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0001,0.2500,100.0000,2024-11-04T12:30:00,221.11\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T13:30:00,0.00,0.01,0.0000,0.0000,0.0000,0.0003,0.2500,100.0000,2024-11-04T13:30:00,222.03\r\ + \n" + application/json: + schema: &id076 + type: array + items: *id075 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 221.73 + - 221.49 + - 221.11 + - 222.03 + color: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + strike: + - 262.5 + - 262.5 + - 262.5 + - 262.5 + - 262.5 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.25 + - 0.25 + - 0.25 + - 0.25 + - 0.25 + iv_error: + - 100.0 + - 100.0 + - 100.0 + - 100.0 + - 100.0 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + ultima: + - 0.0001 + - 0.0002 + - 0.0002 + - 0.0001 + - 0.0003 + ask: + - 0.0 + - 0.01 + - 0.01 + - 0.01 + - 0.01 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T10:30:00' + - '2024-11-04T11:30:00' + - '2024-11-04T12:30:00' + - '2024-11-04T13:30:00' + application/x-ndjson: + schema: *id076 + example: '{"symbol":"AAPL","underlying_price":221.00,"color":0.0000,"strike":262.500,"zomma":0.0000,"right":"CALL","implied_vol":0.2500,"iv_error":100.0000,"speed":0.0000,"ultima":0.0001,"ask":0.00,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T09:30:00","timestamp":"2024-11-04T09:30:00"} + + {"symbol":"AAPL","underlying_price":221.73,"color":0.0000,"strike":262.500,"zomma":0.0000,"right":"CALL","implied_vol":0.2500,"iv_error":100.0000,"speed":0.0000,"ultima":0.0002,"ask":0.01,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T10:30:00","timestamp":"2024-11-04T10:30:00"} + + {"symbol":"AAPL","underlying_price":221.49,"color":0.0000,"strike":262.500,"zomma":0.0000,"right":"CALL","implied_vol":0.2500,"iv_error":100.0000,"speed":0.0000,"ultima":0.0002,"ask":0.01,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T11:30:00","timestamp":"2024-11-04T11:30:00"} + + {"symbol":"AAPL","underlying_price":221.11,"color":0.0000,"strike":262.500,"zomma":0.0000,"right":"CALL","implied_vol":0.2500,"iv_error":100.0000,"speed":0.0000,"ultima":0.0001,"ask":0.01,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T12:30:00","timestamp":"2024-11-04T12:30:00"} + + {"symbol":"AAPL","underlying_price":222.03,"color":0.0000,"strike":262.500,"zomma":0.0000,"right":"CALL","implied_vol":0.2500,"iv_error":100.0000,"speed":0.0000,"ultima":0.0003,"ask":0.01,"expiration":"2024-11-08","bid":0.00,"underlying_timestamp":"2024-11-04T13:30:00","timestamp":"2024-11-04T13:30:00"}' + + /option/history/trade_greeks/third_order: + x-min-subscription: professional + get: + summary: Third Order Trade Greeks + operationId: option_history_trade_greeks_third_order + tags: + - Option + - History + description: | + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade_greeks/third_order?symbol=AAPL&expiration=20241108&date=20241104 + description: "Returns third order trade greeks for an option contract" + - url: http://localhost:25503/v3/option/history/trade_greeks/third_order?symbol=AAPL&expiration=*&date=20241104 + description: "Returns third order trade greeks for an full chain of option contracts" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns third order trade greeks for an option contract + content: + text/csv: + schema: + type: array + items: &id077 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + speed: + type: number + description: The speed. + zomma: + type: number + description: The zomma. + color: + type: string + description: The color. + ultima: + type: number + description: The ultima. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,speed,zomma,color,ultima,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,262.500,CALL,2024-11-04T09:53:54.069,156249981,255,255,255,255,125,1,9,0.01,0.0000,0.0000,-0.0005,22.3494,0.5749,0.0132,2024-11-04T09:53:54,221.33\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:47:14.764,546105677,255,255,255,255,131,2,5,81.32,0.0000,0.0000,-0.0013,2.2683,1.5937,0.0000,2024-11-04T11:47:14,221.22\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:47:56.669,548097371,255,255,255,255,130,3,7,81.16,0.0000,0.0000,0.0000,0.0000,0.0000,0.0011,2024-11-04T11:47:56,221.18\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:48:03.852,548397162,255,255,255,255,130,3,6,81.26,0.0000,0.0000,-0.0013,2.2709,1.5937,0.0000,2024-11-04T11:48:03,221.16\r\ + \nAAPL,2024-11-08,140.000,CALL,2024-11-04T11:48:51.11,550463381,255,255,255,255,131,1,5,81.27,0.0000,0.0000,-0.0003,1.8578,1.3968,0.0000,2024-11-04T11:48:51,221.19\r\ + \n" + application/json: + schema: &id078 + type: array + items: *id077 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.33 + - 221.22 + - 221.18 + - 221.16 + - 221.19 + color: + - -0.0005 + - -0.0013 + - 0.0 + - -0.0013 + - -0.0003 + strike: + - 262.5 + - 140.0 + - 140.0 + - 140.0 + - 140.0 + zomma: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.5749 + - 1.5937 + - 0.0 + - 1.5937 + - 1.3968 + iv_error: + - 0.0132 + - 0.0 + - 0.0011 + - 0.0 + - 0.0 + speed: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + ultima: + - 22.3494 + - 2.2683 + - 0.0 + - 2.2709 + - 1.8578 + sequence: + - 156249981 + - 546105677 + - 548097371 + - 548397162 + - 550463381 + condition: + - 125 + - 131 + - 130 + - 130 + - 131 + size: + - 1 + - 2 + - 3 + - 3 + - 1 + price: + - 0.01 + - 81.32 + - 81.16 + - 81.26 + - 81.27 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 9 + - 5 + - 7 + - 6 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:53:54' + - '2024-11-04T11:47:14' + - '2024-11-04T11:47:56' + - '2024-11-04T11:48:03' + - '2024-11-04T11:48:51' + timestamp: + - '2024-11-04T09:53:54.069' + - '2024-11-04T11:47:14.764' + - '2024-11-04T11:47:56.669' + - '2024-11-04T11:48:03.852' + - '2024-11-04T11:48:51.11' + application/x-ndjson: + schema: *id078 + example: '{"symbol":"AAPL","underlying_price":221.33,"color":-0.0005,"strike":262.500,"zomma":0.0000,"right":"CALL","implied_vol":0.5749,"iv_error":0.0132,"speed":0.0000,"ultima":22.3494,"sequence":156249981,"condition":125,"size":1,"price":0.01,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":9,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:53:54","timestamp":"2024-11-04T09:53:54.069"} + + {"symbol":"AAPL","underlying_price":221.22,"color":-0.0013,"strike":140.000,"zomma":0.0000,"right":"CALL","implied_vol":1.5937,"iv_error":0.0000,"speed":0.0000,"ultima":2.2683,"sequence":546105677,"condition":131,"size":2,"price":81.32,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:47:14","timestamp":"2024-11-04T11:47:14.764"} + + {"symbol":"AAPL","underlying_price":221.18,"color":0.0000,"strike":140.000,"zomma":0.0000,"right":"CALL","implied_vol":0.0000,"iv_error":0.0011,"speed":0.0000,"ultima":0.0000,"sequence":548097371,"condition":130,"size":3,"price":81.16,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":7,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:47:56","timestamp":"2024-11-04T11:47:56.669"} + + {"symbol":"AAPL","underlying_price":221.16,"color":-0.0013,"strike":140.000,"zomma":0.0000,"right":"CALL","implied_vol":1.5937,"iv_error":0.0000,"speed":0.0000,"ultima":2.2709,"sequence":548397162,"condition":130,"size":3,"price":81.26,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:48:03","timestamp":"2024-11-04T11:48:03.852"} + + {"symbol":"AAPL","underlying_price":221.19,"color":-0.0003,"strike":140.000,"zomma":0.0000,"right":"CALL","implied_vol":1.3968,"iv_error":0.0000,"speed":0.0000,"ultima":1.8578,"sequence":550463381,"condition":131,"size":1,"price":81.27,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"underlying_timestamp":"2024-11-04T11:48:51","timestamp":"2024-11-04T11:48:51.11"}' + + /option/history/greeks/implied_volatility: + x-min-subscription: standard + get: + summary: Implied Volatility + operationId: option_history_greeks_implied_volatility + tags: + - Option + - History + description: | + - Returns implied volatilies calculated using the national best bid, mid, and ask price of the option respectively. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/greeks/implied_volatility?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104&interval=5m + description: "Returns 5m interval implied volatility for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration_no_star" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns 5m interval implied volatility for an option contract + content: + text/csv: + schema: + type: array + items: &id079 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid: + type: number + description: The last NBBO bid price. + bid_implied_vol: + type: number + description: The implied volatiltiy calculated using the bid price. + midpoint: + type: number + description: The midpoint calculated by averaging the bid & ask prices. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + ask: + type: number + description: The last NBBO ask price. + ask_implied_vol: + type: number + description: The implied volatiltiy calculated using the ask price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,bid,bid_implied_vol,midpoint,implied_vol,ask,ask_implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00,0.00,0.0000,0.00,0.0000,0.00,0.0000,100.0000,2024-11-04T09:30:00,221.00\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:35:00,3.75,0.3640,3.80,0.3693,3.85,0.3747,0.0000,2024-11-04T09:35:00,220.66\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:40:00,3.70,0.3643,3.75,0.3698,3.80,0.3752,0.0000,2024-11-04T09:40:00,220.56\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:45:00,3.75,0.3518,3.80,0.3574,3.85,0.3627,0.0000,2024-11-04T09:45:00,220.86\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:50:00,3.85,0.3417,3.90,0.3474,3.95,0.3527,0.0000,2024-11-04T09:50:00,221.20\r\ + \n" + application/json: + schema: &id080 + type: array + items: *id079 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 220.66 + - 220.56 + - 220.86 + - 221.2 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.0 + - 0.3693 + - 0.3698 + - 0.3574 + - 0.3474 + iv_error: + - 100.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid_implied_vol: + - 0.0 + - 0.364 + - 0.3643 + - 0.3518 + - 0.3417 + ask: + - 0.0 + - 3.85 + - 3.8 + - 3.85 + - 3.95 + midpoint: + - 0.0 + - 3.8 + - 3.75 + - 3.8 + - 3.9 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ask_implied_vol: + - 0.0 + - 0.3747 + - 0.3752 + - 0.3627 + - 0.3527 + bid: + - 0.0 + - 3.75 + - 3.7 + - 3.75 + - 3.85 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:35:00' + - '2024-11-04T09:40:00' + - '2024-11-04T09:45:00' + - '2024-11-04T09:50:00' + application/x-ndjson: + schema: *id080 + example: '{"symbol":"AAPL","underlying_price":221.00,"strike":220.000,"right":"CALL","implied_vol":0.0000,"iv_error":100.0000,"bid_implied_vol":0.0000,"ask":0.00,"midpoint":0.00,"expiration":"2024-11-08","ask_implied_vol":0.0000,"bid":0.00,"underlying_timestamp":"2024-11-04T09:30:00","timestamp":"2024-11-04T09:30:00"} + + {"symbol":"AAPL","underlying_price":220.66,"strike":220.000,"right":"CALL","implied_vol":0.3693,"iv_error":0.0000,"bid_implied_vol":0.3640,"ask":3.85,"midpoint":3.80,"expiration":"2024-11-08","ask_implied_vol":0.3747,"bid":3.75,"underlying_timestamp":"2024-11-04T09:35:00","timestamp":"2024-11-04T09:35:00"} + + {"symbol":"AAPL","underlying_price":220.56,"strike":220.000,"right":"CALL","implied_vol":0.3698,"iv_error":0.0000,"bid_implied_vol":0.3643,"ask":3.80,"midpoint":3.75,"expiration":"2024-11-08","ask_implied_vol":0.3752,"bid":3.70,"underlying_timestamp":"2024-11-04T09:40:00","timestamp":"2024-11-04T09:40:00"} + + {"symbol":"AAPL","underlying_price":220.86,"strike":220.000,"right":"CALL","implied_vol":0.3574,"iv_error":0.0000,"bid_implied_vol":0.3518,"ask":3.85,"midpoint":3.80,"expiration":"2024-11-08","ask_implied_vol":0.3627,"bid":3.75,"underlying_timestamp":"2024-11-04T09:45:00","timestamp":"2024-11-04T09:45:00"} + + {"symbol":"AAPL","underlying_price":221.20,"strike":220.000,"right":"CALL","implied_vol":0.3474,"iv_error":0.0000,"bid_implied_vol":0.3417,"ask":3.95,"midpoint":3.90,"expiration":"2024-11-08","ask_implied_vol":0.3527,"bid":3.85,"underlying_timestamp":"2024-11-04T09:50:00","timestamp":"2024-11-04T09:50:00"}' + + /option/history/trade_greeks/implied_volatility: + x-min-subscription: professional + get: + summary: Trade Implied Volatility + operationId: option_history_trade_greeks_implied_volatility + tags: + - Option + - History + description: | + - Returns implied volatilies calculated using the trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option-Greeks.html). + x-sample-urls: + - url: http://localhost:25503/v3/option/history/trade_greeks/implied_volatility?symbol=AAPL&expiration=20241108&strike=220.000&right=call&date=20241104 + description: "Returns implied volatility for an option contract" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/annual_dividend" + - $ref: "#/components/parameters/rate_type" + - $ref: "#/components/parameters/rate_value" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns implied volatility for an option contract + content: + text/csv: + schema: + type: array + items: &id081 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + implied_vol: + type: number + description: The implied volatiltiy calculated using the trade price. + iv_error: + type: number + description: 'IV Error: the value of the option calculated using the implied volatiltiy divided by the + actual value reported in the quote. This value will increase as the strike price recedes from the + underlying price.' + underlying_timestamp: + type: string + format: date-time + description: The underlying date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + underlying_price: + type: number + description: The midpoint of the underlying at the time of the option trade. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price,implied_vol,iv_error,underlying_timestamp,underlying_price\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00.471,18902138,255,255,255,255,130,2,22,3.90,0.3598,0.0002,2024-11-04T09:30:00,221.00\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:01.626,19368856,255,255,255,255,130,1,6,4.25,0.3876,0.0000,2024-11-04T09:30:01,221.17\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:01.698,19403970,255,255,255,255,130,1,6,4.22,0.3842,-0.0002,2024-11-04T09:30:01,221.17\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:02.064,19598457,255,255,255,255,18,1,5,4.15,0.3640,-0.0001,2024-11-04T09:30:02,221.37\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:02.064,19598464,255,255,255,255,18,1,5,4.15,0.3640,-0.0001,2024-11-04T09:30:02,221.37\r\ + \n" + application/json: + schema: &id082 + type: array + items: *id081 + example: + symbol: + - AAPL + - AAPL + - AAPL + - AAPL + - AAPL + underlying_price: + - 221.0 + - 221.17 + - 221.17 + - 221.37 + - 221.37 + strike: + - 220.0 + - 220.0 + - 220.0 + - 220.0 + - 220.0 + right: + - CALL + - CALL + - CALL + - CALL + - CALL + implied_vol: + - 0.3598 + - 0.3876 + - 0.3842 + - 0.364 + - 0.364 + iv_error: + - 0.0002 + - 0.0 + - -0.0002 + - -0.0001 + - -0.0001 + sequence: + - 18902138 + - 19368856 + - 19403970 + - 19598457 + - 19598464 + condition: + - 130 + - 130 + - 130 + - 18 + - 18 + size: + - 2 + - 1 + - 1 + - 1 + - 1 + price: + - 3.9 + - 4.25 + - 4.22 + - 4.15 + - 4.15 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + expiration: + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + - '2024-11-08' + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 22 + - 6 + - 6 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + underlying_timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:30:01' + - '2024-11-04T09:30:01' + - '2024-11-04T09:30:02' + - '2024-11-04T09:30:02' + timestamp: + - '2024-11-04T09:30:00.471' + - '2024-11-04T09:30:01.626' + - '2024-11-04T09:30:01.698' + - '2024-11-04T09:30:02.064' + - '2024-11-04T09:30:02.064' + application/x-ndjson: + schema: *id082 + example: '{"symbol":"AAPL","underlying_price":221.00,"strike":220.000,"right":"CALL","implied_vol":0.3598,"iv_error":0.0002,"sequence":18902138,"condition":130,"size":2,"price":3.90,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":22,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:30:00","timestamp":"2024-11-04T09:30:00.471"} + + {"symbol":"AAPL","underlying_price":221.17,"strike":220.000,"right":"CALL","implied_vol":0.3876,"iv_error":0.0000,"sequence":19368856,"condition":130,"size":1,"price":4.25,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:30:01","timestamp":"2024-11-04T09:30:01.626"} + + {"symbol":"AAPL","underlying_price":221.17,"strike":220.000,"right":"CALL","implied_vol":0.3842,"iv_error":-0.0002,"sequence":19403970,"condition":130,"size":1,"price":4.22,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":6,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:30:01","timestamp":"2024-11-04T09:30:01.698"} + + {"symbol":"AAPL","underlying_price":221.37,"strike":220.000,"right":"CALL","implied_vol":0.3640,"iv_error":-0.0001,"sequence":19598457,"condition":18,"size":1,"price":4.15,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:30:02","timestamp":"2024-11-04T09:30:02.064"} + + {"symbol":"AAPL","underlying_price":221.37,"strike":220.000,"right":"CALL","implied_vol":0.3640,"iv_error":-0.0001,"sequence":19598464,"condition":18,"size":1,"price":4.15,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":5,"ext_condition3":255,"underlying_timestamp":"2024-11-04T09:30:02","timestamp":"2024-11-04T09:30:02.064"}' + + /option/at_time/trade: + x-min-subscription: standard + get: + summary: Trade + operationId: option_at_time_trade + tags: + - Option + - At-Time + description: | + - Returns the last trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a specified millisecond of the day. + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) for options, so they can be ignored. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the trade should be provided for. + x-sample-urls: + - url: http://localhost:25503/v3/option/at_time/trade?symbol=AAPL&expiration=20241108&strike=220.000&right=call&start_date=20241104&end_date=20241104&time_of_day=09:30:01.000 + description: "Returns the last trade for an option contract" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last trade for an option contract + content: + text/csv: + schema: + type: array + items: &id083 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + example: "symbol,expiration,strike,right,timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00.471,18902138,255,255,255,255,130,2,22,3.90\r\n" + application/json: + schema: &id084 + type: array + items: *id083 + example: + symbol: + - AAPL + strike: + - 220.0 + right: + - CALL + sequence: + - 18902138 + condition: + - 130 + size: + - 2 + price: + - 3.9 + ext_condition2: + - 255 + ext_condition1: + - 255 + expiration: + - '2024-11-08' + ext_condition4: + - 255 + exchange: + - 22 + ext_condition3: + - 255 + timestamp: + - '2024-11-04T09:30:00.471' + application/x-ndjson: + schema: *id084 + example: '{"symbol":"AAPL","strike":220.000,"right":"CALL","sequence":18902138,"condition":130,"size":2,"price":3.90,"ext_condition2":255,"ext_condition1":255,"expiration":"2024-11-08","ext_condition4":255,"exchange":22,"ext_condition3":255,"timestamp":"2024-11-04T09:30:00.471"}' + + /option/at_time/quote: + x-min-subscription: value + get: + summary: Quote + operationId: option_at_time_quote + tags: + - Option + - At-Time + description: | + - Returns the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a specified millisecond of the day. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the quote should be provided for. + x-sample-urls: + - url: http://localhost:25503/v3/option/at_time/quote?symbol=AAPL&expiration=20241108&strike=220.000&right=call&start_date=20241104&end_date=20241104&time_of_day=09:30:01.000 + description: "Returns the last quote for an option contract" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/expiration" + - $ref: "#/components/parameters/strike" + - $ref: "#/components/parameters/right" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns the last quote for an option contract + content: + text/csv: + schema: + type: array + items: &id085 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + expiration: + type: string + format: date + description: Expiration date of the contract in YYYY-MM-DD format. + strike: + type: number + description: Strike price of the contract in dollars 180.00 + right: + type: string + description: Indicates whether the contract is a call or put option. + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "symbol,expiration,strike,right,timestamp,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \nAAPL,2024-11-08,220.000,CALL,2024-11-04T09:30:00.91,129,69,3.95,50,14,47,4.10,50\r\n" + application/json: + schema: &id086 + type: array + items: *id085 + example: + symbol: + - AAPL + ask_size: + - 14 + ask_condition: + - 50 + strike: + - 220.0 + right: + - CALL + bid_size: + - 129 + ask_exchange: + - 47 + bid_exchange: + - 69 + ask: + - 4.1 + expiration: + - '2024-11-08' + bid: + - 3.95 + bid_condition: + - 50 + timestamp: + - '2024-11-04T09:30:00.91' + application/x-ndjson: + schema: *id086 + example: '{"symbol":"AAPL","ask_size":14,"ask_condition":50,"strike":220.000,"right":"CALL","bid_size":129,"ask_exchange":47,"bid_exchange":69,"ask":4.10,"expiration":"2024-11-08","bid":3.95,"bid_condition":50,"timestamp":"2024-11-04T09:30:00.91"}' + +# +# INDEX ENDPOINTS +# + /index/list/symbols: + x-min-subscription: free + get: + summary: Symbols + operationId: index_list_symbols + tags: + - Index + - List + description: | + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/index/list/symbols + description: "List all symbols for indices" + parameters: + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all symbols for indices + content: + text/csv: + schema: + type: array + items: &id087 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + example: "symbol\r\nAASGI\r\nAASUS\r\nACNAC\r\nACNIT\r\nACNRE\r\n" + application/json: + schema: &id088 + type: array + items: *id087 + example: + symbol: + - AASGI + - AASUS + - ACNAC + - ACNIT + - ACNRE + application/x-ndjson: + schema: *id088 + example: '{"symbol":"AASGI"} + + {"symbol":"AASUS"} + + {"symbol":"ACNAC"} + + {"symbol":"ACNIT"} + + {"symbol":"ACNRE"}' + + /index/list/dates: + x-min-subscription: free + get: + summary: Dates + operationId: index_list_dates + tags: + - Index + - List + description: | + Lists all dates of data that are available for a index with a given request type and symbol. This endpoint is updated overnight. + x-sample-urls: + - url: http://localhost:25503/v3/index/list/dates?symbol=SPX + description: "List all dates for a index for a given symbol" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: List all dates for a index for a given symbol + content: + text/csv: + schema: + type: array + items: &id089 + type: object + properties: + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + date: + type: string + format: date + description: The date formated as YYYY-MM-DD. + example: "symbol,date\r\nSPX,2023-04-20\r\nSPX,2023-04-21\r\nSPX,2023-04-17\r\nSPX,2023-04-18\r\nSPX,2023-04-19\r\ + \n" + application/json: + schema: &id090 + type: array + items: *id089 + example: + date: + - '2023-04-20' + - '2023-04-21' + - '2023-04-17' + - '2023-04-18' + - '2023-04-19' + symbol: + - SPX + - SPX + - SPX + - SPX + - SPX + application/x-ndjson: + schema: *id090 + example: '{"date":"2023-04-20","symbol":"SPX"} + + {"date":"2023-04-21","symbol":"SPX"} + + {"date":"2023-04-17","symbol":"SPX"} + + {"date":"2023-04-18","symbol":"SPX"} + + {"date":"2023-04-19","symbol":"SPX"}' + + /index/snapshot/ohlc: + x-min-subscription: standard + get: + summary: Open High Low Close + operationId: index_snapshot_ohlc + tags: + - Index + - Snapshot + description: | + - Retrieves the real-time current day OHLC. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + x-sample-urls: + - url: http://localhost:25503/v3/index/snapshot/ohlc?symbol=SPX + description: "Returns OHLC for a given index price change" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given index price change + content: + text/csv: + schema: + type: array + items: &id091 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + example: "timestamp,symbol,open,high,low,close,volume,count\r\n2025-08-20T16:02:06,SPX,6406.62,6408.40,6343.86,6395.78,0,0\r\ + \n" + application/json: + schema: &id092 + type: array + items: *id091 + example: + volume: + - 0 + symbol: + - SPX + high: + - 6408.4 + low: + - 6343.86 + count: + - 0 + close: + - 6395.78 + open: + - 6406.62 + timestamp: + - '2025-08-20T16:02:06' + application/x-ndjson: + schema: *id092 + example: '{"volume":0,"symbol":"SPX","high":6408.40,"low":6343.86,"count":0,"close":6395.78,"open":6406.62,"timestamp":"2025-08-20T16:02:06"}' + + /index/snapshot/price: + x-min-subscription: standard + get: + summary: Price + operationId: index_snapshot_price + tags: + - Index + - Snapshot + description: | + - Retrieves a real-time last index price. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + x-sample-urls: + - url: http://localhost:25503/v3/index/snapshot/price?symbol=SPX + description: "Returns last index price" + parameters: + - $ref: "#/components/parameters/multi_symbol" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns last index price + content: + text/csv: + schema: + type: array + items: &id093 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + symbol: + type: string + description: The symbol of the contract, or stock / underlying asset / option / index. + price: + type: number + description: The trade price. + example: "timestamp,symbol,price\r\n2025-08-20T16:02:06,SPX,6395.78\r\n" + application/json: + schema: &id094 + type: array + items: *id093 + example: + symbol: + - SPX + price: + - 6395.78 + timestamp: + - '2025-08-20T16:02:06' + application/x-ndjson: + schema: *id094 + example: '{"symbol":"SPX","price":6395.78,"timestamp":"2025-08-20T16:02:06"}' + + /index/history/eod: + x-min-subscription: free + get: + summary: End of Day + operationId: index_history_eod + tags: + - Index + - History + description: | + - Since [the indices feeds](/Articles/Data-And-Requests/The-SIPs.html) do not provide a national EOD report, Theta Data generates a national EOD report at 17:15 each day. + x-sample-urls: + - url: http://localhost:25503/v3/index/history/eod?symbol=SPX&start_date=20241104&end_date=20241108 + description: "Returns EOD report for a given symbol between specified dates (inclusive)" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns EOD report for a given symbol between specified dates (inclusive) + content: + text/csv: + schema: + type: array + items: &id095 + type: object + properties: + created: + type: string + format: date-time + description: The date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + last_trade: + type: string + format: date-time + description: The last trade date formated as YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + bid_size: + type: integer + description: The last NBBO bid size. + bid_exchange: + type: integer + description: The last NBBO bid [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + bid: + type: number + description: The last NBBO bid price. + bid_condition: + type: integer + description: The last NBBO bid [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + ask_size: + type: integer + description: The last NBBO ask size. + ask_exchange: + type: integer + description: The last NBBO ask [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html). + ask: + type: number + description: The last NBBO ask price. + ask_condition: + type: integer + description: The last NBBO ask [condition](/Articles/Errors-Exchanges-Conditions/Quote-Conditions.html). + example: "created,last_trade,open,high,low,close,volume,count,bid_size,bid_exchange,bid,bid_condition,ask_size,ask_exchange,ask,ask_condition\r\ + \n2024-11-04T17:19:50.198,2024-11-04T16:03:03,5725.15,5741.43,5696.51,5712.69,0,0,0,0,0.00,0,0,0,0.00,0\r\n\ + 2024-11-05T17:15:03.061,2024-11-05T16:02:30,5722.43,5783.44,5722.10,5782.76,0,0,0,0,0.00,0,0,0,0.00,0\r\n\ + 2024-11-06T17:16:28.297,2024-11-06T16:01:37,5864.89,5936.14,5864.89,5929.04,0,0,0,0,0.00,0,0,0,0.00,0\r\n\ + 2024-11-07T17:17:17.218,2024-11-07T16:02:49,5947.21,5983.84,5947.21,5973.10,0,0,0,0,0.00,0,0,0,0.00,0\r\n\ + 2024-11-08T17:21:08.187,2024-11-08T16:01:15,5976.76,6012.45,5976.76,5995.54,0,0,0,0,0.00,0,0,0,0.00,0\r\n" + application/json: + schema: &id096 + type: array + items: *id095 + example: + ask_size: + - 0 + - 0 + - 0 + - 0 + - 0 + last_trade: + - '2024-11-04T16:03:03' + - '2024-11-05T16:02:30' + - '2024-11-06T16:01:37' + - '2024-11-07T16:02:49' + - '2024-11-08T16:01:15' + created: + - '2024-11-04T17:19:50.198' + - '2024-11-05T17:15:03.061' + - '2024-11-06T17:16:28.297' + - '2024-11-07T17:17:17.218' + - '2024-11-08T17:21:08.187' + ask_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + count: + - 0 + - 0 + - 0 + - 0 + - 0 + volume: + - 0 + - 0 + - 0 + - 0 + - 0 + high: + - 5741.43 + - 5783.44 + - 5936.14 + - 5983.84 + - 6012.45 + low: + - 5696.51 + - 5722.1 + - 5864.89 + - 5947.21 + - 5976.76 + bid_size: + - 0 + - 0 + - 0 + - 0 + - 0 + ask_exchange: + - 0 + - 0 + - 0 + - 0 + - 0 + bid_exchange: + - 0 + - 0 + - 0 + - 0 + - 0 + ask: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + bid_condition: + - 0 + - 0 + - 0 + - 0 + - 0 + close: + - 5712.69 + - 5782.76 + - 5929.04 + - 5973.1 + - 5995.54 + open: + - 5725.15 + - 5722.43 + - 5864.89 + - 5947.21 + - 5976.76 + application/x-ndjson: + schema: *id096 + example: '{"ask_size":0,"last_trade":"2024-11-04T16:03:03","created":"2024-11-04T17:19:50.198","ask_condition":0,"count":0,"volume":0,"high":5741.43,"low":5696.51,"bid_size":0,"ask_exchange":0,"bid_exchange":0,"ask":0.00,"bid":0.00,"bid_condition":0,"close":5712.69,"open":5725.15} + + {"ask_size":0,"last_trade":"2024-11-05T16:02:30","created":"2024-11-05T17:15:03.061","ask_condition":0,"count":0,"volume":0,"high":5783.44,"low":5722.10,"bid_size":0,"ask_exchange":0,"bid_exchange":0,"ask":0.00,"bid":0.00,"bid_condition":0,"close":5782.76,"open":5722.43} + + {"ask_size":0,"last_trade":"2024-11-06T16:01:37","created":"2024-11-06T17:16:28.297","ask_condition":0,"count":0,"volume":0,"high":5936.14,"low":5864.89,"bid_size":0,"ask_exchange":0,"bid_exchange":0,"ask":0.00,"bid":0.00,"bid_condition":0,"close":5929.04,"open":5864.89} + + {"ask_size":0,"last_trade":"2024-11-07T16:02:49","created":"2024-11-07T17:17:17.218","ask_condition":0,"count":0,"volume":0,"high":5983.84,"low":5947.21,"bid_size":0,"ask_exchange":0,"bid_exchange":0,"ask":0.00,"bid":0.00,"bid_condition":0,"close":5973.10,"open":5947.21} + + {"ask_size":0,"last_trade":"2024-11-08T16:01:15","created":"2024-11-08T17:21:08.187","ask_condition":0,"count":0,"volume":0,"high":6012.45,"low":5976.76,"bid_size":0,"ask_exchange":0,"bid_exchange":0,"ask":0.00,"bid":0.00,"bid_condition":0,"close":5995.54,"open":5976.76}' + + /index/history/ohlc: + x-min-subscription: standard + get: + summary: Open High Low Close + operationId: index_history_ohlc + tags: + - Index + - History + description: | + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + x-sample-urls: + - url: http://localhost:25503/v3/index/history/ohlc?symbol=SPX&start_date=20241104&end_date=20241104&interval=1m + description: "Returns OHLC for a given symbol between specified dates (inclusive) with a one minute interval" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns OHLC for a given symbol between specified dates (inclusive) with a one minute interval + content: + text/csv: + schema: + type: array + items: &id097 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + open: + type: number + description: The opening trade price. + high: + type: number + description: The highest traded price. + low: + type: number + description: The lowest traded price. + close: + type: number + description: The closing traded price. + volume: + type: integer + description: The amount of contracts / shares traded. + count: + type: integer + description: The amount of trades. + vwap: + type: number + description: The volume weighted average price of the given interval. + example: "timestamp,open,high,low,close,volume,count,vwap\r\n2024-11-04T09:30:00,5725.15,5731.27,5725.15,5728.56,0,0,0.00\r\ + \n2024-11-04T09:31:00,5728.90,5730.40,5724.53,5725.42,0,0,0.00\r\n2024-11-04T09:32:00,5725.48,5729.20,5723.55,5726.54,0,0,0.00\r\ + \n2024-11-04T09:33:00,5726.57,5726.71,5723.13,5723.13,0,0,0.00\r\n2024-11-04T09:34:00,5722.88,5723.33,5717.35,5717.64,0,0,0.00\r\ + \n" + application/json: + schema: &id098 + type: array + items: *id097 + example: + volume: + - 0 + - 0 + - 0 + - 0 + - 0 + high: + - 5731.27 + - 5730.4 + - 5729.2 + - 5726.71 + - 5723.33 + low: + - 5725.15 + - 5724.53 + - 5723.55 + - 5723.13 + - 5717.35 + vwap: + - 0.0 + - 0.0 + - 0.0 + - 0.0 + - 0.0 + count: + - 0 + - 0 + - 0 + - 0 + - 0 + close: + - 5728.56 + - 5725.42 + - 5726.54 + - 5723.13 + - 5717.64 + open: + - 5725.15 + - 5728.9 + - 5725.48 + - 5726.57 + - 5722.88 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:31:00' + - '2024-11-04T09:32:00' + - '2024-11-04T09:33:00' + - '2024-11-04T09:34:00' + application/x-ndjson: + schema: *id098 + example: '{"volume":0,"high":5731.27,"low":5725.15,"vwap":0.00,"count":0,"close":5728.56,"open":5725.15,"timestamp":"2024-11-04T09:30:00"} + + {"volume":0,"high":5730.40,"low":5724.53,"vwap":0.00,"count":0,"close":5725.42,"open":5728.90,"timestamp":"2024-11-04T09:31:00"} + + {"volume":0,"high":5729.20,"low":5723.55,"vwap":0.00,"count":0,"close":5726.54,"open":5725.48,"timestamp":"2024-11-04T09:32:00"} + + {"volume":0,"high":5726.71,"low":5723.13,"vwap":0.00,"count":0,"close":5723.13,"open":5726.57,"timestamp":"2024-11-04T09:33:00"} + + {"volume":0,"high":5723.33,"low":5717.35,"vwap":0.00,"count":0,"close":5717.64,"open":5722.88,"timestamp":"2024-11-04T09:34:00"}' + + /index/history/price: + x-min-subscription: value + get: + summary: Price + operationId: index_history_price + tags: + - Index + - History + description: | + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + - When the ``interval`` parameter is specified, the returned data represents the price at the exact time of each timestamp. If the timestamp in the response is 10:30:00, the price field represents the price at that exact time of the day. + - A price update from the exchange is omitted if the price remained the same from the previous update. + x-sample-urls: + - url: http://localhost:25503/v3/index/history/price?symbol=SPX&date=20241104&interval=1m + description: "Returns historical index price reports" + parameters: + - $ref: "#/components/parameters/date" + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_time" + - $ref: "#/components/parameters/end_time" + - $ref: "#/components/parameters/interval" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns historical index price reports + content: + text/csv: + schema: + type: array + items: &id099 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + price: + type: number + description: The trade price. + example: "timestamp,price\r\n2024-11-04T09:30:00,0.0\r\n2024-11-04T09:31:00,5728.56\r\n2024-11-04T09:32:00,5725.48\r\ + \n2024-11-04T09:33:00,5726.57\r\n2024-11-04T09:34:00,5722.88\r\n" + application/json: + schema: &id100 + type: array + items: *id099 + example: + price: + - 0.0 + - 5728.56 + - 5725.48 + - 5726.57 + - 5722.88 + timestamp: + - '2024-11-04T09:30:00' + - '2024-11-04T09:31:00' + - '2024-11-04T09:32:00' + - '2024-11-04T09:33:00' + - '2024-11-04T09:34:00' + application/x-ndjson: + schema: *id100 + example: '{"price":0.0,"timestamp":"2024-11-04T09:30:00"} + + {"price":5728.56,"timestamp":"2024-11-04T09:31:00"} + + {"price":5725.48,"timestamp":"2024-11-04T09:32:00"} + + {"price":5726.57,"timestamp":"2024-11-04T09:33:00"} + + {"price":5722.88,"timestamp":"2024-11-04T09:34:00"}' + + /index/at_time/price: + x-min-subscription: value + get: + summary: Price + operationId: index_at_time_price + tags: + - Index + - At-Time + description: | + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every second for popular indices like SPX. + - The ``time_of_day`` parameter represents the 00:00:00.000 ET that the price should be provided for. + x-sample-urls: + - url: http://localhost:25503/v3/index/at_time/price?symbol=SPX&start_date=20241104&end_date=20241108&time_of_day=09:30:01.000 + description: "Returns specific at time historical index price reports" + parameters: + - $ref: "#/components/parameters/single_symbol" + - $ref: "#/components/parameters/start_date" + - $ref: "#/components/parameters/end_date" + - $ref: "#/components/parameters/time_of_day" + - $ref: "#/components/parameters/format" + responses: + '200': + description: Returns specific at time historical index price reports + content: + text/csv: + schema: + type: array + items: &id101 + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp in YYYY-MM-DDTHH:mm:ss.SSS format. + sequence: + type: integer + description: The exchange [sequence](/Articles/Data-And-Requests/Making-Requests#trade-sequences). + ext_condition1: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition2: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition3: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + ext_condition4: + type: integer + description: Additional trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html)(s). + These can be ignored for options. + condition: + type: integer + description: The trade [condition](/Articles/Errors-Exchanges-Conditions/Trade-Conditions.html). + size: + type: integer + description: The amount of contracts / shares traded. + exchange: + type: integer + description: The [exchange](/Articles/Errors-Exchanges-Conditions/Exchanges.html) the trade was executed. + price: + type: number + description: The trade price. + example: "timestamp,sequence,ext_condition1,ext_condition2,ext_condition3,ext_condition4,condition,size,exchange,price\r\ + \n2024-11-04T09:30:01,0,255,255,255,255,0,0,5,5725.15\r\n2024-11-05T09:30:01,0,255,255,255,255,0,0,5,5722.43\r\ + \n2024-11-06T09:30:01,0,255,255,255,255,0,0,5,5864.89\r\n2024-11-07T09:30:01,0,255,255,255,255,0,0,5,5947.21\r\ + \n2024-11-08T09:30:01,0,255,255,255,255,0,0,5,5976.76\r\n" + application/json: + schema: &id102 + type: array + items: *id101 + example: + sequence: + - 0 + - 0 + - 0 + - 0 + - 0 + condition: + - 0 + - 0 + - 0 + - 0 + - 0 + size: + - 0 + - 0 + - 0 + - 0 + - 0 + price: + - 5725.15 + - 5722.43 + - 5864.89 + - 5947.21 + - 5976.76 + ext_condition2: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition1: + - 255 + - 255 + - 255 + - 255 + - 255 + ext_condition4: + - 255 + - 255 + - 255 + - 255 + - 255 + exchange: + - 5 + - 5 + - 5 + - 5 + - 5 + ext_condition3: + - 255 + - 255 + - 255 + - 255 + - 255 + timestamp: + - '2024-11-04T09:30:01' + - '2024-11-05T09:30:01' + - '2024-11-06T09:30:01' + - '2024-11-07T09:30:01' + - '2024-11-08T09:30:01' + application/x-ndjson: + schema: *id102 + example: '{"sequence":0,"condition":0,"size":0,"price":5725.15,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-04T09:30:01"} + + {"sequence":0,"condition":0,"size":0,"price":5722.43,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-05T09:30:01"} + + {"sequence":0,"condition":0,"size":0,"price":5864.89,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-06T09:30:01"} + + {"sequence":0,"condition":0,"size":0,"price":5947.21,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-07T09:30:01"} + + {"sequence":0,"condition":0,"size":0,"price":5976.76,"ext_condition2":255,"ext_condition1":255,"ext_condition4":255,"exchange":5,"ext_condition3":255,"timestamp":"2024-11-08T09:30:01"}' + + +components: + parameters: + # required parameters + single_symbol: + name: symbol + in: query + description: The stock or index symbol, or underlying symbol for options. + required: true + schema: + type: string + + multi_symbol: + name: symbol + in: query + description: The stock or index symbol, or underlying symbol for options. Specify '*' for all symbols or a comma separated list when appropriate. + required: true + schema: + type: array + items: + type: string + + opt_multi_symbol: + name: symbol + in: query + description: The stock or index symbol, or underlying symbol for options. + required: false + schema: + type: array + items: + type: string + + date: + name: date + in: query + description: The date to fetch data for. + required: true + schema: + type: string + format: date + + end_date: + name: end_date + in: query + description: The end date (inclusive). + required: true + schema: + type: string + format: date + + start_date: + name: start_date + in: query + description: The start date (inclusive). + required: true + schema: + type: string + format: date + + opt_end_date: + name: end_date + in: query + description: The end date (inclusive). + required: false + schema: + type: string + format: date + + opt_start_date: + name: start_date + in: query + description: The start date (inclusive). + required: false + schema: + type: string + format: date + + time_of_day: + name: time_of_day + in: query + description: The time of the day to fetch data for; assumed to be America/New_York. + required: true + schema: + type: string + format: time + + expiration: + name: expiration + in: query + description: The expiration of the contract in `YYYY-MM-DD` or `YYYYMMDD` format, or `*` for all expirations. + required: true + schema: + type: string + format: date + + expiration_no_star: + name: expiration + in: query + description: The expiration of the contract in `YYYY-MM-DD` or `YYYYMMDD` format. + required: true + schema: + type: string + format: date + + strike: + name: strike + in: query + description: The strike price of the contract in dollars (ie `100.00` for `$100.00`), or `*` for all strikes. + required: false + schema: + type: string + default: "*" + + interval: + name: interval + in: query + description: The size of the time interval must be one of the available options listed below. + required: true + schema: + type: string + enum: + - tick + - 10ms + - 100ms + - 500ms + - 1s + - 5s + - 10s + - 15s + - 30s + - 1m + - 5m + - 10m + - 15m + - 30m + - 1h + default: 1s + + security_type: + name: security_type + in: path + description: The security type. + required: true + schema: + type: string + enum: + - stock + - option + - index + + request_type: + name: request_type + in: path + description: The request type. + required: true + schema: + type: string + enum: + - trade + - quote + + + # non-required parameters + annual_dividend: + name: annual_dividend + in: query + description: The annualized expected dividend amount to be used in Greeks calculations. + required: false + schema: + type: number + format: float + + end_time: + name: end_time + in: query + description: The end time (inclusive) in the specified day. + required: false + schema: + type: string + format: time + default: "16:00:00" + + exclusive: + name: exclusive + in: query + description: If you prefer to match quotes with timestamps that are < the trade timestamp. + required: false + schema: + type: boolean + default: true + + format: + name: format + in: query + description: The format of the data when returned to the user. + required: false + schema: + type: string + enum: + - csv + - json + - ndjson + default: ndjson + + rate_type: + name: rate_type + in: query + description: The interest rate type to be used in a Greeks calculation. + required: false + schema: + type: string + enum: + - sofr + - treasury_m1 + - treasury_m3 + - treasury_m6 + - treasury_y1 + - treasury_y2 + - treasury_y3 + - treasury_y5 + - treasury_y7 + - treasury_y10 + - treasury_y20 + - treasury_y30 + default: sofr + + rate_value: + name: rate_value + in: query + description: The interest rate, as a percent, to be used in a Greeks calculation. + required: false + schema: + type: number + format: float + example: 5.0 + + right: + name: right + in: query + description: The right (call or put) of the contract. + required: false + schema: + type: string + enum: + - call + - put + - both + default: both + + start_time: + name: start_time + in: query + description: The start time (inclusive) in the specified day. + required: false + schema: + type: string + format: time + default: "09:30:00" + + stock_price: + name: stock_price + in: query + description: The underlying stock price to be used in the Greeks calculation. + required: false + schema: + type: number + format: float + + venue: + name: venue + in: query + description: Used to specify the venue of the real time or historic request. ``nqb`` = Nasdaq Basic; ``utp_cta`` = merged UTP & CTA. + required: false + schema: + type: string + enum: + - nqb + - utp_cta + default: nqb + + responses: + 200_OK: + description: "" + content: + text/csv: + schema: + type: string + + diff --git a/openapi/preprocess_td.py b/openapi/preprocess_td.py new file mode 100644 index 000000000..6dbd18040 --- /dev/null +++ b/openapi/preprocess_td.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python3 +# preprocess_openapi.py +# Usage: python preprocess_openapi.py input.yaml output.yaml + +from __future__ import annotations + +import sys +from typing import Any + +from ruamel.yaml import YAML + +yaml = YAML() +yaml.preserve_quotes = True + + +def infer_item_type(x: Any) -> str: + if isinstance(x, bool): + return "boolean" + if isinstance(x, int): + return "integer" + if isinstance(x, float): + return "number" + if isinstance(x, dict): + return "object" + # default + return "string" + + +def is_dict_of_lists(obj: Any) -> bool: + if not isinstance(obj, dict) or not obj: + return False + return all(isinstance(v, list) for v in obj.values()) + + +def coerce_schema_to_object_of_arrays(example: dict[str, list[Any]]) -> dict[str, Any]: + props = {} + for k, v in example.items(): + item_type = infer_item_type(v[0]) if v else "string" + props[k] = {"type": "array", "items": {"type": item_type}} + return {"type": "object", "properties": props, "required": list(example.keys())} + + +def obj_of_arrays_to_array_of_obj(schema: dict) -> dict | None: + if not isinstance(schema, dict) or schema.get("type") != "object": + return None + props = schema.get("properties") + if not isinstance(props, dict) or not props: + return None + # all properties are arrays with item types + if not all( + isinstance(v, dict) + and v.get("type") == "array" + and isinstance(v.get("items"), dict) + for v in props.values() + ): + return None + row_props = {} + for k, v in props.items(): + row_props[k] = v["items"] # carry through item schema (type/format/enum/etc.) + return { + "type": "array", + "items": { + "type": "object", + "properties": row_props, + "required": list(row_props.keys()), + # optional: keep titles/descriptions if you have them + }, + } + + +def normalize_json_response_schema(json_content: dict): + schema = json_content.get("schema") + fixed = obj_of_arrays_to_array_of_obj(schema) + if fixed: + json_content["schema"] = fixed + + +def try_fix_json_schema(json_content: dict[str, Any]) -> None: + """ + If the example is dict-of-lists, rewrite schema accordingly. + If schema says array but example is dict-of-lists, rewrite to object-of-arrays. + If there is no example, but schema clearly wrong (array w/ object items), leave it. + """ + example = json_content.get("example") + schema = json_content.get("schema") + + # If example shows dict-of-lists, prefer it as ground truth + if is_dict_of_lists(example): + json_content["schema"] = coerce_schema_to_object_of_arrays(example) + return + + # Fallback: if schema says array but provider actually returns dict-of-lists, + # and we have no example, we can’t safely infer keys. Leave as-is. + # If schema is object and missing properties but example present, fill them in. + if ( + isinstance(schema, dict) + and schema.get("type") == "object" + and "properties" not in schema + and is_dict_of_lists(example or {}) + ): + json_content["schema"] = coerce_schema_to_object_of_arrays( + example + ) # already handled above + + +def keep_only_application_json(content: dict[str, Any]) -> dict[str, Any]: + if "application/json" in content: + return {"application/json": content["application/json"]} + # If no JSON declared, drop all to force a regen failure (better than wrong types), + # or convert NDJSON to JSON string schema if you prefer. Here we drop. + return {} + + +def process(doc: dict[str, Any]) -> dict[str, Any]: + paths = doc.get("paths", {}) + for _, path_item in paths.items(): + if not isinstance(path_item, dict): + continue + for method, op in list(path_item.items()): + if method.lower() not in { + "get", + "post", + "put", + "patch", + "delete", + "options", + "head", + }: + continue + responses = op.get("responses") + if not isinstance(responses, dict): + continue + for _, resp in responses.items(): + if not isinstance(resp, dict): + continue + content = resp.get("content") + if not isinstance(content, dict): + continue + + # 1) Keep only application/json + new_content = keep_only_application_json(content) + if not new_content: + # remove content entirely if no JSON; generator will surface it + resp["content"] = {} + continue + + # 2) Fix JSON schema if dict-of-lists + json_content = new_content.get("application/json") + if isinstance(json_content, dict): + try_fix_json_schema(json_content) + # 3) Normalize object-of-arrays to array-of-objects + normalize_json_response_schema(json_content) + + resp["content"] = new_content + return doc + + +def main(): + if len(sys.argv) != 3: + print( + "Usage: python preprocess_openapi.py input.yaml output.yaml", + file=sys.stderr, + ) + sys.exit(2) + inf, outf = sys.argv[1], sys.argv[2] + with open(inf, "r", encoding="utf-8") as f: + doc = yaml.load(f) + doc = process(doc) + with open(outf, "w", encoding="utf-8") as f: + yaml.dump(doc, f) + + +if __name__ == "__main__": + main() diff --git a/openapi/swagger_cleaned.json b/openapi/swagger_cleaned.json new file mode 100644 index 000000000..2ad62fd2c --- /dev/null +++ b/openapi/swagger_cleaned.json @@ -0,0 +1,8122 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Silexx API", + "version": "v1" + }, + "paths": { + "/application/login": { + "post": { + "tags": [ + "ApplicationService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LoginRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LoginResponse" + } + } + } + } + } + } + }, + "/orders/createorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateOrderResponse" + } + } + } + } + } + } + }, + "/orders/createordercross": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateOrderCrossRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateOrderCrossResponse" + } + } + } + } + } + } + }, + "/orders/createmultilegorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMultiLegOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMultiLegOrderResponse" + } + } + } + } + } + } + }, + "/orders/createmultilegordercross": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMultiLegOrderCrossRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMultiLegOrderCrossResponse" + } + } + } + } + } + } + }, + "/orders/cancelorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelOrderResponse" + } + } + } + } + } + } + }, + "/orders/replaceorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelReplaceOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelReplaceOrderResponse" + } + } + } + } + } + } + }, + "/orders/replacemultilegorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelReplaceMultiLegOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelReplaceMultiLegOrderResponse" + } + } + } + } + } + } + }, + "/orders/validaterisk/createorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidateRiskResponse" + } + } + } + } + } + } + }, + "/orders/validaterisk/createordercross": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateOrderCrossRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidateRiskResponse" + } + } + } + } + } + } + }, + "/orders/validaterisk/createmultilegorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMultiLegOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidateRiskResponse" + } + } + } + } + } + } + }, + "/orders/validaterisk/createmultilegordercross": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateMultiLegOrderCrossRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidateRiskResponse" + } + } + } + } + } + } + }, + "/orders/validaterisk/replaceorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelReplaceOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidateRiskResponse" + } + } + } + } + } + } + }, + "/orders/validaterisk/replacemultilegorder": { + "post": { + "tags": [ + "OrderService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CancelReplaceMultiLegOrderRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ValidateRiskResponse" + } + } + } + } + } + } + }, + "/orders": { + "get": { + "tags": [ + "OrderService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListOrdersResponse" + } + } + } + } + } + } + }, + "/orders/tradeconfirms": { + "get": { + "tags": [ + "OrderService" + ], + "parameters": [ + { + "name": "accountIds", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "endTimeUtc", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "startTimeUtc", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "tradingFirmIds", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "userIds", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListTradeConfirmsResponse" + } + } + } + } + } + } + }, + "/orders/searchhistory": { + "get": { + "tags": [ + "OrderService" + ], + "parameters": [ + { + "name": "accountIds", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "toDt.year", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "toDt.month", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "toDt.day", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "fromDt.year", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "fromDt.month", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "fromDt.day", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SearchOrderHistoryResponse" + } + } + } + } + } + } + }, + "/portfolio/analyzepositions": { + "post": { + "tags": [ + "PortfolioService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnalyzePositionsRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnalyzePositionsResponse" + } + } + } + } + } + } + }, + "/portfolio/positions": { + "get": { + "tags": [ + "PortfolioService" + ], + "parameters": [ + { + "name": "all", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "accountId", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "accountIdAndSymbol.accountId", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "accountIdAndSymbol.symbol", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListPositionsResponse" + } + } + } + } + } + } + }, + "/portfolio/calculatemargins": { + "post": { + "tags": [ + "PortfolioService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalculateMarginRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CalculateMarginResponse" + } + } + } + } + } + } + }, + "/portfolio/riskradar": { + "post": { + "tags": [ + "PortfolioService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RiskRadarRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RiskRadarResponse" + } + } + } + } + } + } + }, + "/securities/securities": { + "post": { + "tags": [ + "SecurityService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListSecuritiesRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListSecuritiesResponse" + } + } + } + } + } + } + }, + "/securities/exchanges": { + "get": { + "tags": [ + "SecurityService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListExchangesResponse" + } + } + } + } + } + } + }, + "/securities/optionchains": { + "post": { + "tags": [ + "SecurityService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListOptionChainsRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListOptionChainsRepsonse" + } + } + } + } + } + } + }, + "/securities/flexoption": { + "post": { + "tags": [ + "SecurityService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateFlexOptionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateFlexOptionResponse" + } + } + } + } + } + } + }, + "/securities/easytoborrowsecurities": { + "post": { + "tags": [ + "SecurityService" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListEasyToBorrowSecuritiesRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListEasyToBorrowSecuritiesResponse" + } + } + } + } + } + } + }, + "/userdata/activeuser": { + "get": { + "tags": [ + "UserDataService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetActiveUserResponse" + } + } + } + } + } + } + }, + "/userdata/accounts": { + "get": { + "tags": [ + "UserDataService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListAccountsResponse" + } + } + } + } + } + } + }, + "/userdata/tradingfirms": { + "get": { + "tags": [ + "UserDataService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListTradingFirmsResponse" + } + } + } + } + } + } + }, + "/userdata/affiliatedtradingfirms": { + "get": { + "tags": [ + "UserDataService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListAffiliatedTradingFirmsResponse" + } + } + } + } + } + } + }, + "/userdata/p2paccounts": { + "get": { + "tags": [ + "UserDataService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListAccountsResponse" + } + } + } + } + } + } + }, + "/userdata/routes": { + "get": { + "tags": [ + "UserDataService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListRoutesResponse" + } + } + } + } + } + } + }, + "/utility/tradingholidays": { + "get": { + "tags": [ + "UtilityService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetTradingHolidaysResponse" + } + } + } + } + } + } + }, + "/utility/servertime": { + "get": { + "tags": [ + "UtilityService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetServerTimeResponse" + } + } + } + } + } + } + }, + "/utility/serverinfo": { + "get": { + "tags": [ + "UtilityService" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetServerInfoResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Account": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "billingCode": { + "type": "string" + }, + "ctiCode": { + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "equitiesCapacity": { + "$ref": "#/components/schemas/CapacityCode" + }, + "equitiesGiveUp": { + "type": "string" + }, + "equitiesMpid": { + "type": "string" + }, + "futuresClearingAccount": { + "type": "string" + }, + "futuresClearingRange": { + "$ref": "#/components/schemas/ClearingRange" + }, + "futuresCmta": { + "type": "string" + }, + "futuresExecutionBroker": { + "type": "string" + }, + "name": { + "type": "string" + }, + "occActionableId": { + "type": "string" + }, + "optionsClearingAccount": { + "type": "string" + }, + "optionsClearingRange": { + "$ref": "#/components/schemas/ClearingRange" + }, + "optionsCmta": { + "type": "string" + }, + "optionsEfid": { + "type": "string" + }, + "optionsGiveUp": { + "type": "string" + }, + "routingSessionGroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RoutingSessionGroup" + } + }, + "status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "tag1": { + "type": "string" + }, + "tradingFirmId": { + "type": "integer", + "format": "int32" + }, + "type": { + "$ref": "#/components/schemas/AccountType" + }, + "createdTs": { + "type": "string" + }, + "optionalData": { + "type": "string" + }, + "positionScript": { + "$ref": "#/components/schemas/AccountScript" + }, + "buyingPowerScript": { + "$ref": "#/components/schemas/AccountScript" + }, + "clearingScript": { + "$ref": "#/components/schemas/AccountScript" + } + }, + "additionalProperties": false + }, + "AccountScript": { + "type": "object", + "properties": { + "scriptName": { + "type": "string" + }, + "accountName": { + "type": "string" + } + }, + "additionalProperties": false + }, + "AccountStatus": { + "enum": [ + "ACCOUNT_STATUS_VIEW_ONLY", + "ACCOUNT_STATUS_ACTIVE", + "ACCOUNT_STATUS_LIQUIDATION", + "ACCOUNT_STATUS_DELETED" + ], + "type": "string" + }, + "AccountType": { + "enum": [ + "ACCOUNT_TYPE_CASH", + "ACCOUNT_TYPE_MARGIN", + "ACCOUNT_TYPE_INVENTORY" + ], + "type": "string" + }, + "AnalyzePositionItem": { + "type": "object", + "properties": { + "price": { + "type": "number", + "format": "double" + }, + "qty": { + "type": "integer", + "format": "int32" + }, + "symbol": { + "type": "string" + }, + "volatility": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "AnalyzePositionsRequest": { + "type": "object", + "properties": { + "asOfTs": { + "type": "string" + }, + "evaluateAtExpiry": { + "type": "boolean" + }, + "evaluateAtStrike": { + "type": "boolean" + }, + "evaluationAsOf": { + "type": "array", + "items": { + "type": "string" + } + }, + "positions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnalyzePositionItem" + } + }, + "price": { + "type": "number", + "format": "double" + }, + "underlyingVolatility": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "historicalVolatilityDays": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "volatilityChange": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "AnalyzePositionsResponse": { + "type": "object", + "properties": { + "analysis": { + "$ref": "#/components/schemas/PositionAnalysis" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "Any": { + "required": [ + "@type" + ], + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "CalculateMarginRequest": { + "type": "object", + "properties": { + "accountIds": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "marginDataType": { + "$ref": "#/components/schemas/MarginDataType" + }, + "positionsByAccountId": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalculateMarginRequestPositionList" + } + }, + "evalMode": { + "$ref": "#/components/schemas/RiskEvalMode" + }, + "source": { + "$ref": "#/components/schemas/PositionSource" + } + }, + "additionalProperties": false + }, + "CalculateMarginRequestPosition": { + "type": "object", + "properties": { + "isSimulatedPosition": { + "type": "boolean" + }, + "qty": { + "type": "number", + "format": "double" + }, + "symbol": { + "type": "string" + } + }, + "additionalProperties": false + }, + "CalculateMarginRequestPositionList": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "positions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CalculateMarginRequestPosition" + } + } + }, + "additionalProperties": false + }, + "CalculateMarginResponse": { + "type": "object", + "properties": { + "marginData": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MarginData" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CancelOrderRequest": { + "type": "object", + "properties": { + "curOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "permOrdId": { + "type": "string" + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "CancelOrderResponse": { + "type": "object", + "properties": { + "submitTs": { + "type": "string" + }, + "reqOrdId": { + "type": "string" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CancelReplaceMultiLegOrderRequest": { + "type": "object", + "properties": { + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "curOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "permOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "qty": { + "type": "number", + "format": "double" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "CancelReplaceMultiLegOrderResponse": { + "type": "object", + "properties": { + "submitTs": { + "type": "string" + }, + "reqOrdId": { + "type": "string" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CancelReplaceOrderRequest": { + "type": "object", + "properties": { + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "curOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "permOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "qty": { + "type": "number", + "format": "double" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "CancelReplaceOrderResponse": { + "type": "object", + "properties": { + "submitTs": { + "type": "string" + }, + "reqOrdId": { + "type": "string" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CapacityCode": { + "enum": [ + "CAPACITY_CODE_NOT_SET", + "CAPACITY_CODE_AGENT", + "CAPACITY_CODE_PRINCIPAL" + ], + "type": "string" + }, + "ClaimType": { + "enum": [ + "CLAIM_TYPE_UNDEFINED", + "CLAIM_TYPE_UI_MODULE_PERMISSION", + "CLAIM_TYPE_FUNCTIONALITY_PERMISSION", + "CLAIM_TYPE_SYSOP_PERMISSION" + ], + "type": "string" + }, + "ClearingInfo": { + "type": "object", + "properties": { + "clearingOptionalData": { + "type": "string" + }, + "ctiCode": { + "type": "string" + }, + "efid": { + "type": "string" + }, + "eqCapacity": { + "$ref": "#/components/schemas/CapacityCode" + }, + "eqClearingAccount": { + "type": "string" + }, + "eqGiveUp": { + "type": "string" + }, + "eqMpid": { + "type": "string" + }, + "futClearingAccount": { + "type": "string" + }, + "futClearingRange": { + "$ref": "#/components/schemas/ClearingRange" + }, + "futCmta": { + "type": "string" + }, + "futExecBroker": { + "type": "string" + }, + "locateId": { + "type": "string" + }, + "optClearingAccount": { + "type": "string" + }, + "optClearingRange": { + "$ref": "#/components/schemas/ClearingRange" + }, + "optCmta": { + "type": "string" + }, + "optGiveUp": { + "type": "string" + }, + "tag1": { + "type": "string" + }, + "billingCode": { + "type": "string" + } + }, + "additionalProperties": false + }, + "ClearingRange": { + "enum": [ + "CLEARING_RANGE_NOTSET", + "CLEARING_RANGE_CUSTOMER", + "CLEARING_RANGE_PROPRIETARY_FIRM", + "CLEARING_RANGE_BROKER_DEALER_FIRM", + "CLEARING_RANGE_BROKER_DEALER_CUSTOMER", + "CLEARING_RANGE_MARKET_MAKER", + "CLEARING_RANGE_AWAY_MARKET_MAKER", + "CLEARING_RANGE_PROPRIETARY_CUSTOMER", + "CLEARING_RANGE_PROFESSIONAL_CUSTOMER", + "CLEARING_RANGE_BROKER_DEALER", + "CLEARING_RANGE_NON_TPH_BROKER_DEALER", + "CLEARING_RANGE_FIRM", + "CLEARING_RANGE_JOINT_BACK_OFFICE", + "CLEARING_RANGE_NON_TPH_AFFILIATE" + ], + "type": "string" + }, + "Country": { + "enum": [ + "COUNTRY_UNKNOWN", + "COUNTRY_UNITED_STATES", + "COUNTRY_GERMANY", + "COUNTRY_UNITED_KINGDOM", + "COUNTRY_JAPAN", + "COUNTRY_CHINA", + "COUNTRY_INDIA" + ], + "type": "string" + }, + "CreateFlexOptionRequest": { + "type": "object", + "properties": { + "rootSymbol": { + "type": "string" + }, + "settlementType": { + "$ref": "#/components/schemas/FlexSettlementType" + }, + "expirationDt": { + "$ref": "#/components/schemas/Date" + }, + "strike": { + "type": "number", + "format": "double" + }, + "putCall": { + "$ref": "#/components/schemas/PutCall" + }, + "productType": { + "$ref": "#/components/schemas/OptionSeriesProductType" + }, + "exerciseStyle": { + "$ref": "#/components/schemas/OptionExerciseStyle" + }, + "creationDt": { + "$ref": "#/components/schemas/Date" + }, + "observationDay": { + "type": "integer", + "format": "int32" + }, + "isPercentagePriced": { + "type": "boolean" + }, + "capPercentage": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "CreateFlexOptionResponse": { + "type": "object", + "properties": { + "flexOption": { + "$ref": "#/components/schemas/FlexOption" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CreateMultiLegOrderCrossAllocation": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CreateMultiLegOrderLeg" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "qty": { + "type": "number", + "format": "double" + }, + "sideType": { + "$ref": "#/components/schemas/CrossSideType" + } + }, + "additionalProperties": false + }, + "CreateMultiLegOrderCrossRequest": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "allocations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CreateMultiLegOrderCrossAllocation" + } + }, + "crossType": { + "$ref": "#/components/schemas/CrossType" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "parentOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "CreateMultiLegOrderCrossResponse": { + "type": "object", + "properties": { + "multiLegOrderCross": { + "$ref": "#/components/schemas/MultiLegOrderCross" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CreateMultiLegOrderLeg": { + "type": "object", + "properties": { + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "ratio": { + "type": "integer", + "format": "int32" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "symbol": { + "type": "string" + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "flexOption": { + "$ref": "#/components/schemas/FlexOption" + } + }, + "additionalProperties": false + }, + "CreateMultiLegOrderRequest": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CreateMultiLegOrderLeg" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "parentOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "CreateMultiLegOrderResponse": { + "type": "object", + "properties": { + "multiLegOrder": { + "$ref": "#/components/schemas/MultiLegOrder" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CreateOrderCrossAllocation": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "qty": { + "type": "number", + "format": "double" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "sideType": { + "$ref": "#/components/schemas/CrossSideType" + } + }, + "additionalProperties": false + }, + "CreateOrderCrossRequest": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "allocations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CreateOrderCrossAllocation" + } + }, + "crossType": { + "$ref": "#/components/schemas/CrossType" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "parentOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "flexOption": { + "$ref": "#/components/schemas/FlexOption" + } + }, + "additionalProperties": false + }, + "CreateOrderCrossResponse": { + "type": "object", + "properties": { + "orderCross": { + "$ref": "#/components/schemas/OrderCross" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CreateOrderRequest": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "parentOrdId": { + "type": "string" + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "flexOption": { + "$ref": "#/components/schemas/FlexOption" + } + }, + "additionalProperties": false + }, + "CreateOrderResponse": { + "type": "object", + "properties": { + "order": { + "$ref": "#/components/schemas/Order" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "CrossSideType": { + "enum": [ + "CROSS_SIDE_TYPE_UNDEFINED", + "CROSS_SIDE_TYPE_AGENCY", + "CROSS_SIDE_TYPE_CONTRA" + ], + "type": "string" + }, + "CrossType": { + "enum": [ + "CROSS_TYPE_UNDEFINED", + "CROSS_TYPE_SWEEP_AND_CROSS", + "CROSS_TYPE_PCC", + "CROSS_TYPE_AIM", + "CROSS_TYPE_BAM", + "CROSS_TYPE_C2C", + "CROSS_TYPE_FACILITATION", + "CROSS_TYPE_MATRIX_CROSS", + "CROSS_TYPE_PIM", + "CROSS_TYPE_QCC", + "CROSS_TYPE_RFC", + "CROSS_TYPE_SAM", + "CROSS_TYPE_SWEEP_AND_AIM" + ], + "type": "string" + }, + "Crypto": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "quoteCurrency": { + "$ref": "#/components/schemas/Currency" + } + }, + "additionalProperties": false + }, + "Currency": { + "enum": [ + "CURRENCY_USD", + "CURRENCY_AED", + "CURRENCY_AFN", + "CURRENCY_ALL", + "CURRENCY_AMD", + "CURRENCY_ANG", + "CURRENCY_AOA", + "CURRENCY_ARS", + "CURRENCY_AUD", + "CURRENCY_AWG", + "CURRENCY_AZN", + "CURRENCY_BAM", + "CURRENCY_BBD", + "CURRENCY_BDT", + "CURRENCY_BGN", + "CURRENCY_BHD", + "CURRENCY_BIF", + "CURRENCY_BMD", + "CURRENCY_BND", + "CURRENCY_BOB", + "CURRENCY_BRL", + "CURRENCY_BSD", + "CURRENCY_BTN", + "CURRENCY_BWP", + "CURRENCY_BYR", + "CURRENCY_BZD", + "CURRENCY_CAD", + "CURRENCY_CDF", + "CURRENCY_CHF", + "CURRENCY_CLP", + "CURRENCY_CNY", + "CURRENCY_COP", + "CURRENCY_CRC", + "CURRENCY_CUC", + "CURRENCY_CUP", + "CURRENCY_CVE", + "CURRENCY_CZK", + "CURRENCY_DJF", + "CURRENCY_DKK", + "CURRENCY_DOP", + "CURRENCY_DZD", + "CURRENCY_EGP", + "CURRENCY_ERN", + "CURRENCY_ETB", + "CURRENCY_EUR", + "CURRENCY_FJD", + "CURRENCY_FKP", + "CURRENCY_GBP", + "CURRENCY_GEL", + "CURRENCY_GGP", + "CURRENCY_GHS", + "CURRENCY_GIP", + "CURRENCY_GMD", + "CURRENCY_GNF", + "CURRENCY_GTQ", + "CURRENCY_GYD", + "CURRENCY_HKD", + "CURRENCY_HNL", + "CURRENCY_HRK", + "CURRENCY_HTG", + "CURRENCY_HUF", + "CURRENCY_IDR", + "CURRENCY_ILS", + "CURRENCY_IMP", + "CURRENCY_INR", + "CURRENCY_IQD", + "CURRENCY_IRR", + "CURRENCY_ISK", + "CURRENCY_JEP", + "CURRENCY_JMD", + "CURRENCY_JOD", + "CURRENCY_JPY", + "CURRENCY_KES", + "CURRENCY_KGS", + "CURRENCY_KHR", + "CURRENCY_KMF", + "CURRENCY_KPW", + "CURRENCY_KRW", + "CURRENCY_KWD", + "CURRENCY_KYD", + "CURRENCY_KZT", + "CURRENCY_LAK", + "CURRENCY_LBP", + "CURRENCY_LKR", + "CURRENCY_LRD", + "CURRENCY_LSL", + "CURRENCY_LTL", + "CURRENCY_LYD", + "CURRENCY_MAD", + "CURRENCY_MDL", + "CURRENCY_MGA", + "CURRENCY_MKD", + "CURRENCY_MMK", + "CURRENCY_MNT", + "CURRENCY_MOP", + "CURRENCY_MRO", + "CURRENCY_MUR", + "CURRENCY_MVR", + "CURRENCY_MWK", + "CURRENCY_MXN", + "CURRENCY_MYR", + "CURRENCY_MZN", + "CURRENCY_NAD", + "CURRENCY_NGN", + "CURRENCY_NIO", + "CURRENCY_NOK", + "CURRENCY_NPR", + "CURRENCY_NZD", + "CURRENCY_OMR", + "CURRENCY_PAB", + "CURRENCY_PEN", + "CURRENCY_PGK", + "CURRENCY_PHP", + "CURRENCY_PKR", + "CURRENCY_PLN", + "CURRENCY_PYG", + "CURRENCY_QAR", + "CURRENCY_RON", + "CURRENCY_RSD", + "CURRENCY_RUB", + "CURRENCY_RWF", + "CURRENCY_SAR", + "CURRENCY_SBD", + "CURRENCY_SCR", + "CURRENCY_SDG", + "CURRENCY_SEK", + "CURRENCY_SGD", + "CURRENCY_SHP", + "CURRENCY_SLL", + "CURRENCY_SOS", + "CURRENCY_SPL", + "CURRENCY_SRD", + "CURRENCY_STD", + "CURRENCY_SVC", + "CURRENCY_SYP", + "CURRENCY_SZL", + "CURRENCY_THB", + "CURRENCY_TJS", + "CURRENCY_TMT", + "CURRENCY_TND", + "CURRENCY_TOP", + "CURRENCY_TRY", + "CURRENCY_TTD", + "CURRENCY_TVD", + "CURRENCY_TWD", + "CURRENCY_TZS", + "CURRENCY_UAH", + "CURRENCY_UGX", + "CURRENCY_UYU", + "CURRENCY_UZS", + "CURRENCY_VEF", + "CURRENCY_VND", + "CURRENCY_VUV", + "CURRENCY_WST", + "CURRENCY_XAF", + "CURRENCY_XCD", + "CURRENCY_XDR", + "CURRENCY_XOF", + "CURRENCY_XPF", + "CURRENCY_YER", + "CURRENCY_ZAR", + "CURRENCY_ZMW", + "CURRENCY_ZWD", + "CURRENCY_CNH", + "CURRENCY_NLG", + "CURRENCY_DEM", + "CURRENCY_SKK", + "CURRENCY_EEK", + "CURRENCY_LVL", + "CURRENCY_XXX", + "CURRENCY_GBX", + "CURRENCY_BTC", + "CURRENCY_ETH" + ], + "type": "string" + }, + "CxlRejResponseTo": { + "enum": [ + "CXL_REJ_RESPONSE_TO_UNKNOWN", + "CXL_REJ_RESPONSE_TO_ORDER_CANCEL_REQUEST", + "CXL_REJ_RESPONSE_TO_ORDER_CANCEL_REPLACE_REQUEST" + ], + "type": "string" + }, + "Date": { + "type": "object", + "properties": { + "year": { + "type": "integer", + "format": "int32" + }, + "month": { + "type": "integer", + "format": "int32" + }, + "day": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "EasyToBorrowSecurity": { + "type": "object", + "properties": { + "symbol": { + "type": "string" + }, + "locateId": { + "type": "string" + } + }, + "additionalProperties": false + }, + "Empty": { + "type": "object", + "additionalProperties": false + }, + "Exchange": { + "type": "object", + "properties": { + "Country": { + "type": "string" + }, + "Description": { + "type": "string" + }, + "DisplayName": { + "type": "string" + }, + "Id": { + "type": "integer", + "format": "int32" + }, + "MIC": { + "type": "string" + }, + "MicrosoftTimezone": { + "type": "string" + }, + "Name": { + "type": "string" + }, + "OlsonTimezone": { + "type": "string" + }, + "OperatingMIC": { + "type": "string" + }, + "Region": { + "type": "string" + }, + "ShortCode": { + "type": "string" + }, + "Suffix": { + "type": "string" + }, + "UtcOffset": { + "type": "integer", + "format": "int32" + }, + "Website": { + "type": "string" + } + }, + "additionalProperties": false + }, + "ExchangeCode": { + "enum": [ + "EXCHANGE_CODE_XXXX", + "EXCHANGE_CODE_USEQ", + "EXCHANGE_CODE_BATS", + "EXCHANGE_CODE_BATY", + "EXCHANGE_CODE_EDGA", + "EXCHANGE_CODE_EDGX", + "EXCHANGE_CODE_XASE", + "EXCHANGE_CODE_XBOS", + "EXCHANGE_CODE_XNYS", + "EXCHANGE_CODE_ARCX", + "EXCHANGE_CODE_XNAS", + "EXCHANGE_CODE_XCHI", + "EXCHANGE_CODE_XPSX", + "EXCHANGE_CODE_XISE", + "EXCHANGE_CODE_XADF", + "EXCHANGE_CODE_IEXG", + "EXCHANGE_CODE_XNGS", + "EXCHANGE_CODE_LTSE", + "EXCHANGE_CODE_MEMX", + "EXCHANGE_CODE_EPRL", + "EXCHANGE_CODE_XCIS", + "EXCHANGE_CODE_CBSX", + "EXCHANGE_CODE_OOTC", + "EXCHANGE_CODE_OTCM", + "EXCHANGE_CODE_OTCB", + "EXCHANGE_CODE_OTCQ", + "EXCHANGE_CODE_PINC", + "EXCHANGE_CODE_PINX", + "EXCHANGE_CODE_XOTC", + "EXCHANGE_CODE_DJXX", + "EXCHANGE_CODE_SPXX", + "EXCHANGE_CODE_RTXX", + "EXCHANGE_CODE_GIDS", + "EXCHANGE_CODE_CSMI", + "EXCHANGE_CODE_OPRA", + "EXCHANGE_CODE_CGIX", + "EXCHANGE_CODE_MSCI", + "EXCHANGE_CODE_MSTR", + "EXCHANGE_CODE_XOCC", + "EXCHANGE_CODE_BATO", + "EXCHANGE_CODE_EDGO", + "EXCHANGE_CODE_XMIO", + "EXCHANGE_CODE_MPRL", + "EXCHANGE_CODE_XBOX", + "EXCHANGE_CODE_XCBO", + "EXCHANGE_CODE_C2OX", + "EXCHANGE_CODE_XBXO", + "EXCHANGE_CODE_XPHO", + "EXCHANGE_CODE_AMXO", + "EXCHANGE_CODE_ARCO", + "EXCHANGE_CODE_XISX", + "EXCHANGE_CODE_MCRY", + "EXCHANGE_CODE_GMNI", + "EXCHANGE_CODE_XNDQ", + "EXCHANGE_CODE_EMLD", + "EXCHANGE_CODE_MXOP", + "EXCHANGE_CODE_SPHR", + "EXCHANGE_CODE_XCBT", + "EXCHANGE_CODE_XKBT", + "EXCHANGE_CODE_XCME", + "EXCHANGE_CODE_GLBX", + "EXCHANGE_CODE_XNYM", + "EXCHANGE_CODE_XCBF", + "EXCHANGE_CODE_XCEC", + "EXCHANGE_CODE_BLCK" + ], + "type": "string" + }, + "ExecType": { + "enum": [ + "EXEC_TYPE_UNKNOWN", + "EXEC_TYPE_NEW", + "EXEC_TYPE_DONE_FOR_DAY", + "EXEC_TYPE_CANCELED", + "EXEC_TYPE_REPLACED", + "EXEC_TYPE_PENDING_CANCEL", + "EXEC_TYPE_STOPPED", + "EXEC_TYPE_REJECTED", + "EXEC_TYPE_SUSPENDED", + "EXEC_TYPE_PENDING_NEW", + "EXEC_TYPE_EXPIRED", + "EXEC_TYPE_RESTATED", + "EXEC_TYPE_PENDING_REPLACE", + "EXEC_TYPE_TRADE", + "EXEC_TYPE_TRADE_CORRECT", + "EXEC_TYPE_TRADE_BUST", + "EXEC_TYPE_UPDATE", + "EXEC_TYPE_NOTE", + "EXEC_TYPE_QUEUED_ORDER", + "EXEC_TYPE_REPRESENTED", + "EXEC_TYPE_USER_CLAIMED", + "EXEC_TYPE_CLAIM_REQUIRED", + "EXEC_TYPE_UPDATE_OPTIONAL_DATA" + ], + "type": "string" + }, + "Execution": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "allocId": { + "type": "string" + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "claimedBy": { + "type": "string" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "commission": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "curOrdId": { + "type": "string" + }, + "execBroker": { + "type": "string" + }, + "execId": { + "type": "string" + }, + "execRefId": { + "type": "string" + }, + "execType": { + "$ref": "#/components/schemas/ExecType" + }, + "fee1": { + "type": "number", + "format": "double" + }, + "fee2": { + "type": "number", + "format": "double" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "incomingOrigClOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "lastMarket": { + "type": "string" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "legId": { + "type": "string" + }, + "liquidityFlag": { + "type": "string" + }, + "multiLegReportingType": { + "$ref": "#/components/schemas/MultiLegReportingType" + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "origOrdId": { + "type": "string" + }, + "parentOrdId": { + "type": "string" + }, + "permOrdId": { + "type": "string" + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "routingSession": { + "type": "string" + }, + "security": { + "$ref": "#/components/schemas/Security" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "source": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "traderId": { + "type": "string" + }, + "transactTs": { + "type": "string" + }, + "userId": { + "type": "integer", + "format": "int32" + }, + "workingQty": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "FlexOption": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "capPercentage": { + "type": "number", + "format": "double" + }, + "creationDt": { + "$ref": "#/components/schemas/Date" + }, + "deliverablePerContract": { + "type": "number", + "format": "double" + }, + "exerciseStyle": { + "$ref": "#/components/schemas/OptionExerciseStyle" + }, + "expirationDt": { + "$ref": "#/components/schemas/Date" + }, + "observationDay": { + "type": "integer", + "format": "int32" + }, + "percentagePricing": { + "type": "boolean" + }, + "productType": { + "$ref": "#/components/schemas/OptionSeriesProductType" + }, + "putCall": { + "$ref": "#/components/schemas/PutCall" + }, + "root": { + "type": "string" + }, + "rootBase": { + "type": "string" + }, + "settlementType": { + "$ref": "#/components/schemas/OptionSettlementType" + }, + "strike": { + "type": "number", + "format": "double" + }, + "underlying": { + "type": "string" + } + }, + "additionalProperties": false + }, + "FlexSettlementType": { + "enum": [ + "FLEX_SETTLEMENT_TYPE_AM", + "FLEX_SETTLEMENT_TYPE_PM", + "FLEX_SETTLEMENT_TYPE_PM_CASH", + "FLEX_SETTLEMENT_TYPE_ASIAN", + "FLEX_SETTLEMENT_TYPE_CLIQUET" + ], + "type": "string" + }, + "Future": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "contractMYY": { + "type": "string" + }, + "firstNoticeDt": { + "$ref": "#/components/schemas/Date" + }, + "firstTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "lastNoticeDt": { + "$ref": "#/components/schemas/Date" + }, + "lastTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "root": { + "$ref": "#/components/schemas/FutureRoot" + } + }, + "additionalProperties": false + }, + "FutureRoot": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "productGroup": { + "$ref": "#/components/schemas/ProductGroup" + }, + "productSubGroup": { + "$ref": "#/components/schemas/ProductSubGroup" + }, + "settlementDeliverableType": { + "$ref": "#/components/schemas/SettlementDeliverableType" + }, + "unitOfMeasure": { + "type": "string" + }, + "unitOfMeasureQty": { + "type": "number", + "format": "double" + }, + "tradingSessionGroup": { + "$ref": "#/components/schemas/TradingSessionGroup" + } + }, + "additionalProperties": false + }, + "FutureSpread": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "contractMYY": { + "type": "string" + }, + "displayFactor": { + "type": "number", + "format": "double" + }, + "firstNoticeDt": { + "$ref": "#/components/schemas/Date" + }, + "firstTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "lastNoticeDt": { + "$ref": "#/components/schemas/Date" + }, + "lastTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FutureSpreadLeg" + } + }, + "spreadCode": { + "type": "string" + } + }, + "additionalProperties": false + }, + "FutureSpreadLeg": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "price": { + "type": "number", + "format": "double" + }, + "ratio": { + "type": "integer", + "format": "int32" + }, + "future": { + "$ref": "#/components/schemas/Future" + }, + "side": { + "$ref": "#/components/schemas/SpreadLegSide" + }, + "spreadLegType": { + "$ref": "#/components/schemas/SpreadLegType" + } + }, + "additionalProperties": false + }, + "Fx": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "quoteCurrency": { + "$ref": "#/components/schemas/Currency" + } + }, + "additionalProperties": false + }, + "GenericOrder": { + "type": "object", + "properties": { + "order": { + "$ref": "#/components/schemas/Order" + }, + "orderCross": { + "$ref": "#/components/schemas/OrderCross" + }, + "multiLegOrder": { + "$ref": "#/components/schemas/MultiLegOrder" + }, + "multiLegOrderCross": { + "$ref": "#/components/schemas/MultiLegOrderCross" + } + }, + "additionalProperties": false + }, + "GetActiveUserResponse": { + "type": "object", + "properties": { + "user": { + "$ref": "#/components/schemas/User" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "GetServerInfoResponse": { + "type": "object", + "properties": { + "environment": { + "type": "string" + }, + "serverBuildTs": { + "type": "string" + }, + "serverHash": { + "type": "string" + }, + "serverName": { + "type": "string" + }, + "serverVersion": { + "type": "string" + }, + "site": { + "type": "string" + }, + "systemSettings": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "GetServerTimeResponse": { + "type": "object", + "properties": { + "serverTimeUtc": { + "type": "string" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "GetTradingHolidaysResponse": { + "type": "object", + "properties": { + "tradingHolidays": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TradingHoliday" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "Header": { + "type": "object", + "properties": { + "deliverToCompId": { + "type": "string" + }, + "deliverToSubId": { + "type": "string" + }, + "onBehalfOfCompId": { + "type": "string" + }, + "onBehalfOfSubId": { + "type": "string" + }, + "senderCompId": { + "type": "string" + }, + "senderSubId": { + "type": "string" + }, + "targetCompId": { + "type": "string" + }, + "targetSubId": { + "type": "string" + } + }, + "additionalProperties": false + }, + "Index": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + } + }, + "additionalProperties": false + }, + "ListAccountsResponse": { + "type": "object", + "properties": { + "accounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Account" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListAffiliatedTradingFirmsResponse": { + "type": "object", + "properties": { + "affiliatedFirms": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TradingFirmSlim" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListEasyToBorrowSecuritiesRequest": { + "type": "object", + "properties": { + "tradingFirmId": { + "type": "integer", + "format": "int32" + }, + "accountId": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "ListEasyToBorrowSecuritiesResponse": { + "type": "object", + "properties": { + "securities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EasyToBorrowSecurity" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListExchangesResponse": { + "type": "object", + "properties": { + "exchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Exchange" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListOptionChainsRepsonse": { + "type": "object", + "properties": { + "optionChains": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OptionChain" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListOptionChainsRequest": { + "type": "object", + "properties": { + "underlyingSymbols": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "ListOrdersResponse": { + "type": "object", + "properties": { + "orders": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericOrder" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListPositionsResponse": { + "type": "object", + "properties": { + "positions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Position" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListRoutesResponse": { + "type": "object", + "properties": { + "routes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Route" + } + }, + "routeApplicabilities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RouteApplicability" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListSecuritiesRequest": { + "type": "object", + "properties": { + "symbols": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "ListSecuritiesResponse": { + "type": "object", + "properties": { + "securities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Security" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListTradeConfirmsResponse": { + "type": "object", + "properties": { + "tradeConfirms": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TradeConfirm" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "ListTradingFirmsResponse": { + "type": "object", + "properties": { + "tradingFirms": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TradingFirm" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "LoginRequest": { + "type": "object", + "properties": { + "domain": { + "type": "string" + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "applicationName": { + "type": "string" + }, + "applicationVersion": { + "type": "string" + } + }, + "additionalProperties": false + }, + "LoginResponse": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "environment": { + "type": "string" + }, + "loginAttemptsRemaining": { + "type": "integer", + "format": "int32" + }, + "loginStatus": { + "$ref": "#/components/schemas/LoginStatus" + }, + "serverBuildTs": { + "type": "string" + }, + "serverHash": { + "type": "string" + }, + "serverName": { + "type": "string" + }, + "serverTimeUtc": { + "type": "string" + }, + "serverVersion": { + "type": "string" + }, + "site": { + "type": "string" + }, + "text": { + "type": "string" + }, + "user": { + "$ref": "#/components/schemas/User" + }, + "systemSettings": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "LoginStatus": { + "enum": [ + "UNDEFINED", + "NOT_AUTHORIZED", + "LOGIN_SUCCESS", + "VERSION_TOO_OLD", + "SERVER_HASH_CHANGED", + "PASSWORD_EXPIRED", + "PASSWORD_CHANGE_SUCCESSFUL", + "PASSWORD_CHANGE_FAILED", + "LOGIN_DISALLOWED", + "CONNECTION_FAILED", + "MFA_REQUIRED", + "MFA_FAILED" + ], + "type": "string" + }, + "MarginData": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "tims": { + "$ref": "#/components/schemas/TimsMarginData" + }, + "span": { + "$ref": "#/components/schemas/Empty" + } + }, + "additionalProperties": false + }, + "MarginDataType": { + "enum": [ + "MARGIN_DATA_TYPE_UNKNOWN", + "MARGIN_DATA_TYPE_TIMS", + "MARGIN_DATA_TYPE_SPAN" + ], + "type": "string" + }, + "MultiLegOrder": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "curOrdId": { + "type": "string" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "id": { + "type": "string" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MultiLegOrderLeg" + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "orderUpdates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderUpdateEvent" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "parentOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "source": { + "type": "string" + }, + "sourceAddress": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "userId": { + "type": "integer", + "format": "int32" + }, + "traderId": { + "type": "string" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "claimedBy": { + "type": "string" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "lastMarket": { + "type": "string" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "transactTs": { + "type": "string" + }, + "workingQty": { + "type": "number", + "format": "double" + }, + "hasBusts": { + "type": "boolean" + }, + "hasCorrects": { + "type": "boolean" + }, + "hasNotes": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "MultiLegOrderCancelReplaceRequest": { + "type": "object", + "properties": { + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "curOrdId": { + "type": "string" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrigClOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "permOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "reqOrdId": { + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "source": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "traderId": { + "type": "string" + }, + "userId": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "MultiLegOrderCross": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "allocations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MultiLegOrderCrossAllocation" + } + }, + "crossType": { + "$ref": "#/components/schemas/CrossType" + }, + "curOrdId": { + "type": "string" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "id": { + "type": "string" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "orderUpdates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderUpdateEvent" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "parentOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "source": { + "type": "string" + }, + "sourceAddress": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "userId": { + "type": "integer", + "format": "int32" + }, + "traderId": { + "type": "string" + }, + "claimedBy": { + "type": "string" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "transactTs": { + "type": "string" + }, + "hasBusts": { + "type": "boolean" + }, + "hasCorrects": { + "type": "boolean" + }, + "hasNotes": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "MultiLegOrderCrossAllocation": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "id": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MultiLegOrderLeg" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "qty": { + "type": "number", + "format": "double" + }, + "sideType": { + "$ref": "#/components/schemas/CrossSideType" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "lastMarket": { + "type": "string" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "transactTs": { + "type": "string" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MultiLegOrderLeg": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderUpdates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderUpdateEvent" + } + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "qty": { + "type": "number", + "format": "double" + }, + "ratio": { + "type": "integer", + "format": "int32" + }, + "security": { + "$ref": "#/components/schemas/Security" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "symbol": { + "type": "string" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "lastMarket": { + "type": "string" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "transactTs": { + "type": "string" + } + }, + "additionalProperties": false + }, + "MultiLegReportingType": { + "enum": [ + "MULTI_LEG_REPORTING_TYPE_SINGLE", + "MULTI_LEG_REPORTING_TYPE_LEG", + "MULTI_LEG_REPORTING_TYPE_PARENT" + ], + "type": "string" + }, + "NumericDisplayFormat": { + "enum": [ + "NUMERIC_DISPLAY_FORMAT_AUTO", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_01", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_02", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_03", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_04", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_05", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_06", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_07", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_08", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_09", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_10", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_11", + "NUMERIC_DISPLAY_FORMAT_DECIMAL_00", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_WHOLE", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_HALF", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_QUARTER", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_8TH", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_16TH", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_32ND", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_64TH", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_128TH", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_256TH", + "NUMERIC_DISPLAY_FORMAT_FRACTIONAL_512ND" + ], + "type": "string" + }, + "Option": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "expirationDt": { + "$ref": "#/components/schemas/Date" + }, + "expirationStyle": { + "$ref": "#/components/schemas/OptionExpirationStyle" + }, + "firstTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "lastTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "putCall": { + "$ref": "#/components/schemas/PutCall" + }, + "root": { + "$ref": "#/components/schemas/OptionRoot" + }, + "strike": { + "type": "number", + "format": "double" + }, + "underlying": { + "type": "string" + } + }, + "additionalProperties": false + }, + "OptionChain": { + "type": "object", + "properties": { + "underlying": { + "$ref": "#/components/schemas/Security" + }, + "roots": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/OptionRoot" + } + }, + "options": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/OptionChainOption" + } + }, + "optionSeries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OptionSeries" + } + }, + "post": { + "type": "string" + }, + "station": { + "type": "string" + } + }, + "additionalProperties": false + }, + "OptionChainOption": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "firstTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "lastTradeDt": { + "$ref": "#/components/schemas/Date" + }, + "putCall": { + "$ref": "#/components/schemas/PutCall" + }, + "strike": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "OptionExerciseStyle": { + "enum": [ + "OPTION_EXERCISE_STYLE_UNDEFINED", + "OPTION_EXERCISE_STYLE_AMERICAN", + "OPTION_EXERCISE_STYLE_BERMUDAN", + "OPTION_EXERCISE_STYLE_EUROPEAN" + ], + "type": "string" + }, + "OptionExpirationStyle": { + "enum": [ + "OPTION_EXPIRATION_STYLE_UNKNOWN", + "OPTION_EXPIRATION_STYLE_WK1", + "OPTION_EXPIRATION_STYLE_WK2", + "OPTION_EXPIRATION_STYLE_WK3", + "OPTION_EXPIRATION_STYLE_WK4", + "OPTION_EXPIRATION_STYLE_WK5", + "OPTION_EXPIRATION_STYLE_DAILY", + "OPTION_EXPIRATION_STYLE_E_O_M", + "OPTION_EXPIRATION_STYLE_LEAP", + "OPTION_EXPIRATION_STYLE_MONTHLY", + "OPTION_EXPIRATION_STYLE_QUARTERLY", + "OPTION_EXPIRATION_STYLE_WEEKLY" + ], + "type": "string" + }, + "OptionRoot": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "deliverablePerContract": { + "type": "number", + "format": "double" + }, + "exerciseStyle": { + "$ref": "#/components/schemas/OptionExerciseStyle" + }, + "productType": { + "$ref": "#/components/schemas/OptionSeriesProductType" + }, + "seriesType": { + "$ref": "#/components/schemas/OptionSeriesType" + }, + "settlementInfos": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SettlementInfo" + } + }, + "settlementType": { + "$ref": "#/components/schemas/OptionSettlementType" + }, + "strikeMultiplier": { + "type": "number", + "format": "double" + }, + "strikeValue": { + "type": "number", + "format": "double" + }, + "tradingSessionGroup": { + "$ref": "#/components/schemas/TradingSessionGroup" + }, + "underlying": { + "type": "string" + } + }, + "additionalProperties": false + }, + "OptionSeries": { + "type": "object", + "properties": { + "expirationDt": { + "$ref": "#/components/schemas/Date" + }, + "expirationStyle": { + "$ref": "#/components/schemas/OptionExpirationStyle" + }, + "rootSymbol": { + "type": "string" + }, + "seriesType": { + "$ref": "#/components/schemas/OptionSeriesType" + }, + "settlementType": { + "$ref": "#/components/schemas/OptionSettlementType" + }, + "optionSymbols": { + "type": "array", + "items": { + "type": "string" + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + } + }, + "additionalProperties": false + }, + "OptionSeriesProductType": { + "enum": [ + "OPTION_SERIES_PRODUCT_TYPE_STANDARD", + "OPTION_SERIES_PRODUCT_TYPE_MICRO" + ], + "type": "string" + }, + "OptionSeriesType": { + "enum": [ + "OPTION_SERIES_TYPE_UNKNOWN", + "OPTION_SERIES_TYPE_BINARY", + "OPTION_SERIES_TYPE_FLEX", + "OPTION_SERIES_TYPE_LEAP", + "OPTION_SERIES_TYPE_RANGE", + "OPTION_SERIES_TYPE_STANDARD" + ], + "type": "string" + }, + "OptionSettlementType": { + "enum": [ + "OPTION_SETTLEMENT_TYPE_UNDEFINED", + "OPTION_SETTLEMENT_TYPE_AM", + "OPTION_SETTLEMENT_TYPE_CLIQUET", + "OPTION_SETTLEMENT_TYPE_PM", + "OPTION_SETTLEMENT_TYPE_ASIAN" + ], + "type": "string" + }, + "OrdStatus": { + "enum": [ + "ORD_STATUS_UNKNOWN", + "ORD_STATUS_NEW", + "ORD_STATUS_PARTIALLY_FILLED", + "ORD_STATUS_FILLED", + "ORD_STATUS_DONE_FOR_DAY", + "ORD_STATUS_CANCELED", + "ORD_STATUS_REPLACED", + "ORD_STATUS_PENDING_CANCEL", + "ORD_STATUS_STOPPED", + "ORD_STATUS_REJECTED", + "ORD_STATUS_SUSPENDED", + "ORD_STATUS_PENDING_NEW", + "ORD_STATUS_EXPIRED", + "ORD_STATUS_ACCEPTED_FOR_BIDDING", + "ORD_STATUS_PENDING_REPLACE", + "ORD_STATUS_QUEUED", + "ORD_STATUS_REPRESENTED", + "ORD_STATUS_STAGED", + "ORD_STATUS_WORKING", + "ORD_STATUS_ACCEPTED", + "ORD_STATUS_DECLINED", + "ORD_STATUS_PUSHED", + "ORD_STATUS_TIMED_OUT" + ], + "type": "string" + }, + "OrdType": { + "enum": [ + "ORD_TYPE_UNKNOWN", + "ORD_TYPE_MARKET_IF_TOUCHED", + "ORD_TYPE_LIMIT", + "ORD_TYPE_MARKET", + "ORD_TYPE_PEGGED", + "ORD_TYPE_STOP", + "ORD_TYPE_STOP_LIMIT" + ], + "type": "string" + }, + "Order": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "curOrdId": { + "type": "string" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "id": { + "type": "string" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "orderUpdates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderUpdateEvent" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "parentOrdId": { + "type": "string" + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "security": { + "$ref": "#/components/schemas/Security" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "source": { + "type": "string" + }, + "sourceAddress": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "traderId": { + "type": "string" + }, + "userId": { + "type": "integer", + "format": "int32" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "claimedBy": { + "type": "string" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "lastMarket": { + "type": "string" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "transactTs": { + "type": "string" + }, + "workingQty": { + "type": "number", + "format": "double" + }, + "hasBusts": { + "type": "boolean" + }, + "hasCorrects": { + "type": "boolean" + }, + "hasNotes": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "OrderCancelReject": { + "type": "object", + "properties": { + "curOrdId": { + "type": "string" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrigClOrdId": { + "type": "string" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "permOrdId": { + "type": "string" + }, + "reqOrdId": { + "type": "string" + }, + "source": { + "type": "string" + }, + "text": { + "type": "string" + }, + "traderId": { + "type": "string" + }, + "transactTs": { + "type": "string" + }, + "cxlRejResponseTo": { + "$ref": "#/components/schemas/CxlRejResponseTo" + } + }, + "additionalProperties": false + }, + "OrderCancelReplaceRequest": { + "type": "object", + "properties": { + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "curOrdId": { + "type": "string" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrigClOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "permOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "reqOrdId": { + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "source": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "traderId": { + "type": "string" + }, + "userId": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "OrderCancelRequest": { + "type": "object", + "properties": { + "curOrdId": { + "type": "string" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrigClOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "permOrdId": { + "type": "string" + }, + "reqOrdId": { + "type": "string" + }, + "source": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "traderId": { + "type": "string" + }, + "userId": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "OrderCross": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "allocations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderCrossAllocation" + } + }, + "crossType": { + "$ref": "#/components/schemas/CrossType" + }, + "curOrdId": { + "type": "string" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "id": { + "type": "string" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "marketCondition": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "orderUpdates": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderUpdateEvent" + } + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "parentOrdId": { + "type": "string" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "security": { + "$ref": "#/components/schemas/Security" + }, + "source": { + "type": "string" + }, + "sourceAddress": { + "type": "string" + }, + "submitTs": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "userId": { + "type": "integer", + "format": "int32" + }, + "traderId": { + "type": "string" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "claimedBy": { + "type": "string" + }, + "transactTs": { + "type": "string" + }, + "hasBusts": { + "type": "boolean" + }, + "hasCorrects": { + "type": "boolean" + }, + "hasNotes": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "OrderCrossAllocation": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "id": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "qty": { + "type": "number", + "format": "double" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "sideType": { + "$ref": "#/components/schemas/CrossSideType" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "lastMarket": { + "type": "string" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "transactTs": { + "type": "string" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + } + }, + "additionalProperties": false + }, + "OrderDelete": { + "type": "object", + "properties": { + "curOrdId": { + "type": "string" + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "permOrdId": { + "type": "string" + }, + "traderId": { + "type": "string" + }, + "submitTs": { + "type": "string" + } + }, + "additionalProperties": false + }, + "OrderInstruction": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/OrderInstructionType" + }, + "value": { + "type": "string" + } + }, + "additionalProperties": false + }, + "OrderInstructionType": { + "enum": [ + "ORDER_INSTRUCTION_TYPE_NONE", + "ORDER_INSTRUCTION_TYPE_ALL_OR_NONE", + "ORDER_INSTRUCTION_TYPE_AUCTION_ID", + "ORDER_INSTRUCTION_TYPE_AUTO_MATCH", + "ORDER_INSTRUCTION_TYPE_AUTO_MATCH_PRICE", + "ORDER_INSTRUCTION_TYPE_CLIENT_ID", + "ORDER_INSTRUCTION_TYPE_COMMISSION", + "ORDER_INSTRUCTION_TYPE_COMPRESSION", + "ORDER_INSTRUCTION_TYPE_CROSS_PRIORITIZATION", + "ORDER_INSTRUCTION_TYPE_DO_NOT_REDUCE", + "ORDER_INSTRUCTION_TYPE_DO_NOT_ROUTE", + "ORDER_INSTRUCTION_TYPE_DROP", + "ORDER_INSTRUCTION_TYPE_EQUITY_BUY_CLEARING_FIRM", + "ORDER_INSTRUCTION_TYPE_EQUITY_EX_DESTINATION", + "ORDER_INSTRUCTION_TYPE_EQUITY_PARTY_ID", + "ORDER_INSTRUCTION_TYPE_EQUITY_SELL_CLEARING_FIRM", + "ORDER_INSTRUCTION_TYPE_EQUITY_TRADE_PRICE", + "ORDER_INSTRUCTION_TYPE_EQUITY_TRADE_SIZE", + "ORDER_INSTRUCTION_TYPE_EQUITY_TRADE_VENUE", + "ORDER_INSTRUCTION_TYPE_EQUITY_TRANSACT_TS", + "ORDER_INSTRUCTION_TYPE_FLEX_AUCTION_DURATION", + "ORDER_INSTRUCTION_TYPE_FLEX_HEDGE_EXEC_INST", + "ORDER_INSTRUCTION_TYPE_FLEX_PRE_FACIL_PRICE", + "ORDER_INSTRUCTION_TYPE_FREQUENT_TRADER", + "ORDER_INSTRUCTION_TYPE_FREQUENT_TRADER_ID", + "ORDER_INSTRUCTION_TYPE_GOOD_TILL_DATE", + "ORDER_INSTRUCTION_TYPE_HELD", + "ORDER_INSTRUCTION_TYPE_INTERMARKET_SWEEP", + "ORDER_INSTRUCTION_TYPE_MAX_FLOOR", + "ORDER_INSTRUCTION_TYPE_MIN_QTY", + "ORDER_INSTRUCTION_TYPE_NO_COA", + "ORDER_INSTRUCTION_TYPE_NOT_HELD", + "ORDER_INSTRUCTION_TYPE_ORDER_ORIGIN", + "ORDER_INSTRUCTION_TYPE_O_R_S", + "ORDER_INSTRUCTION_TYPE_PEG_DIFFERENCE", + "ORDER_INSTRUCTION_TYPE_PEG_TYPE", + "ORDER_INSTRUCTION_TYPE_PREFERRED_M_M", + "ORDER_INSTRUCTION_TYPE_REPRESENT", + "ORDER_INSTRUCTION_TYPE_ROUTE_STRATEGY", + "ORDER_INSTRUCTION_TYPE_ROUTING_FIRM_ID", + "ORDER_INSTRUCTION_TYPE_ROUTING_INST", + "ORDER_INSTRUCTION_TYPE_SETTLEMENT_LIQUIDITY", + "ORDER_INSTRUCTION_TYPE_SOLICITED", + "ORDER_INSTRUCTION_TYPE_SPX_COMBO", + "ORDER_INSTRUCTION_TYPE_STRATEGY_ID", + "ORDER_INSTRUCTION_TYPE_SWEEP", + "ORDER_INSTRUCTION_TYPE_TIED_HEDGE", + "ORDER_INSTRUCTION_TYPE_LAST_PRIORITY", + "ORDER_INSTRUCTION_TYPE_BROKER_PERCENTAGE", + "ORDER_INSTRUCTION_TYPE_PHLX_QCC", + "ORDER_INSTRUCTION_TYPE_STEP_UP_PX", + "ORDER_INSTRUCTION_TYPE_SESSION_ELIGIBILITY" + ], + "type": "string" + }, + "OrderType": { + "enum": [ + "ORDER_TYPE_UNKNOWN", + "ORDER_TYPE_MULTI_LEG_ORDER_CROSS", + "ORDER_TYPE_MULTI_LEG_ORDER", + "ORDER_TYPE_ORDER", + "ORDER_TYPE_ORDER_CROSS" + ], + "type": "string" + }, + "OrderUpdate": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "Algo": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "allocId": { + "type": "string" + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "clearingInfo": { + "$ref": "#/components/schemas/ClearingInfo" + }, + "commission": { + "type": "number", + "format": "double" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "curOrdId": { + "type": "string" + }, + "execBroker": { + "type": "string" + }, + "execId": { + "type": "string" + }, + "execRefId": { + "type": "string" + }, + "execType": { + "$ref": "#/components/schemas/ExecType" + }, + "fee1": { + "type": "number", + "format": "double" + }, + "fee2": { + "type": "number", + "format": "double" + }, + "header": { + "$ref": "#/components/schemas/Header" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "incomingOrigClOrdId": { + "type": "string" + }, + "instructions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderInstruction" + } + }, + "lastMarket": { + "type": "string" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "legId": { + "type": "string" + }, + "liquidityFlag": { + "type": "string" + }, + "multiLegReportingType": { + "$ref": "#/components/schemas/MultiLegReportingType" + }, + "Notes": { + "type": "string" + }, + "optionalData": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "orderFlags": { + "type": "integer", + "format": "int32" + }, + "ordStatus": { + "$ref": "#/components/schemas/OrdStatus" + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "origOrdId": { + "type": "string" + }, + "parentOrdId": { + "type": "string" + }, + "permOrdId": { + "type": "string" + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "qty": { + "type": "number", + "format": "double" + }, + "route": { + "type": "string" + }, + "security": { + "$ref": "#/components/schemas/Security" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "source": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "traderId": { + "type": "string" + }, + "transactTs": { + "type": "string" + }, + "workingQty": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "OrderUpdateEvent": { + "type": "object", + "properties": { + "orderCancelRequest": { + "$ref": "#/components/schemas/OrderCancelRequest" + }, + "orderCancelReplaceRequest": { + "$ref": "#/components/schemas/OrderCancelReplaceRequest" + }, + "multiLegOrderCancelReplaceRequest": { + "$ref": "#/components/schemas/MultiLegOrderCancelReplaceRequest" + }, + "execution": { + "$ref": "#/components/schemas/Execution" + }, + "orderUpdate": { + "$ref": "#/components/schemas/OrderUpdate" + }, + "orderDelete": { + "$ref": "#/components/schemas/OrderDelete" + }, + "orderCancelReject": { + "$ref": "#/components/schemas/OrderCancelReject" + } + }, + "additionalProperties": false + }, + "OriginationType": { + "enum": [ + "ORIGINATION_TYPE_UNKNOWN", + "ORIGINATION_TYPE_ADMINISTRATIVE", + "ORIGINATION_TYPE_API_CHILD_ORDER", + "ORIGINATION_TYPE_API_ORDER", + "ORIGINATION_TYPE_API_ORDER_CANCEL_REPLACE_REQUEST", + "ORIGINATION_TYPE_API_ORDER_CANCEL_REQUEST", + "ORIGINATION_TYPE_API_PARENT_ORDER", + "ORIGINATION_TYPE_FIX_FROM_STREET_CHILD_ORDER", + "ORIGINATION_TYPE_FIX_FROM_STREET_DROP", + "ORIGINATION_TYPE_FIX_FROM_STREET_DROP_ORDER_UPDATE", + "ORIGINATION_TYPE_FIX_FROM_STREET_ORDER", + "ORIGINATION_TYPE_FIX_FROM_STREET_ORDER_CANCEL_REPLACE_REQUEST", + "ORIGINATION_TYPE_FIX_FROM_STREET_ORDER_CANCEL_REQUEST", + "ORIGINATION_TYPE_FIX_FROM_STREET_ORDER_UPDATE", + "ORIGINATION_TYPE_FIX_FROM_STREET_PARENT_ORDER", + "ORIGINATION_TYPE_ORDER_MANAGER" + ], + "type": "string" + }, + "Position": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "symbol": { + "type": "string" + }, + "avgCost": { + "type": "number", + "format": "double" + }, + "markedCost": { + "type": "number", + "format": "double" + }, + "netQty": { + "type": "number", + "format": "double" + }, + "notionalValue": { + "type": "number", + "format": "double" + }, + "openingCost": { + "type": "number", + "format": "double" + }, + "openingQty": { + "type": "number", + "format": "double" + }, + "realizedPnL": { + "type": "number", + "format": "double" + }, + "tradingAvgCost": { + "type": "number", + "format": "double" + }, + "tradingBuyAvgPrice": { + "type": "number", + "format": "double" + }, + "tradingBuyQty": { + "type": "number", + "format": "double" + }, + "tradingNetQty": { + "type": "number", + "format": "double" + }, + "tradingSellAvgPrice": { + "type": "number", + "format": "double" + }, + "tradingSellQty": { + "type": "number", + "format": "double" + }, + "tradingSellQtyLong": { + "type": "number", + "format": "double" + }, + "tradingSellQtyShort": { + "type": "number", + "format": "double" + }, + "transactTs": { + "type": "string" + } + }, + "additionalProperties": false + }, + "PositionAnalysis": { + "type": "object", + "properties": { + "positionTheo": { + "$ref": "#/components/schemas/PositionTheo" + }, + "scenarioTheos": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ScenarioTheo" + } + } + }, + "additionalProperties": false + }, + "PositionEffect": { + "enum": [ + "POSITION_EFFECT_NONE", + "POSITION_EFFECT_AUTO", + "POSITION_EFFECT_CLOSE", + "POSITION_EFFECT_OPEN" + ], + "type": "string" + }, + "PositionSource": { + "enum": [ + "POSITION_SOURCE_FROM_PORTFOLIO", + "POSITION_SOURCE_FROM_REQUEST" + ], + "type": "string" + }, + "PositionTheo": { + "type": "object", + "properties": { + "asOfTs": { + "type": "string" + }, + "delta": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PositionTheoLeg" + } + }, + "maxLoss": { + "type": "number", + "format": "double" + }, + "maxLossLsd": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "maxProfit": { + "type": "number", + "format": "double" + }, + "maxProfitLsd": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "prem": { + "type": "number", + "format": "double" + }, + "price": { + "type": "number", + "format": "double" + }, + "profit": { + "type": "number", + "format": "double" + }, + "profitProbability": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "rho": { + "type": "number", + "format": "double" + }, + "theta": { + "type": "number", + "format": "double" + }, + "totalValue": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + }, + "volatility": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "PositionTheoLeg": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "maxLoss": { + "type": "number", + "format": "double" + }, + "maxLossLsd": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "maxProfit": { + "type": "number", + "format": "double" + }, + "maxProfitLsd": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "prem": { + "type": "number", + "format": "double" + }, + "profit": { + "type": "number", + "format": "double" + }, + "profitProbability": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "rho": { + "type": "number", + "format": "double" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + }, + "volatility": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "PriceType": { + "enum": [ + "PRICE_TYPE_UNKNOWN", + "PRICE_TYPE_CABINET", + "PRICE_TYPE_FIXED_AMT", + "PRICE_TYPE_D_A_C", + "PRICE_TYPE_PER_UNIT", + "PRICE_TYPE_PERCENTAGE", + "PRICE_TYPE_YIELD" + ], + "type": "string" + }, + "ProductGroup": { + "enum": [ + "PRODUCT_GROUP_UNKNOWN", + "PRODUCT_GROUP_AGRICULTURAL", + "PRODUCT_GROUP_ALTERNATIVE_MARKETS", + "PRODUCT_GROUP_CURRENCY", + "PRODUCT_GROUP_ENERGY", + "PRODUCT_GROUP_EQUITIES", + "PRODUCT_GROUP_FINANCIAL", + "PRODUCT_GROUP_INDEX", + "PRODUCT_GROUP_INTEREST_RATE", + "PRODUCT_GROUP_METAL", + "PRODUCT_GROUP_REAL_ESTATE", + "PRODUCT_GROUP_WEATHER" + ], + "type": "string" + }, + "ProductSubGroup": { + "enum": [ + "PRODUCT_SUB_GROUP_UNKNOWN" + ], + "type": "string" + }, + "PutCall": { + "enum": [ + "PUT_CALL_UNDEFINED", + "PUT_CALL_CALL", + "PUT_CALL_PUT" + ], + "type": "string" + }, + "RiskCalculationType": { + "enum": [ + "RISK_CALCULATION_TYPE_UNKNOWN", + "RISK_CALCULATION_TYPE_ACCOUNT", + "RISK_CALCULATION_TYPE_TRADING_FIRM", + "RISK_CALCULATION_TYPE_USER" + ], + "type": "string" + }, + "RiskEvalMode": { + "enum": [ + "RISK_EVAL_MODE_END_OF_DAY", + "RISK_EVAL_MODE_REAL_TIME" + ], + "type": "string" + }, + "RiskRadarAccountGroup": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "nav": { + "type": "number", + "format": "double" + }, + "productGroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskRadarProductGroup" + } + }, + "shockValues": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ShockValue" + } + } + }, + "additionalProperties": false + }, + "RiskRadarClassGroup": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "dollarDelta": { + "type": "number", + "format": "double" + }, + "dollarGamma": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "price": { + "type": "number", + "format": "double" + }, + "rho": { + "type": "number", + "format": "double" + }, + "shockKeys": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "shockValues": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ShockValue" + } + }, + "symbol": { + "type": "string" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + }, + "positions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskRadarPosition" + } + } + }, + "additionalProperties": false + }, + "RiskRadarData": { + "type": "object", + "properties": { + "risksResult": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskRadarAccountGroup" + } + }, + "shockKeys": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "RiskRadarPosition": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "dollarDelta": { + "type": "number", + "format": "double" + }, + "dollarGamma": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "price": { + "type": "number", + "format": "double" + }, + "pZero": { + "type": "number", + "format": "double" + }, + "rho": { + "type": "number", + "format": "double" + }, + "shockValues": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ShockValue" + } + }, + "symbol": { + "type": "string" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + }, + "rpgRoot": { + "type": "string" + }, + "qty": { + "type": "number", + "format": "double" + }, + "impliedVolatility": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "RiskRadarProductGroup": { + "type": "object", + "properties": { + "group": { + "type": "string" + }, + "nav": { + "type": "number", + "format": "double" + }, + "classGroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskRadarClassGroup" + } + }, + "productId": { + "type": "string" + }, + "shockValues": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ShockValue" + } + } + }, + "additionalProperties": false + }, + "RiskRadarRequest": { + "type": "object", + "properties": { + "accountIds": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "positionsByAccountId": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskRadarRequestPositionList" + } + }, + "source": { + "$ref": "#/components/schemas/PositionSource" + }, + "range": { + "type": "number", + "format": "double" + }, + "timestep": { + "type": "string" + }, + "scenarioOrder": { + "$ref": "#/components/schemas/RiskRadarScenarioOrder" + }, + "evalMode": { + "$ref": "#/components/schemas/RiskEvalMode" + }, + "impliedVolatility": { + "type": "number", + "format": "double" + }, + "volatilityShockSkew": { + "$ref": "#/components/schemas/VolatilityShockSkew" + }, + "volatilityShockType": { + "$ref": "#/components/schemas/VolatilityShockType" + }, + "excludeExpiredContracts": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "RiskRadarRequestPosition": { + "type": "object", + "properties": { + "isSimulatedPosition": { + "type": "boolean" + }, + "qty": { + "type": "number", + "format": "double" + }, + "symbol": { + "type": "string" + } + }, + "additionalProperties": false + }, + "RiskRadarRequestPositionList": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "positions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskRadarRequestPosition" + } + } + }, + "additionalProperties": false + }, + "RiskRadarResponse": { + "type": "object", + "properties": { + "result": { + "$ref": "#/components/schemas/RiskRadarData" + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "RiskRadarScenarioOrder": { + "enum": [ + "RISK_RADAR_SCENARIO_ORDER_SHOCK_FIRST", + "RISK_RADAR_SCENARIO_ORDER_STEP_FIRST" + ], + "type": "string" + }, + "RiskReject": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "guid": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "isOverridden": { + "type": "boolean" + }, + "message": { + "type": "string" + }, + "orderId": { + "type": "string" + }, + "transactTs": { + "type": "string" + }, + "calculationType": { + "$ref": "#/components/schemas/RiskCalculationType" + }, + "rejectType": { + "$ref": "#/components/schemas/RiskRejectType" + }, + "userId": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "RiskRejectType": { + "enum": [ + "RISK_REJECT_TYPE_ACCOUNT_INACTIVE", + "RISK_REJECT_TYPE_ACCOUNT_IN_LIQUIDATION", + "RISK_REJECT_TYPE_ALLOW_CRYPTO_ORDER_MARKET", + "RISK_REJECT_TYPE_ALLOW_EQ_ORDER_LONG_SALE", + "RISK_REJECT_TYPE_ALLOW_EQ_ORDER_MARKET", + "RISK_REJECT_TYPE_ALLOW_FUT_ORDER_MARKET", + "RISK_REJECT_TYPE_ALLOW_OPT_ORDER_MARKET", + "RISK_REJECT_TYPE_ALLOW_OPT_ORDER_SELL_TO_OPEN", + "RISK_REJECT_TYPE_GTC_ORDER_NOT_ALLOWED", + "RISK_REJECT_TYPE_HARD_TO_BORROW", + "RISK_REJECT_TYPE_INVALID_ORD_TYPE", + "RISK_REJECT_TYPE_INVALID_SIDE", + "RISK_REJECT_TYPE_RESTRICTED_SECURITY", + "RISK_REJECT_TYPE_SECURITY_NOT_SUPPORTED", + "RISK_REJECT_TYPE_ORDER_MAX_THRESHOLD_BREACHED", + "RISK_REJECT_TYPE_ALLOW_ORDER_WASH_TRADES", + "RISK_REJECT_TYPE_ACCOUNT_MAX_LOSS", + "RISK_REJECT_TYPE_ALLOW_LOCATE_ID_FOR_EASY_TO_BORROW", + "RISK_REJECT_TYPE_CRYPTO_MAX_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_CRYPTO_MAX_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_CRYPTO_MAX_NET_QTY_DAY", + "RISK_REJECT_TYPE_CRYPTO_ORDER_MAX_NOTIONAL", + "RISK_REJECT_TYPE_CRYPTO_ORDER_MAX_QTY", + "RISK_REJECT_TYPE_EQ_MAX_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_EQ_MAX_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_EQ_MAX_NET_POSITION", + "RISK_REJECT_TYPE_EQ_MAX_NET_QTY_DAY", + "RISK_REJECT_TYPE_EQ_ORDER_MAX_NOTIONAL", + "RISK_REJECT_TYPE_EQ_ORDER_MAX_QTY", + "RISK_REJECT_TYPE_FUT_MAX_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_FUT_MAX_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_FUT_MAX_NET_QTY_DAY", + "RISK_REJECT_TYPE_FUT_ORDER_MAX_NOTIONAL", + "RISK_REJECT_TYPE_FUT_ORDER_MAX_QTY", + "RISK_REJECT_TYPE_OPT_MAX_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_OPT_MAX_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_OPT_MAX_NET_QTY_DAY", + "RISK_REJECT_TYPE_OPT_ORDER_MAX_NOTIONAL", + "RISK_REJECT_TYPE_OPT_ORDER_MAX_QTY", + "RISK_REJECT_TYPE_CRYPTO_MAX_NET_POSITION", + "RISK_REJECT_TYPE_FUT_MAX_NET_POSITION", + "RISK_REJECT_TYPE_OPT_MAX_NET_POSITION", + "RISK_REJECT_TYPE_BUYING_POWER", + "RISK_REJECT_TYPE_CRYPTO_WARN_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_CRYPTO_WARN_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_CRYPTO_WARN_NET_QTY_DAY", + "RISK_REJECT_TYPE_CRYPTO_ORDER_WARN_NOTIONAL", + "RISK_REJECT_TYPE_CRYPTO_ORDER_WARN_QTY", + "RISK_REJECT_TYPE_EQ_WARN_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_EQ_WARN_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_EQ_WARN_NET_POSITION", + "RISK_REJECT_TYPE_EQ_WARN_NET_QTY_DAY", + "RISK_REJECT_TYPE_EQ_ORDER_WARN_NOTIONAL", + "RISK_REJECT_TYPE_EQ_ORDER_WARN_QTY", + "RISK_REJECT_TYPE_FUT_WARN_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_FUT_WARN_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_FUT_WARN_NET_QTY_DAY", + "RISK_REJECT_TYPE_FUT_ORDER_WARN_NOTIONAL", + "RISK_REJECT_TYPE_FUT_ORDER_WARN_QTY", + "RISK_REJECT_TYPE_OPT_WARN_GROSS_NOTIONAL_DAY", + "RISK_REJECT_TYPE_OPT_WARN_GROSS_QTY_DAY", + "RISK_REJECT_TYPE_OPT_WARN_NET_QTY_DAY", + "RISK_REJECT_TYPE_OPT_ORDER_WARN_NOTIONAL", + "RISK_REJECT_TYPE_OPT_ORDER_WARN_QTY", + "RISK_REJECT_TYPE_CRYPTO_WARN_NET_POSITION", + "RISK_REJECT_TYPE_FUT_WARN_NET_POSITION", + "RISK_REJECT_TYPE_OPT_WARN_NET_POSITION" + ], + "type": "string" + }, + "Route": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "algoSchema": { + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "isEnabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "orderType": { + "$ref": "#/components/schemas/OrderType" + }, + "routeProperties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RouteProperty" + } + }, + "securityType": { + "$ref": "#/components/schemas/SecurityType" + }, + "type": { + "$ref": "#/components/schemas/RouteType" + }, + "uiSchema": { + "type": "string" + }, + "venue": { + "type": "string" + } + }, + "additionalProperties": false + }, + "RouteApplicability": { + "type": "object", + "properties": { + "userId": { + "type": "integer", + "format": "int32" + }, + "accountId": { + "type": "integer", + "format": "int32" + }, + "securityType": { + "$ref": "#/components/schemas/SecurityType" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "orderType": { + "$ref": "#/components/schemas/OrderType" + }, + "routeIds": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + } + }, + "additionalProperties": false + }, + "RouteProperty": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "$ref": "#/components/schemas/RoutePropertyType" + }, + "value": { + "type": "string" + } + }, + "additionalProperties": false + }, + "RoutePropertyType": { + "enum": [ + "ROUTE_PROPERTY_TYPE_UNKNOWN", + "ROUTE_PROPERTY_TYPE_ORDER_TYPE", + "ROUTE_PROPERTY_TYPE_PERMISSION", + "ROUTE_PROPERTY_TYPE_TIF", + "ROUTE_PROPERTY_TYPE_CROSS_TYPE", + "ROUTE_PROPERTY_TYPE_STRATEGY_ID", + "ROUTE_PROPERTY_TYPE_CONTINGENCY", + "ROUTE_PROPERTY_TYPE_INSTRUCTION", + "ROUTE_PROPERTY_TYPE_EQUITY_EX_DESTINATION", + "ROUTE_PROPERTY_TYPE_SESSION_ELIGIBILITY" + ], + "type": "string" + }, + "RouteType": { + "enum": [ + "ROUTE_TYPE_DMA", + "ROUTE_TYPE_ALGO", + "ROUTE_TYPE_STAGE", + "ROUTE_TYPE_AWAY", + "ROUTE_TYPE_PAR", + "ROUTE_TYPE_MANUAL", + "ROUTE_TYPE_P2P", + "ROUTE_TYPE_CBOE", + "ROUTE_TYPE_BROKER" + ], + "type": "string" + }, + "RoutingSessionGroup": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/RoutingSessionGroupType" + } + }, + "additionalProperties": false + }, + "RoutingSessionGroupType": { + "enum": [ + "ROUTING_SESSION_GROUP_TYPE_UNKNOWN", + "ROUTING_SESSION_GROUP_TYPE_BROKER", + "ROUTING_SESSION_GROUP_TYPE_EXCHANGE", + "ROUTING_SESSION_GROUP_TYPE_STAGE", + "ROUTING_SESSION_GROUP_TYPE_AWAY", + "ROUTING_SESSION_GROUP_TYPE_PAR", + "ROUTING_SESSION_GROUP_TYPE_MANUAL", + "ROUTING_SESSION_GROUP_TYPE_P2P" + ], + "type": "string" + }, + "Scenario": { + "type": "object", + "properties": { + "price": { + "type": "number", + "format": "double" + }, + "legs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ScenarioLeg" + } + }, + "position": { + "$ref": "#/components/schemas/ScenarioPosition" + } + }, + "additionalProperties": false + }, + "ScenarioLeg": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "prem": { + "type": "number", + "format": "double" + }, + "profit": { + "type": "number", + "format": "double" + }, + "rho": { + "type": "number", + "format": "double" + }, + "theta": { + "type": "number", + "format": "double" + }, + "totalValue": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + }, + "volatility": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "ScenarioPosition": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "prem": { + "type": "number", + "format": "double" + }, + "profit": { + "type": "number", + "format": "double" + }, + "rho": { + "type": "number", + "format": "double" + }, + "theta": { + "type": "number", + "format": "double" + }, + "totalValue": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + }, + "volatility": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "ScenarioTheo": { + "type": "object", + "properties": { + "asOfTs": { + "type": "string" + }, + "asOfEvalExpiry": { + "type": "boolean" + }, + "scenarios": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Scenario" + } + } + }, + "additionalProperties": false + }, + "SearchOrderHistoryResponse": { + "type": "object", + "properties": { + "orders": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericOrder" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "Security": { + "type": "object", + "properties": { + "stock": { + "$ref": "#/components/schemas/Stock" + }, + "option": { + "$ref": "#/components/schemas/Option" + }, + "optionRoot": { + "$ref": "#/components/schemas/OptionRoot" + }, + "future": { + "$ref": "#/components/schemas/Future" + }, + "futureRoot": { + "$ref": "#/components/schemas/FutureRoot" + }, + "index": { + "$ref": "#/components/schemas/Index" + }, + "futureSpread": { + "$ref": "#/components/schemas/FutureSpread" + }, + "fx": { + "$ref": "#/components/schemas/Fx" + }, + "crypto": { + "$ref": "#/components/schemas/Crypto" + }, + "flexOption": { + "$ref": "#/components/schemas/FlexOption" + } + }, + "additionalProperties": false + }, + "SecurityCategory": { + "enum": [ + "SECURITY_CATEGORY_UNKNOWN", + "SECURITY_CATEGORY_COMMON_STOCK", + "SECURITY_CATEGORY_PREFERRED_STOCK", + "SECURITY_CATEGORY_WARRANT", + "SECURITY_CATEGORY_TRUST_UNIT", + "SECURITY_CATEGORY_INSTALLMENT_RECEIPT", + "SECURITY_CATEGORY_DEBENTURE", + "SECURITY_CATEGORY_NOTE", + "SECURITY_CATEGORY_EQUITY_OPTION", + "SECURITY_CATEGORY_INDEX_OPTION", + "SECURITY_CATEGORY_FUTURE", + "SECURITY_CATEGORY_MUTUAL_FUND", + "SECURITY_CATEGORY_CORPORATE_BOND", + "SECURITY_CATEGORY_MUNICIPAL_BOND", + "SECURITY_CATEGORY_TREASURY_BILL", + "SECURITY_CATEGORY_RIGHT", + "SECURITY_CATEGORY_INDEX", + "SECURITY_CATEGORY_ETF", + "SECURITY_CATEGORY_ETN", + "SECURITY_CATEGORY_ADR", + "SECURITY_CATEGORY_FUTURE_SPREAD", + "SECURITY_CATEGORY_FUTURE_ROOT", + "SECURITY_CATEGORY_OPTION_ROOT", + "SECURITY_CATEGORY_FUTURE_OPTION", + "SECURITY_CATEGORY_FX", + "SECURITY_CATEGORY_CRYPTO", + "SECURITY_CATEGORY_FLEX_OPTION", + "SECURITY_CATEGORY_CONVERTIBLE", + "SECURITY_CATEGORY_UNIT", + "SECURITY_CATEGORY_WHEN_DISTRIBUTED", + "SECURITY_CATEGORY_WHEN_ISSUED", + "SECURITY_CATEGORY_TEST" + ], + "type": "string" + }, + "SecurityType": { + "enum": [ + "SECURITY_TYPE_UNKNOWN", + "SECURITY_TYPE_STOCK", + "SECURITY_TYPE_OPTION", + "SECURITY_TYPE_OPTION_ROOT", + "SECURITY_TYPE_FUTURE", + "SECURITY_TYPE_FUTURE_ROOT", + "SECURITY_TYPE_INDEX", + "SECURITY_TYPE_BOND", + "SECURITY_TYPE_FUTURE_SPREAD", + "SECURITY_TYPE_FX", + "SECURITY_TYPE_CRYPTO", + "SECURITY_TYPE_FLEX_OPTION" + ], + "type": "string" + }, + "SettlementDeliverableType": { + "enum": [ + "SETTLEMENT_DELIVERABLE_TYPE_UNDERLYING", + "SETTLEMENT_DELIVERABLE_TYPE_CASH", + "SETTLEMENT_DELIVERABLE_TYPE_PHYSICAL", + "SETTLEMENT_DELIVERABLE_TYPE_UNDEFINED" + ], + "type": "string" + }, + "SettlementInfo": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "format": "double" + }, + "symbol": { + "type": "string" + }, + "deliverableType": { + "$ref": "#/components/schemas/SettlementDeliverableType" + } + }, + "additionalProperties": false + }, + "ShockValue": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "dollarDelta": { + "type": "number", + "format": "double" + }, + "pnL": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "volatility": { + "type": "number", + "format": "double" + }, + "flags": { + "$ref": "#/components/schemas/ShockValueFlags" + } + }, + "additionalProperties": false + }, + "ShockValueFlags": { + "type": "object", + "properties": { + "expired": { + "type": "boolean" + }, + "exercised": { + "type": "boolean" + }, + "delivered": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "Side": { + "enum": [ + "SIDE_NOT_SPECIFIED", + "SIDE_BUY", + "SIDE_SELL_SHORT_EXEMPT", + "SIDE_SELL", + "SIDE_SELL_SHORT", + "SIDE_CROSS" + ], + "type": "string" + }, + "SpreadLegSide": { + "enum": [ + "SPREAD_LEG_SIDE_UNKNOWN", + "SPREAD_LEG_SIDE_BUY", + "SPREAD_LEG_SIDE_SELL" + ], + "type": "string" + }, + "SpreadLegType": { + "enum": [ + "SPREAD_LEG_TYPE_UNKNOWN", + "SPREAD_LEG_TYPE_OUTRIGHT", + "SPREAD_LEG_TYPE_VOLATILITY" + ], + "type": "string" + }, + "Status": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Any" + } + } + }, + "additionalProperties": false + }, + "StatusCode": { + "enum": [ + "STATUS_CODE_OK", + "STATUS_CODE_ERROR", + "STATUS_CODE_DISCONNECTED", + "STATUS_CODE_NOT_AUTHORIZED", + "STATUS_CODE_TIMEOUT", + "STATUS_CODE_SERVER_BUSY", + "STATUS_CODE_SERVER_ERROR", + "STATUS_CODE_NOT_FOUND", + "STATUS_CODE_VALIDATION_ERROR", + "STATUS_CODE_NOT_CONNECTED", + "STATUS_CODE_PEER_ALREADY_EXISTS", + "STATUS_CODE_NOT_UPDATED" + ], + "type": "string" + }, + "Stock": { + "type": "object", + "properties": { + "aliases": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "listedDt": { + "$ref": "#/components/schemas/Date" + }, + "delistedDt": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "exchangeId": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "priceBaseFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFactor": { + "type": "number", + "format": "double" + }, + "priceDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "qtyDisplayFactor": { + "type": "number", + "format": "double" + }, + "qtyDisplayFormat": { + "$ref": "#/components/schemas/NumericDisplayFormat" + }, + "securityCategory": { + "$ref": "#/components/schemas/SecurityCategory" + }, + "symbol": { + "type": "string" + }, + "tickRule": { + "type": "string" + }, + "tickSize": { + "type": "number", + "format": "double" + }, + "tickValue": { + "type": "number", + "format": "double" + }, + "tradedExchanges": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ExchangeCode" + } + }, + "category": { + "type": "string" + }, + "industry": { + "type": "string" + }, + "lotSize": { + "type": "integer", + "format": "int32" + }, + "sector": { + "type": "string" + } + }, + "additionalProperties": false + }, + "Tif": { + "enum": [ + "TIF_UNKNOWN", + "TIF_DAY", + "TIF_GTC", + "TIF_OPG", + "TIF_IOC", + "TIF_FOK", + "TIF_GTX", + "TIF_GTD", + "TIF_CLO", + "TIF_ETH" + ], + "type": "string" + }, + "TimeOfDay": { + "type": "object", + "properties": { + "hours": { + "type": "integer", + "format": "int32" + }, + "minutes": { + "type": "integer", + "format": "int32" + }, + "seconds": { + "type": "integer", + "format": "int32" + }, + "nanos": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "TimsClassGroup": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "dollarDelta": { + "type": "number", + "format": "double" + }, + "dollarGamma": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "hc": { + "type": "number", + "format": "double" + }, + "hcMin": { + "type": "number", + "format": "double" + }, + "longNav": { + "type": "number", + "format": "double" + }, + "marginReq": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "pnL": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "positions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TimsPositionGroup" + } + }, + "productGroup": { + "type": "string" + }, + "rho": { + "type": "number", + "format": "double" + }, + "shortNav": { + "type": "number", + "format": "double" + }, + "symbol": { + "type": "string" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "TimsMarginData": { + "type": "object", + "properties": { + "accountType": { + "type": "string" + }, + "classGroupCount": { + "type": "integer", + "format": "int32" + }, + "classGroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TimsClassGroup" + } + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "dollarDelta": { + "type": "number", + "format": "double" + }, + "dollarGamma": { + "type": "number", + "format": "double" + }, + "longNav": { + "type": "number", + "format": "double" + }, + "marginReq": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "porfolioGroupCount": { + "type": "integer", + "format": "int32" + }, + "positionGroupCount": { + "type": "integer", + "format": "int32" + }, + "productGroupCount": { + "type": "integer", + "format": "int32" + }, + "productGroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TimsProductGroup" + } + }, + "rho": { + "type": "number", + "format": "double" + }, + "shortNav": { + "type": "number", + "format": "double" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "TimsPositionGroup": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "hcMin": { + "type": "number", + "format": "double" + }, + "hcMinval": { + "type": "number", + "format": "double" + }, + "marginReq": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "pnL": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "price": { + "type": "number", + "format": "double" + }, + "qty": { + "type": "number", + "format": "double" + }, + "rho": { + "type": "number", + "format": "double" + }, + "rpgRoot": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "TimsProductGroup": { + "type": "object", + "properties": { + "delta": { + "type": "number", + "format": "double" + }, + "dollarDelta": { + "type": "number", + "format": "double" + }, + "dollarGamma": { + "type": "number", + "format": "double" + }, + "gamma": { + "type": "number", + "format": "double" + }, + "group": { + "type": "string" + }, + "hc": { + "type": "number", + "format": "double" + }, + "hcMin": { + "type": "number", + "format": "double" + }, + "longNav": { + "type": "number", + "format": "double" + }, + "marginReq": { + "type": "number", + "format": "double" + }, + "nav": { + "type": "number", + "format": "double" + }, + "pnLRange": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "portfolioGroup": { + "type": "string" + }, + "rho": { + "type": "number", + "format": "double" + }, + "shortNav": { + "type": "number", + "format": "double" + }, + "theta": { + "type": "number", + "format": "double" + }, + "vega": { + "type": "number", + "format": "double" + } + }, + "additionalProperties": false + }, + "TradeConfirm": { + "type": "object", + "properties": { + "accountId": { + "type": "integer", + "format": "int32" + }, + "accountName": { + "type": "string" + }, + "allocId": { + "type": "string" + }, + "allocQty": { + "type": "number", + "format": "double" + }, + "auxPrice": { + "type": "number", + "format": "double" + }, + "avgPrice": { + "type": "number", + "format": "double" + }, + "billingCode": { + "type": "string" + }, + "capacity": { + "$ref": "#/components/schemas/CapacityCode" + }, + "clearingAccount": { + "type": "string" + }, + "clearingRange": { + "$ref": "#/components/schemas/ClearingRange" + }, + "clientId": { + "type": "string" + }, + "cmta": { + "type": "string" + }, + "commission": { + "type": "number", + "format": "double" + }, + "crossSideType": { + "$ref": "#/components/schemas/CrossSideType" + }, + "crossType": { + "$ref": "#/components/schemas/CrossType" + }, + "cumQty": { + "type": "number", + "format": "double" + }, + "curOrdId": { + "type": "string" + }, + "deliverToCompid": { + "type": "string" + }, + "deliverToSubid": { + "type": "string" + }, + "description": { + "type": "string" + }, + "drop": { + "type": "boolean" + }, + "efid": { + "type": "string" + }, + "execBroker": { + "type": "string" + }, + "execId": { + "type": "string" + }, + "execRefId": { + "type": "string" + }, + "execType": { + "$ref": "#/components/schemas/ExecType" + }, + "exerciseStyle": { + "$ref": "#/components/schemas/OptionExerciseStyle" + }, + "expirationDt": { + "$ref": "#/components/schemas/Date" + }, + "fee1": { + "type": "number", + "format": "double" + }, + "fee2": { + "type": "number", + "format": "double" + }, + "frequentTraderId": { + "type": "string" + }, + "giveUp": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "incomingClOrdId": { + "type": "string" + }, + "incomingOrdId": { + "type": "string" + }, + "incomingOrigClordId": { + "type": "string" + }, + "lastMarket": { + "type": "string" + }, + "lastPrice": { + "type": "number", + "format": "double" + }, + "lastQty": { + "type": "number", + "format": "double" + }, + "leavesQty": { + "type": "number", + "format": "double" + }, + "legId": { + "type": "string" + }, + "liquidityFlag": { + "type": "string" + }, + "locateId": { + "type": "string" + }, + "mpid": { + "type": "string" + }, + "multiLegReportingtype": { + "$ref": "#/components/schemas/MultiLegReportingType" + }, + "ordType": { + "$ref": "#/components/schemas/OrdType" + }, + "originationType": { + "$ref": "#/components/schemas/OriginationType" + }, + "origOrdId": { + "type": "string" + }, + "parentOrdId": { + "type": "string" + }, + "permOrdId": { + "type": "string" + }, + "positionEffect": { + "$ref": "#/components/schemas/PositionEffect" + }, + "price": { + "type": "number", + "format": "double" + }, + "priceType": { + "$ref": "#/components/schemas/PriceType" + }, + "putCall": { + "$ref": "#/components/schemas/PutCall" + }, + "qty": { + "type": "number", + "format": "double" + }, + "reqOrdId": { + "type": "string" + }, + "root": { + "type": "string" + }, + "route": { + "type": "string" + }, + "routingSession": { + "type": "string" + }, + "securityType": { + "$ref": "#/components/schemas/SecurityType" + }, + "settlementType": { + "$ref": "#/components/schemas/OptionSettlementType" + }, + "side": { + "$ref": "#/components/schemas/Side" + }, + "source": { + "type": "string" + }, + "sourceAddress": { + "type": "string" + }, + "strategyId": { + "type": "string" + }, + "strike": { + "type": "number", + "format": "double" + }, + "symbol": { + "type": "string" + }, + "tag": { + "type": "string" + }, + "tag1": { + "type": "string" + }, + "targetCompId": { + "type": "string" + }, + "targetSubId": { + "type": "string" + }, + "text": { + "type": "string" + }, + "tif": { + "$ref": "#/components/schemas/Tif" + }, + "tradedDt": { + "$ref": "#/components/schemas/Date" + }, + "traderId": { + "type": "string" + }, + "tradingFirmId": { + "type": "integer", + "format": "int32" + }, + "transactTs": { + "type": "string" + }, + "underlying": { + "type": "string" + }, + "userId": { + "type": "integer", + "format": "int32" + }, + "workingQty": { + "type": "number", + "format": "double" + }, + "multiplier": { + "type": "number", + "format": "double" + }, + "dacDelta": { + "type": "number", + "format": "double" + }, + "dacReferencePrice": { + "type": "number", + "format": "double" + }, + "manualFillTime": { + "type": "string" + } + }, + "additionalProperties": false + }, + "TradingFirm": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "eqMpid": { + "type": "string" + }, + "name": { + "type": "string" + }, + "occClearingNumber": { + "type": "string" + } + }, + "additionalProperties": false + }, + "TradingFirmSlim": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false + }, + "TradingHoliday": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "country": { + "$ref": "#/components/schemas/Country" + }, + "date": { + "$ref": "#/components/schemas/Date" + }, + "description": { + "type": "string" + }, + "isEarlyClose": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "TradingSession": { + "type": "object", + "properties": { + "daysOfTheWeek": { + "type": "string" + }, + "endTime": { + "$ref": "#/components/schemas/TimeOfDay" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + }, + "startTime": { + "$ref": "#/components/schemas/TimeOfDay" + }, + "tradingSessionGroupId": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + }, + "TradingSessionGroup": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + }, + "sessions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TradingSession" + } + } + }, + "additionalProperties": false + }, + "User": { + "type": "object", + "properties": { + "domain": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "isLockedOut": { + "type": "boolean" + }, + "lastName": { + "type": "string" + }, + "location": { + "$ref": "#/components/schemas/UserLocation" + }, + "phonePrimary": { + "type": "string" + }, + "phoneSecondary": { + "type": "string" + }, + "region": { + "type": "string" + }, + "regionCode": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/UserStatus" + }, + "tradingFirmId": { + "type": "integer", + "format": "int32" + }, + "type": { + "$ref": "#/components/schemas/UserType" + }, + "userName": { + "type": "string" + }, + "city": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/UserPermission" + } + }, + "setupTicket": { + "type": "string" + }, + "largeTraderId": { + "type": "string" + } + }, + "additionalProperties": false + }, + "UserLocation": { + "enum": [ + "USER_LOCATION_UNKNOWN", + "USER_LOCATION_ON_FLOOR", + "USER_LOCATION_OFF_FLOOR" + ], + "type": "string" + }, + "UserPermission": { + "type": "object", + "properties": { + "claim": { + "type": "string" + }, + "claimType": { + "$ref": "#/components/schemas/ClaimType" + }, + "description": { + "type": "string" + } + }, + "additionalProperties": false + }, + "UserStatus": { + "enum": [ + "USER_STATUS_UNKNOWN", + "USER_STATUS_ACTIVE", + "USER_STATUS_DELETED", + "USER_STATUS_VIEW_ONLY", + "USER_STATUS_DISABLED" + ], + "type": "string" + }, + "UserType": { + "enum": [ + "USER_TYPE_UNKNOWN", + "USER_TYPE_API", + "USER_TYPE_GUI" + ], + "type": "string" + }, + "ValidateRiskResponse": { + "type": "object", + "properties": { + "isValid": { + "type": "boolean" + }, + "riskRejects": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RiskReject" + } + }, + "errorMessage": { + "type": "string" + }, + "statusCode": { + "$ref": "#/components/schemas/StatusCode" + } + }, + "additionalProperties": false + }, + "VolatilityShockSkew": { + "enum": [ + "VOLATILITY_SHOCK_SKEW_STICKY_DELTA", + "VOLATILITY_SHOCK_SKEW_STICKY_STRIKE" + ], + "type": "string" + }, + "VolatilityShockType": { + "enum": [ + "VOLATILITY_SHOCK_TYPE_ABSOLUTE", + "VOLATILITY_SHOCK_TYPE_RELATIVE" + ], + "type": "string" + } + }, + "securitySchemes": { + "Bearer": { + "type": "http", + "description": "JSON Web Token based security", + "scheme": "Bearer", + "bearerFormat": "JWT" + } + } + }, + "security": [ + { + "Bearer": [] + } + ] +} \ No newline at end of file diff --git a/openapi/templates/api_init.py.jinja b/openapi/templates/api_init.py.jinja new file mode 100644 index 000000000..dc035f4ce --- /dev/null +++ b/openapi/templates/api_init.py.jinja @@ -0,0 +1 @@ +""" Contains methods for accessing the API """ diff --git a/openapi/templates/client.py.jinja b/openapi/templates/client.py.jinja new file mode 100644 index 000000000..7a166a013 --- /dev/null +++ b/openapi/templates/client.py.jinja @@ -0,0 +1,191 @@ +import ssl +from typing import Any + +from attrs import define, field, evolve +import httpx + + +{% set attrs_info = { + "raise_on_unexpected_status": namespace( + type="bool", + default="field(default=False, kw_only=True)", + docstring="Whether or not to raise an errors.UnexpectedStatus if the API returns a status code" + " that was not documented in the source OpenAPI document. Can also be provided as a keyword" + " argument to the constructor." + ), + "token": namespace(type="str", default="", docstring="The token to use for authentication"), + "prefix": namespace(type="str", default='"Bearer"', docstring="The prefix to use for the Authorization header"), + "auth_header_name": namespace(type="str", default='"Authorization"', docstring="The name of the Authorization header"), +} %} + +{% macro attr_in_class_docstring(name) %} +{{ name }}: {{ attrs_info[name].docstring }} +{%- endmacro %} + +{% macro declare_attr(name) %} +{% set attr = attrs_info[name] %} +{{ name }}: {{ attr.type }}{% if attr.default %} = {{ attr.default }}{% endif %} +{% if attr.docstring and config.docstrings_on_attributes +%} +"""{{ attr.docstring }}""" +{%- endif %} +{% endmacro %} + +@define +class Client: + """A class for keeping track of data related to the API + +{% macro httpx_args_docstring() %} + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. +{% endmacro %} +{{ httpx_args_docstring() }} +{% if not config.docstrings_on_attributes %} + + Attributes: + {{ attr_in_class_docstring("raise_on_unexpected_status") | wordwrap(101) | indent(12) }} +{% endif %} + """ +{% macro attributes() %} + {{ declare_attr("raise_on_unexpected_status") | indent(4) }} + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) +{% endmacro %}{{ attributes() }} +{% macro builders(self) %} + def with_headers(self, headers: dict[str, str]) -> "{{ self }}": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "{{ self }}": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "{{ self }}": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) +{% endmacro %}{{ builders("Client") }} +{% macro httpx_stuff(name, custom_constructor=None) %} + def set_httpx_client(self, client: httpx.Client) -> "{{ name }}": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + {% if custom_constructor %} + {{ custom_constructor | indent(12) }} + {% endif %} + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "{{ name }}": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "{{ name }}": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + {% if custom_constructor %} + {{ custom_constructor | indent(12) }} + {% endif %} + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "{{ name }}": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) +{% endmacro %}{{ httpx_stuff("Client") }} + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + +{{ httpx_args_docstring() }} +{% if not config.docstrings_on_attributes %} + + Attributes: + {{ attr_in_class_docstring("raise_on_unexpected_status") | wordwrap(101) | indent(12) }} + {{ attr_in_class_docstring("token") | indent(8) }} + {{ attr_in_class_docstring("prefix") | indent(8) }} + {{ attr_in_class_docstring("auth_header_name") | indent(8) }} +{% endif %} + """ + +{{ attributes() }} + {{ declare_attr("token") | indent(4) }} + {{ declare_attr("prefix") | indent(4) }} + {{ declare_attr("auth_header_name") | indent(4) }} + +{{ builders("AuthenticatedClient") }} +{{ httpx_stuff("AuthenticatedClient", "self._headers[self.auth_header_name] = f\"{self.prefix} {self.token}\" if self.prefix else self.token") }} diff --git a/openapi/templates/endpoint_init.py.jinja b/openapi/templates/endpoint_init.py.jinja new file mode 100644 index 000000000..c9921b5fd --- /dev/null +++ b/openapi/templates/endpoint_init.py.jinja @@ -0,0 +1 @@ +""" Contains endpoint functions for accessing the API """ diff --git a/openapi/templates/endpoint_macros.py.jinja b/openapi/templates/endpoint_macros.py.jinja new file mode 100644 index 000000000..5fafa0125 --- /dev/null +++ b/openapi/templates/endpoint_macros.py.jinja @@ -0,0 +1,186 @@ +{% from "property_templates/helpers.jinja" import guarded_statement %} +{% from "helpers.jinja" import safe_docstring %} + +{% macro header_params(endpoint) %} +{% if endpoint.header_parameters or endpoint.bodies | length > 0 %} +headers: dict[str, Any] = {} +{% if endpoint.header_parameters %} + {% for parameter in endpoint.header_parameters %} + {% import "property_templates/" + parameter.template as param_template %} + {% if param_template.transform_header %} + {% set expression = param_template.transform_header(parameter.python_name) %} + {% else %} + {% set expression = parameter.python_name %} + {% endif %} + {% set statement = 'headers["' + parameter.name + '"]' + " = " + expression %} +{{ guarded_statement(parameter, parameter.python_name, statement) }} + {% endfor %} +{% endif %} +{% endif %} +{% endmacro %} + +{% macro cookie_params(endpoint) %} +{% if endpoint.cookie_parameters %} +cookies = {} + {% for parameter in endpoint.cookie_parameters %} + {% if parameter.required %} +cookies["{{ parameter.name}}"] = {{ parameter.python_name }} + {% else %} +if {{ parameter.python_name }} is not UNSET: + cookies["{{ parameter.name}}"] = {{ parameter.python_name }} + {% endif %} + + {% endfor %} +{% endif %} +{% endmacro %} + + +{% macro query_params(endpoint) %} +{% if endpoint.query_parameters %} +params: dict[str, Any] = {} + +{% for property in endpoint.query_parameters %} + {% set destination = property.python_name %} + {% import "property_templates/" + property.template as prop_template %} + {% if prop_template.transform %} + {% set destination = "json_" + property.python_name %} +{{ prop_template.transform(property, property.python_name, destination) }} + {% endif %} + {%- if not property.json_is_dict %} +params["{{ property.name }}"] = {{ destination }} + {% else %} +{{ guarded_statement(property, destination, "params.update(" + destination + ")") }} + {% endif %} + +{% endfor %} + +params = {k: v for k, v in params.items() if v is not UNSET and v is not None} +{% endif %} +{% endmacro %} + +{% macro body_to_kwarg(body) %} +{% if body.body_type == "data" %} +_kwargs["data"] = body.to_dict() +{% elif body.body_type == "files"%} +{{ multipart_body(body) }} +{% elif body.body_type == "json" %} +{{ json_body(body) }} +{% elif body.body_type == "content" %} +_kwargs["content"] = body.payload +{% endif %} +{% endmacro %} + +{% macro json_body(body) %} +{% set property = body.prop %} +{% import "property_templates/" + property.template as prop_template %} +{% if prop_template.transform %} +{{ prop_template.transform(property, property.python_name, "_kwargs[\"json\"]") }} +{% else %} +_kwargs["json"] = {{ property.python_name }} +{% endif %} +{% endmacro %} + +{% macro multipart_body(body) %} +{% set property = body.prop %} +{% import "property_templates/" + property.template as prop_template %} +{% if prop_template.transform_multipart_body %} +{{ prop_template.transform_multipart_body(property) }} +{% endif %} +{% endmacro %} + +{# The all the kwargs passed into an endpoint (and variants thereof)) #} +{% macro arguments(endpoint, include_client=True) %} +{# path parameters #} +{% for parameter in endpoint.path_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{% if include_client or ((endpoint.list_all_parameters() | length) > (endpoint.path_parameters | length)) %} +*, +{% endif %} +{# Proper client based on whether or not the endpoint requires authentication #} +{% if include_client %} +{% if endpoint.requires_security %} +client: AuthenticatedClient, +{% else %} +client: AuthenticatedClient | Client, +{% endif %} +{% endif %} +{# Any allowed bodies #} +{% if endpoint.bodies | length == 1 %} +body: {{ endpoint.bodies[0].prop.get_type_string() }}, +{% elif endpoint.bodies | length > 1 %} +body: ( + {% for body in endpoint.bodies %} + {{ body.prop.get_type_string() }}{% if not loop.last %} |{% endif %} + {% endfor %} +), +{% endif %} +{# query parameters #} +{% for parameter in endpoint.query_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{% for parameter in endpoint.header_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{# cookie parameters #} +{% for parameter in endpoint.cookie_parameters %} +{{ parameter.to_string() }}, +{% endfor %} +{% endmacro %} + +{# Just lists all kwargs to endpoints as name=name for passing to other functions #} +{% macro kwargs(endpoint, include_client=True) %} +{% for parameter in endpoint.path_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% if include_client %} +client=client, +{% endif %} +{% if endpoint.bodies | length > 0 %} +body=body, +{% endif %} +{% for parameter in endpoint.query_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% for parameter in endpoint.header_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% for parameter in endpoint.cookie_parameters %} +{{ parameter.python_name }}={{ parameter.python_name }}, +{% endfor %} +{% endmacro %} + +{% macro docstring_content(endpoint, return_string, is_detailed) %} +{% if endpoint.summary %}{{ endpoint.summary | wordwrap(100)}} + +{% endif -%} +{%- if endpoint.description %} {{ endpoint.description | wordwrap(100) }} + +{% endif %} +{% if not endpoint.summary and not endpoint.description %} +{# Leave extra space so that Args or Returns isn't at the top #} + +{% endif %} +{% set all_parameters = endpoint.list_all_parameters() %} +{% if all_parameters %} +Args: + {% for parameter in all_parameters %} + {{ parameter.to_docstring() | wordwrap(90) | indent(8) }} + {% endfor %} + +{% endif %} +Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + +Returns: +{% if is_detailed %} + Response[{{ return_string }}] +{% else %} + {{ return_string }} +{% endif %} +{% endmacro %} + +{% macro docstring(endpoint, return_string, is_detailed) %} +{{ safe_docstring(docstring_content(endpoint, return_string, is_detailed)) }} +{% endmacro %} diff --git a/openapi/templates/endpoint_module.py.jinja b/openapi/templates/endpoint_module.py.jinja new file mode 100644 index 000000000..d08cefab1 --- /dev/null +++ b/openapi/templates/endpoint_module.py.jinja @@ -0,0 +1,149 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ...client import AuthenticatedClient, Client +from ...types import Response, UNSET +from ... import errors + +{% for relative in endpoint.relative_imports | sort %} +{{ relative }} +{% endfor %} + +{% from "endpoint_macros.py.jinja" import header_params, cookie_params, query_params, + arguments, client, kwargs, parse_response, docstring, body_to_kwarg %} + +{% set return_string = endpoint.response_type() %} +{% set parsed_responses = (endpoint.responses | length > 0) and return_string != "Any" %} + +def _get_kwargs( + {{ arguments(endpoint, include_client=False) | indent(4) }} +) -> dict[str, Any]: + {{ header_params(endpoint) | indent(4) }} + + {{ cookie_params(endpoint) | indent(4) }} + + {{ query_params(endpoint) | indent(4) }} + + _kwargs: dict[str, Any] = { + "method": "{{ endpoint.method }}", + {% if endpoint.path_parameters %} + "url": "{{ endpoint.path }}".format( + {%- for parameter in endpoint.path_parameters -%} + {{parameter.python_name}}={{parameter.python_name}}, + {%- endfor -%} + ), + {% else %} + "url": "{{ endpoint.path }}", + {% endif %} + {% if endpoint.query_parameters %} + "params": params, + {% endif %} + {% if endpoint.cookie_parameters %} + "cookies": cookies, + {% endif %} + } + +{% if endpoint.bodies | length > 1 %} +{% for body in endpoint.bodies %} + if isinstance(body, {{body.prop.get_type_string() }}): + {{ body_to_kwarg(body) | indent(8) }} + headers["Content-Type"] = "{{ body.content_type }}" +{% endfor %} +{% elif endpoint.bodies | length == 1 %} +{% set body = endpoint.bodies[0] %} + {{ body_to_kwarg(body) | indent(4) }} + {% if body.content_type != "multipart/form-data" %}{# Need httpx to set the boundary automatically #} + headers["Content-Type"] = "{{ body.content_type }}" + {% endif %} +{% endif %} + +{% if endpoint.header_parameters or endpoint.bodies | length > 0 %} + _kwargs["headers"] = headers +{% endif %} + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> {{ return_string }} | None: + {% for response in endpoint.responses %} + if response.status_code == {{ response.status_code.value }}: + {% if parsed_responses %}{% import "property_templates/" + response.prop.template as prop_template %} + {% if prop_template.construct %} + {{ prop_template.construct(response.prop, response.source.attribute) | indent(8) }} + {% elif response.source.return_type == response.prop.get_type_string() %} + {{ response.prop.python_name }} = {{ response.source.attribute }} + {% else %} + {{ response.prop.python_name }} = cast({{ response.prop.get_type_string() }}, {{ response.source.attribute }}) + {% endif %} + return {{ response.prop.python_name }} + {% else %} + return None + {% endif %} + {% endfor %} + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[{{ return_string }}]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + {{ arguments(endpoint) | indent(4) }} +) -> Response[{{ return_string }}]: + {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} + + kwargs = _get_kwargs( + {{ kwargs(endpoint, include_client=False) }} + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +{% if parsed_responses %} +def sync( + {{ arguments(endpoint) | indent(4) }} +) -> {{ return_string }} | None: + {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} + + return sync_detailed( + {{ kwargs(endpoint) }} + ).parsed +{% endif %} + +async def asyncio_detailed( + {{ arguments(endpoint) | indent(4) }} +) -> Response[{{ return_string }}]: + {{ docstring(endpoint, return_string, is_detailed=true) | indent(4) }} + + kwargs = _get_kwargs( + {{ kwargs(endpoint, include_client=False) }} + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +{% if parsed_responses %} +async def asyncio( + {{ arguments(endpoint) | indent(4) }} +) -> {{ return_string }} | None: + {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} + + return (await asyncio_detailed( + {{ kwargs(endpoint) }} + )).parsed +{% endif %} diff --git a/openapi/templates/model.py.jinja b/openapi/templates/model.py.jinja new file mode 100644 index 000000000..abce0acf9 --- /dev/null +++ b/openapi/templates/model.py.jinja @@ -0,0 +1,241 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +{% if model.is_multipart_body %} +import json +from .. import types +{% endif %} + +from ..types import UNSET, Unset + +{% for relative in model.relative_imports | sort %} +{{ relative }} +{% endfor %} + +{% set all_lazy_imports = model.lazy_imports | list %} +{% if model.additional_properties and model.additional_properties.lazy_imports %} +{% set all_lazy_imports = all_lazy_imports + (model.additional_properties.lazy_imports | list) %} +{% endif %} +{% for lazy_import in all_lazy_imports %} +{% if loop.first %} +if TYPE_CHECKING: +{% endif %} + {{ lazy_import }} +{% endfor %} + + +{% if model.additional_properties %} +{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string() %} +{% endif %} + +{% set class_name = model.class_info.name %} +{% set module_name = model.class_info.module_name %} + +{% from "helpers.jinja" import safe_docstring %} + +T = TypeVar("T", bound="{{ class_name }}") + +{% macro class_docstring_content(model) %} + {% if model.title %}{{ model.title | wordwrap(116) }} + + {% endif -%} + {%- if model.description %}{{ model.description | wordwrap(116) }} + + {% endif %} + {% if not model.title and not model.description %} + {# Leave extra space so that a section doesn't start on the first line #} + + {% endif %} + {% if model.example %} + Example: + {{ model.example | string | wordwrap(112) | indent(12) }} + + {% endif %} + {% if (not config.docstrings_on_attributes) and (model.required_properties or model.optional_properties) %} + Attributes: + {% for property in model.required_properties + model.optional_properties %} + {{ property.to_docstring() | wordwrap(112) | indent(12) }} + {% endfor %}{% endif %} +{% endmacro %} + +{% macro declare_property(property) %} +{%- if config.docstrings_on_attributes and property.description -%} +{{ property.to_string() }} +{{ safe_docstring(property.description, omit_if_empty=True) | wordwrap(112) }} +{%- else -%} +{{ property.to_string() }} +{%- endif -%} +{% endmacro %} + +@_attrs_define +class {{ class_name }}: + {{ safe_docstring(class_docstring_content(model), omit_if_empty=config.docstrings_on_attributes) | indent(4) }} + + {% for property in model.required_properties + model.optional_properties %} + {% if property.default is none and property.required %} + {{ declare_property(property) | indent(4) }} + {% endif %} + {% endfor %} + {% for property in model.required_properties + model.optional_properties %} + {% if property.default is not none or not property.required %} + {{ declare_property(property) | indent(4) }} + {% endif %} + {% endfor %} + {% if model.additional_properties %} + additional_properties: dict[str, {{ additional_property_type }}] = _attrs_field(init=False, factory=dict) + {% endif %} + +{% macro _transform_property(property, content) %} +{% import "property_templates/" + property.template as prop_template %} +{%- if prop_template.transform -%} +{{ prop_template.transform(property=property, source=content, destination=property.python_name) }} +{%- else -%} +{{ property.python_name }} = {{ content }} +{%- endif -%} +{% endmacro %} + +{% macro multipart(property, source, destination) %} +{% import "property_templates/" + property.template as prop_template %} +{% if not property.required %} +if not isinstance({{source}}, Unset): + {{ prop_template.multipart(property, source, destination) | indent(4) }} +{% else %} +{{ prop_template.multipart(property, source, destination) }} +{% endif %} +{% endmacro %} + +{% macro _prepare_field_dict() %} +field_dict: dict[str, Any] = {} +{% if model.additional_properties %} +{% import "property_templates/" + model.additional_properties.template as prop_template %} +{% if prop_template.transform %} +field_dict.update({ + prop_name: {{ prop_template.transform_expression(model.additional_properties, "prop") if prop_template.transform_expression else "prop" }} + for prop_name, prop in self.additional_properties.items() +}) # noqa: PERF403 +{% else %} +field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() +}) # noqa: PERF403 +{%- endif -%} +{%- endif -%} +{% endmacro %} + +{% macro _to_dict() %} +{% for property in model.required_properties + model.optional_properties -%} +{{ _transform_property(property, "self." + property.python_name) }} + +{% endfor %} + +{{ _prepare_field_dict() }} +{% if model.required_properties | length > 0 or model.optional_properties | length > 0 %} +field_dict.update({ + {% for property in model.required_properties + model.optional_properties %} + {% if property.required %} + "{{ property.name }}": {{ property.python_name }}, + {% endif %} + {% endfor %} +}) +{% endif %} +{% for property in model.optional_properties %} +{% if not property.required %} +if {{ property.python_name }} is not UNSET: + field_dict["{{ property.name }}"] = {{ property.python_name }} +{% endif %} +{% endfor %} + +return field_dict +{% endmacro %} + + def to_dict(self) -> dict[str, Any]: + {{ _to_dict() | indent(8) }} + +{% if model.is_multipart_body %} + def to_multipart(self) -> types.RequestFiles: + files: types.RequestFiles = [] + + {% for property in model.required_properties + model.optional_properties %} + {% set destination = "\"" + property.name + "\"" %} + {{ multipart(property, "self." + property.python_name, destination) | indent(8) }} + + {% endfor %} + + {% if model.additional_properties %} + files.extend([ + {{ multipart(model.additional_properties, "prop", "prop_name") }} + for prop_name, prop in self.additional_properties.items() + ]) + {% endif %} + + return files + +{% endif %} + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: +{% if (model.required_properties or model.optional_properties or model.additional_properties) %} + d = dict(src_dict) +{% for property in model.required_properties + model.optional_properties %} + {% if property.required %} + {% set property_source = 'd.pop("' + property.name + '")' %} + {% else %} + {% set property_source = 'd.pop("' + property.name + '", UNSET)' %} + {% endif %} + {% import "property_templates/" + property.template as prop_template %} + {% if prop_template.construct %} + {{ prop_template.construct(property, property_source) | indent(8) }} + {% else %} + {{ property.python_name }} = {{ property_source }} + {% endif %} + +{% endfor %} +{% endif %} + {{ module_name }} = cls( +{% for property in model.required_properties + model.optional_properties %} + {{ property.python_name }}={{ property.python_name }}, +{% endfor %} + ) + +{% if model.additional_properties %} + {% if model.additional_properties.template %}{# Can be a bool instead of an object #} + {% import "property_templates/" + model.additional_properties.template as prop_template %} + + + {% else %} + {% set prop_template = None %} + {% endif %} + {% if prop_template and prop_template.construct %} + additional_properties = {} + for prop_name, prop_dict in d.items(): + {{ prop_template.construct(model.additional_properties, "prop_dict") | indent(12) }} + additional_properties[prop_name] = {{ model.additional_properties.python_name }} + + {{ module_name }}.additional_properties = additional_properties + {% else %} + {{ module_name }}.additional_properties = d + {% endif %} +{% endif %} + return {{ module_name }} + + {% if model.additional_properties %} + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> {{ additional_property_type }}: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: {{ additional_property_type }}) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties + {% endif %} diff --git a/openapi/templates/models_init.py.jinja b/openapi/templates/models_init.py.jinja new file mode 100644 index 000000000..7379e86ad --- /dev/null +++ b/openapi/templates/models_init.py.jinja @@ -0,0 +1,13 @@ +""" Contains all the data models used in inputs/outputs """ + +{% for import in imports | sort %} +{{ import }} +{% endfor %} + +{% if imports %} +__all__ = ( + {% for all in alls | sort %} + "{{ all }}", + {% endfor %} +) +{% endif %} diff --git a/openapi/templates/package_init.py.jinja b/openapi/templates/package_init.py.jinja new file mode 100644 index 000000000..ecf60e74d --- /dev/null +++ b/openapi/templates/package_init.py.jinja @@ -0,0 +1,9 @@ +{% from "helpers.jinja" import safe_docstring %} + +{{ safe_docstring(package_description) }} +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/openapi/templates/types.py.jinja b/openapi/templates/types.py.jinja new file mode 100644 index 000000000..aebf5f11c --- /dev/null +++ b/openapi/templates/types.py.jinja @@ -0,0 +1,53 @@ +""" Contains some shared types for properties """ + +from collections.abc import Mapping, MutableMapping +from http import HTTPStatus +from typing import BinaryIO, Generic, TypeVar, Literal, IO + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +# The types that `httpx.Client(files=)` can accept, copied from that library. +FileContent = IO[bytes] | bytes | str +FileTypes = ( + # (filename, file (or bytes), content_type) + tuple[str | None, FileContent, str | None] | + # (filename, file (or bytes), content_type, headers) + tuple[str | None, FileContent, str | None, Mapping[str, str]] +) +RequestFiles = list[tuple[str, FileTypes]] + +@define +class File: + """ Contains information for file uploads """ + + payload: BinaryIO + file_name: str | None = None + mime_type: str | None = None + + def to_tuple(self) -> FileTypes: + """ Return a tuple representation that httpx will accept for multipart/form-data """ + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """ A response from an endpoint """ + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: T | None + + +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] diff --git a/openapi_project/.gitignore b/openapi_project/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/openapi_project/README.md b/openapi_project/README.md new file mode 100644 index 000000000..e82f9de96 --- /dev/null +++ b/openapi_project/README.md @@ -0,0 +1,124 @@ +# openapi_project +A client library for accessing Theta Data v3 + +## Usage +First, create a client: + +```python +from openapi_package import Client + +client = Client(base_url="https://api.example.com") +``` + +If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead: + +```python +from openapi_package import AuthenticatedClient + +client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") +``` + +Now call your endpoint and use your models: + +```python +from openapi_package.models import MyDataModel +from openapi_package.api.my_tag import get_my_data_model +from openapi_package.types import Response + +with client as client: + my_data: MyDataModel = get_my_data_model.sync(client=client) + # or if you need more info (e.g. status_code) + response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) +``` + +Or do the same thing with an async version: + +```python +from openapi_package.models import MyDataModel +from openapi_package.api.my_tag import get_my_data_model +from openapi_package.types import Response + +async with client as client: + my_data: MyDataModel = await get_my_data_model.asyncio(client=client) + response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) +``` + +By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl="/path/to/certificate_bundle.pem", +) +``` + +You can also disable certificate validation altogether, but beware that **this is a security risk**. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl=False +) +``` + +Things to know: +1. Every path/method combo becomes a Python module with four functions: + 1. `sync`: Blocking request that returns parsed data (if successful) or `None` + 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. + 1. `asyncio`: Like `sync` but async instead of blocking + 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking + +1. All path/query params, and bodies become method arguments. +1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) +1. Any endpoint which did not have a tag will be in `openapi_package.api.default` + +## Advanced customizations + +There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case): + +```python +from openapi_package import Client + +def log_request(request): + print(f"Request event hook: {request.method} {request.url} - Waiting for response") + +def log_response(response): + request = response.request + print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}") + +client = Client( + base_url="https://api.example.com", + httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}, +) + +# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client() +``` + +You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url): + +```python +import httpx +from openapi_package import Client + +client = Client( + base_url="https://api.example.com", +) +# Note that base_url needs to be re-set, as would any shared cookies, headers, etc. +client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030")) +``` + +## Building / publishing this package +This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics: +1. Update the metadata in pyproject.toml (e.g. authors, version) +1. If you're using a private repository, configure it with Poetry + 1. `poetry config repositories. ` + 1. `poetry config http-basic. ` +1. Publish the client with `poetry publish --build -r ` or, if for public PyPI, just `poetry publish --build` + +If you want to install this client into another project without publishing it (e.g. for development) then: +1. If that project **is using Poetry**, you can simply do `poetry add ` from that project +1. If that project is not using Poetry: + 1. Build a wheel with `poetry build -f wheel` + 1. Install that wheel from the other project `pip install ` diff --git a/openapi_project/openapi_package/__init__.py b/openapi_project/openapi_package/__init__.py new file mode 100644 index 000000000..1588df19e --- /dev/null +++ b/openapi_project/openapi_package/__init__.py @@ -0,0 +1,8 @@ + +""" A client library for accessing Theta Data v3 """ +from openapi_project.openapi_package.client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/openapi_project/openapi_package/api/__init__.py b/openapi_project/openapi_package/api/__init__.py new file mode 100644 index 000000000..f5925d14d --- /dev/null +++ b/openapi_project/openapi_package/api/__init__.py @@ -0,0 +1 @@ +""" Contains methods for accessing the API """ diff --git a/openapi_project/openapi_package/api/index/__init__.py b/openapi_project/openapi_package/api/index/__init__.py new file mode 100644 index 000000000..03e86a6af --- /dev/null +++ b/openapi_project/openapi_package/api/index/__init__.py @@ -0,0 +1 @@ +""" Contains endpoint functions for accessing the API """ diff --git a/openapi_project/openapi_package/api/index/index_at_time_price.py b/openapi_project/openapi_package/api/index/index_at_time_price.py new file mode 100644 index 000000000..ddf7387ea --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_at_time_price.py @@ -0,0 +1,269 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_at_time_price_format import IndexAtTimePriceFormat +from openapi_project.openapi_package.models.index_at_time_price_response_200_item import IndexAtTimePriceResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + format_: Unset | IndexAtTimePriceFormat = IndexAtTimePriceFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["time_of_day"] = time_of_day + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/at_time/price", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexAtTimePriceResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexAtTimePriceResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexAtTimePriceResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + format_: Unset | IndexAtTimePriceFormat = IndexAtTimePriceFormat.JSON, + +) -> Response[list[IndexAtTimePriceResponse200Item]]: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - The ``time_of_day`` parameter represents the 00:00:00.000 ET that the price should be provided + for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + format_ (Unset | IndexAtTimePriceFormat): Default: IndexAtTimePriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexAtTimePriceResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + format_: Unset | IndexAtTimePriceFormat = IndexAtTimePriceFormat.JSON, + +) -> list[IndexAtTimePriceResponse200Item] | None: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - The ``time_of_day`` parameter represents the 00:00:00.000 ET that the price should be provided + for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + format_ (Unset | IndexAtTimePriceFormat): Default: IndexAtTimePriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexAtTimePriceResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + format_: Unset | IndexAtTimePriceFormat = IndexAtTimePriceFormat.JSON, + +) -> Response[list[IndexAtTimePriceResponse200Item]]: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - The ``time_of_day`` parameter represents the 00:00:00.000 ET that the price should be provided + for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + format_ (Unset | IndexAtTimePriceFormat): Default: IndexAtTimePriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexAtTimePriceResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + format_: Unset | IndexAtTimePriceFormat = IndexAtTimePriceFormat.JSON, + +) -> list[IndexAtTimePriceResponse200Item] | None: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - The ``time_of_day`` parameter represents the 00:00:00.000 ET that the price should be provided + for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + format_ (Unset | IndexAtTimePriceFormat): Default: IndexAtTimePriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexAtTimePriceResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_history_eod.py b/openapi_project/openapi_package/api/index/index_history_eod.py new file mode 100644 index 000000000..e89c72107 --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_history_eod.py @@ -0,0 +1,246 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_history_eod_format import IndexHistoryEodFormat +from openapi_project.openapi_package.models.index_history_eod_response_200_item import IndexHistoryEodResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | IndexHistoryEodFormat = IndexHistoryEodFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/history/eod", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexHistoryEodResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexHistoryEodResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexHistoryEodResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | IndexHistoryEodFormat = IndexHistoryEodFormat.JSON, + +) -> Response[list[IndexHistoryEodResponse200Item]]: + """ End of Day + + - Since [the indices feeds](/Articles/Data-And-Requests/The-SIPs.html) do not provide a national EOD + report, Theta Data generates a national EOD report at 17:15 each day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | IndexHistoryEodFormat): Default: IndexHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexHistoryEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | IndexHistoryEodFormat = IndexHistoryEodFormat.JSON, + +) -> list[IndexHistoryEodResponse200Item] | None: + """ End of Day + + - Since [the indices feeds](/Articles/Data-And-Requests/The-SIPs.html) do not provide a national EOD + report, Theta Data generates a national EOD report at 17:15 each day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | IndexHistoryEodFormat): Default: IndexHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexHistoryEodResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | IndexHistoryEodFormat = IndexHistoryEodFormat.JSON, + +) -> Response[list[IndexHistoryEodResponse200Item]]: + """ End of Day + + - Since [the indices feeds](/Articles/Data-And-Requests/The-SIPs.html) do not provide a national EOD + report, Theta Data generates a national EOD report at 17:15 each day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | IndexHistoryEodFormat): Default: IndexHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexHistoryEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | IndexHistoryEodFormat = IndexHistoryEodFormat.JSON, + +) -> list[IndexHistoryEodResponse200Item] | None: + """ End of Day + + - Since [the indices feeds](/Articles/Data-And-Requests/The-SIPs.html) do not provide a national EOD + report, Theta Data generates a national EOD report at 17:15 each day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | IndexHistoryEodFormat): Default: IndexHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexHistoryEodResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_history_ohlc.py b/openapi_project/openapi_package/api/index/index_history_ohlc.py new file mode 100644 index 000000000..05bb66851 --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_history_ohlc.py @@ -0,0 +1,305 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_history_ohlc_format import IndexHistoryOhlcFormat +from openapi_project.openapi_package.models.index_history_ohlc_interval import IndexHistoryOhlcInterval +from openapi_project.openapi_package.models.index_history_ohlc_response_200_item import IndexHistoryOhlcResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + interval: IndexHistoryOhlcInterval = IndexHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | IndexHistoryOhlcFormat = IndexHistoryOhlcFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + json_interval = interval.value + params["interval"] = json_interval + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/history/ohlc", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexHistoryOhlcResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexHistoryOhlcResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexHistoryOhlcResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + interval: IndexHistoryOhlcInterval = IndexHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | IndexHistoryOhlcFormat = IndexHistoryOhlcFormat.JSON, + +) -> Response[list[IndexHistoryOhlcResponse200Item]]: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + interval (IndexHistoryOhlcInterval): Default: IndexHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | IndexHistoryOhlcFormat): Default: IndexHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexHistoryOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + interval: IndexHistoryOhlcInterval = IndexHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | IndexHistoryOhlcFormat = IndexHistoryOhlcFormat.JSON, + +) -> list[IndexHistoryOhlcResponse200Item] | None: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + interval (IndexHistoryOhlcInterval): Default: IndexHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | IndexHistoryOhlcFormat): Default: IndexHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexHistoryOhlcResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + interval: IndexHistoryOhlcInterval = IndexHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | IndexHistoryOhlcFormat = IndexHistoryOhlcFormat.JSON, + +) -> Response[list[IndexHistoryOhlcResponse200Item]]: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + interval (IndexHistoryOhlcInterval): Default: IndexHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | IndexHistoryOhlcFormat): Default: IndexHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexHistoryOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + interval: IndexHistoryOhlcInterval = IndexHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | IndexHistoryOhlcFormat = IndexHistoryOhlcFormat.JSON, + +) -> list[IndexHistoryOhlcResponse200Item] | None: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + interval (IndexHistoryOhlcInterval): Default: IndexHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | IndexHistoryOhlcFormat): Default: IndexHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexHistoryOhlcResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_history_price.py b/openapi_project/openapi_package/api/index/index_history_price.py new file mode 100644 index 000000000..97dbd2676 --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_history_price.py @@ -0,0 +1,297 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_history_price_format import IndexHistoryPriceFormat +from openapi_project.openapi_package.models.index_history_price_interval import IndexHistoryPriceInterval +from openapi_project.openapi_package.models.index_history_price_response_200_item import IndexHistoryPriceResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: IndexHistoryPriceInterval = IndexHistoryPriceInterval.VALUE_4, + format_: Unset | IndexHistoryPriceFormat = IndexHistoryPriceFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/history/price", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexHistoryPriceResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexHistoryPriceResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexHistoryPriceResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: IndexHistoryPriceInterval = IndexHistoryPriceInterval.VALUE_4, + format_: Unset | IndexHistoryPriceFormat = IndexHistoryPriceFormat.JSON, + +) -> Response[list[IndexHistoryPriceResponse200Item]]: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - When the ``interval`` parameter is specified, the returned data represents the price at the exact + time of each timestamp. If the timestamp in the response is 10:30:00, the price field represents the + price at that exact time of the day. + - A price update from the exchange is omitted if the price remained the same from the previous + update. + + Args: + date (datetime.date): + symbol (str): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (IndexHistoryPriceInterval): Default: IndexHistoryPriceInterval.VALUE_4. + format_ (Unset | IndexHistoryPriceFormat): Default: IndexHistoryPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexHistoryPriceResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: IndexHistoryPriceInterval = IndexHistoryPriceInterval.VALUE_4, + format_: Unset | IndexHistoryPriceFormat = IndexHistoryPriceFormat.JSON, + +) -> list[IndexHistoryPriceResponse200Item] | None: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - When the ``interval`` parameter is specified, the returned data represents the price at the exact + time of each timestamp. If the timestamp in the response is 10:30:00, the price field represents the + price at that exact time of the day. + - A price update from the exchange is omitted if the price remained the same from the previous + update. + + Args: + date (datetime.date): + symbol (str): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (IndexHistoryPriceInterval): Default: IndexHistoryPriceInterval.VALUE_4. + format_ (Unset | IndexHistoryPriceFormat): Default: IndexHistoryPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexHistoryPriceResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: IndexHistoryPriceInterval = IndexHistoryPriceInterval.VALUE_4, + format_: Unset | IndexHistoryPriceFormat = IndexHistoryPriceFormat.JSON, + +) -> Response[list[IndexHistoryPriceResponse200Item]]: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - When the ``interval`` parameter is specified, the returned data represents the price at the exact + time of each timestamp. If the timestamp in the response is 10:30:00, the price field represents the + price at that exact time of the day. + - A price update from the exchange is omitted if the price remained the same from the previous + update. + + Args: + date (datetime.date): + symbol (str): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (IndexHistoryPriceInterval): Default: IndexHistoryPriceInterval.VALUE_4. + format_ (Unset | IndexHistoryPriceFormat): Default: IndexHistoryPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexHistoryPriceResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: IndexHistoryPriceInterval = IndexHistoryPriceInterval.VALUE_4, + format_: Unset | IndexHistoryPriceFormat = IndexHistoryPriceFormat.JSON, + +) -> list[IndexHistoryPriceResponse200Item] | None: + """ Price + + - Retrieves historical indices price reports. [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) + typically generate a price report every second for popular indices like SPX. + - When the ``interval`` parameter is specified, the returned data represents the price at the exact + time of each timestamp. If the timestamp in the response is 10:30:00, the price field represents the + price at that exact time of the day. + - A price update from the exchange is omitted if the price remained the same from the previous + update. + + Args: + date (datetime.date): + symbol (str): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (IndexHistoryPriceInterval): Default: IndexHistoryPriceInterval.VALUE_4. + format_ (Unset | IndexHistoryPriceFormat): Default: IndexHistoryPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexHistoryPriceResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_list_dates.py b/openapi_project/openapi_package/api/index/index_list_dates.py new file mode 100644 index 000000000..bda5734b9 --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_list_dates.py @@ -0,0 +1,215 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_list_dates_format import IndexListDatesFormat +from openapi_project.openapi_package.models.index_list_dates_response_200_item import IndexListDatesResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + format_: Unset | IndexListDatesFormat = IndexListDatesFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/list/dates", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexListDatesResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexListDatesResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexListDatesResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexListDatesFormat = IndexListDatesFormat.JSON, + +) -> Response[list[IndexListDatesResponse200Item]]: + """ Dates + + Lists all dates of data that are available for a index with a given request type and symbol. This + endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | IndexListDatesFormat): Default: IndexListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexListDatesResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexListDatesFormat = IndexListDatesFormat.JSON, + +) -> list[IndexListDatesResponse200Item] | None: + """ Dates + + Lists all dates of data that are available for a index with a given request type and symbol. This + endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | IndexListDatesFormat): Default: IndexListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexListDatesResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexListDatesFormat = IndexListDatesFormat.JSON, + +) -> Response[list[IndexListDatesResponse200Item]]: + """ Dates + + Lists all dates of data that are available for a index with a given request type and symbol. This + endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | IndexListDatesFormat): Default: IndexListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexListDatesResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexListDatesFormat = IndexListDatesFormat.JSON, + +) -> list[IndexListDatesResponse200Item] | None: + """ Dates + + Lists all dates of data that are available for a index with a given request type and symbol. This + endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | IndexListDatesFormat): Default: IndexListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexListDatesResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_list_symbols.py b/openapi_project/openapi_package/api/index/index_list_symbols.py new file mode 100644 index 000000000..bd21a91a1 --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_list_symbols.py @@ -0,0 +1,201 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_list_symbols_format import IndexListSymbolsFormat +from openapi_project.openapi_package.models.index_list_symbols_response_200_item import IndexListSymbolsResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + format_: Unset | IndexListSymbolsFormat = IndexListSymbolsFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/list/symbols", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexListSymbolsResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexListSymbolsResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexListSymbolsResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + format_: Unset | IndexListSymbolsFormat = IndexListSymbolsFormat.JSON, + +) -> Response[list[IndexListSymbolsResponse200Item]]: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | IndexListSymbolsFormat): Default: IndexListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexListSymbolsResponse200Item]] + """ + + + kwargs = _get_kwargs( + format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + format_: Unset | IndexListSymbolsFormat = IndexListSymbolsFormat.JSON, + +) -> list[IndexListSymbolsResponse200Item] | None: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | IndexListSymbolsFormat): Default: IndexListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexListSymbolsResponse200Item] + """ + + + return sync_detailed( + client=client, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + format_: Unset | IndexListSymbolsFormat = IndexListSymbolsFormat.JSON, + +) -> Response[list[IndexListSymbolsResponse200Item]]: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | IndexListSymbolsFormat): Default: IndexListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexListSymbolsResponse200Item]] + """ + + + kwargs = _get_kwargs( + format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + format_: Unset | IndexListSymbolsFormat = IndexListSymbolsFormat.JSON, + +) -> list[IndexListSymbolsResponse200Item] | None: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | IndexListSymbolsFormat): Default: IndexListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexListSymbolsResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_snapshot_ohlc.py b/openapi_project/openapi_package/api/index/index_snapshot_ohlc.py new file mode 100644 index 000000000..4bb935faa --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_snapshot_ohlc.py @@ -0,0 +1,219 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_snapshot_ohlc_format import IndexSnapshotOhlcFormat +from openapi_project.openapi_package.models.index_snapshot_ohlc_response_200_item import IndexSnapshotOhlcResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + format_: Unset | IndexSnapshotOhlcFormat = IndexSnapshotOhlcFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/snapshot/ohlc", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexSnapshotOhlcResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexSnapshotOhlcResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexSnapshotOhlcResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotOhlcFormat = IndexSnapshotOhlcFormat.JSON, + +) -> Response[list[IndexSnapshotOhlcResponse200Item]]: + """ Open High Low Close + + - Retrieves the real-time current day OHLC. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotOhlcFormat): Default: IndexSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexSnapshotOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotOhlcFormat = IndexSnapshotOhlcFormat.JSON, + +) -> list[IndexSnapshotOhlcResponse200Item] | None: + """ Open High Low Close + + - Retrieves the real-time current day OHLC. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotOhlcFormat): Default: IndexSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexSnapshotOhlcResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotOhlcFormat = IndexSnapshotOhlcFormat.JSON, + +) -> Response[list[IndexSnapshotOhlcResponse200Item]]: + """ Open High Low Close + + - Retrieves the real-time current day OHLC. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotOhlcFormat): Default: IndexSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexSnapshotOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotOhlcFormat = IndexSnapshotOhlcFormat.JSON, + +) -> list[IndexSnapshotOhlcResponse200Item] | None: + """ Open High Low Close + + - Retrieves the real-time current day OHLC. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotOhlcFormat): Default: IndexSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexSnapshotOhlcResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/index/index_snapshot_price.py b/openapi_project/openapi_package/api/index/index_snapshot_price.py new file mode 100644 index 000000000..8fee18d83 --- /dev/null +++ b/openapi_project/openapi_package/api/index/index_snapshot_price.py @@ -0,0 +1,219 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.index_snapshot_price_format import IndexSnapshotPriceFormat +from openapi_project.openapi_package.models.index_snapshot_price_response_200_item import IndexSnapshotPriceResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + format_: Unset | IndexSnapshotPriceFormat = IndexSnapshotPriceFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/index/snapshot/price", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[IndexSnapshotPriceResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = IndexSnapshotPriceResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[IndexSnapshotPriceResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotPriceFormat = IndexSnapshotPriceFormat.JSON, + +) -> Response[list[IndexSnapshotPriceResponse200Item]]: + """ Price + + - Retrieves a real-time last index price. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotPriceFormat): Default: IndexSnapshotPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexSnapshotPriceResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotPriceFormat = IndexSnapshotPriceFormat.JSON, + +) -> list[IndexSnapshotPriceResponse200Item] | None: + """ Price + + - Retrieves a real-time last index price. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotPriceFormat): Default: IndexSnapshotPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexSnapshotPriceResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotPriceFormat = IndexSnapshotPriceFormat.JSON, + +) -> Response[list[IndexSnapshotPriceResponse200Item]]: + """ Price + + - Retrieves a real-time last index price. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotPriceFormat): Default: IndexSnapshotPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[IndexSnapshotPriceResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | IndexSnapshotPriceFormat = IndexSnapshotPriceFormat.JSON, + +) -> list[IndexSnapshotPriceResponse200Item] | None: + """ Price + + - Retrieves a real-time last index price. + - [Exchanges](/Articles/Data-And-Requests/The-SIPs.html) typically generate a price report every + second for popular indices like SPX. + + Args: + symbol (list[str]): + format_ (Unset | IndexSnapshotPriceFormat): Default: IndexSnapshotPriceFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[IndexSnapshotPriceResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/__init__.py b/openapi_project/openapi_package/api/option/__init__.py new file mode 100644 index 000000000..03e86a6af --- /dev/null +++ b/openapi_project/openapi_package/api/option/__init__.py @@ -0,0 +1 @@ +""" Contains endpoint functions for accessing the API """ diff --git a/openapi_project/openapi_package/api/option/option_at_time_quote.py b/openapi_project/openapi_package/api/option/option_at_time_quote.py new file mode 100644 index 000000000..045103e67 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_at_time_quote.py @@ -0,0 +1,314 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_at_time_quote_format import OptionAtTimeQuoteFormat +from openapi_project.openapi_package.models.option_at_time_quote_response_200_item import OptionAtTimeQuoteResponse200Item +from openapi_project.openapi_package.models.option_at_time_quote_right import OptionAtTimeQuoteRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeQuoteRight = OptionAtTimeQuoteRight.BOTH, + format_: Unset | OptionAtTimeQuoteFormat = OptionAtTimeQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["time_of_day"] = time_of_day + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/at_time/quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionAtTimeQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionAtTimeQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionAtTimeQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeQuoteRight = OptionAtTimeQuoteRight.BOTH, + format_: Unset | OptionAtTimeQuoteFormat = OptionAtTimeQuoteFormat.JSON, + +) -> Response[list[OptionAtTimeQuoteResponse200Item]]: + """ Quote + + - Returns the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the quote should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeQuoteRight): Default: OptionAtTimeQuoteRight.BOTH. + format_ (Unset | OptionAtTimeQuoteFormat): Default: OptionAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionAtTimeQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeQuoteRight = OptionAtTimeQuoteRight.BOTH, + format_: Unset | OptionAtTimeQuoteFormat = OptionAtTimeQuoteFormat.JSON, + +) -> list[OptionAtTimeQuoteResponse200Item] | None: + """ Quote + + - Returns the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the quote should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeQuoteRight): Default: OptionAtTimeQuoteRight.BOTH. + format_ (Unset | OptionAtTimeQuoteFormat): Default: OptionAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionAtTimeQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeQuoteRight = OptionAtTimeQuoteRight.BOTH, + format_: Unset | OptionAtTimeQuoteFormat = OptionAtTimeQuoteFormat.JSON, + +) -> Response[list[OptionAtTimeQuoteResponse200Item]]: + """ Quote + + - Returns the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the quote should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeQuoteRight): Default: OptionAtTimeQuoteRight.BOTH. + format_ (Unset | OptionAtTimeQuoteFormat): Default: OptionAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionAtTimeQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeQuoteRight = OptionAtTimeQuoteRight.BOTH, + format_: Unset | OptionAtTimeQuoteFormat = OptionAtTimeQuoteFormat.JSON, + +) -> list[OptionAtTimeQuoteResponse200Item] | None: + """ Quote + + - Returns the last NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the quote should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeQuoteRight): Default: OptionAtTimeQuoteRight.BOTH. + format_ (Unset | OptionAtTimeQuoteFormat): Default: OptionAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionAtTimeQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_at_time_trade.py b/openapi_project/openapi_package/api/option/option_at_time_trade.py new file mode 100644 index 000000000..1234359a5 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_at_time_trade.py @@ -0,0 +1,330 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_at_time_trade_format import OptionAtTimeTradeFormat +from openapi_project.openapi_package.models.option_at_time_trade_response_200_item import OptionAtTimeTradeResponse200Item +from openapi_project.openapi_package.models.option_at_time_trade_right import OptionAtTimeTradeRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeTradeRight = OptionAtTimeTradeRight.BOTH, + format_: Unset | OptionAtTimeTradeFormat = OptionAtTimeTradeFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["time_of_day"] = time_of_day + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/at_time/trade", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionAtTimeTradeResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionAtTimeTradeResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionAtTimeTradeResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeTradeRight = OptionAtTimeTradeRight.BOTH, + format_: Unset | OptionAtTimeTradeFormat = OptionAtTimeTradeFormat.JSON, + +) -> Response[list[OptionAtTimeTradeResponse200Item]]: + """ Trade + + - Returns the last trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the trade should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeTradeRight): Default: OptionAtTimeTradeRight.BOTH. + format_ (Unset | OptionAtTimeTradeFormat): Default: OptionAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionAtTimeTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeTradeRight = OptionAtTimeTradeRight.BOTH, + format_: Unset | OptionAtTimeTradeFormat = OptionAtTimeTradeFormat.JSON, + +) -> list[OptionAtTimeTradeResponse200Item] | None: + """ Trade + + - Returns the last trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the trade should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeTradeRight): Default: OptionAtTimeTradeRight.BOTH. + format_ (Unset | OptionAtTimeTradeFormat): Default: OptionAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionAtTimeTradeResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeTradeRight = OptionAtTimeTradeRight.BOTH, + format_: Unset | OptionAtTimeTradeFormat = OptionAtTimeTradeFormat.JSON, + +) -> Response[list[OptionAtTimeTradeResponse200Item]]: + """ Trade + + - Returns the last trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the trade should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeTradeRight): Default: OptionAtTimeTradeRight.BOTH. + format_ (Unset | OptionAtTimeTradeFormat): Default: OptionAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionAtTimeTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionAtTimeTradeRight = OptionAtTimeTradeRight.BOTH, + format_: Unset | OptionAtTimeTradeFormat = OptionAtTimeTradeFormat.JSON, + +) -> list[OptionAtTimeTradeResponse200Item] | None: + """ Trade + + - Returns the last trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) at a + specified millisecond of the day. + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + - The ``time_of_day``parameter represents the 00:00:00.000 ET that the trade should be provided for. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionAtTimeTradeRight): Default: OptionAtTimeTradeRight.BOTH. + format_ (Unset | OptionAtTimeTradeFormat): Default: OptionAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionAtTimeTradeResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_eod.py b/openapi_project/openapi_package/api/option/option_history_eod.py new file mode 100644 index 000000000..54557e473 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_eod.py @@ -0,0 +1,323 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_eod_format import OptionHistoryEodFormat +from openapi_project.openapi_package.models.option_history_eod_response_200_item import OptionHistoryEodResponse200Item +from openapi_project.openapi_package.models.option_history_eod_right import OptionHistoryEodRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + start_date: datetime.date, + end_date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryEodRight = OptionHistoryEodRight.BOTH, + format_: Unset | OptionHistoryEodFormat = OptionHistoryEodFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/eod", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryEodResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryEodResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryEodResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + start_date: datetime.date, + end_date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryEodRight = OptionHistoryEodRight.BOTH, + format_: Unset | OptionHistoryEodFormat = OptionHistoryEodFormat.JSON, + +) -> Response[list[OptionHistoryEodResponse200Item]]: + """ End of Day + + - Since [OPRA](/Articles/Data-And-Requests/The-SIPs.html) does not provide a national EOD report for + options, Thetadata generates a national EOD report at 17:15 ET each day. + - ``created`` represents the datetime the report was generated and ``last_trade`` represents the + datetime of the last trade. + - The quote in the response represents the last NBBO reported by OPRA at the time of report + generation. + - You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We will expose further + history for the EOD quote in the near future. + + Args: + start_date (datetime.date): + end_date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryEodRight): Default: OptionHistoryEodRight.BOTH. + format_ (Unset | OptionHistoryEodFormat): Default: OptionHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + start_date=start_date, +end_date=end_date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + start_date: datetime.date, + end_date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryEodRight = OptionHistoryEodRight.BOTH, + format_: Unset | OptionHistoryEodFormat = OptionHistoryEodFormat.JSON, + +) -> list[OptionHistoryEodResponse200Item] | None: + """ End of Day + + - Since [OPRA](/Articles/Data-And-Requests/The-SIPs.html) does not provide a national EOD report for + options, Thetadata generates a national EOD report at 17:15 ET each day. + - ``created`` represents the datetime the report was generated and ``last_trade`` represents the + datetime of the last trade. + - The quote in the response represents the last NBBO reported by OPRA at the time of report + generation. + - You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We will expose further + history for the EOD quote in the near future. + + Args: + start_date (datetime.date): + end_date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryEodRight): Default: OptionHistoryEodRight.BOTH. + format_ (Unset | OptionHistoryEodFormat): Default: OptionHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryEodResponse200Item] + """ + + + return sync_detailed( + client=client, +start_date=start_date, +end_date=end_date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + start_date: datetime.date, + end_date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryEodRight = OptionHistoryEodRight.BOTH, + format_: Unset | OptionHistoryEodFormat = OptionHistoryEodFormat.JSON, + +) -> Response[list[OptionHistoryEodResponse200Item]]: + """ End of Day + + - Since [OPRA](/Articles/Data-And-Requests/The-SIPs.html) does not provide a national EOD report for + options, Thetadata generates a national EOD report at 17:15 ET each day. + - ``created`` represents the datetime the report was generated and ``last_trade`` represents the + datetime of the last trade. + - The quote in the response represents the last NBBO reported by OPRA at the time of report + generation. + - You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We will expose further + history for the EOD quote in the near future. + + Args: + start_date (datetime.date): + end_date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryEodRight): Default: OptionHistoryEodRight.BOTH. + format_ (Unset | OptionHistoryEodFormat): Default: OptionHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + start_date=start_date, +end_date=end_date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + start_date: datetime.date, + end_date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryEodRight = OptionHistoryEodRight.BOTH, + format_: Unset | OptionHistoryEodFormat = OptionHistoryEodFormat.JSON, + +) -> list[OptionHistoryEodResponse200Item] | None: + """ End of Day + + - Since [OPRA](/Articles/Data-And-Requests/The-SIPs.html) does not provide a national EOD report for + options, Thetadata generates a national EOD report at 17:15 ET each day. + - ``created`` represents the datetime the report was generated and ``last_trade`` represents the + datetime of the last trade. + - The quote in the response represents the last NBBO reported by OPRA at the time of report + generation. + - You can read more about EOD & OHLC data [here](/Articles/Data-And-Requests/OHLC-EOD.html). + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We will expose further + history for the EOD quote in the near future. + + Args: + start_date (datetime.date): + end_date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryEodRight): Default: OptionHistoryEodRight.BOTH. + format_ (Unset | OptionHistoryEodFormat): Default: OptionHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryEodResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +start_date=start_date, +end_date=end_date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_greeks_all.py b/openapi_project/openapi_package/api/option/option_history_greeks_all.py new file mode 100644 index 000000000..e68557cd5 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_greeks_all.py @@ -0,0 +1,406 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_greeks_all_format import OptionHistoryGreeksAllFormat +from openapi_project.openapi_package.models.option_history_greeks_all_interval import OptionHistoryGreeksAllInterval +from openapi_project.openapi_package.models.option_history_greeks_all_rate_type import OptionHistoryGreeksAllRateType +from openapi_project.openapi_package.models.option_history_greeks_all_response_200_item import OptionHistoryGreeksAllResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_all_right import OptionHistoryGreeksAllRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksAllRight = OptionHistoryGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksAllInterval = OptionHistoryGreeksAllInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksAllRateType = OptionHistoryGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksAllFormat = OptionHistoryGreeksAllFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/greeks/all", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryGreeksAllResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryGreeksAllResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryGreeksAllResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksAllRight = OptionHistoryGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksAllInterval = OptionHistoryGreeksAllInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksAllRateType = OptionHistoryGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksAllFormat = OptionHistoryGreeksAllFormat.JSON, + +) -> Response[list[OptionHistoryGreeksAllResponse200Item]]: + """ All Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksAllRight): Default: OptionHistoryGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksAllInterval): Default: + OptionHistoryGreeksAllInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksAllRateType): Default: + OptionHistoryGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksAllFormat): Default: + OptionHistoryGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksAllResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksAllRight = OptionHistoryGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksAllInterval = OptionHistoryGreeksAllInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksAllRateType = OptionHistoryGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksAllFormat = OptionHistoryGreeksAllFormat.JSON, + +) -> list[OptionHistoryGreeksAllResponse200Item] | None: + """ All Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksAllRight): Default: OptionHistoryGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksAllInterval): Default: + OptionHistoryGreeksAllInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksAllRateType): Default: + OptionHistoryGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksAllFormat): Default: + OptionHistoryGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksAllResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksAllRight = OptionHistoryGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksAllInterval = OptionHistoryGreeksAllInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksAllRateType = OptionHistoryGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksAllFormat = OptionHistoryGreeksAllFormat.JSON, + +) -> Response[list[OptionHistoryGreeksAllResponse200Item]]: + """ All Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksAllRight): Default: OptionHistoryGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksAllInterval): Default: + OptionHistoryGreeksAllInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksAllRateType): Default: + OptionHistoryGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksAllFormat): Default: + OptionHistoryGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksAllResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksAllRight = OptionHistoryGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksAllInterval = OptionHistoryGreeksAllInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksAllRateType = OptionHistoryGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksAllFormat = OptionHistoryGreeksAllFormat.JSON, + +) -> list[OptionHistoryGreeksAllResponse200Item] | None: + """ All Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksAllRight): Default: OptionHistoryGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksAllInterval): Default: + OptionHistoryGreeksAllInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksAllRateType): Default: + OptionHistoryGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksAllFormat): Default: + OptionHistoryGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksAllResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_greeks_eod.py b/openapi_project/openapi_package/api/option/option_history_greeks_eod.py new file mode 100644 index 000000000..93ffce68e --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_greeks_eod.py @@ -0,0 +1,375 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_greeks_eod_format import OptionHistoryGreeksEodFormat +from openapi_project.openapi_package.models.option_history_greeks_eod_rate_type import OptionHistoryGreeksEodRateType +from openapi_project.openapi_package.models.option_history_greeks_eod_response_200_item import OptionHistoryGreeksEodResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_eod_right import OptionHistoryGreeksEodRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksEodRight = OptionHistoryGreeksEodRight.BOTH, + start_date: datetime.date, + end_date: datetime.date, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksEodRateType = OptionHistoryGreeksEodRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksEodFormat = OptionHistoryGreeksEodFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/greeks/eod", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryGreeksEodResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryGreeksEodResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryGreeksEodResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksEodRight = OptionHistoryGreeksEodRight.BOTH, + start_date: datetime.date, + end_date: datetime.date, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksEodRateType = OptionHistoryGreeksEodRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksEodFormat = OptionHistoryGreeksEodFormat.JSON, + +) -> Response[list[OptionHistoryGreeksEodResponse200Item]]: + """ End of Day Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Uses Theta Data's EOD reports that get generated at 17:15 ET each day. The closing option price + and closing underlying price are used for the greeks calculation. + - **Set `expiration` to ``*`` if you want to retrieve data for every option that shares the same + ``symbol``. (note: Any ``expiration=*`` must be requested day by day)** + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We are working to + expose this over the coming months. Obtaining the quote at the end of the day requires much more + processing than the trades, so we initially generated our history for trades. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksEodRight): Default: OptionHistoryGreeksEodRight.BOTH. + start_date (datetime.date): + end_date (datetime.date): + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksEodRateType): Default: + OptionHistoryGreeksEodRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksEodFormat): Default: + OptionHistoryGreeksEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_date=start_date, +end_date=end_date, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksEodRight = OptionHistoryGreeksEodRight.BOTH, + start_date: datetime.date, + end_date: datetime.date, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksEodRateType = OptionHistoryGreeksEodRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksEodFormat = OptionHistoryGreeksEodFormat.JSON, + +) -> list[OptionHistoryGreeksEodResponse200Item] | None: + """ End of Day Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Uses Theta Data's EOD reports that get generated at 17:15 ET each day. The closing option price + and closing underlying price are used for the greeks calculation. + - **Set `expiration` to ``*`` if you want to retrieve data for every option that shares the same + ``symbol``. (note: Any ``expiration=*`` must be requested day by day)** + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We are working to + expose this over the coming months. Obtaining the quote at the end of the day requires much more + processing than the trades, so we initially generated our history for trades. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksEodRight): Default: OptionHistoryGreeksEodRight.BOTH. + start_date (datetime.date): + end_date (datetime.date): + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksEodRateType): Default: + OptionHistoryGreeksEodRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksEodFormat): Default: + OptionHistoryGreeksEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksEodResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_date=start_date, +end_date=end_date, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksEodRight = OptionHistoryGreeksEodRight.BOTH, + start_date: datetime.date, + end_date: datetime.date, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksEodRateType = OptionHistoryGreeksEodRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksEodFormat = OptionHistoryGreeksEodFormat.JSON, + +) -> Response[list[OptionHistoryGreeksEodResponse200Item]]: + """ End of Day Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Uses Theta Data's EOD reports that get generated at 17:15 ET each day. The closing option price + and closing underlying price are used for the greeks calculation. + - **Set `expiration` to ``*`` if you want to retrieve data for every option that shares the same + ``symbol``. (note: Any ``expiration=*`` must be requested day by day)** + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We are working to + expose this over the coming months. Obtaining the quote at the end of the day requires much more + processing than the trades, so we initially generated our history for trades. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksEodRight): Default: OptionHistoryGreeksEodRight.BOTH. + start_date (datetime.date): + end_date (datetime.date): + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksEodRateType): Default: + OptionHistoryGreeksEodRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksEodFormat): Default: + OptionHistoryGreeksEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_date=start_date, +end_date=end_date, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksEodRight = OptionHistoryGreeksEodRight.BOTH, + start_date: datetime.date, + end_date: datetime.date, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksEodRateType = OptionHistoryGreeksEodRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksEodFormat = OptionHistoryGreeksEodFormat.JSON, + +) -> list[OptionHistoryGreeksEodResponse200Item] | None: + """ End of Day Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Uses Theta Data's EOD reports that get generated at 17:15 ET each day. The closing option price + and closing underlying price are used for the greeks calculation. + - **Set `expiration` to ``*`` if you want to retrieve data for every option that shares the same + ``symbol``. (note: Any ``expiration=*`` must be requested day by day)** + > The quote fields (bid / ask info) may not be available prior to 2023-12-01. We are working to + expose this over the coming months. Obtaining the quote at the end of the day requires much more + processing than the trades, so we initially generated our history for trades. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksEodRight): Default: OptionHistoryGreeksEodRight.BOTH. + start_date (datetime.date): + end_date (datetime.date): + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksEodRateType): Default: + OptionHistoryGreeksEodRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksEodFormat): Default: + OptionHistoryGreeksEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksEodResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_date=start_date, +end_date=end_date, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_greeks_first_order.py b/openapi_project/openapi_package/api/option/option_history_greeks_first_order.py new file mode 100644 index 000000000..ec5ba2bf7 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_greeks_first_order.py @@ -0,0 +1,410 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_greeks_first_order_format import OptionHistoryGreeksFirstOrderFormat +from openapi_project.openapi_package.models.option_history_greeks_first_order_interval import OptionHistoryGreeksFirstOrderInterval +from openapi_project.openapi_package.models.option_history_greeks_first_order_rate_type import OptionHistoryGreeksFirstOrderRateType +from openapi_project.openapi_package.models.option_history_greeks_first_order_response_200_item import OptionHistoryGreeksFirstOrderResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_first_order_right import OptionHistoryGreeksFirstOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksFirstOrderRight = OptionHistoryGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksFirstOrderInterval = OptionHistoryGreeksFirstOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksFirstOrderRateType = OptionHistoryGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksFirstOrderFormat = OptionHistoryGreeksFirstOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/greeks/first_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryGreeksFirstOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryGreeksFirstOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryGreeksFirstOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksFirstOrderRight = OptionHistoryGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksFirstOrderInterval = OptionHistoryGreeksFirstOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksFirstOrderRateType = OptionHistoryGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksFirstOrderFormat = OptionHistoryGreeksFirstOrderFormat.JSON, + +) -> Response[list[OptionHistoryGreeksFirstOrderResponse200Item]]: + """ First Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksFirstOrderRight): Default: + OptionHistoryGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksFirstOrderInterval): Default: + OptionHistoryGreeksFirstOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksFirstOrderRateType): Default: + OptionHistoryGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksFirstOrderFormat): Default: + OptionHistoryGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksFirstOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksFirstOrderRight = OptionHistoryGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksFirstOrderInterval = OptionHistoryGreeksFirstOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksFirstOrderRateType = OptionHistoryGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksFirstOrderFormat = OptionHistoryGreeksFirstOrderFormat.JSON, + +) -> list[OptionHistoryGreeksFirstOrderResponse200Item] | None: + """ First Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksFirstOrderRight): Default: + OptionHistoryGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksFirstOrderInterval): Default: + OptionHistoryGreeksFirstOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksFirstOrderRateType): Default: + OptionHistoryGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksFirstOrderFormat): Default: + OptionHistoryGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksFirstOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksFirstOrderRight = OptionHistoryGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksFirstOrderInterval = OptionHistoryGreeksFirstOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksFirstOrderRateType = OptionHistoryGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksFirstOrderFormat = OptionHistoryGreeksFirstOrderFormat.JSON, + +) -> Response[list[OptionHistoryGreeksFirstOrderResponse200Item]]: + """ First Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksFirstOrderRight): Default: + OptionHistoryGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksFirstOrderInterval): Default: + OptionHistoryGreeksFirstOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksFirstOrderRateType): Default: + OptionHistoryGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksFirstOrderFormat): Default: + OptionHistoryGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksFirstOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksFirstOrderRight = OptionHistoryGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksFirstOrderInterval = OptionHistoryGreeksFirstOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksFirstOrderRateType = OptionHistoryGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksFirstOrderFormat = OptionHistoryGreeksFirstOrderFormat.JSON, + +) -> list[OptionHistoryGreeksFirstOrderResponse200Item] | None: + """ First Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksFirstOrderRight): Default: + OptionHistoryGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksFirstOrderInterval): Default: + OptionHistoryGreeksFirstOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksFirstOrderRateType): Default: + OptionHistoryGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksFirstOrderFormat): Default: + OptionHistoryGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksFirstOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_greeks_implied_volatility.py b/openapi_project/openapi_package/api/option/option_history_greeks_implied_volatility.py new file mode 100644 index 000000000..b2ca83eae --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_greeks_implied_volatility.py @@ -0,0 +1,402 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_format import OptionHistoryGreeksImpliedVolatilityFormat +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_interval import OptionHistoryGreeksImpliedVolatilityInterval +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_rate_type import OptionHistoryGreeksImpliedVolatilityRateType +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_response_200_item import OptionHistoryGreeksImpliedVolatilityResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_right import OptionHistoryGreeksImpliedVolatilityRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksImpliedVolatilityRight = OptionHistoryGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksImpliedVolatilityInterval = OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksImpliedVolatilityRateType = OptionHistoryGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksImpliedVolatilityFormat = OptionHistoryGreeksImpliedVolatilityFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/greeks/implied_volatility", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryGreeksImpliedVolatilityResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryGreeksImpliedVolatilityResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryGreeksImpliedVolatilityResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksImpliedVolatilityRight = OptionHistoryGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksImpliedVolatilityInterval = OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksImpliedVolatilityRateType = OptionHistoryGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksImpliedVolatilityFormat = OptionHistoryGreeksImpliedVolatilityFormat.JSON, + +) -> Response[list[OptionHistoryGreeksImpliedVolatilityResponse200Item]]: + """ Implied Volatility + + - Returns implied volatilies calculated using the national best bid, mid, and ask price of the + option respectively. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksImpliedVolatilityRight): Default: + OptionHistoryGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksImpliedVolatilityInterval): Default: + OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksImpliedVolatilityRateType): Default: + OptionHistoryGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksImpliedVolatilityFormat): Default: + OptionHistoryGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksImpliedVolatilityResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksImpliedVolatilityRight = OptionHistoryGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksImpliedVolatilityInterval = OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksImpliedVolatilityRateType = OptionHistoryGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksImpliedVolatilityFormat = OptionHistoryGreeksImpliedVolatilityFormat.JSON, + +) -> list[OptionHistoryGreeksImpliedVolatilityResponse200Item] | None: + """ Implied Volatility + + - Returns implied volatilies calculated using the national best bid, mid, and ask price of the + option respectively. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksImpliedVolatilityRight): Default: + OptionHistoryGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksImpliedVolatilityInterval): Default: + OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksImpliedVolatilityRateType): Default: + OptionHistoryGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksImpliedVolatilityFormat): Default: + OptionHistoryGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksImpliedVolatilityResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksImpliedVolatilityRight = OptionHistoryGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksImpliedVolatilityInterval = OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksImpliedVolatilityRateType = OptionHistoryGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksImpliedVolatilityFormat = OptionHistoryGreeksImpliedVolatilityFormat.JSON, + +) -> Response[list[OptionHistoryGreeksImpliedVolatilityResponse200Item]]: + """ Implied Volatility + + - Returns implied volatilies calculated using the national best bid, mid, and ask price of the + option respectively. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksImpliedVolatilityRight): Default: + OptionHistoryGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksImpliedVolatilityInterval): Default: + OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksImpliedVolatilityRateType): Default: + OptionHistoryGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksImpliedVolatilityFormat): Default: + OptionHistoryGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksImpliedVolatilityResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksImpliedVolatilityRight = OptionHistoryGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksImpliedVolatilityInterval = OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksImpliedVolatilityRateType = OptionHistoryGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksImpliedVolatilityFormat = OptionHistoryGreeksImpliedVolatilityFormat.JSON, + +) -> list[OptionHistoryGreeksImpliedVolatilityResponse200Item] | None: + """ Implied Volatility + + - Returns implied volatilies calculated using the national best bid, mid, and ask price of the + option respectively. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksImpliedVolatilityRight): Default: + OptionHistoryGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksImpliedVolatilityInterval): Default: + OptionHistoryGreeksImpliedVolatilityInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksImpliedVolatilityRateType): Default: + OptionHistoryGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksImpliedVolatilityFormat): Default: + OptionHistoryGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksImpliedVolatilityResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_greeks_second_order.py b/openapi_project/openapi_package/api/option/option_history_greeks_second_order.py new file mode 100644 index 000000000..57af3654e --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_greeks_second_order.py @@ -0,0 +1,410 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_greeks_second_order_format import OptionHistoryGreeksSecondOrderFormat +from openapi_project.openapi_package.models.option_history_greeks_second_order_interval import OptionHistoryGreeksSecondOrderInterval +from openapi_project.openapi_package.models.option_history_greeks_second_order_rate_type import OptionHistoryGreeksSecondOrderRateType +from openapi_project.openapi_package.models.option_history_greeks_second_order_response_200_item import OptionHistoryGreeksSecondOrderResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_second_order_right import OptionHistoryGreeksSecondOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksSecondOrderRight = OptionHistoryGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksSecondOrderInterval = OptionHistoryGreeksSecondOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksSecondOrderRateType = OptionHistoryGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksSecondOrderFormat = OptionHistoryGreeksSecondOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/greeks/second_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryGreeksSecondOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryGreeksSecondOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryGreeksSecondOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksSecondOrderRight = OptionHistoryGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksSecondOrderInterval = OptionHistoryGreeksSecondOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksSecondOrderRateType = OptionHistoryGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksSecondOrderFormat = OptionHistoryGreeksSecondOrderFormat.JSON, + +) -> Response[list[OptionHistoryGreeksSecondOrderResponse200Item]]: + """ Second Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksSecondOrderRight): Default: + OptionHistoryGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksSecondOrderInterval): Default: + OptionHistoryGreeksSecondOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksSecondOrderRateType): Default: + OptionHistoryGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksSecondOrderFormat): Default: + OptionHistoryGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksSecondOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksSecondOrderRight = OptionHistoryGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksSecondOrderInterval = OptionHistoryGreeksSecondOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksSecondOrderRateType = OptionHistoryGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksSecondOrderFormat = OptionHistoryGreeksSecondOrderFormat.JSON, + +) -> list[OptionHistoryGreeksSecondOrderResponse200Item] | None: + """ Second Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksSecondOrderRight): Default: + OptionHistoryGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksSecondOrderInterval): Default: + OptionHistoryGreeksSecondOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksSecondOrderRateType): Default: + OptionHistoryGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksSecondOrderFormat): Default: + OptionHistoryGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksSecondOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksSecondOrderRight = OptionHistoryGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksSecondOrderInterval = OptionHistoryGreeksSecondOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksSecondOrderRateType = OptionHistoryGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksSecondOrderFormat = OptionHistoryGreeksSecondOrderFormat.JSON, + +) -> Response[list[OptionHistoryGreeksSecondOrderResponse200Item]]: + """ Second Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksSecondOrderRight): Default: + OptionHistoryGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksSecondOrderInterval): Default: + OptionHistoryGreeksSecondOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksSecondOrderRateType): Default: + OptionHistoryGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksSecondOrderFormat): Default: + OptionHistoryGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksSecondOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksSecondOrderRight = OptionHistoryGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksSecondOrderInterval = OptionHistoryGreeksSecondOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksSecondOrderRateType = OptionHistoryGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksSecondOrderFormat = OptionHistoryGreeksSecondOrderFormat.JSON, + +) -> list[OptionHistoryGreeksSecondOrderResponse200Item] | None: + """ Second Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksSecondOrderRight): Default: + OptionHistoryGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksSecondOrderInterval): Default: + OptionHistoryGreeksSecondOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksSecondOrderRateType): Default: + OptionHistoryGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksSecondOrderFormat): Default: + OptionHistoryGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksSecondOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_greeks_third_order.py b/openapi_project/openapi_package/api/option/option_history_greeks_third_order.py new file mode 100644 index 000000000..9dd135968 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_greeks_third_order.py @@ -0,0 +1,410 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_greeks_third_order_format import OptionHistoryGreeksThirdOrderFormat +from openapi_project.openapi_package.models.option_history_greeks_third_order_interval import OptionHistoryGreeksThirdOrderInterval +from openapi_project.openapi_package.models.option_history_greeks_third_order_rate_type import OptionHistoryGreeksThirdOrderRateType +from openapi_project.openapi_package.models.option_history_greeks_third_order_response_200_item import OptionHistoryGreeksThirdOrderResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_third_order_right import OptionHistoryGreeksThirdOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksThirdOrderRight = OptionHistoryGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksThirdOrderInterval = OptionHistoryGreeksThirdOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksThirdOrderRateType = OptionHistoryGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksThirdOrderFormat = OptionHistoryGreeksThirdOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/greeks/third_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryGreeksThirdOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryGreeksThirdOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryGreeksThirdOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksThirdOrderRight = OptionHistoryGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksThirdOrderInterval = OptionHistoryGreeksThirdOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksThirdOrderRateType = OptionHistoryGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksThirdOrderFormat = OptionHistoryGreeksThirdOrderFormat.JSON, + +) -> Response[list[OptionHistoryGreeksThirdOrderResponse200Item]]: + """ Third Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksThirdOrderRight): Default: + OptionHistoryGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksThirdOrderInterval): Default: + OptionHistoryGreeksThirdOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksThirdOrderRateType): Default: + OptionHistoryGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksThirdOrderFormat): Default: + OptionHistoryGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksThirdOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksThirdOrderRight = OptionHistoryGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksThirdOrderInterval = OptionHistoryGreeksThirdOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksThirdOrderRateType = OptionHistoryGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksThirdOrderFormat = OptionHistoryGreeksThirdOrderFormat.JSON, + +) -> list[OptionHistoryGreeksThirdOrderResponse200Item] | None: + """ Third Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksThirdOrderRight): Default: + OptionHistoryGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksThirdOrderInterval): Default: + OptionHistoryGreeksThirdOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksThirdOrderRateType): Default: + OptionHistoryGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksThirdOrderFormat): Default: + OptionHistoryGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksThirdOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksThirdOrderRight = OptionHistoryGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksThirdOrderInterval = OptionHistoryGreeksThirdOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksThirdOrderRateType = OptionHistoryGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksThirdOrderFormat = OptionHistoryGreeksThirdOrderFormat.JSON, + +) -> Response[list[OptionHistoryGreeksThirdOrderResponse200Item]]: + """ Third Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksThirdOrderRight): Default: + OptionHistoryGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksThirdOrderInterval): Default: + OptionHistoryGreeksThirdOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksThirdOrderRateType): Default: + OptionHistoryGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksThirdOrderFormat): Default: + OptionHistoryGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryGreeksThirdOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryGreeksThirdOrderRight = OptionHistoryGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryGreeksThirdOrderInterval = OptionHistoryGreeksThirdOrderInterval.VALUE_4, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryGreeksThirdOrderRateType = OptionHistoryGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryGreeksThirdOrderFormat = OptionHistoryGreeksThirdOrderFormat.JSON, + +) -> list[OptionHistoryGreeksThirdOrderResponse200Item] | None: + """ Third Order Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculated using the option and underlying midpoint price. If an interval size is specified + (*highly recommended*), the option quote used in the calculation follows the same rules as the + [quote](/operations/option_history_quote.html) endpoint. + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryGreeksThirdOrderRight): Default: + OptionHistoryGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryGreeksThirdOrderInterval): Default: + OptionHistoryGreeksThirdOrderInterval.VALUE_4. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryGreeksThirdOrderRateType): Default: + OptionHistoryGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryGreeksThirdOrderFormat): Default: + OptionHistoryGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryGreeksThirdOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_ohlc.py b/openapi_project/openapi_package/api/option/option_history_ohlc.py new file mode 100644 index 000000000..5bbf6dc5a --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_ohlc.py @@ -0,0 +1,330 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_ohlc_format import OptionHistoryOhlcFormat +from openapi_project.openapi_package.models.option_history_ohlc_interval import OptionHistoryOhlcInterval +from openapi_project.openapi_package.models.option_history_ohlc_response_200_item import OptionHistoryOhlcResponse200Item +from openapi_project.openapi_package.models.option_history_ohlc_right import OptionHistoryOhlcRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOhlcRight = OptionHistoryOhlcRight.BOTH, + interval: OptionHistoryOhlcInterval = OptionHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryOhlcFormat = OptionHistoryOhlcFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_interval = interval.value + params["interval"] = json_interval + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/ohlc", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryOhlcResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryOhlcResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryOhlcResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOhlcRight = OptionHistoryOhlcRight.BOTH, + interval: OptionHistoryOhlcInterval = OptionHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryOhlcFormat = OptionHistoryOhlcFormat.JSON, + +) -> Response[list[OptionHistoryOhlcResponse200Item]]: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOhlcRight): Default: OptionHistoryOhlcRight.BOTH. + interval (OptionHistoryOhlcInterval): Default: OptionHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryOhlcFormat): Default: OptionHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOhlcRight = OptionHistoryOhlcRight.BOTH, + interval: OptionHistoryOhlcInterval = OptionHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryOhlcFormat = OptionHistoryOhlcFormat.JSON, + +) -> list[OptionHistoryOhlcResponse200Item] | None: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOhlcRight): Default: OptionHistoryOhlcRight.BOTH. + interval (OptionHistoryOhlcInterval): Default: OptionHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryOhlcFormat): Default: OptionHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryOhlcResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOhlcRight = OptionHistoryOhlcRight.BOTH, + interval: OptionHistoryOhlcInterval = OptionHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryOhlcFormat = OptionHistoryOhlcFormat.JSON, + +) -> Response[list[OptionHistoryOhlcResponse200Item]]: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOhlcRight): Default: OptionHistoryOhlcRight.BOTH. + interval (OptionHistoryOhlcInterval): Default: OptionHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryOhlcFormat): Default: OptionHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOhlcRight = OptionHistoryOhlcRight.BOTH, + interval: OptionHistoryOhlcInterval = OptionHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryOhlcFormat = OptionHistoryOhlcFormat.JSON, + +) -> list[OptionHistoryOhlcResponse200Item] | None: + """ Open High Low Close + + - Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + - Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the + bar: ``bar timestamp`` <= ``trade time`` < ``bar timestamp + interval``. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOhlcRight): Default: OptionHistoryOhlcRight.BOTH. + interval (OptionHistoryOhlcInterval): Default: OptionHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryOhlcFormat): Default: OptionHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryOhlcResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +interval=interval, +start_time=start_time, +end_time=end_time, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_open_interest.py b/openapi_project/openapi_package/api/option/option_history_open_interest.py new file mode 100644 index 000000000..5395f9c3a --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_open_interest.py @@ -0,0 +1,299 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_open_interest_format import OptionHistoryOpenInterestFormat +from openapi_project.openapi_package.models.option_history_open_interest_response_200_item import OptionHistoryOpenInterestResponse200Item +from openapi_project.openapi_package.models.option_history_open_interest_right import OptionHistoryOpenInterestRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOpenInterestRight = OptionHistoryOpenInterestRight.BOTH, + format_: Unset | OptionHistoryOpenInterestFormat = OptionHistoryOpenInterestFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/open_interest", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryOpenInterestResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryOpenInterestResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryOpenInterestResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOpenInterestRight = OptionHistoryOpenInterestRight.BOTH, + format_: Unset | OptionHistoryOpenInterestFormat = OptionHistoryOpenInterestFormat.JSON, + +) -> Response[list[OptionHistoryOpenInterestResponse200Item]]: + """ Open Interest + + - Open Interest is normally reported once per day by [OPRA](/Articles/Data-And-Requests/The- + SIPs.html) at approximately 06:30 ET. + - A new open interest message might not be sent by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + if there is no open interest for the option contract. + - The reported open interest represents the open interest at the end of the previous trading day. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOpenInterestRight): Default: + OptionHistoryOpenInterestRight.BOTH. + format_ (Unset | OptionHistoryOpenInterestFormat): Default: + OptionHistoryOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryOpenInterestResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOpenInterestRight = OptionHistoryOpenInterestRight.BOTH, + format_: Unset | OptionHistoryOpenInterestFormat = OptionHistoryOpenInterestFormat.JSON, + +) -> list[OptionHistoryOpenInterestResponse200Item] | None: + """ Open Interest + + - Open Interest is normally reported once per day by [OPRA](/Articles/Data-And-Requests/The- + SIPs.html) at approximately 06:30 ET. + - A new open interest message might not be sent by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + if there is no open interest for the option contract. + - The reported open interest represents the open interest at the end of the previous trading day. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOpenInterestRight): Default: + OptionHistoryOpenInterestRight.BOTH. + format_ (Unset | OptionHistoryOpenInterestFormat): Default: + OptionHistoryOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryOpenInterestResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOpenInterestRight = OptionHistoryOpenInterestRight.BOTH, + format_: Unset | OptionHistoryOpenInterestFormat = OptionHistoryOpenInterestFormat.JSON, + +) -> Response[list[OptionHistoryOpenInterestResponse200Item]]: + """ Open Interest + + - Open Interest is normally reported once per day by [OPRA](/Articles/Data-And-Requests/The- + SIPs.html) at approximately 06:30 ET. + - A new open interest message might not be sent by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + if there is no open interest for the option contract. + - The reported open interest represents the open interest at the end of the previous trading day. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOpenInterestRight): Default: + OptionHistoryOpenInterestRight.BOTH. + format_ (Unset | OptionHistoryOpenInterestFormat): Default: + OptionHistoryOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryOpenInterestResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryOpenInterestRight = OptionHistoryOpenInterestRight.BOTH, + format_: Unset | OptionHistoryOpenInterestFormat = OptionHistoryOpenInterestFormat.JSON, + +) -> list[OptionHistoryOpenInterestResponse200Item] | None: + """ Open Interest + + - Open Interest is normally reported once per day by [OPRA](/Articles/Data-And-Requests/The- + SIPs.html) at approximately 06:30 ET. + - A new open interest message might not be sent by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + if there is no open interest for the option contract. + - The reported open interest represents the open interest at the end of the previous trading day. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryOpenInterestRight): Default: + OptionHistoryOpenInterestRight.BOTH. + format_ (Unset | OptionHistoryOpenInterestFormat): Default: + OptionHistoryOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryOpenInterestResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_quote.py b/openapi_project/openapi_package/api/option/option_history_quote.py new file mode 100644 index 000000000..42ac4cf89 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_quote.py @@ -0,0 +1,330 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_quote_format import OptionHistoryQuoteFormat +from openapi_project.openapi_package.models.option_history_quote_interval import OptionHistoryQuoteInterval +from openapi_project.openapi_package.models.option_history_quote_response_200_item import OptionHistoryQuoteResponse200Item +from openapi_project.openapi_package.models.option_history_quote_right import OptionHistoryQuoteRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryQuoteRight = OptionHistoryQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryQuoteInterval = OptionHistoryQuoteInterval.VALUE_4, + format_: Unset | OptionHistoryQuoteFormat = OptionHistoryQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_interval = interval.value + params["interval"] = json_interval + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryQuoteRight = OptionHistoryQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryQuoteInterval = OptionHistoryQuoteInterval.VALUE_4, + format_: Unset | OptionHistoryQuoteFormat = OptionHistoryQuoteFormat.JSON, + +) -> Response[list[OptionHistoryQuoteResponse200Item]]: + """ Quote + + - Returns every NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - If the ``interval`` parameter is specified, the quote for each interval represents the last quote + at the interval's timestamp. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryQuoteRight): Default: OptionHistoryQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryQuoteInterval): Default: OptionHistoryQuoteInterval.VALUE_4. + format_ (Unset | OptionHistoryQuoteFormat): Default: OptionHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryQuoteRight = OptionHistoryQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryQuoteInterval = OptionHistoryQuoteInterval.VALUE_4, + format_: Unset | OptionHistoryQuoteFormat = OptionHistoryQuoteFormat.JSON, + +) -> list[OptionHistoryQuoteResponse200Item] | None: + """ Quote + + - Returns every NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - If the ``interval`` parameter is specified, the quote for each interval represents the last quote + at the interval's timestamp. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryQuoteRight): Default: OptionHistoryQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryQuoteInterval): Default: OptionHistoryQuoteInterval.VALUE_4. + format_ (Unset | OptionHistoryQuoteFormat): Default: OptionHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryQuoteRight = OptionHistoryQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryQuoteInterval = OptionHistoryQuoteInterval.VALUE_4, + format_: Unset | OptionHistoryQuoteFormat = OptionHistoryQuoteFormat.JSON, + +) -> Response[list[OptionHistoryQuoteResponse200Item]]: + """ Quote + + - Returns every NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - If the ``interval`` parameter is specified, the quote for each interval represents the last quote + at the interval's timestamp. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryQuoteRight): Default: OptionHistoryQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryQuoteInterval): Default: OptionHistoryQuoteInterval.VALUE_4. + format_ (Unset | OptionHistoryQuoteFormat): Default: OptionHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryQuoteRight = OptionHistoryQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + interval: OptionHistoryQuoteInterval = OptionHistoryQuoteInterval.VALUE_4, + format_: Unset | OptionHistoryQuoteFormat = OptionHistoryQuoteFormat.JSON, + +) -> list[OptionHistoryQuoteResponse200Item] | None: + """ Quote + + - Returns every NBBO quote reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - If the ``interval`` parameter is specified, the quote for each interval represents the last quote + at the interval's timestamp. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryQuoteRight): Default: OptionHistoryQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + interval (OptionHistoryQuoteInterval): Default: OptionHistoryQuoteInterval.VALUE_4. + format_ (Unset | OptionHistoryQuoteFormat): Default: OptionHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +interval=interval, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade.py b/openapi_project/openapi_package/api/option/option_history_trade.py new file mode 100644 index 000000000..1c8a7c5e1 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade.py @@ -0,0 +1,321 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_format import OptionHistoryTradeFormat +from openapi_project.openapi_package.models.option_history_trade_response_200_item import OptionHistoryTradeResponse200Item +from openapi_project.openapi_package.models.option_history_trade_right import OptionHistoryTradeRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeRight = OptionHistoryTradeRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryTradeFormat = OptionHistoryTradeFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeRight = OptionHistoryTradeRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryTradeFormat = OptionHistoryTradeFormat.JSON, + +) -> Response[list[OptionHistoryTradeResponse200Item]]: + """ Trade + + - Returns every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeRight): Default: OptionHistoryTradeRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryTradeFormat): Default: OptionHistoryTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeRight = OptionHistoryTradeRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryTradeFormat = OptionHistoryTradeFormat.JSON, + +) -> list[OptionHistoryTradeResponse200Item] | None: + """ Trade + + - Returns every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeRight): Default: OptionHistoryTradeRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryTradeFormat): Default: OptionHistoryTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeRight = OptionHistoryTradeRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryTradeFormat = OptionHistoryTradeFormat.JSON, + +) -> Response[list[OptionHistoryTradeResponse200Item]]: + """ Trade + + - Returns every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeRight): Default: OptionHistoryTradeRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryTradeFormat): Default: OptionHistoryTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeRight = OptionHistoryTradeRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + format_: Unset | OptionHistoryTradeFormat = OptionHistoryTradeFormat.JSON, + +) -> list[OptionHistoryTradeResponse200Item] | None: + """ Trade + + - Returns every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + - Extended trade conditions are not reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html) + for options, so they can be ignored. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeRight): Default: OptionHistoryTradeRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + format_ (Unset | OptionHistoryTradeFormat): Default: OptionHistoryTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade_greeks_all.py b/openapi_project/openapi_package/api/option/option_history_trade_greeks_all.py new file mode 100644 index 000000000..81711f956 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade_greeks_all.py @@ -0,0 +1,381 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_greeks_all_format import OptionHistoryTradeGreeksAllFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_all_rate_type import OptionHistoryTradeGreeksAllRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_all_response_200_item import OptionHistoryTradeGreeksAllResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_all_right import OptionHistoryTradeGreeksAllRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksAllRight = OptionHistoryTradeGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksAllRateType = OptionHistoryTradeGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksAllFormat = OptionHistoryTradeGreeksAllFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade_greeks/all", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeGreeksAllResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeGreeksAllResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeGreeksAllResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksAllRight = OptionHistoryTradeGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksAllRateType = OptionHistoryTradeGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksAllFormat = OptionHistoryTradeGreeksAllFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksAllResponse200Item]]: + """ All Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksAllRight): Default: + OptionHistoryTradeGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksAllRateType): Default: + OptionHistoryTradeGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksAllFormat): Default: + OptionHistoryTradeGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksAllResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksAllRight = OptionHistoryTradeGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksAllRateType = OptionHistoryTradeGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksAllFormat = OptionHistoryTradeGreeksAllFormat.JSON, + +) -> list[OptionHistoryTradeGreeksAllResponse200Item] | None: + """ All Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksAllRight): Default: + OptionHistoryTradeGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksAllRateType): Default: + OptionHistoryTradeGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksAllFormat): Default: + OptionHistoryTradeGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksAllResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksAllRight = OptionHistoryTradeGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksAllRateType = OptionHistoryTradeGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksAllFormat = OptionHistoryTradeGreeksAllFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksAllResponse200Item]]: + """ All Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksAllRight): Default: + OptionHistoryTradeGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksAllRateType): Default: + OptionHistoryTradeGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksAllFormat): Default: + OptionHistoryTradeGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksAllResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksAllRight = OptionHistoryTradeGreeksAllRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksAllRateType = OptionHistoryTradeGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksAllFormat = OptionHistoryTradeGreeksAllFormat.JSON, + +) -> list[OptionHistoryTradeGreeksAllResponse200Item] | None: + """ All Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksAllRight): Default: + OptionHistoryTradeGreeksAllRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksAllRateType): Default: + OptionHistoryTradeGreeksAllRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksAllFormat): Default: + OptionHistoryTradeGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksAllResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade_greeks_first_order.py b/openapi_project/openapi_package/api/option/option_history_trade_greeks_first_order.py new file mode 100644 index 000000000..7446681f2 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade_greeks_first_order.py @@ -0,0 +1,381 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_format import OptionHistoryTradeGreeksFirstOrderFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_rate_type import OptionHistoryTradeGreeksFirstOrderRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_response_200_item import OptionHistoryTradeGreeksFirstOrderResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_right import OptionHistoryTradeGreeksFirstOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksFirstOrderRight = OptionHistoryTradeGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksFirstOrderRateType = OptionHistoryTradeGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksFirstOrderFormat = OptionHistoryTradeGreeksFirstOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade_greeks/first_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeGreeksFirstOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeGreeksFirstOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeGreeksFirstOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksFirstOrderRight = OptionHistoryTradeGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksFirstOrderRateType = OptionHistoryTradeGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksFirstOrderFormat = OptionHistoryTradeGreeksFirstOrderFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksFirstOrderResponse200Item]]: + """ First Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksFirstOrderRight): Default: + OptionHistoryTradeGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksFirstOrderRateType): Default: + OptionHistoryTradeGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksFirstOrderFormat): Default: + OptionHistoryTradeGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksFirstOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksFirstOrderRight = OptionHistoryTradeGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksFirstOrderRateType = OptionHistoryTradeGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksFirstOrderFormat = OptionHistoryTradeGreeksFirstOrderFormat.JSON, + +) -> list[OptionHistoryTradeGreeksFirstOrderResponse200Item] | None: + """ First Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksFirstOrderRight): Default: + OptionHistoryTradeGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksFirstOrderRateType): Default: + OptionHistoryTradeGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksFirstOrderFormat): Default: + OptionHistoryTradeGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksFirstOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksFirstOrderRight = OptionHistoryTradeGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksFirstOrderRateType = OptionHistoryTradeGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksFirstOrderFormat = OptionHistoryTradeGreeksFirstOrderFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksFirstOrderResponse200Item]]: + """ First Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksFirstOrderRight): Default: + OptionHistoryTradeGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksFirstOrderRateType): Default: + OptionHistoryTradeGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksFirstOrderFormat): Default: + OptionHistoryTradeGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksFirstOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksFirstOrderRight = OptionHistoryTradeGreeksFirstOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksFirstOrderRateType = OptionHistoryTradeGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksFirstOrderFormat = OptionHistoryTradeGreeksFirstOrderFormat.JSON, + +) -> list[OptionHistoryTradeGreeksFirstOrderResponse200Item] | None: + """ First Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksFirstOrderRight): Default: + OptionHistoryTradeGreeksFirstOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksFirstOrderRateType): Default: + OptionHistoryTradeGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksFirstOrderFormat): Default: + OptionHistoryTradeGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksFirstOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade_greeks_implied_volatility.py b/openapi_project/openapi_package/api/option/option_history_trade_greeks_implied_volatility.py new file mode 100644 index 000000000..c56843bae --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade_greeks_implied_volatility.py @@ -0,0 +1,381 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_format import OptionHistoryTradeGreeksImpliedVolatilityFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_rate_type import OptionHistoryTradeGreeksImpliedVolatilityRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_response_200_item import OptionHistoryTradeGreeksImpliedVolatilityResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_right import OptionHistoryTradeGreeksImpliedVolatilityRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksImpliedVolatilityRight = OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType = OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat = OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade_greeks/implied_volatility", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeGreeksImpliedVolatilityResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksImpliedVolatilityRight = OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType = OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat = OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item]]: + """ Trade Implied Volatility + + - Returns implied volatilies calculated using the trade reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksImpliedVolatilityRight): Default: + OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType): Default: + OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat): Default: + OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksImpliedVolatilityRight = OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType = OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat = OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON, + +) -> list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item] | None: + """ Trade Implied Volatility + + - Returns implied volatilies calculated using the trade reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksImpliedVolatilityRight): Default: + OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType): Default: + OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat): Default: + OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksImpliedVolatilityRight = OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType = OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat = OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item]]: + """ Trade Implied Volatility + + - Returns implied volatilies calculated using the trade reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksImpliedVolatilityRight): Default: + OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType): Default: + OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat): Default: + OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksImpliedVolatilityRight = OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType = OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat = OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON, + +) -> list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item] | None: + """ Trade Implied Volatility + + - Returns implied volatilies calculated using the trade reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksImpliedVolatilityRight): Default: + OptionHistoryTradeGreeksImpliedVolatilityRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksImpliedVolatilityRateType): Default: + OptionHistoryTradeGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksImpliedVolatilityFormat): Default: + OptionHistoryTradeGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksImpliedVolatilityResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade_greeks_second_order.py b/openapi_project/openapi_package/api/option/option_history_trade_greeks_second_order.py new file mode 100644 index 000000000..b1f4fdcaf --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade_greeks_second_order.py @@ -0,0 +1,381 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_format import OptionHistoryTradeGreeksSecondOrderFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_rate_type import OptionHistoryTradeGreeksSecondOrderRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_response_200_item import OptionHistoryTradeGreeksSecondOrderResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_right import OptionHistoryTradeGreeksSecondOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksSecondOrderRight = OptionHistoryTradeGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksSecondOrderRateType = OptionHistoryTradeGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksSecondOrderFormat = OptionHistoryTradeGreeksSecondOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade_greeks/second_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeGreeksSecondOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeGreeksSecondOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeGreeksSecondOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksSecondOrderRight = OptionHistoryTradeGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksSecondOrderRateType = OptionHistoryTradeGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksSecondOrderFormat = OptionHistoryTradeGreeksSecondOrderFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksSecondOrderResponse200Item]]: + """ Second Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksSecondOrderRight): Default: + OptionHistoryTradeGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksSecondOrderRateType): Default: + OptionHistoryTradeGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksSecondOrderFormat): Default: + OptionHistoryTradeGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksSecondOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksSecondOrderRight = OptionHistoryTradeGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksSecondOrderRateType = OptionHistoryTradeGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksSecondOrderFormat = OptionHistoryTradeGreeksSecondOrderFormat.JSON, + +) -> list[OptionHistoryTradeGreeksSecondOrderResponse200Item] | None: + """ Second Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksSecondOrderRight): Default: + OptionHistoryTradeGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksSecondOrderRateType): Default: + OptionHistoryTradeGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksSecondOrderFormat): Default: + OptionHistoryTradeGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksSecondOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksSecondOrderRight = OptionHistoryTradeGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksSecondOrderRateType = OptionHistoryTradeGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksSecondOrderFormat = OptionHistoryTradeGreeksSecondOrderFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksSecondOrderResponse200Item]]: + """ Second Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksSecondOrderRight): Default: + OptionHistoryTradeGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksSecondOrderRateType): Default: + OptionHistoryTradeGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksSecondOrderFormat): Default: + OptionHistoryTradeGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksSecondOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksSecondOrderRight = OptionHistoryTradeGreeksSecondOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksSecondOrderRateType = OptionHistoryTradeGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksSecondOrderFormat = OptionHistoryTradeGreeksSecondOrderFormat.JSON, + +) -> list[OptionHistoryTradeGreeksSecondOrderResponse200Item] | None: + """ Second Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksSecondOrderRight): Default: + OptionHistoryTradeGreeksSecondOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksSecondOrderRateType): Default: + OptionHistoryTradeGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksSecondOrderFormat): Default: + OptionHistoryTradeGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksSecondOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade_greeks_third_order.py b/openapi_project/openapi_package/api/option/option_history_trade_greeks_third_order.py new file mode 100644 index 000000000..75676576f --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade_greeks_third_order.py @@ -0,0 +1,381 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_format import OptionHistoryTradeGreeksThirdOrderFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_rate_type import OptionHistoryTradeGreeksThirdOrderRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_response_200_item import OptionHistoryTradeGreeksThirdOrderResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_right import OptionHistoryTradeGreeksThirdOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksThirdOrderRight = OptionHistoryTradeGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksThirdOrderRateType = OptionHistoryTradeGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksThirdOrderFormat = OptionHistoryTradeGreeksThirdOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade_greeks/third_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeGreeksThirdOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeGreeksThirdOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeGreeksThirdOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksThirdOrderRight = OptionHistoryTradeGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksThirdOrderRateType = OptionHistoryTradeGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksThirdOrderFormat = OptionHistoryTradeGreeksThirdOrderFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksThirdOrderResponse200Item]]: + """ Third Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksThirdOrderRight): Default: + OptionHistoryTradeGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksThirdOrderRateType): Default: + OptionHistoryTradeGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksThirdOrderFormat): Default: + OptionHistoryTradeGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksThirdOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksThirdOrderRight = OptionHistoryTradeGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksThirdOrderRateType = OptionHistoryTradeGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksThirdOrderFormat = OptionHistoryTradeGreeksThirdOrderFormat.JSON, + +) -> list[OptionHistoryTradeGreeksThirdOrderResponse200Item] | None: + """ Third Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksThirdOrderRight): Default: + OptionHistoryTradeGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksThirdOrderRateType): Default: + OptionHistoryTradeGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksThirdOrderFormat): Default: + OptionHistoryTradeGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksThirdOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksThirdOrderRight = OptionHistoryTradeGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksThirdOrderRateType = OptionHistoryTradeGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksThirdOrderFormat = OptionHistoryTradeGreeksThirdOrderFormat.JSON, + +) -> Response[list[OptionHistoryTradeGreeksThirdOrderResponse200Item]]: + """ Third Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksThirdOrderRight): Default: + OptionHistoryTradeGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksThirdOrderRateType): Default: + OptionHistoryTradeGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksThirdOrderFormat): Default: + OptionHistoryTradeGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeGreeksThirdOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeGreeksThirdOrderRight = OptionHistoryTradeGreeksThirdOrderRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionHistoryTradeGreeksThirdOrderRateType = OptionHistoryTradeGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + format_: Unset | OptionHistoryTradeGreeksThirdOrderFormat = OptionHistoryTradeGreeksThirdOrderFormat.JSON, + +) -> list[OptionHistoryTradeGreeksThirdOrderResponse200Item] | None: + """ Third Order Trade Greeks + + - Returns the data for all contracts that share the same provided symbol and expiration. + - Calculates greeks for every trade reported by [OPRA](/Articles/Data-And-Requests/The-SIPs.html). + - The underlying price represents whatever the last underlying price was at the ``timestamp`` field. + You can read more about how Thetadata calculates greeks [here](/Articles/Data-And-Requests/Option- + Greeks.html). + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeGreeksThirdOrderRight): Default: + OptionHistoryTradeGreeksThirdOrderRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + annual_dividend (Unset | float): + rate_type (Unset | OptionHistoryTradeGreeksThirdOrderRateType): Default: + OptionHistoryTradeGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + format_ (Unset | OptionHistoryTradeGreeksThirdOrderFormat): Default: + OptionHistoryTradeGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeGreeksThirdOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_history_trade_quote.py b/openapi_project/openapi_package/api/option/option_history_trade_quote.py new file mode 100644 index 000000000..a57a349d3 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_history_trade_quote.py @@ -0,0 +1,348 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_history_trade_quote_format import OptionHistoryTradeQuoteFormat +from openapi_project.openapi_package.models.option_history_trade_quote_response_200_item import OptionHistoryTradeQuoteResponse200Item +from openapi_project.openapi_package.models.option_history_trade_quote_right import OptionHistoryTradeQuoteRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeQuoteRight = OptionHistoryTradeQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + format_: Unset | OptionHistoryTradeQuoteFormat = OptionHistoryTradeQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_date = date.isoformat() + params["date"] = json_date + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["exclusive"] = exclusive + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/history/trade_quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionHistoryTradeQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionHistoryTradeQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionHistoryTradeQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeQuoteRight = OptionHistoryTradeQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + format_: Unset | OptionHistoryTradeQuoteFormat = OptionHistoryTradeQuoteFormat.JSON, + +) -> Response[list[OptionHistoryTradeQuoteResponse200Item]]: + """ Trade Quote + + - Returns every [trade](/operations/option_history_trade.html) reported by [OPRA](/Articles/Data- + And-Requests/The-SIPs.html) paired with the last NBBO quote reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html) at the time of trade. + - A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. + - To match trades with quotes timestamps that are ``<`` the trade timestamp, specify the + ``exclusive``parameter to ``true``. After thorough testing, we have determined that using + ``exclusive=true`` might yield better results for various applications. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeQuoteRight): Default: OptionHistoryTradeQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + exclusive (Unset | bool): Default: True. + format_ (Unset | OptionHistoryTradeQuoteFormat): Default: + OptionHistoryTradeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +exclusive=exclusive, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeQuoteRight = OptionHistoryTradeQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + format_: Unset | OptionHistoryTradeQuoteFormat = OptionHistoryTradeQuoteFormat.JSON, + +) -> list[OptionHistoryTradeQuoteResponse200Item] | None: + """ Trade Quote + + - Returns every [trade](/operations/option_history_trade.html) reported by [OPRA](/Articles/Data- + And-Requests/The-SIPs.html) paired with the last NBBO quote reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html) at the time of trade. + - A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. + - To match trades with quotes timestamps that are ``<`` the trade timestamp, specify the + ``exclusive``parameter to ``true``. After thorough testing, we have determined that using + ``exclusive=true`` might yield better results for various applications. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeQuoteRight): Default: OptionHistoryTradeQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + exclusive (Unset | bool): Default: True. + format_ (Unset | OptionHistoryTradeQuoteFormat): Default: + OptionHistoryTradeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +exclusive=exclusive, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeQuoteRight = OptionHistoryTradeQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + format_: Unset | OptionHistoryTradeQuoteFormat = OptionHistoryTradeQuoteFormat.JSON, + +) -> Response[list[OptionHistoryTradeQuoteResponse200Item]]: + """ Trade Quote + + - Returns every [trade](/operations/option_history_trade.html) reported by [OPRA](/Articles/Data- + And-Requests/The-SIPs.html) paired with the last NBBO quote reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html) at the time of trade. + - A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. + - To match trades with quotes timestamps that are ``<`` the trade timestamp, specify the + ``exclusive``parameter to ``true``. After thorough testing, we have determined that using + ``exclusive=true`` might yield better results for various applications. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeQuoteRight): Default: OptionHistoryTradeQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + exclusive (Unset | bool): Default: True. + format_ (Unset | OptionHistoryTradeQuoteFormat): Default: + OptionHistoryTradeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionHistoryTradeQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +exclusive=exclusive, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: datetime.date, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionHistoryTradeQuoteRight = OptionHistoryTradeQuoteRight.BOTH, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + format_: Unset | OptionHistoryTradeQuoteFormat = OptionHistoryTradeQuoteFormat.JSON, + +) -> list[OptionHistoryTradeQuoteResponse200Item] | None: + """ Trade Quote + + - Returns every [trade](/operations/option_history_trade.html) reported by [OPRA](/Articles/Data- + And-Requests/The-SIPs.html) paired with the last NBBO quote reported by [OPRA](/Articles/Data-And- + Requests/The-SIPs.html) at the time of trade. + - A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. + - To match trades with quotes timestamps that are ``<`` the trade timestamp, specify the + ``exclusive``parameter to ``true``. After thorough testing, we have determined that using + ``exclusive=true`` might yield better results for various applications. + + Args: + date (datetime.date): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionHistoryTradeQuoteRight): Default: OptionHistoryTradeQuoteRight.BOTH. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + exclusive (Unset | bool): Default: True. + format_ (Unset | OptionHistoryTradeQuoteFormat): Default: + OptionHistoryTradeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionHistoryTradeQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +date=date, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +start_time=start_time, +end_time=end_time, +exclusive=exclusive, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_list_contracts.py b/openapi_project/openapi_package/api/option/option_list_contracts.py new file mode 100644 index 000000000..a8ca6c498 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_list_contracts.py @@ -0,0 +1,265 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_list_contracts_format import OptionListContractsFormat +from openapi_project.openapi_package.models.option_list_contracts_request_type import OptionListContractsRequestType +from openapi_project.openapi_package.models.option_list_contracts_response_200_item import OptionListContractsResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + request_type: OptionListContractsRequestType, + *, + symbol: Unset | list[str] = UNSET, + date: datetime.date, + format_: Unset | OptionListContractsFormat = OptionListContractsFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol: Unset | list[str] = UNSET + if not isinstance(symbol, Unset): + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_date = date.isoformat() + params["date"] = json_date + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/list/contracts/{request_type}".format(request_type=request_type,), + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionListContractsResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionListContractsResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionListContractsResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + request_type: OptionListContractsRequestType, + *, + client: AuthenticatedClient | Client, + symbol: Unset | list[str] = UNSET, + date: datetime.date, + format_: Unset | OptionListContractsFormat = OptionListContractsFormat.JSON, + +) -> Response[list[OptionListContractsResponse200Item]]: + """ Contracts + + Lists all contracts that were traded or quoted on a particular date. + + If the ``symbol`` parameter is specified, the returned contracts will be filtered to match the + symbol. + Multiple symbols can be specified by separating them with commas such as ``symbol=AAPL,SPY,AMD`` + This endpoint is updated real-time. + + Args: + request_type (OptionListContractsRequestType): + symbol (Unset | list[str]): + date (datetime.date): + format_ (Unset | OptionListContractsFormat): Default: OptionListContractsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListContractsResponse200Item]] + """ + + + kwargs = _get_kwargs( + request_type=request_type, +symbol=symbol, +date=date, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + request_type: OptionListContractsRequestType, + *, + client: AuthenticatedClient | Client, + symbol: Unset | list[str] = UNSET, + date: datetime.date, + format_: Unset | OptionListContractsFormat = OptionListContractsFormat.JSON, + +) -> list[OptionListContractsResponse200Item] | None: + """ Contracts + + Lists all contracts that were traded or quoted on a particular date. + + If the ``symbol`` parameter is specified, the returned contracts will be filtered to match the + symbol. + Multiple symbols can be specified by separating them with commas such as ``symbol=AAPL,SPY,AMD`` + This endpoint is updated real-time. + + Args: + request_type (OptionListContractsRequestType): + symbol (Unset | list[str]): + date (datetime.date): + format_ (Unset | OptionListContractsFormat): Default: OptionListContractsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListContractsResponse200Item] + """ + + + return sync_detailed( + request_type=request_type, +client=client, +symbol=symbol, +date=date, +format_=format_, + + ).parsed + +async def asyncio_detailed( + request_type: OptionListContractsRequestType, + *, + client: AuthenticatedClient | Client, + symbol: Unset | list[str] = UNSET, + date: datetime.date, + format_: Unset | OptionListContractsFormat = OptionListContractsFormat.JSON, + +) -> Response[list[OptionListContractsResponse200Item]]: + """ Contracts + + Lists all contracts that were traded or quoted on a particular date. + + If the ``symbol`` parameter is specified, the returned contracts will be filtered to match the + symbol. + Multiple symbols can be specified by separating them with commas such as ``symbol=AAPL,SPY,AMD`` + This endpoint is updated real-time. + + Args: + request_type (OptionListContractsRequestType): + symbol (Unset | list[str]): + date (datetime.date): + format_ (Unset | OptionListContractsFormat): Default: OptionListContractsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListContractsResponse200Item]] + """ + + + kwargs = _get_kwargs( + request_type=request_type, +symbol=symbol, +date=date, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + request_type: OptionListContractsRequestType, + *, + client: AuthenticatedClient | Client, + symbol: Unset | list[str] = UNSET, + date: datetime.date, + format_: Unset | OptionListContractsFormat = OptionListContractsFormat.JSON, + +) -> list[OptionListContractsResponse200Item] | None: + """ Contracts + + Lists all contracts that were traded or quoted on a particular date. + + If the ``symbol`` parameter is specified, the returned contracts will be filtered to match the + symbol. + Multiple symbols can be specified by separating them with commas such as ``symbol=AAPL,SPY,AMD`` + This endpoint is updated real-time. + + Args: + request_type (OptionListContractsRequestType): + symbol (Unset | list[str]): + date (datetime.date): + format_ (Unset | OptionListContractsFormat): Default: OptionListContractsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListContractsResponse200Item] + """ + + + return (await asyncio_detailed( + request_type=request_type, +client=client, +symbol=symbol, +date=date, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_list_dates.py b/openapi_project/openapi_package/api/option/option_list_dates.py new file mode 100644 index 000000000..b29cbe385 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_list_dates.py @@ -0,0 +1,281 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_list_dates_format import OptionListDatesFormat +from openapi_project.openapi_package.models.option_list_dates_request_type import OptionListDatesRequestType +from openapi_project.openapi_package.models.option_list_dates_response_200_item import OptionListDatesResponse200Item +from openapi_project.openapi_package.models.option_list_dates_right import OptionListDatesRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + request_type: OptionListDatesRequestType, + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionListDatesRight = OptionListDatesRight.BOTH, + format_: Unset | OptionListDatesFormat = OptionListDatesFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/list/dates/{request_type}".format(request_type=request_type,), + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionListDatesResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionListDatesResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionListDatesResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + request_type: OptionListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionListDatesRight = OptionListDatesRight.BOTH, + format_: Unset | OptionListDatesFormat = OptionListDatesFormat.JSON, + +) -> Response[list[OptionListDatesResponse200Item]]: + """ Dates + + Lists all dates of data that are available for an option with a given symbol, request type, and + expiration. + This endpoint is updated overnight. + + Args: + request_type (OptionListDatesRequestType): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionListDatesRight): Default: OptionListDatesRight.BOTH. + format_ (Unset | OptionListDatesFormat): Default: OptionListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListDatesResponse200Item]] + """ + + + kwargs = _get_kwargs( + request_type=request_type, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + request_type: OptionListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionListDatesRight = OptionListDatesRight.BOTH, + format_: Unset | OptionListDatesFormat = OptionListDatesFormat.JSON, + +) -> list[OptionListDatesResponse200Item] | None: + """ Dates + + Lists all dates of data that are available for an option with a given symbol, request type, and + expiration. + This endpoint is updated overnight. + + Args: + request_type (OptionListDatesRequestType): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionListDatesRight): Default: OptionListDatesRight.BOTH. + format_ (Unset | OptionListDatesFormat): Default: OptionListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListDatesResponse200Item] + """ + + + return sync_detailed( + request_type=request_type, +client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + request_type: OptionListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionListDatesRight = OptionListDatesRight.BOTH, + format_: Unset | OptionListDatesFormat = OptionListDatesFormat.JSON, + +) -> Response[list[OptionListDatesResponse200Item]]: + """ Dates + + Lists all dates of data that are available for an option with a given symbol, request type, and + expiration. + This endpoint is updated overnight. + + Args: + request_type (OptionListDatesRequestType): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionListDatesRight): Default: OptionListDatesRight.BOTH. + format_ (Unset | OptionListDatesFormat): Default: OptionListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListDatesResponse200Item]] + """ + + + kwargs = _get_kwargs( + request_type=request_type, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + request_type: OptionListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionListDatesRight = OptionListDatesRight.BOTH, + format_: Unset | OptionListDatesFormat = OptionListDatesFormat.JSON, + +) -> list[OptionListDatesResponse200Item] | None: + """ Dates + + Lists all dates of data that are available for an option with a given symbol, request type, and + expiration. + This endpoint is updated overnight. + + Args: + request_type (OptionListDatesRequestType): + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionListDatesRight): Default: OptionListDatesRight.BOTH. + format_ (Unset | OptionListDatesFormat): Default: OptionListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListDatesResponse200Item] + """ + + + return (await asyncio_detailed( + request_type=request_type, +client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_list_expirations.py b/openapi_project/openapi_package/api/option/option_list_expirations.py new file mode 100644 index 000000000..ab67245d3 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_list_expirations.py @@ -0,0 +1,215 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_list_expirations_format import OptionListExpirationsFormat +from openapi_project.openapi_package.models.option_list_expirations_response_200_item import OptionListExpirationsResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + format_: Unset | OptionListExpirationsFormat = OptionListExpirationsFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/list/expirations", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionListExpirationsResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionListExpirationsResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionListExpirationsResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | OptionListExpirationsFormat = OptionListExpirationsFormat.JSON, + +) -> Response[list[OptionListExpirationsResponse200Item]]: + """ Expirations + + Lists all dates of expirations that are available for an option with a given symbol. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | OptionListExpirationsFormat): Default: OptionListExpirationsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListExpirationsResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | OptionListExpirationsFormat = OptionListExpirationsFormat.JSON, + +) -> list[OptionListExpirationsResponse200Item] | None: + """ Expirations + + Lists all dates of expirations that are available for an option with a given symbol. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | OptionListExpirationsFormat): Default: OptionListExpirationsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListExpirationsResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | OptionListExpirationsFormat = OptionListExpirationsFormat.JSON, + +) -> Response[list[OptionListExpirationsResponse200Item]]: + """ Expirations + + Lists all dates of expirations that are available for an option with a given symbol. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | OptionListExpirationsFormat): Default: OptionListExpirationsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListExpirationsResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | OptionListExpirationsFormat = OptionListExpirationsFormat.JSON, + +) -> list[OptionListExpirationsResponse200Item] | None: + """ Expirations + + Lists all dates of expirations that are available for an option with a given symbol. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + format_ (Unset | OptionListExpirationsFormat): Default: OptionListExpirationsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListExpirationsResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_list_strikes.py b/openapi_project/openapi_package/api/option/option_list_strikes.py new file mode 100644 index 000000000..fd0ccd1ae --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_list_strikes.py @@ -0,0 +1,233 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_list_strikes_format import OptionListStrikesFormat +from openapi_project.openapi_package.models.option_list_strikes_response_200_item import OptionListStrikesResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: list[str], + expiration: datetime.date, + format_: Unset | OptionListStrikesFormat = OptionListStrikesFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/list/strikes", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionListStrikesResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionListStrikesResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionListStrikesResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + expiration: datetime.date, + format_: Unset | OptionListStrikesFormat = OptionListStrikesFormat.JSON, + +) -> Response[list[OptionListStrikesResponse200Item]]: + """ Strikes + + Lists all strikes that are available for an option with a given symbol and expiration date. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + expiration (datetime.date): + format_ (Unset | OptionListStrikesFormat): Default: OptionListStrikesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListStrikesResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + expiration: datetime.date, + format_: Unset | OptionListStrikesFormat = OptionListStrikesFormat.JSON, + +) -> list[OptionListStrikesResponse200Item] | None: + """ Strikes + + Lists all strikes that are available for an option with a given symbol and expiration date. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + expiration (datetime.date): + format_ (Unset | OptionListStrikesFormat): Default: OptionListStrikesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListStrikesResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + expiration: datetime.date, + format_: Unset | OptionListStrikesFormat = OptionListStrikesFormat.JSON, + +) -> Response[list[OptionListStrikesResponse200Item]]: + """ Strikes + + Lists all strikes that are available for an option with a given symbol and expiration date. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + expiration (datetime.date): + format_ (Unset | OptionListStrikesFormat): Default: OptionListStrikesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListStrikesResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + expiration: datetime.date, + format_: Unset | OptionListStrikesFormat = OptionListStrikesFormat.JSON, + +) -> list[OptionListStrikesResponse200Item] | None: + """ Strikes + + Lists all strikes that are available for an option with a given symbol and expiration date. + This endpoint is updated overnight. + + Args: + symbol (list[str]): + expiration (datetime.date): + format_ (Unset | OptionListStrikesFormat): Default: OptionListStrikesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListStrikesResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_list_symbols.py b/openapi_project/openapi_package/api/option/option_list_symbols.py new file mode 100644 index 000000000..ca38b1699 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_list_symbols.py @@ -0,0 +1,201 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_list_symbols_format import OptionListSymbolsFormat +from openapi_project.openapi_package.models.option_list_symbols_response_200_item import OptionListSymbolsResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + format_: Unset | OptionListSymbolsFormat = OptionListSymbolsFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/list/symbols", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionListSymbolsResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionListSymbolsResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionListSymbolsResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + format_: Unset | OptionListSymbolsFormat = OptionListSymbolsFormat.JSON, + +) -> Response[list[OptionListSymbolsResponse200Item]]: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | OptionListSymbolsFormat): Default: OptionListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListSymbolsResponse200Item]] + """ + + + kwargs = _get_kwargs( + format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + format_: Unset | OptionListSymbolsFormat = OptionListSymbolsFormat.JSON, + +) -> list[OptionListSymbolsResponse200Item] | None: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | OptionListSymbolsFormat): Default: OptionListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListSymbolsResponse200Item] + """ + + + return sync_detailed( + client=client, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + format_: Unset | OptionListSymbolsFormat = OptionListSymbolsFormat.JSON, + +) -> Response[list[OptionListSymbolsResponse200Item]]: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | OptionListSymbolsFormat): Default: OptionListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionListSymbolsResponse200Item]] + """ + + + kwargs = _get_kwargs( + format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + format_: Unset | OptionListSymbolsFormat = OptionListSymbolsFormat.JSON, + +) -> list[OptionListSymbolsResponse200Item] | None: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for options. This + endpoint is updated overnight. + + Args: + format_ (Unset | OptionListSymbolsFormat): Default: OptionListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionListSymbolsResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_greeks_all.py b/openapi_project/openapi_package/api/option/option_snapshot_greeks_all.py new file mode 100644 index 000000000..58ff27b7e --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_greeks_all.py @@ -0,0 +1,354 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_greeks_all_format import OptionSnapshotGreeksAllFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_all_rate_type import OptionSnapshotGreeksAllRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_all_response_200_item import OptionSnapshotGreeksAllResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_all_right import OptionSnapshotGreeksAllRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksAllRight = OptionSnapshotGreeksAllRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksAllRateType = OptionSnapshotGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksAllFormat = OptionSnapshotGreeksAllFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + params["stock_price"] = stock_price + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/greeks/all", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotGreeksAllResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotGreeksAllResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotGreeksAllResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksAllRight = OptionSnapshotGreeksAllRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksAllRateType = OptionSnapshotGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksAllFormat = OptionSnapshotGreeksAllFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksAllResponse200Item]]: + """ All Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksAllRight): Default: OptionSnapshotGreeksAllRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksAllRateType): Default: + OptionSnapshotGreeksAllRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksAllFormat): Default: + OptionSnapshotGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksAllResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksAllRight = OptionSnapshotGreeksAllRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksAllRateType = OptionSnapshotGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksAllFormat = OptionSnapshotGreeksAllFormat.JSON, + +) -> list[OptionSnapshotGreeksAllResponse200Item] | None: + """ All Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksAllRight): Default: OptionSnapshotGreeksAllRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksAllRateType): Default: + OptionSnapshotGreeksAllRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksAllFormat): Default: + OptionSnapshotGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksAllResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksAllRight = OptionSnapshotGreeksAllRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksAllRateType = OptionSnapshotGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksAllFormat = OptionSnapshotGreeksAllFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksAllResponse200Item]]: + """ All Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksAllRight): Default: OptionSnapshotGreeksAllRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksAllRateType): Default: + OptionSnapshotGreeksAllRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksAllFormat): Default: + OptionSnapshotGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksAllResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksAllRight = OptionSnapshotGreeksAllRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksAllRateType = OptionSnapshotGreeksAllRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksAllFormat = OptionSnapshotGreeksAllFormat.JSON, + +) -> list[OptionSnapshotGreeksAllResponse200Item] | None: + """ All Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksAllRight): Default: OptionSnapshotGreeksAllRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksAllRateType): Default: + OptionSnapshotGreeksAllRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksAllFormat): Default: + OptionSnapshotGreeksAllFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksAllResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_greeks_first_order.py b/openapi_project/openapi_package/api/option/option_snapshot_greeks_first_order.py new file mode 100644 index 000000000..573c2cf11 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_greeks_first_order.py @@ -0,0 +1,358 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_format import OptionSnapshotGreeksFirstOrderFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_rate_type import OptionSnapshotGreeksFirstOrderRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_response_200_item import OptionSnapshotGreeksFirstOrderResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_right import OptionSnapshotGreeksFirstOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksFirstOrderRight = OptionSnapshotGreeksFirstOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksFirstOrderRateType = OptionSnapshotGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksFirstOrderFormat = OptionSnapshotGreeksFirstOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + params["stock_price"] = stock_price + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/greeks/first_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotGreeksFirstOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotGreeksFirstOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotGreeksFirstOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksFirstOrderRight = OptionSnapshotGreeksFirstOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksFirstOrderRateType = OptionSnapshotGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksFirstOrderFormat = OptionSnapshotGreeksFirstOrderFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksFirstOrderResponse200Item]]: + """ First Order Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksFirstOrderRight): Default: + OptionSnapshotGreeksFirstOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksFirstOrderRateType): Default: + OptionSnapshotGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksFirstOrderFormat): Default: + OptionSnapshotGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksFirstOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksFirstOrderRight = OptionSnapshotGreeksFirstOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksFirstOrderRateType = OptionSnapshotGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksFirstOrderFormat = OptionSnapshotGreeksFirstOrderFormat.JSON, + +) -> list[OptionSnapshotGreeksFirstOrderResponse200Item] | None: + """ First Order Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksFirstOrderRight): Default: + OptionSnapshotGreeksFirstOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksFirstOrderRateType): Default: + OptionSnapshotGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksFirstOrderFormat): Default: + OptionSnapshotGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksFirstOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksFirstOrderRight = OptionSnapshotGreeksFirstOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksFirstOrderRateType = OptionSnapshotGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksFirstOrderFormat = OptionSnapshotGreeksFirstOrderFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksFirstOrderResponse200Item]]: + """ First Order Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksFirstOrderRight): Default: + OptionSnapshotGreeksFirstOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksFirstOrderRateType): Default: + OptionSnapshotGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksFirstOrderFormat): Default: + OptionSnapshotGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksFirstOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksFirstOrderRight = OptionSnapshotGreeksFirstOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksFirstOrderRateType = OptionSnapshotGreeksFirstOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksFirstOrderFormat = OptionSnapshotGreeksFirstOrderFormat.JSON, + +) -> list[OptionSnapshotGreeksFirstOrderResponse200Item] | None: + """ First Order Greeks + + - Retrieve a real-time last greeks calculation for all option contracts that lie on a provided + expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksFirstOrderRight): Default: + OptionSnapshotGreeksFirstOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksFirstOrderRateType): Default: + OptionSnapshotGreeksFirstOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksFirstOrderFormat): Default: + OptionSnapshotGreeksFirstOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksFirstOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_greeks_implied_volatility.py b/openapi_project/openapi_package/api/option/option_snapshot_greeks_implied_volatility.py new file mode 100644 index 000000000..a860d41a6 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_greeks_implied_volatility.py @@ -0,0 +1,350 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_format import OptionSnapshotGreeksImpliedVolatilityFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_rate_type import OptionSnapshotGreeksImpliedVolatilityRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_response_200_item import OptionSnapshotGreeksImpliedVolatilityResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_right import OptionSnapshotGreeksImpliedVolatilityRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksImpliedVolatilityRight = OptionSnapshotGreeksImpliedVolatilityRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksImpliedVolatilityRateType = OptionSnapshotGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksImpliedVolatilityFormat = OptionSnapshotGreeksImpliedVolatilityFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + params["stock_price"] = stock_price + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/greeks/implied_volatility", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotGreeksImpliedVolatilityResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotGreeksImpliedVolatilityResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotGreeksImpliedVolatilityResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksImpliedVolatilityRight = OptionSnapshotGreeksImpliedVolatilityRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksImpliedVolatilityRateType = OptionSnapshotGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksImpliedVolatilityFormat = OptionSnapshotGreeksImpliedVolatilityFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksImpliedVolatilityResponse200Item]]: + """ Implied Volatility + + Returns implied volatilies calculated using the national best bid, mid, and ask price + of the option respectively. The underlying price represents whatever the last underlying price was + at the + ``underlying_timestamp`` field. You can read more about how Thetadata calculates greeks + [here](/Articles/Data-And-Requests/Option-Greeks.html). + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksImpliedVolatilityRight): Default: + OptionSnapshotGreeksImpliedVolatilityRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksImpliedVolatilityRateType): Default: + OptionSnapshotGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksImpliedVolatilityFormat): Default: + OptionSnapshotGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksImpliedVolatilityResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksImpliedVolatilityRight = OptionSnapshotGreeksImpliedVolatilityRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksImpliedVolatilityRateType = OptionSnapshotGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksImpliedVolatilityFormat = OptionSnapshotGreeksImpliedVolatilityFormat.JSON, + +) -> list[OptionSnapshotGreeksImpliedVolatilityResponse200Item] | None: + """ Implied Volatility + + Returns implied volatilies calculated using the national best bid, mid, and ask price + of the option respectively. The underlying price represents whatever the last underlying price was + at the + ``underlying_timestamp`` field. You can read more about how Thetadata calculates greeks + [here](/Articles/Data-And-Requests/Option-Greeks.html). + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksImpliedVolatilityRight): Default: + OptionSnapshotGreeksImpliedVolatilityRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksImpliedVolatilityRateType): Default: + OptionSnapshotGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksImpliedVolatilityFormat): Default: + OptionSnapshotGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksImpliedVolatilityResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksImpliedVolatilityRight = OptionSnapshotGreeksImpliedVolatilityRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksImpliedVolatilityRateType = OptionSnapshotGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksImpliedVolatilityFormat = OptionSnapshotGreeksImpliedVolatilityFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksImpliedVolatilityResponse200Item]]: + """ Implied Volatility + + Returns implied volatilies calculated using the national best bid, mid, and ask price + of the option respectively. The underlying price represents whatever the last underlying price was + at the + ``underlying_timestamp`` field. You can read more about how Thetadata calculates greeks + [here](/Articles/Data-And-Requests/Option-Greeks.html). + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksImpliedVolatilityRight): Default: + OptionSnapshotGreeksImpliedVolatilityRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksImpliedVolatilityRateType): Default: + OptionSnapshotGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksImpliedVolatilityFormat): Default: + OptionSnapshotGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksImpliedVolatilityResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksImpliedVolatilityRight = OptionSnapshotGreeksImpliedVolatilityRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksImpliedVolatilityRateType = OptionSnapshotGreeksImpliedVolatilityRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksImpliedVolatilityFormat = OptionSnapshotGreeksImpliedVolatilityFormat.JSON, + +) -> list[OptionSnapshotGreeksImpliedVolatilityResponse200Item] | None: + """ Implied Volatility + + Returns implied volatilies calculated using the national best bid, mid, and ask price + of the option respectively. The underlying price represents whatever the last underlying price was + at the + ``underlying_timestamp`` field. You can read more about how Thetadata calculates greeks + [here](/Articles/Data-And-Requests/Option-Greeks.html). + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksImpliedVolatilityRight): Default: + OptionSnapshotGreeksImpliedVolatilityRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksImpliedVolatilityRateType): Default: + OptionSnapshotGreeksImpliedVolatilityRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksImpliedVolatilityFormat): Default: + OptionSnapshotGreeksImpliedVolatilityFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksImpliedVolatilityResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_greeks_second_order.py b/openapi_project/openapi_package/api/option/option_snapshot_greeks_second_order.py new file mode 100644 index 000000000..c52705d30 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_greeks_second_order.py @@ -0,0 +1,358 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_format import OptionSnapshotGreeksSecondOrderFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_rate_type import OptionSnapshotGreeksSecondOrderRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_response_200_item import OptionSnapshotGreeksSecondOrderResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_right import OptionSnapshotGreeksSecondOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksSecondOrderRight = OptionSnapshotGreeksSecondOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksSecondOrderRateType = OptionSnapshotGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksSecondOrderFormat = OptionSnapshotGreeksSecondOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + params["stock_price"] = stock_price + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/greeks/second_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotGreeksSecondOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotGreeksSecondOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotGreeksSecondOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksSecondOrderRight = OptionSnapshotGreeksSecondOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksSecondOrderRateType = OptionSnapshotGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksSecondOrderFormat = OptionSnapshotGreeksSecondOrderFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksSecondOrderResponse200Item]]: + """ Second Order Greeks + + - Retrieve a real-time last second order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksSecondOrderRight): Default: + OptionSnapshotGreeksSecondOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksSecondOrderRateType): Default: + OptionSnapshotGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksSecondOrderFormat): Default: + OptionSnapshotGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksSecondOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksSecondOrderRight = OptionSnapshotGreeksSecondOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksSecondOrderRateType = OptionSnapshotGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksSecondOrderFormat = OptionSnapshotGreeksSecondOrderFormat.JSON, + +) -> list[OptionSnapshotGreeksSecondOrderResponse200Item] | None: + """ Second Order Greeks + + - Retrieve a real-time last second order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksSecondOrderRight): Default: + OptionSnapshotGreeksSecondOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksSecondOrderRateType): Default: + OptionSnapshotGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksSecondOrderFormat): Default: + OptionSnapshotGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksSecondOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksSecondOrderRight = OptionSnapshotGreeksSecondOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksSecondOrderRateType = OptionSnapshotGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksSecondOrderFormat = OptionSnapshotGreeksSecondOrderFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksSecondOrderResponse200Item]]: + """ Second Order Greeks + + - Retrieve a real-time last second order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksSecondOrderRight): Default: + OptionSnapshotGreeksSecondOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksSecondOrderRateType): Default: + OptionSnapshotGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksSecondOrderFormat): Default: + OptionSnapshotGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksSecondOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksSecondOrderRight = OptionSnapshotGreeksSecondOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksSecondOrderRateType = OptionSnapshotGreeksSecondOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksSecondOrderFormat = OptionSnapshotGreeksSecondOrderFormat.JSON, + +) -> list[OptionSnapshotGreeksSecondOrderResponse200Item] | None: + """ Second Order Greeks + + - Retrieve a real-time last second order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksSecondOrderRight): Default: + OptionSnapshotGreeksSecondOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksSecondOrderRateType): Default: + OptionSnapshotGreeksSecondOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksSecondOrderFormat): Default: + OptionSnapshotGreeksSecondOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksSecondOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_greeks_third_order.py b/openapi_project/openapi_package/api/option/option_snapshot_greeks_third_order.py new file mode 100644 index 000000000..b29894c51 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_greeks_third_order.py @@ -0,0 +1,358 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_format import OptionSnapshotGreeksThirdOrderFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_rate_type import OptionSnapshotGreeksThirdOrderRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_response_200_item import OptionSnapshotGreeksThirdOrderResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_right import OptionSnapshotGreeksThirdOrderRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksThirdOrderRight = OptionSnapshotGreeksThirdOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksThirdOrderRateType = OptionSnapshotGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksThirdOrderFormat = OptionSnapshotGreeksThirdOrderFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + params["annual_dividend"] = annual_dividend + + json_rate_type: Unset | str = UNSET if isinstance(rate_type, Unset) else rate_type.value + + params["rate_type"] = json_rate_type + + params["rate_value"] = rate_value + + params["stock_price"] = stock_price + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/greeks/third_order", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotGreeksThirdOrderResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotGreeksThirdOrderResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotGreeksThirdOrderResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksThirdOrderRight = OptionSnapshotGreeksThirdOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksThirdOrderRateType = OptionSnapshotGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksThirdOrderFormat = OptionSnapshotGreeksThirdOrderFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksThirdOrderResponse200Item]]: + """ Third Order Greeks + + - Retrieve a real-time last third order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksThirdOrderRight): Default: + OptionSnapshotGreeksThirdOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksThirdOrderRateType): Default: + OptionSnapshotGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksThirdOrderFormat): Default: + OptionSnapshotGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksThirdOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksThirdOrderRight = OptionSnapshotGreeksThirdOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksThirdOrderRateType = OptionSnapshotGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksThirdOrderFormat = OptionSnapshotGreeksThirdOrderFormat.JSON, + +) -> list[OptionSnapshotGreeksThirdOrderResponse200Item] | None: + """ Third Order Greeks + + - Retrieve a real-time last third order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksThirdOrderRight): Default: + OptionSnapshotGreeksThirdOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksThirdOrderRateType): Default: + OptionSnapshotGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksThirdOrderFormat): Default: + OptionSnapshotGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksThirdOrderResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksThirdOrderRight = OptionSnapshotGreeksThirdOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksThirdOrderRateType = OptionSnapshotGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksThirdOrderFormat = OptionSnapshotGreeksThirdOrderFormat.JSON, + +) -> Response[list[OptionSnapshotGreeksThirdOrderResponse200Item]]: + """ Third Order Greeks + + - Retrieve a real-time last third order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksThirdOrderRight): Default: + OptionSnapshotGreeksThirdOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksThirdOrderRateType): Default: + OptionSnapshotGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksThirdOrderFormat): Default: + OptionSnapshotGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotGreeksThirdOrderResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotGreeksThirdOrderRight = OptionSnapshotGreeksThirdOrderRight.BOTH, + annual_dividend: Unset | float = UNSET, + rate_type: Unset | OptionSnapshotGreeksThirdOrderRateType = OptionSnapshotGreeksThirdOrderRateType.SOFR, + rate_value: Unset | float = UNSET, + stock_price: Unset | float = UNSET, + format_: Unset | OptionSnapshotGreeksThirdOrderFormat = OptionSnapshotGreeksThirdOrderFormat.JSON, + +) -> list[OptionSnapshotGreeksThirdOrderResponse200Item] | None: + """ Third Order Greeks + + - Retrieve a real-time last third order greeks calculation for all option contracts that lie on a + provided expiration. + - You might need to change the default expiration date to a different date if it is past the current + date. Some quotes are omitted in the example to reduce the space of the sample output. + - Make `expiration` * if you want to get the snapshot for every expiration chain for the underlying. + > This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotGreeksThirdOrderRight): Default: + OptionSnapshotGreeksThirdOrderRight.BOTH. + annual_dividend (Unset | float): + rate_type (Unset | OptionSnapshotGreeksThirdOrderRateType): Default: + OptionSnapshotGreeksThirdOrderRateType.SOFR. + rate_value (Unset | float): + stock_price (Unset | float): + format_ (Unset | OptionSnapshotGreeksThirdOrderFormat): Default: + OptionSnapshotGreeksThirdOrderFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotGreeksThirdOrderResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +annual_dividend=annual_dividend, +rate_type=rate_type, +rate_value=rate_value, +stock_price=stock_price, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_ohlc.py b/openapi_project/openapi_package/api/option/option_snapshot_ohlc.py new file mode 100644 index 000000000..ebd270d80 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_ohlc.py @@ -0,0 +1,267 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_ohlc_format import OptionSnapshotOhlcFormat +from openapi_project.openapi_package.models.option_snapshot_ohlc_response_200_item import OptionSnapshotOhlcResponse200Item +from openapi_project.openapi_package.models.option_snapshot_ohlc_right import OptionSnapshotOhlcRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOhlcRight = OptionSnapshotOhlcRight.BOTH, + format_: Unset | OptionSnapshotOhlcFormat = OptionSnapshotOhlcFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/ohlc", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotOhlcResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotOhlcResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotOhlcResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOhlcRight = OptionSnapshotOhlcRight.BOTH, + format_: Unset | OptionSnapshotOhlcFormat = OptionSnapshotOhlcFormat.JSON, + +) -> Response[list[OptionSnapshotOhlcResponse200Item]]: + """ Open High Low Close + + - Retrieve a real-time last ohlc of an option contract for the trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOhlcRight): Default: OptionSnapshotOhlcRight.BOTH. + format_ (Unset | OptionSnapshotOhlcFormat): Default: OptionSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOhlcRight = OptionSnapshotOhlcRight.BOTH, + format_: Unset | OptionSnapshotOhlcFormat = OptionSnapshotOhlcFormat.JSON, + +) -> list[OptionSnapshotOhlcResponse200Item] | None: + """ Open High Low Close + + - Retrieve a real-time last ohlc of an option contract for the trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOhlcRight): Default: OptionSnapshotOhlcRight.BOTH. + format_ (Unset | OptionSnapshotOhlcFormat): Default: OptionSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotOhlcResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOhlcRight = OptionSnapshotOhlcRight.BOTH, + format_: Unset | OptionSnapshotOhlcFormat = OptionSnapshotOhlcFormat.JSON, + +) -> Response[list[OptionSnapshotOhlcResponse200Item]]: + """ Open High Low Close + + - Retrieve a real-time last ohlc of an option contract for the trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOhlcRight): Default: OptionSnapshotOhlcRight.BOTH. + format_ (Unset | OptionSnapshotOhlcFormat): Default: OptionSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOhlcRight = OptionSnapshotOhlcRight.BOTH, + format_: Unset | OptionSnapshotOhlcFormat = OptionSnapshotOhlcFormat.JSON, + +) -> list[OptionSnapshotOhlcResponse200Item] | None: + """ Open High Low Close + + - Retrieve a real-time last ohlc of an option contract for the trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOhlcRight): Default: OptionSnapshotOhlcRight.BOTH. + format_ (Unset | OptionSnapshotOhlcFormat): Default: OptionSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotOhlcResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_open_interest.py b/openapi_project/openapi_package/api/option/option_snapshot_open_interest.py new file mode 100644 index 000000000..66aad216a --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_open_interest.py @@ -0,0 +1,291 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_open_interest_format import OptionSnapshotOpenInterestFormat +from openapi_project.openapi_package.models.option_snapshot_open_interest_response_200_item import OptionSnapshotOpenInterestResponse200Item +from openapi_project.openapi_package.models.option_snapshot_open_interest_right import OptionSnapshotOpenInterestRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOpenInterestRight = OptionSnapshotOpenInterestRight.BOTH, + format_: Unset | OptionSnapshotOpenInterestFormat = OptionSnapshotOpenInterestFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/open_interest", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotOpenInterestResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotOpenInterestResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotOpenInterestResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOpenInterestRight = OptionSnapshotOpenInterestRight.BOTH, + format_: Unset | OptionSnapshotOpenInterestFormat = OptionSnapshotOpenInterestFormat.JSON, + +) -> Response[list[OptionSnapshotOpenInterestResponse200Item]]: + """ Open Interest + + - Retrieve the last open interest message of an option contract. + - Open interest is reported around 06:30 ET every morning by OPRA and reflects the open interest at + the of the previous trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOpenInterestRight): Default: + OptionSnapshotOpenInterestRight.BOTH. + format_ (Unset | OptionSnapshotOpenInterestFormat): Default: + OptionSnapshotOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotOpenInterestResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOpenInterestRight = OptionSnapshotOpenInterestRight.BOTH, + format_: Unset | OptionSnapshotOpenInterestFormat = OptionSnapshotOpenInterestFormat.JSON, + +) -> list[OptionSnapshotOpenInterestResponse200Item] | None: + """ Open Interest + + - Retrieve the last open interest message of an option contract. + - Open interest is reported around 06:30 ET every morning by OPRA and reflects the open interest at + the of the previous trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOpenInterestRight): Default: + OptionSnapshotOpenInterestRight.BOTH. + format_ (Unset | OptionSnapshotOpenInterestFormat): Default: + OptionSnapshotOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotOpenInterestResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOpenInterestRight = OptionSnapshotOpenInterestRight.BOTH, + format_: Unset | OptionSnapshotOpenInterestFormat = OptionSnapshotOpenInterestFormat.JSON, + +) -> Response[list[OptionSnapshotOpenInterestResponse200Item]]: + """ Open Interest + + - Retrieve the last open interest message of an option contract. + - Open interest is reported around 06:30 ET every morning by OPRA and reflects the open interest at + the of the previous trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOpenInterestRight): Default: + OptionSnapshotOpenInterestRight.BOTH. + format_ (Unset | OptionSnapshotOpenInterestFormat): Default: + OptionSnapshotOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotOpenInterestResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotOpenInterestRight = OptionSnapshotOpenInterestRight.BOTH, + format_: Unset | OptionSnapshotOpenInterestFormat = OptionSnapshotOpenInterestFormat.JSON, + +) -> list[OptionSnapshotOpenInterestResponse200Item] | None: + """ Open Interest + + - Retrieve the last open interest message of an option contract. + - Open interest is reported around 06:30 ET every morning by OPRA and reflects the open interest at + the of the previous trading day. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotOpenInterestRight): Default: + OptionSnapshotOpenInterestRight.BOTH. + format_ (Unset | OptionSnapshotOpenInterestFormat): Default: + OptionSnapshotOpenInterestFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotOpenInterestResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_quote.py b/openapi_project/openapi_package/api/option/option_snapshot_quote.py new file mode 100644 index 000000000..7ddec55de --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_quote.py @@ -0,0 +1,279 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_quote_format import OptionSnapshotQuoteFormat +from openapi_project.openapi_package.models.option_snapshot_quote_response_200_item import OptionSnapshotQuoteResponse200Item +from openapi_project.openapi_package.models.option_snapshot_quote_right import OptionSnapshotQuoteRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotQuoteRight = OptionSnapshotQuoteRight.BOTH, + format_: Unset | OptionSnapshotQuoteFormat = OptionSnapshotQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotQuoteRight = OptionSnapshotQuoteRight.BOTH, + format_: Unset | OptionSnapshotQuoteFormat = OptionSnapshotQuoteFormat.JSON, + +) -> Response[list[OptionSnapshotQuoteResponse200Item]]: + """ Quote + + + - Retrieve a real-time last NBBO quote of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotQuoteRight): Default: OptionSnapshotQuoteRight.BOTH. + format_ (Unset | OptionSnapshotQuoteFormat): Default: OptionSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotQuoteRight = OptionSnapshotQuoteRight.BOTH, + format_: Unset | OptionSnapshotQuoteFormat = OptionSnapshotQuoteFormat.JSON, + +) -> list[OptionSnapshotQuoteResponse200Item] | None: + """ Quote + + + - Retrieve a real-time last NBBO quote of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotQuoteRight): Default: OptionSnapshotQuoteRight.BOTH. + format_ (Unset | OptionSnapshotQuoteFormat): Default: OptionSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotQuoteRight = OptionSnapshotQuoteRight.BOTH, + format_: Unset | OptionSnapshotQuoteFormat = OptionSnapshotQuoteFormat.JSON, + +) -> Response[list[OptionSnapshotQuoteResponse200Item]]: + """ Quote + + + - Retrieve a real-time last NBBO quote of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotQuoteRight): Default: OptionSnapshotQuoteRight.BOTH. + format_ (Unset | OptionSnapshotQuoteFormat): Default: OptionSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotQuoteRight = OptionSnapshotQuoteRight.BOTH, + format_: Unset | OptionSnapshotQuoteFormat = OptionSnapshotQuoteFormat.JSON, + +) -> list[OptionSnapshotQuoteResponse200Item] | None: + """ Quote + + + - Retrieve a real-time last NBBO quote of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotQuoteRight): Default: OptionSnapshotQuoteRight.BOTH. + format_ (Unset | OptionSnapshotQuoteFormat): Default: OptionSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/option/option_snapshot_trade.py b/openapi_project/openapi_package/api/option/option_snapshot_trade.py new file mode 100644 index 000000000..06d252142 --- /dev/null +++ b/openapi_project/openapi_package/api/option/option_snapshot_trade.py @@ -0,0 +1,275 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.option_snapshot_trade_format import OptionSnapshotTradeFormat +from openapi_project.openapi_package.models.option_snapshot_trade_response_200_item import OptionSnapshotTradeResponse200Item +from openapi_project.openapi_package.models.option_snapshot_trade_right import OptionSnapshotTradeRight +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotTradeRight = OptionSnapshotTradeRight.BOTH, + format_: Unset | OptionSnapshotTradeFormat = OptionSnapshotTradeFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_expiration = expiration.isoformat() + params["expiration"] = json_expiration + + params["strike"] = strike + + json_right: Unset | str = UNSET if isinstance(right, Unset) else right.value + + params["right"] = json_right + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/option/snapshot/trade", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[OptionSnapshotTradeResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = OptionSnapshotTradeResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[OptionSnapshotTradeResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotTradeRight = OptionSnapshotTradeRight.BOTH, + format_: Unset | OptionSnapshotTradeFormat = OptionSnapshotTradeFormat.JSON, + +) -> Response[list[OptionSnapshotTradeResponse200Item]]: + """ Trade + + - Retrieve the real-time last trade of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotTradeRight): Default: OptionSnapshotTradeRight.BOTH. + format_ (Unset | OptionSnapshotTradeFormat): Default: OptionSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotTradeRight = OptionSnapshotTradeRight.BOTH, + format_: Unset | OptionSnapshotTradeFormat = OptionSnapshotTradeFormat.JSON, + +) -> list[OptionSnapshotTradeResponse200Item] | None: + """ Trade + + - Retrieve the real-time last trade of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotTradeRight): Default: OptionSnapshotTradeRight.BOTH. + format_ (Unset | OptionSnapshotTradeFormat): Default: OptionSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotTradeResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotTradeRight = OptionSnapshotTradeRight.BOTH, + format_: Unset | OptionSnapshotTradeFormat = OptionSnapshotTradeFormat.JSON, + +) -> Response[list[OptionSnapshotTradeResponse200Item]]: + """ Trade + + - Retrieve the real-time last trade of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotTradeRight): Default: OptionSnapshotTradeRight.BOTH. + format_ (Unset | OptionSnapshotTradeFormat): Default: OptionSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[OptionSnapshotTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + expiration: datetime.date, + strike: Unset | str = '*', + right: Unset | OptionSnapshotTradeRight = OptionSnapshotTradeRight.BOTH, + format_: Unset | OptionSnapshotTradeFormat = OptionSnapshotTradeFormat.JSON, + +) -> list[OptionSnapshotTradeResponse200Item] | None: + """ Trade + + - Retrieve the real-time last trade of an option contract. + - You might need to change the default expiration date to a different date if it is past the current + date. + - This endpoint will return no data if the market was closed for the day. Theta Data resets the + snapshot cache at midnight ET every night. + + Args: + symbol (str): + expiration (datetime.date): + strike (Unset | str): Default: '*'. + right (Unset | OptionSnapshotTradeRight): Default: OptionSnapshotTradeRight.BOTH. + format_ (Unset | OptionSnapshotTradeFormat): Default: OptionSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[OptionSnapshotTradeResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +expiration=expiration, +strike=strike, +right=right, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/__init__.py b/openapi_project/openapi_package/api/stock/__init__.py new file mode 100644 index 000000000..03e86a6af --- /dev/null +++ b/openapi_project/openapi_package/api/stock/__init__.py @@ -0,0 +1 @@ +""" Contains endpoint functions for accessing the API """ diff --git a/openapi_project/openapi_package/api/stock/stock_at_time_quote.py b/openapi_project/openapi_package/api/stock/stock_at_time_quote.py new file mode 100644 index 000000000..2faa2e313 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_at_time_quote.py @@ -0,0 +1,319 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_at_time_quote_format import StockAtTimeQuoteFormat +from openapi_project.openapi_package.models.stock_at_time_quote_response_200_item import StockAtTimeQuoteResponse200Item +from openapi_project.openapi_package.models.stock_at_time_quote_venue import StockAtTimeQuoteVenue +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeQuoteVenue = StockAtTimeQuoteVenue.NQB, + format_: Unset | StockAtTimeQuoteFormat = StockAtTimeQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["time_of_day"] = time_of_day + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/at_time/quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockAtTimeQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockAtTimeQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockAtTimeQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeQuoteVenue = StockAtTimeQuoteVenue.NQB, + format_: Unset | StockAtTimeQuoteFormat = StockAtTimeQuoteFormat.JSON, + +) -> Response[list[StockAtTimeQuoteResponse200Item]]: + """ Quote + + #### Real-time request: + - Subscription tier standard or higher will default to NQB. + - Real-time last BBO quote at-time_of_day-time from the [Nasdaq Basic feed](/Articles/Data-And- + Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - 15-minute delayed NBBO quote at-time_of_day-time from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last NBBO quote reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeQuoteVenue): Default: StockAtTimeQuoteVenue.NQB. + format_ (Unset | StockAtTimeQuoteFormat): Default: StockAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockAtTimeQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeQuoteVenue = StockAtTimeQuoteVenue.NQB, + format_: Unset | StockAtTimeQuoteFormat = StockAtTimeQuoteFormat.JSON, + +) -> list[StockAtTimeQuoteResponse200Item] | None: + """ Quote + + #### Real-time request: + - Subscription tier standard or higher will default to NQB. + - Real-time last BBO quote at-time_of_day-time from the [Nasdaq Basic feed](/Articles/Data-And- + Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - 15-minute delayed NBBO quote at-time_of_day-time from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last NBBO quote reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeQuoteVenue): Default: StockAtTimeQuoteVenue.NQB. + format_ (Unset | StockAtTimeQuoteFormat): Default: StockAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockAtTimeQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeQuoteVenue = StockAtTimeQuoteVenue.NQB, + format_: Unset | StockAtTimeQuoteFormat = StockAtTimeQuoteFormat.JSON, + +) -> Response[list[StockAtTimeQuoteResponse200Item]]: + """ Quote + + #### Real-time request: + - Subscription tier standard or higher will default to NQB. + - Real-time last BBO quote at-time_of_day-time from the [Nasdaq Basic feed](/Articles/Data-And- + Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - 15-minute delayed NBBO quote at-time_of_day-time from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last NBBO quote reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeQuoteVenue): Default: StockAtTimeQuoteVenue.NQB. + format_ (Unset | StockAtTimeQuoteFormat): Default: StockAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockAtTimeQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeQuoteVenue = StockAtTimeQuoteVenue.NQB, + format_: Unset | StockAtTimeQuoteFormat = StockAtTimeQuoteFormat.JSON, + +) -> list[StockAtTimeQuoteResponse200Item] | None: + """ Quote + + #### Real-time request: + - Subscription tier standard or higher will default to NQB. + - Real-time last BBO quote at-time_of_day-time from the [Nasdaq Basic feed](/Articles/Data-And- + Requests/The-SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - 15-minute delayed NBBO quote at-time_of_day-time from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last NBBO quote reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeQuoteVenue): Default: StockAtTimeQuoteVenue.NQB. + format_ (Unset | StockAtTimeQuoteFormat): Default: StockAtTimeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockAtTimeQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_at_time_trade.py b/openapi_project/openapi_package/api/stock/stock_at_time_trade.py new file mode 100644 index 000000000..bd6b47799 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_at_time_trade.py @@ -0,0 +1,323 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_at_time_trade_format import StockAtTimeTradeFormat +from openapi_project.openapi_package.models.stock_at_time_trade_response_200_item import StockAtTimeTradeResponse200Item +from openapi_project.openapi_package.models.stock_at_time_trade_venue import StockAtTimeTradeVenue +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeTradeVenue = StockAtTimeTradeVenue.NQB, + format_: Unset | StockAtTimeTradeFormat = StockAtTimeTradeFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + params["time_of_day"] = time_of_day + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/at_time/trade", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockAtTimeTradeResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockAtTimeTradeResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockAtTimeTradeResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeTradeVenue = StockAtTimeTradeVenue.NQB, + format_: Unset | StockAtTimeTradeFormat = StockAtTimeTradeFormat.JSON, + +) -> Response[list[StockAtTimeTradeResponse200Item]]: + """ Trade + + #### Real-time request: + - Returns a real-time session from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - Returns a 15-minute delayed session from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last trade reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeTradeVenue): Default: StockAtTimeTradeVenue.NQB. + format_ (Unset | StockAtTimeTradeFormat): Default: StockAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockAtTimeTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeTradeVenue = StockAtTimeTradeVenue.NQB, + format_: Unset | StockAtTimeTradeFormat = StockAtTimeTradeFormat.JSON, + +) -> list[StockAtTimeTradeResponse200Item] | None: + """ Trade + + #### Real-time request: + - Returns a real-time session from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - Returns a 15-minute delayed session from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last trade reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeTradeVenue): Default: StockAtTimeTradeVenue.NQB. + format_ (Unset | StockAtTimeTradeFormat): Default: StockAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockAtTimeTradeResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeTradeVenue = StockAtTimeTradeVenue.NQB, + format_: Unset | StockAtTimeTradeFormat = StockAtTimeTradeFormat.JSON, + +) -> Response[list[StockAtTimeTradeResponse200Item]]: + """ Trade + + #### Real-time request: + - Returns a real-time session from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - Returns a 15-minute delayed session from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last trade reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeTradeVenue): Default: StockAtTimeTradeVenue.NQB. + format_ (Unset | StockAtTimeTradeFormat): Default: StockAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockAtTimeTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + time_of_day: str, + venue: Unset | StockAtTimeTradeVenue = StockAtTimeTradeVenue.NQB, + format_: Unset | StockAtTimeTradeFormat = StockAtTimeTradeFormat.JSON, + +) -> list[StockAtTimeTradeResponse200Item] | None: + """ Trade + + #### Real-time request: + - Returns a real-time session from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs.html#nasdaq-basic) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + - Returns a 15-minute delayed session from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) account has the [stocks value + subscription](https://www.thetadata.net/subscribe.html#stocks) subscription. + + #### Historical request: + Returns the last trade reported by [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs.html#equities-cta-utp) at a specified millisecond of the day. + Trade condition mappings can be found [here](/Articles/Errors-Exchanges-Conditions/Trade- + Conditions.html). + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + time_of_day (str): + venue (Unset | StockAtTimeTradeVenue): Default: StockAtTimeTradeVenue.NQB. + format_ (Unset | StockAtTimeTradeFormat): Default: StockAtTimeTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockAtTimeTradeResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +time_of_day=time_of_day, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_history_eod.py b/openapi_project/openapi_package/api/stock/stock_history_eod.py new file mode 100644 index 000000000..cce95d215 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_history_eod.py @@ -0,0 +1,270 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_history_eod_format import StockHistoryEodFormat +from openapi_project.openapi_package.models.stock_history_eod_response_200_item import StockHistoryEodResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | StockHistoryEodFormat = StockHistoryEodFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_start_date = start_date.isoformat() + params["start_date"] = json_start_date + + json_end_date = end_date.isoformat() + params["end_date"] = json_end_date + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/history/eod", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockHistoryEodResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockHistoryEodResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockHistoryEodResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | StockHistoryEodFormat = StockHistoryEodFormat.JSON, + +) -> Response[list[StockHistoryEodResponse200Item]]: + """ End of Day + + + Since [the equity SIPs](/Articles/Data-And-Requests/The-SIPs.html) only generate a partial EOD + report, Theta Data generates a national EOD report at 17:15 ET each day. ``created`` represents the + datetime the report was generated and ``last_trade`` represents the datetime of the last trade. The + quote in the response represents the last NBBO reported by [CTA or UTP](/Articles/Data-And- + Requests/The-SIPs.html) at the time of report generation. You can read more about EOD & OHLC data + [here](/Articles/Data-And-Requests/OHLC-EOD.html). Theta Data plans to avail SIP EOD reports in the + near future. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | StockHistoryEodFormat): Default: StockHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockHistoryEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | StockHistoryEodFormat = StockHistoryEodFormat.JSON, + +) -> list[StockHistoryEodResponse200Item] | None: + """ End of Day + + + Since [the equity SIPs](/Articles/Data-And-Requests/The-SIPs.html) only generate a partial EOD + report, Theta Data generates a national EOD report at 17:15 ET each day. ``created`` represents the + datetime the report was generated and ``last_trade`` represents the datetime of the last trade. The + quote in the response represents the last NBBO reported by [CTA or UTP](/Articles/Data-And- + Requests/The-SIPs.html) at the time of report generation. You can read more about EOD & OHLC data + [here](/Articles/Data-And-Requests/OHLC-EOD.html). Theta Data plans to avail SIP EOD reports in the + near future. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | StockHistoryEodFormat): Default: StockHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockHistoryEodResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | StockHistoryEodFormat = StockHistoryEodFormat.JSON, + +) -> Response[list[StockHistoryEodResponse200Item]]: + """ End of Day + + + Since [the equity SIPs](/Articles/Data-And-Requests/The-SIPs.html) only generate a partial EOD + report, Theta Data generates a national EOD report at 17:15 ET each day. ``created`` represents the + datetime the report was generated and ``last_trade`` represents the datetime of the last trade. The + quote in the response represents the last NBBO reported by [CTA or UTP](/Articles/Data-And- + Requests/The-SIPs.html) at the time of report generation. You can read more about EOD & OHLC data + [here](/Articles/Data-And-Requests/OHLC-EOD.html). Theta Data plans to avail SIP EOD reports in the + near future. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | StockHistoryEodFormat): Default: StockHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockHistoryEodResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + start_date: datetime.date, + end_date: datetime.date, + format_: Unset | StockHistoryEodFormat = StockHistoryEodFormat.JSON, + +) -> list[StockHistoryEodResponse200Item] | None: + """ End of Day + + + Since [the equity SIPs](/Articles/Data-And-Requests/The-SIPs.html) only generate a partial EOD + report, Theta Data generates a national EOD report at 17:15 ET each day. ``created`` represents the + datetime the report was generated and ``last_trade`` represents the datetime of the last trade. The + quote in the response represents the last NBBO reported by [CTA or UTP](/Articles/Data-And- + Requests/The-SIPs.html) at the time of report generation. You can read more about EOD & OHLC data + [here](/Articles/Data-And-Requests/OHLC-EOD.html). Theta Data plans to avail SIP EOD reports in the + near future. + + Args: + symbol (str): + start_date (datetime.date): + end_date (datetime.date): + format_ (Unset | StockHistoryEodFormat): Default: StockHistoryEodFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockHistoryEodResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +start_date=start_date, +end_date=end_date, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_history_ohlc.py b/openapi_project/openapi_package/api/stock/stock_history_ohlc.py new file mode 100644 index 000000000..e52fc6c70 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_history_ohlc.py @@ -0,0 +1,311 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_history_ohlc_format import StockHistoryOhlcFormat +from openapi_project.openapi_package.models.stock_history_ohlc_interval import StockHistoryOhlcInterval +from openapi_project.openapi_package.models.stock_history_ohlc_response_200_item import StockHistoryOhlcResponse200Item +from openapi_project.openapi_package.models.stock_history_ohlc_venue import StockHistoryOhlcVenue +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + date: datetime.date, + interval: StockHistoryOhlcInterval = StockHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryOhlcVenue = StockHistoryOhlcVenue.NQB, + format_: Unset | StockHistoryOhlcFormat = StockHistoryOhlcFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_date = date.isoformat() + params["date"] = json_date + + json_interval = interval.value + params["interval"] = json_interval + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/history/ohlc", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockHistoryOhlcResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockHistoryOhlcResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockHistoryOhlcResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryOhlcInterval = StockHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryOhlcVenue = StockHistoryOhlcVenue.NQB, + format_: Unset | StockHistoryOhlcFormat = StockHistoryOhlcFormat.JSON, + +) -> Response[list[StockHistoryOhlcResponse200Item]]: + """ Open High Low Close + + Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: + ``bar time`` <= ``trade time`` < ``bar timestamp + ivl``, where ivl is the specified interval size + in milliseconds. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic + data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks + standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryOhlcInterval): Default: StockHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryOhlcVenue): Default: StockHistoryOhlcVenue.NQB. + format_ (Unset | StockHistoryOhlcFormat): Default: StockHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockHistoryOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryOhlcInterval = StockHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryOhlcVenue = StockHistoryOhlcVenue.NQB, + format_: Unset | StockHistoryOhlcFormat = StockHistoryOhlcFormat.JSON, + +) -> list[StockHistoryOhlcResponse200Item] | None: + """ Open High Low Close + + Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: + ``bar time`` <= ``trade time`` < ``bar timestamp + ivl``, where ivl is the specified interval size + in milliseconds. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic + data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks + standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryOhlcInterval): Default: StockHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryOhlcVenue): Default: StockHistoryOhlcVenue.NQB. + format_ (Unset | StockHistoryOhlcFormat): Default: StockHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockHistoryOhlcResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryOhlcInterval = StockHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryOhlcVenue = StockHistoryOhlcVenue.NQB, + format_: Unset | StockHistoryOhlcFormat = StockHistoryOhlcFormat.JSON, + +) -> Response[list[StockHistoryOhlcResponse200Item]]: + """ Open High Low Close + + Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: + ``bar time`` <= ``trade time`` < ``bar timestamp + ivl``, where ivl is the specified interval size + in milliseconds. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic + data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks + standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryOhlcInterval): Default: StockHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryOhlcVenue): Default: StockHistoryOhlcVenue.NQB. + format_ (Unset | StockHistoryOhlcFormat): Default: StockHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockHistoryOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryOhlcInterval = StockHistoryOhlcInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryOhlcVenue = StockHistoryOhlcVenue.NQB, + format_: Unset | StockHistoryOhlcFormat = StockHistoryOhlcFormat.JSON, + +) -> list[StockHistoryOhlcResponse200Item] | None: + """ Open High Low Close + + Aggregated OHLC bars that use [SIP rules](/Articles/Data-And-Requests/OHLC-EOD.html) for each bar. + Time timestamp of the bar represents the opening time of the bar. For a trade to be part of the bar: + ``bar time`` <= ``trade time`` < ``bar timestamp + ivl``, where ivl is the specified interval size + in milliseconds. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic + data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks + standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryOhlcInterval): Default: StockHistoryOhlcInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryOhlcVenue): Default: StockHistoryOhlcVenue.NQB. + format_ (Unset | StockHistoryOhlcFormat): Default: StockHistoryOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockHistoryOhlcResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_history_quote.py b/openapi_project/openapi_package/api/stock/stock_history_quote.py new file mode 100644 index 000000000..afa2234a4 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_history_quote.py @@ -0,0 +1,307 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_history_quote_format import StockHistoryQuoteFormat +from openapi_project.openapi_package.models.stock_history_quote_interval import StockHistoryQuoteInterval +from openapi_project.openapi_package.models.stock_history_quote_response_200_item import StockHistoryQuoteResponse200Item +from openapi_project.openapi_package.models.stock_history_quote_venue import StockHistoryQuoteVenue +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + date: datetime.date, + interval: StockHistoryQuoteInterval = StockHistoryQuoteInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryQuoteVenue = StockHistoryQuoteVenue.NQB, + format_: Unset | StockHistoryQuoteFormat = StockHistoryQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_date = date.isoformat() + params["date"] = json_date + + json_interval = interval.value + params["interval"] = json_interval + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/history/quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockHistoryQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockHistoryQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockHistoryQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryQuoteInterval = StockHistoryQuoteInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryQuoteVenue = StockHistoryQuoteVenue.NQB, + format_: Unset | StockHistoryQuoteFormat = StockHistoryQuoteFormat.JSON, + +) -> Response[list[StockHistoryQuoteResponse200Item]]: + """ Quote + + Returns every NBBO quote reported by [UTP and CTA](/Articles/Data-And-Requests/The-SIPs). If the + ``interval`` parameter is specified, the quote for each interval represents the last quote prior to + the interval's timestamp. Set the ``venue`` parameter to ``nqb`` to access current-day real-time + historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has + a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryQuoteInterval): Default: StockHistoryQuoteInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryQuoteVenue): Default: StockHistoryQuoteVenue.NQB. + format_ (Unset | StockHistoryQuoteFormat): Default: StockHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockHistoryQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryQuoteInterval = StockHistoryQuoteInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryQuoteVenue = StockHistoryQuoteVenue.NQB, + format_: Unset | StockHistoryQuoteFormat = StockHistoryQuoteFormat.JSON, + +) -> list[StockHistoryQuoteResponse200Item] | None: + """ Quote + + Returns every NBBO quote reported by [UTP and CTA](/Articles/Data-And-Requests/The-SIPs). If the + ``interval`` parameter is specified, the quote for each interval represents the last quote prior to + the interval's timestamp. Set the ``venue`` parameter to ``nqb`` to access current-day real-time + historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has + a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryQuoteInterval): Default: StockHistoryQuoteInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryQuoteVenue): Default: StockHistoryQuoteVenue.NQB. + format_ (Unset | StockHistoryQuoteFormat): Default: StockHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockHistoryQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryQuoteInterval = StockHistoryQuoteInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryQuoteVenue = StockHistoryQuoteVenue.NQB, + format_: Unset | StockHistoryQuoteFormat = StockHistoryQuoteFormat.JSON, + +) -> Response[list[StockHistoryQuoteResponse200Item]]: + """ Quote + + Returns every NBBO quote reported by [UTP and CTA](/Articles/Data-And-Requests/The-SIPs). If the + ``interval`` parameter is specified, the quote for each interval represents the last quote prior to + the interval's timestamp. Set the ``venue`` parameter to ``nqb`` to access current-day real-time + historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has + a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryQuoteInterval): Default: StockHistoryQuoteInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryQuoteVenue): Default: StockHistoryQuoteVenue.NQB. + format_ (Unset | StockHistoryQuoteFormat): Default: StockHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockHistoryQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + interval: StockHistoryQuoteInterval = StockHistoryQuoteInterval.VALUE_4, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryQuoteVenue = StockHistoryQuoteVenue.NQB, + format_: Unset | StockHistoryQuoteFormat = StockHistoryQuoteFormat.JSON, + +) -> list[StockHistoryQuoteResponse200Item] | None: + """ Quote + + Returns every NBBO quote reported by [UTP and CTA](/Articles/Data-And-Requests/The-SIPs). If the + ``interval`` parameter is specified, the quote for each interval represents the last quote prior to + the interval's timestamp. Set the ``venue`` parameter to ``nqb`` to access current-day real-time + historic data from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has + a [stocks standard or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + interval (StockHistoryQuoteInterval): Default: StockHistoryQuoteInterval.VALUE_4. + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryQuoteVenue): Default: StockHistoryQuoteVenue.NQB. + format_ (Unset | StockHistoryQuoteFormat): Default: StockHistoryQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockHistoryQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +date=date, +interval=interval, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_history_trade.py b/openapi_project/openapi_package/api/stock/stock_history_trade.py new file mode 100644 index 000000000..e2066a10f --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_history_trade.py @@ -0,0 +1,186 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_history_trade_format import StockHistoryTradeFormat +from openapi_project.openapi_package.models.stock_history_trade_venue import StockHistoryTradeVenue +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + date: datetime.date, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryTradeVenue = StockHistoryTradeVenue.NQB, + format_: Unset | StockHistoryTradeFormat = StockHistoryTradeFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_date = date.isoformat() + params["date"] = json_date + + params["start_time"] = start_time + + params["end_time"] = end_time + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/history/trade", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | None: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryTradeVenue = StockHistoryTradeVenue.NQB, + format_: Unset | StockHistoryTradeFormat = StockHistoryTradeFormat.JSON, + +) -> Response[Any]: + """ Trade + + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs). Set the ``venue`` + parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic + feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryTradeVenue): Default: StockHistoryTradeVenue.NQB. + format_ (Unset | StockHistoryTradeFormat): Default: StockHistoryTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + venue: Unset | StockHistoryTradeVenue = StockHistoryTradeVenue.NQB, + format_: Unset | StockHistoryTradeFormat = StockHistoryTradeFormat.JSON, + +) -> Response[Any]: + """ Trade + + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs). Set the ``venue`` + parameter to ``nqb`` to access current-day real-time historic data from the [Nasdaq Basic + feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + venue (Unset | StockHistoryTradeVenue): Default: StockHistoryTradeVenue.NQB. + format_ (Unset | StockHistoryTradeFormat): Default: StockHistoryTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +start_time=start_time, +end_time=end_time, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + diff --git a/openapi_project/openapi_package/api/stock/stock_history_trade_quote.py b/openapi_project/openapi_package/api/stock/stock_history_trade_quote.py new file mode 100644 index 000000000..13a9508a7 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_history_trade_quote.py @@ -0,0 +1,203 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_history_trade_quote_format import StockHistoryTradeQuoteFormat +from openapi_project.openapi_package.models.stock_history_trade_quote_venue import StockHistoryTradeQuoteVenue +from openapi_project.openapi_package.types import UNSET, Unset +from dateutil.parser import isoparse +from typing import cast +import datetime + + + +def _get_kwargs( + *, + symbol: str, + date: datetime.date, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + venue: Unset | StockHistoryTradeQuoteVenue = StockHistoryTradeQuoteVenue.NQB, + format_: Unset | StockHistoryTradeQuoteFormat = StockHistoryTradeQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + params["symbol"] = symbol + + json_date = date.isoformat() + params["date"] = json_date + + params["start_time"] = start_time + + params["end_time"] = end_time + + params["exclusive"] = exclusive + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/history/trade_quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | None: + if response.status_code == 200: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + venue: Unset | StockHistoryTradeQuoteVenue = StockHistoryTradeQuoteVenue.NQB, + format_: Unset | StockHistoryTradeQuoteFormat = StockHistoryTradeQuoteFormat.JSON, + +) -> Response[Any]: + """ Trade Quote + + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs) paired with the + last BBO quote reported by [UTP or CTA](/Articles/Data-And-Requests/The-SIPs) at the time of trade. + A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. If you prefer to match + quotes with timestamps that are ``<`` the trade timestamp, specify the ``exclusive`` parameter to + ``true``. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from + the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard + or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + exclusive (Unset | bool): Default: True. + venue (Unset | StockHistoryTradeQuoteVenue): Default: StockHistoryTradeQuoteVenue.NQB. + format_ (Unset | StockHistoryTradeQuoteFormat): Default: + StockHistoryTradeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +start_time=start_time, +end_time=end_time, +exclusive=exclusive, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: str, + date: datetime.date, + start_time: Unset | str = '09:30:00', + end_time: Unset | str = '16:00:00', + exclusive: Unset | bool = True, + venue: Unset | StockHistoryTradeQuoteVenue = StockHistoryTradeQuoteVenue.NQB, + format_: Unset | StockHistoryTradeQuoteFormat = StockHistoryTradeQuoteFormat.JSON, + +) -> Response[Any]: + """ Trade Quote + + Returns every trade reported by [UTP & CTA](/Articles/Data-And-Requests/The-SIPs) paired with the + last BBO quote reported by [UTP or CTA](/Articles/Data-And-Requests/The-SIPs) at the time of trade. + A quote is matched with a trade if its timestamp ``<=`` the trade timestamp. If you prefer to match + quotes with timestamps that are ``<`` the trade timestamp, specify the ``exclusive`` parameter to + ``true``. Set the ``venue`` parameter to ``nqb`` to access current-day real-time historic data from + the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if the account has a [stocks standard + or pro subscription](https://www.thetadata.net/subscribe.html#stocks). + + Args: + symbol (str): + date (datetime.date): + start_time (Unset | str): Default: '09:30:00'. + end_time (Unset | str): Default: '16:00:00'. + exclusive (Unset | bool): Default: True. + venue (Unset | StockHistoryTradeQuoteVenue): Default: StockHistoryTradeQuoteVenue.NQB. + format_ (Unset | StockHistoryTradeQuoteFormat): Default: + StockHistoryTradeQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +date=date, +start_time=start_time, +end_time=end_time, +exclusive=exclusive, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + diff --git a/openapi_project/openapi_package/api/stock/stock_list_dates.py b/openapi_project/openapi_package/api/stock/stock_list_dates.py new file mode 100644 index 000000000..93b4cff63 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_list_dates.py @@ -0,0 +1,229 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_list_dates_format import StockListDatesFormat +from openapi_project.openapi_package.models.stock_list_dates_request_type import StockListDatesRequestType +from openapi_project.openapi_package.models.stock_list_dates_response_200_item import StockListDatesResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + request_type: StockListDatesRequestType, + *, + symbol: list[str], + format_: Unset | StockListDatesFormat = StockListDatesFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/list/dates/{request_type}".format(request_type=request_type,), + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockListDatesResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockListDatesResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockListDatesResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + request_type: StockListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | StockListDatesFormat = StockListDatesFormat.JSON, + +) -> Response[list[StockListDatesResponse200Item]]: + """ Dates + + Lists all dates of data that are available for a stock with a given request type and symbol. This + endpoint is updated overnight. + + Args: + request_type (StockListDatesRequestType): + symbol (list[str]): + format_ (Unset | StockListDatesFormat): Default: StockListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockListDatesResponse200Item]] + """ + + + kwargs = _get_kwargs( + request_type=request_type, +symbol=symbol, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + request_type: StockListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | StockListDatesFormat = StockListDatesFormat.JSON, + +) -> list[StockListDatesResponse200Item] | None: + """ Dates + + Lists all dates of data that are available for a stock with a given request type and symbol. This + endpoint is updated overnight. + + Args: + request_type (StockListDatesRequestType): + symbol (list[str]): + format_ (Unset | StockListDatesFormat): Default: StockListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockListDatesResponse200Item] + """ + + + return sync_detailed( + request_type=request_type, +client=client, +symbol=symbol, +format_=format_, + + ).parsed + +async def asyncio_detailed( + request_type: StockListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | StockListDatesFormat = StockListDatesFormat.JSON, + +) -> Response[list[StockListDatesResponse200Item]]: + """ Dates + + Lists all dates of data that are available for a stock with a given request type and symbol. This + endpoint is updated overnight. + + Args: + request_type (StockListDatesRequestType): + symbol (list[str]): + format_ (Unset | StockListDatesFormat): Default: StockListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockListDatesResponse200Item]] + """ + + + kwargs = _get_kwargs( + request_type=request_type, +symbol=symbol, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + request_type: StockListDatesRequestType, + *, + client: AuthenticatedClient | Client, + symbol: list[str], + format_: Unset | StockListDatesFormat = StockListDatesFormat.JSON, + +) -> list[StockListDatesResponse200Item] | None: + """ Dates + + Lists all dates of data that are available for a stock with a given request type and symbol. This + endpoint is updated overnight. + + Args: + request_type (StockListDatesRequestType): + symbol (list[str]): + format_ (Unset | StockListDatesFormat): Default: StockListDatesFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockListDatesResponse200Item] + """ + + + return (await asyncio_detailed( + request_type=request_type, +client=client, +symbol=symbol, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_list_symbols.py b/openapi_project/openapi_package/api/stock/stock_list_symbols.py new file mode 100644 index 000000000..761845d3a --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_list_symbols.py @@ -0,0 +1,201 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_list_symbols_format import StockListSymbolsFormat +from openapi_project.openapi_package.models.stock_list_symbols_response_200_item import StockListSymbolsResponse200Item +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + format_: Unset | StockListSymbolsFormat = StockListSymbolsFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/list/symbols", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockListSymbolsResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockListSymbolsResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockListSymbolsResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + format_: Unset | StockListSymbolsFormat = StockListSymbolsFormat.JSON, + +) -> Response[list[StockListSymbolsResponse200Item]]: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for stocks. This + endpoint is updated overnight. + + Args: + format_ (Unset | StockListSymbolsFormat): Default: StockListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockListSymbolsResponse200Item]] + """ + + + kwargs = _get_kwargs( + format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + format_: Unset | StockListSymbolsFormat = StockListSymbolsFormat.JSON, + +) -> list[StockListSymbolsResponse200Item] | None: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for stocks. This + endpoint is updated overnight. + + Args: + format_ (Unset | StockListSymbolsFormat): Default: StockListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockListSymbolsResponse200Item] + """ + + + return sync_detailed( + client=client, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + format_: Unset | StockListSymbolsFormat = StockListSymbolsFormat.JSON, + +) -> Response[list[StockListSymbolsResponse200Item]]: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for stocks. This + endpoint is updated overnight. + + Args: + format_ (Unset | StockListSymbolsFormat): Default: StockListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockListSymbolsResponse200Item]] + """ + + + kwargs = _get_kwargs( + format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + format_: Unset | StockListSymbolsFormat = StockListSymbolsFormat.JSON, + +) -> list[StockListSymbolsResponse200Item] | None: + """ Symbols + + A symbol can be defined as a unique identifier for a stock / underlying asset. Common terms also + include: root, ticker, and underlying. This endpoint returns all traded symbols for stocks. This + endpoint is updated overnight. + + Args: + format_ (Unset | StockListSymbolsFormat): Default: StockListSymbolsFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockListSymbolsResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_snapshot_ohlc.py b/openapi_project/openapi_package/api/stock/stock_snapshot_ohlc.py new file mode 100644 index 000000000..e00d08b9d --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_snapshot_ohlc.py @@ -0,0 +1,265 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_snapshot_ohlc_format import StockSnapshotOhlcFormat +from openapi_project.openapi_package.models.stock_snapshot_ohlc_response_200_item import StockSnapshotOhlcResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_ohlc_venue import StockSnapshotOhlcVenue +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + venue: Unset | StockSnapshotOhlcVenue = StockSnapshotOhlcVenue.NQB, + format_: Unset | StockSnapshotOhlcFormat = StockSnapshotOhlcFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/snapshot/ohlc", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockSnapshotOhlcResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockSnapshotOhlcResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockSnapshotOhlcResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotOhlcVenue = StockSnapshotOhlcVenue.NQB, + format_: Unset | StockSnapshotOhlcFormat = StockSnapshotOhlcFormat.JSON, + +) -> Response[list[StockSnapshotOhlcResponse200Item]]: + """ Open High Low Close + + + Provides a real-time Open, High, Low, Close for the current day. + * Returns a real-time session OHLC from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed session OHLC from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs) if the account has the stocks value subscription. + * ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotOhlcVenue): Default: StockSnapshotOhlcVenue.NQB. + format_ (Unset | StockSnapshotOhlcFormat): Default: StockSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockSnapshotOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotOhlcVenue = StockSnapshotOhlcVenue.NQB, + format_: Unset | StockSnapshotOhlcFormat = StockSnapshotOhlcFormat.JSON, + +) -> list[StockSnapshotOhlcResponse200Item] | None: + """ Open High Low Close + + + Provides a real-time Open, High, Low, Close for the current day. + * Returns a real-time session OHLC from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed session OHLC from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs) if the account has the stocks value subscription. + * ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotOhlcVenue): Default: StockSnapshotOhlcVenue.NQB. + format_ (Unset | StockSnapshotOhlcFormat): Default: StockSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockSnapshotOhlcResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotOhlcVenue = StockSnapshotOhlcVenue.NQB, + format_: Unset | StockSnapshotOhlcFormat = StockSnapshotOhlcFormat.JSON, + +) -> Response[list[StockSnapshotOhlcResponse200Item]]: + """ Open High Low Close + + + Provides a real-time Open, High, Low, Close for the current day. + * Returns a real-time session OHLC from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed session OHLC from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs) if the account has the stocks value subscription. + * ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotOhlcVenue): Default: StockSnapshotOhlcVenue.NQB. + format_ (Unset | StockSnapshotOhlcFormat): Default: StockSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockSnapshotOhlcResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotOhlcVenue = StockSnapshotOhlcVenue.NQB, + format_: Unset | StockSnapshotOhlcFormat = StockSnapshotOhlcFormat.JSON, + +) -> list[StockSnapshotOhlcResponse200Item] | None: + """ Open High Low Close + + + Provides a real-time Open, High, Low, Close for the current day. + * Returns a real-time session OHLC from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed session OHLC from the [UTP & CTA feeds](/Articles/Data-And- + Requests/The-SIPs) if the account has the stocks value subscription. + * ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotOhlcVenue): Default: StockSnapshotOhlcVenue.NQB. + format_ (Unset | StockSnapshotOhlcFormat): Default: StockSnapshotOhlcFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockSnapshotOhlcResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_snapshot_quote.py b/openapi_project/openapi_package/api/stock/stock_snapshot_quote.py new file mode 100644 index 000000000..7bc429617 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_snapshot_quote.py @@ -0,0 +1,261 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_snapshot_quote_format import StockSnapshotQuoteFormat +from openapi_project.openapi_package.models.stock_snapshot_quote_response_200_item import StockSnapshotQuoteResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_quote_venue import StockSnapshotQuoteVenue +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + venue: Unset | StockSnapshotQuoteVenue = StockSnapshotQuoteVenue.NQB, + format_: Unset | StockSnapshotQuoteFormat = StockSnapshotQuoteFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/snapshot/quote", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockSnapshotQuoteResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockSnapshotQuoteResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockSnapshotQuoteResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotQuoteVenue = StockSnapshotQuoteVenue.NQB, + format_: Unset | StockSnapshotQuoteFormat = StockSnapshotQuoteFormat.JSON, + +) -> Response[list[StockSnapshotQuoteResponse200Item]]: + """ Quote + + * Returns a real-time last BBO quote from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed NBBO quote from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) + subscription. + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotQuoteVenue): Default: StockSnapshotQuoteVenue.NQB. + format_ (Unset | StockSnapshotQuoteFormat): Default: StockSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockSnapshotQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotQuoteVenue = StockSnapshotQuoteVenue.NQB, + format_: Unset | StockSnapshotQuoteFormat = StockSnapshotQuoteFormat.JSON, + +) -> list[StockSnapshotQuoteResponse200Item] | None: + """ Quote + + * Returns a real-time last BBO quote from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed NBBO quote from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) + subscription. + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotQuoteVenue): Default: StockSnapshotQuoteVenue.NQB. + format_ (Unset | StockSnapshotQuoteFormat): Default: StockSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockSnapshotQuoteResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotQuoteVenue = StockSnapshotQuoteVenue.NQB, + format_: Unset | StockSnapshotQuoteFormat = StockSnapshotQuoteFormat.JSON, + +) -> Response[list[StockSnapshotQuoteResponse200Item]]: + """ Quote + + * Returns a real-time last BBO quote from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed NBBO quote from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) + subscription. + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotQuoteVenue): Default: StockSnapshotQuoteVenue.NQB. + format_ (Unset | StockSnapshotQuoteFormat): Default: StockSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockSnapshotQuoteResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotQuoteVenue = StockSnapshotQuoteVenue.NQB, + format_: Unset | StockSnapshotQuoteFormat = StockSnapshotQuoteFormat.JSON, + +) -> list[StockSnapshotQuoteResponse200Item] | None: + """ Quote + + * Returns a real-time last BBO quote from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The- + SIPs) if the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + * Returns a 15-minute delayed NBBO quote from the [UTP & CTA feeds](/Articles/Data-And-Requests/The- + SIPs) account has the [stocks value subscription](https://www.thetadata.net/subscribe.html#stocks) + subscription. + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotQuoteVenue): Default: StockSnapshotQuoteVenue.NQB. + format_ (Unset | StockSnapshotQuoteFormat): Default: StockSnapshotQuoteFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockSnapshotQuoteResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/api/stock/stock_snapshot_trade.py b/openapi_project/openapi_package/api/stock/stock_snapshot_trade.py new file mode 100644 index 000000000..01d454192 --- /dev/null +++ b/openapi_project/openapi_package/api/stock/stock_snapshot_trade.py @@ -0,0 +1,257 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from openapi_project.openapi_package.client import AuthenticatedClient, Client +from openapi_project.openapi_package.types import Response, UNSET +from openapi_project.openapi_package import errors + +from openapi_project.openapi_package.models.stock_snapshot_trade_format import StockSnapshotTradeFormat +from openapi_project.openapi_package.models.stock_snapshot_trade_response_200_item import StockSnapshotTradeResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_trade_venue import StockSnapshotTradeVenue +from openapi_project.openapi_package.types import UNSET, Unset +from typing import cast + + + +def _get_kwargs( + *, + symbol: list[str], + venue: Unset | StockSnapshotTradeVenue = StockSnapshotTradeVenue.NQB, + format_: Unset | StockSnapshotTradeFormat = StockSnapshotTradeFormat.JSON, + +) -> dict[str, Any]: + + + + + params: dict[str, Any] = {} + + json_symbol = symbol + + + params["symbol"] = json_symbol + + json_venue: Unset | str = UNSET if isinstance(venue, Unset) else venue.value + + params["venue"] = json_venue + + json_format_: Unset | str = UNSET if isinstance(format_, Unset) else format_.value + + params["format"] = json_format_ + + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/stock/snapshot/trade", + "params": params, + } + + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list[StockSnapshotTradeResponse200Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in (_response_200): + response_200_item = StockSnapshotTradeResponse200Item.from_dict(response_200_item_data) + + + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list[StockSnapshotTradeResponse200Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotTradeVenue = StockSnapshotTradeVenue.NQB, + format_: Unset | StockSnapshotTradeFormat = StockSnapshotTradeFormat.JSON, + +) -> Response[list[StockSnapshotTradeResponse200Item]]: + """ Trade + + + Returns a real-time last trade from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if + the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotTradeVenue): Default: StockSnapshotTradeVenue.NQB. + format_ (Unset | StockSnapshotTradeFormat): Default: StockSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockSnapshotTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +venue=venue, +format_=format_, + + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + +def sync( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotTradeVenue = StockSnapshotTradeVenue.NQB, + format_: Unset | StockSnapshotTradeFormat = StockSnapshotTradeFormat.JSON, + +) -> list[StockSnapshotTradeResponse200Item] | None: + """ Trade + + + Returns a real-time last trade from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if + the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotTradeVenue): Default: StockSnapshotTradeVenue.NQB. + format_ (Unset | StockSnapshotTradeFormat): Default: StockSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockSnapshotTradeResponse200Item] + """ + + + return sync_detailed( + client=client, +symbol=symbol, +venue=venue, +format_=format_, + + ).parsed + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotTradeVenue = StockSnapshotTradeVenue.NQB, + format_: Unset | StockSnapshotTradeFormat = StockSnapshotTradeFormat.JSON, + +) -> Response[list[StockSnapshotTradeResponse200Item]]: + """ Trade + + + Returns a real-time last trade from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if + the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotTradeVenue): Default: StockSnapshotTradeVenue.NQB. + format_ (Unset | StockSnapshotTradeFormat): Default: StockSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[StockSnapshotTradeResponse200Item]] + """ + + + kwargs = _get_kwargs( + symbol=symbol, +venue=venue, +format_=format_, + + ) + + response = await client.get_async_httpx_client().request( + **kwargs + ) + + return _build_response(client=client, response=response) + +async def asyncio( + *, + client: AuthenticatedClient | Client, + symbol: list[str], + venue: Unset | StockSnapshotTradeVenue = StockSnapshotTradeVenue.NQB, + format_: Unset | StockSnapshotTradeFormat = StockSnapshotTradeFormat.JSON, + +) -> list[StockSnapshotTradeResponse200Item] | None: + """ Trade + + + Returns a real-time last trade from the [Nasdaq Basic feed](/Articles/Data-And-Requests/The-SIPs) if + the account has a [stocks standard or pro + subscription](https://www.thetadata.net/subscribe.html#stocks). + + - ThetaData resets its snapshot cache at midnight ET every day. This endpoint may not work on a + weekend where there were no eligible messages sent over exchange feeds. We recommend using historic + requests during the weekend. + + Args: + symbol (list[str]): + venue (Unset | StockSnapshotTradeVenue): Default: StockSnapshotTradeVenue.NQB. + format_ (Unset | StockSnapshotTradeFormat): Default: StockSnapshotTradeFormat.JSON. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[StockSnapshotTradeResponse200Item] + """ + + + return (await asyncio_detailed( + client=client, +symbol=symbol, +venue=venue, +format_=format_, + + )).parsed diff --git a/openapi_project/openapi_package/client.py b/openapi_project/openapi_package/client.py new file mode 100644 index 000000000..4b89354a4 --- /dev/null +++ b/openapi_project/openapi_package/client.py @@ -0,0 +1,271 @@ +import ssl +from typing import Any + +from attrs import define, field, evolve +import httpx + + + + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) + + def with_headers(self, headers: dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + diff --git a/openapi_project/openapi_package/errors.py b/openapi_project/openapi_package/errors.py new file mode 100644 index 000000000..ce027c6b0 --- /dev/null +++ b/openapi_project/openapi_package/errors.py @@ -0,0 +1,16 @@ +""" Contains shared errors types that can be raised from API functions """ + +from __future__ import annotations + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + +__all__ = ["UnexpectedStatus"] diff --git a/openapi_project/openapi_package/models/__init__.py b/openapi_project/openapi_package/models/__init__.py new file mode 100644 index 000000000..b3aac17b2 --- /dev/null +++ b/openapi_project/openapi_package/models/__init__.py @@ -0,0 +1,349 @@ +""" Contains all the data models used in inputs/outputs """ + +from openapi_project.openapi_package.models.index_at_time_price_format import IndexAtTimePriceFormat +from openapi_project.openapi_package.models.index_at_time_price_response_200_item import IndexAtTimePriceResponse200Item +from openapi_project.openapi_package.models.index_history_eod_format import IndexHistoryEodFormat +from openapi_project.openapi_package.models.index_history_eod_response_200_item import IndexHistoryEodResponse200Item +from openapi_project.openapi_package.models.index_history_ohlc_format import IndexHistoryOhlcFormat +from openapi_project.openapi_package.models.index_history_ohlc_interval import IndexHistoryOhlcInterval +from openapi_project.openapi_package.models.index_history_ohlc_response_200_item import IndexHistoryOhlcResponse200Item +from openapi_project.openapi_package.models.index_history_price_format import IndexHistoryPriceFormat +from openapi_project.openapi_package.models.index_history_price_interval import IndexHistoryPriceInterval +from openapi_project.openapi_package.models.index_history_price_response_200_item import IndexHistoryPriceResponse200Item +from openapi_project.openapi_package.models.index_list_dates_format import IndexListDatesFormat +from openapi_project.openapi_package.models.index_list_dates_response_200_item import IndexListDatesResponse200Item +from openapi_project.openapi_package.models.index_list_symbols_format import IndexListSymbolsFormat +from openapi_project.openapi_package.models.index_list_symbols_response_200_item import IndexListSymbolsResponse200Item +from openapi_project.openapi_package.models.index_snapshot_ohlc_format import IndexSnapshotOhlcFormat +from openapi_project.openapi_package.models.index_snapshot_ohlc_response_200_item import IndexSnapshotOhlcResponse200Item +from openapi_project.openapi_package.models.index_snapshot_price_format import IndexSnapshotPriceFormat +from openapi_project.openapi_package.models.index_snapshot_price_response_200_item import IndexSnapshotPriceResponse200Item +from openapi_project.openapi_package.models.option_at_time_quote_format import OptionAtTimeQuoteFormat +from openapi_project.openapi_package.models.option_at_time_quote_response_200_item import OptionAtTimeQuoteResponse200Item +from openapi_project.openapi_package.models.option_at_time_quote_right import OptionAtTimeQuoteRight +from openapi_project.openapi_package.models.option_at_time_trade_format import OptionAtTimeTradeFormat +from openapi_project.openapi_package.models.option_at_time_trade_response_200_item import OptionAtTimeTradeResponse200Item +from openapi_project.openapi_package.models.option_at_time_trade_right import OptionAtTimeTradeRight +from openapi_project.openapi_package.models.option_history_eod_format import OptionHistoryEodFormat +from openapi_project.openapi_package.models.option_history_eod_response_200_item import OptionHistoryEodResponse200Item +from openapi_project.openapi_package.models.option_history_eod_right import OptionHistoryEodRight +from openapi_project.openapi_package.models.option_history_greeks_all_format import OptionHistoryGreeksAllFormat +from openapi_project.openapi_package.models.option_history_greeks_all_interval import OptionHistoryGreeksAllInterval +from openapi_project.openapi_package.models.option_history_greeks_all_rate_type import OptionHistoryGreeksAllRateType +from openapi_project.openapi_package.models.option_history_greeks_all_response_200_item import OptionHistoryGreeksAllResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_all_right import OptionHistoryGreeksAllRight +from openapi_project.openapi_package.models.option_history_greeks_eod_format import OptionHistoryGreeksEodFormat +from openapi_project.openapi_package.models.option_history_greeks_eod_rate_type import OptionHistoryGreeksEodRateType +from openapi_project.openapi_package.models.option_history_greeks_eod_response_200_item import OptionHistoryGreeksEodResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_eod_right import OptionHistoryGreeksEodRight +from openapi_project.openapi_package.models.option_history_greeks_first_order_format import OptionHistoryGreeksFirstOrderFormat +from openapi_project.openapi_package.models.option_history_greeks_first_order_interval import OptionHistoryGreeksFirstOrderInterval +from openapi_project.openapi_package.models.option_history_greeks_first_order_rate_type import OptionHistoryGreeksFirstOrderRateType +from openapi_project.openapi_package.models.option_history_greeks_first_order_response_200_item import OptionHistoryGreeksFirstOrderResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_first_order_right import OptionHistoryGreeksFirstOrderRight +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_format import OptionHistoryGreeksImpliedVolatilityFormat +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_interval import OptionHistoryGreeksImpliedVolatilityInterval +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_rate_type import OptionHistoryGreeksImpliedVolatilityRateType +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_response_200_item import OptionHistoryGreeksImpliedVolatilityResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_implied_volatility_right import OptionHistoryGreeksImpliedVolatilityRight +from openapi_project.openapi_package.models.option_history_greeks_second_order_format import OptionHistoryGreeksSecondOrderFormat +from openapi_project.openapi_package.models.option_history_greeks_second_order_interval import OptionHistoryGreeksSecondOrderInterval +from openapi_project.openapi_package.models.option_history_greeks_second_order_rate_type import OptionHistoryGreeksSecondOrderRateType +from openapi_project.openapi_package.models.option_history_greeks_second_order_response_200_item import OptionHistoryGreeksSecondOrderResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_second_order_right import OptionHistoryGreeksSecondOrderRight +from openapi_project.openapi_package.models.option_history_greeks_third_order_format import OptionHistoryGreeksThirdOrderFormat +from openapi_project.openapi_package.models.option_history_greeks_third_order_interval import OptionHistoryGreeksThirdOrderInterval +from openapi_project.openapi_package.models.option_history_greeks_third_order_rate_type import OptionHistoryGreeksThirdOrderRateType +from openapi_project.openapi_package.models.option_history_greeks_third_order_response_200_item import OptionHistoryGreeksThirdOrderResponse200Item +from openapi_project.openapi_package.models.option_history_greeks_third_order_right import OptionHistoryGreeksThirdOrderRight +from openapi_project.openapi_package.models.option_history_ohlc_format import OptionHistoryOhlcFormat +from openapi_project.openapi_package.models.option_history_ohlc_interval import OptionHistoryOhlcInterval +from openapi_project.openapi_package.models.option_history_ohlc_response_200_item import OptionHistoryOhlcResponse200Item +from openapi_project.openapi_package.models.option_history_ohlc_right import OptionHistoryOhlcRight +from openapi_project.openapi_package.models.option_history_open_interest_format import OptionHistoryOpenInterestFormat +from openapi_project.openapi_package.models.option_history_open_interest_response_200_item import OptionHistoryOpenInterestResponse200Item +from openapi_project.openapi_package.models.option_history_open_interest_right import OptionHistoryOpenInterestRight +from openapi_project.openapi_package.models.option_history_quote_format import OptionHistoryQuoteFormat +from openapi_project.openapi_package.models.option_history_quote_interval import OptionHistoryQuoteInterval +from openapi_project.openapi_package.models.option_history_quote_response_200_item import OptionHistoryQuoteResponse200Item +from openapi_project.openapi_package.models.option_history_quote_right import OptionHistoryQuoteRight +from openapi_project.openapi_package.models.option_history_trade_format import OptionHistoryTradeFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_all_format import OptionHistoryTradeGreeksAllFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_all_rate_type import OptionHistoryTradeGreeksAllRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_all_response_200_item import OptionHistoryTradeGreeksAllResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_all_right import OptionHistoryTradeGreeksAllRight +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_format import OptionHistoryTradeGreeksFirstOrderFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_rate_type import OptionHistoryTradeGreeksFirstOrderRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_response_200_item import OptionHistoryTradeGreeksFirstOrderResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_first_order_right import OptionHistoryTradeGreeksFirstOrderRight +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_format import OptionHistoryTradeGreeksImpliedVolatilityFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_rate_type import OptionHistoryTradeGreeksImpliedVolatilityRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_response_200_item import OptionHistoryTradeGreeksImpliedVolatilityResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_implied_volatility_right import OptionHistoryTradeGreeksImpliedVolatilityRight +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_format import OptionHistoryTradeGreeksSecondOrderFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_rate_type import OptionHistoryTradeGreeksSecondOrderRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_response_200_item import OptionHistoryTradeGreeksSecondOrderResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_second_order_right import OptionHistoryTradeGreeksSecondOrderRight +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_format import OptionHistoryTradeGreeksThirdOrderFormat +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_rate_type import OptionHistoryTradeGreeksThirdOrderRateType +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_response_200_item import OptionHistoryTradeGreeksThirdOrderResponse200Item +from openapi_project.openapi_package.models.option_history_trade_greeks_third_order_right import OptionHistoryTradeGreeksThirdOrderRight +from openapi_project.openapi_package.models.option_history_trade_quote_format import OptionHistoryTradeQuoteFormat +from openapi_project.openapi_package.models.option_history_trade_quote_response_200_item import OptionHistoryTradeQuoteResponse200Item +from openapi_project.openapi_package.models.option_history_trade_quote_right import OptionHistoryTradeQuoteRight +from openapi_project.openapi_package.models.option_history_trade_response_200_item import OptionHistoryTradeResponse200Item +from openapi_project.openapi_package.models.option_history_trade_right import OptionHistoryTradeRight +from openapi_project.openapi_package.models.option_list_contracts_format import OptionListContractsFormat +from openapi_project.openapi_package.models.option_list_contracts_request_type import OptionListContractsRequestType +from openapi_project.openapi_package.models.option_list_contracts_response_200_item import OptionListContractsResponse200Item +from openapi_project.openapi_package.models.option_list_dates_format import OptionListDatesFormat +from openapi_project.openapi_package.models.option_list_dates_request_type import OptionListDatesRequestType +from openapi_project.openapi_package.models.option_list_dates_response_200_item import OptionListDatesResponse200Item +from openapi_project.openapi_package.models.option_list_dates_right import OptionListDatesRight +from openapi_project.openapi_package.models.option_list_expirations_format import OptionListExpirationsFormat +from openapi_project.openapi_package.models.option_list_expirations_response_200_item import OptionListExpirationsResponse200Item +from openapi_project.openapi_package.models.option_list_strikes_format import OptionListStrikesFormat +from openapi_project.openapi_package.models.option_list_strikes_response_200_item import OptionListStrikesResponse200Item +from openapi_project.openapi_package.models.option_list_symbols_format import OptionListSymbolsFormat +from openapi_project.openapi_package.models.option_list_symbols_response_200_item import OptionListSymbolsResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_all_format import OptionSnapshotGreeksAllFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_all_rate_type import OptionSnapshotGreeksAllRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_all_response_200_item import OptionSnapshotGreeksAllResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_all_right import OptionSnapshotGreeksAllRight +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_format import OptionSnapshotGreeksFirstOrderFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_rate_type import OptionSnapshotGreeksFirstOrderRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_response_200_item import OptionSnapshotGreeksFirstOrderResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_first_order_right import OptionSnapshotGreeksFirstOrderRight +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_format import OptionSnapshotGreeksImpliedVolatilityFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_rate_type import OptionSnapshotGreeksImpliedVolatilityRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_response_200_item import OptionSnapshotGreeksImpliedVolatilityResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_implied_volatility_right import OptionSnapshotGreeksImpliedVolatilityRight +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_format import OptionSnapshotGreeksSecondOrderFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_rate_type import OptionSnapshotGreeksSecondOrderRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_response_200_item import OptionSnapshotGreeksSecondOrderResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_second_order_right import OptionSnapshotGreeksSecondOrderRight +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_format import OptionSnapshotGreeksThirdOrderFormat +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_rate_type import OptionSnapshotGreeksThirdOrderRateType +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_response_200_item import OptionSnapshotGreeksThirdOrderResponse200Item +from openapi_project.openapi_package.models.option_snapshot_greeks_third_order_right import OptionSnapshotGreeksThirdOrderRight +from openapi_project.openapi_package.models.option_snapshot_ohlc_format import OptionSnapshotOhlcFormat +from openapi_project.openapi_package.models.option_snapshot_ohlc_response_200_item import OptionSnapshotOhlcResponse200Item +from openapi_project.openapi_package.models.option_snapshot_ohlc_right import OptionSnapshotOhlcRight +from openapi_project.openapi_package.models.option_snapshot_open_interest_format import OptionSnapshotOpenInterestFormat +from openapi_project.openapi_package.models.option_snapshot_open_interest_response_200_item import OptionSnapshotOpenInterestResponse200Item +from openapi_project.openapi_package.models.option_snapshot_open_interest_right import OptionSnapshotOpenInterestRight +from openapi_project.openapi_package.models.option_snapshot_quote_format import OptionSnapshotQuoteFormat +from openapi_project.openapi_package.models.option_snapshot_quote_response_200_item import OptionSnapshotQuoteResponse200Item +from openapi_project.openapi_package.models.option_snapshot_quote_right import OptionSnapshotQuoteRight +from openapi_project.openapi_package.models.option_snapshot_trade_format import OptionSnapshotTradeFormat +from openapi_project.openapi_package.models.option_snapshot_trade_response_200_item import OptionSnapshotTradeResponse200Item +from openapi_project.openapi_package.models.option_snapshot_trade_right import OptionSnapshotTradeRight +from openapi_project.openapi_package.models.stock_at_time_quote_format import StockAtTimeQuoteFormat +from openapi_project.openapi_package.models.stock_at_time_quote_response_200_item import StockAtTimeQuoteResponse200Item +from openapi_project.openapi_package.models.stock_at_time_quote_venue import StockAtTimeQuoteVenue +from openapi_project.openapi_package.models.stock_at_time_trade_format import StockAtTimeTradeFormat +from openapi_project.openapi_package.models.stock_at_time_trade_response_200_item import StockAtTimeTradeResponse200Item +from openapi_project.openapi_package.models.stock_at_time_trade_venue import StockAtTimeTradeVenue +from openapi_project.openapi_package.models.stock_history_eod_format import StockHistoryEodFormat +from openapi_project.openapi_package.models.stock_history_eod_response_200_item import StockHistoryEodResponse200Item +from openapi_project.openapi_package.models.stock_history_ohlc_format import StockHistoryOhlcFormat +from openapi_project.openapi_package.models.stock_history_ohlc_interval import StockHistoryOhlcInterval +from openapi_project.openapi_package.models.stock_history_ohlc_response_200_item import StockHistoryOhlcResponse200Item +from openapi_project.openapi_package.models.stock_history_ohlc_venue import StockHistoryOhlcVenue +from openapi_project.openapi_package.models.stock_history_quote_format import StockHistoryQuoteFormat +from openapi_project.openapi_package.models.stock_history_quote_interval import StockHistoryQuoteInterval +from openapi_project.openapi_package.models.stock_history_quote_response_200_item import StockHistoryQuoteResponse200Item +from openapi_project.openapi_package.models.stock_history_quote_venue import StockHistoryQuoteVenue +from openapi_project.openapi_package.models.stock_history_trade_format import StockHistoryTradeFormat +from openapi_project.openapi_package.models.stock_history_trade_quote_format import StockHistoryTradeQuoteFormat +from openapi_project.openapi_package.models.stock_history_trade_quote_venue import StockHistoryTradeQuoteVenue +from openapi_project.openapi_package.models.stock_history_trade_venue import StockHistoryTradeVenue +from openapi_project.openapi_package.models.stock_list_dates_format import StockListDatesFormat +from openapi_project.openapi_package.models.stock_list_dates_request_type import StockListDatesRequestType +from openapi_project.openapi_package.models.stock_list_dates_response_200_item import StockListDatesResponse200Item +from openapi_project.openapi_package.models.stock_list_symbols_format import StockListSymbolsFormat +from openapi_project.openapi_package.models.stock_list_symbols_response_200_item import StockListSymbolsResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_ohlc_format import StockSnapshotOhlcFormat +from openapi_project.openapi_package.models.stock_snapshot_ohlc_response_200_item import StockSnapshotOhlcResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_ohlc_venue import StockSnapshotOhlcVenue +from openapi_project.openapi_package.models.stock_snapshot_quote_format import StockSnapshotQuoteFormat +from openapi_project.openapi_package.models.stock_snapshot_quote_response_200_item import StockSnapshotQuoteResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_quote_venue import StockSnapshotQuoteVenue +from openapi_project.openapi_package.models.stock_snapshot_trade_format import StockSnapshotTradeFormat +from openapi_project.openapi_package.models.stock_snapshot_trade_response_200_item import StockSnapshotTradeResponse200Item +from openapi_project.openapi_package.models.stock_snapshot_trade_venue import StockSnapshotTradeVenue + +__all__ = ( + "IndexAtTimePriceFormat", + "IndexAtTimePriceResponse200Item", + "IndexHistoryEodFormat", + "IndexHistoryEodResponse200Item", + "IndexHistoryOhlcFormat", + "IndexHistoryOhlcInterval", + "IndexHistoryOhlcResponse200Item", + "IndexHistoryPriceFormat", + "IndexHistoryPriceInterval", + "IndexHistoryPriceResponse200Item", + "IndexListDatesFormat", + "IndexListDatesResponse200Item", + "IndexListSymbolsFormat", + "IndexListSymbolsResponse200Item", + "IndexSnapshotOhlcFormat", + "IndexSnapshotOhlcResponse200Item", + "IndexSnapshotPriceFormat", + "IndexSnapshotPriceResponse200Item", + "OptionAtTimeQuoteFormat", + "OptionAtTimeQuoteResponse200Item", + "OptionAtTimeQuoteRight", + "OptionAtTimeTradeFormat", + "OptionAtTimeTradeResponse200Item", + "OptionAtTimeTradeRight", + "OptionHistoryEodFormat", + "OptionHistoryEodResponse200Item", + "OptionHistoryEodRight", + "OptionHistoryGreeksAllFormat", + "OptionHistoryGreeksAllInterval", + "OptionHistoryGreeksAllRateType", + "OptionHistoryGreeksAllResponse200Item", + "OptionHistoryGreeksAllRight", + "OptionHistoryGreeksEodFormat", + "OptionHistoryGreeksEodRateType", + "OptionHistoryGreeksEodResponse200Item", + "OptionHistoryGreeksEodRight", + "OptionHistoryGreeksFirstOrderFormat", + "OptionHistoryGreeksFirstOrderInterval", + "OptionHistoryGreeksFirstOrderRateType", + "OptionHistoryGreeksFirstOrderResponse200Item", + "OptionHistoryGreeksFirstOrderRight", + "OptionHistoryGreeksImpliedVolatilityFormat", + "OptionHistoryGreeksImpliedVolatilityInterval", + "OptionHistoryGreeksImpliedVolatilityRateType", + "OptionHistoryGreeksImpliedVolatilityResponse200Item", + "OptionHistoryGreeksImpliedVolatilityRight", + "OptionHistoryGreeksSecondOrderFormat", + "OptionHistoryGreeksSecondOrderInterval", + "OptionHistoryGreeksSecondOrderRateType", + "OptionHistoryGreeksSecondOrderResponse200Item", + "OptionHistoryGreeksSecondOrderRight", + "OptionHistoryGreeksThirdOrderFormat", + "OptionHistoryGreeksThirdOrderInterval", + "OptionHistoryGreeksThirdOrderRateType", + "OptionHistoryGreeksThirdOrderResponse200Item", + "OptionHistoryGreeksThirdOrderRight", + "OptionHistoryOhlcFormat", + "OptionHistoryOhlcInterval", + "OptionHistoryOhlcResponse200Item", + "OptionHistoryOhlcRight", + "OptionHistoryOpenInterestFormat", + "OptionHistoryOpenInterestResponse200Item", + "OptionHistoryOpenInterestRight", + "OptionHistoryQuoteFormat", + "OptionHistoryQuoteInterval", + "OptionHistoryQuoteResponse200Item", + "OptionHistoryQuoteRight", + "OptionHistoryTradeFormat", + "OptionHistoryTradeGreeksAllFormat", + "OptionHistoryTradeGreeksAllRateType", + "OptionHistoryTradeGreeksAllResponse200Item", + "OptionHistoryTradeGreeksAllRight", + "OptionHistoryTradeGreeksFirstOrderFormat", + "OptionHistoryTradeGreeksFirstOrderRateType", + "OptionHistoryTradeGreeksFirstOrderResponse200Item", + "OptionHistoryTradeGreeksFirstOrderRight", + "OptionHistoryTradeGreeksImpliedVolatilityFormat", + "OptionHistoryTradeGreeksImpliedVolatilityRateType", + "OptionHistoryTradeGreeksImpliedVolatilityResponse200Item", + "OptionHistoryTradeGreeksImpliedVolatilityRight", + "OptionHistoryTradeGreeksSecondOrderFormat", + "OptionHistoryTradeGreeksSecondOrderRateType", + "OptionHistoryTradeGreeksSecondOrderResponse200Item", + "OptionHistoryTradeGreeksSecondOrderRight", + "OptionHistoryTradeGreeksThirdOrderFormat", + "OptionHistoryTradeGreeksThirdOrderRateType", + "OptionHistoryTradeGreeksThirdOrderResponse200Item", + "OptionHistoryTradeGreeksThirdOrderRight", + "OptionHistoryTradeQuoteFormat", + "OptionHistoryTradeQuoteResponse200Item", + "OptionHistoryTradeQuoteRight", + "OptionHistoryTradeResponse200Item", + "OptionHistoryTradeRight", + "OptionListContractsFormat", + "OptionListContractsRequestType", + "OptionListContractsResponse200Item", + "OptionListDatesFormat", + "OptionListDatesRequestType", + "OptionListDatesResponse200Item", + "OptionListDatesRight", + "OptionListExpirationsFormat", + "OptionListExpirationsResponse200Item", + "OptionListStrikesFormat", + "OptionListStrikesResponse200Item", + "OptionListSymbolsFormat", + "OptionListSymbolsResponse200Item", + "OptionSnapshotGreeksAllFormat", + "OptionSnapshotGreeksAllRateType", + "OptionSnapshotGreeksAllResponse200Item", + "OptionSnapshotGreeksAllRight", + "OptionSnapshotGreeksFirstOrderFormat", + "OptionSnapshotGreeksFirstOrderRateType", + "OptionSnapshotGreeksFirstOrderResponse200Item", + "OptionSnapshotGreeksFirstOrderRight", + "OptionSnapshotGreeksImpliedVolatilityFormat", + "OptionSnapshotGreeksImpliedVolatilityRateType", + "OptionSnapshotGreeksImpliedVolatilityResponse200Item", + "OptionSnapshotGreeksImpliedVolatilityRight", + "OptionSnapshotGreeksSecondOrderFormat", + "OptionSnapshotGreeksSecondOrderRateType", + "OptionSnapshotGreeksSecondOrderResponse200Item", + "OptionSnapshotGreeksSecondOrderRight", + "OptionSnapshotGreeksThirdOrderFormat", + "OptionSnapshotGreeksThirdOrderRateType", + "OptionSnapshotGreeksThirdOrderResponse200Item", + "OptionSnapshotGreeksThirdOrderRight", + "OptionSnapshotOhlcFormat", + "OptionSnapshotOhlcResponse200Item", + "OptionSnapshotOhlcRight", + "OptionSnapshotOpenInterestFormat", + "OptionSnapshotOpenInterestResponse200Item", + "OptionSnapshotOpenInterestRight", + "OptionSnapshotQuoteFormat", + "OptionSnapshotQuoteResponse200Item", + "OptionSnapshotQuoteRight", + "OptionSnapshotTradeFormat", + "OptionSnapshotTradeResponse200Item", + "OptionSnapshotTradeRight", + "StockAtTimeQuoteFormat", + "StockAtTimeQuoteResponse200Item", + "StockAtTimeQuoteVenue", + "StockAtTimeTradeFormat", + "StockAtTimeTradeResponse200Item", + "StockAtTimeTradeVenue", + "StockHistoryEodFormat", + "StockHistoryEodResponse200Item", + "StockHistoryOhlcFormat", + "StockHistoryOhlcInterval", + "StockHistoryOhlcResponse200Item", + "StockHistoryOhlcVenue", + "StockHistoryQuoteFormat", + "StockHistoryQuoteInterval", + "StockHistoryQuoteResponse200Item", + "StockHistoryQuoteVenue", + "StockHistoryTradeFormat", + "StockHistoryTradeQuoteFormat", + "StockHistoryTradeQuoteVenue", + "StockHistoryTradeVenue", + "StockListDatesFormat", + "StockListDatesRequestType", + "StockListDatesResponse200Item", + "StockListSymbolsFormat", + "StockListSymbolsResponse200Item", + "StockSnapshotOhlcFormat", + "StockSnapshotOhlcResponse200Item", + "StockSnapshotOhlcVenue", + "StockSnapshotQuoteFormat", + "StockSnapshotQuoteResponse200Item", + "StockSnapshotQuoteVenue", + "StockSnapshotTradeFormat", + "StockSnapshotTradeResponse200Item", + "StockSnapshotTradeVenue", +) diff --git a/openapi_project/openapi_package/models/index_at_time_price_format.py b/openapi_project/openapi_package/models/index_at_time_price_format.py new file mode 100644 index 000000000..158ad4958 --- /dev/null +++ b/openapi_project/openapi_package/models/index_at_time_price_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexAtTimePriceFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_at_time_price_response_200_item.py b/openapi_project/openapi_package/models/index_at_time_price_response_200_item.py new file mode 100644 index 000000000..f30bee935 --- /dev/null +++ b/openapi_project/openapi_package/models/index_at_time_price_response_200_item.py @@ -0,0 +1,152 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexAtTimePriceResponse200Item") + + + +@_attrs_define +class IndexAtTimePriceResponse200Item: + """ + Attributes: + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + timestamp (str): + """ + + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + ext_condition4: int + exchange: int + ext_condition3: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + timestamp = d.pop("timestamp") + + index_at_time_price_response_200_item = cls( + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + timestamp=timestamp, + ) + + + + index_at_time_price_response_200_item.additional_properties = d + return index_at_time_price_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_history_eod_format.py b/openapi_project/openapi_package/models/index_history_eod_format.py new file mode 100644 index 000000000..0873f867a --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_eod_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexHistoryEodFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_history_eod_response_200_item.py b/openapi_project/openapi_package/models/index_history_eod_response_200_item.py new file mode 100644 index 000000000..a9e98c48e --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_eod_response_200_item.py @@ -0,0 +1,200 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexHistoryEodResponse200Item") + + + +@_attrs_define +class IndexHistoryEodResponse200Item: + """ + Attributes: + ask_size (int): + last_trade (str): + created (str): + ask_condition (int): + count (int): + volume (int): + high (float): + low (float): + bid_size (int): + ask_exchange (int): + bid_exchange (int): + ask (float): + bid (float): + bid_condition (int): + close (float): + open_ (float): + """ + + ask_size: int + last_trade: str + created: str + ask_condition: int + count: int + volume: int + high: float + low: float + bid_size: int + ask_exchange: int + bid_exchange: int + ask: float + bid: float + bid_condition: int + close: float + open_: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + ask_size = self.ask_size + + last_trade = self.last_trade + + created = self.created + + ask_condition = self.ask_condition + + count = self.count + + volume = self.volume + + high = self.high + + low = self.low + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + ask = self.ask + + bid = self.bid + + bid_condition = self.bid_condition + + close = self.close + + open_ = self.open_ + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "ask_size": ask_size, + "last_trade": last_trade, + "created": created, + "ask_condition": ask_condition, + "count": count, + "volume": volume, + "high": high, + "low": low, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "ask": ask, + "bid": bid, + "bid_condition": bid_condition, + "close": close, + "open": open_, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + ask_size = d.pop("ask_size") + + last_trade = d.pop("last_trade") + + created = d.pop("created") + + ask_condition = d.pop("ask_condition") + + count = d.pop("count") + + volume = d.pop("volume") + + high = d.pop("high") + + low = d.pop("low") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + close = d.pop("close") + + open_ = d.pop("open") + + index_history_eod_response_200_item = cls( + ask_size=ask_size, + last_trade=last_trade, + created=created, + ask_condition=ask_condition, + count=count, + volume=volume, + high=high, + low=low, + bid_size=bid_size, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + ask=ask, + bid=bid, + bid_condition=bid_condition, + close=close, + open_=open_, + ) + + + + index_history_eod_response_200_item.additional_properties = d + return index_history_eod_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_history_ohlc_format.py b/openapi_project/openapi_package/models/index_history_ohlc_format.py new file mode 100644 index 000000000..d960523e6 --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_ohlc_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexHistoryOhlcFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_history_ohlc_interval.py b/openapi_project/openapi_package/models/index_history_ohlc_interval.py new file mode 100644 index 000000000..8eda6530f --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_ohlc_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class IndexHistoryOhlcInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_history_ohlc_response_200_item.py b/openapi_project/openapi_package/models/index_history_ohlc_response_200_item.py new file mode 100644 index 000000000..ac472bf0e --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_ohlc_response_200_item.py @@ -0,0 +1,136 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexHistoryOhlcResponse200Item") + + + +@_attrs_define +class IndexHistoryOhlcResponse200Item: + """ + Attributes: + volume (int): + high (float): + low (float): + vwap (float): + count (int): + close (float): + open_ (float): + timestamp (str): + """ + + volume: int + high: float + low: float + vwap: float + count: int + close: float + open_: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + volume = self.volume + + high = self.high + + low = self.low + + vwap = self.vwap + + count = self.count + + close = self.close + + open_ = self.open_ + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "volume": volume, + "high": high, + "low": low, + "vwap": vwap, + "count": count, + "close": close, + "open": open_, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + volume = d.pop("volume") + + high = d.pop("high") + + low = d.pop("low") + + vwap = d.pop("vwap") + + count = d.pop("count") + + close = d.pop("close") + + open_ = d.pop("open") + + timestamp = d.pop("timestamp") + + index_history_ohlc_response_200_item = cls( + volume=volume, + high=high, + low=low, + vwap=vwap, + count=count, + close=close, + open_=open_, + timestamp=timestamp, + ) + + + + index_history_ohlc_response_200_item.additional_properties = d + return index_history_ohlc_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_history_price_format.py b/openapi_project/openapi_package/models/index_history_price_format.py new file mode 100644 index 000000000..3335e6b83 --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_price_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexHistoryPriceFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_history_price_interval.py b/openapi_project/openapi_package/models/index_history_price_interval.py new file mode 100644 index 000000000..8104487f9 --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_price_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class IndexHistoryPriceInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_history_price_response_200_item.py b/openapi_project/openapi_package/models/index_history_price_response_200_item.py new file mode 100644 index 000000000..b60dd4543 --- /dev/null +++ b/openapi_project/openapi_package/models/index_history_price_response_200_item.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexHistoryPriceResponse200Item") + + + +@_attrs_define +class IndexHistoryPriceResponse200Item: + """ + Attributes: + price (float): + timestamp (str): + """ + + price: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + price = self.price + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "price": price, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + price = d.pop("price") + + timestamp = d.pop("timestamp") + + index_history_price_response_200_item = cls( + price=price, + timestamp=timestamp, + ) + + + + index_history_price_response_200_item.additional_properties = d + return index_history_price_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_list_dates_format.py b/openapi_project/openapi_package/models/index_list_dates_format.py new file mode 100644 index 000000000..d37f2e1c6 --- /dev/null +++ b/openapi_project/openapi_package/models/index_list_dates_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexListDatesFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_list_dates_response_200_item.py b/openapi_project/openapi_package/models/index_list_dates_response_200_item.py new file mode 100644 index 000000000..77a4a8ec8 --- /dev/null +++ b/openapi_project/openapi_package/models/index_list_dates_response_200_item.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexListDatesResponse200Item") + + + +@_attrs_define +class IndexListDatesResponse200Item: + """ + Attributes: + date (str): + symbol (str): + """ + + date: str + symbol: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + date = self.date + + symbol = self.symbol + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "date": date, + "symbol": symbol, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date") + + symbol = d.pop("symbol") + + index_list_dates_response_200_item = cls( + date=date, + symbol=symbol, + ) + + + + index_list_dates_response_200_item.additional_properties = d + return index_list_dates_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_list_symbols_format.py b/openapi_project/openapi_package/models/index_list_symbols_format.py new file mode 100644 index 000000000..889c630c0 --- /dev/null +++ b/openapi_project/openapi_package/models/index_list_symbols_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexListSymbolsFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_list_symbols_response_200_item.py b/openapi_project/openapi_package/models/index_list_symbols_response_200_item.py new file mode 100644 index 000000000..e695b9657 --- /dev/null +++ b/openapi_project/openapi_package/models/index_list_symbols_response_200_item.py @@ -0,0 +1,80 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexListSymbolsResponse200Item") + + + +@_attrs_define +class IndexListSymbolsResponse200Item: + """ + Attributes: + symbol (str): + """ + + symbol: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + index_list_symbols_response_200_item = cls( + symbol=symbol, + ) + + + + index_list_symbols_response_200_item.additional_properties = d + return index_list_symbols_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_snapshot_ohlc_format.py b/openapi_project/openapi_package/models/index_snapshot_ohlc_format.py new file mode 100644 index 000000000..5eaca7030 --- /dev/null +++ b/openapi_project/openapi_package/models/index_snapshot_ohlc_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexSnapshotOhlcFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_snapshot_ohlc_response_200_item.py b/openapi_project/openapi_package/models/index_snapshot_ohlc_response_200_item.py new file mode 100644 index 000000000..ea63ae759 --- /dev/null +++ b/openapi_project/openapi_package/models/index_snapshot_ohlc_response_200_item.py @@ -0,0 +1,136 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexSnapshotOhlcResponse200Item") + + + +@_attrs_define +class IndexSnapshotOhlcResponse200Item: + """ + Attributes: + volume (int): + symbol (str): + high (float): + low (float): + count (int): + close (float): + open_ (float): + timestamp (str): + """ + + volume: int + symbol: str + high: float + low: float + count: int + close: float + open_: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + volume = self.volume + + symbol = self.symbol + + high = self.high + + low = self.low + + count = self.count + + close = self.close + + open_ = self.open_ + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "volume": volume, + "symbol": symbol, + "high": high, + "low": low, + "count": count, + "close": close, + "open": open_, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + volume = d.pop("volume") + + symbol = d.pop("symbol") + + high = d.pop("high") + + low = d.pop("low") + + count = d.pop("count") + + close = d.pop("close") + + open_ = d.pop("open") + + timestamp = d.pop("timestamp") + + index_snapshot_ohlc_response_200_item = cls( + volume=volume, + symbol=symbol, + high=high, + low=low, + count=count, + close=close, + open_=open_, + timestamp=timestamp, + ) + + + + index_snapshot_ohlc_response_200_item.additional_properties = d + return index_snapshot_ohlc_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/index_snapshot_price_format.py b/openapi_project/openapi_package/models/index_snapshot_price_format.py new file mode 100644 index 000000000..84c50d2e7 --- /dev/null +++ b/openapi_project/openapi_package/models/index_snapshot_price_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class IndexSnapshotPriceFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/index_snapshot_price_response_200_item.py b/openapi_project/openapi_package/models/index_snapshot_price_response_200_item.py new file mode 100644 index 000000000..d5e5728a3 --- /dev/null +++ b/openapi_project/openapi_package/models/index_snapshot_price_response_200_item.py @@ -0,0 +1,96 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="IndexSnapshotPriceResponse200Item") + + + +@_attrs_define +class IndexSnapshotPriceResponse200Item: + """ + Attributes: + symbol (str): + price (float): + timestamp (str): + """ + + symbol: str + price: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + price = self.price + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "price": price, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + price = d.pop("price") + + timestamp = d.pop("timestamp") + + index_snapshot_price_response_200_item = cls( + symbol=symbol, + price=price, + timestamp=timestamp, + ) + + + + index_snapshot_price_response_200_item.additional_properties = d + return index_snapshot_price_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_at_time_quote_format.py b/openapi_project/openapi_package/models/option_at_time_quote_format.py new file mode 100644 index 000000000..1957b3157 --- /dev/null +++ b/openapi_project/openapi_package/models/option_at_time_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionAtTimeQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_at_time_quote_response_200_item.py b/openapi_project/openapi_package/models/option_at_time_quote_response_200_item.py new file mode 100644 index 000000000..6078bacfd --- /dev/null +++ b/openapi_project/openapi_package/models/option_at_time_quote_response_200_item.py @@ -0,0 +1,176 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionAtTimeQuoteResponse200Item") + + + +@_attrs_define +class OptionAtTimeQuoteResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + ask_condition (int): + strike (float): + right (str): + bid_size (int): + ask_exchange (int): + bid_exchange (int): + ask (float): + expiration (str): + bid (float): + bid_condition (int): + timestamp (str): + """ + + symbol: str + ask_size: int + ask_condition: int + strike: float + right: str + bid_size: int + ask_exchange: int + bid_exchange: int + ask: float + expiration: str + bid: float + bid_condition: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + ask_condition = self.ask_condition + + strike = self.strike + + right = self.right + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + ask = self.ask + + expiration = self.expiration + + bid = self.bid + + bid_condition = self.bid_condition + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "ask_condition": ask_condition, + "strike": strike, + "right": right, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "ask": ask, + "expiration": expiration, + "bid": bid, + "bid_condition": bid_condition, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + ask_condition = d.pop("ask_condition") + + strike = d.pop("strike") + + right = d.pop("right") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + timestamp = d.pop("timestamp") + + option_at_time_quote_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + ask_condition=ask_condition, + strike=strike, + right=right, + bid_size=bid_size, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + ask=ask, + expiration=expiration, + bid=bid, + bid_condition=bid_condition, + timestamp=timestamp, + ) + + + + option_at_time_quote_response_200_item.additional_properties = d + return option_at_time_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_at_time_quote_right.py b/openapi_project/openapi_package/models/option_at_time_quote_right.py new file mode 100644 index 000000000..7999fd8c9 --- /dev/null +++ b/openapi_project/openapi_package/models/option_at_time_quote_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionAtTimeQuoteRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_at_time_trade_format.py b/openapi_project/openapi_package/models/option_at_time_trade_format.py new file mode 100644 index 000000000..62f02e761 --- /dev/null +++ b/openapi_project/openapi_package/models/option_at_time_trade_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionAtTimeTradeFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_at_time_trade_response_200_item.py b/openapi_project/openapi_package/models/option_at_time_trade_response_200_item.py new file mode 100644 index 000000000..1d627983d --- /dev/null +++ b/openapi_project/openapi_package/models/option_at_time_trade_response_200_item.py @@ -0,0 +1,184 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionAtTimeTradeResponse200Item") + + + +@_attrs_define +class OptionAtTimeTradeResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + right (str): + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + timestamp (str): + """ + + symbol: str + strike: float + right: str + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + right = self.right + + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + "right": right, + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + right = d.pop("right") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + timestamp = d.pop("timestamp") + + option_at_time_trade_response_200_item = cls( + symbol=symbol, + strike=strike, + right=right, + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + timestamp=timestamp, + ) + + + + option_at_time_trade_response_200_item.additional_properties = d + return option_at_time_trade_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_at_time_trade_right.py b/openapi_project/openapi_package/models/option_at_time_trade_right.py new file mode 100644 index 000000000..e7382eb6e --- /dev/null +++ b/openapi_project/openapi_package/models/option_at_time_trade_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionAtTimeTradeRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_eod_format.py b/openapi_project/openapi_package/models/option_history_eod_format.py new file mode 100644 index 000000000..273820f2c --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_eod_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryEodFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_eod_response_200_item.py b/openapi_project/openapi_package/models/option_history_eod_response_200_item.py new file mode 100644 index 000000000..7187d4cb1 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_eod_response_200_item.py @@ -0,0 +1,232 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryEodResponse200Item") + + + +@_attrs_define +class OptionHistoryEodResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + last_trade (str): + created (str): + ask_condition (int): + strike (float): + count (int): + right (str): + volume (int): + high (float): + low (float): + bid_size (int): + ask_exchange (int): + bid_exchange (int): + ask (float): + expiration (str): + bid (float): + bid_condition (int): + close (float): + open_ (float): + """ + + symbol: str + ask_size: int + last_trade: str + created: str + ask_condition: int + strike: float + count: int + right: str + volume: int + high: float + low: float + bid_size: int + ask_exchange: int + bid_exchange: int + ask: float + expiration: str + bid: float + bid_condition: int + close: float + open_: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + last_trade = self.last_trade + + created = self.created + + ask_condition = self.ask_condition + + strike = self.strike + + count = self.count + + right = self.right + + volume = self.volume + + high = self.high + + low = self.low + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + ask = self.ask + + expiration = self.expiration + + bid = self.bid + + bid_condition = self.bid_condition + + close = self.close + + open_ = self.open_ + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "last_trade": last_trade, + "created": created, + "ask_condition": ask_condition, + "strike": strike, + "count": count, + "right": right, + "volume": volume, + "high": high, + "low": low, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "ask": ask, + "expiration": expiration, + "bid": bid, + "bid_condition": bid_condition, + "close": close, + "open": open_, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + last_trade = d.pop("last_trade") + + created = d.pop("created") + + ask_condition = d.pop("ask_condition") + + strike = d.pop("strike") + + count = d.pop("count") + + right = d.pop("right") + + volume = d.pop("volume") + + high = d.pop("high") + + low = d.pop("low") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + close = d.pop("close") + + open_ = d.pop("open") + + option_history_eod_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + last_trade=last_trade, + created=created, + ask_condition=ask_condition, + strike=strike, + count=count, + right=right, + volume=volume, + high=high, + low=low, + bid_size=bid_size, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + ask=ask, + expiration=expiration, + bid=bid, + bid_condition=bid_condition, + close=close, + open_=open_, + ) + + + + option_history_eod_response_200_item.additional_properties = d + return option_history_eod_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_eod_right.py b/openapi_project/openapi_package/models/option_history_eod_right.py new file mode 100644 index 000000000..f16a3916a --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_eod_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryEodRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_all_format.py b/openapi_project/openapi_package/models/option_history_greeks_all_format.py new file mode 100644 index 000000000..c7db86d56 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_all_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryGreeksAllFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_all_interval.py b/openapi_project/openapi_package/models/option_history_greeks_all_interval.py new file mode 100644 index 000000000..86fcb2505 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_all_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryGreeksAllInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_all_rate_type.py b/openapi_project/openapi_package/models/option_history_greeks_all_rate_type.py new file mode 100644 index 000000000..24d58ccba --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_all_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryGreeksAllRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_all_response_200_item.py b/openapi_project/openapi_package/models/option_history_greeks_all_response_200_item.py new file mode 100644 index 000000000..a445936ba --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_all_response_200_item.py @@ -0,0 +1,320 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryGreeksAllResponse200Item") + + + +@_attrs_define +class OptionHistoryGreeksAllResponse200Item: + """ + Attributes: + symbol (str): + dual_delta (float): + color (float): + zomma (float): + delta (float): + implied_vol (float): + theta (float): + d1 (float): + speed (float): + d2 (float): + epsilon (float): + lambda_ (float): + vomma (float): + underlying_timestamp (str): + timestamp (str): + underlying_price (float): + strike (float): + vera (float): + right (str): + veta (float): + iv_error (float): + ultima (float): + charm (float): + ask (float): + rho (float): + expiration (str): + vanna (float): + dual_gamma (float): + bid (float): + vega (float): + gamma (float): + """ + + symbol: str + dual_delta: float + color: float + zomma: float + delta: float + implied_vol: float + theta: float + d1: float + speed: float + d2: float + epsilon: float + lambda_: float + vomma: float + underlying_timestamp: str + timestamp: str + underlying_price: float + strike: float + vera: float + right: str + veta: float + iv_error: float + ultima: float + charm: float + ask: float + rho: float + expiration: str + vanna: float + dual_gamma: float + bid: float + vega: float + gamma: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + dual_delta = self.dual_delta + + color = self.color + + zomma = self.zomma + + delta = self.delta + + implied_vol = self.implied_vol + + theta = self.theta + + d1 = self.d1 + + speed = self.speed + + d2 = self.d2 + + epsilon = self.epsilon + + lambda_ = self.lambda_ + + vomma = self.vomma + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + underlying_price = self.underlying_price + + strike = self.strike + + vera = self.vera + + right = self.right + + veta = self.veta + + iv_error = self.iv_error + + ultima = self.ultima + + charm = self.charm + + ask = self.ask + + rho = self.rho + + expiration = self.expiration + + vanna = self.vanna + + dual_gamma = self.dual_gamma + + bid = self.bid + + vega = self.vega + + gamma = self.gamma + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "dual_delta": dual_delta, + "color": color, + "zomma": zomma, + "delta": delta, + "implied_vol": implied_vol, + "theta": theta, + "d1": d1, + "speed": speed, + "d2": d2, + "epsilon": epsilon, + "lambda": lambda_, + "vomma": vomma, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + "underlying_price": underlying_price, + "strike": strike, + "vera": vera, + "right": right, + "veta": veta, + "iv_error": iv_error, + "ultima": ultima, + "charm": charm, + "ask": ask, + "rho": rho, + "expiration": expiration, + "vanna": vanna, + "dual_gamma": dual_gamma, + "bid": bid, + "vega": vega, + "gamma": gamma, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + dual_delta = d.pop("dual_delta") + + color = d.pop("color") + + zomma = d.pop("zomma") + + delta = d.pop("delta") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + d1 = d.pop("d1") + + speed = d.pop("speed") + + d2 = d.pop("d2") + + epsilon = d.pop("epsilon") + + lambda_ = d.pop("lambda") + + vomma = d.pop("vomma") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + vera = d.pop("vera") + + right = d.pop("right") + + veta = d.pop("veta") + + iv_error = d.pop("iv_error") + + ultima = d.pop("ultima") + + charm = d.pop("charm") + + ask = d.pop("ask") + + rho = d.pop("rho") + + expiration = d.pop("expiration") + + vanna = d.pop("vanna") + + dual_gamma = d.pop("dual_gamma") + + bid = d.pop("bid") + + vega = d.pop("vega") + + gamma = d.pop("gamma") + + option_history_greeks_all_response_200_item = cls( + symbol=symbol, + dual_delta=dual_delta, + color=color, + zomma=zomma, + delta=delta, + implied_vol=implied_vol, + theta=theta, + d1=d1, + speed=speed, + d2=d2, + epsilon=epsilon, + lambda_=lambda_, + vomma=vomma, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + underlying_price=underlying_price, + strike=strike, + vera=vera, + right=right, + veta=veta, + iv_error=iv_error, + ultima=ultima, + charm=charm, + ask=ask, + rho=rho, + expiration=expiration, + vanna=vanna, + dual_gamma=dual_gamma, + bid=bid, + vega=vega, + gamma=gamma, + ) + + + + option_history_greeks_all_response_200_item.additional_properties = d + return option_history_greeks_all_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_greeks_all_right.py b/openapi_project/openapi_package/models/option_history_greeks_all_right.py new file mode 100644 index 000000000..0bc111ae7 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_all_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryGreeksAllRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_eod_format.py b/openapi_project/openapi_package/models/option_history_greeks_eod_format.py new file mode 100644 index 000000000..3170d1064 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_eod_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryGreeksEodFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_eod_rate_type.py b/openapi_project/openapi_package/models/option_history_greeks_eod_rate_type.py new file mode 100644 index 000000000..546a6ce84 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_eod_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryGreeksEodRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_eod_response_200_item.py b/openapi_project/openapi_package/models/option_history_greeks_eod_response_200_item.py new file mode 100644 index 000000000..497409c16 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_eod_response_200_item.py @@ -0,0 +1,416 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryGreeksEodResponse200Item") + + + +@_attrs_define +class OptionHistoryGreeksEodResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + dual_delta (float): + color (float): + zomma (float): + delta (float): + implied_vol (float): + theta (float): + d1 (float): + speed (float): + d2 (float): + epsilon (float): + high (float): + lambda_ (float): + low (float): + ask_exchange (int): + bid_exchange (int): + vomma (float): + bid_condition (int): + underlying_timestamp (str): + close (float): + timestamp (str): + underlying_price (float): + ask_condition (int): + strike (float): + count (int): + vera (float): + right (str): + veta (float): + iv_error (float): + ultima (float): + volume (int): + charm (float): + bid_size (int): + ask (float): + rho (float): + expiration (str): + vanna (float): + dual_gamma (float): + bid (float): + open_ (float): + vega (float): + gamma (float): + """ + + symbol: str + ask_size: int + dual_delta: float + color: float + zomma: float + delta: float + implied_vol: float + theta: float + d1: float + speed: float + d2: float + epsilon: float + high: float + lambda_: float + low: float + ask_exchange: int + bid_exchange: int + vomma: float + bid_condition: int + underlying_timestamp: str + close: float + timestamp: str + underlying_price: float + ask_condition: int + strike: float + count: int + vera: float + right: str + veta: float + iv_error: float + ultima: float + volume: int + charm: float + bid_size: int + ask: float + rho: float + expiration: str + vanna: float + dual_gamma: float + bid: float + open_: float + vega: float + gamma: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + dual_delta = self.dual_delta + + color = self.color + + zomma = self.zomma + + delta = self.delta + + implied_vol = self.implied_vol + + theta = self.theta + + d1 = self.d1 + + speed = self.speed + + d2 = self.d2 + + epsilon = self.epsilon + + high = self.high + + lambda_ = self.lambda_ + + low = self.low + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + vomma = self.vomma + + bid_condition = self.bid_condition + + underlying_timestamp = self.underlying_timestamp + + close = self.close + + timestamp = self.timestamp + + underlying_price = self.underlying_price + + ask_condition = self.ask_condition + + strike = self.strike + + count = self.count + + vera = self.vera + + right = self.right + + veta = self.veta + + iv_error = self.iv_error + + ultima = self.ultima + + volume = self.volume + + charm = self.charm + + bid_size = self.bid_size + + ask = self.ask + + rho = self.rho + + expiration = self.expiration + + vanna = self.vanna + + dual_gamma = self.dual_gamma + + bid = self.bid + + open_ = self.open_ + + vega = self.vega + + gamma = self.gamma + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "dual_delta": dual_delta, + "color": color, + "zomma": zomma, + "delta": delta, + "implied_vol": implied_vol, + "theta": theta, + "d1": d1, + "speed": speed, + "d2": d2, + "epsilon": epsilon, + "high": high, + "lambda": lambda_, + "low": low, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "vomma": vomma, + "bid_condition": bid_condition, + "underlying_timestamp": underlying_timestamp, + "close": close, + "timestamp": timestamp, + "underlying_price": underlying_price, + "ask_condition": ask_condition, + "strike": strike, + "count": count, + "vera": vera, + "right": right, + "veta": veta, + "iv_error": iv_error, + "ultima": ultima, + "volume": volume, + "charm": charm, + "bid_size": bid_size, + "ask": ask, + "rho": rho, + "expiration": expiration, + "vanna": vanna, + "dual_gamma": dual_gamma, + "bid": bid, + "open": open_, + "vega": vega, + "gamma": gamma, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + dual_delta = d.pop("dual_delta") + + color = d.pop("color") + + zomma = d.pop("zomma") + + delta = d.pop("delta") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + d1 = d.pop("d1") + + speed = d.pop("speed") + + d2 = d.pop("d2") + + epsilon = d.pop("epsilon") + + high = d.pop("high") + + lambda_ = d.pop("lambda") + + low = d.pop("low") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + vomma = d.pop("vomma") + + bid_condition = d.pop("bid_condition") + + underlying_timestamp = d.pop("underlying_timestamp") + + close = d.pop("close") + + timestamp = d.pop("timestamp") + + underlying_price = d.pop("underlying_price") + + ask_condition = d.pop("ask_condition") + + strike = d.pop("strike") + + count = d.pop("count") + + vera = d.pop("vera") + + right = d.pop("right") + + veta = d.pop("veta") + + iv_error = d.pop("iv_error") + + ultima = d.pop("ultima") + + volume = d.pop("volume") + + charm = d.pop("charm") + + bid_size = d.pop("bid_size") + + ask = d.pop("ask") + + rho = d.pop("rho") + + expiration = d.pop("expiration") + + vanna = d.pop("vanna") + + dual_gamma = d.pop("dual_gamma") + + bid = d.pop("bid") + + open_ = d.pop("open") + + vega = d.pop("vega") + + gamma = d.pop("gamma") + + option_history_greeks_eod_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + dual_delta=dual_delta, + color=color, + zomma=zomma, + delta=delta, + implied_vol=implied_vol, + theta=theta, + d1=d1, + speed=speed, + d2=d2, + epsilon=epsilon, + high=high, + lambda_=lambda_, + low=low, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + vomma=vomma, + bid_condition=bid_condition, + underlying_timestamp=underlying_timestamp, + close=close, + timestamp=timestamp, + underlying_price=underlying_price, + ask_condition=ask_condition, + strike=strike, + count=count, + vera=vera, + right=right, + veta=veta, + iv_error=iv_error, + ultima=ultima, + volume=volume, + charm=charm, + bid_size=bid_size, + ask=ask, + rho=rho, + expiration=expiration, + vanna=vanna, + dual_gamma=dual_gamma, + bid=bid, + open_=open_, + vega=vega, + gamma=gamma, + ) + + + + option_history_greeks_eod_response_200_item.additional_properties = d + return option_history_greeks_eod_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_greeks_eod_right.py b/openapi_project/openapi_package/models/option_history_greeks_eod_right.py new file mode 100644 index 000000000..49602daeb --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_eod_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryGreeksEodRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_first_order_format.py b/openapi_project/openapi_package/models/option_history_greeks_first_order_format.py new file mode 100644 index 000000000..fad075173 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_first_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryGreeksFirstOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_first_order_interval.py b/openapi_project/openapi_package/models/option_history_greeks_first_order_interval.py new file mode 100644 index 000000000..d1056cc19 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_first_order_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryGreeksFirstOrderInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_first_order_rate_type.py b/openapi_project/openapi_package/models/option_history_greeks_first_order_rate_type.py new file mode 100644 index 000000000..9c36e72e9 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_first_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryGreeksFirstOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_first_order_response_200_item.py b/openapi_project/openapi_package/models/option_history_greeks_first_order_response_200_item.py new file mode 100644 index 000000000..891937d94 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_first_order_response_200_item.py @@ -0,0 +1,208 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryGreeksFirstOrderResponse200Item") + + + +@_attrs_define +class OptionHistoryGreeksFirstOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + delta (float): + right (str): + implied_vol (float): + theta (float): + iv_error (float): + epsilon (float): + lambda_ (float): + ask (float): + rho (float): + expiration (str): + bid (float): + underlying_timestamp (str): + vega (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + delta: float + right: str + implied_vol: float + theta: float + iv_error: float + epsilon: float + lambda_: float + ask: float + rho: float + expiration: str + bid: float + underlying_timestamp: str + vega: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + delta = self.delta + + right = self.right + + implied_vol = self.implied_vol + + theta = self.theta + + iv_error = self.iv_error + + epsilon = self.epsilon + + lambda_ = self.lambda_ + + ask = self.ask + + rho = self.rho + + expiration = self.expiration + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + vega = self.vega + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "delta": delta, + "right": right, + "implied_vol": implied_vol, + "theta": theta, + "iv_error": iv_error, + "epsilon": epsilon, + "lambda": lambda_, + "ask": ask, + "rho": rho, + "expiration": expiration, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "vega": vega, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + delta = d.pop("delta") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + iv_error = d.pop("iv_error") + + epsilon = d.pop("epsilon") + + lambda_ = d.pop("lambda") + + ask = d.pop("ask") + + rho = d.pop("rho") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + vega = d.pop("vega") + + timestamp = d.pop("timestamp") + + option_history_greeks_first_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + delta=delta, + right=right, + implied_vol=implied_vol, + theta=theta, + iv_error=iv_error, + epsilon=epsilon, + lambda_=lambda_, + ask=ask, + rho=rho, + expiration=expiration, + bid=bid, + underlying_timestamp=underlying_timestamp, + vega=vega, + timestamp=timestamp, + ) + + + + option_history_greeks_first_order_response_200_item.additional_properties = d + return option_history_greeks_first_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_greeks_first_order_right.py b/openapi_project/openapi_package/models/option_history_greeks_first_order_right.py new file mode 100644 index 000000000..c5a605366 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_first_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryGreeksFirstOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_format.py b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_format.py new file mode 100644 index 000000000..80ecf0bce --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryGreeksImpliedVolatilityFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_interval.py b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_interval.py new file mode 100644 index 000000000..dddb254d4 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryGreeksImpliedVolatilityInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_rate_type.py b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_rate_type.py new file mode 100644 index 000000000..3eb437040 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryGreeksImpliedVolatilityRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_response_200_item.py b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_response_200_item.py new file mode 100644 index 000000000..049803635 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_response_200_item.py @@ -0,0 +1,184 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryGreeksImpliedVolatilityResponse200Item") + + + +@_attrs_define +class OptionHistoryGreeksImpliedVolatilityResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + right (str): + implied_vol (float): + iv_error (float): + bid_implied_vol (float): + ask (float): + midpoint (float): + expiration (str): + ask_implied_vol (float): + bid (float): + underlying_timestamp (str): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + right: str + implied_vol: float + iv_error: float + bid_implied_vol: float + ask: float + midpoint: float + expiration: str + ask_implied_vol: float + bid: float + underlying_timestamp: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + right = self.right + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + bid_implied_vol = self.bid_implied_vol + + ask = self.ask + + midpoint = self.midpoint + + expiration = self.expiration + + ask_implied_vol = self.ask_implied_vol + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "right": right, + "implied_vol": implied_vol, + "iv_error": iv_error, + "bid_implied_vol": bid_implied_vol, + "ask": ask, + "midpoint": midpoint, + "expiration": expiration, + "ask_implied_vol": ask_implied_vol, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + bid_implied_vol = d.pop("bid_implied_vol") + + ask = d.pop("ask") + + midpoint = d.pop("midpoint") + + expiration = d.pop("expiration") + + ask_implied_vol = d.pop("ask_implied_vol") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + option_history_greeks_implied_volatility_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + right=right, + implied_vol=implied_vol, + iv_error=iv_error, + bid_implied_vol=bid_implied_vol, + ask=ask, + midpoint=midpoint, + expiration=expiration, + ask_implied_vol=ask_implied_vol, + bid=bid, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + ) + + + + option_history_greeks_implied_volatility_response_200_item.additional_properties = d + return option_history_greeks_implied_volatility_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_right.py b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_right.py new file mode 100644 index 000000000..f9faa3c31 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_implied_volatility_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryGreeksImpliedVolatilityRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_second_order_format.py b/openapi_project/openapi_package/models/option_history_greeks_second_order_format.py new file mode 100644 index 000000000..835c39592 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_second_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryGreeksSecondOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_second_order_interval.py b/openapi_project/openapi_package/models/option_history_greeks_second_order_interval.py new file mode 100644 index 000000000..40b139817 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_second_order_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryGreeksSecondOrderInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_second_order_rate_type.py b/openapi_project/openapi_package/models/option_history_greeks_second_order_rate_type.py new file mode 100644 index 000000000..4ab12dbf2 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_second_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryGreeksSecondOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_second_order_response_200_item.py b/openapi_project/openapi_package/models/option_history_greeks_second_order_response_200_item.py new file mode 100644 index 000000000..7629acdb0 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_second_order_response_200_item.py @@ -0,0 +1,200 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryGreeksSecondOrderResponse200Item") + + + +@_attrs_define +class OptionHistoryGreeksSecondOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + right (str): + veta (float): + implied_vol (float): + iv_error (float): + charm (float): + ask (float): + expiration (str): + vanna (float): + vomma (float): + bid (float): + underlying_timestamp (str): + gamma (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + right: str + veta: float + implied_vol: float + iv_error: float + charm: float + ask: float + expiration: str + vanna: float + vomma: float + bid: float + underlying_timestamp: str + gamma: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + right = self.right + + veta = self.veta + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + charm = self.charm + + ask = self.ask + + expiration = self.expiration + + vanna = self.vanna + + vomma = self.vomma + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + gamma = self.gamma + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "right": right, + "veta": veta, + "implied_vol": implied_vol, + "iv_error": iv_error, + "charm": charm, + "ask": ask, + "expiration": expiration, + "vanna": vanna, + "vomma": vomma, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "gamma": gamma, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + right = d.pop("right") + + veta = d.pop("veta") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + charm = d.pop("charm") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + vanna = d.pop("vanna") + + vomma = d.pop("vomma") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + gamma = d.pop("gamma") + + timestamp = d.pop("timestamp") + + option_history_greeks_second_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + right=right, + veta=veta, + implied_vol=implied_vol, + iv_error=iv_error, + charm=charm, + ask=ask, + expiration=expiration, + vanna=vanna, + vomma=vomma, + bid=bid, + underlying_timestamp=underlying_timestamp, + gamma=gamma, + timestamp=timestamp, + ) + + + + option_history_greeks_second_order_response_200_item.additional_properties = d + return option_history_greeks_second_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_greeks_second_order_right.py b/openapi_project/openapi_package/models/option_history_greeks_second_order_right.py new file mode 100644 index 000000000..b450742ac --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_second_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryGreeksSecondOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_third_order_format.py b/openapi_project/openapi_package/models/option_history_greeks_third_order_format.py new file mode 100644 index 000000000..bf4f2b8f8 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_third_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryGreeksThirdOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_third_order_interval.py b/openapi_project/openapi_package/models/option_history_greeks_third_order_interval.py new file mode 100644 index 000000000..abb2ff006 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_third_order_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryGreeksThirdOrderInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_third_order_rate_type.py b/openapi_project/openapi_package/models/option_history_greeks_third_order_rate_type.py new file mode 100644 index 000000000..17707720e --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_third_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryGreeksThirdOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_greeks_third_order_response_200_item.py b/openapi_project/openapi_package/models/option_history_greeks_third_order_response_200_item.py new file mode 100644 index 000000000..d2d6b0847 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_third_order_response_200_item.py @@ -0,0 +1,192 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryGreeksThirdOrderResponse200Item") + + + +@_attrs_define +class OptionHistoryGreeksThirdOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + color (float): + strike (float): + zomma (float): + right (str): + implied_vol (float): + iv_error (float): + speed (float): + ultima (float): + ask (float): + expiration (str): + bid (float): + underlying_timestamp (str): + timestamp (str): + """ + + symbol: str + underlying_price: float + color: float + strike: float + zomma: float + right: str + implied_vol: float + iv_error: float + speed: float + ultima: float + ask: float + expiration: str + bid: float + underlying_timestamp: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + color = self.color + + strike = self.strike + + zomma = self.zomma + + right = self.right + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + speed = self.speed + + ultima = self.ultima + + ask = self.ask + + expiration = self.expiration + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "color": color, + "strike": strike, + "zomma": zomma, + "right": right, + "implied_vol": implied_vol, + "iv_error": iv_error, + "speed": speed, + "ultima": ultima, + "ask": ask, + "expiration": expiration, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + color = d.pop("color") + + strike = d.pop("strike") + + zomma = d.pop("zomma") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + speed = d.pop("speed") + + ultima = d.pop("ultima") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + option_history_greeks_third_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + color=color, + strike=strike, + zomma=zomma, + right=right, + implied_vol=implied_vol, + iv_error=iv_error, + speed=speed, + ultima=ultima, + ask=ask, + expiration=expiration, + bid=bid, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + ) + + + + option_history_greeks_third_order_response_200_item.additional_properties = d + return option_history_greeks_third_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_greeks_third_order_right.py b/openapi_project/openapi_package/models/option_history_greeks_third_order_right.py new file mode 100644 index 000000000..8ef6716e5 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_greeks_third_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryGreeksThirdOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_ohlc_format.py b/openapi_project/openapi_package/models/option_history_ohlc_format.py new file mode 100644 index 000000000..b0a934e0f --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_ohlc_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryOhlcFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_ohlc_interval.py b/openapi_project/openapi_package/models/option_history_ohlc_interval.py new file mode 100644 index 000000000..2ebbbef8f --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_ohlc_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryOhlcInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_ohlc_response_200_item.py b/openapi_project/openapi_package/models/option_history_ohlc_response_200_item.py new file mode 100644 index 000000000..b867c3d9d --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_ohlc_response_200_item.py @@ -0,0 +1,168 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryOhlcResponse200Item") + + + +@_attrs_define +class OptionHistoryOhlcResponse200Item: + """ + Attributes: + volume (int): + symbol (str): + high (float): + low (float): + strike (float): + vwap (float): + count (int): + expiration (str): + right (str): + close (float): + open_ (float): + timestamp (str): + """ + + volume: int + symbol: str + high: float + low: float + strike: float + vwap: float + count: int + expiration: str + right: str + close: float + open_: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + volume = self.volume + + symbol = self.symbol + + high = self.high + + low = self.low + + strike = self.strike + + vwap = self.vwap + + count = self.count + + expiration = self.expiration + + right = self.right + + close = self.close + + open_ = self.open_ + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "volume": volume, + "symbol": symbol, + "high": high, + "low": low, + "strike": strike, + "vwap": vwap, + "count": count, + "expiration": expiration, + "right": right, + "close": close, + "open": open_, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + volume = d.pop("volume") + + symbol = d.pop("symbol") + + high = d.pop("high") + + low = d.pop("low") + + strike = d.pop("strike") + + vwap = d.pop("vwap") + + count = d.pop("count") + + expiration = d.pop("expiration") + + right = d.pop("right") + + close = d.pop("close") + + open_ = d.pop("open") + + timestamp = d.pop("timestamp") + + option_history_ohlc_response_200_item = cls( + volume=volume, + symbol=symbol, + high=high, + low=low, + strike=strike, + vwap=vwap, + count=count, + expiration=expiration, + right=right, + close=close, + open_=open_, + timestamp=timestamp, + ) + + + + option_history_ohlc_response_200_item.additional_properties = d + return option_history_ohlc_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_ohlc_right.py b/openapi_project/openapi_package/models/option_history_ohlc_right.py new file mode 100644 index 000000000..1d425eb47 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_ohlc_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryOhlcRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_open_interest_format.py b/openapi_project/openapi_package/models/option_history_open_interest_format.py new file mode 100644 index 000000000..accb6e54e --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_open_interest_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryOpenInterestFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_open_interest_response_200_item.py b/openapi_project/openapi_package/models/option_history_open_interest_response_200_item.py new file mode 100644 index 000000000..338796933 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_open_interest_response_200_item.py @@ -0,0 +1,120 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryOpenInterestResponse200Item") + + + +@_attrs_define +class OptionHistoryOpenInterestResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + open_interest (int): + expiration (str): + right (str): + timestamp (str): + """ + + symbol: str + strike: float + open_interest: int + expiration: str + right: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + open_interest = self.open_interest + + expiration = self.expiration + + right = self.right + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + "open_interest": open_interest, + "expiration": expiration, + "right": right, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + open_interest = d.pop("open_interest") + + expiration = d.pop("expiration") + + right = d.pop("right") + + timestamp = d.pop("timestamp") + + option_history_open_interest_response_200_item = cls( + symbol=symbol, + strike=strike, + open_interest=open_interest, + expiration=expiration, + right=right, + timestamp=timestamp, + ) + + + + option_history_open_interest_response_200_item.additional_properties = d + return option_history_open_interest_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_open_interest_right.py b/openapi_project/openapi_package/models/option_history_open_interest_right.py new file mode 100644 index 000000000..dbdb9a035 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_open_interest_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryOpenInterestRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_quote_format.py b/openapi_project/openapi_package/models/option_history_quote_format.py new file mode 100644 index 000000000..2c8c449b1 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_quote_interval.py b/openapi_project/openapi_package/models/option_history_quote_interval.py new file mode 100644 index 000000000..3a9565477 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_quote_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class OptionHistoryQuoteInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_quote_response_200_item.py b/openapi_project/openapi_package/models/option_history_quote_response_200_item.py new file mode 100644 index 000000000..9cf69fefc --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_quote_response_200_item.py @@ -0,0 +1,176 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryQuoteResponse200Item") + + + +@_attrs_define +class OptionHistoryQuoteResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + ask_condition (int): + strike (float): + right (str): + bid_size (int): + ask_exchange (int): + bid_exchange (int): + ask (float): + expiration (str): + bid (float): + bid_condition (int): + timestamp (str): + """ + + symbol: str + ask_size: int + ask_condition: int + strike: float + right: str + bid_size: int + ask_exchange: int + bid_exchange: int + ask: float + expiration: str + bid: float + bid_condition: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + ask_condition = self.ask_condition + + strike = self.strike + + right = self.right + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + ask = self.ask + + expiration = self.expiration + + bid = self.bid + + bid_condition = self.bid_condition + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "ask_condition": ask_condition, + "strike": strike, + "right": right, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "ask": ask, + "expiration": expiration, + "bid": bid, + "bid_condition": bid_condition, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + ask_condition = d.pop("ask_condition") + + strike = d.pop("strike") + + right = d.pop("right") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + timestamp = d.pop("timestamp") + + option_history_quote_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + ask_condition=ask_condition, + strike=strike, + right=right, + bid_size=bid_size, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + ask=ask, + expiration=expiration, + bid=bid, + bid_condition=bid_condition, + timestamp=timestamp, + ) + + + + option_history_quote_response_200_item.additional_properties = d + return option_history_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_quote_right.py b/openapi_project/openapi_package/models/option_history_quote_right.py new file mode 100644 index 000000000..e070d7a48 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_quote_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryQuoteRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_format.py b/openapi_project/openapi_package/models/option_history_trade_format.py new file mode 100644 index 000000000..7528cfeae --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_all_format.py b/openapi_project/openapi_package/models/option_history_trade_greeks_all_format.py new file mode 100644 index 000000000..0f5634643 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_all_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeGreeksAllFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_all_rate_type.py b/openapi_project/openapi_package/models/option_history_trade_greeks_all_rate_type.py new file mode 100644 index 000000000..70305c766 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_all_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryTradeGreeksAllRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_all_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_greeks_all_response_200_item.py new file mode 100644 index 000000000..1dcffa24a --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_all_response_200_item.py @@ -0,0 +1,376 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeGreeksAllResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeGreeksAllResponse200Item: + """ + Attributes: + symbol (str): + dual_delta (float): + color (float): + zomma (float): + delta (float): + implied_vol (float): + theta (float): + d1 (float): + speed (float): + d2 (float): + epsilon (float): + lambda_ (float): + price (float): + ext_condition2 (int): + ext_condition1 (int): + ext_condition4 (int): + vomma (float): + ext_condition3 (int): + underlying_timestamp (str): + timestamp (str): + underlying_price (float): + strike (float): + vera (float): + right (str): + veta (float): + iv_error (float): + ultima (float): + sequence (int): + condition (int): + size (int): + charm (float): + rho (float): + expiration (str): + exchange (int): + vanna (float): + dual_gamma (float): + vega (float): + gamma (float): + """ + + symbol: str + dual_delta: float + color: float + zomma: float + delta: float + implied_vol: float + theta: float + d1: float + speed: float + d2: float + epsilon: float + lambda_: float + price: float + ext_condition2: int + ext_condition1: int + ext_condition4: int + vomma: float + ext_condition3: int + underlying_timestamp: str + timestamp: str + underlying_price: float + strike: float + vera: float + right: str + veta: float + iv_error: float + ultima: float + sequence: int + condition: int + size: int + charm: float + rho: float + expiration: str + exchange: int + vanna: float + dual_gamma: float + vega: float + gamma: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + dual_delta = self.dual_delta + + color = self.color + + zomma = self.zomma + + delta = self.delta + + implied_vol = self.implied_vol + + theta = self.theta + + d1 = self.d1 + + speed = self.speed + + d2 = self.d2 + + epsilon = self.epsilon + + lambda_ = self.lambda_ + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + ext_condition4 = self.ext_condition4 + + vomma = self.vomma + + ext_condition3 = self.ext_condition3 + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + underlying_price = self.underlying_price + + strike = self.strike + + vera = self.vera + + right = self.right + + veta = self.veta + + iv_error = self.iv_error + + ultima = self.ultima + + sequence = self.sequence + + condition = self.condition + + size = self.size + + charm = self.charm + + rho = self.rho + + expiration = self.expiration + + exchange = self.exchange + + vanna = self.vanna + + dual_gamma = self.dual_gamma + + vega = self.vega + + gamma = self.gamma + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "dual_delta": dual_delta, + "color": color, + "zomma": zomma, + "delta": delta, + "implied_vol": implied_vol, + "theta": theta, + "d1": d1, + "speed": speed, + "d2": d2, + "epsilon": epsilon, + "lambda": lambda_, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "ext_condition4": ext_condition4, + "vomma": vomma, + "ext_condition3": ext_condition3, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + "underlying_price": underlying_price, + "strike": strike, + "vera": vera, + "right": right, + "veta": veta, + "iv_error": iv_error, + "ultima": ultima, + "sequence": sequence, + "condition": condition, + "size": size, + "charm": charm, + "rho": rho, + "expiration": expiration, + "exchange": exchange, + "vanna": vanna, + "dual_gamma": dual_gamma, + "vega": vega, + "gamma": gamma, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + dual_delta = d.pop("dual_delta") + + color = d.pop("color") + + zomma = d.pop("zomma") + + delta = d.pop("delta") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + d1 = d.pop("d1") + + speed = d.pop("speed") + + d2 = d.pop("d2") + + epsilon = d.pop("epsilon") + + lambda_ = d.pop("lambda") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + ext_condition4 = d.pop("ext_condition4") + + vomma = d.pop("vomma") + + ext_condition3 = d.pop("ext_condition3") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + vera = d.pop("vera") + + right = d.pop("right") + + veta = d.pop("veta") + + iv_error = d.pop("iv_error") + + ultima = d.pop("ultima") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + charm = d.pop("charm") + + rho = d.pop("rho") + + expiration = d.pop("expiration") + + exchange = d.pop("exchange") + + vanna = d.pop("vanna") + + dual_gamma = d.pop("dual_gamma") + + vega = d.pop("vega") + + gamma = d.pop("gamma") + + option_history_trade_greeks_all_response_200_item = cls( + symbol=symbol, + dual_delta=dual_delta, + color=color, + zomma=zomma, + delta=delta, + implied_vol=implied_vol, + theta=theta, + d1=d1, + speed=speed, + d2=d2, + epsilon=epsilon, + lambda_=lambda_, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + ext_condition4=ext_condition4, + vomma=vomma, + ext_condition3=ext_condition3, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + underlying_price=underlying_price, + strike=strike, + vera=vera, + right=right, + veta=veta, + iv_error=iv_error, + ultima=ultima, + sequence=sequence, + condition=condition, + size=size, + charm=charm, + rho=rho, + expiration=expiration, + exchange=exchange, + vanna=vanna, + dual_gamma=dual_gamma, + vega=vega, + gamma=gamma, + ) + + + + option_history_trade_greeks_all_response_200_item.additional_properties = d + return option_history_trade_greeks_all_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_all_right.py b/openapi_project/openapi_package/models/option_history_trade_greeks_all_right.py new file mode 100644 index 000000000..599f5b673 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_all_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeGreeksAllRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_format.py b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_format.py new file mode 100644 index 000000000..3967a09a4 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeGreeksFirstOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_rate_type.py b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_rate_type.py new file mode 100644 index 000000000..18134f910 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryTradeGreeksFirstOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_response_200_item.py new file mode 100644 index 000000000..fc18dd81c --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_response_200_item.py @@ -0,0 +1,264 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeGreeksFirstOrderResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeGreeksFirstOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + delta (float): + right (str): + implied_vol (float): + theta (float): + iv_error (float): + epsilon (float): + sequence (int): + condition (int): + lambda_ (float): + size (int): + price (float): + ext_condition2 (int): + rho (float): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + underlying_timestamp (str): + vega (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + delta: float + right: str + implied_vol: float + theta: float + iv_error: float + epsilon: float + sequence: int + condition: int + lambda_: float + size: int + price: float + ext_condition2: int + rho: float + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + underlying_timestamp: str + vega: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + delta = self.delta + + right = self.right + + implied_vol = self.implied_vol + + theta = self.theta + + iv_error = self.iv_error + + epsilon = self.epsilon + + sequence = self.sequence + + condition = self.condition + + lambda_ = self.lambda_ + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + rho = self.rho + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + underlying_timestamp = self.underlying_timestamp + + vega = self.vega + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "delta": delta, + "right": right, + "implied_vol": implied_vol, + "theta": theta, + "iv_error": iv_error, + "epsilon": epsilon, + "sequence": sequence, + "condition": condition, + "lambda": lambda_, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "rho": rho, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "underlying_timestamp": underlying_timestamp, + "vega": vega, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + delta = d.pop("delta") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + iv_error = d.pop("iv_error") + + epsilon = d.pop("epsilon") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + lambda_ = d.pop("lambda") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + rho = d.pop("rho") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + underlying_timestamp = d.pop("underlying_timestamp") + + vega = d.pop("vega") + + timestamp = d.pop("timestamp") + + option_history_trade_greeks_first_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + delta=delta, + right=right, + implied_vol=implied_vol, + theta=theta, + iv_error=iv_error, + epsilon=epsilon, + sequence=sequence, + condition=condition, + lambda_=lambda_, + size=size, + price=price, + ext_condition2=ext_condition2, + rho=rho, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + underlying_timestamp=underlying_timestamp, + vega=vega, + timestamp=timestamp, + ) + + + + option_history_trade_greeks_first_order_response_200_item.additional_properties = d + return option_history_trade_greeks_first_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_right.py b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_right.py new file mode 100644 index 000000000..46f4e71be --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_first_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeGreeksFirstOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_format.py b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_format.py new file mode 100644 index 000000000..4cf2c76bc --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeGreeksImpliedVolatilityFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_rate_type.py b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_rate_type.py new file mode 100644 index 000000000..e32d60ba6 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryTradeGreeksImpliedVolatilityRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_response_200_item.py new file mode 100644 index 000000000..2005355eb --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_response_200_item.py @@ -0,0 +1,216 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeGreeksImpliedVolatilityResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeGreeksImpliedVolatilityResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + right (str): + implied_vol (float): + iv_error (float): + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + underlying_timestamp (str): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + right: str + implied_vol: float + iv_error: float + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + underlying_timestamp: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + right = self.right + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "right": right, + "implied_vol": implied_vol, + "iv_error": iv_error, + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + option_history_trade_greeks_implied_volatility_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + right=right, + implied_vol=implied_vol, + iv_error=iv_error, + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + ) + + + + option_history_trade_greeks_implied_volatility_response_200_item.additional_properties = d + return option_history_trade_greeks_implied_volatility_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_right.py b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_right.py new file mode 100644 index 000000000..dafc1899d --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_implied_volatility_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeGreeksImpliedVolatilityRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_format.py b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_format.py new file mode 100644 index 000000000..d5648b438 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeGreeksSecondOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_rate_type.py b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_rate_type.py new file mode 100644 index 000000000..d9567f04e --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryTradeGreeksSecondOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_response_200_item.py new file mode 100644 index 000000000..c9c97a338 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_response_200_item.py @@ -0,0 +1,256 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeGreeksSecondOrderResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeGreeksSecondOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + right (str): + veta (float): + implied_vol (float): + iv_error (float): + sequence (int): + condition (int): + size (int): + charm (float): + price (float): + ext_condition2 (int): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + vanna (float): + vomma (float): + ext_condition3 (int): + underlying_timestamp (str): + gamma (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + right: str + veta: float + implied_vol: float + iv_error: float + sequence: int + condition: int + size: int + charm: float + price: float + ext_condition2: int + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + vanna: float + vomma: float + ext_condition3: int + underlying_timestamp: str + gamma: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + right = self.right + + veta = self.veta + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + sequence = self.sequence + + condition = self.condition + + size = self.size + + charm = self.charm + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + vanna = self.vanna + + vomma = self.vomma + + ext_condition3 = self.ext_condition3 + + underlying_timestamp = self.underlying_timestamp + + gamma = self.gamma + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "right": right, + "veta": veta, + "implied_vol": implied_vol, + "iv_error": iv_error, + "sequence": sequence, + "condition": condition, + "size": size, + "charm": charm, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "vanna": vanna, + "vomma": vomma, + "ext_condition3": ext_condition3, + "underlying_timestamp": underlying_timestamp, + "gamma": gamma, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + right = d.pop("right") + + veta = d.pop("veta") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + charm = d.pop("charm") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + vanna = d.pop("vanna") + + vomma = d.pop("vomma") + + ext_condition3 = d.pop("ext_condition3") + + underlying_timestamp = d.pop("underlying_timestamp") + + gamma = d.pop("gamma") + + timestamp = d.pop("timestamp") + + option_history_trade_greeks_second_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + right=right, + veta=veta, + implied_vol=implied_vol, + iv_error=iv_error, + sequence=sequence, + condition=condition, + size=size, + charm=charm, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + vanna=vanna, + vomma=vomma, + ext_condition3=ext_condition3, + underlying_timestamp=underlying_timestamp, + gamma=gamma, + timestamp=timestamp, + ) + + + + option_history_trade_greeks_second_order_response_200_item.additional_properties = d + return option_history_trade_greeks_second_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_right.py b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_right.py new file mode 100644 index 000000000..6e68db6cf --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_second_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeGreeksSecondOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_format.py b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_format.py new file mode 100644 index 000000000..f08c3f3b1 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeGreeksThirdOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_rate_type.py b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_rate_type.py new file mode 100644 index 000000000..e616b990b --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionHistoryTradeGreeksThirdOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_response_200_item.py new file mode 100644 index 000000000..557c64244 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_response_200_item.py @@ -0,0 +1,248 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeGreeksThirdOrderResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeGreeksThirdOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + color (float): + strike (float): + zomma (float): + right (str): + implied_vol (float): + iv_error (float): + speed (float): + ultima (float): + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + underlying_timestamp (str): + timestamp (str): + """ + + symbol: str + underlying_price: float + color: float + strike: float + zomma: float + right: str + implied_vol: float + iv_error: float + speed: float + ultima: float + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + underlying_timestamp: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + color = self.color + + strike = self.strike + + zomma = self.zomma + + right = self.right + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + speed = self.speed + + ultima = self.ultima + + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "color": color, + "strike": strike, + "zomma": zomma, + "right": right, + "implied_vol": implied_vol, + "iv_error": iv_error, + "speed": speed, + "ultima": ultima, + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + color = d.pop("color") + + strike = d.pop("strike") + + zomma = d.pop("zomma") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + speed = d.pop("speed") + + ultima = d.pop("ultima") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + option_history_trade_greeks_third_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + color=color, + strike=strike, + zomma=zomma, + right=right, + implied_vol=implied_vol, + iv_error=iv_error, + speed=speed, + ultima=ultima, + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + ) + + + + option_history_trade_greeks_third_order_response_200_item.additional_properties = d + return option_history_trade_greeks_third_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_right.py b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_right.py new file mode 100644 index 000000000..da55d85d6 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_greeks_third_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeGreeksThirdOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_quote_format.py b/openapi_project/openapi_package/models/option_history_trade_quote_format.py new file mode 100644 index 000000000..a0e68fe18 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionHistoryTradeQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_quote_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_quote_response_200_item.py new file mode 100644 index 000000000..912f6ebf9 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_quote_response_200_item.py @@ -0,0 +1,256 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeQuoteResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeQuoteResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + trade_timestamp (str): + ask_condition (int): + strike (float): + right (str): + sequence (int): + condition (int): + size (int): + bid_size (int): + ask_exchange (int): + price (float): + ext_condition2 (int): + bid_exchange (int): + ask (float): + quote_timestamp (str): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + bid (float): + bid_condition (int): + """ + + symbol: str + ask_size: int + trade_timestamp: str + ask_condition: int + strike: float + right: str + sequence: int + condition: int + size: int + bid_size: int + ask_exchange: int + price: float + ext_condition2: int + bid_exchange: int + ask: float + quote_timestamp: str + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + bid: float + bid_condition: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + trade_timestamp = self.trade_timestamp + + ask_condition = self.ask_condition + + strike = self.strike + + right = self.right + + sequence = self.sequence + + condition = self.condition + + size = self.size + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + price = self.price + + ext_condition2 = self.ext_condition2 + + bid_exchange = self.bid_exchange + + ask = self.ask + + quote_timestamp = self.quote_timestamp + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + bid = self.bid + + bid_condition = self.bid_condition + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "trade_timestamp": trade_timestamp, + "ask_condition": ask_condition, + "strike": strike, + "right": right, + "sequence": sequence, + "condition": condition, + "size": size, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "price": price, + "ext_condition2": ext_condition2, + "bid_exchange": bid_exchange, + "ask": ask, + "quote_timestamp": quote_timestamp, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "bid": bid, + "bid_condition": bid_condition, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + trade_timestamp = d.pop("trade_timestamp") + + ask_condition = d.pop("ask_condition") + + strike = d.pop("strike") + + right = d.pop("right") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + quote_timestamp = d.pop("quote_timestamp") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + option_history_trade_quote_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + trade_timestamp=trade_timestamp, + ask_condition=ask_condition, + strike=strike, + right=right, + sequence=sequence, + condition=condition, + size=size, + bid_size=bid_size, + ask_exchange=ask_exchange, + price=price, + ext_condition2=ext_condition2, + bid_exchange=bid_exchange, + ask=ask, + quote_timestamp=quote_timestamp, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + bid=bid, + bid_condition=bid_condition, + ) + + + + option_history_trade_quote_response_200_item.additional_properties = d + return option_history_trade_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_quote_right.py b/openapi_project/openapi_package/models/option_history_trade_quote_right.py new file mode 100644 index 000000000..4e2db3779 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_quote_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeQuoteRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_history_trade_response_200_item.py b/openapi_project/openapi_package/models/option_history_trade_response_200_item.py new file mode 100644 index 000000000..6eb9786ae --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_response_200_item.py @@ -0,0 +1,184 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionHistoryTradeResponse200Item") + + + +@_attrs_define +class OptionHistoryTradeResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + right (str): + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + timestamp (str): + """ + + symbol: str + strike: float + right: str + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + right = self.right + + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + "right": right, + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + right = d.pop("right") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + timestamp = d.pop("timestamp") + + option_history_trade_response_200_item = cls( + symbol=symbol, + strike=strike, + right=right, + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + timestamp=timestamp, + ) + + + + option_history_trade_response_200_item.additional_properties = d + return option_history_trade_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_history_trade_right.py b/openapi_project/openapi_package/models/option_history_trade_right.py new file mode 100644 index 000000000..7a8e374f4 --- /dev/null +++ b/openapi_project/openapi_package/models/option_history_trade_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionHistoryTradeRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_contracts_format.py b/openapi_project/openapi_package/models/option_list_contracts_format.py new file mode 100644 index 000000000..7bfa34f40 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_contracts_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionListContractsFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_contracts_request_type.py b/openapi_project/openapi_package/models/option_list_contracts_request_type.py new file mode 100644 index 000000000..90f0de3a2 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_contracts_request_type.py @@ -0,0 +1,8 @@ +from enum import Enum + +class OptionListContractsRequestType(str, Enum): + QUOTE = "quote" + TRADE = "trade" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_contracts_response_200_item.py b/openapi_project/openapi_package/models/option_list_contracts_response_200_item.py new file mode 100644 index 000000000..667b8917c --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_contracts_response_200_item.py @@ -0,0 +1,104 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionListContractsResponse200Item") + + + +@_attrs_define +class OptionListContractsResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + expiration (str): + right (str): + """ + + symbol: str + strike: float + expiration: str + right: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + expiration = self.expiration + + right = self.right + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + "expiration": expiration, + "right": right, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + expiration = d.pop("expiration") + + right = d.pop("right") + + option_list_contracts_response_200_item = cls( + symbol=symbol, + strike=strike, + expiration=expiration, + right=right, + ) + + + + option_list_contracts_response_200_item.additional_properties = d + return option_list_contracts_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_list_dates_format.py b/openapi_project/openapi_package/models/option_list_dates_format.py new file mode 100644 index 000000000..ac71cb25c --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_dates_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionListDatesFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_dates_request_type.py b/openapi_project/openapi_package/models/option_list_dates_request_type.py new file mode 100644 index 000000000..9caf17593 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_dates_request_type.py @@ -0,0 +1,8 @@ +from enum import Enum + +class OptionListDatesRequestType(str, Enum): + QUOTE = "quote" + TRADE = "trade" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_dates_response_200_item.py b/openapi_project/openapi_package/models/option_list_dates_response_200_item.py new file mode 100644 index 000000000..871783faa --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_dates_response_200_item.py @@ -0,0 +1,112 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionListDatesResponse200Item") + + + +@_attrs_define +class OptionListDatesResponse200Item: + """ + Attributes: + date (str): + symbol (str): + strike (float): + expiration (str): + right (str): + """ + + date: str + symbol: str + strike: float + expiration: str + right: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + date = self.date + + symbol = self.symbol + + strike = self.strike + + expiration = self.expiration + + right = self.right + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "date": date, + "symbol": symbol, + "strike": strike, + "expiration": expiration, + "right": right, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date") + + symbol = d.pop("symbol") + + strike = d.pop("strike") + + expiration = d.pop("expiration") + + right = d.pop("right") + + option_list_dates_response_200_item = cls( + date=date, + symbol=symbol, + strike=strike, + expiration=expiration, + right=right, + ) + + + + option_list_dates_response_200_item.additional_properties = d + return option_list_dates_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_list_dates_right.py b/openapi_project/openapi_package/models/option_list_dates_right.py new file mode 100644 index 000000000..c56cfe3e0 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_dates_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionListDatesRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_expirations_format.py b/openapi_project/openapi_package/models/option_list_expirations_format.py new file mode 100644 index 000000000..747192660 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_expirations_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionListExpirationsFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_expirations_response_200_item.py b/openapi_project/openapi_package/models/option_list_expirations_response_200_item.py new file mode 100644 index 000000000..25e9264cb --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_expirations_response_200_item.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionListExpirationsResponse200Item") + + + +@_attrs_define +class OptionListExpirationsResponse200Item: + """ + Attributes: + symbol (str): + expiration (str): + """ + + symbol: str + expiration: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + expiration = self.expiration + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "expiration": expiration, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + expiration = d.pop("expiration") + + option_list_expirations_response_200_item = cls( + symbol=symbol, + expiration=expiration, + ) + + + + option_list_expirations_response_200_item.additional_properties = d + return option_list_expirations_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_list_strikes_format.py b/openapi_project/openapi_package/models/option_list_strikes_format.py new file mode 100644 index 000000000..c834d07ed --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_strikes_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionListStrikesFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_strikes_response_200_item.py b/openapi_project/openapi_package/models/option_list_strikes_response_200_item.py new file mode 100644 index 000000000..b42d23370 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_strikes_response_200_item.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionListStrikesResponse200Item") + + + +@_attrs_define +class OptionListStrikesResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + """ + + symbol: str + strike: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + option_list_strikes_response_200_item = cls( + symbol=symbol, + strike=strike, + ) + + + + option_list_strikes_response_200_item.additional_properties = d + return option_list_strikes_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_list_symbols_format.py b/openapi_project/openapi_package/models/option_list_symbols_format.py new file mode 100644 index 000000000..523470e39 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_symbols_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionListSymbolsFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_list_symbols_response_200_item.py b/openapi_project/openapi_package/models/option_list_symbols_response_200_item.py new file mode 100644 index 000000000..6a839ed27 --- /dev/null +++ b/openapi_project/openapi_package/models/option_list_symbols_response_200_item.py @@ -0,0 +1,80 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionListSymbolsResponse200Item") + + + +@_attrs_define +class OptionListSymbolsResponse200Item: + """ + Attributes: + symbol (str): + """ + + symbol: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + option_list_symbols_response_200_item = cls( + symbol=symbol, + ) + + + + option_list_symbols_response_200_item.additional_properties = d + return option_list_symbols_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_all_format.py b/openapi_project/openapi_package/models/option_snapshot_greeks_all_format.py new file mode 100644 index 000000000..b7423c74f --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_all_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotGreeksAllFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_all_rate_type.py b/openapi_project/openapi_package/models/option_snapshot_greeks_all_rate_type.py new file mode 100644 index 000000000..cf07f3e54 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_all_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionSnapshotGreeksAllRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_all_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_greeks_all_response_200_item.py new file mode 100644 index 000000000..47fb4f715 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_all_response_200_item.py @@ -0,0 +1,320 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotGreeksAllResponse200Item") + + + +@_attrs_define +class OptionSnapshotGreeksAllResponse200Item: + """ + Attributes: + symbol (str): + dual_delta (float): + color (float): + zomma (float): + delta (float): + implied_vol (float): + theta (float): + d1 (float): + speed (float): + d2 (float): + epsilon (float): + lambda_ (float): + vomma (float): + underlying_timestamp (str): + timestamp (str): + underlying_price (float): + strike (float): + vera (float): + right (str): + veta (float): + iv_error (float): + ultima (float): + charm (float): + ask (float): + rho (float): + expiration (str): + vanna (float): + dual_gamma (float): + bid (float): + vega (float): + gamma (float): + """ + + symbol: str + dual_delta: float + color: float + zomma: float + delta: float + implied_vol: float + theta: float + d1: float + speed: float + d2: float + epsilon: float + lambda_: float + vomma: float + underlying_timestamp: str + timestamp: str + underlying_price: float + strike: float + vera: float + right: str + veta: float + iv_error: float + ultima: float + charm: float + ask: float + rho: float + expiration: str + vanna: float + dual_gamma: float + bid: float + vega: float + gamma: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + dual_delta = self.dual_delta + + color = self.color + + zomma = self.zomma + + delta = self.delta + + implied_vol = self.implied_vol + + theta = self.theta + + d1 = self.d1 + + speed = self.speed + + d2 = self.d2 + + epsilon = self.epsilon + + lambda_ = self.lambda_ + + vomma = self.vomma + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + underlying_price = self.underlying_price + + strike = self.strike + + vera = self.vera + + right = self.right + + veta = self.veta + + iv_error = self.iv_error + + ultima = self.ultima + + charm = self.charm + + ask = self.ask + + rho = self.rho + + expiration = self.expiration + + vanna = self.vanna + + dual_gamma = self.dual_gamma + + bid = self.bid + + vega = self.vega + + gamma = self.gamma + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "dual_delta": dual_delta, + "color": color, + "zomma": zomma, + "delta": delta, + "implied_vol": implied_vol, + "theta": theta, + "d1": d1, + "speed": speed, + "d2": d2, + "epsilon": epsilon, + "lambda": lambda_, + "vomma": vomma, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + "underlying_price": underlying_price, + "strike": strike, + "vera": vera, + "right": right, + "veta": veta, + "iv_error": iv_error, + "ultima": ultima, + "charm": charm, + "ask": ask, + "rho": rho, + "expiration": expiration, + "vanna": vanna, + "dual_gamma": dual_gamma, + "bid": bid, + "vega": vega, + "gamma": gamma, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + dual_delta = d.pop("dual_delta") + + color = d.pop("color") + + zomma = d.pop("zomma") + + delta = d.pop("delta") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + d1 = d.pop("d1") + + speed = d.pop("speed") + + d2 = d.pop("d2") + + epsilon = d.pop("epsilon") + + lambda_ = d.pop("lambda") + + vomma = d.pop("vomma") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + vera = d.pop("vera") + + right = d.pop("right") + + veta = d.pop("veta") + + iv_error = d.pop("iv_error") + + ultima = d.pop("ultima") + + charm = d.pop("charm") + + ask = d.pop("ask") + + rho = d.pop("rho") + + expiration = d.pop("expiration") + + vanna = d.pop("vanna") + + dual_gamma = d.pop("dual_gamma") + + bid = d.pop("bid") + + vega = d.pop("vega") + + gamma = d.pop("gamma") + + option_snapshot_greeks_all_response_200_item = cls( + symbol=symbol, + dual_delta=dual_delta, + color=color, + zomma=zomma, + delta=delta, + implied_vol=implied_vol, + theta=theta, + d1=d1, + speed=speed, + d2=d2, + epsilon=epsilon, + lambda_=lambda_, + vomma=vomma, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + underlying_price=underlying_price, + strike=strike, + vera=vera, + right=right, + veta=veta, + iv_error=iv_error, + ultima=ultima, + charm=charm, + ask=ask, + rho=rho, + expiration=expiration, + vanna=vanna, + dual_gamma=dual_gamma, + bid=bid, + vega=vega, + gamma=gamma, + ) + + + + option_snapshot_greeks_all_response_200_item.additional_properties = d + return option_snapshot_greeks_all_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_all_right.py b/openapi_project/openapi_package/models/option_snapshot_greeks_all_right.py new file mode 100644 index 000000000..cedc0aa94 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_all_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotGreeksAllRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_format.py b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_format.py new file mode 100644 index 000000000..580badfdd --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotGreeksFirstOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_rate_type.py b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_rate_type.py new file mode 100644 index 000000000..89a1ee0bf --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionSnapshotGreeksFirstOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_response_200_item.py new file mode 100644 index 000000000..9df1c8f24 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_response_200_item.py @@ -0,0 +1,208 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotGreeksFirstOrderResponse200Item") + + + +@_attrs_define +class OptionSnapshotGreeksFirstOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + delta (float): + right (str): + implied_vol (float): + theta (float): + iv_error (float): + epsilon (float): + lambda_ (float): + ask (float): + rho (float): + expiration (str): + bid (float): + underlying_timestamp (str): + vega (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + delta: float + right: str + implied_vol: float + theta: float + iv_error: float + epsilon: float + lambda_: float + ask: float + rho: float + expiration: str + bid: float + underlying_timestamp: str + vega: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + delta = self.delta + + right = self.right + + implied_vol = self.implied_vol + + theta = self.theta + + iv_error = self.iv_error + + epsilon = self.epsilon + + lambda_ = self.lambda_ + + ask = self.ask + + rho = self.rho + + expiration = self.expiration + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + vega = self.vega + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "delta": delta, + "right": right, + "implied_vol": implied_vol, + "theta": theta, + "iv_error": iv_error, + "epsilon": epsilon, + "lambda": lambda_, + "ask": ask, + "rho": rho, + "expiration": expiration, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "vega": vega, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + delta = d.pop("delta") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + theta = d.pop("theta") + + iv_error = d.pop("iv_error") + + epsilon = d.pop("epsilon") + + lambda_ = d.pop("lambda") + + ask = d.pop("ask") + + rho = d.pop("rho") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + vega = d.pop("vega") + + timestamp = d.pop("timestamp") + + option_snapshot_greeks_first_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + delta=delta, + right=right, + implied_vol=implied_vol, + theta=theta, + iv_error=iv_error, + epsilon=epsilon, + lambda_=lambda_, + ask=ask, + rho=rho, + expiration=expiration, + bid=bid, + underlying_timestamp=underlying_timestamp, + vega=vega, + timestamp=timestamp, + ) + + + + option_snapshot_greeks_first_order_response_200_item.additional_properties = d + return option_snapshot_greeks_first_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_right.py b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_right.py new file mode 100644 index 000000000..fc01ef505 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_first_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotGreeksFirstOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_format.py b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_format.py new file mode 100644 index 000000000..5c042b5f3 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotGreeksImpliedVolatilityFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_rate_type.py b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_rate_type.py new file mode 100644 index 000000000..1457ef18a --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionSnapshotGreeksImpliedVolatilityRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_response_200_item.py new file mode 100644 index 000000000..1cccd1d9c --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_response_200_item.py @@ -0,0 +1,160 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotGreeksImpliedVolatilityResponse200Item") + + + +@_attrs_define +class OptionSnapshotGreeksImpliedVolatilityResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + ask (float): + expiration (str): + right (str): + implied_vol (float): + bid (float): + underlying_timestamp (str): + iv_error (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + ask: float + expiration: str + right: str + implied_vol: float + bid: float + underlying_timestamp: str + iv_error: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + ask = self.ask + + expiration = self.expiration + + right = self.right + + implied_vol = self.implied_vol + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + iv_error = self.iv_error + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "ask": ask, + "expiration": expiration, + "right": right, + "implied_vol": implied_vol, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "iv_error": iv_error, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + iv_error = d.pop("iv_error") + + timestamp = d.pop("timestamp") + + option_snapshot_greeks_implied_volatility_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + ask=ask, + expiration=expiration, + right=right, + implied_vol=implied_vol, + bid=bid, + underlying_timestamp=underlying_timestamp, + iv_error=iv_error, + timestamp=timestamp, + ) + + + + option_snapshot_greeks_implied_volatility_response_200_item.additional_properties = d + return option_snapshot_greeks_implied_volatility_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_right.py b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_right.py new file mode 100644 index 000000000..734d9afe8 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_implied_volatility_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotGreeksImpliedVolatilityRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_format.py b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_format.py new file mode 100644 index 000000000..288c532d6 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotGreeksSecondOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_rate_type.py b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_rate_type.py new file mode 100644 index 000000000..a4624ac36 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionSnapshotGreeksSecondOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_response_200_item.py new file mode 100644 index 000000000..947a358b5 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_response_200_item.py @@ -0,0 +1,200 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotGreeksSecondOrderResponse200Item") + + + +@_attrs_define +class OptionSnapshotGreeksSecondOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + strike (float): + right (str): + veta (float): + implied_vol (float): + iv_error (float): + charm (float): + ask (float): + expiration (str): + vanna (float): + vomma (float): + bid (float): + underlying_timestamp (str): + gamma (float): + timestamp (str): + """ + + symbol: str + underlying_price: float + strike: float + right: str + veta: float + implied_vol: float + iv_error: float + charm: float + ask: float + expiration: str + vanna: float + vomma: float + bid: float + underlying_timestamp: str + gamma: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + strike = self.strike + + right = self.right + + veta = self.veta + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + charm = self.charm + + ask = self.ask + + expiration = self.expiration + + vanna = self.vanna + + vomma = self.vomma + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + gamma = self.gamma + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "strike": strike, + "right": right, + "veta": veta, + "implied_vol": implied_vol, + "iv_error": iv_error, + "charm": charm, + "ask": ask, + "expiration": expiration, + "vanna": vanna, + "vomma": vomma, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "gamma": gamma, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + strike = d.pop("strike") + + right = d.pop("right") + + veta = d.pop("veta") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + charm = d.pop("charm") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + vanna = d.pop("vanna") + + vomma = d.pop("vomma") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + gamma = d.pop("gamma") + + timestamp = d.pop("timestamp") + + option_snapshot_greeks_second_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + strike=strike, + right=right, + veta=veta, + implied_vol=implied_vol, + iv_error=iv_error, + charm=charm, + ask=ask, + expiration=expiration, + vanna=vanna, + vomma=vomma, + bid=bid, + underlying_timestamp=underlying_timestamp, + gamma=gamma, + timestamp=timestamp, + ) + + + + option_snapshot_greeks_second_order_response_200_item.additional_properties = d + return option_snapshot_greeks_second_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_right.py b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_right.py new file mode 100644 index 000000000..c2ee3873e --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_second_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotGreeksSecondOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_format.py b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_format.py new file mode 100644 index 000000000..038850cc1 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotGreeksThirdOrderFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_rate_type.py b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_rate_type.py new file mode 100644 index 000000000..3e7806dcd --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_rate_type.py @@ -0,0 +1,18 @@ +from enum import Enum + +class OptionSnapshotGreeksThirdOrderRateType(str, Enum): + SOFR = "sofr" + TREASURY_M1 = "treasury_m1" + TREASURY_M3 = "treasury_m3" + TREASURY_M6 = "treasury_m6" + TREASURY_Y1 = "treasury_y1" + TREASURY_Y10 = "treasury_y10" + TREASURY_Y2 = "treasury_y2" + TREASURY_Y20 = "treasury_y20" + TREASURY_Y3 = "treasury_y3" + TREASURY_Y30 = "treasury_y30" + TREASURY_Y5 = "treasury_y5" + TREASURY_Y7 = "treasury_y7" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_response_200_item.py new file mode 100644 index 000000000..15f756bb9 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_response_200_item.py @@ -0,0 +1,192 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotGreeksThirdOrderResponse200Item") + + + +@_attrs_define +class OptionSnapshotGreeksThirdOrderResponse200Item: + """ + Attributes: + symbol (str): + underlying_price (float): + color (float): + strike (float): + zomma (float): + right (str): + implied_vol (float): + iv_error (float): + speed (float): + ultima (float): + ask (float): + expiration (str): + bid (float): + underlying_timestamp (str): + timestamp (str): + """ + + symbol: str + underlying_price: float + color: float + strike: float + zomma: float + right: str + implied_vol: float + iv_error: float + speed: float + ultima: float + ask: float + expiration: str + bid: float + underlying_timestamp: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + underlying_price = self.underlying_price + + color = self.color + + strike = self.strike + + zomma = self.zomma + + right = self.right + + implied_vol = self.implied_vol + + iv_error = self.iv_error + + speed = self.speed + + ultima = self.ultima + + ask = self.ask + + expiration = self.expiration + + bid = self.bid + + underlying_timestamp = self.underlying_timestamp + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "underlying_price": underlying_price, + "color": color, + "strike": strike, + "zomma": zomma, + "right": right, + "implied_vol": implied_vol, + "iv_error": iv_error, + "speed": speed, + "ultima": ultima, + "ask": ask, + "expiration": expiration, + "bid": bid, + "underlying_timestamp": underlying_timestamp, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + underlying_price = d.pop("underlying_price") + + color = d.pop("color") + + strike = d.pop("strike") + + zomma = d.pop("zomma") + + right = d.pop("right") + + implied_vol = d.pop("implied_vol") + + iv_error = d.pop("iv_error") + + speed = d.pop("speed") + + ultima = d.pop("ultima") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + underlying_timestamp = d.pop("underlying_timestamp") + + timestamp = d.pop("timestamp") + + option_snapshot_greeks_third_order_response_200_item = cls( + symbol=symbol, + underlying_price=underlying_price, + color=color, + strike=strike, + zomma=zomma, + right=right, + implied_vol=implied_vol, + iv_error=iv_error, + speed=speed, + ultima=ultima, + ask=ask, + expiration=expiration, + bid=bid, + underlying_timestamp=underlying_timestamp, + timestamp=timestamp, + ) + + + + option_snapshot_greeks_third_order_response_200_item.additional_properties = d + return option_snapshot_greeks_third_order_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_right.py b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_right.py new file mode 100644 index 000000000..c12a89af4 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_greeks_third_order_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotGreeksThirdOrderRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_ohlc_format.py b/openapi_project/openapi_package/models/option_snapshot_ohlc_format.py new file mode 100644 index 000000000..b13a25fc8 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_ohlc_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotOhlcFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_ohlc_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_ohlc_response_200_item.py new file mode 100644 index 000000000..d2a956c7f --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_ohlc_response_200_item.py @@ -0,0 +1,160 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotOhlcResponse200Item") + + + +@_attrs_define +class OptionSnapshotOhlcResponse200Item: + """ + Attributes: + volume (int): + symbol (str): + high (float): + low (float): + strike (float): + count (int): + expiration (str): + right (str): + close (float): + open_ (float): + timestamp (str): + """ + + volume: int + symbol: str + high: float + low: float + strike: float + count: int + expiration: str + right: str + close: float + open_: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + volume = self.volume + + symbol = self.symbol + + high = self.high + + low = self.low + + strike = self.strike + + count = self.count + + expiration = self.expiration + + right = self.right + + close = self.close + + open_ = self.open_ + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "volume": volume, + "symbol": symbol, + "high": high, + "low": low, + "strike": strike, + "count": count, + "expiration": expiration, + "right": right, + "close": close, + "open": open_, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + volume = d.pop("volume") + + symbol = d.pop("symbol") + + high = d.pop("high") + + low = d.pop("low") + + strike = d.pop("strike") + + count = d.pop("count") + + expiration = d.pop("expiration") + + right = d.pop("right") + + close = d.pop("close") + + open_ = d.pop("open") + + timestamp = d.pop("timestamp") + + option_snapshot_ohlc_response_200_item = cls( + volume=volume, + symbol=symbol, + high=high, + low=low, + strike=strike, + count=count, + expiration=expiration, + right=right, + close=close, + open_=open_, + timestamp=timestamp, + ) + + + + option_snapshot_ohlc_response_200_item.additional_properties = d + return option_snapshot_ohlc_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_ohlc_right.py b/openapi_project/openapi_package/models/option_snapshot_ohlc_right.py new file mode 100644 index 000000000..11340679d --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_ohlc_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotOhlcRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_open_interest_format.py b/openapi_project/openapi_package/models/option_snapshot_open_interest_format.py new file mode 100644 index 000000000..f62abea5e --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_open_interest_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotOpenInterestFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_open_interest_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_open_interest_response_200_item.py new file mode 100644 index 000000000..380977b66 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_open_interest_response_200_item.py @@ -0,0 +1,120 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotOpenInterestResponse200Item") + + + +@_attrs_define +class OptionSnapshotOpenInterestResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + open_interest (int): + expiration (str): + right (str): + timestamp (str): + """ + + symbol: str + strike: float + open_interest: int + expiration: str + right: str + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + open_interest = self.open_interest + + expiration = self.expiration + + right = self.right + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + "open_interest": open_interest, + "expiration": expiration, + "right": right, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + open_interest = d.pop("open_interest") + + expiration = d.pop("expiration") + + right = d.pop("right") + + timestamp = d.pop("timestamp") + + option_snapshot_open_interest_response_200_item = cls( + symbol=symbol, + strike=strike, + open_interest=open_interest, + expiration=expiration, + right=right, + timestamp=timestamp, + ) + + + + option_snapshot_open_interest_response_200_item.additional_properties = d + return option_snapshot_open_interest_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_open_interest_right.py b/openapi_project/openapi_package/models/option_snapshot_open_interest_right.py new file mode 100644 index 000000000..f87b86ce1 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_open_interest_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotOpenInterestRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_quote_format.py b/openapi_project/openapi_package/models/option_snapshot_quote_format.py new file mode 100644 index 000000000..3a1b5d479 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_quote_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_quote_response_200_item.py new file mode 100644 index 000000000..40489df2d --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_quote_response_200_item.py @@ -0,0 +1,176 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotQuoteResponse200Item") + + + +@_attrs_define +class OptionSnapshotQuoteResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + ask_condition (int): + strike (float): + right (str): + bid_size (int): + ask_exchange (int): + bid_exchange (int): + ask (float): + expiration (str): + bid (float): + bid_condition (int): + timestamp (str): + """ + + symbol: str + ask_size: int + ask_condition: int + strike: float + right: str + bid_size: int + ask_exchange: int + bid_exchange: int + ask: float + expiration: str + bid: float + bid_condition: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + ask_condition = self.ask_condition + + strike = self.strike + + right = self.right + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + ask = self.ask + + expiration = self.expiration + + bid = self.bid + + bid_condition = self.bid_condition + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "ask_condition": ask_condition, + "strike": strike, + "right": right, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "ask": ask, + "expiration": expiration, + "bid": bid, + "bid_condition": bid_condition, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + ask_condition = d.pop("ask_condition") + + strike = d.pop("strike") + + right = d.pop("right") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + expiration = d.pop("expiration") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + timestamp = d.pop("timestamp") + + option_snapshot_quote_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + ask_condition=ask_condition, + strike=strike, + right=right, + bid_size=bid_size, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + ask=ask, + expiration=expiration, + bid=bid, + bid_condition=bid_condition, + timestamp=timestamp, + ) + + + + option_snapshot_quote_response_200_item.additional_properties = d + return option_snapshot_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_quote_right.py b/openapi_project/openapi_package/models/option_snapshot_quote_right.py new file mode 100644 index 000000000..15f363cea --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_quote_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotQuoteRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_trade_format.py b/openapi_project/openapi_package/models/option_snapshot_trade_format.py new file mode 100644 index 000000000..9fe82bc46 --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_trade_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class OptionSnapshotTradeFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/option_snapshot_trade_response_200_item.py b/openapi_project/openapi_package/models/option_snapshot_trade_response_200_item.py new file mode 100644 index 000000000..8f810262b --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_trade_response_200_item.py @@ -0,0 +1,184 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="OptionSnapshotTradeResponse200Item") + + + +@_attrs_define +class OptionSnapshotTradeResponse200Item: + """ + Attributes: + symbol (str): + strike (float): + right (str): + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + expiration (str): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + timestamp (str): + """ + + symbol: str + strike: float + right: str + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + expiration: str + ext_condition4: int + exchange: int + ext_condition3: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + strike = self.strike + + right = self.right + + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + expiration = self.expiration + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "strike": strike, + "right": right, + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "expiration": expiration, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + strike = d.pop("strike") + + right = d.pop("right") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + expiration = d.pop("expiration") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + timestamp = d.pop("timestamp") + + option_snapshot_trade_response_200_item = cls( + symbol=symbol, + strike=strike, + right=right, + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + expiration=expiration, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + timestamp=timestamp, + ) + + + + option_snapshot_trade_response_200_item.additional_properties = d + return option_snapshot_trade_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/option_snapshot_trade_right.py b/openapi_project/openapi_package/models/option_snapshot_trade_right.py new file mode 100644 index 000000000..612c9a86b --- /dev/null +++ b/openapi_project/openapi_package/models/option_snapshot_trade_right.py @@ -0,0 +1,9 @@ +from enum import Enum + +class OptionSnapshotTradeRight(str, Enum): + BOTH = "both" + CALL = "call" + PUT = "put" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_at_time_quote_format.py b/openapi_project/openapi_package/models/stock_at_time_quote_format.py new file mode 100644 index 000000000..e0228cec3 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_at_time_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockAtTimeQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_at_time_quote_response_200_item.py b/openapi_project/openapi_package/models/stock_at_time_quote_response_200_item.py new file mode 100644 index 000000000..94a4ebb2c --- /dev/null +++ b/openapi_project/openapi_package/models/stock_at_time_quote_response_200_item.py @@ -0,0 +1,144 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockAtTimeQuoteResponse200Item") + + + +@_attrs_define +class StockAtTimeQuoteResponse200Item: + """ + Attributes: + ask_size (int): + bid_size (int): + ask_exchange (int): + ask_condition (int): + bid_exchange (int): + ask (float): + bid (float): + bid_condition (int): + timestamp (str): + """ + + ask_size: int + bid_size: int + ask_exchange: int + ask_condition: int + bid_exchange: int + ask: float + bid: float + bid_condition: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + ask_size = self.ask_size + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + ask_condition = self.ask_condition + + bid_exchange = self.bid_exchange + + ask = self.ask + + bid = self.bid + + bid_condition = self.bid_condition + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "ask_size": ask_size, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "ask_condition": ask_condition, + "bid_exchange": bid_exchange, + "ask": ask, + "bid": bid, + "bid_condition": bid_condition, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + ask_size = d.pop("ask_size") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + ask_condition = d.pop("ask_condition") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + timestamp = d.pop("timestamp") + + stock_at_time_quote_response_200_item = cls( + ask_size=ask_size, + bid_size=bid_size, + ask_exchange=ask_exchange, + ask_condition=ask_condition, + bid_exchange=bid_exchange, + ask=ask, + bid=bid, + bid_condition=bid_condition, + timestamp=timestamp, + ) + + + + stock_at_time_quote_response_200_item.additional_properties = d + return stock_at_time_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_at_time_quote_venue.py b/openapi_project/openapi_package/models/stock_at_time_quote_venue.py new file mode 100644 index 000000000..9b175eb0b --- /dev/null +++ b/openapi_project/openapi_package/models/stock_at_time_quote_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockAtTimeQuoteVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_at_time_trade_format.py b/openapi_project/openapi_package/models/stock_at_time_trade_format.py new file mode 100644 index 000000000..a4b6493a3 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_at_time_trade_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockAtTimeTradeFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_at_time_trade_response_200_item.py b/openapi_project/openapi_package/models/stock_at_time_trade_response_200_item.py new file mode 100644 index 000000000..d3b365f87 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_at_time_trade_response_200_item.py @@ -0,0 +1,152 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockAtTimeTradeResponse200Item") + + + +@_attrs_define +class StockAtTimeTradeResponse200Item: + """ + Attributes: + sequence (int): + condition (int): + size (int): + price (float): + ext_condition2 (int): + ext_condition1 (int): + ext_condition4 (int): + exchange (int): + ext_condition3 (int): + timestamp (str): + """ + + sequence: int + condition: int + size: int + price: float + ext_condition2: int + ext_condition1: int + ext_condition4: int + exchange: int + ext_condition3: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + ext_condition2 = self.ext_condition2 + + ext_condition1 = self.ext_condition1 + + ext_condition4 = self.ext_condition4 + + exchange = self.exchange + + ext_condition3 = self.ext_condition3 + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "ext_condition2": ext_condition2, + "ext_condition1": ext_condition1, + "ext_condition4": ext_condition4, + "exchange": exchange, + "ext_condition3": ext_condition3, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + ext_condition2 = d.pop("ext_condition2") + + ext_condition1 = d.pop("ext_condition1") + + ext_condition4 = d.pop("ext_condition4") + + exchange = d.pop("exchange") + + ext_condition3 = d.pop("ext_condition3") + + timestamp = d.pop("timestamp") + + stock_at_time_trade_response_200_item = cls( + sequence=sequence, + condition=condition, + size=size, + price=price, + ext_condition2=ext_condition2, + ext_condition1=ext_condition1, + ext_condition4=ext_condition4, + exchange=exchange, + ext_condition3=ext_condition3, + timestamp=timestamp, + ) + + + + stock_at_time_trade_response_200_item.additional_properties = d + return stock_at_time_trade_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_at_time_trade_venue.py b/openapi_project/openapi_package/models/stock_at_time_trade_venue.py new file mode 100644 index 000000000..a370a37d8 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_at_time_trade_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockAtTimeTradeVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_eod_format.py b/openapi_project/openapi_package/models/stock_history_eod_format.py new file mode 100644 index 000000000..2d6267bb1 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_eod_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockHistoryEodFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_eod_response_200_item.py b/openapi_project/openapi_package/models/stock_history_eod_response_200_item.py new file mode 100644 index 000000000..7d4b41a19 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_eod_response_200_item.py @@ -0,0 +1,200 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockHistoryEodResponse200Item") + + + +@_attrs_define +class StockHistoryEodResponse200Item: + """ + Attributes: + ask_size (int): + last_trade (str): + created (str): + ask_condition (int): + count (int): + volume (int): + high (float): + low (float): + bid_size (int): + ask_exchange (int): + bid_exchange (int): + ask (float): + bid (float): + bid_condition (int): + close (float): + open_ (float): + """ + + ask_size: int + last_trade: str + created: str + ask_condition: int + count: int + volume: int + high: float + low: float + bid_size: int + ask_exchange: int + bid_exchange: int + ask: float + bid: float + bid_condition: int + close: float + open_: float + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + ask_size = self.ask_size + + last_trade = self.last_trade + + created = self.created + + ask_condition = self.ask_condition + + count = self.count + + volume = self.volume + + high = self.high + + low = self.low + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + bid_exchange = self.bid_exchange + + ask = self.ask + + bid = self.bid + + bid_condition = self.bid_condition + + close = self.close + + open_ = self.open_ + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "ask_size": ask_size, + "last_trade": last_trade, + "created": created, + "ask_condition": ask_condition, + "count": count, + "volume": volume, + "high": high, + "low": low, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "bid_exchange": bid_exchange, + "ask": ask, + "bid": bid, + "bid_condition": bid_condition, + "close": close, + "open": open_, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + ask_size = d.pop("ask_size") + + last_trade = d.pop("last_trade") + + created = d.pop("created") + + ask_condition = d.pop("ask_condition") + + count = d.pop("count") + + volume = d.pop("volume") + + high = d.pop("high") + + low = d.pop("low") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + close = d.pop("close") + + open_ = d.pop("open") + + stock_history_eod_response_200_item = cls( + ask_size=ask_size, + last_trade=last_trade, + created=created, + ask_condition=ask_condition, + count=count, + volume=volume, + high=high, + low=low, + bid_size=bid_size, + ask_exchange=ask_exchange, + bid_exchange=bid_exchange, + ask=ask, + bid=bid, + bid_condition=bid_condition, + close=close, + open_=open_, + ) + + + + stock_history_eod_response_200_item.additional_properties = d + return stock_history_eod_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_history_ohlc_format.py b/openapi_project/openapi_package/models/stock_history_ohlc_format.py new file mode 100644 index 000000000..a625e5842 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_ohlc_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockHistoryOhlcFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_ohlc_interval.py b/openapi_project/openapi_package/models/stock_history_ohlc_interval.py new file mode 100644 index 000000000..3fc9a1475 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_ohlc_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class StockHistoryOhlcInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_ohlc_response_200_item.py b/openapi_project/openapi_package/models/stock_history_ohlc_response_200_item.py new file mode 100644 index 000000000..a6eef1fb5 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_ohlc_response_200_item.py @@ -0,0 +1,136 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockHistoryOhlcResponse200Item") + + + +@_attrs_define +class StockHistoryOhlcResponse200Item: + """ + Attributes: + volume (int): + high (float): + low (float): + vwap (float): + count (int): + close (float): + open_ (float): + timestamp (str): + """ + + volume: int + high: float + low: float + vwap: float + count: int + close: float + open_: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + volume = self.volume + + high = self.high + + low = self.low + + vwap = self.vwap + + count = self.count + + close = self.close + + open_ = self.open_ + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "volume": volume, + "high": high, + "low": low, + "vwap": vwap, + "count": count, + "close": close, + "open": open_, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + volume = d.pop("volume") + + high = d.pop("high") + + low = d.pop("low") + + vwap = d.pop("vwap") + + count = d.pop("count") + + close = d.pop("close") + + open_ = d.pop("open") + + timestamp = d.pop("timestamp") + + stock_history_ohlc_response_200_item = cls( + volume=volume, + high=high, + low=low, + vwap=vwap, + count=count, + close=close, + open_=open_, + timestamp=timestamp, + ) + + + + stock_history_ohlc_response_200_item.additional_properties = d + return stock_history_ohlc_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_history_ohlc_venue.py b/openapi_project/openapi_package/models/stock_history_ohlc_venue.py new file mode 100644 index 000000000..14cdeda1e --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_ohlc_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockHistoryOhlcVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_quote_format.py b/openapi_project/openapi_package/models/stock_history_quote_format.py new file mode 100644 index 000000000..387cd3780 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockHistoryQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_quote_interval.py b/openapi_project/openapi_package/models/stock_history_quote_interval.py new file mode 100644 index 000000000..6bd02b890 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_quote_interval.py @@ -0,0 +1,21 @@ +from enum import Enum + +class StockHistoryQuoteInterval(str, Enum): + TICK = "tick" + VALUE_1 = "10ms" + VALUE_10 = "5m" + VALUE_11 = "10m" + VALUE_12 = "15m" + VALUE_13 = "30m" + VALUE_14 = "1h" + VALUE_2 = "100ms" + VALUE_3 = "500ms" + VALUE_4 = "1s" + VALUE_5 = "5s" + VALUE_6 = "10s" + VALUE_7 = "15s" + VALUE_8 = "30s" + VALUE_9 = "1m" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_quote_response_200_item.py b/openapi_project/openapi_package/models/stock_history_quote_response_200_item.py new file mode 100644 index 000000000..e2f5fe36f --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_quote_response_200_item.py @@ -0,0 +1,144 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockHistoryQuoteResponse200Item") + + + +@_attrs_define +class StockHistoryQuoteResponse200Item: + """ + Attributes: + ask_size (int): + bid_size (int): + ask_exchange (int): + ask_condition (int): + bid_exchange (int): + ask (float): + bid (float): + bid_condition (int): + timestamp (str): + """ + + ask_size: int + bid_size: int + ask_exchange: int + ask_condition: int + bid_exchange: int + ask: float + bid: float + bid_condition: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + ask_size = self.ask_size + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + ask_condition = self.ask_condition + + bid_exchange = self.bid_exchange + + ask = self.ask + + bid = self.bid + + bid_condition = self.bid_condition + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "ask_size": ask_size, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "ask_condition": ask_condition, + "bid_exchange": bid_exchange, + "ask": ask, + "bid": bid, + "bid_condition": bid_condition, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + ask_size = d.pop("ask_size") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + ask_condition = d.pop("ask_condition") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + timestamp = d.pop("timestamp") + + stock_history_quote_response_200_item = cls( + ask_size=ask_size, + bid_size=bid_size, + ask_exchange=ask_exchange, + ask_condition=ask_condition, + bid_exchange=bid_exchange, + ask=ask, + bid=bid, + bid_condition=bid_condition, + timestamp=timestamp, + ) + + + + stock_history_quote_response_200_item.additional_properties = d + return stock_history_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_history_quote_venue.py b/openapi_project/openapi_package/models/stock_history_quote_venue.py new file mode 100644 index 000000000..bc294e35f --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_quote_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockHistoryQuoteVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_trade_format.py b/openapi_project/openapi_package/models/stock_history_trade_format.py new file mode 100644 index 000000000..ab094e3ac --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_trade_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockHistoryTradeFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_trade_quote_format.py b/openapi_project/openapi_package/models/stock_history_trade_quote_format.py new file mode 100644 index 000000000..d0c42dcdf --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_trade_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockHistoryTradeQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_trade_quote_venue.py b/openapi_project/openapi_package/models/stock_history_trade_quote_venue.py new file mode 100644 index 000000000..976e9fb4c --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_trade_quote_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockHistoryTradeQuoteVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_history_trade_venue.py b/openapi_project/openapi_package/models/stock_history_trade_venue.py new file mode 100644 index 000000000..68004b183 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_history_trade_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockHistoryTradeVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_list_dates_format.py b/openapi_project/openapi_package/models/stock_list_dates_format.py new file mode 100644 index 000000000..81384ea2a --- /dev/null +++ b/openapi_project/openapi_package/models/stock_list_dates_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockListDatesFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_list_dates_request_type.py b/openapi_project/openapi_package/models/stock_list_dates_request_type.py new file mode 100644 index 000000000..4b2f84d2b --- /dev/null +++ b/openapi_project/openapi_package/models/stock_list_dates_request_type.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockListDatesRequestType(str, Enum): + QUOTE = "quote" + TRADE = "trade" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_list_dates_response_200_item.py b/openapi_project/openapi_package/models/stock_list_dates_response_200_item.py new file mode 100644 index 000000000..3509e1463 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_list_dates_response_200_item.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockListDatesResponse200Item") + + + +@_attrs_define +class StockListDatesResponse200Item: + """ + Attributes: + date (str): + symbol (str): + """ + + date: str + symbol: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + date = self.date + + symbol = self.symbol + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "date": date, + "symbol": symbol, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date") + + symbol = d.pop("symbol") + + stock_list_dates_response_200_item = cls( + date=date, + symbol=symbol, + ) + + + + stock_list_dates_response_200_item.additional_properties = d + return stock_list_dates_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_list_symbols_format.py b/openapi_project/openapi_package/models/stock_list_symbols_format.py new file mode 100644 index 000000000..0dbd257e6 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_list_symbols_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockListSymbolsFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_list_symbols_response_200_item.py b/openapi_project/openapi_package/models/stock_list_symbols_response_200_item.py new file mode 100644 index 000000000..aad393270 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_list_symbols_response_200_item.py @@ -0,0 +1,80 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockListSymbolsResponse200Item") + + + +@_attrs_define +class StockListSymbolsResponse200Item: + """ + Attributes: + symbol (str): + """ + + symbol: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + stock_list_symbols_response_200_item = cls( + symbol=symbol, + ) + + + + stock_list_symbols_response_200_item.additional_properties = d + return stock_list_symbols_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_snapshot_ohlc_format.py b/openapi_project/openapi_package/models/stock_snapshot_ohlc_format.py new file mode 100644 index 000000000..1dac3424a --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_ohlc_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockSnapshotOhlcFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_snapshot_ohlc_response_200_item.py b/openapi_project/openapi_package/models/stock_snapshot_ohlc_response_200_item.py new file mode 100644 index 000000000..1c334e179 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_ohlc_response_200_item.py @@ -0,0 +1,136 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockSnapshotOhlcResponse200Item") + + + +@_attrs_define +class StockSnapshotOhlcResponse200Item: + """ + Attributes: + volume (int): + symbol (str): + high (float): + low (float): + count (int): + close (float): + open_ (float): + timestamp (str): + """ + + volume: int + symbol: str + high: float + low: float + count: int + close: float + open_: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + volume = self.volume + + symbol = self.symbol + + high = self.high + + low = self.low + + count = self.count + + close = self.close + + open_ = self.open_ + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "volume": volume, + "symbol": symbol, + "high": high, + "low": low, + "count": count, + "close": close, + "open": open_, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + volume = d.pop("volume") + + symbol = d.pop("symbol") + + high = d.pop("high") + + low = d.pop("low") + + count = d.pop("count") + + close = d.pop("close") + + open_ = d.pop("open") + + timestamp = d.pop("timestamp") + + stock_snapshot_ohlc_response_200_item = cls( + volume=volume, + symbol=symbol, + high=high, + low=low, + count=count, + close=close, + open_=open_, + timestamp=timestamp, + ) + + + + stock_snapshot_ohlc_response_200_item.additional_properties = d + return stock_snapshot_ohlc_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_snapshot_ohlc_venue.py b/openapi_project/openapi_package/models/stock_snapshot_ohlc_venue.py new file mode 100644 index 000000000..9b5bac47d --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_ohlc_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockSnapshotOhlcVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_snapshot_quote_format.py b/openapi_project/openapi_package/models/stock_snapshot_quote_format.py new file mode 100644 index 000000000..49d849b0c --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_quote_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockSnapshotQuoteFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_snapshot_quote_response_200_item.py b/openapi_project/openapi_package/models/stock_snapshot_quote_response_200_item.py new file mode 100644 index 000000000..100ab0ec7 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_quote_response_200_item.py @@ -0,0 +1,152 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockSnapshotQuoteResponse200Item") + + + +@_attrs_define +class StockSnapshotQuoteResponse200Item: + """ + Attributes: + symbol (str): + ask_size (int): + bid_size (int): + ask_exchange (int): + ask_condition (int): + bid_exchange (int): + ask (float): + bid (float): + bid_condition (int): + timestamp (str): + """ + + symbol: str + ask_size: int + bid_size: int + ask_exchange: int + ask_condition: int + bid_exchange: int + ask: float + bid: float + bid_condition: int + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + ask_size = self.ask_size + + bid_size = self.bid_size + + ask_exchange = self.ask_exchange + + ask_condition = self.ask_condition + + bid_exchange = self.bid_exchange + + ask = self.ask + + bid = self.bid + + bid_condition = self.bid_condition + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "ask_size": ask_size, + "bid_size": bid_size, + "ask_exchange": ask_exchange, + "ask_condition": ask_condition, + "bid_exchange": bid_exchange, + "ask": ask, + "bid": bid, + "bid_condition": bid_condition, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + ask_size = d.pop("ask_size") + + bid_size = d.pop("bid_size") + + ask_exchange = d.pop("ask_exchange") + + ask_condition = d.pop("ask_condition") + + bid_exchange = d.pop("bid_exchange") + + ask = d.pop("ask") + + bid = d.pop("bid") + + bid_condition = d.pop("bid_condition") + + timestamp = d.pop("timestamp") + + stock_snapshot_quote_response_200_item = cls( + symbol=symbol, + ask_size=ask_size, + bid_size=bid_size, + ask_exchange=ask_exchange, + ask_condition=ask_condition, + bid_exchange=bid_exchange, + ask=ask, + bid=bid, + bid_condition=bid_condition, + timestamp=timestamp, + ) + + + + stock_snapshot_quote_response_200_item.additional_properties = d + return stock_snapshot_quote_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_snapshot_quote_venue.py b/openapi_project/openapi_package/models/stock_snapshot_quote_venue.py new file mode 100644 index 000000000..aebe1c4f0 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_quote_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockSnapshotQuoteVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_snapshot_trade_format.py b/openapi_project/openapi_package/models/stock_snapshot_trade_format.py new file mode 100644 index 000000000..55a28b469 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_trade_format.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StockSnapshotTradeFormat(str, Enum): + JSON = "json" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/models/stock_snapshot_trade_response_200_item.py b/openapi_project/openapi_package/models/stock_snapshot_trade_response_200_item.py new file mode 100644 index 000000000..3742d0fc8 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_trade_response_200_item.py @@ -0,0 +1,120 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from openapi_project.openapi_package.types import UNSET, Unset + + + + + + + +T = TypeVar("T", bound="StockSnapshotTradeResponse200Item") + + + +@_attrs_define +class StockSnapshotTradeResponse200Item: + """ + Attributes: + symbol (str): + sequence (int): + condition (int): + size (int): + price (float): + timestamp (str): + """ + + symbol: str + sequence: int + condition: int + size: int + price: float + timestamp: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + + + + + def to_dict(self) -> dict[str, Any]: + symbol = self.symbol + + sequence = self.sequence + + condition = self.condition + + size = self.size + + price = self.price + + timestamp = self.timestamp + + + field_dict: dict[str, Any] = {} + field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() + }) + field_dict.update({ + "symbol": symbol, + "sequence": sequence, + "condition": condition, + "size": size, + "price": price, + "timestamp": timestamp, + }) + + return field_dict + + + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + symbol = d.pop("symbol") + + sequence = d.pop("sequence") + + condition = d.pop("condition") + + size = d.pop("size") + + price = d.pop("price") + + timestamp = d.pop("timestamp") + + stock_snapshot_trade_response_200_item = cls( + symbol=symbol, + sequence=sequence, + condition=condition, + size=size, + price=price, + timestamp=timestamp, + ) + + + + stock_snapshot_trade_response_200_item.additional_properties = d + return stock_snapshot_trade_response_200_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/openapi_project/openapi_package/models/stock_snapshot_trade_venue.py b/openapi_project/openapi_package/models/stock_snapshot_trade_venue.py new file mode 100644 index 000000000..41fb48c43 --- /dev/null +++ b/openapi_project/openapi_package/models/stock_snapshot_trade_venue.py @@ -0,0 +1,8 @@ +from enum import Enum + +class StockSnapshotTradeVenue(str, Enum): + NQB = "nqb" + UTP_CTA = "utp_cta" + + def __str__(self) -> str: + return str(self.value) diff --git a/openapi_project/openapi_package/py.typed b/openapi_project/openapi_package/py.typed new file mode 100644 index 000000000..1aad32711 --- /dev/null +++ b/openapi_project/openapi_package/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/openapi_project/openapi_package/types.py b/openapi_project/openapi_package/types.py new file mode 100644 index 000000000..12cd8c0dd --- /dev/null +++ b/openapi_project/openapi_package/types.py @@ -0,0 +1,53 @@ +""" Contains some shared types for properties """ + +from collections.abc import Mapping, MutableMapping +from http import HTTPStatus +from typing import BinaryIO, Generic, TypeVar, Literal, IO + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +# The types that `httpx.Client(files=)` can accept, copied from that library. +FileContent = IO[bytes] | bytes | str +FileTypes = ( + # (filename, file (or bytes), content_type) + tuple[str | None, FileContent, str | None] | + # (filename, file (or bytes), content_type, headers) + tuple[str | None, FileContent, str | None, Mapping[str, str]] +) +RequestFiles = list[tuple[str, FileTypes]] + +@define +class File: + """ Contains information for file uploads """ + + payload: BinaryIO + file_name: str | None = None + mime_type: str | None = None + + def to_tuple(self) -> FileTypes: + """ Return a tuple representation that httpx will accept for multipart/form-data """ + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """ A response from an endpoint """ + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: T | None + + +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] diff --git a/openapi_project/pyproject.toml b/openapi_project/pyproject.toml new file mode 100644 index 000000000..e69de29bb diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index a9accab71..610207354 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -12,7 +12,13 @@ import httpcore import httpx -from jinja2 import BaseLoader, ChoiceLoader, Environment, FileSystemLoader, PackageLoader +from jinja2 import ( + BaseLoader, + ChoiceLoader, + Environment, + FileSystemLoader, + PackageLoader, +) from ruamel.yaml import YAML from ruamel.yaml.error import YAMLError @@ -66,8 +72,13 @@ def __init__( keep_trailing_newline=True, ) - self.project_name: str = config.project_name_override or f"{utils.kebab_case(openapi.title).lower()}-client" - self.package_name: str = config.package_name_override or self.project_name.replace("-", "_") + self.project_name: str = ( + config.project_name_override + or f"{utils.kebab_case(openapi.title).lower()}-client" + ) + self.package_name: str = ( + config.package_name_override or self.project_name.replace("-", "_") + ) self.project_dir: Path # Where the generated code will be placed self.package_dir: Path # Where the generated Python module will be placed (same as project_dir if no meta) @@ -113,7 +124,11 @@ def build(self) -> Sequence[GeneratorError]: self.project_dir.mkdir() except FileExistsError: if not self.config.overwrite: - return [GeneratorError(detail="Directory already exists. Delete it or use the --overwrite option.")] + return [ + GeneratorError( + detail="Directory already exists. Delete it or use the --overwrite option." + ) + ] self._create_package() self._build_metadata() self._build_models() @@ -131,7 +146,9 @@ def _run_command(self, cmd: str) -> None: if not command_exists: self.errors.append( GeneratorError( - level=ErrorLevel.WARNING, header="Skipping Integration", detail=f"{cmd_name} is not in PATH" + level=ErrorLevel.WARNING, + header="Skipping Integration", + detail=f"{cmd_name} is not in PATH", ) ) return @@ -162,15 +179,21 @@ def _create_package(self) -> None: package_init = self.package_dir / "__init__.py" package_init_template = self.env.get_template("package_init.py.jinja") - package_init.write_text(package_init_template.render(), encoding=self.config.file_encoding) + package_init.write_text( + package_init_template.render(), encoding=self.config.file_encoding + ) if self.config.meta_type != MetaType.NONE: pytyped = self.package_dir / "py.typed" - pytyped.write_text("# Marker file for PEP 561", encoding=self.config.file_encoding) + pytyped.write_text( + "# Marker file for PEP 561", encoding=self.config.file_encoding + ) types_template = self.env.get_template("types.py.jinja") types_path = self.package_dir / "types.py" - types_path.write_text(types_template.render(), encoding=self.config.file_encoding) + types_path.write_text( + types_template.render(), encoding=self.config.file_encoding + ) def _build_metadata(self) -> None: if self.config.meta_type == MetaType.NONE: @@ -191,7 +214,9 @@ def _build_metadata(self) -> None: # .gitignore git_ignore_path = self.project_dir / ".gitignore" git_ignore_template = self.env.get_template(".gitignore.jinja") - git_ignore_path.write_text(git_ignore_template.render(), encoding=self.config.file_encoding) + git_ignore_path.write_text( + git_ignore_template.render(), encoding=self.config.file_encoding + ) def _build_pyproject_toml(self) -> None: template = "pyproject.toml.jinja" @@ -222,7 +247,9 @@ def _build_models(self) -> None: model_template = self.env.get_template("model.py.jinja") for model in self.openapi.models: module_path = models_dir / f"{model.class_info.module_name}.py" - module_path.write_text(model_template.render(model=model), encoding=self.config.file_encoding) + module_path.write_text( + model_template.render(model=model), encoding=self.config.file_encoding + ) imports.append(import_string_from_class(model.class_info)) alls.append(model.class_info.name) @@ -233,29 +260,43 @@ def _build_models(self) -> None: for enum in self.openapi.enums: module_path = models_dir / f"{enum.class_info.module_name}.py" if isinstance(enum, LiteralEnumProperty): - module_path.write_text(literal_enum_template.render(enum=enum), encoding=self.config.file_encoding) + module_path.write_text( + literal_enum_template.render(enum=enum), + encoding=self.config.file_encoding, + ) elif enum.value_type is int: - module_path.write_text(int_enum_template.render(enum=enum), encoding=self.config.file_encoding) + module_path.write_text( + int_enum_template.render(enum=enum), + encoding=self.config.file_encoding, + ) else: - module_path.write_text(str_enum_template.render(enum=enum), encoding=self.config.file_encoding) + module_path.write_text( + str_enum_template.render(enum=enum), + encoding=self.config.file_encoding, + ) imports.append(import_string_from_class(enum.class_info)) alls.append(enum.class_info.name) models_init_template = self.env.get_template("models_init.py.jinja") models_init.write_text( - models_init_template.render(imports=imports, alls=alls), encoding=self.config.file_encoding + models_init_template.render(imports=imports, alls=alls), + encoding=self.config.file_encoding, ) def _build_api(self) -> None: # Generate Client client_path = self.package_dir / "client.py" client_template = self.env.get_template("client.py.jinja") - client_path.write_text(client_template.render(), encoding=self.config.file_encoding) + client_path.write_text( + client_template.render(), encoding=self.config.file_encoding + ) # Generate included Errors errors_path = self.package_dir / "errors.py" errors_template = self.env.get_template("errors.py.jinja") - errors_path.write_text(errors_template.render(), encoding=self.config.file_encoding) + errors_path.write_text( + errors_template.render(), encoding=self.config.file_encoding + ) # Generate endpoints api_dir = self.package_dir / "api" @@ -263,11 +304,14 @@ def _build_api(self) -> None: api_dir.mkdir() api_init_path = api_dir / "__init__.py" api_init_template = self.env.get_template("api_init.py.jinja") - api_init_path.write_text(api_init_template.render(), encoding=self.config.file_encoding) + api_init_path.write_text( + api_init_template.render(), encoding=self.config.file_encoding + ) endpoint_collections_by_tag = self.openapi.endpoint_collections_by_tag endpoint_template = self.env.get_template( - "endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"} + "endpoint_module.py.jinja", + globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"}, ) for tag, collection in endpoint_collections_by_tag.items(): tag_dir = api_dir / tag @@ -281,7 +325,10 @@ def _build_api(self) -> None: ) for endpoint in collection.endpoints: - module_path = tag_dir / f"{utils.PythonIdentifier(endpoint.name, self.config.field_prefix)}.py" + module_path = ( + tag_dir + / f"{utils.PythonIdentifier(endpoint.name, self.config.field_prefix)}.py" + ) module_path.write_text( endpoint_template.render( endpoint=endpoint, @@ -294,7 +341,9 @@ def _get_project_for_url_or_path( config: Config, custom_template_path: Optional[Path] = None, ) -> Union[Project, GeneratorError]: - data_dict = _get_document(source=config.document_source, timeout=config.http_timeout) + data_dict = _get_document( + source=config.document_source, timeout=config.http_timeout + ) if isinstance(data_dict, GeneratorError): return data_dict openapi = GeneratorData.from_dict(data_dict, config=config) @@ -327,7 +376,9 @@ def generate( return project.build() -def _load_yaml_or_json(data: bytes, content_type: Optional[str]) -> Union[dict[str, Any], GeneratorError]: +def _load_yaml_or_json( + data: bytes, content_type: Optional[str] +) -> Union[dict[str, Any], GeneratorError]: if content_type == "application/json": try: return json.loads(data.decode()) @@ -341,7 +392,9 @@ def _load_yaml_or_json(data: bytes, content_type: Optional[str]) -> Union[dict[s return GeneratorError(header=f"Invalid YAML from provided source: {err}") -def _get_document(*, source: Union[str, Path], timeout: int) -> Union[dict[str, Any], GeneratorError]: +def _get_document( + *, source: Union[str, Path], timeout: int +) -> Union[dict[str, Any], GeneratorError]: yaml_bytes: bytes content_type: Optional[str] if isinstance(source, str): @@ -354,7 +407,9 @@ def _get_document(*, source: Union[str, Path], timeout: int) -> Union[dict[str, content_type = mimetypes.guess_type(source, strict=True)[0] except (httpx.HTTPError, httpcore.NetworkError): - return GeneratorError(header="Could not get OpenAPI document from provided URL") + return GeneratorError( + header="Could not get OpenAPI document from provided URL" + ) else: yaml_bytes = source.read_bytes() content_type = mimetypes.guess_type(source.absolute().as_uri(), strict=True)[0] diff --git a/openapi_python_client/cli.py b/openapi_python_client/cli.py index 4b55e4bc9..2af684ae8 100644 --- a/openapi_python_client/cli.py +++ b/openapi_python_client/cli.py @@ -55,7 +55,14 @@ def _process_config( except Exception as err: raise typer.BadParameter("Unable to parse config") from err - return Config.from_sources(config_file, meta_type, source, file_encoding, overwrite, output_path=output_path) + return Config.from_sources( + config_file, + meta_type, + source, + file_encoding, + overwrite, + output_path=output_path, + ) # noinspection PyUnusedLocal @@ -63,7 +70,12 @@ def _process_config( @app.callback() def cli( - version: bool = typer.Option(False, "--version", callback=_version_callback, help="Print the version and exit"), + version: bool = typer.Option( + False, + "--version", + callback=_version_callback, + help="Print the version and exit", + ), ) -> None: """Generate a Python client from an OpenAPI document""" @@ -82,7 +94,9 @@ def _print_parser_error(err: GeneratorError, color: str) -> None: typer.echo() -def handle_errors(errors: Sequence[GeneratorError], fail_on_warning: bool = False) -> None: +def handle_errors( + errors: Sequence[GeneratorError], fail_on_warning: bool = False +) -> None: """Turn custom errors into formatted error messages""" if len(errors) == 0: return @@ -110,7 +124,8 @@ def handle_errors(errors: Sequence[GeneratorError], fail_on_warning: bool = Fals _print_parser_error(err, color) gh_link = typer.style( - "https://github.com/openapi-generators/openapi-python-client/issues/new/choose", fg=typer.colors.BRIGHT_BLUE + "https://github.com/openapi-generators/openapi-python-client/issues/new/choose", + fg=typer.colors.BRIGHT_BLUE, ) typer.secho( f"If you believe this was a mistake or this tool is missing a feature you need, " @@ -125,7 +140,9 @@ def handle_errors(errors: Sequence[GeneratorError], fail_on_warning: bool = Fals @app.command() def generate( - url: Optional[str] = typer.Option(None, help="A URL to read the OpenAPI document from"), + url: Optional[str] = typer.Option( + None, help="A URL to read the OpenAPI document from" + ), path: Optional[Path] = typer.Option(None, help="A path to the OpenAPI document"), custom_template_path: Optional[Path] = typer.Option( None, @@ -139,10 +156,16 @@ def generate( MetaType.POETRY, help="The type of metadata you want to generate.", ), - file_encoding: str = typer.Option("utf-8", help="Encoding used when writing generated"), - config_path: Optional[Path] = typer.Option(None, "--config", help="Path to the config file to use"), + file_encoding: str = typer.Option( + "utf-8", help="Encoding used when writing generated" + ), + config_path: Optional[Path] = typer.Option( + None, "--config", help="Path to the config file to use" + ), fail_on_warning: bool = False, - overwrite: bool = typer.Option(False, help="Overwrite the existing client if it exists"), + overwrite: bool = typer.Option( + False, help="Overwrite the existing client if it exists" + ), output_path: Optional[Path] = typer.Option( None, help="Path to write the generated code to. " diff --git a/openapi_python_client/parser/bodies.py b/openapi_python_client/parser/bodies.py index 7d0b12954..3a57b64df 100644 --- a/openapi_python_client/parser/bodies.py +++ b/openapi_python_client/parser/bodies.py @@ -24,6 +24,7 @@ class BodyType(StrEnum): DATA = "data" FILES = "files" CONTENT = "content" + else: from enum import Enum @@ -87,7 +88,10 @@ def body_from_data( body_type = BodyType.FILES elif simplified_content_type == "application/octet-stream": body_type = BodyType.CONTENT - elif simplified_content_type == "application/json" or simplified_content_type.endswith("+json"): + elif ( + simplified_content_type == "application/json" + or simplified_content_type.endswith("+json") + ): body_type = BodyType.JSON else: bodies.append( @@ -103,7 +107,9 @@ def body_from_data( required=True, data=media_type_schema, schemas=schemas, - parent_name=f"{endpoint_name}_{body_type}" if prefix_type_names else endpoint_name, + parent_name=( + f"{endpoint_name}_{body_type}" if prefix_type_names else endpoint_name + ), config=config, ) if isinstance(prop, ParseError): @@ -132,7 +138,8 @@ def body_from_data( def _resolve_reference( - body: Union[oai.RequestBody, oai.Reference, None], request_bodies: dict[str, Union[oai.RequestBody, oai.Reference]] + body: Union[oai.RequestBody, oai.Reference, None], + request_bodies: dict[str, Union[oai.RequestBody, oai.Reference]], ) -> Union[oai.RequestBody, ParseError, None]: if body is None: return None @@ -143,5 +150,7 @@ def _resolve_reference( if isinstance(body, oai.Reference): return ParseError(detail="Circular $ref in request body", data=body) if body is None and references_seen: - return ParseError(detail=f"Could not resolve $ref {references_seen[-1]} in request body") + return ParseError( + detail=f"Could not resolve $ref {references_seen[-1]} in request body" + ) return body diff --git a/openapi_python_client/parser/errors.py b/openapi_python_client/parser/errors.py index 36322f0cf..1281ac660 100644 --- a/openapi_python_client/parser/errors.py +++ b/openapi_python_client/parser/errors.py @@ -2,7 +2,13 @@ from enum import Enum from typing import Optional -__all__ = ["ErrorLevel", "GeneratorError", "ParameterError", "ParseError", "PropertyError"] +__all__ = [ + "ErrorLevel", + "GeneratorError", + "ParameterError", + "ParseError", + "PropertyError", +] from pydantic import BaseModel diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index 0aab5a717..0c2cde99c 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -65,11 +65,17 @@ def from_data( if operation is None: continue - tags = [utils.PythonIdentifier(value=tag, prefix="tag") for tag in operation.tags or ["default"]] + tags = [ + utils.PythonIdentifier(value=tag, prefix="tag") + for tag in operation.tags or ["default"] + ] if not config.generate_all_tags: tags = tags[:1] - collections = [endpoints_by_tag.setdefault(tag, EndpointCollection(tag=tag)) for tag in tags] + collections = [ + endpoints_by_tag.setdefault(tag, EndpointCollection(tag=tag)) + for tag in tags + ] endpoint, schemas, parameters = Endpoint.from_data( data=operation, @@ -125,7 +131,12 @@ class RequestBodyParser(Protocol): __name__: str = "RequestBodyParser" def __call__( - self, *, body: oai.RequestBody, schemas: Schemas, parent_name: str, config: Config + self, + *, + body: oai.RequestBody, + schemas: Schemas, + parent_name: str, + config: Config, ) -> tuple[Union[Property, PropertyError, None], Schemas]: ... # pragma: no cover @@ -186,7 +197,9 @@ def _add_responses( config=config, ) if isinstance(response, ParseError): - detail_suffix = "" if response.detail is None else f" ({response.detail})" + detail_suffix = ( + "" if response.detail is None else f" ({response.detail})" + ) endpoint.errors.append( ParseError( detail=( @@ -199,8 +212,12 @@ def _add_responses( continue # No reasons to use lazy imports in endpoints, so add lazy imports to relative here. - endpoint.relative_imports |= response.prop.get_lazy_imports(prefix=models_relative_prefix) - endpoint.relative_imports |= response.prop.get_imports(prefix=models_relative_prefix) + endpoint.relative_imports |= response.prop.get_lazy_imports( + prefix=models_relative_prefix + ) + endpoint.relative_imports |= response.prop.get_imports( + prefix=models_relative_prefix + ) endpoint.responses.append(response) return endpoint, schemas @@ -251,7 +268,9 @@ def add_parameters( for param in data.parameters: # Obtain the parameter from the reference or just the parameter itself - param_or_error = parameter_from_reference(param=param, parameters=parameters) + param_or_error = parameter_from_reference( + param=param, parameters=parameters + ) if isinstance(param_or_error, ParseError): return param_or_error, schemas, parameters param = param_or_error # noqa: PLW2901 @@ -277,7 +296,9 @@ def add_parameters( unique_parameters.add(unique_param) if any( - other_param for other_param in parameters_by_location[param.param_in] if other_param.name == param.name + other_param + for other_param in parameters_by_location[param.param_in] + if other_param.name == param.name ): # Defined at the operation level, ignore it here continue @@ -309,17 +330,27 @@ def add_parameters( return location_error, schemas, parameters # No reasons to use lazy imports in endpoints, so add lazy imports to relative here. - endpoint.relative_imports.update(prop.get_lazy_imports(prefix=models_relative_prefix)) - endpoint.relative_imports.update(prop.get_imports(prefix=models_relative_prefix)) + endpoint.relative_imports.update( + prop.get_lazy_imports(prefix=models_relative_prefix) + ) + endpoint.relative_imports.update( + prop.get_imports(prefix=models_relative_prefix) + ) parameters_by_location[param.param_in].append(prop) - return endpoint._check_parameters_for_conflicts(config=config), schemas, parameters + return ( + endpoint._check_parameters_for_conflicts(config=config), + schemas, + parameters, + ) def _check_parameters_for_conflicts( self, *, config: Config, - previously_modified_params: Optional[set[tuple[oai.ParameterLocation, str]]] = None, + previously_modified_params: Optional[ + set[tuple[oai.ParameterLocation, str]] + ] = None, ) -> Union["Endpoint", ParseError]: """Check for conflicting parameters @@ -331,13 +362,17 @@ def _check_parameters_for_conflicts( unique python_name. """ modified_params = previously_modified_params or set() - used_python_names: dict[PythonIdentifier, tuple[oai.ParameterLocation, Property]] = {} + used_python_names: dict[ + PythonIdentifier, tuple[oai.ParameterLocation, Property] + ] = {} reserved_names = ["client", "url"] for parameter in self.iter_all_parameters(): location, prop = parameter if prop.python_name in reserved_names: - prop.set_python_name(new_name=f"{prop.python_name}_{location}", config=config) + prop.set_python_name( + new_name=f"{prop.python_name}_{location}", config=config + ) modified_params.add((location, prop.name)) continue @@ -356,12 +391,19 @@ def _check_parameters_for_conflicts( if location != conflicting_location: conflicting_prop.set_python_name( - new_name=f"{conflicting_prop.python_name}_{conflicting_location}", config=config + new_name=f"{conflicting_prop.python_name}_{conflicting_location}", + config=config, + ) + prop.set_python_name( + new_name=f"{prop.python_name}_{location}", config=config ) - prop.set_python_name(new_name=f"{prop.python_name}_{location}", config=config) elif conflicting_prop.name != prop.name: # Use the name to differentiate - conflicting_prop.set_python_name(new_name=conflicting_prop.name, config=config, skip_snake_case=True) - prop.set_python_name(new_name=prop.name, config=config, skip_snake_case=True) + conflicting_prop.set_python_name( + new_name=conflicting_prop.name, config=config, skip_snake_case=True + ) + prop.set_python_name( + new_name=prop.name, config=config, skip_snake_case=True + ) modified_params.add((location, conflicting_prop.name)) modified_params.add((conflicting_location, conflicting_prop.name)) @@ -369,7 +411,9 @@ def _check_parameters_for_conflicts( used_python_names[conflicting_prop.python_name] = conflicting if len(modified_params) > 0 and modified_params != previously_modified_params: - return self._check_parameters_for_conflicts(config=config, previously_modified_params=modified_params) + return self._check_parameters_for_conflicts( + config=config, previously_modified_params=modified_params + ) return self @staticmethod @@ -398,7 +442,9 @@ def sort_parameters(*, endpoint: "Endpoint") -> Union["Endpoint", ParseError]: detail=f"Incorrect path templating for {endpoint.path} (Path parameters do not match with path)", ) for parameter in endpoint.path_parameters: - endpoint.path = endpoint.path.replace(f"{{{parameter.name}}}", f"{{{parameter.python_name}}}") + endpoint.path = endpoint.path.replace( + f"{{{parameter.name}}}", f"{{{parameter.python_name}}}" + ) return endpoint @staticmethod @@ -425,7 +471,11 @@ def from_data( path=path, method=method, summary=utils.remove_string_escapes(data.summary) if data.summary else "", - description=utils.remove_string_escapes(data.description) if data.description else "", + description=( + utils.remove_string_escapes(data.description) + if data.description + else "" + ), name=name, requires_security=bool(data.security), tags=tags, @@ -450,7 +500,11 @@ def from_data( if isinstance(result, ParseError): return result, schemas, parameters bodies, schemas = body_from_data( - data=data, schemas=schemas, config=config, endpoint_name=result.name, request_bodies=request_bodies + data=data, + schemas=schemas, + config=config, + endpoint_name=result.name, + request_bodies=request_bodies, ) body_errors = [] for body in bodies: @@ -458,8 +512,12 @@ def from_data( body_errors.append(body) continue result.bodies.append(body) - result.relative_imports.update(body.prop.get_imports(prefix=models_relative_prefix)) - result.relative_imports.update(body.prop.get_lazy_imports(prefix=models_relative_prefix)) + result.relative_imports.update( + body.prop.get_imports(prefix=models_relative_prefix) + ) + result.relative_imports.update( + body.prop.get_lazy_imports(prefix=models_relative_prefix) + ) if len(result.bodies) > 0: result.errors.extend(body_errors) elif len(body_errors) > 0: @@ -476,19 +534,29 @@ def from_data( def response_type(self) -> str: """Get the Python type of any response from this endpoint""" - types = sorted({response.prop.get_type_string(quoted=False) for response in self.responses}) + types = sorted( + {response.prop.get_type_string(quoted=False) for response in self.responses} + ) if len(types) == 0: return "Any" if len(types) == 1: return self.responses[0].prop.get_type_string(quoted=False) - return f"Union[{', '.join(types)}]" + return f"{' | '.join(types)}" def iter_all_parameters(self) -> Iterator[tuple[oai.ParameterLocation, Property]]: """Iterate through all the parameters of this endpoint""" - yield from ((oai.ParameterLocation.PATH, param) for param in self.path_parameters) - yield from ((oai.ParameterLocation.QUERY, param) for param in self.query_parameters) - yield from ((oai.ParameterLocation.HEADER, param) for param in self.header_parameters) - yield from ((oai.ParameterLocation.COOKIE, param) for param in self.cookie_parameters) + yield from ( + (oai.ParameterLocation.PATH, param) for param in self.path_parameters + ) + yield from ( + (oai.ParameterLocation.QUERY, param) for param in self.query_parameters + ) + yield from ( + (oai.ParameterLocation.HEADER, param) for param in self.header_parameters + ) + yield from ( + (oai.ParameterLocation.COOKIE, param) for param in self.cookie_parameters + ) def list_all_parameters(self) -> list[Property]: """Return a list of all the parameters of this endpoint""" @@ -514,7 +582,9 @@ class GeneratorData: enums: list[Union[EnumProperty, LiteralEnumProperty]] @staticmethod - def from_dict(data: dict[str, Any], *, config: Config) -> Union["GeneratorData", GeneratorError]: + def from_dict( + data: dict[str, Any], *, config: Config + ) -> Union["GeneratorData", GeneratorError]: """Create an OpenAPI from dict""" try: openapi = oai.OpenAPI.model_validate(data) @@ -522,13 +592,18 @@ def from_dict(data: dict[str, Any], *, config: Config) -> Union["GeneratorData", detail = str(err) if "swagger" in data: detail = ( - "You may be trying to use a Swagger document; this is not supported by this project.\n\n" + detail + "You may be trying to use a Swagger document; this is not supported by this project.\n\n" + + detail ) - return GeneratorError(header="Failed to parse OpenAPI document", detail=detail) + return GeneratorError( + header="Failed to parse OpenAPI document", detail=detail + ) schemas = Schemas() parameters = Parameters() if openapi.components and openapi.components.schemas: - schemas = build_schemas(components=openapi.components.schemas, schemas=schemas, config=config) + schemas = build_schemas( + components=openapi.components.schemas, schemas=schemas, config=config + ) if openapi.components and openapi.components.parameters: parameters = build_parameters( components=openapi.components.parameters, @@ -547,9 +622,15 @@ def from_dict(data: dict[str, Any], *, config: Config) -> Union["GeneratorData", ) enums = [ - prop for prop in schemas.classes_by_name.values() if isinstance(prop, (EnumProperty, LiteralEnumProperty)) + prop + for prop in schemas.classes_by_name.values() + if isinstance(prop, (EnumProperty, LiteralEnumProperty)) + ] + models = [ + prop + for prop in schemas.classes_by_name.values() + if isinstance(prop, ModelProperty) ] - models = [prop for prop in schemas.classes_by_name.values() if isinstance(prop, ModelProperty)] return GeneratorData( title=openapi.info.title, diff --git a/openapi_python_client/parser/properties/__init__.py b/openapi_python_client/parser/properties/__init__.py index ba667347b..c0d9c5727 100644 --- a/openapi_python_client/parser/properties/__init__.py +++ b/openapi_python_client/parser/properties/__init__.py @@ -51,7 +51,14 @@ def _string_based_property( name: str, required: bool, data: oai.Schema, config: Config -) -> StringProperty | DateProperty | DateTimeProperty | FileProperty | UuidProperty | PropertyError: +) -> ( + StringProperty + | DateProperty + | DateTimeProperty + | FileProperty + | UuidProperty + | PropertyError +): """Construct a Property from the type "string" """ string_format = data.schema_format python_name = utils.PythonIdentifier(value=name, prefix=config.field_prefix) @@ -116,7 +123,9 @@ def _property_from_ref( existing = schemas.classes_by_reference.get(ref_path) if not existing: return ( - PropertyError(data=data, detail="Could not find reference in parsed models or enums"), + PropertyError( + data=data, detail="Could not find reference in parsed models or enums" + ), schemas, ) @@ -189,7 +198,9 @@ def property_from_data( # noqa: PLR0911, PLR0912 name=name, required=required, default=data.default, - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=data.description, example=data.example, ), @@ -229,14 +240,18 @@ def property_from_data( # noqa: PLR0911, PLR0912 required=required, default=data.default, const=data.const, - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=data.description, ), schemas, ) if data.type == oai.DataType.STRING: return ( - _string_based_property(name=name, required=required, data=data, config=config), + _string_based_property( + name=name, required=required, data=data, config=config + ), schemas, ) if data.type == oai.DataType.NUMBER: @@ -245,7 +260,9 @@ def property_from_data( # noqa: PLR0911, PLR0912 name=name, default=data.default, required=required, - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=data.description, example=data.example, ), @@ -257,7 +274,9 @@ def property_from_data( # noqa: PLR0911, PLR0912 name=name, default=data.default, required=required, - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=data.description, example=data.example, ), @@ -269,7 +288,9 @@ def property_from_data( # noqa: PLR0911, PLR0912 name=name, required=required, default=None, - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=data.description, example=data.example, ), @@ -286,7 +307,11 @@ def property_from_data( # noqa: PLR0911, PLR0912 process_properties=process_properties, roots=roots, ) - if data.type == oai.DataType.OBJECT or data.allOf or (data.type is None and data.properties): + if ( + data.type == oai.DataType.OBJECT + or data.allOf + or (data.type is None and data.properties) + ): return ModelProperty.build( data=data, name=name, @@ -328,13 +353,19 @@ def _create_schemas( # Only accumulate errors from the last round, since we might fix some along the way for name, data in to_process: if isinstance(data, oai.Reference): - schemas.errors.append(PropertyError(data=data, detail="Reference schemas are not supported.")) + schemas.errors.append( + PropertyError( + data=data, detail="Reference schemas are not supported." + ) + ) continue ref_path = parse_reference_path(f"#/components/schemas/{name}") if isinstance(ref_path, ParseError): schemas.errors.append(PropertyError(detail=ref_path.detail, data=data)) continue - schemas_or_err = update_schemas_with_data(ref_path=ref_path, data=data, schemas=schemas, config=config) + schemas_or_err = update_schemas_with_data( + ref_path=ref_path, data=data, schemas=schemas, config=config + ) if isinstance(schemas_or_err, PropertyError): next_round.append((name, data)) errors.append(schemas_or_err) @@ -347,7 +378,9 @@ def _create_schemas( return schemas -def _propogate_removal(*, root: ReferencePath | utils.ClassName, schemas: Schemas, error: PropertyError) -> None: +def _propogate_removal( + *, root: ReferencePath | utils.ClassName, schemas: Schemas, error: PropertyError +) -> None: if isinstance(root, utils.ClassName): schemas.classes_by_name.pop(root, None) return @@ -386,7 +419,9 @@ def _process_models(*, schemas: Schemas, config: Config) -> Schemas: schemas_or_err = process_model(model_prop, schemas=schemas, config=config) if isinstance(schemas_or_err, PropertyError): schemas_or_err.header = f"\nUnable to process schema {model_prop.name}:" - if isinstance(schemas_or_err.data, oai.Reference) and schemas_or_err.data.ref.endswith( + if isinstance( + schemas_or_err.data, oai.Reference + ) and schemas_or_err.data.ref.endswith( f"/{model_prop.class_info.name}" ): schemas_or_err.detail = schemas_or_err.detail or "" @@ -402,7 +437,9 @@ def _process_models(*, schemas: Schemas, config: Config) -> Schemas: final_model_errors.extend(latest_model_errors) errors = _process_model_errors(final_model_errors, schemas=schemas) - return evolve(schemas, errors=[*schemas.errors, *errors], models_to_process=to_process) + return evolve( + schemas, errors=[*schemas.errors, *errors], models_to_process=to_process + ) def build_schemas( @@ -438,11 +475,17 @@ def build_parameters( # Only accumulate errors from the last round, since we might fix some along the way for name, data in to_process: if isinstance(data, oai.Reference): - parameters.errors.append(ParameterError(data=data, detail="Reference parameters are not supported.")) + parameters.errors.append( + ParameterError( + data=data, detail="Reference parameters are not supported." + ) + ) continue ref_path = parse_reference_path(f"#/components/parameters/{name}") if isinstance(ref_path, ParseError): - parameters.errors.append(ParameterError(detail=ref_path.detail, data=data)) + parameters.errors.append( + ParameterError(detail=ref_path.detail, data=data) + ) continue parameters_or_err = update_parameters_with_data( ref_path=ref_path, data=data, parameters=parameters, config=config diff --git a/openapi_python_client/parser/properties/date.py b/openapi_python_client/parser/properties/date.py index 7261698ea..df994f410 100644 --- a/openapi_python_client/parser/properties/date.py +++ b/openapi_python_client/parser/properties/date.py @@ -69,5 +69,11 @@ def get_imports(self, *, prefix: str) -> set[str]: back to the root of the generated client. """ imports = super().get_imports(prefix=prefix) - imports.update({"import datetime", "from typing import cast", "from dateutil.parser import isoparse"}) + imports.update( + { + "import datetime", + "from typing import cast", + "from dateutil.parser import isoparse", + } + ) return imports diff --git a/openapi_python_client/parser/properties/datetime.py b/openapi_python_client/parser/properties/datetime.py index 5924d173c..7ef5648ec 100644 --- a/openapi_python_client/parser/properties/datetime.py +++ b/openapi_python_client/parser/properties/datetime.py @@ -71,5 +71,11 @@ def get_imports(self, *, prefix: str) -> set[str]: back to the root of the generated client. """ imports = super().get_imports(prefix=prefix) - imports.update({"import datetime", "from typing import cast", "from dateutil.parser import isoparse"}) + imports.update( + { + "import datetime", + "from typing import cast", + "from dateutil.parser import isoparse", + } + ) return imports diff --git a/openapi_python_client/parser/properties/enum_property.py b/openapi_python_client/parser/properties/enum_property.py index 32389c12b..229e5719b 100644 --- a/openapi_python_client/parser/properties/enum_property.py +++ b/openapi_python_client/parser/properties/enum_property.py @@ -69,7 +69,9 @@ def build( # noqa: PLR0911 A tuple containing either the created property or a PropertyError AND update schemas. """ - enum = data.enum or [] # The outer function checks for this, but mypy doesn't know that + enum = ( + data.enum or [] + ) # The outer function checks for this, but mypy doesn't know that # OpenAPI allows for null as an enum value, but it doesn't make sense with how enums are constructed in Python. # So instead, if null is a possible value, make the property nullable. @@ -83,7 +85,9 @@ def build( # noqa: PLR0911 name=name, required=required, default="None", - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=None, example=None, ), @@ -92,17 +96,27 @@ def build( # noqa: PLR0911 value_types = {type(value) for value in unchecked_value_list} if len(value_types) > 1: - return PropertyError( - header="Enum values must all be the same type", detail=f"Got {value_types}", data=data - ), schemas + return ( + PropertyError( + header="Enum values must all be the same type", + detail=f"Got {value_types}", + data=data, + ), + schemas, + ) value_type = next(iter(value_types)) if value_type not in (str, int): - return PropertyError(header=f"Unsupported enum type {value_type}", data=data), schemas + return ( + PropertyError(header=f"Unsupported enum type {value_type}", data=data), + schemas, + ) value_list = cast( Union[list[int], list[str]], unchecked_value_list ) # We checked this with all the value_types stuff - if len(value_list) < len(enum): # Only one of the values was None, that becomes a union + if len(value_list) < len( + enum + ): # Only one of the values was None, that becomes a union data.oneOf = [ oai.Schema(type=DataType.NULL), data.model_copy(update={"enum": value_list, "default": data.default}), @@ -119,9 +133,13 @@ def build( # noqa: PLR0911 class_name = data.title or name if parent_name: - class_name = f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_name)}" + class_name = ( + f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_name)}" + ) class_info = Class.from_string(string=class_name, config=config) - var_names = data.model_extra.get("x-enum-varnames", []) if data.model_extra else [] + var_names = ( + data.model_extra.get("x-enum-varnames", []) if data.model_extra else [] + ) values = EnumProperty.values_from_list(value_list, class_info, var_names) if class_info.name in schemas.classes_by_name: @@ -129,7 +147,8 @@ def build( # noqa: PLR0911 if not isinstance(existing, EnumProperty) or values != existing.values: return ( PropertyError( - detail=f"Found conflicting enums named {class_info.name} with incompatible values.", data=data + detail=f"Found conflicting enums named {class_info.name} with incompatible values.", + data=data, ), schemas, ) @@ -151,7 +170,9 @@ def build( # noqa: PLR0911 return checked_default, schemas prop = evolve(prop, default=checked_default) - schemas = evolve(schemas, classes_by_name={**schemas.classes_by_name, class_info.name: prop}) + schemas = evolve( + schemas, classes_by_name={**schemas.classes_by_name, class_info.name: prop} + ) return prop, schemas def convert_value(self, value: Any) -> Value | PropertyError | None: @@ -160,10 +181,17 @@ def convert_value(self, value: Any) -> Value | PropertyError | None: if isinstance(value, self.value_type): inverse_values = {v: k for k, v in self.values.items()} try: - return Value(python_code=f"{self.class_info.name}.{inverse_values[value]}", raw_value=value) + return Value( + python_code=f"{self.class_info.name}.{inverse_values[value]}", + raw_value=value, + ) except KeyError: - return PropertyError(detail=f"Value {value} is not valid for enum {self.name}") - return PropertyError(detail=f"Cannot convert {value} to enum {self.name} of type {self.value_type}") + return PropertyError( + detail=f"Value {value} is not valid for enum {self.name}" + ) + return PropertyError( + detail=f"Cannot convert {value} to enum {self.name} of type {self.value_type}" + ) def get_base_type_string(self, *, quoted: bool = False) -> str: return self.class_info.name @@ -180,7 +208,9 @@ def get_imports(self, *, prefix: str) -> set[str]: back to the root of the generated client. """ imports = super().get_imports(prefix=prefix) - imports.add(f"from {prefix}models.{self.class_info.module_name} import {self.class_info.name}") + imports.add( + f"from {prefix}models.{self.class_info.module_name} import {self.class_info.name}" + ) return imports @staticmethod diff --git a/openapi_python_client/parser/properties/file.py b/openapi_python_client/parser/properties/file.py index 90bbf6aec..13c153798 100644 --- a/openapi_python_client/parser/properties/file.py +++ b/openapi_python_client/parser/properties/file.py @@ -63,5 +63,7 @@ def get_imports(self, *, prefix: str) -> set[str]: back to the root of the generated client. """ imports = super().get_imports(prefix=prefix) - imports.update({f"from {prefix}types import File, FileTypes", "from io import BytesIO"}) + imports.update( + {f"from {prefix}types import File, FileTypes", "from io import BytesIO"} + ) return imports diff --git a/openapi_python_client/parser/properties/list_property.py b/openapi_python_client/parser/properties/list_property.py index 06d773672..9e2a614ef 100644 --- a/openapi_python_client/parser/properties/list_property.py +++ b/openapi_python_client/parser/properties/list_property.py @@ -95,7 +95,9 @@ def build( required=required, default=None, inner_property=inner_prop, - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=data.description, example=data.example, ), @@ -106,10 +108,10 @@ def convert_value(self, value: Any) -> Value | None | PropertyError: return None # pragma: no cover def get_base_type_string(self, *, quoted: bool = False) -> str: - return f"list[{self.inner_property.get_type_string(quoted=not self.inner_property.is_base_type)}]" + return f"list[{self.inner_property.get_type_string(quoted=False)}]" def get_base_json_type_string(self, *, quoted: bool = False) -> str: - return f"list[{self.inner_property.get_type_string(json=True, quoted=not self.inner_property.is_base_type)}]" + return f"list[{self.inner_property.get_type_string(json=True, quoted=False)}]" def get_instance_type_string(self) -> str: """Get a string representation of runtime type that should be used for `isinstance` checks""" @@ -154,4 +156,4 @@ def get_type_string( if no_optional or self.required: return type_string - return f"Union[Unset, {type_string}]" + return f"Unset | {type_string}" diff --git a/openapi_python_client/parser/properties/literal_enum_property.py b/openapi_python_client/parser/properties/literal_enum_property.py index 669b62f58..3f4ce7a44 100644 --- a/openapi_python_client/parser/properties/literal_enum_property.py +++ b/openapi_python_client/parser/properties/literal_enum_property.py @@ -52,7 +52,9 @@ def build( # noqa: PLR0911 schemas: Schemas, parent_name: str, config: Config, - ) -> tuple[LiteralEnumProperty | NoneProperty | UnionProperty | PropertyError, Schemas]: + ) -> tuple[ + LiteralEnumProperty | NoneProperty | UnionProperty | PropertyError, Schemas + ]: """ Create a LiteralEnumProperty from schema data. @@ -68,7 +70,9 @@ def build( # noqa: PLR0911 A tuple containing either the created property or a PropertyError AND update schemas. """ - enum = data.enum or [] # The outer function checks for this, but mypy doesn't know that + enum = ( + data.enum or [] + ) # The outer function checks for this, but mypy doesn't know that # OpenAPI allows for null as an enum value, but it doesn't make sense with how enums are constructed in Python. # So instead, if null is a possible value, make the property nullable. @@ -82,7 +86,9 @@ def build( # noqa: PLR0911 name=name, required=required, default="None", - python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix), + python_name=utils.PythonIdentifier( + value=name, prefix=config.field_prefix + ), description=None, example=None, ), @@ -91,17 +97,27 @@ def build( # noqa: PLR0911 value_types = {type(value) for value in unchecked_value_list} if len(value_types) > 1: - return PropertyError( - header="Enum values must all be the same type", detail=f"Got {value_types}", data=data - ), schemas + return ( + PropertyError( + header="Enum values must all be the same type", + detail=f"Got {value_types}", + data=data, + ), + schemas, + ) value_type = next(iter(value_types)) if value_type not in (str, int): - return PropertyError(header=f"Unsupported enum type {value_type}", data=data), schemas + return ( + PropertyError(header=f"Unsupported enum type {value_type}", data=data), + schemas, + ) value_list = cast( Union[list[int], list[str]], unchecked_value_list ) # We checked this with all the value_types stuff - if len(value_list) < len(enum): # Only one of the values was None, that becomes a union + if len(value_list) < len( + enum + ): # Only one of the values was None, that becomes a union data.oneOf = [ oai.Schema(type=DataType.NULL), data.model_copy(update={"enum": value_list, "default": data.default}), @@ -118,16 +134,22 @@ def build( # noqa: PLR0911 class_name = data.title or name if parent_name: - class_name = f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_name)}" + class_name = ( + f"{utils.pascal_case(parent_name)}{utils.pascal_case(class_name)}" + ) class_info = Class.from_string(string=class_name, config=config) values: set[str | int] = set(value_list) if class_info.name in schemas.classes_by_name: existing = schemas.classes_by_name[class_info.name] - if not isinstance(existing, LiteralEnumProperty) or values != existing.values: + if ( + not isinstance(existing, LiteralEnumProperty) + or values != existing.values + ): return ( PropertyError( - detail=f"Found conflicting enums named {class_info.name} with incompatible values.", data=data + detail=f"Found conflicting enums named {class_info.name} with incompatible values.", + data=data, ), schemas, ) @@ -149,7 +171,9 @@ def build( # noqa: PLR0911 return checked_default, schemas prop = evolve(prop, default=checked_default) - schemas = evolve(schemas, classes_by_name={**schemas.classes_by_name, class_info.name: prop}) + schemas = evolve( + schemas, classes_by_name={**schemas.classes_by_name, class_info.name: prop} + ) return prop, schemas def convert_value(self, value: Any) -> Value | PropertyError | None: @@ -159,8 +183,12 @@ def convert_value(self, value: Any) -> Value | PropertyError | None: if value in self.values: return Value(python_code=repr(value), raw_value=value) else: - return PropertyError(detail=f"Value {value} is not valid for enum {self.name}") - return PropertyError(detail=f"Cannot convert {value} to enum {self.name} of type {self.value_type}") + return PropertyError( + detail=f"Value {value} is not valid for enum {self.name}" + ) + return PropertyError( + detail=f"Cannot convert {value} to enum {self.name} of type {self.value_type}" + ) def get_base_type_string(self, *, quoted: bool = False) -> str: return self.class_info.name @@ -181,7 +209,9 @@ def get_imports(self, *, prefix: str) -> set[str]: """ imports = super().get_imports(prefix=prefix) imports.add("from typing import cast") - imports.add(f"from {prefix}models.{self.class_info.module_name} import {self.class_info.name}") + imports.add( + f"from {prefix}models.{self.class_info.module_name} import {self.class_info.name}" + ) imports.add( f"from {prefix}models.{self.class_info.module_name} import check_{self.get_class_name_snake_case()}" ) diff --git a/openapi_python_client/parser/properties/merge_properties.py b/openapi_python_client/parser/properties/merge_properties.py index db6424a7c..b88562861 100644 --- a/openapi_python_client/parser/properties/merge_properties.py +++ b/openapi_python_client/parser/properties/merge_properties.py @@ -3,7 +3,9 @@ from openapi_python_client.parser.properties.date import DateProperty from openapi_python_client.parser.properties.datetime import DateTimeProperty from openapi_python_client.parser.properties.file import FileProperty -from openapi_python_client.parser.properties.literal_enum_property import LiteralEnumProperty +from openapi_python_client.parser.properties.literal_enum_property import ( + LiteralEnumProperty, +) __all__ = ["merge_properties"] @@ -27,7 +29,9 @@ STRING_WITH_FORMAT_TYPES = (DateProperty, DateTimeProperty, FileProperty) -def merge_properties(prop1: Property, prop2: Property) -> Property | PropertyError: # noqa: PLR0911 +def merge_properties( + prop1: Property, prop2: Property +) -> Property | PropertyError: # noqa: PLR0911 """Attempt to create a new property that incorporates the behavior of both. This is used when merging schemas with allOf, when two schemas define a property with the same name. @@ -71,7 +75,9 @@ def merge_properties(prop1: Property, prop2: Property) -> Property | PropertyErr ) -def _merge_same_type(prop1: Property, prop2: Property) -> Property | None | PropertyError: +def _merge_same_type( + prop1: Property, prop2: Property +) -> Property | None | PropertyError: if type(prop1) is not type(prop2): return None @@ -82,7 +88,9 @@ def _merge_same_type(prop1: Property, prop2: Property) -> Property | None | Prop if isinstance(prop1, ListProperty) and isinstance(prop2, ListProperty): inner_property = merge_properties(prop1.inner_property, prop2.inner_property) # type: ignore if isinstance(inner_property, PropertyError): - return PropertyError(detail=f"can't merge list properties: {inner_property.detail}") + return PropertyError( + detail=f"can't merge list properties: {inner_property.detail}" + ) prop1.inner_property = inner_property # For all other property types, there aren't any special attributes that affect validation, so just @@ -90,31 +98,45 @@ def _merge_same_type(prop1: Property, prop2: Property) -> Property | None | Prop return _merge_common_attributes(prop1, prop2) -def _merge_string_with_format(prop1: Property, prop2: Property) -> Property | None | PropertyError: +def _merge_string_with_format( + prop1: Property, prop2: Property +) -> Property | None | PropertyError: """Merge a string that has no format with a string that has a format""" # Here we need to use the DateProperty/DateTimeProperty/FileProperty as the base so that we preserve # its class, but keep the correct override order for merging the attributes. - if isinstance(prop1, StringProperty) and isinstance(prop2, STRING_WITH_FORMAT_TYPES): + if isinstance(prop1, StringProperty) and isinstance( + prop2, STRING_WITH_FORMAT_TYPES + ): # Use the more specific class as a base, but keep the correct override order return _merge_common_attributes(prop2, prop1, prop2) - elif isinstance(prop2, StringProperty) and isinstance(prop1, STRING_WITH_FORMAT_TYPES): + elif isinstance(prop2, StringProperty) and isinstance( + prop1, STRING_WITH_FORMAT_TYPES + ): return _merge_common_attributes(prop1, prop2) else: return None -def _merge_numeric(prop1: Property, prop2: Property) -> IntProperty | None | PropertyError: +def _merge_numeric( + prop1: Property, prop2: Property +) -> IntProperty | None | PropertyError: """Merge IntProperty with FloatProperty""" - if isinstance(prop1, IntProperty) and isinstance(prop2, (IntProperty, FloatProperty)): + if isinstance(prop1, IntProperty) and isinstance( + prop2, (IntProperty, FloatProperty) + ): return _merge_common_attributes(prop1, prop2) - elif isinstance(prop2, IntProperty) and isinstance(prop1, (IntProperty, FloatProperty)): + elif isinstance(prop2, IntProperty) and isinstance( + prop1, (IntProperty, FloatProperty) + ): # Use the IntProperty as a base since it's more restrictive, but keep the correct override order return _merge_common_attributes(prop2, prop1, prop2) else: return None -def _merge_with_enum(prop1: PropertyProtocol, prop2: PropertyProtocol) -> EnumProperty | PropertyError: +def _merge_with_enum( + prop1: PropertyProtocol, prop2: PropertyProtocol +) -> EnumProperty | PropertyError: if isinstance(prop1, EnumProperty) and isinstance(prop2, EnumProperty): # We want the narrowest validation rules that fit both, so use whichever values list is a # subset of the other. @@ -125,8 +147,12 @@ def _merge_with_enum(prop1: PropertyProtocol, prop2: PropertyProtocol) -> EnumPr values = prop2.values class_info = prop2.class_info else: - return PropertyError(detail="can't redefine an enum property with incompatible lists of values") - return _merge_common_attributes(evolve(prop1, values=values, class_info=class_info), prop2) + return PropertyError( + detail="can't redefine an enum property with incompatible lists of values" + ) + return _merge_common_attributes( + evolve(prop1, values=values, class_info=class_info), prop2 + ) # If enum values were specified for just one of the properties, use those. enum_prop = prop1 if isinstance(prop1, EnumProperty) else cast(EnumProperty, prop2) @@ -140,8 +166,12 @@ def _merge_with_enum(prop1: PropertyProtocol, prop2: PropertyProtocol) -> EnumPr ) -def _merge_with_literal_enum(prop1: PropertyProtocol, prop2: PropertyProtocol) -> LiteralEnumProperty | PropertyError: - if isinstance(prop1, LiteralEnumProperty) and isinstance(prop2, LiteralEnumProperty): +def _merge_with_literal_enum( + prop1: PropertyProtocol, prop2: PropertyProtocol +) -> LiteralEnumProperty | PropertyError: + if isinstance(prop1, LiteralEnumProperty) and isinstance( + prop2, LiteralEnumProperty + ): # We want the narrowest validation rules that fit both, so use whichever values list is a # subset of the other. if prop1.values <= prop2.values: @@ -151,11 +181,19 @@ def _merge_with_literal_enum(prop1: PropertyProtocol, prop2: PropertyProtocol) - values = prop2.values class_info = prop2.class_info else: - return PropertyError(detail="can't redefine a literal enum property with incompatible lists of values") - return _merge_common_attributes(evolve(prop1, values=values, class_info=class_info), prop2) + return PropertyError( + detail="can't redefine a literal enum property with incompatible lists of values" + ) + return _merge_common_attributes( + evolve(prop1, values=values, class_info=class_info), prop2 + ) # If enum values were specified for just one of the properties, use those. - enum_prop = prop1 if isinstance(prop1, LiteralEnumProperty) else cast(LiteralEnumProperty, prop2) + enum_prop = ( + prop1 + if isinstance(prop1, LiteralEnumProperty) + else cast(LiteralEnumProperty, prop2) + ) non_enum_prop = prop2 if isinstance(prop1, LiteralEnumProperty) else prop1 if (isinstance(non_enum_prop, IntProperty) and enum_prop.value_type is int) or ( isinstance(non_enum_prop, StringProperty) and enum_prop.value_type is str @@ -166,7 +204,9 @@ def _merge_with_literal_enum(prop1: PropertyProtocol, prop2: PropertyProtocol) - ) -def _merge_common_attributes(base: PropertyT, *extend_with: PropertyProtocol) -> PropertyT | PropertyError: +def _merge_common_attributes( + base: PropertyT, *extend_with: PropertyProtocol +) -> PropertyT | PropertyError: """Create a new instance based on base, overriding basic attributes with values from extend_with, in order. For "default", "description", and "example", a non-None value overrides any value from a previously diff --git a/openapi_python_client/parser/properties/model_property.py b/openapi_python_client/parser/properties/model_property.py index 805de1c7b..c6c7b0bbd 100644 --- a/openapi_python_client/parser/properties/model_property.py +++ b/openapi_python_client/parser/properties/model_property.py @@ -70,7 +70,9 @@ def build( else: title = data.title or name if parent_name: - class_string = f"{utils.pascal_case(parent_name)}{utils.pascal_case(title)}" + class_string = ( + f"{utils.pascal_case(parent_name)}{utils.pascal_case(title)}" + ) else: class_string = title class_info = Class.from_string(string=class_string, config=config) @@ -82,7 +84,11 @@ def build( additional_properties: Property | None = None if process_properties: data_or_err, schemas = _process_property_data( - data=data, schemas=schemas, class_info=class_info, config=config, roots=model_roots + data=data, + schemas=schemas, + class_info=class_info, + config=config, + roots=model_roots, ) if isinstance(data_or_err, PropertyError): return data_or_err, schemas @@ -114,7 +120,8 @@ def build( ) if class_info.name in schemas.classes_by_name: error = PropertyError( - data=data, detail=f'Attempted to generate duplicate models with name "{class_info.name}"' + data=data, + detail=f'Attempted to generate duplicate models with name "{class_info.name}"', ) return error, schemas @@ -128,7 +135,9 @@ def build( @classmethod def convert_value(cls, value: Any) -> Value | None | PropertyError: if value is not None: - return PropertyError(detail="ModelProperty cannot have a default value") # pragma: no cover + return PropertyError( + detail="ModelProperty cannot have a default value" + ) # pragma: no cover return None def __attrs_post_init__(self) -> None: @@ -141,7 +150,7 @@ def self_import(self) -> str: return f"models.{self.class_info.module_name} import {self.class_info.name}" def get_base_type_string(self, *, quoted: bool = False) -> str: - return f'"{self.class_info.name}"' if quoted else self.class_info.name + return self.class_info.name def get_imports(self, *, prefix: str) -> set[str]: """ @@ -174,7 +183,11 @@ def set_relative_imports(self, relative_imports: set[str]) -> None: Args: relative_imports: The set of relative import strings """ - object.__setattr__(self, "relative_imports", {ri for ri in relative_imports if self.self_import not in ri}) + object.__setattr__( + self, + "relative_imports", + {ri for ri in relative_imports if self.self_import not in ri}, + ) def set_lazy_imports(self, lazy_imports: set[str]) -> None: """Set the lazy imports set for this ModelProperty, filtering out self imports @@ -182,7 +195,11 @@ def set_lazy_imports(self, lazy_imports: set[str]) -> None: Args: lazy_imports: The set of lazy import strings """ - object.__setattr__(self, "lazy_imports", {li for li in lazy_imports if self.self_import not in li}) + object.__setattr__( + self, + "lazy_imports", + {li for li in lazy_imports if self.self_import not in li}, + ) def get_type_string( self, @@ -203,19 +220,17 @@ def get_type_string( else: type_string = self.get_base_type_string() - if quoted: - if type_string == self.class_info.name: - type_string = f"'{type_string}'" - if no_optional or self.required: return type_string - return f"Union[Unset, {type_string}]" + return f"Unset | {type_string}" from .property import Property # noqa: E402 -def _resolve_naming_conflict(first: Property, second: Property, config: Config) -> PropertyError | None: +def _resolve_naming_conflict( + first: Property, second: Property, config: Config +) -> PropertyError | None: first.set_python_name(first.name, config=config, skip_snake_case=True) second.set_python_name(second.name, config=config, skip_snake_case=True) if first.python_name == second.python_name: @@ -254,7 +269,9 @@ def _add_if_no_conflict(new_prop: Property) -> PropertyError | None: nonlocal properties name_conflict = properties.get(new_prop.name) - merged_prop = merge_properties(name_conflict, new_prop) if name_conflict else new_prop + merged_prop = ( + merge_properties(name_conflict, new_prop) if name_conflict else new_prop + ) if isinstance(merged_prop, PropertyError): merged_prop.header = f"Found conflicting properties named {new_prop.name} when creating {class_name}" return merged_prop @@ -286,16 +303,24 @@ def _add_if_no_conflict(new_prop: Property) -> PropertyError | None: return PropertyError("Cannot take allOf a non-object") # Properties of allOf references first should be processed first if not ( - isinstance(sub_model.required_properties, list) and isinstance(sub_model.optional_properties, list) + isinstance(sub_model.required_properties, list) + and isinstance(sub_model.optional_properties, list) + ): + return PropertyError( + f"Reference {sub_model.name} in allOf was not processed", + data=sub_prop, + ) + for prop in chain( + sub_model.required_properties, sub_model.optional_properties ): - return PropertyError(f"Reference {sub_model.name} in allOf was not processed", data=sub_prop) - for prop in chain(sub_model.required_properties, sub_model.optional_properties): err = _add_if_no_conflict(prop) if err is not None: return err schemas.add_dependencies(ref_path=ref_path, roots=roots) else: - unprocessed_props.extend(sub_prop.properties.items() if sub_prop.properties else []) + unprocessed_props.extend( + sub_prop.properties.items() if sub_prop.properties else [] + ) required_set.update(sub_prop.required or []) for key, value in unprocessed_props: @@ -363,7 +388,9 @@ def _get_additional_properties( return ANY_ADDITIONAL_PROPERTY, schemas return None, schemas - if isinstance(schema_additional, oai.Schema) and not any(schema_additional.model_dump().values()): + if isinstance(schema_additional, oai.Schema) and not any( + schema_additional.model_dump().values() + ): # An empty schema return ANY_ADDITIONAL_PROPERTY, schemas @@ -388,7 +415,11 @@ def _process_property_data( roots: set[ReferencePath | utils.ClassName], ) -> tuple[tuple[_PropertyData, Property | None] | PropertyError, Schemas]: property_data = _process_properties( - data=data, schemas=schemas, class_name=class_info.name, config=config, roots=roots + data=data, + schemas=schemas, + class_name=class_info.name, + config=config, + roots=roots, ) if isinstance(property_data, PropertyError): return property_data, schemas @@ -406,13 +437,19 @@ def _process_property_data( elif additional_properties is None: pass else: - property_data.relative_imports.update(additional_properties.get_imports(prefix="..")) - property_data.lazy_imports.update(additional_properties.get_lazy_imports(prefix="..")) + property_data.relative_imports.update( + additional_properties.get_imports(prefix="..") + ) + property_data.lazy_imports.update( + additional_properties.get_lazy_imports(prefix="..") + ) return (property_data, additional_properties), schemas -def process_model(model_prop: ModelProperty, *, schemas: Schemas, config: Config) -> Schemas | PropertyError: +def process_model( + model_prop: ModelProperty, *, schemas: Schemas, config: Config +) -> Schemas | PropertyError: """Populate a ModelProperty instance's property data Args: model_prop: The ModelProperty to build property data for diff --git a/openapi_python_client/parser/properties/protocol.py b/openapi_python_client/parser/properties/protocol.py index 327ba0a5e..5b399d0c0 100644 --- a/openapi_python_client/parser/properties/protocol.py +++ b/openapi_python_client/parser/properties/protocol.py @@ -48,7 +48,9 @@ class PropertyProtocol(Protocol): name: str required: bool _type_string: ClassVar[str] = "" - _json_type_string: ClassVar[str] = "" # Type of the property after JSON serialization + _json_type_string: ClassVar[str] = ( + "" # Type of the property after JSON serialization + ) _allowed_locations: ClassVar[set[oai.ParameterLocation]] = { oai.ParameterLocation.QUERY, oai.ParameterLocation.PATH, @@ -70,12 +72,16 @@ def convert_value(self, value: Any) -> Value | None | PropertyError: def validate_location(self, location: oai.ParameterLocation) -> ParseError | None: """Returns an error if this type of property is not allowed in the given location""" if location not in self._allowed_locations: - return ParseError(detail=f"{self.get_type_string()} is not allowed in {location}") + return ParseError( + detail=f"{self.get_type_string()} is not allowed in {location}" + ) if location == oai.ParameterLocation.PATH and not self.required: return ParseError(detail="Path parameter must be required") return None - def set_python_name(self, new_name: str, config: Config, skip_snake_case: bool = False) -> None: + def set_python_name( + self, new_name: str, config: Config, skip_snake_case: bool = False + ) -> None: """Mutates this Property to set a new python_name. Required to mutate due to how Properties are stored and the difficulty of updating them in-dict. @@ -85,16 +91,28 @@ def set_python_name(self, new_name: str, config: Config, skip_snake_case: bool = object.__setattr__( self, "python_name", - PythonIdentifier(value=new_name, prefix=config.field_prefix, skip_snake_case=skip_snake_case), + PythonIdentifier( + value=new_name, + prefix=config.field_prefix, + skip_snake_case=skip_snake_case, + ), ) def get_base_type_string(self, *, quoted: bool = False) -> str: """Get the string describing the Python type of this property. Base types no require quoting.""" - return f'"{self._type_string}"' if not self.is_base_type and quoted else self._type_string + return ( + f'"{self._type_string}"' + if not self.is_base_type and quoted + else self._type_string + ) def get_base_json_type_string(self, *, quoted: bool = False) -> str: """Get the string describing the JSON type of this property. Base types no require quoting.""" - return f'"{self._json_type_string}"' if not self.is_base_type and quoted else self._json_type_string + return ( + f'"{self._json_type_string}"' + if not self.is_base_type and quoted + else self._json_type_string + ) def get_type_string( self, @@ -118,7 +136,7 @@ def get_type_string( if no_optional or self.required: return type_string - return f"Union[Unset, {type_string}]" + return f"Unset | {type_string}" def get_instance_type_string(self) -> str: """Get a string representation of runtime type that should be used for `isinstance` checks""" @@ -135,7 +153,6 @@ def get_imports(self, *, prefix: str) -> set[str]: """ imports = set() if not self.required: - imports.add("from typing import Union") imports.add(f"from {prefix}types import UNSET, Unset") return imports @@ -159,7 +176,9 @@ def to_string(self) -> str: default = None if default is not None: - return f"{self.python_name}: {self.get_type_string(quoted=True)} = {default}" + return ( + f"{self.python_name}: {self.get_type_string(quoted=True)} = {default}" + ) return f"{self.python_name}: {self.get_type_string(quoted=True)}" def to_docstring(self) -> str: diff --git a/openapi_python_client/parser/properties/schemas.py b/openapi_python_client/parser/properties/schemas.py index acfb21c8d..4bba23bc8 100644 --- a/openapi_python_client/parser/properties/schemas.py +++ b/openapi_python_client/parser/properties/schemas.py @@ -42,7 +42,9 @@ def parse_reference_path(ref_path_raw: str) -> Union[ReferencePath, ParseError]: """ parsed = urlparse(ref_path_raw) if parsed.scheme or parsed.path: - return ParseError(detail=f"Remote references such as {ref_path_raw} are not supported yet.") + return ParseError( + detail=f"Remote references such as {ref_path_raw} are not supported yet." + ) return cast(ReferencePath, parsed.fragment) @@ -84,12 +86,16 @@ class Schemas: """Structure for containing all defined, shareable, and reusable schemas (attr classes and Enums)""" classes_by_reference: dict[ReferencePath, Property] = field(factory=dict) - dependencies: dict[ReferencePath, set[Union[ReferencePath, ClassName]]] = field(factory=dict) + dependencies: dict[ReferencePath, set[Union[ReferencePath, ClassName]]] = field( + factory=dict + ) classes_by_name: dict[ClassName, Property] = field(factory=dict) models_to_process: list[ModelProperty] = field(factory=list) errors: list[ParseError] = field(factory=list) - def add_dependencies(self, ref_path: ReferencePath, roots: set[Union[ReferencePath, ClassName]]) -> None: + def add_dependencies( + self, ref_path: ReferencePath, roots: set[Union[ReferencePath, ClassName]] + ) -> None: """Record new dependencies on the given ReferencePath Args: @@ -136,13 +142,15 @@ def update_schemas_with_data( if isinstance(prop, PropertyError): prop.detail = f"{prop.header}: {prop.detail}" prop.header = f"Unable to parse schema {ref_path}" - if isinstance(prop.data, oai.Reference) and prop.data.ref.endswith(ref_path): # pragma: nocover - prop.detail += ( - "\n\nRecursive and circular references are not supported directly in an array schema's 'items' section" - ) + if isinstance(prop.data, oai.Reference) and prop.data.ref.endswith( + ref_path + ): # pragma: nocover + prop.detail += "\n\nRecursive and circular references are not supported directly in an array schema's 'items' section" return prop - schemas = evolve(schemas, classes_by_reference={ref_path: prop, **schemas.classes_by_reference}) + schemas = evolve( + schemas, classes_by_reference={ref_path: prop, **schemas.classes_by_reference} + ) return schemas @@ -179,13 +187,21 @@ def parameter_from_data( param_in=data.param_in, ) parameters = evolve( - parameters, classes_by_name={**parameters.classes_by_name, ClassName(name, config.field_prefix): new_param} + parameters, + classes_by_name={ + **parameters.classes_by_name, + ClassName(name, config.field_prefix): new_param, + }, ) return new_param, parameters def update_parameters_with_data( - *, ref_path: ReferencePath, data: oai.Parameter, parameters: Parameters, config: Config + *, + ref_path: ReferencePath, + data: oai.Parameter, + parameters: Parameters, + config: Config, ) -> Union[Parameters, ParameterError]: """ Update a `Parameters` using some new reference. @@ -201,19 +217,26 @@ def update_parameters_with_data( See Also: - https://swagger.io/docs/specification/using-ref/ """ - param, parameters = parameter_from_data(data=data, name=data.name, parameters=parameters, config=config) + param, parameters = parameter_from_data( + data=data, name=data.name, parameters=parameters, config=config + ) if isinstance(param, ParameterError): param.detail = f"{param.header}: {param.detail}" param.header = f"Unable to parse parameter {ref_path}" - if isinstance(param.data, oai.Reference) and param.data.ref.endswith(ref_path): # pragma: nocover + if isinstance(param.data, oai.Reference) and param.data.ref.endswith( + ref_path + ): # pragma: nocover param.detail += ( "\n\nRecursive and circular references are not supported. " "See https://github.com/openapi-generators/openapi-python-client/issues/466" ) return param - parameters = evolve(parameters, classes_by_reference={ref_path: param, **parameters.classes_by_reference}) + parameters = evolve( + parameters, + classes_by_reference={ref_path: param, **parameters.classes_by_reference}, + ) return parameters diff --git a/openapi_python_client/parser/properties/string.py b/openapi_python_client/parser/properties/string.py index e40c1eee6..6774cd3b9 100644 --- a/openapi_python_client/parser/properties/string.py +++ b/openapi_python_client/parser/properties/string.py @@ -65,4 +65,6 @@ def convert_value(cls, value: Any) -> Value | None: return value if not isinstance(value, str): value = str(value) - return Value(python_code=repr(utils.remove_string_escapes(value)), raw_value=value) + return Value( + python_code=repr(utils.remove_string_escapes(value)), raw_value=value + ) diff --git a/openapi_python_client/parser/properties/union.py b/openapi_python_client/parser/properties/union.py index 1e47714ff..d611e13e4 100644 --- a/openapi_python_client/parser/properties/union.py +++ b/openapi_python_client/parser/properties/union.py @@ -59,9 +59,13 @@ def build( type_list_data = [] if isinstance(data.type, list): for _type in data.type: - type_list_data.append(data.model_copy(update={"type": _type, "default": None})) + type_list_data.append( + data.model_copy(update={"type": _type, "default": None}) + ) - for i, sub_prop_data in enumerate(chain(data.anyOf, data.oneOf, type_list_data)): + for i, sub_prop_data in enumerate( + chain(data.anyOf, data.oneOf, type_list_data) + ): # If a schema has a unique title property, we can use that to carry forward a descriptive name instead of "type_0" subscript: str if ( @@ -83,16 +87,22 @@ def build( ) if isinstance(sub_prop, PropertyError): return ( - PropertyError(detail=f"Invalid property in union {name}", data=sub_prop_data), + PropertyError( + detail=f"Invalid property in union {name}", data=sub_prop_data + ), schemas, ) sub_properties.append(sub_prop) - def flatten_union_properties(sub_properties: list[PropertyProtocol]) -> list[PropertyProtocol]: + def flatten_union_properties( + sub_properties: list[PropertyProtocol], + ) -> list[PropertyProtocol]: flattened = [] for sub_prop in sub_properties: if isinstance(sub_prop, UnionProperty): - flattened.extend(flatten_union_properties(sub_prop.inner_properties)) + flattened.extend( + flatten_union_properties(sub_prop.inner_properties) + ) else: flattened.append(sub_prop) return flattened @@ -132,7 +142,7 @@ def _get_inner_type_strings(self, json: bool) -> set[str]: p.get_type_string( no_optional=True, json=json, - quoted=not p.is_base_type, + quoted=False, ) for p in self.inner_properties } @@ -144,12 +154,18 @@ def _get_type_string_from_inner_type_strings(inner_types: set[str]) -> str: return f"Union[{', '.join(sorted(inner_types))}]" def get_base_type_string(self, *, quoted: bool = False) -> str: - return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=False)) + return self._get_type_string_from_inner_type_strings( + self._get_inner_type_strings(json=False) + ) def get_base_json_type_string(self, *, quoted: bool = False) -> str: - return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=True)) + return self._get_type_string_from_inner_type_strings( + self._get_inner_type_strings(json=True) + ) - def get_type_strings_in_union(self, *, no_optional: bool = False, json: bool) -> set[str]: + def get_type_strings_in_union( + self, *, no_optional: bool = False, json: bool + ) -> set[str]: """ Get the set of all the types that should appear within the `Union` representing this property. @@ -181,7 +197,9 @@ def get_type_string( This implementation differs slightly from `Property.get_type_string` in order to collapse nested union types. """ - type_strings_in_union = self.get_type_strings_in_union(no_optional=no_optional, json=json) + type_strings_in_union = self.get_type_strings_in_union( + no_optional=no_optional, json=json + ) return self._get_type_string_from_inner_type_strings(type_strings_in_union) def get_imports(self, *, prefix: str) -> set[str]: @@ -209,6 +227,13 @@ def validate_location(self, location: oai.ParameterLocation) -> ParseError | Non from ..properties import Property # noqa: PLC0415 for inner_prop in self.inner_properties: - if evolve(cast(Property, inner_prop), required=self.required).validate_location(location) is not None: - return ParseError(detail=f"{self.get_type_string()} is not allowed in {location}") + if ( + evolve( + cast(Property, inner_prop), required=self.required + ).validate_location(location) + is not None + ): + return ParseError( + detail=f"{self.get_type_string()} is not allowed in {location}" + ) return None diff --git a/openapi_python_client/parser/responses.py b/openapi_python_client/parser/responses.py index ec0f6136b..525ab5ff8 100644 --- a/openapi_python_client/parser/responses.py +++ b/openapi_python_client/parser/responses.py @@ -6,7 +6,10 @@ from attrs import define from openapi_python_client import utils -from openapi_python_client.parser.properties.schemas import get_reference_simple_name, parse_reference_path +from openapi_python_client.parser.properties.schemas import ( + get_reference_simple_name, + parse_reference_path, +) from .. import Config from .. import schema as oai @@ -35,10 +38,14 @@ class Response: status_code: HTTPStatus prop: Property source: _ResponseSource - data: Union[oai.Response, oai.Reference] # Original data which created this response, useful for custom templates + data: Union[ + oai.Response, oai.Reference + ] # Original data which created this response, useful for custom templates -def _source_by_content_type(content_type: str, config: Config) -> Optional[_ResponseSource]: +def _source_by_content_type( + content_type: str, config: Config +) -> Optional[_ResponseSource]: parsed_content_type = utils.get_content_type(content_type, config) if parsed_content_type is None: return None @@ -72,7 +79,9 @@ def empty_response( name=response_name, default=None, required=True, - python_name=PythonIdentifier(value=response_name, prefix=config.field_prefix), + python_name=PythonIdentifier( + value=response_name, prefix=config.field_prefix + ), description=data.description if isinstance(data, oai.Response) else None, example=None, ), @@ -97,12 +106,26 @@ def response_from_data( # noqa: PLR0911 if isinstance(ref_path, ParseError): return ref_path, schemas if not ref_path.startswith("/components/responses/"): - return ParseError(data=data, detail=f"$ref to {data.ref} not allowed in responses"), schemas + return ( + ParseError( + data=data, detail=f"$ref to {data.ref} not allowed in responses" + ), + schemas, + ) resp_data = responses.get(get_reference_simple_name(ref_path), None) if not resp_data: - return ParseError(data=data, detail=f"Could not find reference: {data.ref}"), schemas + return ( + ParseError(data=data, detail=f"Could not find reference: {data.ref}"), + schemas, + ) if not isinstance(resp_data, oai.Response): - return ParseError(data=data, detail="Top-level $ref inside components/responses is not supported"), schemas + return ( + ParseError( + data=data, + detail="Top-level $ref inside components/responses is not supported", + ), + schemas, + ) data = resp_data content = data.content @@ -151,4 +174,7 @@ def response_from_data( # noqa: PLR0911 if isinstance(prop, PropertyError): return prop, schemas - return Response(status_code=status_code, prop=prop, source=source, data=data), schemas + return ( + Response(status_code=status_code, prop=prop, source=source, data=data), + schemas, + ) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/components.py b/openapi_python_client/schema/openapi_schema_pydantic/components.py index ac5e7648d..84bba9e7a 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/components.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/components.py @@ -51,11 +51,17 @@ class Components(BaseModel): }, "Category": { "type": "object", - "properties": {"id": {"type": "integer", "format": "int64"}, "name": {"type": "string"}}, + "properties": { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string"}, + }, }, "Tag": { "type": "object", - "properties": {"id": {"type": "integer", "format": "int64"}, "name": {"type": "string"}}, + "properties": { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string"}, + }, }, }, "parameters": { @@ -79,11 +85,21 @@ class Components(BaseModel): "IllegalInput": {"description": "Illegal input for operation."}, "GeneralError": { "description": "General Error", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/GeneralError"}}}, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GeneralError" + } + } + }, }, }, "securitySchemes": { - "api_key": {"type": "apiKey", "name": "api_key", "in": "header"}, + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header", + }, "petstore_auth": { "type": "oauth2", "flows": { diff --git a/openapi_python_client/schema/openapi_schema_pydantic/contact.py b/openapi_python_client/schema/openapi_schema_pydantic/contact.py index c04fdbbe0..bcf87f3fd 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/contact.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/contact.py @@ -18,7 +18,11 @@ class Contact(BaseModel): extra="allow", json_schema_extra={ "examples": [ - {"name": "API Support", "url": "http://www.example.com/support", "email": "support@example.com"} + { + "name": "API Support", + "url": "http://www.example.com/support", + "email": "support@example.com", + } ] }, ) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/example.py b/openapi_python_client/schema/openapi_schema_pydantic/example.py index 90db2530e..ad2af52ff 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/example.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/example.py @@ -24,7 +24,10 @@ class Example(BaseModel): "summary": "This is an example in XML", "externalValue": "http://example.org/examples/address-example.xml", }, - {"summary": "This is a text example", "externalValue": "http://foo.bar/examples/address-example.txt"}, + { + "summary": "This is a text example", + "externalValue": "http://foo.bar/examples/address-example.txt", + }, ] }, ) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py b/openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py index 2c0c39b7c..c12d2a64e 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py @@ -14,5 +14,9 @@ class ExternalDocumentation(BaseModel): url: str model_config = ConfigDict( extra="allow", - json_schema_extra={"examples": [{"description": "Find more info here", "url": "https://example.com"}]}, + json_schema_extra={ + "examples": [ + {"description": "Find more info here", "url": "https://example.com"} + ] + }, ) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/header.py b/openapi_python_client/schema/openapi_schema_pydantic/header.py index 2deb6f390..08d16248a 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/header.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/header.py @@ -27,7 +27,10 @@ class Header(Parameter): populate_by_name=True, json_schema_extra={ "examples": [ - {"description": "The number of allowed requests in the current period", "schema": {"type": "integer"}} + { + "description": "The number of allowed requests in the current period", + "schema": {"type": "integer"}, + } ] }, ) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/info.py b/openapi_python_client/schema/openapi_schema_pydantic/info.py index bec1354da..42e3af6f9 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/info.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/info.py @@ -36,7 +36,10 @@ class Info(BaseModel): "url": "http://www.example.com/support", "email": "support@example.com", }, - "license": {"name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html"}, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html", + }, "version": "1.0.1", } ] diff --git a/openapi_python_client/schema/openapi_schema_pydantic/license.py b/openapi_python_client/schema/openapi_schema_pydantic/license.py index 185eec1db..1bebc376c 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/license.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/license.py @@ -16,6 +16,11 @@ class License(BaseModel): model_config = ConfigDict( extra="allow", json_schema_extra={ - "examples": [{"name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html"}] + "examples": [ + { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html", + } + ] }, ) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/link.py b/openapi_python_client/schema/openapi_schema_pydantic/link.py index 69cdf29c0..4c3c56ab0 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/link.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/link.py @@ -33,7 +33,10 @@ class Link(BaseModel): extra="allow", json_schema_extra={ "examples": [ - {"operationId": "getUserAddressByUUID", "parameters": {"userUuid": "$response.body#/uuid"}}, + { + "operationId": "getUserAddressByUUID", + "parameters": {"userUuid": "$response.body#/uuid"}, + }, { "operationRef": "#/paths/~12.0~1repositories~1{username}/get", "parameters": {"username": "$response.body#/username"}, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/media_type.py b/openapi_python_client/schema/openapi_schema_pydantic/media_type.py index 48cea8b75..ebf0dcf12 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/media_type.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/media_type.py @@ -16,7 +16,9 @@ class MediaType(BaseModel): - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject """ - media_type_schema: Optional[ReferenceOr[Schema]] = Field(default=None, alias="schema") + media_type_schema: Optional[ReferenceOr[Schema]] = Field( + default=None, alias="schema" + ) example: Optional[Any] = None examples: Optional[dict[str, ReferenceOr[Example]]] = None encoding: Optional[dict[str, Encoding]] = None diff --git a/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py b/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py index 16e366090..8ed737014 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py @@ -22,12 +22,18 @@ class OAuthFlow(BaseModel): "examples": [ { "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": {"write:pets": "modify pets in your account", "read:pets": "read your pets"}, + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets", + }, }, { "authorizationUrl": "https://example.com/api/oauth/dialog", "tokenUrl": "https://example.com/api/oauth/token", - "scopes": {"write:pets": "modify pets in your account", "read:pets": "read your pets"}, + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets", + }, }, ] }, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/parameter.py b/openapi_python_client/schema/openapi_schema_pydantic/parameter.py index bf4f4cf02..d259efa23 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/parameter.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/parameter.py @@ -46,7 +46,10 @@ class Parameter(BaseModel): "in": "header", "description": "token to be passed as a header", "required": True, - "schema": {"type": "array", "items": {"type": "integer", "format": "int64"}}, + "schema": { + "type": "array", + "items": {"type": "integer", "format": "int64"}, + }, "style": "simple", }, { @@ -68,7 +71,10 @@ class Parameter(BaseModel): { "in": "query", "name": "freeForm", - "schema": {"type": "object", "additionalProperties": {"type": "integer"}}, + "schema": { + "type": "object", + "additionalProperties": {"type": "integer"}, + }, "style": "form", }, { @@ -79,7 +85,10 @@ class Parameter(BaseModel): "schema": { "type": "object", "required": ["lat", "long"], - "properties": {"lat": {"type": "number"}, "long": {"type": "number"}}, + "properties": { + "lat": {"type": "number"}, + "long": {"type": "number"}, + }, } } }, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/path_item.py b/openapi_python_client/schema/openapi_schema_pydantic/path_item.py index 44beb2acb..681c616ce 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/path_item.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/path_item.py @@ -51,12 +51,25 @@ class PathItem(BaseModel): "200": { "description": "pet response", "content": { - "*/*": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/Pet"}}} + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + }, + } + } }, }, "default": { "description": "error payload", - "content": {"text/html": {"schema": {"$ref": "#/components/schemas/ErrorModel"}}}, + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/ErrorModel" + } + } + }, }, }, }, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/reference.py b/openapi_python_client/schema/openapi_schema_pydantic/reference.py index da913c0ce..bf4283b4c 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/reference.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/reference.py @@ -24,7 +24,11 @@ class Reference(BaseModel): extra="allow", populate_by_name=True, json_schema_extra={ - "examples": [{"$ref": "#/components/schemas/Pet"}, {"$ref": "Pet.json"}, {"$ref": "definitions.json#/Pet"}] + "examples": [ + {"$ref": "#/components/schemas/Pet"}, + {"$ref": "Pet.json"}, + {"$ref": "definitions.json#/Pet"}, + ] }, ) @@ -39,5 +43,6 @@ def _reference_discriminator(obj: Any) -> Literal["ref", "other"]: ReferenceOr: TypeAlias = Annotated[ - Union[Annotated[Reference, Tag("ref")], Annotated[T, Tag("other")]], Discriminator(_reference_discriminator) + Union[Annotated[Reference, Tag("ref")], Annotated[T, Tag("other")]], + Discriminator(_reference_discriminator), ] diff --git a/openapi_python_client/schema/openapi_schema_pydantic/request_body.py b/openapi_python_client/schema/openapi_schema_pydantic/request_body.py index 8cd9bb527..a57dd7460 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/request_body.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/request_body.py @@ -63,7 +63,11 @@ class RequestBody(BaseModel): }, { "description": "user to add to the system", - "content": {"text/plain": {"schema": {"type": "array", "items": {"type": "string"}}}}, + "content": { + "text/plain": { + "schema": {"type": "array", "items": {"type": "string"}} + } + }, }, ] }, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/response.py b/openapi_python_client/schema/openapi_schema_pydantic/response.py index b8e7782a7..77c5e63b8 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/response.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/response.py @@ -32,14 +32,24 @@ class Response(BaseModel): "description": "A complex object array response", "content": { "application/json": { - "schema": {"type": "array", "items": {"$ref": "#/components/schemas/VeryComplexType"}} + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/VeryComplexType" + }, + } } }, }, - {"description": "A simple string response", "content": {"text/plain": {"schema": {"type": "string"}}}}, { "description": "A simple string response", - "content": {"text/plain": {"schema": {"type": "string", "example": "whoa!"}}}, + "content": {"text/plain": {"schema": {"type": "string"}}}, + }, + { + "description": "A simple string response", + "content": { + "text/plain": {"schema": {"type": "string", "example": "whoa!"}} + }, "headers": { "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", diff --git a/openapi_python_client/schema/openapi_schema_pydantic/schema.py b/openapi_python_client/schema/openapi_schema_pydantic/schema.py index e1abdeecb..68ef29b6d 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/schema.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/schema.py @@ -1,6 +1,15 @@ from typing import Any, Optional, Union -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, model_validator +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, + model_validator, +) from ..data_type import DataType from .discriminator import Discriminator @@ -75,7 +84,9 @@ class Schema(BaseModel): {"type": "object", "additionalProperties": {"type": "string"}}, { "type": "object", - "additionalProperties": {"$ref": "#/components/schemas/ComplexModel"}, + "additionalProperties": { + "$ref": "#/components/schemas/ComplexModel" + }, }, { "type": "object", diff --git a/openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py b/openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py index df385440c..9b3cb10f8 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py @@ -40,7 +40,10 @@ class SecurityScheme(BaseModel): "flows": { "implicit": { "authorizationUrl": "https://example.com/api/oauth/dialog", - "scopes": {"write:pets": "modify pets in your account", "read:pets": "read your pets"}, + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets", + }, } }, }, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/server.py b/openapi_python_client/schema/openapi_schema_pydantic/server.py index 6bc21766c..449ca6c96 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/server.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/server.py @@ -20,7 +20,10 @@ class Server(BaseModel): extra="allow", json_schema_extra={ "examples": [ - {"url": "https://development.gigantic-server.com/v1", "description": "Development server"}, + { + "url": "https://development.gigantic-server.com/v1", + "description": "Development server", + }, { "url": "https://{username}.gigantic-server.com:{port}/{basePath}", "description": "The production API server", diff --git a/openapi_python_client/schema/openapi_schema_pydantic/tag.py b/openapi_python_client/schema/openapi_schema_pydantic/tag.py index acb5fdc28..7d2a2ecbe 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/tag.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/tag.py @@ -19,5 +19,8 @@ class Tag(BaseModel): description: Optional[str] = None externalDocs: Optional[ExternalDocumentation] = None model_config = ConfigDict( - extra="allow", json_schema_extra={"examples": [{"name": "pet", "description": "Pets operations"}]} + extra="allow", + json_schema_extra={ + "examples": [{"name": "pet", "description": "Pets operations"}] + }, ) diff --git a/openapi_python_client/templates/.gitignore.jinja b/openapi_python_client/templates/.gitignore.jinja index 79a2c3d73..f674ed247 100644 --- a/openapi_python_client/templates/.gitignore.jinja +++ b/openapi_python_client/templates/.gitignore.jinja @@ -1,3 +1,5 @@ +{# Skip .gitignore generation for monorepo integration - no file should be created #} +{% if false %} __pycache__/ build/ dist/ @@ -21,3 +23,4 @@ dmypy.json /coverage.xml /.coverage +{% endif %} diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index cf0301a9a..ad4f63a86 100644 --- a/openapi_python_client/templates/client.py.jinja +++ b/openapi_python_client/templates/client.py.jinja @@ -1,5 +1,7 @@ +from __future__ import annotations + import ssl -from typing import Any, Union, Optional +from typing import Any from attrs import define, field, evolve import httpx @@ -65,12 +67,12 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") - _client: Optional[httpx.Client] = field(default=None, init=False) - _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) {% endmacro %}{{ attributes() }} {% macro builders(self) %} def with_headers(self, headers: dict[str, str]) -> "{{ self }}": diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index 1b53becdd..5fafa0125 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -102,18 +102,18 @@ _kwargs["json"] = {{ property.python_name }} {% if endpoint.requires_security %} client: AuthenticatedClient, {% else %} -client: Union[AuthenticatedClient, Client], +client: AuthenticatedClient | Client, {% endif %} {% endif %} {# Any allowed bodies #} {% if endpoint.bodies | length == 1 %} body: {{ endpoint.bodies[0].prop.get_type_string() }}, {% elif endpoint.bodies | length > 1 %} -body: Union[ +body: ( {% for body in endpoint.bodies %} - {{ body.prop.get_type_string() }}, + {{ body.prop.get_type_string() }}{% if not loop.last %} |{% endif %} {% endfor %} -], +), {% endif %} {# query parameters #} {% for parameter in endpoint.query_parameters %} diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 802fcc2ea..ba4e7412c 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -1,5 +1,7 @@ +from __future__ import annotations + from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -65,7 +67,7 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[{{ return_string }}]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> {{ return_string }} | None: {% for response in endpoint.responses %} if response.status_code == {{ response.status_code.value }}: {% if parsed_responses %}{% import "property_templates/" + response.prop.template as prop_template %} @@ -87,7 +89,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[{{ return_string }}]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[{{ return_string }}]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -114,7 +116,7 @@ def sync_detailed( {% if parsed_responses %} def sync( {{ arguments(endpoint) | indent(4) }} -) -> Optional[{{ return_string }}]: +) -> {{ return_string }} | None: {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} return sync_detailed( @@ -140,7 +142,7 @@ async def asyncio_detailed( {% if parsed_responses %} async def asyncio( {{ arguments(endpoint) | indent(4) }} -) -> Optional[{{ return_string }}]: +) -> {{ return_string }} | None: {{ docstring(endpoint, return_string, is_detailed=false) | indent(4) }} return (await asyncio_detailed( diff --git a/openapi_python_client/templates/errors.py.jinja b/openapi_python_client/templates/errors.py.jinja index b912123d0..798d8a158 100644 --- a/openapi_python_client/templates/errors.py.jinja +++ b/openapi_python_client/templates/errors.py.jinja @@ -1,5 +1,7 @@ """ Contains shared errors types that can be raised from API functions """ +from __future__ import annotations + class UnexpectedStatus(Exception): """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" diff --git a/openapi_python_client/templates/literal_enum.py.jinja b/openapi_python_client/templates/literal_enum.py.jinja index 72207efa3..d24ff09f2 100644 --- a/openapi_python_client/templates/literal_enum.py.jinja +++ b/openapi_python_client/templates/literal_enum.py.jinja @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Literal, cast {{ enum.class_info.name }} = Literal{{ "%r" | format(enum.values|list|sort) }} diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index d792797c3..abce0acf9 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -1,5 +1,7 @@ +from __future__ import annotations + from collections.abc import Mapping -from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator +from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,7 +16,11 @@ from ..types import UNSET, Unset {{ relative }} {% endfor %} -{% for lazy_import in model.lazy_imports %} +{% set all_lazy_imports = model.lazy_imports | list %} +{% if model.additional_properties and model.additional_properties.lazy_imports %} +{% set all_lazy_imports = all_lazy_imports + (model.additional_properties.lazy_imports | list) %} +{% endif %} +{% for lazy_import in all_lazy_imports %} {% if loop.first %} if TYPE_CHECKING: {% endif %} @@ -23,7 +29,7 @@ if TYPE_CHECKING: {% if model.additional_properties %} -{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string(quoted=not model.additional_properties.is_base_type) %} +{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string() %} {% endif %} {% set class_name = model.class_info.name %} @@ -107,10 +113,15 @@ field_dict: dict[str, Any] = {} {% if model.additional_properties %} {% import "property_templates/" + model.additional_properties.template as prop_template %} {% if prop_template.transform %} -for prop_name, prop in self.additional_properties.items(): - {{ prop_template.transform(model.additional_properties, "prop", "field_dict[prop_name]", declare_type=false) | indent(4) }} +field_dict.update({ + prop_name: {{ prop_template.transform_expression(model.additional_properties, "prop") if prop_template.transform_expression else "prop" }} + for prop_name, prop in self.additional_properties.items() +}) # noqa: PERF403 {% else %} -field_dict.update(self.additional_properties) +field_dict.update({ + prop_name: prop + for prop_name, prop in self.additional_properties.items() +}) # noqa: PERF403 {%- endif -%} {%- endif -%} {% endmacro %} @@ -142,9 +153,6 @@ return field_dict {% endmacro %} def to_dict(self) -> dict[str, Any]: - {% for lazy_import in model.lazy_imports %} - {{ lazy_import }} - {% endfor %} {{ _to_dict() | indent(8) }} {% if model.is_multipart_body %} @@ -158,8 +166,10 @@ return field_dict {% endfor %} {% if model.additional_properties %} - for prop_name, prop in self.additional_properties.items(): - {{ multipart(model.additional_properties, "prop", "prop_name") | indent(4) }} + files.extend([ + {{ multipart(model.additional_properties, "prop", "prop_name") }} + for prop_name, prop in self.additional_properties.items() + ]) {% endif %} return files @@ -168,9 +178,6 @@ return field_dict @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - {% for lazy_import in model.lazy_imports %} - {{ lazy_import }} - {% endfor %} {% if (model.required_properties or model.optional_properties or model.additional_properties) %} d = dict(src_dict) {% for property in model.required_properties + model.optional_properties %} @@ -198,11 +205,7 @@ return field_dict {% if model.additional_properties.template %}{# Can be a bool instead of an object #} {% import "property_templates/" + model.additional_properties.template as prop_template %} -{% if model.additional_properties.lazy_imports %} - {% for lazy_import in model.additional_properties.lazy_imports %} - {{ lazy_import }} - {% endfor %} -{% endif %} + {% else %} {% set prop_template = None %} {% endif %} diff --git a/openapi_python_client/templates/property_templates/date_property.py.jinja b/openapi_python_client/templates/property_templates/date_property.py.jinja index 3ca8faee9..d683629a1 100644 --- a/openapi_python_client/templates/property_templates/date_property.py.jinja +++ b/openapi_python_client/templates/property_templates/date_property.py.jinja @@ -17,15 +17,17 @@ isoparse({{ source }}).date() {%- else %} {% if declare_type %} {% set type_annotation = property.get_type_string(json=True) %} -{{ destination }}: {{ type_annotation }} = UNSET +{{ destination }}: {{ type_annotation }} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% else %} -{{ destination }} = UNSET +{{ destination }} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% endif %} -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ transformed }} {%- endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{{ source }}.isoformat() +{% endmacro %} + {% macro multipart(property, source, name) %} files.append(({{ name }}, (None, {{ source }}.isoformat().encode(), "text/plain"))) {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/datetime_property.py.jinja b/openapi_python_client/templates/property_templates/datetime_property.py.jinja index bf7e601d1..7bc34448e 100644 --- a/openapi_python_client/templates/property_templates/datetime_property.py.jinja +++ b/openapi_python_client/templates/property_templates/datetime_property.py.jinja @@ -17,15 +17,17 @@ isoparse({{ source }}) {%- else %} {% if declare_type %} {% set type_annotation = property.get_type_string(json=True) %} -{{ destination }}: {{ type_annotation }} = UNSET +{{ destination }}: {{ type_annotation }} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% else %} -{{ destination }} = UNSET +{{ destination }} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% endif %} -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ transformed }} {%- endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{{ source }}.isoformat() +{% endmacro %} + {% macro multipart(property, source, name) %} files.append(({{ name }}, (None, {{ source }}.isoformat().encode(), "text/plain"))) {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/enum_property.py.jinja b/openapi_python_client/templates/property_templates/enum_property.py.jinja index af8ca6eff..58d9fe77b 100644 --- a/openapi_python_client/templates/property_templates/enum_property.py.jinja +++ b/openapi_python_client/templates/property_templates/enum_property.py.jinja @@ -16,12 +16,14 @@ {% if property.required %} {{ destination }} = {{ transformed }} {%- else %} -{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ transformed }} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{{ source }}.value +{% endmacro %} + {% macro multipart(property, source, name) %} files.append(({{ name }}, (None, str({{ source }}.value).encode(), "text/plain"))) {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/file_property.py.jinja b/openapi_python_client/templates/property_templates/file_property.py.jinja index b08a13b46..8856dcdf1 100644 --- a/openapi_python_client/templates/property_templates/file_property.py.jinja +++ b/openapi_python_client/templates/property_templates/file_property.py.jinja @@ -16,12 +16,14 @@ File( {% if property.required %} {{ destination }} = {{ source }}.to_tuple() {% else %} -{{ destination }}{% if declare_type %}: {{ property.get_type_string(json=True) }}{% endif %} = UNSET -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ source }}.to_tuple() +{{ destination }}{% if declare_type %}: {{ property.get_type_string(json=True) }}{% endif %} = UNSET if isinstance({{ source }}, Unset) else {{ source }}.to_tuple() {% endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{{ source }}.to_tuple() +{% endmacro %} + {% macro multipart(property, source, name) %} files.append(({{ name }}, {{ source }}.to_tuple())) {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/list_property.py.jinja b/openapi_python_client/templates/property_templates/list_property.py.jinja index 785d0b675..f583b2db4 100644 --- a/openapi_python_client/templates/property_templates/list_property.py.jinja +++ b/openapi_python_client/templates/property_templates/list_property.py.jinja @@ -45,6 +45,19 @@ if not isinstance({{ source }}, Unset): {% endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{% set inner_property = property.inner_property %} +{% import "property_templates/" + inner_property.template as inner_template %} +{% if inner_template.transform_expression %} +[ + {{ inner_template.transform_expression(inner_property, inner_property.python_name + "_item") }} + for {{ inner_property.python_name }}_item in {{ source }} +] +{% else %} +{{ source }} +{% endif %} +{% endmacro %} + {% macro multipart(property, source, destination) %} {% set inner_property = property.inner_property %} {% import "property_templates/" + inner_property.template as inner_template %} diff --git a/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja b/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja index 2cc4558c6..50ccfe13b 100644 --- a/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja +++ b/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja @@ -15,12 +15,14 @@ check_{{ property.get_class_name_snake_case() }}({{ source }}) {% if property.required %} {{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = {{ source }} {%- else %} -{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ source }} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET if isinstance({{ source }}, Unset) else {{ source }} {% endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{{ source }} +{% endmacro %} + {% macro multipart(property, source, name) %} files.append(({{ name }}, (None, str({{ source }}).encode(), "text/plain"))) {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/model_property.py.jinja b/openapi_python_client/templates/property_templates/model_property.py.jinja index d1a4b5d34..a2c845352 100644 --- a/openapi_python_client/templates/property_templates/model_property.py.jinja +++ b/openapi_python_client/templates/property_templates/model_property.py.jinja @@ -16,19 +16,20 @@ {% if property.required %} {{ destination }} = {{ transformed }} {%- else %} -{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ transformed }} +{{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {%- endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +{{ source }}.to_dict() +{% endmacro %} + {% macro transform_multipart_body(property) %} {% set transformed = property.python_name + ".to_multipart()" %} {% if property.required %} _kwargs["files"] = {{ transformed }} {%- else %} -if not isinstance({{ property.python_name }}, Unset): - _kwargs["files"] = {{ transformed }} +_kwargs["files"] = {{ transformed }} if not isinstance({{ property.python_name }}, Unset) else None {%- endif %} {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/property_macros.py.jinja b/openapi_python_client/templates/property_templates/property_macros.py.jinja index 52e1d41bc..b95870d40 100644 --- a/openapi_python_client/templates/property_templates/property_macros.py.jinja +++ b/openapi_python_client/templates/property_templates/property_macros.py.jinja @@ -3,12 +3,6 @@ {{ property.python_name }} = {{ construct_function(property, source) }} {% else %}{# Must be non-required #} _{{ property.python_name }} = {{ source }} -{{ property.python_name }}: {{ property.get_type_string() }} - {% if not property.required %} -if isinstance(_{{ property.python_name }}, Unset): - {{ property.python_name }} = UNSET - {% endif %} -else: - {{ property.python_name }} = {{ construct_function(property, "_" + property.python_name) }} +{{ property.python_name }}: {{ property.get_type_string() }} = UNSET if isinstance(_{{ property.python_name }}, Unset) else {{ construct_function(property, "_" + property.python_name) }} {% endif %} {% endmacro %} diff --git a/openapi_python_client/templates/property_templates/union_property.py.jinja b/openapi_python_client/templates/property_templates/union_property.py.jinja index 09b6e6e09..9c897a95f 100644 --- a/openapi_python_client/templates/property_templates/union_property.py.jinja +++ b/openapi_python_client/templates/property_templates/union_property.py.jinja @@ -100,3 +100,7 @@ else: {{ inner_template.multipart(inner_property, source, destination) | indent(4) | trim }} {%- endfor -%} {% endmacro %} + +{% macro transform_expression(property, source) %} +{{ source }} +{% endmacro %} diff --git a/openapi_python_client/templates/property_templates/uuid_property.py.jinja b/openapi_python_client/templates/property_templates/uuid_property.py.jinja index 3a6ce46bb..2cc35f98d 100644 --- a/openapi_python_client/templates/property_templates/uuid_property.py.jinja +++ b/openapi_python_client/templates/property_templates/uuid_property.py.jinja @@ -17,15 +17,17 @@ UUID({{ source }}) {%- else %} {% if declare_type %} {% set type_annotation = property.get_type_string(json=True) %} -{{ destination }}: {{ type_annotation }} = UNSET +{{ destination }}: {{ type_annotation }} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% else %} -{{ destination }} = UNSET +{{ destination }} = UNSET if isinstance({{ source }}, Unset) else {{ transformed }} {% endif %} -if not isinstance({{ source }}, Unset): - {{ destination }} = {{ transformed }} {%- endif %} {% endmacro %} +{% macro transform_expression(property, source) %} +str({{ source }}) +{% endmacro %} + {% macro multipart(property, source, name) %} files.append(({{ name }}, (None, str({{ source }}), "text/plain")) {% endmacro %} diff --git a/openapi_python_client/templates/pyproject.toml.jinja b/openapi_python_client/templates/pyproject.toml.jinja index 9f21f8043..d607bb694 100644 --- a/openapi_python_client/templates/pyproject.toml.jinja +++ b/openapi_python_client/templates/pyproject.toml.jinja @@ -1,3 +1,5 @@ +{# Skip pyproject.toml generation for monorepo integration - no file should be created #} +{# {% if meta == "poetry" %} {% include "pyproject_poetry.toml.jinja" %} {% elif meta == "pdm" %} @@ -7,3 +9,5 @@ {% endif %} {% include "pyproject_ruff.toml.jinja" %} +{% endif %} +#} diff --git a/openapi_python_client/templates/types.py.jinja b/openapi_python_client/templates/types.py.jinja index 2330892ca..108d3068f 100644 --- a/openapi_python_client/templates/types.py.jinja +++ b/openapi_python_client/templates/types.py.jinja @@ -1,8 +1,10 @@ """ Contains some shared types for properties """ +from __future__ import annotations + from collections.abc import Mapping, MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Optional, TypeVar, Literal, Union, IO +from typing import BinaryIO, Generic, TypeVar, Literal, IO from attrs import define @@ -15,13 +17,13 @@ class Unset: UNSET: Unset = Unset() # The types that `httpx.Client(files=)` can accept, copied from that library. -FileContent = Union[IO[bytes], bytes, str] -FileTypes = Union[ +FileContent = IO[bytes] | bytes | str +FileTypes = ( # (filename, file (or bytes), content_type) - tuple[Optional[str], FileContent, Optional[str]], + tuple[str | None, FileContent, str | None] | # (filename, file (or bytes), content_type, headers) - tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], -] + tuple[str | None, FileContent, str | None, Mapping[str, str]] +) RequestFiles = list[tuple[str, FileTypes]] @define @@ -29,8 +31,8 @@ class File: """ Contains information for file uploads """ payload: BinaryIO - file_name: Optional[str] = None - mime_type: Optional[str] = None + file_name: str | None = None + mime_type: str | None = None def to_tuple(self) -> FileTypes: """ Return a tuple representation that httpx will accept for multipart/form-data """ @@ -47,7 +49,7 @@ class Response(Generic[T]): status_code: HTTPStatus content: bytes headers: MutableMapping[str, str] - parsed: Optional[T] + parsed: T | None __all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] diff --git a/openapi_python_client/utils.py b/openapi_python_client/utils.py index 15e8c9eec..cd564b09a 100644 --- a/openapi_python_client/utils.py +++ b/openapi_python_client/utils.py @@ -14,7 +14,9 @@ class PythonIdentifier(str): """A snake_case string which has been validated / transformed into a valid identifier for Python""" - def __new__(cls, value: str, prefix: str, skip_snake_case: bool = False) -> PythonIdentifier: + def __new__( + cls, value: str, prefix: str, skip_snake_case: bool = False + ) -> PythonIdentifier: new_value = sanitize(value) if not skip_snake_case: new_value = snake_case(new_value) @@ -85,7 +87,9 @@ def snake_case(value: str) -> str: def pascal_case(value: str) -> str: """Converts to PascalCase""" words = split_words(sanitize(value)) - capitalized_words = (word.capitalize() if not word.isupper() else word for word in words) + capitalized_words = ( + word.capitalize() if not word.isupper() else word for word in words + ) return "".join(capitalized_words) diff --git a/pyproject.toml b/pyproject.toml index 614cb733d..6513ed65a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,40 +46,131 @@ repository = "https://github.com/openapi-generators/openapi-python-client" [project.scripts] openapi-python-client = "openapi_python_client.cli:app" -[tool.ruff] -line-length = 120 -exclude = [ - ".git", - ".mypy_cache", - ".venv", - "openapi_python_client/templates/*", - "end_to_end_tests/*", - "tests/test_templates/*", -] - -[tool.ruff.lint] -select = ["E", "F", "I", "UP", "B", "PL", "RUF"] -ignore = ["E501", "PLR0913", "PLR2004"] - -[tool.ruff.lint.per-file-ignores] -"openapi_python_client/cli.py" = ["B008"] -"tests/*" = ["PLR2004"] - [tool.coverage.run] omit = ["openapi_python_client/__main__.py", "openapi_python_client/templates/*", "end_to_end_tests/*", "integration_tests/*", "tests/*"] [tool.mypy] -plugins = ["pydantic.mypy"] +python_version = "3.13" # Will break in 3.14 due to protobufs dependency +strict = true +warn_unreachable = true +no_implicit_optional = false disallow_any_generics = true -disallow_untyped_defs = true -warn_redundant_casts = true +warn_return_any = false +explicit_package_bases = true +disable_error_code = "unused-ignore" +mypy_path = "python/protocols" +allow_untyped_globals = false +allow_redefinition = false +local_partial_types = false strict_equality = true +enable_error_code = ["deprecated"] -[[tool.mypy.overrides]] -module = [ - "importlib_metadata", - "typer", +[tool.ruff] +src = ["python"] +lint.select = [ + "SIM102", + "B904", + "B007", + "SIM108", + "B006", + "B904", + "B007", + "B023", + "SIM118", + "A002", + "PERF", + "PL", + "PTH", + "LOG", + "S", + "RUF", + "E", + "W", + # TODO: introduce gradually here and pyproject.toml (mostly copying standard from pandas repo) + # YTT - flake8-2020 + # Q - flake8-quotes + # INT - flake8-gettext + # PT - flake8-pytest-style + # PYI - flake8-pyi + # ISC - implicit string concatenation + # TC - flake8-type-checking + # PGH - pygrep-hooks + # NPY002 - numpy-legacy-random + # G - flake8-logging-format + # FA - flake8-future-annotations + # ICN001 - unconventional-import-alias + # SLOT - flake8-slots + # RSE - flake8-raise + # UP046/7 - clearer generics, seems like type checkers dont understand it yet +] +lint.ignore = [ + "PLR", + # try-except-in-loop, becomes useless in Python 3.11 + "PERF203", + "RUF022", + # Min line lenght, we use black + "E501", + # Blank line contains whitespace, black should clear + "W293", + "S106", + "S101", + "S608", + "S603", + "RUF009", + # getattr is used to side-step mypy + "B010", + # tests use comparisons but not their returned value + "B015", + # Function definition does not bind loop variable + "B023", + # Too many arguments to function call + "B905", + # Too many returns + "PLR0913", + # Too many branches + "PLR0911", + # Too many statements + "PLR0915", + # Redefined loop name + "PLW2901", + # Global statements are discouraged + "PLW0603", + # Use `typing.NamedTuple` instead of `collections.namedtuple` + "PYI024", + # Use of possibly insecure function; consider using ast.literal_eval + "S307", + # while int | float can be shortened to float, the former is more explicit + "PERF102", + # pytest-parametrize-names-wrong-type + "PT006", + # pytest-parametrize-values-wrong-type + "PT007", + # pytest-patch-with-lambda + "PT008", + # pytest-raises-with-multiple-statements + "PT017", + # pytest-assert-in-except + "PT018", + # pytest-composite-assertion + "PT019", + # pytest-fixture-param-without-value + "ISC001", + # if-stmt-min-max + "PLR1730", + # type vs TypeAlias do not have the same runtime behavior + "UP040", + # binding to all interfaces, we do this too much - someone smarter than me will fix this + "S104", + # UP046/7 - clearer generics, seems like type checkers dont understand it yet + "UP046", + "UP047", ] + +[tool.ruff.lint.isort] +known-first-party = ["python"] + +[[tool.mypy.overrides]] +module = "psutil" ignore_missing_imports = true [tool.pytest.ini_options] diff --git a/replace_imports.py b/replace_imports.py new file mode 100644 index 000000000..48ec7a63b --- /dev/null +++ b/replace_imports.py @@ -0,0 +1,227 @@ +#!/usr/bin/env python3 +import argparse +import sys +from pathlib import Path + +import libcst as cst +from libcst.metadata import MetadataWrapper, ParentNodeProvider + + +def find_top_package_dir(d: Path) -> Path | None: + """ + Return the highest directory in the package chain for d (which itself must + be inside a package). A 'package' is a dir with __init__.py. + Example: /src/my_pkg/sub/mod -> returns /src/my_pkg + """ + cur = d + top = None + while (cur / "__init__.py").exists(): + top = cur + parent = cur.parent + if not (parent / "__init__.py").exists(): + break + cur = parent + return top + + +def package_components_for_file( + file_path: Path, import_root: Path | None = None +) -> list[str] | None: + """ + Current *package* of the module containing file_path. + - For foo/bar/baz.py -> package is foo.bar + - For foo/bar/__init__.py -> package is foo.bar + Returns None if file isn't inside a package (no __init__.py chain). + + If import_root is specified, it's used as the base for computing package structure + instead of the actual file system location. + """ + file_dir = file_path.parent + + if import_root is not None: + # Use the specified import root to compute package structure + try: + # Get the relative path from import_root to file_dir + rel_path = file_dir.relative_to(import_root) + # The import_root becomes the base package, so we include it in the path + import_root_name = import_root.name + return [import_root_name] + list(rel_path.parts) + except ValueError: + # File is not under the import_root + return None + + # Original logic: use actual file system location + top_pkg_dir = find_top_package_dir( + file_dir if file_path.name != "__init__.py" else file_dir + ) + if top_pkg_dir is None: + return None + # package is from top_pkg_dir down to file_dir + pkg_rel = file_dir.relative_to(top_pkg_dir.parent) + return list(pkg_rel.parts) + + +def compute_abs_module( + pkg_comps: list[str], level: int, rel_module: str | None +) -> str | None: + """ + Translate 'from .rel_module import x' (level >= 1) to absolute module string. + Rule: base = pkg_comps[: len(pkg_comps) - (level - 1)] + Then append rel_module parts if present. + """ + if level < 1: + return None + cut = len(pkg_comps) - (level - 1) + if cut <= 0: + # Would escape top-level package; skip (leave as-is). + return None + base = pkg_comps[:cut] + if rel_module: + base += rel_module.split(".") + return ".".join(base) + + +def importfrom_level(node: cst.ImportFrom) -> int: + r = node.relative + if r is None: + return 0 + # In LibCST, relative is a sequence of Dot tokens + return len(r) + + +class RelToAbsTransformer(cst.CSTTransformer): + METADATA_DEPENDENCIES = (ParentNodeProvider,) + + def __init__(self, file_path: Path, import_root: Path | None = None): + self.file_path = file_path + self.pkg_comps = package_components_for_file(file_path, import_root) + self.changed = False + + def leave_ImportFrom( + self, original_node: cst.ImportFrom, updated_node: cst.ImportFrom + ) -> cst.ImportFrom: + if self.pkg_comps is None: + return updated_node + + level = importfrom_level(original_node) + if level <= 0: + return updated_node # already absolute or 'from x import y' with no dots + + # Get module string if present + mod = None + if original_node.module is not None: + if isinstance(original_node.module, cst.Name): + mod = original_node.module.value + elif isinstance(original_node.module, cst.Attribute): + # Convert dotted attribute chain to string + parts = [] + cur = original_node.module + while isinstance(cur, cst.Attribute): + if isinstance(cur.attr, cst.Name): + parts.append(cur.attr.value) + else: + return updated_node # unexpected; bail + if isinstance(cur.value, cst.Name): + parts.append(cur.value.value) + break + cur = cur.value + mod = ".".join(reversed(parts)) if parts else None + + abs_mod = compute_abs_module(self.pkg_comps, level, mod) + if not abs_mod: + return updated_node # can't safely compute; skip + + self.changed = True + return cst.ImportFrom( + module=cst.parse_expression(abs_mod), + names=updated_node.names, + relative=(), # Empty sequence for absolute imports + whitespace_after_from=updated_node.whitespace_after_from, + whitespace_before_import=updated_node.whitespace_before_import, + ) + + +def rewrite_file(path: Path, write: bool, import_root: Path | None = None) -> bool: + try: + code = path.read_text(encoding="utf-8") + except Exception: + return False + try: + mod = cst.parse_module(code) + wrapper = MetadataWrapper(mod) + tx = RelToAbsTransformer(path, import_root) + new_mod = wrapper.visit(tx) + if tx.changed: + if write: + path.write_text(new_mod.code, encoding="utf-8") + else: + # Show a minimal preview header in dry-run + rel = str(path) + print(f"[change] {rel}") + return True + return False + except Exception as e: + print(f"[skip] {path}: {e}", file=sys.stderr) + return False + + +def main(): + ap = argparse.ArgumentParser( + description="Rewrite relative imports to absolute across a tree." + ) + ap.add_argument("root", type=Path, help="Folder to process") + ap.add_argument( + "--write", action="store_true", help="Apply changes in-place (default: dry-run)" + ) + ap.add_argument( + "--include-glob", + default="**/*.py", + help="Glob of files to include (default: **/*.py)", + ) + ap.add_argument( + "--exclude", + action="append", + default=[".venv", "venv", "__pycache__", ".git", "site-packages"], + help="Directories to skip (repeatable)", + ) + ap.add_argument( + "--import-root", + type=Path, + help="Root directory to use for computing import paths (default: use actual file system location)", + ) + args = ap.parse_args() + + root = args.root.resolve() + if not root.exists(): + print(f"Root not found: {root}", file=sys.stderr) + sys.exit(2) + + import_root = args.import_root.resolve() if args.import_root else None + if import_root and not import_root.exists(): + print(f"Import root not found: {import_root}", file=sys.stderr) + sys.exit(2) + + changed = 0 + for path in root.glob(args.include_glob): + if not path.is_file(): + continue + # Exclusions + p = path + skip = False + for ex in args.exclude: + if ex and ex in p.parts: + skip = True + break + if skip: + continue + if rewrite_file(path, args.write, import_root): + changed += 1 + + if not args.write: + print(f"\nDry-run complete. Files to change: {changed}") + else: + print(f"Rewritten files: {changed}") + + +if __name__ == "__main__": + main() diff --git a/tests/conftest.py b/tests/conftest.py index 3d2660c49..0d310e315 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -61,7 +61,10 @@ def _factory(**kwargs): kwargs = _common_kwargs(kwargs) kwargs = { "description": "", - "class_info": Class(name=ClassName("MyClass", ""), module_name=PythonIdentifier("my_module", "")), + "class_info": Class( + name=ClassName("MyClass", ""), + module_name=PythonIdentifier("my_module", ""), + ), "data": oai.Schema.model_construct(), "roots": set(), "required_properties": None, @@ -280,7 +283,9 @@ def __call__( @pytest.fixture -def union_property_factory(date_time_property_factory, string_property_factory) -> UnionFactory: +def union_property_factory( + date_time_property_factory, string_property_factory +) -> UnionFactory: """ This fixture surfaces in the test as a function which manufactures UnionProperties with defaults. @@ -288,7 +293,8 @@ def union_property_factory(date_time_property_factory, string_property_factory) """ return _simple_factory( - UnionProperty, {"inner_properties": [date_time_property_factory(), string_property_factory()]} + UnionProperty, + {"inner_properties": [date_time_property_factory(), string_property_factory()]}, ) diff --git a/tests/test___init__.py b/tests/test___init__.py index 34ad3188f..272d0082b 100644 --- a/tests/test___init__.py +++ b/tests/test___init__.py @@ -5,7 +5,9 @@ from openapi_python_client import Config, ErrorLevel, Project from openapi_python_client.config import ConfigFile -default_http_timeout = ConfigFile.model_json_schema()["properties"]["http_timeout"]["default"] +default_http_timeout = ConfigFile.model_json_schema()["properties"]["http_timeout"][ + "default" +] def make_project(config: Config) -> Project: @@ -24,7 +26,9 @@ def project_with_dir(config) -> Project: class TestProject: - def test__run_post_hooks_reports_missing_commands(self, project_with_dir: Project) -> None: + def test__run_post_hooks_reports_missing_commands( + self, project_with_dir: Project + ) -> None: fake_command_name = "blahblahdoesntexist" project_with_dir.config.post_hooks = [fake_command_name] need_to_make_cwd = not project_with_dir.project_dir.exists() @@ -39,7 +43,9 @@ def test__run_post_hooks_reports_missing_commands(self, project_with_dir: Projec assert error.header == "Skipping Integration" assert fake_command_name in error.detail - def test__run_post_hooks_reports_stdout_of_commands_that_error_with_no_stderr(self, project_with_dir): + def test__run_post_hooks_reports_stdout_of_commands_that_error_with_no_stderr( + self, project_with_dir + ): failing_command = "python3 -c \"print('a message'); exit(1)\"" project_with_dir.config.post_hooks = [failing_command] project_with_dir._run_post_hooks() @@ -50,8 +56,12 @@ def test__run_post_hooks_reports_stdout_of_commands_that_error_with_no_stderr(se assert error.header == "python3 failed" assert "a message" in error.detail - def test__run_post_hooks_reports_stderr_of_commands_that_error(self, project_with_dir): - failing_command = "python3 -c \"print('a message'); raise Exception('some exception')\"" + def test__run_post_hooks_reports_stderr_of_commands_that_error( + self, project_with_dir + ): + failing_command = ( + "python3 -c \"print('a message'); raise Exception('some exception')\"" + ) project_with_dir.config.post_hooks = [failing_command] project_with_dir._run_post_hooks() diff --git a/tests/test_cli.py b/tests/test_cli.py index 0775ce5c1..059f3e600 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -16,7 +16,9 @@ def test_bad_config() -> None: config_path = "config/path" path = "cool/path" - result = runner.invoke(app, ["generate", f"--config={config_path}", f"--path={path}"]) + result = runner.invoke( + app, ["generate", f"--config={config_path}", f"--path={path}"] + ) assert result.exit_code == 2 assert "Unable to parse config" in result.stdout @@ -37,7 +39,9 @@ def test_generate_url_and_path(self) -> None: def test_generate_encoding_errors(self) -> None: path = "cool/path" file_encoding = "error-file-encoding" - result = runner.invoke(app, ["generate", f"--path={path}", f"--file-encoding={file_encoding}"]) + result = runner.invoke( + app, ["generate", f"--path={path}", f"--file-encoding={file_encoding}"] + ) assert result.exit_code == 1 assert result.output == f"Unknown encoding : {file_encoding}\n" diff --git a/tests/test_parser/test_bodies.py b/tests/test_parser/test_bodies.py index 0956d11f6..dce6e4abc 100644 --- a/tests/test_parser/test_bodies.py +++ b/tests/test_parser/test_bodies.py @@ -33,7 +33,11 @@ def test_errors(config): ) errs, _ = body_from_data( - data=operation, schemas=Schemas(), config=config, endpoint_name="this will not succeed", request_bodies={} + data=operation, + schemas=Schemas(), + config=config, + endpoint_name="this will not succeed", + request_bodies={}, ) assert len(errs) == len(operation.request_body.content) diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index 3d1391ae2..80c2c5fa3 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -5,8 +5,17 @@ import openapi_python_client.schema as oai from openapi_python_client.parser.errors import ParseError -from openapi_python_client.parser.openapi import Endpoint, EndpointCollection, import_string_from_class -from openapi_python_client.parser.properties import Class, IntProperty, Parameters, Schemas +from openapi_python_client.parser.openapi import ( + Endpoint, + EndpointCollection, + import_string_from_class, +) +from openapi_python_client.parser.properties import ( + Class, + IntProperty, + Parameters, + Schemas, +) from openapi_python_client.schema import DataType MODULE_NAME = "openapi_python_client.parser.openapi" @@ -33,7 +42,9 @@ def test__add_responses_status_code_error(self, response_status_code, mocker): } endpoint = self.make_endpoint() parse_error = ParseError(data=mocker.MagicMock()) - response_from_data = mocker.patch(f"{MODULE_NAME}.response_from_data", return_value=(parse_error, schemas)) + response_from_data = mocker.patch( + f"{MODULE_NAME}.response_from_data", return_value=(parse_error, schemas) + ) config = MagicMock() response, schemas = Endpoint._add_responses( @@ -58,7 +69,9 @@ def test__add_responses_error(self, mocker): } endpoint = self.make_endpoint() parse_error = ParseError(data=mocker.MagicMock(), detail="some problem") - response_from_data = mocker.patch(f"{MODULE_NAME}.response_from_data", return_value=(parse_error, schemas)) + response_from_data = mocker.patch( + f"{MODULE_NAME}.response_from_data", return_value=(parse_error, schemas) + ) config = MagicMock() response, schemas = Endpoint._add_responses( @@ -119,9 +132,15 @@ def test_add_parameters_parse_error(self, mocker): initial_parameters = mocker.MagicMock() parse_error = ParseError(data=mocker.MagicMock()) property_schemas = mocker.MagicMock() - mocker.patch(f"{MODULE_NAME}.property_from_data", return_value=(parse_error, property_schemas)) + mocker.patch( + f"{MODULE_NAME}.property_from_data", + return_value=(parse_error, property_schemas), + ) param = oai.Parameter.model_construct( - name="test", required=True, param_schema=mocker.MagicMock(), param_in="cookie" + name="test", + required=True, + param_schema=mocker.MagicMock(), + param_in="cookie", ) config = MagicMock() @@ -157,7 +176,10 @@ def test_add_parameters_header_types(self, data_type, allowed, config): initial_schemas = Schemas() parameters = Parameters() param = oai.Parameter.model_construct( - name="test", required=True, param_schema=oai.Schema(type=data_type), param_in=oai.ParameterLocation.HEADER + name="test", + required=True, + param_schema=oai.Schema(type=data_type), + param_in=oai.ParameterLocation.HEADER, ) result = Endpoint.add_parameters( @@ -190,13 +212,25 @@ def test__add_parameters_parse_error_on_non_required_path_param(self, config): schemas=schemas, config=config, ) - assert result == (ParseError(data=param, detail="Path parameter must be required"), schemas, parameters) + assert result == ( + ParseError(data=param, detail="Path parameter must be required"), + schemas, + parameters, + ) def test_validation_error_when_location_not_supported(self, mocker): parsed_schemas = mocker.MagicMock() - mocker.patch(f"{MODULE_NAME}.property_from_data", return_value=(mocker.MagicMock(), parsed_schemas)) + mocker.patch( + f"{MODULE_NAME}.property_from_data", + return_value=(mocker.MagicMock(), parsed_schemas), + ) with pytest.raises(pydantic.ValidationError): - oai.Parameter(name="test", required=True, param_schema=mocker.MagicMock(), param_in="error_location") + oai.Parameter( + name="test", + required=True, + param_schema=mocker.MagicMock(), + param_in="error_location", + ) def test__add_parameters_handles_invalid_references(self, config): """References are not supported as direct params yet""" @@ -209,7 +243,11 @@ def test__add_parameters_handles_invalid_references(self, config): parameters = Parameters() (error, _, return_parameters) = endpoint.add_parameters( - endpoint=endpoint, data=data, schemas=Schemas(), parameters=parameters, config=config + endpoint=endpoint, + data=data, + schemas=Schemas(), + parameters=parameters, + config=config, ) assert isinstance(error, ParseError) @@ -225,14 +263,20 @@ def test__add_parameters_resolves_references(self, mocker, param_factory, config ) parameters = mocker.MagicMock() - new_param = param_factory(name="blah", schema=oai.Schema.model_construct(type="string")) + new_param = param_factory( + name="blah", schema=oai.Schema.model_construct(type="string") + ) parameters.classes_by_name = { "blah": new_param, } parameters.classes_by_reference = {"components/parameters/blah": new_param} (endpoint, _, return_parameters) = endpoint.add_parameters( - endpoint=endpoint, data=data, schemas=Schemas(), parameters=parameters, config=config + endpoint=endpoint, + data=data, + schemas=Schemas(), + parameters=parameters, + config=config, ) assert isinstance(endpoint, Endpoint) @@ -251,7 +295,11 @@ def test__add_parameters_skips_params_without_schemas(self, config): ) (endpoint, _, _) = endpoint.add_parameters( - endpoint=endpoint, data=data, schemas=Schemas(), parameters=Parameters(), config=config + endpoint=endpoint, + data=data, + schemas=Schemas(), + parameters=Parameters(), + config=config, ) assert isinstance(endpoint, Endpoint) @@ -282,7 +330,11 @@ def test__add_parameters_same_identifier_conflict(self, config): ) (err, _, _) = endpoint.add_parameters( - endpoint=endpoint, data=data, schemas=Schemas(), parameters=Parameters(), config=config + endpoint=endpoint, + data=data, + schemas=Schemas(), + parameters=Parameters(), + config=config, ) assert isinstance(err, ParseError) @@ -308,7 +360,11 @@ def test__add_parameters_query_optionality(self, config): ) (endpoint, _, _) = endpoint.add_parameters( - endpoint=endpoint, data=data, schemas=Schemas(), parameters=Parameters(), config=config + endpoint=endpoint, + data=data, + schemas=Schemas(), + parameters=Parameters(), + config=config, ) assert len(endpoint.query_parameters) == 2, "Not all query params were added" @@ -321,14 +377,21 @@ def test__add_parameters_query_optionality(self, config): def test_add_parameters_duplicate_properties(self, config): endpoint = self.make_endpoint() param = oai.Parameter.model_construct( - name="test", required=True, param_schema=oai.Schema.model_construct(type="string"), param_in="path" + name="test", + required=True, + param_schema=oai.Schema.model_construct(type="string"), + param_in="path", ) data = oai.Operation.model_construct(parameters=[param, param]) schemas = Schemas() parameters = Parameters() result = Endpoint.add_parameters( - endpoint=endpoint, data=data, schemas=schemas, parameters=parameters, config=config + endpoint=endpoint, + data=data, + schemas=schemas, + parameters=parameters, + config=config, ) assert result == ( ParseError( @@ -344,10 +407,16 @@ def test_add_parameters_duplicate_properties(self, config): def test_add_parameters_duplicate_properties_different_location(self, config): endpoint = self.make_endpoint() path_param = oai.Parameter.model_construct( - name="test", required=True, param_schema=oai.Schema.model_construct(type="string"), param_in="path" + name="test", + required=True, + param_schema=oai.Schema.model_construct(type="string"), + param_in="path", ) query_param = oai.Parameter.model_construct( - name="test", required=True, param_schema=oai.Schema.model_construct(type="string"), param_in="query" + name="test", + required=True, + param_schema=oai.Schema.model_construct(type="string"), + param_in="query", ) schemas = Schemas() parameters = Parameters() @@ -407,7 +476,11 @@ def test_from_data_bad_params(self, mocker, config): parse_error = ParseError(data=mocker.MagicMock()) return_schemas = mocker.MagicMock() return_parameters = mocker.MagicMock() - mocker.patch.object(Endpoint, "add_parameters", return_value=(parse_error, return_schemas, return_parameters)) + mocker.patch.object( + Endpoint, + "add_parameters", + return_value=(parse_error, return_schemas, return_parameters), + ) data = oai.Operation.model_construct( description=mocker.MagicMock(), operationId=mocker.MagicMock(), @@ -438,10 +511,14 @@ def test_from_data_bad_responses(self, mocker, config): param_schemas = mocker.MagicMock() return_parameters = mocker.MagicMock() mocker.patch.object( - Endpoint, "add_parameters", return_value=(mocker.MagicMock(), param_schemas, return_parameters) + Endpoint, + "add_parameters", + return_value=(mocker.MagicMock(), param_schemas, return_parameters), ) response_schemas = mocker.MagicMock() - _add_responses = mocker.patch.object(Endpoint, "_add_responses", return_value=(parse_error, response_schemas)) + _add_responses = mocker.patch.object( + Endpoint, "_add_responses", return_value=(parse_error, response_schemas) + ) data = oai.Operation.model_construct( description=mocker.MagicMock(), operationId=mocker.MagicMock(), @@ -472,12 +549,16 @@ def test_from_data_standard(self, mocker, config): param_endpoint = mocker.MagicMock() return_parameters = mocker.MagicMock() add_parameters = mocker.patch.object( - Endpoint, "add_parameters", return_value=(param_endpoint, param_schemas, return_parameters) + Endpoint, + "add_parameters", + return_value=(param_endpoint, param_schemas, return_parameters), ) response_schemas = mocker.MagicMock() response_endpoint = mocker.MagicMock() _add_responses = mocker.patch.object( - Endpoint, "_add_responses", return_value=(response_endpoint, response_schemas) + Endpoint, + "_add_responses", + return_value=(response_endpoint, response_schemas), ) data = oai.Operation.model_construct( description=mocker.MagicMock(), @@ -488,7 +569,10 @@ def test_from_data_standard(self, mocker, config): initial_schemas = mocker.MagicMock() initial_parameters = mocker.MagicMock() - mocker.patch("openapi_python_client.utils.remove_string_escapes", return_value=data.description) + mocker.patch( + "openapi_python_client.utils.remove_string_escapes", + return_value=data.description, + ) Endpoint.from_data( data=data, @@ -518,17 +602,25 @@ def test_from_data_standard(self, mocker, config): config=config, ) _add_responses.assert_called_once_with( - endpoint=param_endpoint, data=data.responses, schemas=param_schemas, responses={}, config=config + endpoint=param_endpoint, + data=data.responses, + schemas=param_schemas, + responses={}, + config=config, ) def test_from_data_no_operation_id(self, mocker, config): path = "/path/with/{param}/" method = "get" add_parameters = mocker.patch.object( - Endpoint, "add_parameters", return_value=(mocker.MagicMock(), mocker.MagicMock(), mocker.MagicMock()) + Endpoint, + "add_parameters", + return_value=(mocker.MagicMock(), mocker.MagicMock(), mocker.MagicMock()), ) _add_responses = mocker.patch.object( - Endpoint, "_add_responses", return_value=(mocker.MagicMock(), mocker.MagicMock()) + Endpoint, + "_add_responses", + return_value=(mocker.MagicMock(), mocker.MagicMock()), ) data = oai.Operation.model_construct( description=mocker.MagicMock(), @@ -537,7 +629,10 @@ def test_from_data_no_operation_id(self, mocker, config): responses=mocker.MagicMock(), ) schemas = mocker.MagicMock() - mocker.patch("openapi_python_client.utils.remove_string_escapes", return_value=data.description) + mocker.patch( + "openapi_python_client.utils.remove_string_escapes", + return_value=data.description, + ) parameters = mocker.MagicMock() endpoint, _, return_params = Endpoint.from_data( @@ -583,14 +678,21 @@ def test_from_data_no_security(self, mocker, config): responses=mocker.MagicMock(), ) add_parameters = mocker.patch.object( - Endpoint, "add_parameters", return_value=(mocker.MagicMock(), mocker.MagicMock(), mocker.MagicMock()) + Endpoint, + "add_parameters", + return_value=(mocker.MagicMock(), mocker.MagicMock(), mocker.MagicMock()), ) _add_responses = mocker.patch.object( - Endpoint, "_add_responses", return_value=(mocker.MagicMock(), mocker.MagicMock()) + Endpoint, + "_add_responses", + return_value=(mocker.MagicMock(), mocker.MagicMock()), ) path = mocker.MagicMock() method = mocker.MagicMock() - mocker.patch("openapi_python_client.utils.remove_string_escapes", return_value=data.description) + mocker.patch( + "openapi_python_client.utils.remove_string_escapes", + return_value=data.description, + ) schemas = mocker.MagicMock() parameters = mocker.MagicMock() @@ -635,8 +737,12 @@ def test_from_data_some_bad_bodies(self, config): responses={}, requestBody=oai.RequestBody( content={ - "application/json": oai.MediaType(media_type_schema=oai.Schema(type=DataType.STRING)), - "not a real media type": oai.MediaType(media_type_schema=oai.Schema(type=DataType.STRING)), + "application/json": oai.MediaType( + media_type_schema=oai.Schema(type=DataType.STRING) + ), + "not a real media type": oai.MediaType( + media_type_schema=oai.Schema(type=DataType.STRING) + ), }, ), ), @@ -660,7 +766,9 @@ def test_from_data_all_bodies_bad(self, config): responses={}, requestBody=oai.RequestBody( content={ - "not a real media type": oai.MediaType(media_type_schema=oai.Schema(type=DataType.STRING)), + "not a real media type": oai.MediaType( + media_type_schema=oai.Schema(type=DataType.STRING) + ), }, ), ), @@ -678,7 +786,11 @@ def test_from_data_all_bodies_bad(self, config): @pytest.mark.parametrize( "response_types, expected", - (([], "Any"), (["Something"], "Something"), (["First", "Second", "Second"], "Union[First, Second]")), + ( + ([], "Any"), + (["Something"], "Something"), + (["First", "Second", "Second"], "Union[First, Second]"), + ), ) def test_response_type(self, response_types, expected): endpoint = self.make_endpoint() @@ -711,13 +823,17 @@ def test_from_data_overrides_path_item_params_with_operation_params(self, config "/": oai.PathItem.model_construct( parameters=[ oai.Parameter.model_construct( - name="param", param_in="query", param_schema=oai.Schema.model_construct(type="string") + name="param", + param_in="query", + param_schema=oai.Schema.model_construct(type="string"), ), ], get=oai.Operation.model_construct( parameters=[ oai.Parameter.model_construct( - name="param", param_in="query", param_schema=oai.Schema.model_construct(type="integer") + name="param", + param_in="query", + param_schema=oai.Schema.model_construct(type="integer"), ) ], responses={"200": oai.Response.model_construct(description="blah")}, diff --git a/tests/test_parser/test_properties/test_init.py b/tests/test_parser/test_properties/test_init.py index 6db5c2752..97c69df74 100644 --- a/tests/test_parser/test_properties/test_init.py +++ b/tests/test_parser/test_properties/test_init.py @@ -52,10 +52,14 @@ def test_get_lazy_import_base_inner(self, union_property_factory): p = union_property_factory() assert p.get_lazy_imports(prefix="..") == set() - def test_get_lazy_import_model_inner(self, union_property_factory, model_property_factory): + def test_get_lazy_import_model_inner( + self, union_property_factory, model_property_factory + ): m = model_property_factory() p = union_property_factory(inner_properties=[m]) - assert p.get_lazy_imports(prefix="..") == {"from ..models.my_module import MyClass"} + assert p.get_lazy_imports(prefix="..") == { + "from ..models.my_module import MyClass" + } @pytest.mark.parametrize( "required,no_optional,json,expected", @@ -90,20 +94,29 @@ def test_get_type_string( assert p.get_type_string(no_optional=no_optional, json=json) == expected def test_get_base_type_string_base_inners( - self, union_property_factory, date_time_property_factory, string_property_factory + self, + union_property_factory, + date_time_property_factory, + string_property_factory, ): - p = union_property_factory(inner_properties=[date_time_property_factory(), string_property_factory()]) + p = union_property_factory( + inner_properties=[date_time_property_factory(), string_property_factory()] + ) assert p.get_base_type_string() == "Union[datetime.datetime, str]" - def test_get_base_type_string_one_base_inner(self, union_property_factory, date_time_property_factory): + def test_get_base_type_string_one_base_inner( + self, union_property_factory, date_time_property_factory + ): p = union_property_factory( inner_properties=[date_time_property_factory()], ) assert p.get_base_type_string() == "datetime.datetime" - def test_get_base_type_string_one_model_inner(self, union_property_factory, model_property_factory): + def test_get_base_type_string_one_model_inner( + self, union_property_factory, model_property_factory + ): p = union_property_factory( inner_properties=[model_property_factory()], ) @@ -113,11 +126,15 @@ def test_get_base_type_string_one_model_inner(self, union_property_factory, mode def test_get_base_type_string_model_inners( self, union_property_factory, date_time_property_factory, model_property_factory ): - p = union_property_factory(inner_properties=[date_time_property_factory(), model_property_factory()]) + p = union_property_factory( + inner_properties=[date_time_property_factory(), model_property_factory()] + ) assert p.get_base_type_string() == "Union['MyClass', datetime.datetime]" - def test_get_base_json_type_string(self, union_property_factory, date_time_property_factory): + def test_get_base_json_type_string( + self, union_property_factory, date_time_property_factory + ): p = union_property_factory( inner_properties=[date_time_property_factory()], ) @@ -125,7 +142,9 @@ def test_get_base_json_type_string(self, union_property_factory, date_time_prope assert p.get_base_json_type_string() == "str" @pytest.mark.parametrize("required", (True, False)) - def test_get_type_imports(self, union_property_factory, date_time_property_factory, required): + def test_get_type_imports( + self, union_property_factory, date_time_property_factory, required + ): p = union_property_factory( inner_properties=[date_time_property_factory()], required=required, @@ -151,16 +170,27 @@ def test_property_from_data_ref_model(self, model_property_factory, config): required = False class_name = ClassName("MyModel", "") data = oai.Reference.model_construct(ref=f"#/components/schemas/{class_name}") - class_info = Class(name=class_name, module_name=PythonIdentifier("my_model", "")) + class_info = Class( + name=class_name, module_name=PythonIdentifier("my_model", "") + ) existing_model = model_property_factory( name="old_name", class_info=class_info, ) - schemas = Schemas(classes_by_reference={ReferencePath(f"/components/schemas/{class_name}"): existing_model}) + schemas = Schemas( + classes_by_reference={ + ReferencePath(f"/components/schemas/{class_name}"): existing_model + } + ) prop, new_schemas = property_from_data( - name=name, required=required, data=data, schemas=schemas, parent_name="", config=config + name=name, + required=required, + data=data, + schemas=schemas, + parent_name="", + config=config, ) assert prop == model_property_factory( @@ -176,16 +206,25 @@ def test_property_from_data_ref_not_found(self, mocker): schemas = Schemas() prop, new_schemas = property_from_data( - name="a_prop", required=False, data=data, schemas=schemas, parent_name="parent", config=mocker.MagicMock() + name="a_prop", + required=False, + data=data, + schemas=schemas, + parent_name="parent", + config=mocker.MagicMock(), ) parse_reference_path.assert_called_once_with(data.ref) - assert prop == PropertyError(data=data, detail="Could not find reference in parsed models or enums") + assert prop == PropertyError( + data=data, detail="Could not find reference in parsed models or enums" + ) assert schemas == new_schemas assert schemas.dependencies == {} @pytest.mark.parametrize("references_exist", (True, False)) - def test_property_from_data_ref(self, any_property_factory, references_exist, config): + def test_property_from_data_ref( + self, any_property_factory, references_exist, config + ): name = "new_name" required = False ref_path = "/components/schemas/RefName" @@ -194,27 +233,43 @@ def test_property_from_data_ref(self, any_property_factory, references_exist, co existing_property = any_property_factory(name="old_name") references = {ref_path: {"old_root"}} if references_exist else {} - schemas = Schemas(classes_by_reference={ref_path: existing_property}, dependencies=references) + schemas = Schemas( + classes_by_reference={ref_path: existing_property}, dependencies=references + ) prop, new_schemas = property_from_data( - name=name, required=required, data=data, schemas=schemas, parent_name="", config=config, roots=roots + name=name, + required=required, + data=data, + schemas=schemas, + parent_name="", + config=config, + roots=roots, ) assert prop == any_property_factory(name=name, required=required) assert schemas == new_schemas - assert schemas.dependencies == {ref_path: {*roots, *references.get(ref_path, set())}} + assert schemas.dependencies == { + ref_path: {*roots, *references.get(ref_path, set())} + } def test_property_from_data_invalid_ref(self, mocker): name = mocker.MagicMock() required = mocker.MagicMock() data = oai.Reference.model_construct(ref=mocker.MagicMock()) parse_reference_path = mocker.patch( - f"{MODULE_NAME}.parse_reference_path", return_value=PropertyError(detail="bad stuff") + f"{MODULE_NAME}.parse_reference_path", + return_value=PropertyError(detail="bad stuff"), ) schemas = Schemas() prop, new_schemas = property_from_data( - name=name, required=required, data=data, schemas=schemas, parent_name="parent", config=mocker.MagicMock() + name=name, + required=required, + data=data, + schemas=schemas, + parent_name="parent", + config=mocker.MagicMock(), ) parse_reference_path.assert_called_once_with(data.ref) @@ -226,18 +281,30 @@ class TestStringBasedProperty: def test__string_based_property_binary_format(self, file_property_factory, config): name = "file_prop" required = True - data = oai.Schema.model_construct(type="string", schema_format="binary", default="a") + data = oai.Schema.model_construct( + type="string", schema_format="binary", default="a" + ) p, _ = property_from_data( - name=name, required=required, data=data, schemas=Schemas(), config=config, parent_name="" + name=name, + required=required, + data=data, + schemas=Schemas(), + config=config, + parent_name="", ) assert p == file_property_factory(name=name, required=required) class TestCreateSchemas: def test_skips_references_and_keeps_going(self, mocker, config): - components = {"a_ref": Reference.model_construct(), "a_schema": Schema.model_construct()} - update_schemas_with_data = mocker.patch(f"{MODULE_NAME}.update_schemas_with_data") + components = { + "a_ref": Reference.model_construct(), + "a_schema": Schema.model_construct(), + } + update_schemas_with_data = mocker.patch( + f"{MODULE_NAME}.update_schemas_with_data" + ) parse_reference_path = mocker.patch(f"{MODULE_NAME}.parse_reference_path") schemas = Schemas() @@ -249,16 +316,27 @@ def test_skips_references_and_keeps_going(self, mocker, config): config=config, data=components["a_schema"], schemas=Schemas( - errors=[PropertyError(detail="Reference schemas are not supported.", data=components["a_ref"])] + errors=[ + PropertyError( + detail="Reference schemas are not supported.", + data=components["a_ref"], + ) + ] ), ) assert result == update_schemas_with_data.return_value def test_records_bad_uris_and_keeps_going(self, mocker, config): - components = {"first": Schema.model_construct(), "second": Schema.model_construct()} - update_schemas_with_data = mocker.patch(f"{MODULE_NAME}.update_schemas_with_data") + components = { + "first": Schema.model_construct(), + "second": Schema.model_construct(), + } + update_schemas_with_data = mocker.patch( + f"{MODULE_NAME}.update_schemas_with_data" + ) parse_reference_path = mocker.patch( - f"{MODULE_NAME}.parse_reference_path", side_effect=[PropertyError(detail="some details"), "a_path"] + f"{MODULE_NAME}.parse_reference_path", + side_effect=[PropertyError(detail="some details"), "a_path"], ) schemas = Schemas() @@ -273,14 +351,20 @@ def test_records_bad_uris_and_keeps_going(self, mocker, config): ref_path="a_path", config=config, data=components["second"], - schemas=Schemas(errors=[PropertyError(detail="some details", data=components["first"])]), + schemas=Schemas( + errors=[PropertyError(detail="some details", data=components["first"])] + ), ) assert result == update_schemas_with_data.return_value def test_retries_failing_properties_while_making_progress(self, mocker, config): - components = {"first": Schema.model_construct(), "second": Schema.model_construct()} + components = { + "first": Schema.model_construct(), + "second": Schema.model_construct(), + } update_schemas_with_data = mocker.patch( - f"{MODULE_NAME}.update_schemas_with_data", side_effect=[PropertyError(), Schemas(), PropertyError()] + f"{MODULE_NAME}.update_schemas_with_data", + side_effect=[PropertyError(), Schemas(), PropertyError()], ) parse_reference_path = mocker.patch(f"{MODULE_NAME}.parse_reference_path") schemas = Schemas() @@ -298,10 +382,14 @@ def test_retries_failing_properties_while_making_progress(self, mocker, config): class TestProcessModels: - def test_detect_recursive_allof_reference_no_retry(self, mocker, model_property_factory, config): + def test_detect_recursive_allof_reference_no_retry( + self, mocker, model_property_factory, config + ): class_name = ClassName("class_name", "") recursive_model = model_property_factory( - class_info=Class(name=class_name, module_name=PythonIdentifier("module_name", "")) + class_info=Class( + name=class_name, module_name=PythonIdentifier("module_name", "") + ) ) second_model = model_property_factory() schemas = Schemas( @@ -311,9 +399,15 @@ def test_detect_recursive_allof_reference_no_retry(self, mocker, model_property_ }, models_to_process=[recursive_model, second_model], ) - recursion_error = PropertyError(data=Reference.model_construct(ref=f"#/{class_name}")) - process_model = mocker.patch(f"{MODULE_NAME}.process_model", side_effect=[recursion_error, schemas]) - process_model_errors = mocker.patch(f"{MODULE_NAME}._process_model_errors", return_value=["error"]) + recursion_error = PropertyError( + data=Reference.model_construct(ref=f"#/{class_name}") + ) + process_model = mocker.patch( + f"{MODULE_NAME}.process_model", side_effect=[recursion_error, schemas] + ) + process_model_errors = mocker.patch( + f"{MODULE_NAME}._process_model_errors", return_value=["error"] + ) result = _process_models(schemas=schemas, config=config) @@ -323,11 +417,17 @@ def test_detect_recursive_allof_reference_no_retry(self, mocker, model_property_ call(schemas.classes_by_name["second"], schemas=schemas, config=config), ] ) - assert process_model_errors.was_called_once_with([(recursive_model, recursion_error)]) - assert all(error in result.errors for error in process_model_errors.return_value) + assert process_model_errors.was_called_once_with( + [(recursive_model, recursion_error)] + ) + assert all( + error in result.errors for error in process_model_errors.return_value + ) assert "\n\nRecursive allOf reference found" in recursion_error.detail - def test_resolve_reference_to_single_allof_reference(self, config, model_property_factory): + def test_resolve_reference_to_single_allof_reference( + self, config, model_property_factory + ): # test for https://github.com/openapi-generators/openapi-python-client/issues/1091 components = { @@ -376,7 +476,9 @@ def test_resolve_reference_to_single_allof_reference(self, config, model_propert ) # Verify that Model3 extended the properties from Model1 - assert [p.name for p in result.classes_by_name["Model3"].optional_properties] == ["prop1", "prop2"] + assert [ + p.name for p in result.classes_by_name["Model3"].optional_properties + ] == ["prop1", "prop2"] class TestPropogateRemoval: @@ -418,7 +520,10 @@ def test_propogate_removal_ref_path_no_refs(self): root = ReferencePath("/root/reference") class_name = ClassName("ClassName", "") ref_path = ReferencePath("/ref/path") - schemas = Schemas(classes_by_name={class_name: None}, classes_by_reference={root: None, ref_path: None}) + schemas = Schemas( + classes_by_name={class_name: None}, + classes_by_reference={root: None, ref_path: None}, + ) error = PropertyError() _propogate_removal(root=root, schemas=schemas, error=error) @@ -448,19 +553,32 @@ def test_propogate_removal_ref_path_already_removed(self): def test_process_model_errors(mocker, model_property_factory): propogate_removal = mocker.patch(f"{MODULE_NAME}._propogate_removal") model_errors = [ - (model_property_factory(roots={"root1", "root2"}), PropertyError(detail="existing detail")), + ( + model_property_factory(roots={"root1", "root2"}), + PropertyError(detail="existing detail"), + ), (model_property_factory(roots=set()), PropertyError()), - (model_property_factory(roots={"root1", "root3"}), PropertyError(detail="other existing detail")), + ( + model_property_factory(roots={"root1", "root3"}), + PropertyError(detail="other existing detail"), + ), ] schemas = Schemas() result = _process_model_errors(model_errors, schemas=schemas) propogate_removal.assert_has_calls( - [call(root=root, schemas=schemas, error=error) for model, error in model_errors for root in model.roots] + [ + call(root=root, schemas=schemas, error=error) + for model, error in model_errors + for root in model.roots + ] ) assert result == [error for _, error in model_errors] - assert all("\n\nFailure to process schema has resulted in the removal of:" in error.detail for error in result) + assert all( + "\n\nFailure to process schema has resulted in the removal of:" in error.detail + for error in result + ) class TestBuildParameters: @@ -477,30 +595,47 @@ def test_skips_references_and_keeps_going(self, mocker, config): ), } - update_parameters_with_data = mocker.patch(f"{MODULE_NAME}.update_parameters_with_data") + update_parameters_with_data = mocker.patch( + f"{MODULE_NAME}.update_parameters_with_data" + ) parse_reference_path = mocker.patch(f"{MODULE_NAME}.parse_reference_path") - result = build_parameters(components=parameters, parameters=Parameters(), config=config) + result = build_parameters( + components=parameters, parameters=Parameters(), config=config + ) # Should not even try to parse a path for the Reference parse_reference_path.assert_called_once_with("#/components/parameters/defined") update_parameters_with_data.assert_called_once_with( ref_path=parse_reference_path.return_value, data=parameters["defined"], parameters=Parameters( - errors=[ParameterError(detail="Reference parameters are not supported.", data=parameters["reference"])] + errors=[ + ParameterError( + detail="Reference parameters are not supported.", + data=parameters["reference"], + ) + ] ), config=config, ) assert result == update_parameters_with_data.return_value def test_records_bad_uris_and_keeps_going(self, mocker, config): - parameters = {"first": Parameter.model_construct(), "second": Parameter.model_construct()} - update_parameters_with_data = mocker.patch(f"{MODULE_NAME}.update_parameters_with_data") + parameters = { + "first": Parameter.model_construct(), + "second": Parameter.model_construct(), + } + update_parameters_with_data = mocker.patch( + f"{MODULE_NAME}.update_parameters_with_data" + ) parse_reference_path = mocker.patch( - f"{MODULE_NAME}.parse_reference_path", side_effect=[ParameterError(detail="some details"), "a_path"] + f"{MODULE_NAME}.parse_reference_path", + side_effect=[ParameterError(detail="some details"), "a_path"], ) - result = build_parameters(components=parameters, parameters=Parameters(), config=config) + result = build_parameters( + components=parameters, parameters=Parameters(), config=config + ) parse_reference_path.assert_has_calls( [ call("#/components/parameters/first"), @@ -510,19 +645,27 @@ def test_records_bad_uris_and_keeps_going(self, mocker, config): update_parameters_with_data.assert_called_once_with( ref_path="a_path", data=parameters["second"], - parameters=Parameters(errors=[ParameterError(detail="some details", data=parameters["first"])]), + parameters=Parameters( + errors=[ParameterError(detail="some details", data=parameters["first"])] + ), config=config, ) assert result == update_parameters_with_data.return_value def test_retries_failing_parameters_while_making_progress(self, mocker, config): - parameters = {"first": Parameter.model_construct(), "second": Parameter.model_construct()} + parameters = { + "first": Parameter.model_construct(), + "second": Parameter.model_construct(), + } update_parameters_with_data = mocker.patch( - f"{MODULE_NAME}.update_parameters_with_data", side_effect=[ParameterError(), Parameters(), ParameterError()] + f"{MODULE_NAME}.update_parameters_with_data", + side_effect=[ParameterError(), Parameters(), ParameterError()], ) parse_reference_path = mocker.patch(f"{MODULE_NAME}.parse_reference_path") - result = build_parameters(components=parameters, parameters=Parameters(), config=config) + result = build_parameters( + components=parameters, parameters=Parameters(), config=config + ) parse_reference_path.assert_has_calls( [ call("#/components/parameters/first"), @@ -538,11 +681,18 @@ def test_build_schemas(mocker, config): create_schemas = mocker.patch(f"{MODULE_NAME}._create_schemas") process_models = mocker.patch(f"{MODULE_NAME}._process_models") - components = {"a_ref": Reference.model_construct(), "a_schema": Schema.model_construct()} + components = { + "a_ref": Reference.model_construct(), + "a_schema": Schema.model_construct(), + } schemas = Schemas() result = build_schemas(components=components, schemas=schemas, config=config) - create_schemas.assert_called_once_with(components=components, schemas=schemas, config=config) - process_models.assert_called_once_with(schemas=create_schemas.return_value, config=config) + create_schemas.assert_called_once_with( + components=components, schemas=schemas, config=config + ) + process_models.assert_called_once_with( + schemas=create_schemas.return_value, config=config + ) assert result == process_models.return_value diff --git a/tests/test_parser/test_properties/test_merge_properties.py b/tests/test_parser/test_properties/test_merge_properties.py index 819f9ec26..9b85c9d00 100644 --- a/tests/test_parser/test_properties/test_merge_properties.py +++ b/tests/test_parser/test_properties/test_merge_properties.py @@ -65,7 +65,9 @@ def test_incompatible_types( if {prop1.__class__, prop2.__class__} == {IntProperty, FloatProperty}: continue # the int+float case is covered in another test error = merge_properties(prop1, prop2) - assert isinstance(error, PropertyError), f"Expected {type(prop1)} and {type(prop2)} to be incompatible" + assert isinstance( + error, PropertyError + ), f"Expected {type(prop1)} and {type(prop2)} to be incompatible" def test_merge_int_with_float(int_property_factory, float_property_factory): @@ -75,7 +77,9 @@ def test_merge_int_with_float(int_property_factory, float_property_factory): assert merge_properties(int_prop, float_prop) == ( evolve(int_prop, default=Value("2", 2), description=float_prop.description) ) - assert merge_properties(float_prop, int_prop) == evolve(int_prop, default=Value("2", 2)) + assert merge_properties(float_prop, int_prop) == evolve( + int_prop, default=Value("2", 2) + ) float_prop_with_non_int_default = evolve(float_prop, default=Value("2.5", 2.5)) error = merge_properties(int_prop, float_prop_with_non_int_default) @@ -93,10 +97,14 @@ def test_merge_with_any( ): original_desc = "description" props = [ - boolean_property_factory(default=Value("True", "True"), description=original_desc), + boolean_property_factory( + default=Value("True", "True"), description=original_desc + ), int_property_factory(default=Value("1", "1"), description=original_desc), float_property_factory(default=Value("1.5", "1.5"), description=original_desc), - string_property_factory(default=StringProperty.convert_value("x"), description=original_desc), + string_property_factory( + default=StringProperty.convert_value("x"), description=original_desc + ), model_property_factory(description=original_desc), ] any_prop = any_property_factory() @@ -106,7 +114,9 @@ def test_merge_with_any( @pytest.mark.parametrize("literal_enums", (False, True)) -def test_merge_enums(literal_enums, enum_property_factory, literal_enum_property_factory, config): +def test_merge_enums( + literal_enums, enum_property_factory, literal_enum_property_factory, config +): if literal_enums: enum_with_fewer_values = literal_enum_property_factory( description="desc1", @@ -132,8 +142,12 @@ def test_merge_enums(literal_enums, enum_property_factory, literal_enum_property # Setting class_info separately because it doesn't get initialized by the constructor - we want # to make sure the right enum class name gets used in the merged property - enum_with_fewer_values.class_info = Class.from_string(string="FewerValuesEnum", config=config) - enum_with_more_values.class_info = Class.from_string(string="MoreValuesEnum", config=config) + enum_with_fewer_values.class_info = Class.from_string( + string="FewerValuesEnum", config=config + ) + enum_with_more_values.class_info = Class.from_string( + string="MoreValuesEnum", config=config + ) assert merge_properties(enum_with_fewer_values, enum_with_more_values) == evolve( enum_with_more_values, @@ -149,9 +163,14 @@ def test_merge_enums(literal_enums, enum_property_factory, literal_enum_property @pytest.mark.parametrize("literal_enums", (False, True)) def test_merge_string_with_string_enum( - literal_enums, string_property_factory, enum_property_factory, literal_enum_property_factory + literal_enums, + string_property_factory, + enum_property_factory, + literal_enum_property_factory, ): - string_prop = string_property_factory(default=Value("A", "A"), description="desc1", example="example1") + string_prop = string_property_factory( + default=Value("A", "A"), description="desc1", example="example1" + ) enum_prop = ( literal_enum_property_factory( default=Value("'B'", "B"), @@ -182,9 +201,14 @@ def test_merge_string_with_string_enum( @pytest.mark.parametrize("literal_enums", (False, True)) def test_merge_int_with_int_enum( - literal_enums, int_property_factory, enum_property_factory, literal_enum_property_factory + literal_enums, + int_property_factory, + enum_property_factory, + literal_enum_property_factory, ): - int_prop = int_property_factory(default=Value("1", 1), description="desc1", example="example1") + int_prop = int_property_factory( + default=Value("1", 1), description="desc1", example="example1" + ) enum_prop = ( literal_enum_property_factory( default=Value("1", 1), @@ -205,7 +229,10 @@ def test_merge_int_with_int_enum( assert merge_properties(int_prop, enum_prop) == evolve(enum_prop, required=True) assert merge_properties(enum_prop, int_prop) == evolve( - enum_prop, required=True, description=int_prop.description, example=int_prop.example + enum_prop, + required=True, + description=int_prop.description, + example=int_prop.example, ) @@ -272,11 +299,19 @@ def test_merge_string_with_formatted_string( assert isinstance(merged2, formatted_prop.__class__) assert merged2.description == string_prop.description - assert isinstance(merge_properties(string_prop_with_invalid_default, formatted_prop), PropertyError) - assert isinstance(merge_properties(formatted_prop, string_prop_with_invalid_default), PropertyError) + assert isinstance( + merge_properties(string_prop_with_invalid_default, formatted_prop), + PropertyError, + ) + assert isinstance( + merge_properties(formatted_prop, string_prop_with_invalid_default), + PropertyError, + ) -def test_merge_lists(int_property_factory, list_property_factory, string_property_factory): +def test_merge_lists( + int_property_factory, list_property_factory, string_property_factory +): string_prop_1 = string_property_factory(description="desc1") string_prop_2 = string_property_factory(example="desc2") int_prop = int_property_factory() diff --git a/tests/test_parser/test_properties/test_model_property.py b/tests/test_parser/test_properties/test_model_property.py index 85ab3389a..0725aa43d 100644 --- a/tests/test_parser/test_properties/test_model_property.py +++ b/tests/test_parser/test_properties/test_model_property.py @@ -5,7 +5,12 @@ import openapi_python_client.schema as oai from openapi_python_client.parser.errors import PropertyError -from openapi_python_client.parser.properties import Class, ModelProperty, Schemas, StringProperty +from openapi_python_client.parser.properties import ( + Class, + ModelProperty, + Schemas, + StringProperty, +) from openapi_python_client.parser.properties.model_property import ( ANY_ADDITIONAL_PROPERTY, _process_properties, @@ -32,12 +37,17 @@ class TestModelProperty: (False, True, True, True, "dict[str, Any]"), ], ) - def test_get_type_string(self, no_optional, required, json, expected, model_property_factory, quoted): + def test_get_type_string( + self, no_optional, required, json, expected, model_property_factory, quoted + ): prop = model_property_factory( required=required, ) - assert prop.get_type_string(no_optional=no_optional, json=json, quoted=quoted) == expected + assert ( + prop.get_type_string(no_optional=no_optional, json=json, quoted=quoted) + == expected + ) def test_get_imports(self, model_property_factory): prop = model_property_factory(required=False) @@ -91,7 +101,9 @@ class TestBuild: ), ], ) - def test_additional_schemas(self, additional_properties_schema, expected_additional_properties, config): + def test_additional_schemas( + self, additional_properties_schema, expected_additional_properties, config + ): data = oai.Schema.model_construct( additionalProperties=additional_properties_schema, ) @@ -109,7 +121,13 @@ def test_additional_schemas(self, additional_properties_schema, expected_additio assert model.additional_properties == expected_additional_properties - def test_happy_path(self, model_property_factory, string_property_factory, date_time_property_factory, config): + def test_happy_path( + self, + model_property_factory, + string_property_factory, + date_time_property_factory, + config, + ): name = "prop" required = True @@ -122,7 +140,10 @@ def test_happy_path(self, model_property_factory, string_property_factory, date_ }, description="A class called MyModel", ) - schemas = Schemas(classes_by_reference={"OtherModel": None}, classes_by_name={"OtherModel": None}) + schemas = Schemas( + classes_by_reference={"OtherModel": None}, + classes_by_name={"OtherModel": None}, + ) class_info = Class(name="ParentMyModel", module_name="parent_my_model") roots = {"root"} @@ -153,7 +174,9 @@ def test_happy_path(self, model_property_factory, string_property_factory, date_ data=data, class_info=class_info, required_properties=[string_property_factory(name="req", required=True)], - optional_properties=[date_time_property_factory(name="opt", required=False)], + optional_properties=[ + date_time_property_factory(name="opt", required=False) + ], description=data.description, relative_imports={ "from dateutil.parser import isoparse", @@ -182,7 +205,10 @@ def test_model_name_conflict(self, config): ) assert new_schemas == schemas - assert err == PropertyError(detail='Attempted to generate duplicate models with name "OtherModel"', data=data) + assert err == PropertyError( + detail='Attempted to generate duplicate models with name "OtherModel"', + data=data, + ) @pytest.mark.parametrize( "name, title, parent_name, use_title_prefixing, expected", @@ -216,7 +242,9 @@ def test_model_naming( title=title, properties={}, ) - config = evolve(config, use_path_prefixes_for_title_model_names=use_title_prefixing) + config = evolve( + config, use_path_prefixes_for_title_model_names=use_title_prefixing + ) result = ModelProperty.build( data=data, name=name, @@ -232,7 +260,9 @@ def test_model_naming( def test_model_bad_properties(self, config): data = oai.Schema( properties={ - "bad": oai.Reference.model_construct(ref="#/components/schema/NotExist"), + "bad": oai.Reference.model_construct( + ref="#/components/schema/NotExist" + ), }, ) result = ModelProperty.build( @@ -280,7 +310,10 @@ def test_process_properties_false(self, model_property_factory, config): }, description="A class called MyModel", ) - schemas = Schemas(classes_by_reference={"OtherModel": None}, classes_by_name={"OtherModel": None}) + schemas = Schemas( + classes_by_reference={"OtherModel": None}, + classes_by_name={"OtherModel": None}, + ) roots = {"root"} class_info = Class(name="ParentMyModel", module_name="parent_my_model") @@ -315,87 +348,134 @@ def test_process_properties_false(self, model_property_factory, config): class TestProcessProperties: def test_conflicting_properties_different_types( - self, model_property_factory, string_property_factory, int_property_factory, config + self, + model_property_factory, + string_property_factory, + int_property_factory, + config, ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) schemas = Schemas( classes_by_reference={ "/First": model_property_factory( - required_properties=[], optional_properties=[string_property_factory()] + required_properties=[], + optional_properties=[string_property_factory()], + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[int_property_factory()] ), - "/Second": model_property_factory(required_properties=[], optional_properties=[int_property_factory()]), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) def test_process_properties_reference_not_exist(self, config): data = oai.Schema( properties={ - "bad": oai.Reference.model_construct(ref="#/components/schema/NotExist"), + "bad": oai.Reference.model_construct( + ref="#/components/schema/NotExist" + ), }, ) - result = _process_properties(data=data, class_name="", schemas=Schemas(), config=config, roots={"root"}) + result = _process_properties( + data=data, class_name="", schemas=Schemas(), config=config, roots={"root"} + ) assert isinstance(result, PropertyError) def test_process_properties_all_of_reference_not_exist(self, config): - data = oai.Schema.model_construct(allOf=[oai.Reference.model_construct(ref="#/components/schema/NotExist")]) + data = oai.Schema.model_construct( + allOf=[oai.Reference.model_construct(ref="#/components/schema/NotExist")] + ) - result = _process_properties(data=data, class_name="", schemas=Schemas(), config=config, roots={"root"}) + result = _process_properties( + data=data, class_name="", schemas=Schemas(), config=config, roots={"root"} + ) assert isinstance(result, PropertyError) - def test_process_properties_model_property_roots(self, model_property_factory, config): + def test_process_properties_model_property_roots( + self, model_property_factory, config + ): roots = {"root"} - data = oai.Schema(properties={"test_model_property": oai.Schema.model_construct(type="object")}) + data = oai.Schema( + properties={ + "test_model_property": oai.Schema.model_construct(type="object") + } + ) - result = _process_properties(data=data, class_name="", schemas=Schemas(), config=config, roots=roots) + result = _process_properties( + data=data, class_name="", schemas=Schemas(), config=config, roots=roots + ) assert all(root in result.optional_props[0].roots for root in roots) def test_invalid_reference(self, config): - data = oai.Schema.model_construct(allOf=[oai.Reference.model_construct(ref="ThisIsNotGood")]) + data = oai.Schema.model_construct( + allOf=[oai.Reference.model_construct(ref="ThisIsNotGood")] + ) schemas = Schemas() - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) def test_non_model_reference(self, enum_property_factory, config): - data = oai.Schema.model_construct(allOf=[oai.Reference.model_construct(ref="#/First")]) + data = oai.Schema.model_construct( + allOf=[oai.Reference.model_construct(ref="#/First")] + ) schemas = Schemas( classes_by_reference={ "/First": enum_property_factory(), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) def test_reference_not_processed(self, model_property_factory, config): - data = oai.Schema.model_construct(allOf=[oai.Reference.model_construct(ref="#/Unprocessed")]) + data = oai.Schema.model_construct( + allOf=[oai.Reference.model_construct(ref="#/Unprocessed")] + ) schemas = Schemas( classes_by_reference={ "/Unprocessed": model_property_factory(), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) def test_allof_string_and_string_enum( - self, model_property_factory, enum_property_factory, string_property_factory, config + self, + model_property_factory, + enum_property_factory, + string_property_factory, + config, ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property = enum_property_factory( values={"foo": "foo"}, @@ -406,18 +486,29 @@ def test_allof_string_and_string_enum( required_properties=[], optional_properties=[string_property_factory(required=False)], ), - "/Second": model_property_factory(required_properties=[], optional_properties=[enum_property]), + "/Second": model_property_factory( + required_properties=[], optional_properties=[enum_property] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert result.required_props[0] == enum_property def test_allof_string_enum_and_string( - self, model_property_factory, enum_property_factory, string_property_factory, config + self, + model_property_factory, + enum_property_factory, + string_property_factory, + config, ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property = enum_property_factory( required=False, @@ -425,7 +516,9 @@ def test_allof_string_enum_and_string( ) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[enum_property]), + "/First": model_property_factory( + required_properties=[], optional_properties=[enum_property] + ), "/Second": model_property_factory( required_properties=[], optional_properties=[string_property_factory(required=False)], @@ -433,12 +526,23 @@ def test_allof_string_enum_and_string( } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert result.optional_props[0] == enum_property - def test_allof_int_and_int_enum(self, model_property_factory, enum_property_factory, int_property_factory, config): + def test_allof_int_and_int_enum( + self, + model_property_factory, + enum_property_factory, + int_property_factory, + config, + ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property = enum_property_factory( values={"foo": 1}, @@ -446,19 +550,32 @@ def test_allof_int_and_int_enum(self, model_property_factory, enum_property_fact ) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[int_property_factory()]), - "/Second": model_property_factory(required_properties=[], optional_properties=[enum_property]), + "/First": model_property_factory( + required_properties=[], optional_properties=[int_property_factory()] + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[enum_property] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert result.required_props[0] == enum_property def test_allof_enum_incompatible_type( - self, model_property_factory, enum_property_factory, int_property_factory, config + self, + model_property_factory, + enum_property_factory, + int_property_factory, + config, ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property = enum_property_factory( values={"foo": 1}, @@ -466,17 +583,28 @@ def test_allof_enum_incompatible_type( ) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[int_property_factory()]), - "/Second": model_property_factory(required_properties=[], optional_properties=[enum_property]), + "/First": model_property_factory( + required_properties=[], optional_properties=[int_property_factory()] + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[enum_property] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) - def test_allof_string_enums(self, model_property_factory, enum_property_factory, config): + def test_allof_string_enums( + self, model_property_factory, enum_property_factory, config + ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property1 = enum_property_factory( name="an_enum", @@ -490,17 +618,28 @@ def test_allof_string_enums(self, model_property_factory, enum_property_factory, ) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[enum_property1]), - "/Second": model_property_factory(required_properties=[], optional_properties=[enum_property2]), + "/First": model_property_factory( + required_properties=[], optional_properties=[enum_property1] + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[enum_property2] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert result.required_props[0] == enum_property1 - def test_allof_int_enums(self, model_property_factory, enum_property_factory, config): + def test_allof_int_enums( + self, model_property_factory, enum_property_factory, config + ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property1 = enum_property_factory( name="an_enum", @@ -514,17 +653,28 @@ def test_allof_int_enums(self, model_property_factory, enum_property_factory, co ) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[enum_property1]), - "/Second": model_property_factory(required_properties=[], optional_properties=[enum_property2]), + "/First": model_property_factory( + required_properties=[], optional_properties=[enum_property1] + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[enum_property2] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert result.required_props[0] == enum_property2 - def test_allof_enums_are_not_subsets(self, model_property_factory, enum_property_factory, config): + def test_allof_enums_are_not_subsets( + self, model_property_factory, enum_property_factory, config + ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) enum_property1 = enum_property_factory( name="an_enum", @@ -538,29 +688,48 @@ def test_allof_enums_are_not_subsets(self, model_property_factory, enum_property ) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[enum_property1]), - "/Second": model_property_factory(required_properties=[], optional_properties=[enum_property2]), + "/First": model_property_factory( + required_properties=[], optional_properties=[enum_property1] + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[enum_property2] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) - def test_duplicate_properties(self, model_property_factory, string_property_factory, config): + def test_duplicate_properties( + self, model_property_factory, string_property_factory, config + ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) prop = string_property_factory(required=False) schemas = Schemas( classes_by_reference={ - "/First": model_property_factory(required_properties=[], optional_properties=[prop]), - "/Second": model_property_factory(required_properties=[], optional_properties=[prop]), + "/First": model_property_factory( + required_properties=[], optional_properties=[prop] + ), + "/Second": model_property_factory( + required_properties=[], optional_properties=[prop] + ), } ) - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) - assert result.optional_props == [prop], "There should only be one copy of duplicate properties" + assert result.optional_props == [ + prop + ], "There should only be one copy of duplicate properties" @pytest.mark.parametrize("first_required", [True, False]) @pytest.mark.parametrize("second_required", [True, False]) @@ -573,23 +742,32 @@ def test_mixed_requirements( config, ): data = oai.Schema.model_construct( - allOf=[oai.Reference.model_construct(ref="#/First"), oai.Reference.model_construct(ref="#/Second")] + allOf=[ + oai.Reference.model_construct(ref="#/First"), + oai.Reference.model_construct(ref="#/Second"), + ] ) schemas = Schemas( classes_by_reference={ "/First": model_property_factory( required_properties=[], - optional_properties=[string_property_factory(required=first_required)], + optional_properties=[ + string_property_factory(required=first_required) + ], ), "/Second": model_property_factory( required_properties=[], - optional_properties=[string_property_factory(required=second_required)], + optional_properties=[ + string_property_factory(required=second_required) + ], ), } ) roots = {"root"} - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots=roots) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots=roots + ) required = first_required or second_required expected_prop = string_property_factory( @@ -616,10 +794,16 @@ def test_direct_properties_non_ref(self, string_property_factory, config): ) schemas = Schemas() - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) - assert result.optional_props == [string_property_factory(name="second", required=False)] - assert result.required_props == [string_property_factory(name="first", required=True)] + assert result.optional_props == [ + string_property_factory(name="second", required=False) + ] + assert result.required_props == [ + string_property_factory(name="first", required=True) + ] def test_conflicting_property_names(self, config): data = oai.Schema.model_construct( @@ -629,10 +813,14 @@ def test_conflicting_property_names(self, config): } ) schemas = Schemas() - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert isinstance(result, PropertyError) - def test_merge_inline_objects(self, model_property_factory, enum_property_factory, config): + def test_merge_inline_objects( + self, model_property_factory, enum_property_factory, config + ): data = oai.Schema.model_construct( allOf=[ oai.Schema.model_construct( @@ -644,14 +832,18 @@ def test_merge_inline_objects(self, model_property_factory, enum_property_factor oai.Schema.model_construct( type="object", properties={ - "prop1": oai.Schema.model_construct(type="string", description="desc"), + "prop1": oai.Schema.model_construct( + type="string", description="desc" + ), }, ), ] ) schemas = Schemas() - result = _process_properties(data=data, schemas=schemas, class_name="", config=config, roots={"root"}) + result = _process_properties( + data=data, schemas=schemas, class_name="", config=config, roots={"root"} + ) assert not isinstance(result, PropertyError) assert len(result.optional_props) == 1 prop1 = result.optional_props[0] @@ -687,7 +879,10 @@ def test_process_model(self, mocker, model_property_factory, config): ) additional_properties = True process_property_data = mocker.patch(f"{MODULE_NAME}._process_property_data") - process_property_data.return_value = ((property_data, additional_properties), schemas) + process_property_data.return_value = ( + (property_data, additional_properties), + schemas, + ) result = process_model(model_prop=model_prop, schemas=schemas, config=config) @@ -701,8 +896,12 @@ def test_process_model(self, mocker, model_property_factory, config): def test_set_relative_imports(model_property_factory): class_info = Class("ClassName", module_name="module_name") - relative_imports = {f"from ..models.{class_info.module_name} import {class_info.name}"} + relative_imports = { + f"from ..models.{class_info.module_name} import {class_info.name}" + } - model_property = model_property_factory(class_info=class_info, relative_imports=relative_imports) + model_property = model_property_factory( + class_info=class_info, relative_imports=relative_imports + ) assert model_property.relative_imports == set() diff --git a/tests/test_parser/test_properties/test_protocol.py b/tests/test_parser/test_properties/test_protocol.py index 800aa69e4..5d047bac0 100644 --- a/tests/test_parser/test_properties/test_protocol.py +++ b/tests/test_parser/test_properties/test_protocol.py @@ -23,11 +23,15 @@ def test_is_base_type(any_property_factory): (True, True, True, False, "str"), ], ) -def test_get_type_string(any_property_factory, mocker, required, no_optional, json, expected, quoted): +def test_get_type_string( + any_property_factory, mocker, required, no_optional, json, expected, quoted +): mocker.patch.object(AnyProperty, "_type_string", "TestType") mocker.patch.object(AnyProperty, "_json_type_string", "str") p = any_property_factory(required=required) - assert p.get_type_string(no_optional=no_optional, json=json, quoted=quoted) == expected + assert ( + p.get_type_string(no_optional=no_optional, json=json, quoted=quoted) == expected + ) @pytest.mark.parametrize( @@ -39,10 +43,14 @@ def test_get_type_string(any_property_factory, mocker, required, no_optional, js ("Test", True, "test: Any = Test"), ], ) -def test_to_string(default: str | None, required: bool, expected: str, any_property_factory): +def test_to_string( + default: str | None, required: bool, expected: str, any_property_factory +): name = "test" p = any_property_factory( - name=name, required=required, default=Value(default, default) if default is not None else None + name=name, + required=required, + default=Value(default, default) if default is not None else None, ) assert p.to_string() == expected @@ -53,7 +61,10 @@ def test_get_imports(any_property_factory): assert p.get_imports(prefix="") == set() p = any_property_factory(name="test", required=False, default=None) - assert p.get_imports(prefix="") == {"from types import UNSET, Unset", "from typing import Union"} + assert p.get_imports(prefix="") == { + "from types import UNSET, Unset", + "from typing import Union", + } @pytest.mark.parametrize( diff --git a/tests/test_parser/test_properties/test_schemas.py b/tests/test_parser/test_properties/test_schemas.py index 7e7af8514..f0b2e4e24 100644 --- a/tests/test_parser/test_properties/test_schemas.py +++ b/tests/test_parser/test_properties/test_schemas.py @@ -16,7 +16,9 @@ def test_class_from_string_default_config(config): - class_ = Class.from_string(string="#/components/schemas/PingResponse", config=config) + class_ = Class.from_string( + string="#/components/schemas/PingResponse", config=config + ) assert class_.name == "PingResponse" assert class_.module_name == "ping_response" @@ -31,10 +33,17 @@ def test_class_from_string_default_config(config): (None, "some_module", "MyResponse", "some_module"), ), ) -def test_class_from_string(class_override, module_override, expected_class, expected_module, config): +def test_class_from_string( + class_override, module_override, expected_class, expected_module, config +): ref = "#/components/schemas/MyResponse" config = evolve( - config, class_overrides={"MyResponse": ClassOverride(class_name=class_override, module_name=module_override)} + config, + class_overrides={ + "MyResponse": ClassOverride( + class_name=class_override, module_name=module_override + ) + }, ) result = Class.from_string(string=ref, config=config) @@ -63,14 +72,21 @@ def test_parameters_without_schema_are_ignored(self, config): def test_registers_new_parameters(self, config): param = Parameter.model_construct( - name="a_param", param_in=ParameterLocation.QUERY, param_schema=Schema.model_construct() + name="a_param", + param_in=ParameterLocation.QUERY, + param_schema=Schema.model_construct(), ) parameters = Parameters() param_or_error, new_parameters = parameter_from_data( name=param.name, data=param, parameters=parameters, config=config ) assert param_or_error == param - assert new_parameters.classes_by_name[ClassName(param.name, prefix=config.field_prefix)] == param + assert ( + new_parameters.classes_by_name[ + ClassName(param.name, prefix=config.field_prefix) + ] + == param + ) class TestParameterFromReference: @@ -84,9 +100,12 @@ def test_errors_out_if_reference_not_in_parameters(self): ref = Reference.model_construct(ref="#/components/parameters/a_param") class_info = Class(name="a_param", module_name="module_name") existing_param = Parameter.model_construct(name="a_param") - param_by_ref = Reference.model_construct(ref="#/components/parameters/another_param") + param_by_ref = Reference.model_construct( + ref="#/components/parameters/another_param" + ) params = Parameters( - classes_by_name={class_info.name: existing_param}, classes_by_reference={ref.ref: existing_param} + classes_by_name={class_info.name: existing_param}, + classes_by_reference={ref.ref: existing_param}, ) param_or_error = parameter_from_reference(param=param_by_ref, parameters=params) assert param_or_error == ParameterError( @@ -110,10 +129,13 @@ class TestUpdateParametersFromData: def test_reports_parameters_with_errors(self, mocker, config): parameters = Parameters() param = Parameter.model_construct( - name="a_param", param_in=ParameterLocation.QUERY, param_schema=Schema.model_construct() + name="a_param", + param_in=ParameterLocation.QUERY, + param_schema=Schema.model_construct(), ) parameter_from_data = mocker.patch( - f"{MODULE_NAME}.parameter_from_data", side_effect=[(ParameterError(), parameters)] + f"{MODULE_NAME}.parameter_from_data", + side_effect=[(ParameterError(), parameters)], ) ref_path = Reference.model_construct(ref="#/components/parameters/a_param") new_parameters_or_error = update_parameters_with_data( @@ -129,9 +151,13 @@ def test_reports_parameters_with_errors(self, mocker, config): def test_records_references_to_parameters(self, mocker, config): parameters = Parameters() param = Parameter.model_construct( - name="a_param", param_in=ParameterLocation.QUERY, param_schema=Schema.model_construct() + name="a_param", + param_in=ParameterLocation.QUERY, + param_schema=Schema.model_construct(), + ) + parameter_from_data = mocker.patch( + f"{MODULE_NAME}.parameter_from_data", side_effect=[(param, parameters)] ) - parameter_from_data = mocker.patch(f"{MODULE_NAME}.parameter_from_data", side_effect=[(param, parameters)]) ref_path = "#/components/parameters/a_param" new_parameters = update_parameters_with_data( ref_path=ref_path, data=param, parameters=parameters, config=config diff --git a/tests/test_parser/test_properties/test_union.py b/tests/test_parser/test_properties/test_union.py index a36e14030..d9f3ea0bd 100644 --- a/tests/test_parser/test_properties/test_union.py +++ b/tests/test_parser/test_properties/test_union.py @@ -1,6 +1,10 @@ import openapi_python_client.schema as oai from openapi_python_client.parser.errors import ParseError -from openapi_python_client.parser.properties import Schemas, UnionProperty, property_from_data +from openapi_python_client.parser.properties import ( + Schemas, + UnionProperty, + property_from_data, +) from openapi_python_client.schema import DataType, ParameterLocation @@ -10,7 +14,12 @@ def test_invalid_location(config): ) prop, _ = UnionProperty.build( - data=data, required=True, schemas=Schemas(), parent_name="parent", name="name", config=config + data=data, + required=True, + schemas=Schemas(), + parent_name="parent", + name="name", + config=config, ) err = prop.validate_location(ParameterLocation.PATH) @@ -23,7 +32,12 @@ def test_not_required_in_path(config): ) prop, _ = UnionProperty.build( - data=data, required=False, schemas=Schemas(), parent_name="parent", name="name", config=config + data=data, + required=False, + schemas=Schemas(), + parent_name="parent", + name="name", + config=config, ) err = prop.validate_location(ParameterLocation.PATH) @@ -69,7 +83,12 @@ def test_union_oneOf_descriptive_type_name( ) p, s = property_from_data( - name=name, required=required, data=data, schemas=Schemas(), parent_name="parent", config=config + name=name, + required=required, + data=data, + schemas=Schemas(), + parent_name="parent", + config=config, ) assert p == expected diff --git a/tests/test_parser/test_responses.py b/tests/test_parser/test_responses.py index 8fb04d720..d7783dfe9 100644 --- a/tests/test_parser/test_responses.py +++ b/tests/test_parser/test_responses.py @@ -6,7 +6,12 @@ from openapi_python_client.parser import responses from openapi_python_client.parser.errors import ParseError, PropertyError from openapi_python_client.parser.properties import Schemas -from openapi_python_client.parser.responses import JSON_SOURCE, NONE_SOURCE, Response, response_from_data +from openapi_python_client.parser.responses import ( + JSON_SOURCE, + NONE_SOURCE, + Response, + response_from_data, +) MODULE_NAME = "openapi_python_client.parser.responses" @@ -49,13 +54,17 @@ def test_response_from_data_unsupported_content_type(): config=config, ) - assert response == ParseError(data=data, detail="Unsupported content_type {'blah': None}") + assert response == ParseError( + data=data, detail="Unsupported content_type {'blah': None}" + ) def test_response_from_data_no_content_schema(any_property_factory): data = oai.Response.model_construct( description="", - content={"application/vnd.api+json; version=2.2": oai.MediaType.model_construct()}, + content={ + "application/vnd.api+json; version=2.2": oai.MediaType.model_construct() + }, ) config = MagicMock() config.content_type_overrides = {} @@ -82,10 +91,16 @@ def test_response_from_data_no_content_schema(any_property_factory): def test_response_from_data_property_error(mocker): - property_from_data = mocker.patch.object(responses, "property_from_data", return_value=(PropertyError(), Schemas())) + property_from_data = mocker.patch.object( + responses, "property_from_data", return_value=(PropertyError(), Schemas()) + ) data = oai.Response.model_construct( description="", - content={"application/json": oai.MediaType.model_construct(media_type_schema="something")}, + content={ + "application/json": oai.MediaType.model_construct( + media_type_schema="something" + ) + }, ) config = MagicMock() config.content_type_overrides = {} @@ -112,10 +127,16 @@ def test_response_from_data_property_error(mocker): def test_response_from_data_property(mocker, any_property_factory): prop = any_property_factory() - property_from_data = mocker.patch.object(responses, "property_from_data", return_value=(prop, Schemas())) + property_from_data = mocker.patch.object( + responses, "property_from_data", return_value=(prop, Schemas()) + ) data = oai.Response.model_construct( description="", - content={"application/json": oai.MediaType.model_construct(media_type_schema="something")}, + content={ + "application/json": oai.MediaType.model_construct( + media_type_schema="something" + ) + }, ) config = MagicMock() config.content_type_overrides = {} @@ -150,7 +171,11 @@ def test_response_from_data_reference(mocker, any_property_factory): mocker.patch.object(responses, "property_from_data", return_value=(prop, Schemas())) predefined_response_data = oai.Response.model_construct( description="", - content={"application/json": oai.MediaType.model_construct(media_type_schema="something")}, + content={ + "application/json": oai.MediaType.model_construct( + media_type_schema="something" + ) + }, ) config = MagicMock() config.content_type_overrides = {} @@ -177,15 +202,24 @@ def test_response_from_data_reference(mocker, any_property_factory): [ ("#/components/responses/Nonexistent", "Could not find"), ("https://remote-reference", "Remote references"), - ("#/components/something-that-isnt-responses/ErrorResponse", "not allowed in responses"), + ( + "#/components/something-that-isnt-responses/ErrorResponse", + "not allowed in responses", + ), ], ) -def test_response_from_data_invalid_reference(ref_string, expected_error_string, mocker, any_property_factory): +def test_response_from_data_invalid_reference( + ref_string, expected_error_string, mocker, any_property_factory +): prop = any_property_factory() mocker.patch.object(responses, "property_from_data", return_value=(prop, Schemas())) predefined_response_data = oai.Response.model_construct( description="", - content={"application/json": oai.MediaType.model_construct(media_type_schema="something")}, + content={ + "application/json": oai.MediaType.model_construct( + media_type_schema="something" + ) + }, ) config = MagicMock() config.content_type_overrides = {} @@ -208,7 +242,11 @@ def test_response_from_data_ref_to_response_that_is_a_ref(mocker, any_property_f mocker.patch.object(responses, "property_from_data", return_value=(prop, Schemas())) predefined_response_base_data = oai.Response.model_construct( description="", - content={"application/json": oai.MediaType.model_construct(media_type_schema="something")}, + content={ + "application/json": oai.MediaType.model_construct( + media_type_schema="something" + ) + }, ) predefined_response_data = oai.Reference.model_construct( ref="#/components/references/BaseResponse", diff --git a/tests/test_schema/test_noisy_refs.py b/tests/test_schema/test_noisy_refs.py index 0d1ac1fc2..0bfeee508 100644 --- a/tests/test_schema/test_noisy_refs.py +++ b/tests/test_schema/test_noisy_refs.py @@ -31,7 +31,9 @@ ) try: - from openapi_python_client.schema.openapi_schema_pydantic.reference import ReferenceOr + from openapi_python_client.schema.openapi_schema_pydantic.reference import ( + ReferenceOr, + ) except ImportError: T = TypeVar("T") ReferenceOr = Union[Reference, T] @@ -59,7 +61,10 @@ def deannotate_type(t): @pytest.mark.parametrize( ("ref_or_type", "get_example_fn"), [ - (ReferenceOr[Callback], lambda t: {"test1": get_example(PathItem), "test2": get_example(PathItem)}), + ( + ReferenceOr[Callback], + lambda t: {"test1": get_example(PathItem), "test2": get_example(PathItem)}, + ), (ReferenceOr[Example], get_example), (ReferenceOr[Header], get_example), (ReferenceOr[Link], get_example), diff --git a/tests/test_schema/test_open_api.py b/tests/test_schema/test_open_api.py index bdab19eba..814905e3f 100644 --- a/tests/test_schema/test_open_api.py +++ b/tests/test_schema/test_open_api.py @@ -33,7 +33,15 @@ def test_parse_with_callback(): "/create": { "post": { "responses": {"200": {"description": "Success"}}, - "callbacks": {"event": {"callback": {"post": {"responses": {"200": {"description": "Success"}}}}}}, + "callbacks": { + "event": { + "callback": { + "post": { + "responses": {"200": {"description": "Success"}} + } + } + } + }, } } }, diff --git a/tests/test_schema/test_schema.py b/tests/test_schema/test_schema.py index 0aa892af1..4ffac002a 100644 --- a/tests/test_schema/test_schema.py +++ b/tests/test_schema/test_schema.py @@ -7,28 +7,41 @@ def test_nullable_with_simple_type(): def test_nullable_with_allof(): - schema = Schema.model_validate_json('{"allOf": [{"type": "string"}], "nullable": true}') - assert schema.oneOf == [Schema(type=DataType.NULL), Schema(allOf=[Schema(type=DataType.STRING)])] + schema = Schema.model_validate_json( + '{"allOf": [{"type": "string"}], "nullable": true}' + ) + assert schema.oneOf == [ + Schema(type=DataType.NULL), + Schema(allOf=[Schema(type=DataType.STRING)]), + ] assert schema.allOf == [] def test_constant_bool(): - schema = Schema.model_validate_json('{"type":"boolean", "enum":[true], "const":true, "default":true}') + schema = Schema.model_validate_json( + '{"type":"boolean", "enum":[true], "const":true, "default":true}' + ) assert schema.const is True def test_nullable_with_type_list(): - schema = Schema.model_validate_json('{"type": ["string", "number"], "nullable": true}') + schema = Schema.model_validate_json( + '{"type": ["string", "number"], "nullable": true}' + ) assert schema.type == [DataType.STRING, DataType.NUMBER, DataType.NULL] def test_nullable_with_any_of(): - schema = Schema.model_validate_json('{"anyOf": [{"type": "string"}], "nullable": true}') + schema = Schema.model_validate_json( + '{"anyOf": [{"type": "string"}], "nullable": true}' + ) assert schema.anyOf == [Schema(type=DataType.STRING), Schema(type=DataType.NULL)] def test_nullable_with_one_of(): - schema = Schema.model_validate_json('{"oneOf": [{"type": "string"}], "nullable": true}') + schema = Schema.model_validate_json( + '{"oneOf": [{"type": "string"}], "nullable": true}' + ) assert schema.oneOf == [Schema(type=DataType.STRING), Schema(type=DataType.NULL)] diff --git a/tests/test_templates/conftest.py b/tests/test_templates/conftest.py index 09fd63f6c..77d148d86 100644 --- a/tests/test_templates/conftest.py +++ b/tests/test_templates/conftest.py @@ -7,6 +7,10 @@ def env() -> Environment: from openapi_python_client import utils TEMPLATE_FILTERS = {"snakecase": utils.snake_case, "kebabcase": utils.kebab_case} - env = Environment(loader=PackageLoader("openapi_python_client"), trim_blocks=True, lstrip_blocks=True) + env = Environment( + loader=PackageLoader("openapi_python_client"), + trim_blocks=True, + lstrip_blocks=True, + ) env.filters.update(TEMPLATE_FILTERS) return env diff --git a/tests/test_templates/test_property_templates/test_date_property/required_not_null.py b/tests/test_templates/test_property_templates/test_date_property/required_not_null.py index ad4f380a4..c7342ab44 100644 --- a/tests/test_templates/test_property_templates/test_date_property/required_not_null.py +++ b/tests/test_templates/test_property_templates/test_date_property/required_not_null.py @@ -2,8 +2,7 @@ from typing import cast, Union from dateutil.parser import isoparse + some_source = date(2020, 10, 12) some_destination = some_source.isoformat() a_prop = isoparse(some_destination).date() - - diff --git a/tests/test_templates/test_property_templates/test_date_property/test_date_property.py b/tests/test_templates/test_property_templates/test_date_property/test_date_property.py index 89944994c..72820ab11 100644 --- a/tests/test_templates/test_property_templates/test_date_property/test_date_property.py +++ b/tests/test_templates/test_property_templates/test_date_property/test_date_property.py @@ -19,12 +19,16 @@ def date_property(required=True, default=None) -> DateProperty: def test_required(): prop = date_property() here = Path(__file__).parent - templates_dir = here.parent.parent.parent.parent / "openapi_python_client" / "templates" + templates_dir = ( + here.parent.parent.parent.parent / "openapi_python_client" / "templates" + ) env = jinja2.Environment( - loader=jinja2.ChoiceLoader([jinja2.FileSystemLoader(here), jinja2.FileSystemLoader(templates_dir)]), + loader=jinja2.ChoiceLoader( + [jinja2.FileSystemLoader(here), jinja2.FileSystemLoader(templates_dir)] + ), trim_blocks=True, - lstrip_blocks=True + lstrip_blocks=True, ) template = env.get_template("date_property_template.py.jinja") diff --git a/tests/test_templates/test_property_templates/test_datetime_property/required_not_null.py b/tests/test_templates/test_property_templates/test_datetime_property/required_not_null.py index 8253828e3..672f15247 100644 --- a/tests/test_templates/test_property_templates/test_datetime_property/required_not_null.py +++ b/tests/test_templates/test_property_templates/test_datetime_property/required_not_null.py @@ -2,8 +2,7 @@ from typing import cast, Union from dateutil.parser import isoparse + some_source = date(2020, 10, 12) some_destination = some_source.isoformat() a_prop = isoparse(some_destination) - - diff --git a/tests/test_templates/test_property_templates/test_datetime_property/test_datetime_property.py b/tests/test_templates/test_property_templates/test_datetime_property/test_datetime_property.py index bb9a3bd10..1292553d3 100644 --- a/tests/test_templates/test_property_templates/test_datetime_property/test_datetime_property.py +++ b/tests/test_templates/test_property_templates/test_datetime_property/test_datetime_property.py @@ -19,12 +19,16 @@ def datetime_property(required=True, default=None) -> DateTimeProperty: def test_required(): prop = datetime_property() here = Path(__file__).parent - templates_dir = here.parent.parent.parent.parent / "openapi_python_client" / "templates" + templates_dir = ( + here.parent.parent.parent.parent / "openapi_python_client" / "templates" + ) env = jinja2.Environment( - loader=jinja2.ChoiceLoader([jinja2.FileSystemLoader(here), jinja2.FileSystemLoader(templates_dir)]), + loader=jinja2.ChoiceLoader( + [jinja2.FileSystemLoader(here), jinja2.FileSystemLoader(templates_dir)] + ), trim_blocks=True, - lstrip_blocks=True + lstrip_blocks=True, ) template = env.get_template("datetime_property_template.py.jinja") diff --git a/tests/test_utils.py b/tests/test_utils.py index fafa61805..01d26da86 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,7 +5,9 @@ class TestPythonIdentifier: def test_valid_identifier_is_not_changed(self): - assert utils.PythonIdentifier(value="valid_field", prefix="field") == "valid_field" + assert ( + utils.PythonIdentifier(value="valid_field", prefix="field") == "valid_field" + ) def test_numbers_are_prefixed(self): assert utils.PythonIdentifier(value="1", prefix="field") == "field1" @@ -85,7 +87,10 @@ def test_kebab_case(): def test_sanitize(): - assert utils.sanitize("some.thing*~with lots_- of weird things}=") == "some.thingwith lots_- of weird things" + assert ( + utils.sanitize("some.thing*~with lots_- of weird things}=") + == "some.thingwith lots_- of weird things" + ) def test_no_string_escapes(): @@ -129,7 +134,9 @@ def test_pascalcase(before, after): pytest.param("application/json", "application/json"), pytest.param("application/vnd.api+json", "application/vnd.api+json"), pytest.param("application/json;charset=utf-8", "application/json"), - pytest.param("application/vnd.api+json;charset=utf-8", "application/vnd.api+json"), + pytest.param( + "application/vnd.api+json;charset=utf-8", "application/vnd.api+json" + ), ], ) def test_get_content_type(content_type: str, expected: str, config) -> None: