diff --git a/webull-python-sdk-core/webullsdkcore/__init__.py b/webull-python-sdk-core/webullsdkcore/__init__.py index f3a645c..7b31556 100644 --- a/webull-python-sdk-core/webullsdkcore/__init__.py +++ b/webull-python-sdk-core/webullsdkcore/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.1.10" +__version__ = "0.1.11" import logging diff --git a/webull-python-sdk-demos/setup.py b/webull-python-sdk-demos/setup.py index a5995d1..078d626 100644 --- a/webull-python-sdk-demos/setup.py +++ b/webull-python-sdk-demos/setup.py @@ -15,8 +15,8 @@ LONG_DESCRIPTION = fp.read() requires = [ - "webull-python-sdk-mdata==0.1.10", - "webull-python-sdk-trade==0.1.10" + "webull-python-sdk-mdata==0.1.11", + "webull-python-sdk-trade==0.1.11" ] setup_args = { diff --git a/webull-python-sdk-demos/tests/trade/request/test_cancel_option.py b/webull-python-sdk-demos/tests/trade/request/test_cancel_option.py new file mode 100644 index 0000000..a72480a --- /dev/null +++ b/webull-python-sdk-demos/tests/trade/request/test_cancel_option.py @@ -0,0 +1,47 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import unittest + +from webullsdkcore.client import ApiClient +from webullsdkcore.exception.exceptions import ServerException +from webullsdktrade.request.v2.cancel_option_request import CancelOptionRequest + +optional_api_endpoint = "" +optional_api_region_id = "" +your_app_key = "" +your_app_secret = "" +account_id = "" +api_client = ApiClient(your_app_key, your_app_secret) +api_client.add_endpoint(optional_api_region_id, optional_api_endpoint) + +client_order_id = "e1890d630d5542b48fe50d82e0d7b13f" + +class TestOptionOperation(unittest.TestCase): + def test_preview_order(self): + request = CancelOptionRequest() + request.set_endpoint(optional_api_endpoint) + request.set_account_id(account_id) + request.set_client_order_id(client_order_id) + post_body = request.get_body_params() + print(json.dumps(post_body, indent=4)) + params = request.get_query_params() + print(params) + + try: + response = api_client.get_response(request) + print(response.json()) + + except ServerException as se: + print(se.get_error_code(), ":", se.get_error_msg()) diff --git a/webull-python-sdk-demos/tests/trade/request/test_place_option.py b/webull-python-sdk-demos/tests/trade/request/test_place_option.py new file mode 100644 index 0000000..98cdb88 --- /dev/null +++ b/webull-python-sdk-demos/tests/trade/request/test_place_option.py @@ -0,0 +1,74 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import unittest +import uuid + +from webullsdkcore.client import ApiClient +from webullsdkcore.exception.exceptions import ServerException +from webullsdktrade.request.v2.place_option_request import PlaceOptionRequest + +optional_api_endpoint = "" +optional_api_region_id = "" +your_app_key = "" +your_app_secret = "" +account_id = "" +api_client = ApiClient(your_app_key, your_app_secret) +api_client.add_endpoint(optional_api_region_id, optional_api_endpoint) + +client_order_id = uuid.uuid4().hex +new_orders = [ + { + "client_order_id": client_order_id, + "combo_type": "NORMAL", + "order_type": "LIMIT", + "quantity": "1", + "limit_price": "11.25", + "option_strategy": "SINGLE", + "side": "BUY", + "time_in_force": "GTC", + "entrust_type": "QTY", + "orders": [ + { + "side": "BUY", + "quantity": "1", + "symbol": "AAPL", + "strike_price": "250.0", + "init_exp_date": "2025-08-15", + "instrument_type": "OPTION", + "option_type": "CALL", + "market": "US" + } + ] + } + ] + + +class TestOptionOperation(unittest.TestCase): + def test_preview_order(self): + request = PlaceOptionRequest() + request.set_endpoint(optional_api_endpoint) + request.set_account_id(account_id) + request.set_new_orders(new_orders) + post_body = request.get_body_params() + print(json.dumps(post_body, indent=4)) + params = request.get_query_params() + print(params) + + try: + response = api_client.get_response(request) + print(response.json()) + + except ServerException as se: + print(se.get_error_code(), ":", se.get_error_msg()) diff --git a/webull-python-sdk-demos/tests/trade/request/test_preview_option.py b/webull-python-sdk-demos/tests/trade/request/test_preview_option.py new file mode 100644 index 0000000..cd8c76c --- /dev/null +++ b/webull-python-sdk-demos/tests/trade/request/test_preview_option.py @@ -0,0 +1,75 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import unittest +import uuid + +from webullsdkcore.client import ApiClient +from webullsdkcore.exception.exceptions import ServerException +from webullsdktrade.request.v2.preview_option_request import PreviewOptionRequest + + +optional_api_endpoint = "" +optional_api_region_id = "" +your_app_key = "" +your_app_secret = "" +account_id = "" +api_client = ApiClient(your_app_key, your_app_secret) +api_client.add_endpoint(optional_api_region_id, optional_api_endpoint) + +client_order_id = uuid.uuid4().hex +new_orders = [ + { + "client_order_id": client_order_id, + "combo_type": "NORMAL", + "order_type": "LIMIT", + "quantity": "1", + "limit_price": "11.25", + "option_strategy": "SINGLE", + "side": "BUY", + "time_in_force": "DAY", + "entrust_type": "QTY", + "orders": [ + { + "side": "BUY", + "quantity": "1", + "symbol": "AAPL", + "strike_price": "250.0", + "init_exp_date": "2025-08-15", + "instrument_type": "OPTION", + "option_type": "CALL", + "market": "US" + } + ] + } + ] + + +class TestOptionOperation(unittest.TestCase): + def test_preview_order(self): + request = PreviewOptionRequest() + request.set_endpoint(optional_api_endpoint) + request.set_account_id(account_id) + request.set_new_orders(new_orders) + post_body = request.get_body_params() + print(json.dumps(post_body, indent=4)) + params = request.get_query_params() + print(params) + + try: + response = api_client.get_response(request) + print(response.json()) + + except ServerException as se: + print(se.get_error_code(), ":", se.get_error_msg()) diff --git a/webull-python-sdk-demos/tests/trade/request/test_replace_option.py b/webull-python-sdk-demos/tests/trade/request/test_replace_option.py new file mode 100644 index 0000000..e3dbef9 --- /dev/null +++ b/webull-python-sdk-demos/tests/trade/request/test_replace_option.py @@ -0,0 +1,62 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import unittest + +from webullsdkcore.client import ApiClient +from webullsdkcore.exception.exceptions import ServerException +from webullsdktrade.request.v2.replace_option_request import ReplaceOptionRequest + + +optional_api_endpoint = "" +optional_api_region_id = "" +your_app_key = "" +your_app_secret = "" +account_id = "" +api_client = ApiClient(your_app_key, your_app_secret) +api_client.add_endpoint(optional_api_region_id, optional_api_endpoint) + +client_order_id = "e1890d630d5542b48fe50d82e0d7b13f" +modify_orders = [ + { + "client_order_id": client_order_id, + "quantity": "2", + "limit_price": "11.3", + "orders": [ + { + "client_order_id": client_order_id, + "quantity": "2" + } + ] + } + ] + + +class TestOptionOperation(unittest.TestCase): + def test_preview_order(self): + request = ReplaceOptionRequest() + request.set_endpoint(optional_api_endpoint) + request.set_account_id(account_id) + request.set_modify_orders(modify_orders) + post_body = request.get_body_params() + print(json.dumps(post_body, indent=4)) + params = request.get_query_params() + print(params) + + try: + response = api_client.get_response(request) + print(response.json()) + + except ServerException as se: + print(se.get_error_code(), ":", se.get_error_msg()) diff --git a/webull-python-sdk-demos/tests/trade/request/v2/test_order_detail.py b/webull-python-sdk-demos/tests/trade/request/v2/test_order_detail.py new file mode 100644 index 0000000..0a3f6aa --- /dev/null +++ b/webull-python-sdk-demos/tests/trade/request/v2/test_order_detail.py @@ -0,0 +1,46 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import unittest + +from webullsdkcore.client import ApiClient +from webullsdkcore.exception.exceptions import ServerException +from webullsdktrade.request.v2.get_order_detail_request import OrderDetailRequest + + +optional_api_endpoint = "" +optional_api_region_id = "" +your_app_key = "" +your_app_secret = "" +account_id = "" +api_client = ApiClient(your_app_key, your_app_secret) +api_client.add_endpoint(optional_api_region_id, optional_api_endpoint) + +# Replace with the client_order_id to be queried. +client_order_id = "" + +class TestOrderOperation(unittest.TestCase): + def test_order_open(self): + request = OrderDetailRequest() + request.set_endpoint(optional_api_endpoint) + request.set_account_id(account_id) + request.set_client_order_id(client_order_id) + params = request.get_query_params() + print(params) + try: + response = api_client.get_response(request) + print(json.dumps(response.json(), indent=4)) + + except ServerException as se: + print(se.get_error_code(), ":", se.get_error_msg()) diff --git a/webull-python-sdk-demos/tests/trade/test_api.py b/webull-python-sdk-demos/tests/trade/test_api.py index 4a92000..df971ab 100644 --- a/webull-python-sdk-demos/tests/trade/test_api.py +++ b/webull-python-sdk-demos/tests/trade/test_api.py @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import unittest import uuid +from time import sleep from webullsdkcore.client import ApiClient from webullsdkmdata.common.category import Category @@ -219,3 +221,71 @@ def test_api(self): res = api.order.cancel_order(account_id, client_order_id) if res.status_code == 200: print('cancel order status:', res.json()) + + + + # Options + # For option order inquiries, please use the V2 query interface: api.order_v2.get_order_detail(account_id, client_order_id). + client_order_id = uuid.uuid4().hex + option_new_orders = [ + { + "client_order_id": client_order_id, + "combo_type": "NORMAL", + "order_type": "LIMIT", + "quantity": "1", + "limit_price": "11.25", + "option_strategy": "SINGLE", + "side": "BUY", + "time_in_force": "GTC", + "entrust_type": "QTY", + "orders": [ + { + "side": "BUY", + "quantity": "1", + "symbol": "AAPL", + "strike_price": "250.0", + "init_exp_date": "2025-08-15", + "instrument_type": "OPTION", + "option_type": "CALL", + "market": "US" + } + ] + } + ] + + option_modify_orders = [ + { + "client_order_id": client_order_id, + "quantity": "2", + "limit_price": "11.3", + "orders": [ + { + "client_order_id": client_order_id, + "quantity": "2" + } + ] + } + ] + + # preview + res = api.order.preview_option(account_id, option_new_orders) + if res.status_code == 200: + print("preview option=" + json.dumps(res.json(), indent=4)) + sleep(5) + + # place + res = api.order.place_option(account_id, option_new_orders) + if res.status_code == 200: + print("place option=" + json.dumps(res.json(), indent=4)) + sleep(5) + + # replace + res = api.order.replace_option(account_id, option_modify_orders) + if res.status_code == 200: + print("replace option=" + json.dumps(res.json(), indent=4)) + sleep(5) + + # cancel + res = api.order.cancel_option(account_id, client_order_id) + if res.status_code == 200: + print("cancel option=" + json.dumps(res.json(), indent=4)) diff --git a/webull-python-sdk-demos/tests/trade/test_api_v2.py b/webull-python-sdk-demos/tests/trade/test_api_v2.py index f2e587f..de8930f 100644 --- a/webull-python-sdk-demos/tests/trade/test_api_v2.py +++ b/webull-python-sdk-demos/tests/trade/test_api_v2.py @@ -96,3 +96,8 @@ def test_api(self): res = api.order_v2.get_order_history_request(account_id=account_id) if res.status_code == 200: print("order_history_res=" + json.dumps(res.json(), indent=4)) + + # order detail + res = api.order_v2.get_order_detail(account_id=account_id, client_order_id=client_order_id) + if res.status_code == 200: + print("order_detail_res=" + json.dumps(res.json(), indent=4)) \ No newline at end of file diff --git a/webull-python-sdk-mdata/setup.py b/webull-python-sdk-mdata/setup.py index 92b203a..d0ef114 100644 --- a/webull-python-sdk-mdata/setup.py +++ b/webull-python-sdk-mdata/setup.py @@ -15,8 +15,8 @@ LONG_DESCRIPTION = fp.read() requires = [ - "webull-python-sdk-core==0.1.10", - "webull-python-sdk-quotes-core==0.1.10" + "webull-python-sdk-core==0.1.11", + "webull-python-sdk-quotes-core==0.1.11" ] setup_args = { diff --git a/webull-python-sdk-mdata/webullsdkmdata/__init__.py b/webull-python-sdk-mdata/webullsdkmdata/__init__.py index 8805f1f..68f2508 100644 --- a/webull-python-sdk-mdata/webullsdkmdata/__init__.py +++ b/webull-python-sdk-mdata/webullsdkmdata/__init__.py @@ -1,3 +1,3 @@ # coding=utf-8 -__version__ = '0.1.10' \ No newline at end of file +__version__ = '0.1.11' \ No newline at end of file diff --git a/webull-python-sdk-quotes-core/setup.py b/webull-python-sdk-quotes-core/setup.py index 18439d7..ffb2a49 100644 --- a/webull-python-sdk-quotes-core/setup.py +++ b/webull-python-sdk-quotes-core/setup.py @@ -24,7 +24,7 @@ "grpcio==1.51.1", "grpcio-tools==1.51.1", "protobuf==4.21.12", - "webull-python-sdk-core==0.1.10" + "webull-python-sdk-core==0.1.11" ] setup_args = { diff --git a/webull-python-sdk-quotes-core/webullsdkquotescore/__init__.py b/webull-python-sdk-quotes-core/webullsdkquotescore/__init__.py index 569b121..0c5c300 100644 --- a/webull-python-sdk-quotes-core/webullsdkquotescore/__init__.py +++ b/webull-python-sdk-quotes-core/webullsdkquotescore/__init__.py @@ -1 +1 @@ -__version__ = "0.1.10" +__version__ = "0.1.11" diff --git a/webull-python-sdk-trade-events-core/setup.py b/webull-python-sdk-trade-events-core/setup.py index 09a68a7..06bb966 100644 --- a/webull-python-sdk-trade-events-core/setup.py +++ b/webull-python-sdk-trade-events-core/setup.py @@ -23,7 +23,7 @@ "grpcio==1.51.1", "grpcio-tools==1.51.1", "protobuf==4.21.12", - "webull-python-sdk-core==0.1.10" + "webull-python-sdk-core==0.1.11" ] setup_args = { diff --git a/webull-python-sdk-trade-events-core/webullsdktradeeventscore/__init__.py b/webull-python-sdk-trade-events-core/webullsdktradeeventscore/__init__.py index 569b121..0c5c300 100644 --- a/webull-python-sdk-trade-events-core/webullsdktradeeventscore/__init__.py +++ b/webull-python-sdk-trade-events-core/webullsdktradeeventscore/__init__.py @@ -1 +1 @@ -__version__ = "0.1.10" +__version__ = "0.1.11" diff --git a/webull-python-sdk-trade/setup.py b/webull-python-sdk-trade/setup.py index 6ab9d2e..592a7d3 100644 --- a/webull-python-sdk-trade/setup.py +++ b/webull-python-sdk-trade/setup.py @@ -15,8 +15,8 @@ LONG_DESCRIPTION = fp.read() requires = [ - "webull-python-sdk-trade-events-core==0.1.10", - "webull-python-sdk-core==0.1.10" + "webull-python-sdk-trade-events-core==0.1.11", + "webull-python-sdk-core==0.1.11" ] setup_args = { diff --git a/webull-python-sdk-trade/webullsdktrade/__init__.py b/webull-python-sdk-trade/webullsdktrade/__init__.py index d09418f..aebb7d1 100644 --- a/webull-python-sdk-trade/webullsdktrade/__init__.py +++ b/webull-python-sdk-trade/webullsdktrade/__init__.py @@ -1,2 +1,2 @@ -__version__ = "0.1.10" +__version__ = "0.1.11" diff --git a/webull-python-sdk-trade/webullsdktrade/request/v2/cancel_option_request.py b/webull-python-sdk-trade/webullsdktrade/request/v2/cancel_option_request.py new file mode 100644 index 0000000..b8fc94c --- /dev/null +++ b/webull-python-sdk-trade/webullsdktrade/request/v2/cancel_option_request.py @@ -0,0 +1,28 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# coding=utf-8 + +from webullsdkcore.request import ApiRequest + + +class CancelOptionRequest(ApiRequest): + def __init__(self): + super().__init__("/openapi/account/orders/option/cancel", version='v1', method="POST", body_params={}) + + def set_client_order_id(self, client_order_id): + self.add_body_params("client_order_id", client_order_id) + + def set_account_id(self, account_id): + self.add_query_param("account_id", account_id) \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_detail_request.py b/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_detail_request.py new file mode 100644 index 0000000..424a868 --- /dev/null +++ b/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_detail_request.py @@ -0,0 +1,26 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from webullsdkcore.request import ApiRequest + + +class OrderDetailRequest(ApiRequest): + def __init__(self): + ApiRequest.__init__(self, "/openapi/account/orders/detail", version='v1', method="GET", body_params={}) + + def set_account_id(self, account_id): + self.add_query_param("account_id", account_id) + + def set_client_order_id(self, client_order_id): + self.add_query_param("client_order_id", client_order_id) \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_history_request.py b/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_history_request.py index 48670a2..9861437 100644 --- a/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_history_request.py +++ b/webull-python-sdk-trade/webullsdktrade/request/v2/get_order_history_request.py @@ -28,5 +28,8 @@ def set_page_size(self, page_size): def set_start_date(self, start_date): self.add_query_param("start_date", start_date) + def set_end_date(self, end_date): + self.add_query_param("end_date", end_date) + def set_last_client_order_id(self, last_client_order_id): self.add_query_param("last_client_order_id", last_client_order_id) \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/request/v2/place_option_request.py b/webull-python-sdk-trade/webullsdktrade/request/v2/place_option_request.py new file mode 100644 index 0000000..61fb9ea --- /dev/null +++ b/webull-python-sdk-trade/webullsdktrade/request/v2/place_option_request.py @@ -0,0 +1,28 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# coding=utf-8 + +from webullsdkcore.request import ApiRequest + + +class PlaceOptionRequest(ApiRequest): + def __init__(self): + super().__init__("/openapi/account/orders/option/place", version='v1', method="POST", body_params={}) + + def set_new_orders(self, new_orders): + self.add_body_params("new_orders", new_orders) + + def set_account_id(self, account_id): + self.add_query_param("account_id", account_id) \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/request/v2/preview_option_request.py b/webull-python-sdk-trade/webullsdktrade/request/v2/preview_option_request.py new file mode 100644 index 0000000..a1b6ee8 --- /dev/null +++ b/webull-python-sdk-trade/webullsdktrade/request/v2/preview_option_request.py @@ -0,0 +1,28 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# coding=utf-8 + +from webullsdkcore.request import ApiRequest + + +class PreviewOptionRequest(ApiRequest): + def __init__(self): + super().__init__("/openapi/account/orders/option/preview", version='v1', method="POST", body_params={}) + + def set_new_orders(self, new_orders): + self.add_body_params("new_orders", new_orders) + + def set_account_id(self, account_id): + self.add_query_param("account_id", account_id) \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/request/v2/replace_option_request.py b/webull-python-sdk-trade/webullsdktrade/request/v2/replace_option_request.py new file mode 100644 index 0000000..2027c7b --- /dev/null +++ b/webull-python-sdk-trade/webullsdktrade/request/v2/replace_option_request.py @@ -0,0 +1,28 @@ +# Copyright 2022 Webull +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# coding=utf-8 + +from webullsdkcore.request import ApiRequest + + +class ReplaceOptionRequest(ApiRequest): + def __init__(self): + super().__init__("/openapi/account/orders/option/replace", version='v1', method="POST", body_params={}) + + def set_modify_orders(self, modify_orders): + self.add_body_params("modify_orders", modify_orders) + + def set_account_id(self, account_id): + self.add_query_param("account_id", account_id) \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/trade/order_operation.py b/webull-python-sdk-trade/webullsdktrade/trade/order_operation.py index 4114b7f..778ece8 100644 --- a/webull-python-sdk-trade/webullsdktrade/trade/order_operation.py +++ b/webull-python-sdk-trade/webullsdktrade/trade/order_operation.py @@ -13,10 +13,6 @@ # limitations under the License. # coding=utf-8 -import uuid -from webullsdktrade.common.order_side import OrderSide -from webullsdktrade.common.order_tif import OrderTIF -from webullsdktrade.common.order_type import OrderType from webullsdktrade.request.cancel_order_request import CancelOrderRequest from webullsdktrade.request.get_open_orders_request import OpenOrdersListRequest from webullsdktrade.request.get_order_detail_request import OrderDetailRequest @@ -25,6 +21,10 @@ from webullsdktrade.request.place_order_request_v2 import PlaceOrderRequestV2 from webullsdktrade.request.replace_order_request import ReplaceOrderRequest from webullsdktrade.request.replace_order_request_v2 import ReplaceOrderRequestV2 +from webullsdktrade.request.v2.cancel_option_request import CancelOptionRequest +from webullsdktrade.request.v2.place_option_request import PlaceOptionRequest +from webullsdktrade.request.v2.preview_option_request import PreviewOptionRequest +from webullsdktrade.request.v2.replace_option_request import ReplaceOptionRequest class OrderOperation: @@ -171,3 +171,51 @@ def query_order_detail(self, account_id, client_order_id): order_detail_request.set_client_order_id(client_order_id) response = self.client.get_response(order_detail_request) return response + + def preview_option(self, account_id, new_orders): + """ + This interface is exclusively available for Webull Hong Kong brokerage clients. + Currently, it does not support Webull Japan or Webull U.S. clients, + but support will be gradually introduced in the future. + """ + preview_option_request = PreviewOptionRequest() + preview_option_request.set_new_orders(new_orders) + preview_option_request.set_account_id(account_id) + response = self.client.get_response(preview_option_request) + return response + + def place_option(self, account_id, new_orders): + """ + This interface is exclusively available for Webull Hong Kong brokerage clients. + Currently, it does not support Webull Japan or Webull U.S. clients, + but support will be gradually introduced in the future. + """ + place_option_request = PlaceOptionRequest() + place_option_request.set_new_orders(new_orders) + place_option_request.set_account_id(account_id) + response = self.client.get_response(place_option_request) + return response + + def replace_option(self, account_id, modify_orders): + """ + This interface is exclusively available for Webull Hong Kong brokerage clients. + Currently, it does not support Webull Japan or Webull U.S. clients, + but support will be gradually introduced in the future. + """ + replace_option_request = ReplaceOptionRequest() + replace_option_request.set_modify_orders(modify_orders) + replace_option_request.set_account_id(account_id) + response = self.client.get_response(replace_option_request) + return response + + def cancel_option(self, account_id, client_order_id): + """ + This interface is exclusively available for Webull Hong Kong brokerage clients. + Currently, it does not support Webull Japan or Webull U.S. clients, + but support will be gradually introduced in the future. + """ + cancel_option_request = CancelOptionRequest() + cancel_option_request.set_client_order_id(client_order_id) + cancel_option_request.set_account_id(account_id) + response = self.client.get_response(cancel_option_request) + return response \ No newline at end of file diff --git a/webull-python-sdk-trade/webullsdktrade/trade/v2/order_operation_v2.py b/webull-python-sdk-trade/webullsdktrade/trade/v2/order_operation_v2.py index ef04da7..f8387b4 100644 --- a/webull-python-sdk-trade/webullsdktrade/trade/v2/order_operation_v2.py +++ b/webull-python-sdk-trade/webullsdktrade/trade/v2/order_operation_v2.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # coding=utf-8 - from webullsdktrade.request.v2.cancel_order_request import CancelOrderRequest +from webullsdktrade.request.v2.get_order_detail_request import OrderDetailRequest from webullsdktrade.request.v2.get_order_history_request import OrderHistoryRequest from webullsdktrade.request.v2.palce_order_request import PlaceOrderRequest from webullsdktrade.request.v2.preview_order_request import PreviewOrderRequest @@ -75,7 +75,19 @@ def cancel_order_v2(self, account_id, client_order_id): response = self.client.get_response(cancel_order_request) return response - def get_order_history_request(self, account_id, page_size=None, start_date=None, last_client_order_id=None): + def get_order_detail(self, account_id, client_order_id): + """ + This interface is exclusively available for Webull Hong Kong brokerage clients. + Currently, it does not support Webull Japan or Webull U.S. clients, + but support will be gradually introduced in the future. + """ + order_detail_request = OrderDetailRequest() + order_detail_request.set_account_id(account_id) + order_detail_request.set_client_order_id(client_order_id) + response = self.client.get_response(order_detail_request) + return response + + def get_order_history_request(self, account_id, page_size=None, start_date=None, end_date=None, last_client_order_id=None): """ This interface is exclusively available for Webull Japan brokerage clients. Currently, it does not support Webull Hong Kong or Webull U.S. clients, @@ -87,6 +99,8 @@ def get_order_history_request(self, account_id, page_size=None, start_date=None, order_history_request.set_page_size(page_size=page_size) if start_date: order_history_request.set_start_date(start_date=start_date) + if end_date: + order_history_request.set_end_date(end_date=end_date) if last_client_order_id: order_history_request.set_last_client_order_id(last_client_order_id=last_client_order_id) response = self.client.get_response(order_history_request)