binance-sdk-convert 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 (28) hide show
  1. binance_sdk_convert-1.0.0/CHANGELOG.md +5 -0
  2. binance_sdk_convert-1.0.0/LICENCE +21 -0
  3. binance_sdk_convert-1.0.0/PKG-INFO +204 -0
  4. binance_sdk_convert-1.0.0/README.md +176 -0
  5. binance_sdk_convert-1.0.0/pyproject.toml +40 -0
  6. binance_sdk_convert-1.0.0/src/binance_sdk_convert/__init__.py +31 -0
  7. binance_sdk_convert-1.0.0/src/binance_sdk_convert/convert.py +34 -0
  8. binance_sdk_convert-1.0.0/src/binance_sdk_convert/metadata.py +1 -0
  9. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/__init__.py +13 -0
  10. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/api/__init__.py +12 -0
  11. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/api/market_data_api.py +112 -0
  12. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/api/trade_api.py +432 -0
  13. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/__init__.py +45 -0
  14. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/accept_quote_response.py +110 -0
  15. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/cancel_limit_order_response.py +105 -0
  16. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/enums.py +9 -0
  17. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/get_convert_trade_history_response.py +137 -0
  18. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/get_convert_trade_history_response_list_inner.py +135 -0
  19. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/list_all_convert_pairs_response.py +81 -0
  20. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/list_all_convert_pairs_response_inner.py +131 -0
  21. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/order_status_response.py +132 -0
  22. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/place_limit_order_response.py +123 -0
  23. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/query_limit_open_orders_response.py +123 -0
  24. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/query_limit_open_orders_response_list_inner.py +140 -0
  25. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/query_order_quantity_precision_per_asset_response.py +83 -0
  26. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/query_order_quantity_precision_per_asset_response_inner.py +105 -0
  27. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/models/send_quote_request_response.py +123 -0
  28. binance_sdk_convert-1.0.0/src/binance_sdk_convert/rest_api/rest_api.py +384 -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,204 @@
