binance-sdk-copy-trading 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 (18) hide show
  1. binance_sdk_copy_trading-1.0.0/CHANGELOG.md +5 -0
  2. binance_sdk_copy_trading-1.0.0/LICENCE +21 -0
  3. binance_sdk_copy_trading-1.0.0/PKG-INFO +199 -0
  4. binance_sdk_copy_trading-1.0.0/README.md +171 -0
  5. binance_sdk_copy_trading-1.0.0/pyproject.toml +40 -0
  6. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/__init__.py +31 -0
  7. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/copy_trading.py +34 -0
  8. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/metadata.py +1 -0
  9. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/__init__.py +13 -0
  10. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/api/__init__.py +11 -0
  11. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/api/future_copy_trading_api.py +109 -0
  12. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/models/__init__.py +22 -0
  13. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/models/enums.py +9 -0
  14. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/models/get_futures_lead_trader_status_response.py +122 -0
  15. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/models/get_futures_lead_trader_status_response_data.py +105 -0
  16. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/models/get_futures_lead_trading_symbol_whitelist_response.py +129 -0
  17. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/models/get_futures_lead_trading_symbol_whitelist_response_data_inner.py +110 -0
  18. binance_sdk_copy_trading-1.0.0/src/binance_sdk_copy_trading/rest_api/rest_api.py +135 -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,199 @@
