|
| 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 | + |
| 15 | +import unittest |
| 16 | + |
| 17 | +from webullsdkcore.client import ApiClient |
| 18 | +from webullsdkcore.exception.exceptions import ServerException |
| 19 | +from webullsdktrade.api import API |
| 20 | +from webullsdktrade.common.markets import Markets |
| 21 | + |
| 22 | +optional_api_endpoint = "</optional_api_endpoint>" |
| 23 | +your_app_key = "</your_app_key>" |
| 24 | +your_app_secret = "</your_app_secret>" |
| 25 | + |
| 26 | +# 'hk' or 'us' |
| 27 | +region_id = "<region_id>" |
| 28 | +api_client = ApiClient(your_app_key, your_app_secret, region_id) |
| 29 | +api_client.add_endpoint(region_id, optional_api_endpoint) |
| 30 | + |
| 31 | + |
| 32 | +class TestTradeCalendar(unittest.TestCase): |
| 33 | + |
| 34 | + def test_trade_calendar(self): |
| 35 | + api = API(api_client) |
| 36 | + try: |
| 37 | + response = api.trade_calendar.get_trade_calendar(Markets.US.name, "2023-01-20", "2023-02-03") |
| 38 | + print(response.json()) |
| 39 | + except ServerException as se: |
| 40 | + print(se) |
| 41 | + |
| 42 | + try: |
| 43 | + response = api.trade_calendar.get_trade_calendar(Markets.HK.name, "2023-01-20", "2023-02-03") |
| 44 | + print(response.json()) |
| 45 | + except ServerException as se: |
| 46 | + print(se) |
0 commit comments