|
| 1 | +# Copyright 2022 Webull |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +import json |
| 15 | +import unittest |
| 16 | + |
| 17 | +from webullsdkcore.client import ApiClient |
| 18 | +from webullsdkcore.exception.exceptions import ServerException |
| 19 | +from webullsdktrade.request.v2.cancel_order_request import CancelOrderRequest |
| 20 | + |
| 21 | +optional_api_endpoint = "<api_endpoint>" |
| 22 | +your_app_key = "<your_app_key>" |
| 23 | +your_app_secret = "<your_app_secret>" |
| 24 | +account_id = "<your_account_id>" |
| 25 | +#'jp' |
| 26 | +region_id = "<region_id>" |
| 27 | +api_client = ApiClient(your_app_key, your_app_secret, region_id) |
| 28 | +api_client.add_endpoint(region_id, optional_api_endpoint) |
| 29 | +client_order_id = "88a0b06eb35b448b8aacd9f2ae4d2deb" |
| 30 | + |
| 31 | + |
| 32 | +class TestOrderOperation(unittest.TestCase): |
| 33 | + def test_cancel_order(self): |
| 34 | + request = CancelOrderRequest() |
| 35 | + request.set_endpoint(optional_api_endpoint) |
| 36 | + request.set_account_id(account_id) |
| 37 | + request.set_client_order_id(client_order_id) |
| 38 | + post_body = request.get_body_params() |
| 39 | + print(json.dumps(post_body, indent=4)) |
| 40 | + params = request.get_query_params() |
| 41 | + print(params) |
| 42 | + try: |
| 43 | + response = api_client.get_response(request) |
| 44 | + print(json.dumps(response.json(), indent=4)) |
| 45 | + |
| 46 | + except ServerException as se: |
| 47 | + print(se.get_error_code(), ":", se.get_error_msg()) |
0 commit comments