binance-sdk-sub-account 1.0.0__tar.gz

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.
Files changed (102) hide show
  1. binance_sdk_sub_account-1.0.0/CHANGELOG.md +5 -0
  2. binance_sdk_sub_account-1.0.0/LICENCE +21 -0
  3. binance_sdk_sub_account-1.0.0/PKG-INFO +210 -0
  4. binance_sdk_sub_account-1.0.0/README.md +182 -0
  5. binance_sdk_sub_account-1.0.0/pyproject.toml +40 -0
  6. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/__init__.py +31 -0
  7. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/metadata.py +1 -0
  8. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/__init__.py +13 -0
  9. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/api/__init__.py +14 -0
  10. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/api/account_management_api.py +419 -0
  11. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/api/api_management_api.py +225 -0
  12. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/api/asset_management_api.py +1452 -0
  13. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/api/managed_sub_account_api.py +729 -0
  14. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/__init__.py +265 -0
  15. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/add_ip_restriction_for_sub_account_api_key_response.py +112 -0
  16. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/create_a_virtual_sub_account_response.py +102 -0
  17. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/delete_ip_list_for_a_sub_account_api_key_response.py +112 -0
  18. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/deposit_assets_into_the_managed_sub_account_response.py +102 -0
  19. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/enable_futures_for_sub_account_response.py +107 -0
  20. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/enable_options_for_sub_account_response.py +110 -0
  21. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/enums.py +9 -0
  22. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/futures_transfer_for_sub_account_response.py +102 -0
  23. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_futures_account_response.py +190 -0
  24. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_futures_account_v2_response.py +136 -0
  25. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_futures_account_v2_response_delivery_account_resp.py +149 -0
  26. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_futures_account_v2_response_delivery_account_resp_assets_inner.py +144 -0
  27. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_futures_account_v2_response_future_account_resp.py +187 -0
  28. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_futures_account_v2_response_future_account_resp_assets_inner.py +144 -0
  29. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_margin_account_response.py +167 -0
  30. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_margin_account_response_margin_trade_coeff_vo.py +116 -0
  31. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_detail_on_sub_accounts_margin_account_response_margin_user_asset_vo_list_inner.py +123 -0
  32. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_futures_position_risk_of_sub_account_response.py +83 -0
  33. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_futures_position_risk_of_sub_account_v2_response.py +153 -0
  34. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_futures_position_risk_of_sub_account_v2_response_delivery_position_risk_vos_inner.py +144 -0
  35. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_futures_position_risk_of_sub_account_v2_response_future_position_risk_vos_inner.py +133 -0
  36. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_ip_restriction_for_a_sub_account_api_key_response.py +112 -0
  37. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_managed_sub_account_deposit_address_response.py +112 -0
  38. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_move_position_history_for_sub_account_response.py +133 -0
  39. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_move_position_history_for_sub_account_response_future_move_position_order_vo_list_inner.py +134 -0
  40. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_sub_account_deposit_address_response.py +112 -0
  41. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_sub_account_deposit_history_response.py +81 -0
  42. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_sub_account_deposit_history_response_inner.py +144 -0
  43. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_sub_accounts_status_on_margin_or_futures_response.py +83 -0
  44. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_sub_accounts_status_on_margin_or_futures_response_inner.py +132 -0
  45. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_futures_account_response.py +169 -0
  46. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_futures_account_v2_response.py +143 -0
  47. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_futures_account_v2_response_delivery_account_summary_resp.py +151 -0
  48. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_futures_account_v2_response_delivery_account_summary_resp_sub_account_list_inner.py +128 -0
  49. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_futures_account_v2_response_future_account_summary_resp.py +171 -0
  50. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_futures_account_v2_response_future_account_summary_resp_sub_account_list_inner.py +148 -0
  51. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_margin_account_response.py +144 -0
  52. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/get_summary_of_sub_accounts_margin_account_response_sub_account_list_inner.py +123 -0
  53. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/margin_transfer_for_sub_account_response.py +102 -0
  54. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/move_position_for_sub_account_response.py +127 -0
  55. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/move_position_for_sub_account_response_move_position_orders_inner.py +135 -0
  56. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_asset_details_response.py +83 -0
  57. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_asset_details_response_inner.py +125 -0
  58. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_futures_asset_details_response.py +131 -0
  59. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_futures_asset_details_response_snapshot_vos_inner.py +124 -0
  60. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_futures_asset_details_response_snapshot_vos_inner_data.py +154 -0
  61. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_futures_asset_details_response_snapshot_vos_inner_data_assets_inner.py +112 -0
  62. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_futures_asset_details_response_snapshot_vos_inner_data_position_inner.py +121 -0
  63. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_list_response.py +131 -0
  64. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_list_response_manager_sub_user_info_vo_list_inner.py +154 -0
  65. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_margin_asset_details_response.py +147 -0
  66. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_margin_asset_details_response_user_assets_inner.py +123 -0
  67. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response.py +131 -0
  68. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response_snapshot_vos_inner.py +122 -0
  69. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response_snapshot_vos_inner_data.py +219 -0
  70. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response_snapshot_vos_inner_data_assets_inner.py +110 -0
  71. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response_snapshot_vos_inner_data_balances_inner.py +112 -0
  72. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response_snapshot_vos_inner_data_position_inner.py +124 -0
  73. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_snapshot_response_snapshot_vos_inner_data_user_assets_inner.py +125 -0
  74. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_transfer_log_master_account_investor_response.py +133 -0
  75. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_transfer_log_master_account_investor_response_manager_sub_transfer_history_vos_inner.py +139 -0
  76. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_transfer_log_master_account_trading_response.py +133 -0
  77. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_managed_sub_account_transfer_log_sub_account_trading_response.py +133 -0
  78. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_assets_asset_management_response.py +127 -0
  79. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_assets_asset_management_response_balances_inner.py +120 -0
  80. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_assets_response.py +123 -0
  81. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_assets_response_balances_inner.py +120 -0
  82. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_futures_asset_transfer_history_response.py +131 -0
  83. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_futures_asset_transfer_history_response_transfers_inner.py +116 -0
  84. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_list_response.py +125 -0
  85. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_list_response_sub_accounts_inner.py +130 -0
  86. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_spot_asset_transfer_history_response.py +83 -0
  87. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_spot_asset_transfer_history_response_inner.py +126 -0
  88. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_spot_assets_summary_response.py +139 -0
  89. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_spot_assets_summary_response_spot_sub_user_asset_btc_vo_list_inner.py +105 -0
  90. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_transaction_statistics_response.py +159 -0
  91. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_sub_account_transaction_statistics_response_trade_info_vos_inner.py +129 -0
  92. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_universal_transfer_history_response.py +127 -0
  93. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/query_universal_transfer_history_response_result_inner.py +139 -0
  94. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/sub_account_futures_asset_transfer_response.py +105 -0
  95. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/sub_account_transfer_history_response.py +81 -0
  96. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/sub_account_transfer_history_response_inner.py +137 -0
  97. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/transfer_to_master_response.py +102 -0
  98. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/transfer_to_sub_account_of_same_master_response.py +102 -0
  99. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/universal_transfer_response.py +105 -0
  100. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/models/withdrawl_assets_from_the_managed_sub_account_response.py +102 -0
  101. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/rest_api/rest_api.py +1710 -0
  102. binance_sdk_sub_account-1.0.0/src/binance_sdk_sub_account/sub_account.py +34 -0
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2025-07-17
4
+
5
+ - Initial release
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Binance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.1
2
+ Name: binance-sdk-sub-account
3
+ Version: 1.0.0
4
+ Summary: Official Binance SubAccount SDK - A lightweight library that provides a convenient interface to Binance's SubAccount REST API
5
+ License: MIT
6
+ Author: Binance
7
+ Requires-Python: >=3.9,<=3.13
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Provides-Extra: dev
16
+ Requires-Dist: aiohttp (>=3.9,<4.0)
17
+ Requires-Dist: binance-common (==1.0.0)
18
+ Requires-Dist: black (>=25.1.0,<26.0.0)
19
+ Requires-Dist: pycryptodome (>=3.17,<4.0)
20
+ Requires-Dist: pydantic (>=2.10.0)
21
+ Requires-Dist: pytest (>=6.2.5) ; extra == "dev"
22
+ Requires-Dist: requests (>=2.31.0)
23
+ Requires-Dist: ruff (>=0.12.0,<0.13.0)
24
+ Requires-Dist: websocket-client (>=1.6.3)
25
+ Requires-Dist: websockets (>=15.0.1,<16.0.0)
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Binance Python Sub Account SDK
29
+
30
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-sub-account.yml)](https://github.com/binance/binance-connector-python/actions)
31
+ [![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)
32
+ [![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
33
+ [![PyPI version](https://img.shields.io/pypi/v/binance-sdk-sub-account)](https://pypi.python.org/pypi/binance-sdk-sub-account)
34
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-sub-account.svg)](https://pypi.org/project/binance-sdk-sub-account/)
35
+ [![Python version](https://img.shields.io/pypi/pyversions/binance-connector)](https://www.python.org/downloads/)
36
+ [![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
38
+
39
+ This is a client library for the Binance Sub Account SDK API, enabling developers to interact programmatically with Binance's Sub Account trading platform. The library provides tools to trade through multiple accounts through the REST API:
40
+
41
+ - [REST API](./src/binance_sdk_sub_account/rest_api/rest_api.py)
42
+
43
+ ## Table of Contents
44
+
45
+ - [Supported Features](#supported-features)
46
+ - [Installation](#installation)
47
+ - [Documentation](#documentation)
48
+ - [REST APIs](#rest-apis)
49
+ - [Testing](#testing)
50
+ - [Migration Guide](#migration-guide)
51
+ - [Contributing](#contributing)
52
+ - [Licence](#licence)
53
+
54
+ ## Supported Features
55
+
56
+ - REST API Endpoints:
57
+ - `/sapi/v1/sub-account/*`
58
+ - `/sapi/v2/sub-account/*`
59
+ - `/sapi/v3/sub-account/*`
60
+ - `/sapi/v4/sub-account/*`
61
+ - `/sapi/v1/managed-subaccount/*`
62
+ - `/sapi/v1/capital/*`
63
+ - Inclusion of test cases and examples for quick onboarding.
64
+
65
+ ## Installation
66
+
67
+ To use this library, ensure your environment is running Python version **3.9** or later.
68
+
69
+ ```bash
70
+ pip install binance-sdk-sub-account
71
+ ```
72
+
73
+ ## Documentation
74
+
75
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/sub_account/Introduction).
76
+
77
+ ### REST APIs
78
+
79
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_sub_account/rest_api/rest_api.py) module. The REST API enables you to fetch market data, manage trades, and access account information. Note that some endpoints require authentication using your Binance API credentials.
80
+
81
+ ```python
82
+ from binance_common.configuration import ConfigurationRestAPI
83
+ from binance_common.constants import SUB_ACCOUNT_REST_API_PROD_URL
84
+ from binance_sdk_sub_account.sub_account import SubAccount
85
+ from binance_sdk_sub_account.rest_api.models import GetSummaryOfSubAccountsMarginAccountResponse
86
+
87
+ logging.basicConfig(level=logging.INFO)
88
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=SUB_ACCOUNT_REST_API_PROD_URL)
89
+
90
+ client = SubAccount(config_rest_api=configuration)
91
+
92
+ try:
93
+ response = client.rest_api.get_summary_of_sub_accounts_margin_account()
94
+
95
+ data: GetSummaryOfSubAccountsMarginAccountResponse = response.data()
96
+ logging.info(f"get_summary_of_sub_accounts_margin_account() response: {data}")
97
+ except Exception as e:
98
+ logging.error(f"get_summary_of_sub_accounts_margin_account() error: {e}")
99
+ ```
100
+
101
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
102
+
103
+ #### Configuration Options
104
+
105
+ The REST API supports the following advanced configuration options:
106
+
107
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
108
+ - `proxy`: Proxy configuration:
109
+ - `host`: Proxy server hostname.
110
+ - `port`: Proxy server port.
111
+ - `protocol`: Proxy protocol (http or https).
112
+ - `auth`: Proxy authentication credentials:
113
+ - `username`: Proxy username.
114
+ - `password`: Proxy password.
115
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
116
+ - `compression`: Enable response compression (default: true).
117
+ - `retries`: Number of retry attempts for failed requests (default: 3).
118
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
119
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
120
+ - `private_key`: RSA or ED25519 private key for authentication.
121
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
122
+
123
+ ##### Timeout
124
+
125
+ You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the [Timeout example](./docs/rest_api/timeout.md) for detailed usage.
126
+
127
+ ##### Proxy
128
+
129
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
130
+
131
+ ##### Keep-Alive
132
+
133
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
134
+
135
+ ##### Compression
136
+
137
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
138
+
139
+ ##### Retries
140
+
141
+ Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the [Retries example](./docs/rest_api/retries.md) for detailed usage.
142
+
143
+ ##### HTTPS Agent
144
+
145
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
146
+
147
+ ##### Key Pair Based Authentication
148
+
149
+ The REST API supports key pair-based authentication for secure communication. You can use `RSA` or `ED25519` keys for signing requests. See the [Key Pair Based Authentication example](./docs/rest_api/key-pair-authentication.md) for detailed usage.
150
+
151
+ ##### Certificate Pinning
152
+
153
+ To enhance security, you can use certificate pinning with the `https_agent` option in the configuration. This ensures the client only communicates with servers using specific certificates. See the [Certificate Pinning example](./docs/rest_api/certificate-pinning.md) for detailed usage.
154
+
155
+ #### Error Handling
156
+
157
+ The REST API provides detailed error types to help you handle issues effectively:
158
+
159
+ - `ClientError`: Represents an error that occurred in the SDK client.
160
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
161
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
162
+ - `ForbiddenError`: Access to the requested resource is forbidden.
163
+ - `TooManyRequestsError`: Rate limit exceeded.
164
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
165
+ - `ServerError`: Internal server error, optionally includes a status code.
166
+ - `NetworkError`: Issues with network connectivity.
167
+ - `NotFoundError`: Resource not found.
168
+ - `BadRequestError`: Invalid request or one that cannot be served.
169
+
170
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
171
+
172
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
173
+
174
+ ## Testing
175
+
176
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
177
+
178
+ ```bash
179
+ poetry install
180
+ poetry run pytest ./tests
181
+ ```
182
+
183
+ The tests cover:
184
+ * REST API endpoints
185
+ * Error handling
186
+ * Edge cases
187
+
188
+ ## Migration Guide
189
+
190
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_sub_account_sdk.md) for detailed steps.
191
+
192
+ ## Contributing
193
+
194
+ Contributions are welcome!
195
+
196
+ Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.
197
+
198
+ To contribute:
199
+
200
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
201
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
202
+
203
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
204
+
205
+ Thank you for your contributions!
206
+
207
+ ## Licence
208
+
209
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
210
+
@@ -0,0 +1,182 @@
1
+ # Binance Python Sub Account SDK
2
+
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-sub-account.yml)](https://github.com/binance/binance-connector-python/actions)
4
+ [![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)
5
+ [![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
6
+ [![PyPI version](https://img.shields.io/pypi/v/binance-sdk-sub-account)](https://pypi.python.org/pypi/binance-sdk-sub-account)
7
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-sub-account.svg)](https://pypi.org/project/binance-sdk-sub-account/)
8
+ [![Python version](https://img.shields.io/pypi/pyversions/binance-connector)](https://www.python.org/downloads/)
9
+ [![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ This is a client library for the Binance Sub Account SDK API, enabling developers to interact programmatically with Binance's Sub Account trading platform. The library provides tools to trade through multiple accounts through the REST API:
13
+
14
+ - [REST API](./src/binance_sdk_sub_account/rest_api/rest_api.py)
15
+
16
+ ## Table of Contents
17
+
18
+ - [Supported Features](#supported-features)
19
+ - [Installation](#installation)
20
+ - [Documentation](#documentation)
21
+ - [REST APIs](#rest-apis)
22
+ - [Testing](#testing)
23
+ - [Migration Guide](#migration-guide)
24
+ - [Contributing](#contributing)
25
+ - [Licence](#licence)
26
+
27
+ ## Supported Features
28
+
29
+ - REST API Endpoints:
30
+ - `/sapi/v1/sub-account/*`
31
+ - `/sapi/v2/sub-account/*`
32
+ - `/sapi/v3/sub-account/*`
33
+ - `/sapi/v4/sub-account/*`
34
+ - `/sapi/v1/managed-subaccount/*`
35
+ - `/sapi/v1/capital/*`
36
+ - Inclusion of test cases and examples for quick onboarding.
37
+
38
+ ## Installation
39
+
40
+ To use this library, ensure your environment is running Python version **3.9** or later.
41
+
42
+ ```bash
43
+ pip install binance-sdk-sub-account
44
+ ```
45
+
46
+ ## Documentation
47
+
48
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/sub_account/Introduction).
49
+
50
+ ### REST APIs
51
+
52
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_sub_account/rest_api/rest_api.py) module. The REST API enables you to fetch market data, manage trades, and access account information. Note that some endpoints require authentication using your Binance API credentials.
53
+
54
+ ```python
55
+ from binance_common.configuration import ConfigurationRestAPI
56
+ from binance_common.constants import SUB_ACCOUNT_REST_API_PROD_URL
57
+ from binance_sdk_sub_account.sub_account import SubAccount
58
+ from binance_sdk_sub_account.rest_api.models import GetSummaryOfSubAccountsMarginAccountResponse
59
+
60
+ logging.basicConfig(level=logging.INFO)
61
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=SUB_ACCOUNT_REST_API_PROD_URL)
62
+
63
+ client = SubAccount(config_rest_api=configuration)
64
+
65
+ try:
66
+ response = client.rest_api.get_summary_of_sub_accounts_margin_account()
67
+
68
+ data: GetSummaryOfSubAccountsMarginAccountResponse = response.data()
69
+ logging.info(f"get_summary_of_sub_accounts_margin_account() response: {data}")
70
+ except Exception as e:
71
+ logging.error(f"get_summary_of_sub_accounts_margin_account() error: {e}")
72
+ ```
73
+
74
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
75
+
76
+ #### Configuration Options
77
+
78
+ The REST API supports the following advanced configuration options:
79
+
80
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
81
+ - `proxy`: Proxy configuration:
82
+ - `host`: Proxy server hostname.
83
+ - `port`: Proxy server port.
84
+ - `protocol`: Proxy protocol (http or https).
85
+ - `auth`: Proxy authentication credentials:
86
+ - `username`: Proxy username.
87
+ - `password`: Proxy password.
88
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
89
+ - `compression`: Enable response compression (default: true).
90
+ - `retries`: Number of retry attempts for failed requests (default: 3).
91
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
92
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
93
+ - `private_key`: RSA or ED25519 private key for authentication.
94
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
95
+
96
+ ##### Timeout
97
+
98
+ You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the [Timeout example](./docs/rest_api/timeout.md) for detailed usage.
99
+
100
+ ##### Proxy
101
+
102
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
103
+
104
+ ##### Keep-Alive
105
+
106
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
107
+
108
+ ##### Compression
109
+
110
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
111
+
112
+ ##### Retries
113
+
114
+ Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the [Retries example](./docs/rest_api/retries.md) for detailed usage.
115
+
116
+ ##### HTTPS Agent
117
+
118
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
119
+
120
+ ##### Key Pair Based Authentication
121
+
122
+ The REST API supports key pair-based authentication for secure communication. You can use `RSA` or `ED25519` keys for signing requests. See the [Key Pair Based Authentication example](./docs/rest_api/key-pair-authentication.md) for detailed usage.
123
+
124
+ ##### Certificate Pinning
125
+
126
+ To enhance security, you can use certificate pinning with the `https_agent` option in the configuration. This ensures the client only communicates with servers using specific certificates. See the [Certificate Pinning example](./docs/rest_api/certificate-pinning.md) for detailed usage.
127
+
128
+ #### Error Handling
129
+
130
+ The REST API provides detailed error types to help you handle issues effectively:
131
+
132
+ - `ClientError`: Represents an error that occurred in the SDK client.
133
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
134
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
135
+ - `ForbiddenError`: Access to the requested resource is forbidden.
136
+ - `TooManyRequestsError`: Rate limit exceeded.
137
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
138
+ - `ServerError`: Internal server error, optionally includes a status code.
139
+ - `NetworkError`: Issues with network connectivity.
140
+ - `NotFoundError`: Resource not found.
141
+ - `BadRequestError`: Invalid request or one that cannot be served.
142
+
143
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
144
+
145
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
146
+
147
+ ## Testing
148
+
149
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
150
+
151
+ ```bash
152
+ poetry install
153
+ poetry run pytest ./tests
154
+ ```
155
+
156
+ The tests cover:
157
+ * REST API endpoints
158
+ * Error handling
159
+ * Edge cases
160
+
161
+ ## Migration Guide
162
+
163
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_sub_account_sdk.md) for detailed steps.
164
+
165
+ ## Contributing
166
+
167
+ Contributions are welcome!
168
+
169
+ Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.
170
+
171
+ To contribute:
172
+
173
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
174
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
175
+
176
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
177
+
178
+ Thank you for your contributions!
179
+
180
+ ## Licence
181
+
182
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
@@ -0,0 +1,40 @@
1
+ [tool.poetry]
2
+ name = "binance-sdk-sub-account"
3
+ version = "1.0.0"
4
+ description = "Official Binance SubAccount SDK - A lightweight library that provides a convenient interface to Binance's SubAccount REST API"
5
+ authors = ["Binance"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ include = ["CHANGELOG.md", "LICENSE", "README.md"]
9
+ packages = [
10
+ { include = "binance_sdk_sub_account", from = "src" }
11
+ ]
12
+
13
+ [tool.poetry.dependencies]
14
+ python = ">=3.9,<=3.13"
15
+ requests = ">=2.31.0"
16
+ pydantic = ">=2.10.0"
17
+ websockets = "^15.0.1"
18
+ websocket-client = ">=1.6.3"
19
+ black = "^25.1.0"
20
+ ruff = "^0.12.0"
21
+ pycryptodome = "^3.17"
22
+ aiohttp = "^3.9"
23
+ binance-common = "1.0.0"
24
+ pytest = { version = ">=6.2.5", optional = true }
25
+
26
+ [tool.poetry.extras]
27
+ dev = ["pytest"]
28
+
29
+ [tool.poetry.group.dev.dependencies]
30
+ tox = "^4.27.0"
31
+ pytest = ">=8.4.1"
32
+ pytest-asyncio = "^1.0.0"
33
+
34
+ [tool.ruff]
35
+ exclude = [".git", ".tox", "build", "dist"]
36
+ lint.ignore = ["E741"]
37
+
38
+ [build-system]
39
+ requires = ["poetry-core>=1.0.0"]
40
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,31 @@
1
+ from binance_sdk_sub_account.sub_account import SubAccount
2
+ from binance_common.errors import (
3
+ ClientError,
4
+ RequiredError,
5
+ UnauthorizedError,
6
+ ForbiddenError,
7
+ TooManyRequestsError,
8
+ RateLimitBanError,
9
+ ServerError,
10
+ NetworkError,
11
+ NotFoundError,
12
+ BadRequestError,
13
+ )
14
+ from binance_common.constants import (
15
+ SUB_ACCOUNT_REST_API_PROD_URL,
16
+ )
17
+
18
+ __all__ = [
19
+ "SubAccount",
20
+ "SUB_ACCOUNT_REST_API_PROD_URL",
21
+ "ClientError",
22
+ "RequiredError",
23
+ "UnauthorizedError",
24
+ "ForbiddenError",
25
+ "TooManyRequestsError",
26
+ "RateLimitBanError",
27
+ "ServerError",
28
+ "NetworkError",
29
+ "NotFoundError",
30
+ "BadRequestError",
31
+ ]
@@ -0,0 +1 @@
1
+ NAME = "binance-sdk-sub-account"
@@ -0,0 +1,13 @@
1
+ """
2
+ Binance Sub Account REST API
3
+
4
+ OpenAPI Specification for the Binance Sub Account REST API
5
+ The version of the OpenAPI document: 1.0.0
6
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
7
+
8
+ Do not edit the class manually.
9
+ """
10
+
11
+ from .rest_api import SubAccountRestAPI
12
+
13
+ __all__ = ["SubAccountRestAPI"]
@@ -0,0 +1,14 @@
1
+ """
2
+ Binance Sub Account REST API
3
+
4
+ OpenAPI Specification for the Binance Sub Account REST API
5
+ The version of the OpenAPI document: 1.0.0
6
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
7
+
8
+ Do not edit the class manually.
9
+ """
10
+
11
+ from .account_management_api import AccountManagementApi as AccountManagementApi
12
+ from .api_management_api import ApiManagementApi as ApiManagementApi
13
+ from .asset_management_api import AssetManagementApi as AssetManagementApi
14
+ from .managed_sub_account_api import ManagedSubAccountApi as ManagedSubAccountApi