1
+ Metadata-Version: 2.1
2
+ Name: binance-sdk-convert
3
+ Version: 1.0.0
4
+ Summary: Official Binance Convert SDK - A lightweight library that provides a convenient interface to Binance's Convert 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 Convert SDK
29
+
30
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-convert.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-convert)](https://pypi.python.org/pypi/binance-sdk-convert)
34
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-convert.svg)](https://pypi.org/project/binance-sdk-convert/)
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 Convert SDK API, enabling developers to interact programmatically with Binance's Convert trading platform. The library provides tools to buy or sell cryptocurrencies through the REST API:
40
+ - [REST API](./src/binance_sdk_convert/rest_api/rest_api.py)
41
+
42
+ ## Table of Contents
43
+
44
+ - [Supported Features](#supported-features)
45
+ - [Installation](#installation)
46
+ - [Documentation](#documentation)
47
+ - [REST APIs](#rest-apis)
48
+ - [Testing](#testing)
49
+ - [Migration Guide](#migration-guide)
50
+ - [Contributing](#contributing)
51
+ - [Licence](#licence)
52
+
53
+ ## Supported Features
54
+
55
+ - REST API Endpoints:
56
+ - `/sapi/v1/convert/*`
57
+ - Inclusion of test cases and examples for quick onboarding.
58
+
59
+ ## Installation
60
+
61
+ To use this library, ensure your environment is running Python version **3.9** or later.
62
+
63
+ ```bash
64
+ pip install binance-sdk-convert
65
+ ```
66
+
67
+ ## Documentation
68
+
69
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/convert/Introduction).
70
+
71
+ ### REST APIs
72
+
73
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_convert/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.
74
+
75
+ ```python
76
+ from binance_common.configuration import ConfigurationRestAPI
77
+ from binance_common.constants import CONVERT_REST_API_PROD_URL
78
+ from binance_sdk_convert.convert import Convert
79
+ from binance_sdk_convert.rest_api.models import ListAllConvertPairsResponse
80
+
81
+ logging.basicConfig(level=logging.INFO)
82
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=CONVERT_REST_API_PROD_URL)
83
+
84
+ client = Convert(config_rest_api=configuration)
85
+
86
+ try:
87
+ response = client.rest_api.list_all_convert_pairs()
88
+
89
+ data: ListAllConvertPairsResponse = response.data()
90
+ logging.info(f"list_all_convert_pairs() response: {data}")
91
+ except Exception as e:
92
+ logging.error(f"list_all_convert_pairs() error: {e}")
93
+ ```
94
+
95
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
96
+
97
+ #### Configuration Options
98
+
99
+ The REST API supports the following advanced configuration options:
100
+
101
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
102
+ - `proxy`: Proxy configuration:
103
+ - `host`: Proxy server hostname.
104
+ - `port`: Proxy server port.
105
+ - `protocol`: Proxy protocol (http or https).
106
+ - `auth`: Proxy authentication credentials:
107
+ - `username`: Proxy username.
108
+ - `password`: Proxy password.
109
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
110
+ - `compression`: Enable response compression (default: true).
111
+ - `retries`: Number of retry attempts for failed requests (default: 3).
112
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
113
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
114
+ - `private_key`: RSA or ED25519 private key for authentication.
115
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
116
+
117
+ ##### Timeout
118
+
119
+ 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.
120
+
121
+ ##### Proxy
122
+
123
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
124
+
125
+ ##### Keep-Alive
126
+
127
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
128
+
129
+ ##### Compression
130
+
131
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
132
+
133
+ ##### Retries
134
+
135
+ 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.
136
+
137
+ ##### HTTPS Agent
138
+
139
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
140
+
141
+ ##### Key Pair Based Authentication
142
+
143
+ 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.
144
+
145
+ ##### Certificate Pinning
146
+
147
+ 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.
148
+
149
+ #### Error Handling
150
+
151
+ The REST API provides detailed error types to help you handle issues effectively:
152
+
153
+ - `ClientError`: Represents an error that occurred in the SDK client.
154
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
155
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
156
+ - `ForbiddenError`: Access to the requested resource is forbidden.
157
+ - `TooManyRequestsError`: Rate limit exceeded.
158
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
159
+ - `ServerError`: Internal server error, optionally includes a status code.
160
+ - `NetworkError`: Issues with network connectivity.
161
+ - `NotFoundError`: Resource not found.
162
+ - `BadRequestError`: Invalid request or one that cannot be served.
163
+
164
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
165
+
166
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
167
+
168
+ ## Testing
169
+
170
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
171
+
172
+ ```bash
173
+ poetry install
174
+ poetry run pytest ./tests
175
+ ```
176
+
177
+ The tests cover:
178
+ * REST API endpoints
179
+ * Error handling
180
+ * Edge cases
181
+
182
+ ## Migration Guide
183
+
184
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_convert_sdk.md) for detailed steps.
185
+
186
+ ## Contributing
187
+
188
+ Contributions are welcome!
189
+
190
+ 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.
191
+
192
+ To contribute:
193
+
194
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
195
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
196
+
197
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
198
+
199
+ Thank you for your contributions!
200
+
201
+ ## Licence
202
+
203
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
204
+
@@ -0,0 +1,176 @@
1
+ # Binance Python Convert SDK
2
+
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-convert.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-convert)](https://pypi.python.org/pypi/binance-sdk-convert)
7
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-convert.svg)](https://pypi.org/project/binance-sdk-convert/)
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 Convert SDK API, enabling developers to interact programmatically with Binance's Convert trading platform. The library provides tools to buy or sell cryptocurrencies through the REST API:
13
+ - [REST API](./src/binance_sdk_convert/rest_api/rest_api.py)
14
+
15
+ ## Table of Contents
16
+
17
+ - [Supported Features](#supported-features)
18
+ - [Installation](#installation)
19
+ - [Documentation](#documentation)
20
+ - [REST APIs](#rest-apis)
21
+ - [Testing](#testing)
22
+ - [Migration Guide](#migration-guide)
23
+ - [Contributing](#contributing)
24
+ - [Licence](#licence)
25
+
26
+ ## Supported Features
27
+
28
+ - REST API Endpoints:
29
+ - `/sapi/v1/convert/*`
30
+ - Inclusion of test cases and examples for quick onboarding.
31
+
32
+ ## Installation
33
+
34
+ To use this library, ensure your environment is running Python version **3.9** or later.
35
+
36
+ ```bash
37
+ pip install binance-sdk-convert
38
+ ```
39
+
40
+ ## Documentation
41
+
42
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/convert/Introduction).
43
+
44
+ ### REST APIs
45
+
46
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_convert/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.
47
+
48
+ ```python
49
+ from binance_common.configuration import ConfigurationRestAPI
50
+ from binance_common.constants import CONVERT_REST_API_PROD_URL
51
+ from binance_sdk_convert.convert import Convert
52
+ from binance_sdk_convert.rest_api.models import ListAllConvertPairsResponse
53
+
54
+ logging.basicConfig(level=logging.INFO)
55
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=CONVERT_REST_API_PROD_URL)
56
+
57
+ client = Convert(config_rest_api=configuration)
58
+
59
+ try:
60
+ response = client.rest_api.list_all_convert_pairs()
61
+
62
+ data: ListAllConvertPairsResponse = response.data()
63
+ logging.info(f"list_all_convert_pairs() response: {data}")
64
+ except Exception as e:
65
+ logging.error(f"list_all_convert_pairs() error: {e}")
66
+ ```
67
+
68
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
69
+
70
+ #### Configuration Options
71
+
72
+ The REST API supports the following advanced configuration options:
73
+
74
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
75
+ - `proxy`: Proxy configuration:
76
+ - `host`: Proxy server hostname.
77
+ - `port`: Proxy server port.
78
+ - `protocol`: Proxy protocol (http or https).
79
+ - `auth`: Proxy authentication credentials:
80
+ - `username`: Proxy username.
81
+ - `password`: Proxy password.
82
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
83
+ - `compression`: Enable response compression (default: true).
84
+ - `retries`: Number of retry attempts for failed requests (default: 3).
85
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
86
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
87
+ - `private_key`: RSA or ED25519 private key for authentication.
88
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
89
+
90
+ ##### Timeout
91
+
92
+ 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.
93
+
94
+ ##### Proxy
95
+
96
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
97
+
98
+ ##### Keep-Alive
99
+
100
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
101
+
102
+ ##### Compression
103
+
104
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
105
+
106
+ ##### Retries
107
+
108
+ 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.
109
+
110
+ ##### HTTPS Agent
111
+
112
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
113
+
114
+ ##### Key Pair Based Authentication
115
+
116
+ 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.
117
+
118
+ ##### Certificate Pinning
119
+
120
+ 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.
121
+
122
+ #### Error Handling
123
+
124
+ The REST API provides detailed error types to help you handle issues effectively:
125
+
126
+ - `ClientError`: Represents an error that occurred in the SDK client.
127
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
128
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
129
+ - `ForbiddenError`: Access to the requested resource is forbidden.
130
+ - `TooManyRequestsError`: Rate limit exceeded.
131
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
132
+ - `ServerError`: Internal server error, optionally includes a status code.
133
+ - `NetworkError`: Issues with network connectivity.
134
+ - `NotFoundError`: Resource not found.
135
+ - `BadRequestError`: Invalid request or one that cannot be served.
136
+
137
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
138
+
139
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
140
+
141
+ ## Testing
142
+
143
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
144
+
145
+ ```bash
146
+ poetry install
147
+ poetry run pytest ./tests
148
+ ```
149
+
150
+ The tests cover:
151
+ * REST API endpoints
152
+ * Error handling
153
+ * Edge cases
154
+
155
+ ## Migration Guide
156
+
157
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_convert_sdk.md) for detailed steps.
158
+
159
+ ## Contributing
160
+
161
+ Contributions are welcome!
162
+
163
+ 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.
164
+
165
+ To contribute:
166
+
167
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
168
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
169
+
170
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
171
+
172
+ Thank you for your contributions!
173
+
174
+ ## Licence
175
+
176
+ 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-convert"
3
+ version = "1.0.0"
4
+ description = "Official Binance Convert SDK - A lightweight library that provides a convenient interface to Binance's Convert 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_convert", 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_convert.convert import Convert
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
+ CONVERT_REST_API_PROD_URL,
16
+ )
17
+
18
+ __all__ = [
19
+ "Convert",
20
+ "CONVERT_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,34 @@
1
+ import platform
2
+ from importlib.metadata import version
3
+
4
+ from binance_common.configuration import ConfigurationRestAPI
5
+ from binance_common.constants import CONVERT_REST_API_PROD_URL
6
+ from . import metadata
7
+ from .rest_api import ConvertRestAPI
8
+
9
+ LIB_NAME = metadata.NAME
10
+ LIB_VERSION = version(LIB_NAME)
11
+
12
+
13
+ class Convert:
14
+ """Convert API that exposes REST APIs in a single interface."""
15
+
16
+ def __init__(self, config_rest_api: ConfigurationRestAPI = None) -> None:
17
+ self._rest_api = None
18
+ self._rest_api_config = (
19
+ ConfigurationRestAPI() if config_rest_api is None else config_rest_api
20
+ )
21
+
22
+ @property
23
+ def rest_api(self) -> ConvertRestAPI:
24
+ if self._rest_api is None and self._rest_api_config:
25
+ self._rest_api_config.base_headers["User-Agent"] = (
26
+ f"{LIB_NAME}/{LIB_VERSION} (Python/{platform.python_version()}; {platform.system()}; {platform.machine()})"
27
+ )
28
+ self._rest_api_config.base_path = (
29
+ CONVERT_REST_API_PROD_URL
30
+ if self._rest_api_config.base_path is None
31
+ else self._rest_api_config.base_path
32
+ )
33
+ self._rest_api = ConvertRestAPI(self._rest_api_config)
34
+ return self._rest_api
@@ -0,0 +1 @@
1
+ NAME = "binance-sdk-convert"
@@ -0,0 +1,13 @@
1
+ """
2
+ Binance Convert REST API
3
+
4
+ OpenAPI Specification for the Binance Convert 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 ConvertRestAPI
12
+
13
+ __all__ = ["ConvertRestAPI"]
@@ -0,0 +1,12 @@
1
+ """
2
+ Binance Convert REST API
3
+
4
+ OpenAPI Specification for the Binance Convert 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 .market_data_api import MarketDataApi as MarketDataApi
12
+ from .trade_api import TradeApi as TradeApi
@@ -0,0 +1,112 @@
1
+ """
2
+ Binance Convert REST API
3
+
4
+ OpenAPI Specification for the Binance Convert 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 typing import Optional
12
+ from requests import Session
13
+ from binance_common.configuration import ConfigurationRestAPI
14
+ from binance_common.models import ApiResponse
15
+ from binance_common.signature import Signers
16
+ from binance_common.utils import send_request
17
+
18
+ from ..models import ListAllConvertPairsResponse
19
+ from ..models import QueryOrderQuantityPrecisionPerAssetResponse
20
+
21
+
22
+ class MarketDataApi:
23
+ """API Client for MarketDataApi endpoints."""
24
+
25
+ def __init__(
26
+ self,
27
+ configuration: ConfigurationRestAPI = None,
28
+ session: Session = None,
29
+ signer: Signers = None,
30
+ ) -> None:
31
+ self._configuration = configuration
32
+ self._session = session
33
+ self._signer = signer
34
+
35
+ def list_all_convert_pairs(
36
+ self,
37
+ from_asset: Optional[str] = None,
38
+ to_asset: Optional[str] = None,
39
+ ) -> ApiResponse[ListAllConvertPairsResponse]:
40
+ """
41
+ List All Convert Pairs
42
+ GET /sapi/v1/convert/exchangeInfo
43
+ https://developers.binance.com/docs/convert/market-data/
44
+
45
+ Query for all convertible token pairs and the tokens’ respective upper/lower limits
46
+
47
+ * User needs to supply either or both of the input parameter
48
+ * If not defined for both fromAsset and toAsset, only partial token pairs will be returned
49
+
50
+ Weight: 3000(IP)
51
+
52
+ Args:
53
+ from_asset (Optional[str]): User spends coin
54
+ to_asset (Optional[str]): User receives coin
55
+
56
+ Returns:
57
+ ApiResponse[ListAllConvertPairsResponse]
58
+
59
+ Raises:
60
+ RequiredError: If a required parameter is missing.
61
+
62
+ """
63
+
64
+ payload = {"from_asset": from_asset, "to_asset": to_asset}
65
+
66
+ return send_request(
67
+ self._session,
68
+ self._configuration,
69
+ method="GET",
70
+ path="/sapi/v1/convert/exchangeInfo",
71
+ payload=payload,
72
+ time_unit=self._configuration.time_unit,
73
+ response_model=ListAllConvertPairsResponse,
74
+ )
75
+
76
+ def query_order_quantity_precision_per_asset(
77
+ self,
78
+ recv_window: Optional[int] = None,
79
+ ) -> ApiResponse[QueryOrderQuantityPrecisionPerAssetResponse]:
80
+ """
81
+ Query order quantity precision per asset(USER_DATA)
82
+ GET /sapi/v1/convert/assetInfo
83
+ https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset
84
+
85
+ Query for supported asset’s precision information
86
+
87
+ Weight: 100(IP)
88
+
89
+ Args:
90
+ recv_window (Optional[int]): The value cannot be greater than 60000
91
+
92
+ Returns:
93
+ ApiResponse[QueryOrderQuantityPrecisionPerAssetResponse]
94
+
95
+ Raises:
96
+ RequiredError: If a required parameter is missing.
97
+
98
+ """
99
+
100
+ payload = {"recv_window": recv_window}
101
+
102
+ return send_request(
103
+ self._session,
104
+ self._configuration,
105
+ method="GET",
106
+ path="/sapi/v1/convert/assetInfo",
107
+ payload=payload,
108
+ time_unit=self._configuration.time_unit,
109
+ response_model=QueryOrderQuantityPrecisionPerAssetResponse,
110
+ is_signed=True,
111
+ signer=self._signer,
112
+ )