webull-openapi-python-sdk 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- samples/__init__.py +1 -0
- samples/data/__init__.py +1 -0
- samples/data/data_client.py +57 -0
- samples/data/data_streaming_client.py +86 -0
- samples/data/data_streaming_client_async.py +101 -0
- samples/trade/__init__.py +0 -0
- samples/trade/trade_client.py +163 -0
- samples/trade/trade_client_v2.py +181 -0
- samples/trade/trade_event_client.py +47 -0
- webull/__init__.py +1 -0
- webull/core/__init__.py +12 -0
- webull/core/auth/__init__.py +0 -0
- webull/core/auth/algorithm/__init__.py +0 -0
- webull/core/auth/algorithm/sha_hmac1.py +65 -0
- webull/core/auth/algorithm/sha_hmac256.py +75 -0
- webull/core/auth/composer/__init__.py +0 -0
- webull/core/auth/composer/default_signature_composer.py +125 -0
- webull/core/auth/credentials.py +46 -0
- webull/core/auth/signers/__init__.py +0 -0
- webull/core/auth/signers/app_key_signer.py +72 -0
- webull/core/auth/signers/signer.py +48 -0
- webull/core/auth/signers/signer_factory.py +58 -0
- webull/core/cache/__init__.py +225 -0
- webull/core/client.py +410 -0
- webull/core/common/__init__.py +0 -0
- webull/core/common/api_type.py +19 -0
- webull/core/common/easy_enum.py +35 -0
- webull/core/common/region.py +7 -0
- webull/core/compat.py +85 -0
- webull/core/context/__init__.py +0 -0
- webull/core/context/request_context_holder.py +33 -0
- webull/core/data/endpoints.json +22 -0
- webull/core/data/retry_config.json +15 -0
- webull/core/endpoint/__init__.py +8 -0
- webull/core/endpoint/chained_endpoint_resolver.py +57 -0
- webull/core/endpoint/default_endpoint_resolver.py +60 -0
- webull/core/endpoint/local_config_regional_endpoint_resolver.py +77 -0
- webull/core/endpoint/resolver_endpoint_request.py +46 -0
- webull/core/endpoint/user_customized_endpoint_resolver.py +55 -0
- webull/core/exception/__init__.py +0 -0
- webull/core/exception/error_code.py +23 -0
- webull/core/exception/error_msg.py +21 -0
- webull/core/exception/exceptions.py +53 -0
- webull/core/headers.py +57 -0
- webull/core/http/__init__.py +0 -0
- webull/core/http/initializer/__init__.py +0 -0
- webull/core/http/initializer/client_initializer.py +79 -0
- webull/core/http/initializer/token/__init__.py +0 -0
- webull/core/http/initializer/token/bean/__init__.py +0 -0
- webull/core/http/initializer/token/bean/access_token.py +40 -0
- webull/core/http/initializer/token/bean/check_token_request.py +44 -0
- webull/core/http/initializer/token/bean/create_token_request.py +45 -0
- webull/core/http/initializer/token/bean/refresh_token_request.py +44 -0
- webull/core/http/initializer/token/token_manager.py +208 -0
- webull/core/http/initializer/token/token_operation.py +72 -0
- webull/core/http/method_type.py +43 -0
- webull/core/http/protocol_type.py +43 -0
- webull/core/http/request.py +121 -0
- webull/core/http/response.py +166 -0
- webull/core/request.py +278 -0
- webull/core/retry/__init__.py +0 -0
- webull/core/retry/backoff_strategy.py +102 -0
- webull/core/retry/retry_condition.py +214 -0
- webull/core/retry/retry_policy.py +63 -0
- webull/core/retry/retry_policy_context.py +51 -0
- webull/core/utils/__init__.py +0 -0
- webull/core/utils/common.py +62 -0
- webull/core/utils/data.py +25 -0
- webull/core/utils/desensitize.py +33 -0
- webull/core/utils/validation.py +49 -0
- webull/core/vendored/__init__.py +0 -0
- webull/core/vendored/requests/__init__.py +94 -0
- webull/core/vendored/requests/__version__.py +28 -0
- webull/core/vendored/requests/_internal_utils.py +56 -0
- webull/core/vendored/requests/adapters.py +539 -0
- webull/core/vendored/requests/api.py +166 -0
- webull/core/vendored/requests/auth.py +307 -0
- webull/core/vendored/requests/certs.py +34 -0
- webull/core/vendored/requests/compat.py +85 -0
- webull/core/vendored/requests/cookies.py +555 -0
- webull/core/vendored/requests/exceptions.py +136 -0
- webull/core/vendored/requests/help.py +134 -0
- webull/core/vendored/requests/hooks.py +48 -0
- webull/core/vendored/requests/models.py +960 -0
- webull/core/vendored/requests/packages/__init__.py +17 -0
- webull/core/vendored/requests/packages/certifi/__init__.py +17 -0
- webull/core/vendored/requests/packages/certifi/__main__.py +16 -0
- webull/core/vendored/requests/packages/certifi/cacert.pem +4433 -0
- webull/core/vendored/requests/packages/certifi/core.py +51 -0
- webull/core/vendored/requests/packages/chardet/__init__.py +53 -0
- webull/core/vendored/requests/packages/chardet/big5freq.py +400 -0
- webull/core/vendored/requests/packages/chardet/big5prober.py +61 -0
- webull/core/vendored/requests/packages/chardet/chardistribution.py +247 -0
- webull/core/vendored/requests/packages/chardet/charsetgroupprober.py +120 -0
- webull/core/vendored/requests/packages/chardet/charsetprober.py +159 -0
- webull/core/vendored/requests/packages/chardet/cli/__init__.py +1 -0
- webull/core/vendored/requests/packages/chardet/cli/chardetect.py +99 -0
- webull/core/vendored/requests/packages/chardet/codingstatemachine.py +102 -0
- webull/core/vendored/requests/packages/chardet/compat.py +48 -0
- webull/core/vendored/requests/packages/chardet/cp949prober.py +63 -0
- webull/core/vendored/requests/packages/chardet/enums.py +90 -0
- webull/core/vendored/requests/packages/chardet/escprober.py +115 -0
- webull/core/vendored/requests/packages/chardet/escsm.py +260 -0
- webull/core/vendored/requests/packages/chardet/eucjpprober.py +106 -0
- webull/core/vendored/requests/packages/chardet/euckrfreq.py +209 -0
- webull/core/vendored/requests/packages/chardet/euckrprober.py +61 -0
- webull/core/vendored/requests/packages/chardet/euctwfreq.py +401 -0
- webull/core/vendored/requests/packages/chardet/euctwprober.py +60 -0
- webull/core/vendored/requests/packages/chardet/gb2312freq.py +297 -0
- webull/core/vendored/requests/packages/chardet/gb2312prober.py +60 -0
- webull/core/vendored/requests/packages/chardet/hebrewprober.py +306 -0
- webull/core/vendored/requests/packages/chardet/jisfreq.py +339 -0
- webull/core/vendored/requests/packages/chardet/jpcntx.py +247 -0
- webull/core/vendored/requests/packages/chardet/langbulgarianmodel.py +242 -0
- webull/core/vendored/requests/packages/chardet/langcyrillicmodel.py +347 -0
- webull/core/vendored/requests/packages/chardet/langgreekmodel.py +239 -0
- webull/core/vendored/requests/packages/chardet/langhebrewmodel.py +214 -0
- webull/core/vendored/requests/packages/chardet/langhungarianmodel.py +239 -0
- webull/core/vendored/requests/packages/chardet/langthaimodel.py +213 -0
- webull/core/vendored/requests/packages/chardet/langturkishmodel.py +207 -0
- webull/core/vendored/requests/packages/chardet/latin1prober.py +159 -0
- webull/core/vendored/requests/packages/chardet/mbcharsetprober.py +105 -0
- webull/core/vendored/requests/packages/chardet/mbcsgroupprober.py +68 -0
- webull/core/vendored/requests/packages/chardet/mbcssm.py +586 -0
- webull/core/vendored/requests/packages/chardet/sbcharsetprober.py +146 -0
- webull/core/vendored/requests/packages/chardet/sbcsgroupprober.py +87 -0
- webull/core/vendored/requests/packages/chardet/sjisprober.py +106 -0
- webull/core/vendored/requests/packages/chardet/universaldetector.py +300 -0
- webull/core/vendored/requests/packages/chardet/utf8prober.py +96 -0
- webull/core/vendored/requests/packages/chardet/version.py +23 -0
- webull/core/vendored/requests/packages/urllib3/__init__.py +114 -0
- webull/core/vendored/requests/packages/urllib3/_collections.py +346 -0
- webull/core/vendored/requests/packages/urllib3/connection.py +405 -0
- webull/core/vendored/requests/packages/urllib3/connectionpool.py +910 -0
- webull/core/vendored/requests/packages/urllib3/contrib/__init__.py +0 -0
- webull/core/vendored/requests/packages/urllib3/contrib/_appengine_environ.py +44 -0
- webull/core/vendored/requests/packages/urllib3/contrib/_securetransport/__init__.py +0 -0
- webull/core/vendored/requests/packages/urllib3/contrib/_securetransport/bindings.py +607 -0
- webull/core/vendored/requests/packages/urllib3/contrib/_securetransport/low_level.py +360 -0
- webull/core/vendored/requests/packages/urllib3/contrib/appengine.py +303 -0
- webull/core/vendored/requests/packages/urllib3/contrib/ntlmpool.py +125 -0
- webull/core/vendored/requests/packages/urllib3/contrib/pyopenssl.py +484 -0
- webull/core/vendored/requests/packages/urllib3/contrib/securetransport.py +818 -0
- webull/core/vendored/requests/packages/urllib3/contrib/socks.py +206 -0
- webull/core/vendored/requests/packages/urllib3/exceptions.py +260 -0
- webull/core/vendored/requests/packages/urllib3/fields.py +192 -0
- webull/core/vendored/requests/packages/urllib3/filepost.py +112 -0
- webull/core/vendored/requests/packages/urllib3/packages/__init__.py +19 -0
- webull/core/vendored/requests/packages/urllib3/packages/backports/__init__.py +0 -0
- webull/core/vendored/requests/packages/urllib3/packages/backports/makefile.py +67 -0
- webull/core/vendored/requests/packages/urllib3/packages/ordered_dict.py +273 -0
- webull/core/vendored/requests/packages/urllib3/packages/six.py +882 -0
- webull/core/vendored/requests/packages/urllib3/packages/socks.py +887 -0
- webull/core/vendored/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py +19 -0
- webull/core/vendored/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py +170 -0
- webull/core/vendored/requests/packages/urllib3/poolmanager.py +467 -0
- webull/core/vendored/requests/packages/urllib3/request.py +164 -0
- webull/core/vendored/requests/packages/urllib3/response.py +721 -0
- webull/core/vendored/requests/packages/urllib3/util/__init__.py +68 -0
- webull/core/vendored/requests/packages/urllib3/util/connection.py +148 -0
- webull/core/vendored/requests/packages/urllib3/util/queue.py +35 -0
- webull/core/vendored/requests/packages/urllib3/util/request.py +132 -0
- webull/core/vendored/requests/packages/urllib3/util/response.py +101 -0
- webull/core/vendored/requests/packages/urllib3/util/retry.py +426 -0
- webull/core/vendored/requests/packages/urllib3/util/selectors.py +601 -0
- webull/core/vendored/requests/packages/urllib3/util/ssl_.py +396 -0
- webull/core/vendored/requests/packages/urllib3/util/timeout.py +256 -0
- webull/core/vendored/requests/packages/urllib3/util/url.py +252 -0
- webull/core/vendored/requests/packages/urllib3/util/wait.py +164 -0
- webull/core/vendored/requests/packages.py +28 -0
- webull/core/vendored/requests/sessions.py +750 -0
- webull/core/vendored/requests/status_codes.py +105 -0
- webull/core/vendored/requests/structures.py +119 -0
- webull/core/vendored/requests/utils.py +916 -0
- webull/core/vendored/six.py +905 -0
- webull/data/__init__.py +3 -0
- webull/data/common/__init__.py +0 -0
- webull/data/common/category.py +26 -0
- webull/data/common/connect_ack.py +29 -0
- webull/data/common/direction.py +25 -0
- webull/data/common/exchange_code.py +33 -0
- webull/data/common/exercise_style.py +22 -0
- webull/data/common/expiration_cycle.py +26 -0
- webull/data/common/instrument_status.py +23 -0
- webull/data/common/option_type.py +20 -0
- webull/data/common/subscribe_type.py +22 -0
- webull/data/common/timespan.py +29 -0
- webull/data/data_client.py +35 -0
- webull/data/data_streaming_client.py +89 -0
- webull/data/internal/__init__.py +0 -0
- webull/data/internal/default_retry_policy.py +84 -0
- webull/data/internal/exceptions.py +60 -0
- webull/data/internal/quotes_client.py +314 -0
- webull/data/internal/quotes_decoder.py +40 -0
- webull/data/internal/quotes_payload_decoder.py +35 -0
- webull/data/internal/quotes_topic.py +36 -0
- webull/data/quotes/__init__.py +0 -0
- webull/data/quotes/instrument.py +33 -0
- webull/data/quotes/market_data.py +187 -0
- webull/data/quotes/market_streaming_data.py +66 -0
- webull/data/quotes/subscribe/__init__.py +0 -0
- webull/data/quotes/subscribe/ask_bid_result.py +49 -0
- webull/data/quotes/subscribe/basic_result.py +45 -0
- webull/data/quotes/subscribe/broker_result.py +33 -0
- webull/data/quotes/subscribe/message_pb2.py +37 -0
- webull/data/quotes/subscribe/order_result.py +30 -0
- webull/data/quotes/subscribe/payload_type.py +19 -0
- webull/data/quotes/subscribe/quote_decoder.py +28 -0
- webull/data/quotes/subscribe/quote_result.py +47 -0
- webull/data/quotes/subscribe/snapshot_decoder.py +30 -0
- webull/data/quotes/subscribe/snapshot_result.py +69 -0
- webull/data/quotes/subscribe/tick_decoder.py +29 -0
- webull/data/quotes/subscribe/tick_result.py +47 -0
- webull/data/request/__init__.py +0 -0
- webull/data/request/get_batch_historical_bars_request.py +43 -0
- webull/data/request/get_corp_action_request.py +47 -0
- webull/data/request/get_eod_bars_request.py +32 -0
- webull/data/request/get_historical_bars_request.py +43 -0
- webull/data/request/get_instruments_request.py +30 -0
- webull/data/request/get_quotes_request.py +35 -0
- webull/data/request/get_snapshot_request.py +38 -0
- webull/data/request/get_tick_request.py +37 -0
- webull/data/request/subscribe_request.py +43 -0
- webull/data/request/unsubscribe_request.py +42 -0
- webull/trade/__init__.py +2 -0
- webull/trade/common/__init__.py +0 -0
- webull/trade/common/account_type.py +22 -0
- webull/trade/common/category.py +29 -0
- webull/trade/common/combo_ticker_type.py +23 -0
- webull/trade/common/combo_type.py +31 -0
- webull/trade/common/currency.py +24 -0
- webull/trade/common/forbid_reason.py +27 -0
- webull/trade/common/instrument_type.py +27 -0
- webull/trade/common/markets.py +27 -0
- webull/trade/common/order_entrust_type.py +21 -0
- webull/trade/common/order_side.py +23 -0
- webull/trade/common/order_status.py +25 -0
- webull/trade/common/order_tif.py +24 -0
- webull/trade/common/order_type.py +30 -0
- webull/trade/common/trade_policy.py +22 -0
- webull/trade/common/trading_date_type.py +24 -0
- webull/trade/common/trailing_type.py +23 -0
- webull/trade/events/__init__.py +0 -0
- webull/trade/events/default_retry_policy.py +64 -0
- webull/trade/events/events_pb2.py +43 -0
- webull/trade/events/events_pb2_grpc.py +66 -0
- webull/trade/events/signature_composer.py +61 -0
- webull/trade/events/types.py +21 -0
- webull/trade/request/__init__.py +0 -0
- webull/trade/request/cancel_order_request.py +28 -0
- webull/trade/request/get_account_balance_request.py +28 -0
- webull/trade/request/get_account_positions_request.py +30 -0
- webull/trade/request/get_account_profile_request.py +26 -0
- webull/trade/request/get_app_subscriptions.py +28 -0
- webull/trade/request/get_open_orders_request.py +30 -0
- webull/trade/request/get_order_detail_request.py +27 -0
- webull/trade/request/get_today_orders_request.py +31 -0
- webull/trade/request/get_trade_calendar_request.py +30 -0
- webull/trade/request/get_trade_instrument_detail_request.py +24 -0
- webull/trade/request/get_trade_security_detail_request.py +42 -0
- webull/trade/request/get_tradeable_instruments_request.py +27 -0
- webull/trade/request/palce_order_request.py +91 -0
- webull/trade/request/place_order_request_v2.py +58 -0
- webull/trade/request/replace_order_request.py +73 -0
- webull/trade/request/replace_order_request_v2.py +38 -0
- webull/trade/request/v2/__init__.py +0 -0
- webull/trade/request/v2/cancel_option_request.py +28 -0
- webull/trade/request/v2/cancel_order_request.py +28 -0
- webull/trade/request/v2/get_account_balance_request.py +28 -0
- webull/trade/request/v2/get_account_list.py +23 -0
- webull/trade/request/v2/get_account_positions_request.py +24 -0
- webull/trade/request/v2/get_order_detail_request.py +26 -0
- webull/trade/request/v2/get_order_history_request.py +35 -0
- webull/trade/request/v2/palce_order_request.py +87 -0
- webull/trade/request/v2/place_option_request.py +64 -0
- webull/trade/request/v2/preview_option_request.py +28 -0
- webull/trade/request/v2/preview_order_request.py +59 -0
- webull/trade/request/v2/replace_option_request.py +28 -0
- webull/trade/request/v2/replace_order_request.py +57 -0
- webull/trade/trade/__init__.py +0 -0
- webull/trade/trade/account_info.py +83 -0
- webull/trade/trade/order_operation.py +246 -0
- webull/trade/trade/trade_calendar.py +37 -0
- webull/trade/trade/trade_instrument.py +72 -0
- webull/trade/trade/v2/__init__.py +0 -0
- webull/trade/trade/v2/account_info_v2.py +55 -0
- webull/trade/trade/v2/order_operation_v2.py +206 -0
- webull/trade/trade_client.py +43 -0
- webull/trade/trade_events_client.py +233 -0
- webull_openapi_python_sdk-1.0.0.dist-info/METADATA +28 -0
- webull_openapi_python_sdk-1.0.0.dist-info/RECORD +295 -0
- webull_openapi_python_sdk-1.0.0.dist-info/WHEEL +5 -0
- webull_openapi_python_sdk-1.0.0.dist-info/licenses/LICENSE +202 -0
- webull_openapi_python_sdk-1.0.0.dist-info/licenses/NOTICE +56 -0
- webull_openapi_python_sdk-1.0.0.dist-info/top_level.txt +2 -0
webull/data/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
class Category(EasyEnum):
|
|
20
|
+
US_STOCK = (1, 'US STOCK')
|
|
21
|
+
US_OPTION = (2, 'US OPTION')
|
|
22
|
+
HK_STOCK = (3, 'HK STOCK')
|
|
23
|
+
CRYPTO = (4, 'CRYPTO')
|
|
24
|
+
US_ETF = (5, 'US ETF')
|
|
25
|
+
HK_ETF = (6, 'HK ETF')
|
|
26
|
+
CN_STOCK = (7, "CN STOCK")
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
class ConnectAck(EasyEnum):
|
|
20
|
+
CONNECTION_SUCCESS = (0, 'Connection successful')
|
|
21
|
+
PROTOCOL_NOT_SUPPORTED = (1, 'Protocol not supported')
|
|
22
|
+
SESSION_ID_IS_BLANK = (2, 'session_id is blank')
|
|
23
|
+
AK_IS_BLANK = (3, 'AppKey is blank')
|
|
24
|
+
UNKNOWN_ERROR = (100, 'Unknown error')
|
|
25
|
+
INTERNAL_ERROR = (101, 'Internal error')
|
|
26
|
+
CONNECTION_AUTHENTICATED = (102, 'Connection already authenticated')
|
|
27
|
+
CONNECTION_AUTH_FAILED = (103, "Connection authentication failed")
|
|
28
|
+
AK_INVALID = (104, "Invalid AppKey")
|
|
29
|
+
CONNECTION_LIMIT_EXCEEDED = (105, "Connection limit exceeded")
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Direction(EasyEnum):
|
|
21
|
+
B = (1, 'Buy(stocks are traded at the first set bid price)')
|
|
22
|
+
S = (2, 'Sell(stocks are traded at the first set ask price)')
|
|
23
|
+
G = (3, 'Buy(stocks are traded at a higher price than the first set bid price)')
|
|
24
|
+
L = (4, 'Sell(stocks are traded at a lower price than the first set ask price)')
|
|
25
|
+
N = (5, 'Neutral')
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ExchangeCode(EasyEnum):
|
|
21
|
+
HKG = (1, 'Hong Kong Stock Exchange')
|
|
22
|
+
NAS = (2, 'NASDAQ Capital Market')
|
|
23
|
+
NYSE = (3, 'New York Stock Exchange')
|
|
24
|
+
ASE = (4, 'NYSE MKT')
|
|
25
|
+
PSE = (5, 'NYSE Archipelago Exchange')
|
|
26
|
+
BAT = (6, 'BATS Exchanges')
|
|
27
|
+
NMS = (7, "NASDAQ Global Market")
|
|
28
|
+
NSQ = (8, "NASDAQ Global Select Market")
|
|
29
|
+
OTC = (9, "Over The Counter Bulletin Board")
|
|
30
|
+
PK = (10, "Pink Sheets")
|
|
31
|
+
OPRA = (11, "Option Pricing Reporting Authority")
|
|
32
|
+
CCC = (12, "Cryptocurrency")
|
|
33
|
+
HKW = (13, "Hong Kong Warrant Exchange")
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ExerciseStyle(EasyEnum):
|
|
21
|
+
AMERICAN = (1, 'American Options')
|
|
22
|
+
EUROPEAN = (2, 'European Options')
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ExpirationCycle(EasyEnum):
|
|
21
|
+
DAILY = (1, 'day')
|
|
22
|
+
WEEKLY = (2, 'week')
|
|
23
|
+
MONTHLY = (3, 'month')
|
|
24
|
+
QUATERLY = (4, 'season')
|
|
25
|
+
END_OF_MONTH = (5, 'end of month')
|
|
26
|
+
YEARLY = (6, 'year')
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class InstrumentStatus(EasyEnum):
|
|
21
|
+
ACTIVE = (1, 'trading status')
|
|
22
|
+
INACTIVE = (2, 'non-transactional status')
|
|
23
|
+
HALTED = (3, 'suspended status')
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
class OptionType(EasyEnum):
|
|
19
|
+
CALL = (1, "call")
|
|
20
|
+
PUT = (2, "put")
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SubscribeType(EasyEnum):
|
|
20
|
+
QUOTE = (0, "QUOTE")
|
|
21
|
+
SNAPSHOT = (1, "SNAPSHOT")
|
|
22
|
+
TICK = (2, "TICK")
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.common.easy_enum import EasyEnum
|
|
18
|
+
class Timespan(EasyEnum):
|
|
19
|
+
M1 = (1, "1 minute")
|
|
20
|
+
M5 = (2, "5 minute")
|
|
21
|
+
M15 = (3, "15 minute")
|
|
22
|
+
M30 = (4, "30 minute")
|
|
23
|
+
M60 = (5, "60 minute")
|
|
24
|
+
M120 = (6, "120 minute")
|
|
25
|
+
M240 = (7, "240 minute")
|
|
26
|
+
D = (8, "1 day")
|
|
27
|
+
W = (9, "1 week")
|
|
28
|
+
M = (10, "1 month")
|
|
29
|
+
Y = (11, "1 year")
|
|
@@ -0,0 +1,35 @@
|
|
|
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 logging
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
from webull.core.http.initializer.client_initializer import ClientInitializer
|
|
18
|
+
from webull.data.quotes.instrument import Instrument
|
|
19
|
+
from webull.data.quotes.market_data import MarketData
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DataClient:
|
|
23
|
+
def __init__(self, api_client):
|
|
24
|
+
self._init_logger(api_client)
|
|
25
|
+
ClientInitializer.initializer(api_client)
|
|
26
|
+
self.instrument = Instrument(api_client)
|
|
27
|
+
self.market_data = MarketData(api_client)
|
|
28
|
+
|
|
29
|
+
def _init_logger(self, api_client):
|
|
30
|
+
# No logger configured, using default console and local file logging.
|
|
31
|
+
if not getattr(api_client, '_stream_logger_set', False) and not getattr(api_client, '_file_logger_set', False):
|
|
32
|
+
log_format = '%(thread)d %(asctime)s %(name)s %(levelname)s %(message)s'
|
|
33
|
+
log_file_path = 'webull_data_sdk.log'
|
|
34
|
+
api_client.set_stream_logger(stream=sys.stdout, format_string=log_format)
|
|
35
|
+
api_client.set_file_logger(path=log_file_path, log_level=logging.INFO, format_string=log_format)
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.data.internal.quotes_client import QuotesClient, LOG_ERR
|
|
18
|
+
from webull.data.quotes.market_streaming_data import MarketDataStreaming
|
|
19
|
+
from webull.data.quotes.subscribe.payload_type import PAYLOAD_TYPE_QUOTE, PAYLOAD_TYPE_SHAPSHOT, PAYLOAD_TYPE_TICK
|
|
20
|
+
from webull.data.quotes.subscribe.quote_decoder import QuoteDecoder
|
|
21
|
+
from webull.data.quotes.subscribe.snapshot_decoder import SnapshotDecoder
|
|
22
|
+
from webull.data.quotes.subscribe.tick_decoder import TickDecoder
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DataStreamingClient(QuotesClient):
|
|
26
|
+
def __init__(self, app_key, app_secret, region_id, session_id, http_host=None, mqtt_host=None, mqtt_port=1883, tls_enable=True, transport="tcp",
|
|
27
|
+
retry_policy=None):
|
|
28
|
+
super().__init__(app_key, app_secret, region_id, session_id,
|
|
29
|
+
http_host=http_host,
|
|
30
|
+
mqtt_host=mqtt_host,
|
|
31
|
+
mqtt_port=mqtt_port,
|
|
32
|
+
tls_enable=tls_enable,
|
|
33
|
+
transport=transport, retry_policy=retry_policy)
|
|
34
|
+
self._subscribe_success = None
|
|
35
|
+
self._connect_success = None
|
|
36
|
+
self.on_quotes_subscribe = None
|
|
37
|
+
self._on_subscribe_success = None
|
|
38
|
+
# default decoder
|
|
39
|
+
self.register_payload_decoder(PAYLOAD_TYPE_QUOTE, QuoteDecoder())
|
|
40
|
+
self.register_payload_decoder(PAYLOAD_TYPE_SHAPSHOT, SnapshotDecoder())
|
|
41
|
+
self.register_payload_decoder(PAYLOAD_TYPE_TICK, TickDecoder())
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def on_connect_success(self):
|
|
45
|
+
return self.on_quotes_subscribe
|
|
46
|
+
|
|
47
|
+
@on_connect_success.setter
|
|
48
|
+
def on_connect_success(self, func):
|
|
49
|
+
self._connect_success = True
|
|
50
|
+
with self._callback_mutex:
|
|
51
|
+
self.on_quotes_subscribe = func
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def on_subscribe_success(self):
|
|
55
|
+
return self._on_subscribe_success
|
|
56
|
+
|
|
57
|
+
@on_subscribe_success.setter
|
|
58
|
+
def on_subscribe_success(self, func):
|
|
59
|
+
self._subscribe_success = True
|
|
60
|
+
with self._callback_mutex:
|
|
61
|
+
self._on_subscribe_success = func
|
|
62
|
+
|
|
63
|
+
def subscribe(self, symbols, category, sub_types, depth=None, overnight_required=None):
|
|
64
|
+
market_data_streaming = MarketDataStreaming(self.api_client)
|
|
65
|
+
response = market_data_streaming.subscribe(self.quotes_session_id, symbols, category, sub_types, depth, overnight_required)
|
|
66
|
+
if response.status_code == 200:
|
|
67
|
+
_on_subscribe_success = self._on_subscribe_success
|
|
68
|
+
if _on_subscribe_success:
|
|
69
|
+
try:
|
|
70
|
+
_on_subscribe_success(self, self.api_client, self.quotes_session_id)
|
|
71
|
+
except Exception as e:
|
|
72
|
+
self._easy_log(LOG_ERR, 'Caught exception in on_subscribe_success: %s', e)
|
|
73
|
+
raise
|
|
74
|
+
|
|
75
|
+
def unsubscribe(self, symbols=None, category=None, sub_types=None, unsubscribe_all=False):
|
|
76
|
+
market_data_streaming = MarketDataStreaming(self.api_client)
|
|
77
|
+
market_data_streaming.unsubscribe(self.quotes_session_id, symbols, category, sub_types, unsubscribe_all)
|
|
78
|
+
|
|
79
|
+
def get_connect_success(self):
|
|
80
|
+
return self._connect_success
|
|
81
|
+
|
|
82
|
+
def get_subscribe_success(self):
|
|
83
|
+
return self._subscribe_success
|
|
84
|
+
|
|
85
|
+
def get_session_id(self):
|
|
86
|
+
return self.quotes_session_id
|
|
87
|
+
|
|
88
|
+
def easy_log(self, level, msg, *args):
|
|
89
|
+
self._easy_log(level, msg, *args)
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
# coding=utf-8
|
|
16
|
+
|
|
17
|
+
from webull.core.retry.backoff_strategy import FixedDelayStrategy
|
|
18
|
+
from webull.core.exception import error_code
|
|
19
|
+
from webull.core.retry.retry_condition import RetryCondition, ClientException, MaxRetryTimesCondition, \
|
|
20
|
+
MergeAndRetryCondition, MergeRetryCondition
|
|
21
|
+
from webull.core.retry.retry_policy import RetryPolicy
|
|
22
|
+
from webull.core.retry.retry_policy_context import RetryPolicyContext
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class QuotesRetryPolicyContext(RetryPolicyContext):
|
|
26
|
+
def __init__(self, exception, retries_attempted, rc_code):
|
|
27
|
+
super().__init__(None, exception, retries_attempted, None)
|
|
28
|
+
self.rc_code = rc_code
|
|
29
|
+
|
|
30
|
+
def __str__(self):
|
|
31
|
+
return "exception:%s, retries:%s, rc_code:%s" % (self.exception, self.retries_attempted, self.rc_code)
|
|
32
|
+
|
|
33
|
+
class RetryOnRcCodeCondition(RetryCondition):
|
|
34
|
+
DEFAULT_RETRYABLE_RC_CODE_LIST = [
|
|
35
|
+
3,
|
|
36
|
+
5,
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
def __init__(self, retryable_rc_code_list=None):
|
|
40
|
+
if retryable_rc_code_list:
|
|
41
|
+
self.retryable_rc_code_list = retryable_rc_code_list
|
|
42
|
+
else:
|
|
43
|
+
self.retryable_rc_code_list = self.DEFAULT_RETRYABLE_RC_CODE_LIST
|
|
44
|
+
|
|
45
|
+
def should_retry(self, retry_policy_context):
|
|
46
|
+
if retry_policy_context.rc_code in self.retryable_rc_code_list:
|
|
47
|
+
return RetryCondition.RETRY
|
|
48
|
+
else:
|
|
49
|
+
return RetryCondition.NO_RETRY
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class RetryOnExceptionCondition(RetryCondition):
|
|
53
|
+
def __init__(self):
|
|
54
|
+
RetryCondition.__init__(self)
|
|
55
|
+
|
|
56
|
+
def should_retry(self, retry_policy_context):
|
|
57
|
+
exception = retry_policy_context.exception
|
|
58
|
+
if exception:
|
|
59
|
+
if isinstance(exception, ClientException):
|
|
60
|
+
if exception.get_error_code() == error_code.SDK_HTTP_ERROR:
|
|
61
|
+
return RetryCondition.RETRY
|
|
62
|
+
else:
|
|
63
|
+
return RetryCondition.NO_RETRY
|
|
64
|
+
return RetryCondition.RETRY
|
|
65
|
+
return RetryCondition.NO_RETRY
|
|
66
|
+
|
|
67
|
+
class DefaultQuotesRetryCondition(RetryCondition):
|
|
68
|
+
def __init__(self, max_retry_times=-1):
|
|
69
|
+
RetryCondition.__init__(self)
|
|
70
|
+
if max_retry_times < 0:
|
|
71
|
+
_conditions = []
|
|
72
|
+
else:
|
|
73
|
+
_conditions = [MaxRetryTimesCondition(max_retry_times)]
|
|
74
|
+
_merge_and_cnd = MergeAndRetryCondition(
|
|
75
|
+
[RetryOnRcCodeCondition(), RetryOnExceptionCondition()])
|
|
76
|
+
_conditions.append(_merge_and_cnd)
|
|
77
|
+
self._condition = MergeRetryCondition(_conditions)
|
|
78
|
+
|
|
79
|
+
def should_retry(self, retry_policy_context):
|
|
80
|
+
return self._condition.should_retry(retry_policy_context)
|
|
81
|
+
|
|
82
|
+
class DefaultQuotesRetryPolicy(RetryPolicy):
|
|
83
|
+
def __init__(self, max_retry_times=-1, fixed_delay=10000):
|
|
84
|
+
RetryPolicy.__init__(self, DefaultQuotesRetryCondition(max_retry_times), FixedDelayStrategy(fixed_delay))
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
from webull.data.common.connect_ack import ConnectAck
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# coding=utf-8
|
|
19
|
+
|
|
20
|
+
class ConnectException(Exception):
|
|
21
|
+
def __init__(self, rc_code, msg=""):
|
|
22
|
+
Exception.__init__(self)
|
|
23
|
+
self.error_code = rc_code
|
|
24
|
+
self.error_msg = msg
|
|
25
|
+
|
|
26
|
+
def get_error_code(self):
|
|
27
|
+
return self.error_code
|
|
28
|
+
|
|
29
|
+
def get_error_msg(self):
|
|
30
|
+
return self.error_msg
|
|
31
|
+
|
|
32
|
+
def __str__(self):
|
|
33
|
+
return "rc code: %s, msg: %s" % (self.error_code, self.error_msg)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ExitedException(ConnectException):
|
|
37
|
+
def __init__(self):
|
|
38
|
+
ConnectException.__init__(
|
|
39
|
+
self, 0, "exited exception which used to stop processing manually")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class LoopException(Exception):
|
|
43
|
+
def __init__(self, loop_code, msg=""):
|
|
44
|
+
Exception.__init__(self)
|
|
45
|
+
self.error_code = loop_code
|
|
46
|
+
self.error_msg = msg
|
|
47
|
+
|
|
48
|
+
def get_error_code(self):
|
|
49
|
+
return self.error_code
|
|
50
|
+
|
|
51
|
+
def get_error_msg(self):
|
|
52
|
+
return self.error_msg
|
|
53
|
+
|
|
54
|
+
def __str__(self):
|
|
55
|
+
error_msg = self.error_msg
|
|
56
|
+
if not error_msg:
|
|
57
|
+
ack = ConnectAck.from_code(self.error_code)
|
|
58
|
+
if ack is not None:
|
|
59
|
+
error_msg = ack.value[1]
|
|
60
|
+
return "loop ack code: %s, msg: %s" % (self.error_code, error_msg)
|