1
+ Metadata-Version: 2.1
2
+ Name: binance-sdk-copy-trading
3
+ Version: 1.0.0
4
+ Summary: Official Binance CopyTrading Connector - A lightweight library that provides a convenient interface to Binance's CopyTrading 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 Copy Trading SDK
29
+
30
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-copy-trading.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-copy-trading)](https://pypi.python.org/pypi/binance-sdk-copy-trading)
34
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-copy-trading.svg)](https://pypi.org/project/binance-sdk-copy-trading/)
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 Copy Trading SDK API, enabling developers to interact programmatically with Binance's Copy Trading trading platform. The library provides tools to do automatic lead trading through the REST API:
40
+ - [REST API](./src/binance_sdk_copy_trading/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
+ - [Contributing](#contributing)
50
+ - [Licence](#licence)
51
+
52
+ ## Supported Features
53
+
54
+ - REST API Endpoints:
55
+ - `/sapi/v1/copyTrading/*`
56
+ - Inclusion of test cases and examples for quick onboarding.
57
+
58
+ ## Installation
59
+
60
+ To use this library, ensure your environment is running Python version **3.9** or later.
61
+
62
+ ```bash
63
+ pip install binance-sdk-copy-trading
64
+ ```
65
+
66
+ ## Documentation
67
+
68
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/copy_trading/Introduction).
69
+
70
+ ### REST APIs
71
+
72
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_copy_trading/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.
73
+
74
+ ```python
75
+ from binance_common.configuration import ConfigurationRestAPI
76
+ from binance_common.constants import COPY_TRADING_REST_API_PROD_URL
77
+ from binance_sdk_copy_trading.copy_trading import CopyTrading
78
+ from binance_sdk_copy_trading.rest_api.models import GetFuturesLeadTraderStatusResponse
79
+
80
+ logging.basicConfig(level=logging.INFO)
81
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=COPY_TRADING_REST_API_PROD_URL)
82
+
83
+ client = CopyTrading(config_rest_api=configuration)
84
+
85
+ try:
86
+ response = client.rest_api.get_futures_lead_trader_status()
87
+
88
+ data: GetFuturesLeadTraderStatusResponse = response.data()
89
+ logging.info(f"get_futures_lead_trader_status() response: {data}")
90
+ except Exception as e:
91
+ logging.error(f"get_futures_lead_trader_status() error: {e}")
92
+ ```
93
+
94
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
95
+
96
+ #### Configuration Options
97
+
98
+ The REST API supports the following advanced configuration options:
99
+
100
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
101
+ - `proxy`: Proxy configuration:
102
+ - `host`: Proxy server hostname.
103
+ - `port`: Proxy server port.
104
+ - `protocol`: Proxy protocol (http or https).
105
+ - `auth`: Proxy authentication credentials:
106
+ - `username`: Proxy username.
107
+ - `password`: Proxy password.
108
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
109
+ - `compression`: Enable response compression (default: true).
110
+ - `retries`: Number of retry attempts for failed requests (default: 3).
111
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
112
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
113
+ - `private_key`: RSA or ED25519 private key for authentication.
114
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
115
+
116
+ ##### Timeout
117
+
118
+ 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.
119
+
120
+ ##### Proxy
121
+
122
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
123
+
124
+ ##### Keep-Alive
125
+
126
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
127
+
128
+ ##### Compression
129
+
130
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
131
+
132
+ ##### Retries
133
+
134
+ 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.
135
+
136
+ ##### HTTPS Agent
137
+
138
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
139
+
140
+ ##### Key Pair Based Authentication
141
+
142
+ 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.
143
+
144
+ ##### Certificate Pinning
145
+
146
+ 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.
147
+
148
+ #### Error Handling
149
+
150
+ The REST API provides detailed error types to help you handle issues effectively:
151
+
152
+ - `ClientError`: Represents an error that occurred in the SDK client.
153
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
154
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
155
+ - `ForbiddenError`: Access to the requested resource is forbidden.
156
+ - `TooManyRequestsError`: Rate limit exceeded.
157
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
158
+ - `ServerError`: Internal server error, optionally includes a status code.
159
+ - `NetworkError`: Issues with network connectivity.
160
+ - `NotFoundError`: Resource not found.
161
+ - `BadRequestError`: Invalid request or one that cannot be served.
162
+
163
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
164
+
165
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
166
+
167
+ ## Testing
168
+
169
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
170
+
171
+ ```bash
172
+ poetry install
173
+ poetry run pytest ./tests
174
+ ```
175
+
176
+ The tests cover:
177
+ * REST API endpoints
178
+ * Error handling
179
+ * Edge cases
180
+
181
+ ## Contributing
182
+
183
+ Contributions are welcome!
184
+
185
+ 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.
186
+
187
+ To contribute:
188
+
189
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
190
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
191
+
192
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
193
+
194
+ Thank you for your contributions!
195
+
196
+ ## Licence
197
+
198
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
199
+
@@ -0,0 +1,171 @@
1
+ # Binance Python Copy Trading SDK
2
+
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-copy-trading.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-copy-trading)](https://pypi.python.org/pypi/binance-sdk-copy-trading)
7
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-copy-trading.svg)](https://pypi.org/project/binance-sdk-copy-trading/)
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 Copy Trading SDK API, enabling developers to interact programmatically with Binance's Copy Trading trading platform. The library provides tools to do automatic lead trading through the REST API:
13
+ - [REST API](./src/binance_sdk_copy_trading/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
+ - [Contributing](#contributing)
23
+ - [Licence](#licence)
24
+
25
+ ## Supported Features
26
+
27
+ - REST API Endpoints:
28
+ - `/sapi/v1/copyTrading/*`
29
+ - Inclusion of test cases and examples for quick onboarding.
30
+
31
+ ## Installation
32
+
33
+ To use this library, ensure your environment is running Python version **3.9** or later.
34
+
35
+ ```bash
36
+ pip install binance-sdk-copy-trading
37
+ ```
38
+
39
+ ## Documentation
40
+
41
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/copy_trading/Introduction).
42
+
43
+ ### REST APIs
44
+
45
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_copy_trading/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.
46
+
47
+ ```python
48
+ from binance_common.configuration import ConfigurationRestAPI
49
+ from binance_common.constants import COPY_TRADING_REST_API_PROD_URL
50
+ from binance_sdk_copy_trading.copy_trading import CopyTrading
51
+ from binance_sdk_copy_trading.rest_api.models import GetFuturesLeadTraderStatusResponse
52
+
53
+ logging.basicConfig(level=logging.INFO)
54
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=COPY_TRADING_REST_API_PROD_URL)
55
+
56
+ client = CopyTrading(config_rest_api=configuration)
57
+
58
+ try:
59
+ response = client.rest_api.get_futures_lead_trader_status()
60
+
61
+ data: GetFuturesLeadTraderStatusResponse = response.data()
62
+ logging.info(f"get_futures_lead_trader_status() response: {data}")
63
+ except Exception as e:
64
+ logging.error(f"get_futures_lead_trader_status() error: {e}")
65
+ ```
66
+
67
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
68
+
69
+ #### Configuration Options
70
+
71
+ The REST API supports the following advanced configuration options:
72
+
73
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
74
+ - `proxy`: Proxy configuration:
75
+ - `host`: Proxy server hostname.
76
+ - `port`: Proxy server port.
77
+ - `protocol`: Proxy protocol (http or https).
78
+ - `auth`: Proxy authentication credentials:
79
+ - `username`: Proxy username.
80
+ - `password`: Proxy password.
81
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
82
+ - `compression`: Enable response compression (default: true).
83
+ - `retries`: Number of retry attempts for failed requests (default: 3).
84
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
85
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
86
+ - `private_key`: RSA or ED25519 private key for authentication.
87
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
88
+
89
+ ##### Timeout
90
+
91
+ 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.
92
+
93
+ ##### Proxy
94
+
95
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
96
+
97
+ ##### Keep-Alive
98
+
99
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
100
+
101
+ ##### Compression
102
+
103
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
104
+
105
+ ##### Retries
106
+
107
+ 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.
108
+
109
+ ##### HTTPS Agent
110
+
111
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
112
+
113
+ ##### Key Pair Based Authentication
114
+
115
+ 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.
116
+
117
+ ##### Certificate Pinning
118
+
119
+ 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.
120
+
121
+ #### Error Handling
122
+
123
+ The REST API provides detailed error types to help you handle issues effectively:
124
+
125
+ - `ClientError`: Represents an error that occurred in the SDK client.
126
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
127
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
128
+ - `ForbiddenError`: Access to the requested resource is forbidden.
129
+ - `TooManyRequestsError`: Rate limit exceeded.
130
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
131
+ - `ServerError`: Internal server error, optionally includes a status code.
132
+ - `NetworkError`: Issues with network connectivity.
133
+ - `NotFoundError`: Resource not found.
134
+ - `BadRequestError`: Invalid request or one that cannot be served.
135
+
136
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
137
+
138
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
139
+
140
+ ## Testing
141
+
142
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
143
+
144
+ ```bash
145
+ poetry install
146
+ poetry run pytest ./tests
147
+ ```
148
+
149
+ The tests cover:
150
+ * REST API endpoints
151
+ * Error handling
152
+ * Edge cases
153
+
154
+ ## Contributing
155
+
156
+ Contributions are welcome!
157
+
158
+ 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.
159
+
160
+ To contribute:
161
+
162
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
163
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
164
+
165
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
166
+
167
+ Thank you for your contributions!
168
+
169
+ ## Licence
170
+
171
+ 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-copy-trading"
3
+ version = "1.0.0"
4
+ description = "Official Binance CopyTrading Connector - A lightweight library that provides a convenient interface to Binance's CopyTrading 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_copy_trading", 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_copy_trading.copy_trading import CopyTrading
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
+ COPY_TRADING_REST_API_PROD_URL,
16
+ )
17
+
18
+ __all__ = [
19
+ "CopyTrading",
20
+ "COPY_TRADING_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 COPY_TRADING_REST_API_PROD_URL
6
+ from . import metadata
7
+ from .rest_api import CopyTradingRestAPI
8
+
9
+ LIB_NAME = metadata.NAME
10
+ LIB_VERSION = version(LIB_NAME)
11
+
12
+
13
+ class CopyTrading:
14
+ """CopyTrading 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) -> CopyTradingRestAPI:
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
+ COPY_TRADING_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 = CopyTradingRestAPI(self._rest_api_config)
34
+ return self._rest_api
@@ -0,0 +1 @@
1
+ NAME = "binance-sdk-copy-trading"
@@ -0,0 +1,13 @@
1
+ """
2
+ Binance Copy Trading REST API
3
+
4
+ OpenAPI Specification for the Binance Copy Trading 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 CopyTradingRestAPI
12
+
13
+ __all__ = ["CopyTradingRestAPI"]
@@ -0,0 +1,11 @@
1
+ """
2
+ Binance Copy Trading REST API
3
+
4
+ OpenAPI Specification for the Binance Copy Trading 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 .future_copy_trading_api import FutureCopyTradingApi as FutureCopyTradingApi
@@ -0,0 +1,109 @@
1
+ """
2
+ Binance Copy Trading REST API
3
+
4
+ OpenAPI Specification for the Binance Copy Trading 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 GetFuturesLeadTraderStatusResponse
19
+ from ..models import GetFuturesLeadTradingSymbolWhitelistResponse
20
+
21
+
22
+ class FutureCopyTradingApi:
23
+ """API Client for FutureCopyTradingApi 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 get_futures_lead_trader_status(
36
+ self,
37
+ recv_window: Optional[int] = None,
38
+ ) -> ApiResponse[GetFuturesLeadTraderStatusResponse]:
39
+ """
40
+ Get Futures Lead Trader Status(TRADE)
41
+ GET /sapi/v1/copyTrading/futures/userStatus
42
+ https://developers.binance.com/docs/copy_trading/future-copy-trading/Get-Futures-Lead-Trader-Status
43
+
44
+ Get Futures Lead Trader Status
45
+
46
+ Weight: 20
47
+
48
+ Args:
49
+ recv_window (Optional[int]):
50
+
51
+ Returns:
52
+ ApiResponse[GetFuturesLeadTraderStatusResponse]
53
+
54
+ Raises:
55
+ RequiredError: If a required parameter is missing.
56
+
57
+ """
58
+
59
+ payload = {"recv_window": recv_window}
60
+
61
+ return send_request(
62
+ self._session,
63
+ self._configuration,
64
+ method="GET",
65
+ path="/sapi/v1/copyTrading/futures/userStatus",
66
+ payload=payload,
67
+ time_unit=self._configuration.time_unit,
68
+ response_model=GetFuturesLeadTraderStatusResponse,
69
+ is_signed=True,
70
+ signer=self._signer,
71
+ )
72
+
73
+ def get_futures_lead_trading_symbol_whitelist(
74
+ self,
75
+ recv_window: Optional[int] = None,
76
+ ) -> ApiResponse[GetFuturesLeadTradingSymbolWhitelistResponse]:
77
+ """
78
+ Get Futures Lead Trading Symbol Whitelist(USER_DATA)
79
+ GET /sapi/v1/copyTrading/futures/leadSymbol
80
+ https://developers.binance.com/docs/copy_trading/future-copy-trading/Get-Futures-Lead-Trading-Symbol-Whitelist
81
+
82
+ Get Futures Lead Trading Symbol Whitelist
83
+
84
+ Weight: 20
85
+
86
+ Args:
87
+ recv_window (Optional[int]):
88
+
89
+ Returns:
90
+ ApiResponse[GetFuturesLeadTradingSymbolWhitelistResponse]
91
+
92
+ Raises:
93
+ RequiredError: If a required parameter is missing.
94
+
95
+ """
96
+
97
+ payload = {"recv_window": recv_window}
98
+
99
+ return send_request(
100
+ self._session,
101
+ self._configuration,
102
+ method="GET",
103
+ path="/sapi/v1/copyTrading/futures/leadSymbol",
104
+ payload=payload,
105
+ time_unit=self._configuration.time_unit,
106
+ response_model=GetFuturesLeadTradingSymbolWhitelistResponse,
107
+ is_signed=True,
108
+ signer=self._signer,
109
+ )
@@ -0,0 +1,22 @@
1
+ """
2
+ Binance Copy Trading REST API
3
+
4
+ OpenAPI Specification for the Binance Copy Trading 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 .get_futures_lead_trader_status_response import (
12
+ GetFuturesLeadTraderStatusResponse as GetFuturesLeadTraderStatusResponse,
13
+ )
14
+ from .get_futures_lead_trader_status_response_data import (
15
+ GetFuturesLeadTraderStatusResponseData as GetFuturesLeadTraderStatusResponseData,
16
+ )
17
+ from .get_futures_lead_trading_symbol_whitelist_response import (
18
+ GetFuturesLeadTradingSymbolWhitelistResponse as GetFuturesLeadTradingSymbolWhitelistResponse,
19
+ )
20
+ from .get_futures_lead_trading_symbol_whitelist_response_data_inner import (
21
+ GetFuturesLeadTradingSymbolWhitelistResponseDataInner as GetFuturesLeadTradingSymbolWhitelistResponseDataInner,
22
+ )
@@ -0,0 +1,9 @@
1
+ """
2
+ Binance Copy Trading REST API
3
+
4
+ OpenAPI Specification for the Binance Copy Trading 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
+ """
@@ -0,0 +1,122 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Copy Trading REST API
5
+
6
+ OpenAPI Specification for the Binance Copy Trading REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from binance_sdk_copy_trading.rest_api.models.get_futures_lead_trader_status_response_data import (
22
+ GetFuturesLeadTraderStatusResponseData,
23
+ )
24
+ from typing import Set
25
+ from typing_extensions import Self
26
+
27
+
28
+ class GetFuturesLeadTraderStatusResponse(BaseModel):
29
+ """
30
+ GetFuturesLeadTraderStatusResponse
31
+ """ # noqa: E501
32
+
33
+ code: Optional[StrictStr] = None
34
+ message: Optional[StrictStr] = None
35
+ data: Optional[GetFuturesLeadTraderStatusResponseData] = None
36
+ success: Optional[StrictBool] = None
37
+ additional_properties: Dict[str, Any] = {}
38
+ __properties: ClassVar[List[str]] = ["code", "message", "data", "success"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+ def to_str(self) -> str:
47
+ """Returns the string representation of the model using alias"""
48
+ return pprint.pformat(self.model_dump(by_alias=True))
49
+
50
+ def to_json(self) -> str:
51
+ """Returns the JSON representation of the model using alias"""
52
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
53
+ return json.dumps(self.to_dict())
54
+
55
+ @classmethod
56
+ def is_array(cls) -> bool:
57
+ return False
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of GetFuturesLeadTraderStatusResponse from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ * Fields in `self.additional_properties` are added to the output dict.
74
+ """
75
+ excluded_fields: Set[str] = set(
76
+ [
77
+ "additional_properties",
78
+ ]
79
+ )
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ # override the default output from pydantic by calling `to_dict()` of data
87
+ if self.data:
88
+ _dict["data"] = self.data.to_dict()
89
+ # puts key-value pairs in additional_properties in the top level
90
+ if self.additional_properties is not None:
91
+ for _key, _value in self.additional_properties.items():
92
+ _dict[_key] = _value
93
+
94
+ return _dict
95
+
96
+ @classmethod
97
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98
+ """Create an instance of GetFuturesLeadTraderStatusResponse from a dict"""
99
+ if obj is None:
100
+ return None
101
+
102
+ if not isinstance(obj, dict):
103
+ return cls.model_validate(obj)
104
+
105
+ _obj = cls.model_validate(
106
+ {
107
+ "code": obj.get("code"),
108
+ "message": obj.get("message"),
109
+ "data": (
110
+ GetFuturesLeadTraderStatusResponseData.from_dict(obj["data"])
111
+ if obj.get("data") is not None
112
+ else None
113
+ ),
114
+ "success": obj.get("success"),
115
+ }
116
+ )
117
+ # store additional fields in additional_properties
118
+ for _key in obj.keys():
119
+ if _key not in cls.__properties:
120
+ _obj.additional_properties[_key] = obj.get(_key)
121
+
122
+ return _obj
@@ -0,0 +1,105 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Copy Trading REST API
5
+
6
+ OpenAPI Specification for the Binance Copy Trading REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from typing import Set
22
+ from typing_extensions import Self
23
+
24
+
25
+ class GetFuturesLeadTraderStatusResponseData(BaseModel):
26
+ """
27
+ GetFuturesLeadTraderStatusResponseData
28
+ """ # noqa: E501
29
+
30
+ is_lead_trader: Optional[StrictBool] = Field(default=None, alias="isLeadTrader")
31
+ time: Optional[StrictInt] = None
32
+ additional_properties: Dict[str, Any] = {}
33
+ __properties: ClassVar[List[str]] = ["isLeadTrader", "time"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def is_array(cls) -> bool:
52
+ return False
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of GetFuturesLeadTraderStatusResponseData from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ * Fields in `self.additional_properties` are added to the output dict.
69
+ """
70
+ excluded_fields: Set[str] = set(
71
+ [
72
+ "additional_properties",
73
+ ]
74
+ )
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # puts key-value pairs in additional_properties in the top level
82
+ if self.additional_properties is not None:
83
+ for _key, _value in self.additional_properties.items():
84
+ _dict[_key] = _value
85
+
86
+ return _dict
87
+
88
+ @classmethod
89
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
90
+ """Create an instance of GetFuturesLeadTraderStatusResponseData from a dict"""
91
+ if obj is None:
92
+ return None
93
+
94
+ if not isinstance(obj, dict):
95
+ return cls.model_validate(obj)
96
+
97
+ _obj = cls.model_validate(
98
+ {"isLeadTrader": obj.get("isLeadTrader"), "time": obj.get("time")}
99
+ )
100
+ # store additional fields in additional_properties
101
+ for _key in obj.keys():
102
+ if _key not in cls.__properties:
103
+ _obj.additional_properties[_key] = obj.get(_key)
104
+
105
+ return _obj
@@ -0,0 +1,129 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Copy Trading REST API
5
+
6
+ OpenAPI Specification for the Binance Copy Trading REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from binance_sdk_copy_trading.rest_api.models.get_futures_lead_trading_symbol_whitelist_response_data_inner import (
22
+ GetFuturesLeadTradingSymbolWhitelistResponseDataInner,
23
+ )
24
+ from typing import Set
25
+ from typing_extensions import Self
26
+
27
+
28
+ class GetFuturesLeadTradingSymbolWhitelistResponse(BaseModel):
29
+ """
30
+ GetFuturesLeadTradingSymbolWhitelistResponse
31
+ """ # noqa: E501
32
+
33
+ code: Optional[StrictStr] = None
34
+ message: Optional[StrictStr] = None
35
+ data: Optional[List[GetFuturesLeadTradingSymbolWhitelistResponseDataInner]] = None
36
+ additional_properties: Dict[str, Any] = {}
37
+ __properties: ClassVar[List[str]] = ["code", "message", "data"]
38
+
39
+ model_config = ConfigDict(
40
+ populate_by_name=True,
41
+ validate_assignment=True,
42
+ protected_namespaces=(),
43
+ )
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def is_array(cls) -> bool:
56
+ return False
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of GetFuturesLeadTradingSymbolWhitelistResponse from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ * Fields in `self.additional_properties` are added to the output dict.
73
+ """
74
+ excluded_fields: Set[str] = set(
75
+ [
76
+ "additional_properties",
77
+ ]
78
+ )
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ # override the default output from pydantic by calling `to_dict()` of each item in data (list)
86
+ _items = []
87
+ if self.data:
88
+ for _item_data in self.data:
89
+ if _item_data:
90
+ _items.append(_item_data.to_dict())
91
+ _dict["data"] = _items
92
+ # puts key-value pairs in additional_properties in the top level
93
+ if self.additional_properties is not None:
94
+ for _key, _value in self.additional_properties.items():
95
+ _dict[_key] = _value
96
+
97
+ return _dict
98
+
99
+ @classmethod
100
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
101
+ """Create an instance of GetFuturesLeadTradingSymbolWhitelistResponse from a dict"""
102
+ if obj is None:
103
+ return None
104
+
105
+ if not isinstance(obj, dict):
106
+ return cls.model_validate(obj)
107
+
108
+ _obj = cls.model_validate(
109
+ {
110
+ "code": obj.get("code"),
111
+ "message": obj.get("message"),
112
+ "data": (
113
+ [
114
+ GetFuturesLeadTradingSymbolWhitelistResponseDataInner.from_dict(
115
+ _item
116
+ )
117
+ for _item in obj["data"]
118
+ ]
119
+ if obj.get("data") is not None
120
+ else None
121
+ ),
122
+ }
123
+ )
124
+ # store additional fields in additional_properties
125
+ for _key in obj.keys():
126
+ if _key not in cls.__properties:
127
+ _obj.additional_properties[_key] = obj.get(_key)
128
+
129
+ return _obj
@@ -0,0 +1,110 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Copy Trading REST API
5
+
6
+ OpenAPI Specification for the Binance Copy Trading REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from typing import Set
22
+ from typing_extensions import Self
23
+
24
+
25
+ class GetFuturesLeadTradingSymbolWhitelistResponseDataInner(BaseModel):
26
+ """
27
+ GetFuturesLeadTradingSymbolWhitelistResponseDataInner
28
+ """ # noqa: E501
29
+
30
+ symbol: Optional[StrictStr] = None
31
+ base_asset: Optional[StrictStr] = Field(default=None, alias="baseAsset")
32
+ quote_asset: Optional[StrictStr] = Field(default=None, alias="quoteAsset")
33
+ additional_properties: Dict[str, Any] = {}
34
+ __properties: ClassVar[List[str]] = ["symbol", "baseAsset", "quoteAsset"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def is_array(cls) -> bool:
53
+ return False
54
+
55
+ @classmethod
56
+ def from_json(cls, json_str: str) -> Optional[Self]:
57
+ """Create an instance of GetFuturesLeadTradingSymbolWhitelistResponseDataInner from a JSON string"""
58
+ return cls.from_dict(json.loads(json_str))
59
+
60
+ def to_dict(self) -> Dict[str, Any]:
61
+ """Return the dictionary representation of the model using alias.
62
+
63
+ This has the following differences from calling pydantic's
64
+ `self.model_dump(by_alias=True)`:
65
+
66
+ * `None` is only added to the output dict for nullable fields that
67
+ were set at model initialization. Other fields with value `None`
68
+ are ignored.
69
+ * Fields in `self.additional_properties` are added to the output dict.
70
+ """
71
+ excluded_fields: Set[str] = set(
72
+ [
73
+ "additional_properties",
74
+ ]
75
+ )
76
+
77
+ _dict = self.model_dump(
78
+ by_alias=True,
79
+ exclude=excluded_fields,
80
+ exclude_none=True,
81
+ )
82
+ # puts key-value pairs in additional_properties in the top level
83
+ if self.additional_properties is not None:
84
+ for _key, _value in self.additional_properties.items():
85
+ _dict[_key] = _value
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of GetFuturesLeadTradingSymbolWhitelistResponseDataInner from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate(
99
+ {
100
+ "symbol": obj.get("symbol"),
101
+ "baseAsset": obj.get("baseAsset"),
102
+ "quoteAsset": obj.get("quoteAsset"),
103
+ }
104
+ )
105
+ # store additional fields in additional_properties
106
+ for _key in obj.keys():
107
+ if _key not in cls.__properties:
108
+ _obj.additional_properties[_key] = obj.get(_key)
109
+
110
+ return _obj
@@ -0,0 +1,135 @@
1
+ """
2
+ Binance Copy Trading REST API
3
+
4
+ OpenAPI Specification for the Binance Copy Trading 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
+ import requests
12
+ from typing import Optional, TypeVar
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
+ from .api.future_copy_trading_api import FutureCopyTradingApi
18
+
19
+ from .models import GetFuturesLeadTraderStatusResponse
20
+ from .models import GetFuturesLeadTradingSymbolWhitelistResponse
21
+
22
+
23
+ T = TypeVar("T")
24
+
25
+
26
+ class CopyTradingRestAPI:
27
+ def __init__(
28
+ self,
29
+ configuration: ConfigurationRestAPI,
30
+ ) -> None:
31
+ self.configuration = configuration
32
+ self._session = requests.Session()
33
+ self._signer = (
34
+ Signers.get_signer(
35
+ configuration.private_key, configuration.private_key_passphrase
36
+ )
37
+ if configuration.private_key is not None
38
+ else None
39
+ )
40
+
41
+ self._futureCopyTradingApi = FutureCopyTradingApi(
42
+ self.configuration, self._session, self._signer
43
+ )
44
+
45
+ def send_request(
46
+ self, endpoint: str, method: str, params: Optional[dict] = None
47
+ ) -> ApiResponse[T]:
48
+ """
49
+ Sends an request to the Binance REST API.
50
+
51
+ Args:
52
+ endpoint (str): The API endpoint path to send the request to.
53
+ method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
54
+ params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
55
+
56
+ Returns:
57
+ ApiResponse[T]: The API response, where T is the expected response type.
58
+ """
59
+ return send_request[T](
60
+ self._session, self.configuration, method, endpoint, params
61
+ )
62
+
63
+ def send_signed_request(
64
+ self, endpoint: str, method: str, params: Optional[dict] = None
65
+ ) -> ApiResponse[T]:
66
+ """
67
+ Sends a signed request to the Binance REST API.
68
+
69
+ Args:
70
+ endpoint (str): The API endpoint path to send the request to.
71
+ method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
72
+ params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
73
+
74
+ Returns:
75
+ ApiResponse[T]: The API response, where T is the expected response type.
76
+ """
77
+ return send_request[T](
78
+ self._session,
79
+ self.configuration,
80
+ method,
81
+ endpoint,
82
+ params,
83
+ is_signed=True,
84
+ signer=self._signer,
85
+ )
86
+
87
+ def get_futures_lead_trader_status(
88
+ self,
89
+ recv_window: Optional[int] = None,
90
+ ) -> ApiResponse[GetFuturesLeadTraderStatusResponse]:
91
+ """
92
+ Get Futures Lead Trader Status(TRADE)
93
+
94
+ Get Futures Lead Trader Status
95
+
96
+ Weight: 20
97
+
98
+ Args:
99
+ recv_window (Optional[int]):
100
+
101
+ Returns:
102
+ ApiResponse[GetFuturesLeadTraderStatusResponse]
103
+
104
+ Raises:
105
+ RequiredError: If a required parameter is missing.
106
+
107
+ """
108
+
109
+ return self._futureCopyTradingApi.get_futures_lead_trader_status(recv_window)
110
+
111
+ def get_futures_lead_trading_symbol_whitelist(
112
+ self,
113
+ recv_window: Optional[int] = None,
114
+ ) -> ApiResponse[GetFuturesLeadTradingSymbolWhitelistResponse]:
115
+ """
116
+ Get Futures Lead Trading Symbol Whitelist(USER_DATA)
117
+
118
+ Get Futures Lead Trading Symbol Whitelist
119
+
120
+ Weight: 20
121
+
122
+ Args:
123
+ recv_window (Optional[int]):
124
+
125
+ Returns:
126
+ ApiResponse[GetFuturesLeadTradingSymbolWhitelistResponse]
127
+
128
+ Raises:
129
+ RequiredError: If a required parameter is missing.
130
+
131
+ """
132
+
133
+ return self._futureCopyTradingApi.get_futures_lead_trading_symbol_whitelist(
134
+ recv_window
135
+ )