binance-sdk-derivatives-trading-portfolio-margin-pro


Namebinance-sdk-derivatives-trading-portfolio-margin-pro JSON
Version 1.3.0 PyPI version JSON
download
home_pageNone
SummaryOfficial Binance Derivatives Trading Portfolio Margin Pro SDK - A lightweight library that provides a convenient interface to Binance's DerivativesTradingPortfolioMarginPro REST API and WebSocket Streams.
upload_time2025-08-22 14:49:07
maintainerNone
docs_urlNone
authorBinance
requires_python<3.14,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Binance Python Derivatives Trading (Portfolio Margin Pro) SDK

[![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci.yaml)](https://github.com/binance/binance-connector-python/actions)
[![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)
[![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
[![PyPI version](https://img.shields.io/pypi/v/binance-sdk-derivatives-trading-portfolio-margin)](https://pypi.python.org/pypi/binance-sdk-derivatives-trading-portfolio-margin)
[![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-derivatives-trading-portfolio-margin.svg)](https://pypi.org/project/binance-sdk-derivatives-trading-portfolio-margin/)
[![Python version](https://img.shields.io/pypi/pyversions/binance-sdk-derivatives-trading-portfolio-margin)](https://www.python.org/downloads/)
[![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

This is a client library for the Binance Derivatives Trading Portfolio Margin Pro SDK API, enabling developers to interact programmatically with Binance's API to suit their derivative trading needs, through three distinct endpoints:
- [REST API](./src/binance_sdk_derivatives_trading_portfolio_margin/rest_api/rest_api.py)
- [Websocket Streams](./src/binance_sdk_derivatives_trading_portfolio_margin/websocket_streams/websocket_streams.py)

## Table of Contents

- [Supported Features](#supported-features)
- [Installation](#installation)
- [Documentation](#documentation)
- [REST APIs](#rest-apis)
- [Websocket Streams](#websocket-streams)
- [Testing](#testing)
- [Migration Guide](#migration-guide)
- [Contributing](#contributing)
- [Licence](#licence)

## Supported Features

- REST API Endpoints:
  - `/fapi/*`
- Inclusion of test cases and examples for quick onboarding.

## Installation

To use this library, ensure your environment is running Python version **3.9** or later.

```bash
pip install binance-sdk-derivatives-trading-portfolio-margin-pro
```

## Documentation

For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/derivatives/portfolio-margin-pro/general-info).

### REST APIs

All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_derivatives_trading_portfolio_margin_pro/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.

```python
from binance_common.configuration import ConfigurationRestAPI
from binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL
from binance_sdk_derivatives_trading_portfolio_margin_pro.derivatives_trading_portfolio_margin_pro import DerivativesTradingPortfolioMarginPro
from binance_sdk_derivatives_trading_portfolio_margin_pro.rest_api.models import GetPortfolioMarginProAccountInfoResponse

logging.basicConfig(level=logging.INFO)
configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL)

client = DerivativesTradingPortfolioMarginPro(config_rest_api=configuration)

try:
    response = client.rest_api.get_portfolio_margin_pro_account_info()

    data: GetPortfolioMarginProAccountInfoResponse = response.data()
    logging.info(f"get_portfolio_margin_pro_account_info() response: {data}")
except Exception as e:
    logging.error(f"get_portfolio_margin_pro_account_info() error: {e}")
```

More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.

#### Configuration Options

The REST API supports the following advanced configuration options:

- `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
- `proxy`: Proxy configuration:
  - `host`: Proxy server hostname.
  - `port`: Proxy server port.
  - `protocol`: Proxy protocol (http or https).
  - `auth`: Proxy authentication credentials:
    - `username`: Proxy username.
    - `password`: Proxy password.
- `keep_alive`: Enable HTTP keep-alive (default: true).
- `compression`: Enable response compression (default: true).
- `retries`: Number of retry attempts for failed requests (default: 3).
- `backoff`: Delay in milliseconds between retries (default: 1000 ms).
- `https_agent`: Custom HTTPS agent for advanced TLS configuration.
- `private_key`: RSA or ED25519 private key for authentication.
- `private_key_passphrase`: Passphrase for the private key, if encrypted.

##### Timeout

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.

##### Proxy

The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.

##### Keep-Alive

Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.

##### Compression

Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.

##### Retries

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.

##### HTTPS Agent

Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.

##### Key Pair Based Authentication

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.

##### Certificate Pinning

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.

#### Error Handling

The REST API provides detailed error types to help you handle issues effectively:

- `ClientError`: Represents an error that occurred in the SDK client.
- `RequiredError`: Thrown when a required parameter is missing or undefined.
- `UnauthorizedError`: Indicates missing or invalid authentication credentials.
- `ForbiddenError`: Access to the requested resource is forbidden.
- `TooManyRequestsError`: Rate limit exceeded.
- `RateLimitBanError`: IP address banned for exceeding rate limits.
- `ServerError`: Internal server error, optionally includes a status code.
- `NetworkError`: Issues with network connectivity.
- `NotFoundError`: Resource not found.
- `BadRequestError`: Invalid request or one that cannot be served.

See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.

If `base_path` is not provided, it defaults to `https://api.binance.com`.

### Websocket Streams

WebSocket Streams in `derivatives-trading-portfolio-margin-pro` is used for subscribing to user data streams. Use the [websocket-streams](./src/binance_sdk_derivatives_trading_portfolio_margin_pro/websocket_streams/websocket_streams.py) module to interact with it.

#### Configuration Options

The WebSocket Streams API supports the following advanced configuration options:

- `reconnect_delay`: Delay (ms) between reconnections.
- `compression`: Enable response compression.
- `mode`: Choose between `single` and `pool` connection modes.
  - `single`: A single WebSocket connection.
  - `pool`: A pool of WebSocket connections.
- `pool_size`: Define the number of WebSocket connections in pool mode.
- `https_agent`: Custom HTTPS agent for advanced TLS configuration.
- `user_agent`: Custom user agent string for WebSocket Streams.

#### Subscribe to User Data Streams

You can consume the user data stream, which sends account-level events such as account and order updates. First create a listen-key via REST API; then:
```python
import asyncio
import logging

from binance_common.configuration import ConfigurationWebSocketStreams
from binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL
from binance_sdk_derivatives_trading_portfolio_margin_pro.derivatives_trading_portfolio_margin_pro import DerivativesTradingPortfolioMarginPro

logging.basicConfig(level=logging.INFO)

configuration_ws_streams = ConfigurationWebSocketStreams(
    stream_url=os.getenv("STREAM_URL", DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL)
)
client = DerivativesTradingPortfolioMarginPro(config_ws_streams=configuration_ws_streams)

try:
    connection = await client.websocket_streams.create_connection()
    stream = connection.user_data(listenKey="listen-key")
    stream.on("message", lambda data: {
        match data["e"]:
            case "riskLevelChange":
                print(f"Risk level change stream: {data}")
            case _:
                print(f"Unknown stream: {data}")
    })
except Exception as e:
    logging.error(f"Error in user data stream: {e}")
```

#### Unsubscribing from Streams

You can unsubscribe from specific WebSocket streams using the `unsubscribe` method. This is useful for managing active subscriptions without closing the connection.

```python
import asyncio
import logging

from binance_common.configuration import ConfigurationWebSocketStreams
from binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL
from binance_sdk_derivatives_trading_portfolio_margin_pro.derivatives_trading_portfolio_margin_pro import DerivativesTradingPortfolioMarginPro

logging.basicConfig(level=logging.INFO)

configuration_ws_streams = ConfigurationWebSocketStreams(
    stream_url=os.getenv("STREAM_URL", DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL)
)
client = DerivativesTradingPortfolioMarginPro(config_ws_streams=configuration_ws_streams)

connection = None
try:
    connection = await client.websocket_streams.create_connection()
    stream = connection.user_data(listenKey="listen-key")
    stream.on("message", lambda data: {
        match data["e"]:
            case "riskLevelChange":
                print(f"Risk level change stream: {data}")
            case _:
                print(f"Unknown stream: {data}")
    })

    await asyncio.sleep(10)
    await stream.unsubscribe()
except Exception as e:
    logging.error(f"Error in user data stream: {e}")
finally:
    if connection:
        await connection.close_connection(close_session=True)
```

If `wsURL` is not provided, it defaults to `wss://fstream.binance.com/pm-classic`.

### Automatic Connection Renewal

The WebSocket connection is automatically renewed for both WebSocket API and WebSocket Streams connections, before the 24 hours expiration of the API key. This ensures continuous connectivity.

## Testing

To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:

```bash
poetry install
poetry run pytest ./tests
```

The tests cover:
* REST API endpoints
* WebSocket Streams endpoints
* Error handling
* Edge cases

## Migration Guide

If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_derivatives_trading_portfolio_margin_pro_sdk.md) for detailed steps.

## Contributing

Contributions are welcome!

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.

To contribute:

1. Open a GitHub issue describing your suggestion or the bug you've identified.
2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.

Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.

Thank you for your contributions!

## Licence

This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "binance-sdk-derivatives-trading-portfolio-margin-pro",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Binance",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/7c/1e/7a7ac2514233cb9a9692208044883f0fb8166851db07d44b6f707b087c48/binance_sdk_derivatives_trading_portfolio_margin_pro-1.3.0.tar.gz",
    "platform": null,
    "description": "# Binance Python Derivatives Trading (Portfolio Margin Pro) SDK\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci.yaml)](https://github.com/binance/binance-connector-python/actions)\n[![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)\n[![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)\n[![PyPI version](https://img.shields.io/pypi/v/binance-sdk-derivatives-trading-portfolio-margin)](https://pypi.python.org/pypi/binance-sdk-derivatives-trading-portfolio-margin)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-derivatives-trading-portfolio-margin.svg)](https://pypi.org/project/binance-sdk-derivatives-trading-portfolio-margin/)\n[![Python version](https://img.shields.io/pypi/pyversions/binance-sdk-derivatives-trading-portfolio-margin)](https://www.python.org/downloads/)\n[![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nThis is a client library for the Binance Derivatives Trading Portfolio Margin Pro SDK API, enabling developers to interact programmatically with Binance's API to suit their derivative trading needs, through three distinct endpoints:\n- [REST API](./src/binance_sdk_derivatives_trading_portfolio_margin/rest_api/rest_api.py)\n- [Websocket Streams](./src/binance_sdk_derivatives_trading_portfolio_margin/websocket_streams/websocket_streams.py)\n\n## Table of Contents\n\n- [Supported Features](#supported-features)\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [REST APIs](#rest-apis)\n- [Websocket Streams](#websocket-streams)\n- [Testing](#testing)\n- [Migration Guide](#migration-guide)\n- [Contributing](#contributing)\n- [Licence](#licence)\n\n## Supported Features\n\n- REST API Endpoints:\n  - `/fapi/*`\n- Inclusion of test cases and examples for quick onboarding.\n\n## Installation\n\nTo use this library, ensure your environment is running Python version **3.9** or later.\n\n```bash\npip install binance-sdk-derivatives-trading-portfolio-margin-pro\n```\n\n## Documentation\n\nFor detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/derivatives/portfolio-margin-pro/general-info).\n\n### REST APIs\n\nAll REST API endpoints are available through the [`rest_api`](./src/binance_sdk_derivatives_trading_portfolio_margin_pro/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.\n\n```python\nfrom binance_common.configuration import ConfigurationRestAPI\nfrom binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL\nfrom binance_sdk_derivatives_trading_portfolio_margin_pro.derivatives_trading_portfolio_margin_pro import DerivativesTradingPortfolioMarginPro\nfrom binance_sdk_derivatives_trading_portfolio_margin_pro.rest_api.models import GetPortfolioMarginProAccountInfoResponse\n\nlogging.basicConfig(level=logging.INFO)\nconfiguration = ConfigurationRestAPI(api_key=\"your-api-key\", api_secret=\"your-api-secret\", base_path=DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL)\n\nclient = DerivativesTradingPortfolioMarginPro(config_rest_api=configuration)\n\ntry:\n    response = client.rest_api.get_portfolio_margin_pro_account_info()\n\n    data: GetPortfolioMarginProAccountInfoResponse = response.data()\n    logging.info(f\"get_portfolio_margin_pro_account_info() response: {data}\")\nexcept Exception as e:\n    logging.error(f\"get_portfolio_margin_pro_account_info() error: {e}\")\n```\n\nMore examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.\n\n#### Configuration Options\n\nThe REST API supports the following advanced configuration options:\n\n- `timeout`: Timeout for requests in milliseconds (default: 1000 ms).\n- `proxy`: Proxy configuration:\n  - `host`: Proxy server hostname.\n  - `port`: Proxy server port.\n  - `protocol`: Proxy protocol (http or https).\n  - `auth`: Proxy authentication credentials:\n    - `username`: Proxy username.\n    - `password`: Proxy password.\n- `keep_alive`: Enable HTTP keep-alive (default: true).\n- `compression`: Enable response compression (default: true).\n- `retries`: Number of retry attempts for failed requests (default: 3).\n- `backoff`: Delay in milliseconds between retries (default: 1000 ms).\n- `https_agent`: Custom HTTPS agent for advanced TLS configuration.\n- `private_key`: RSA or ED25519 private key for authentication.\n- `private_key_passphrase`: Passphrase for the private key, if encrypted.\n\n##### Timeout\n\nYou 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.\n\n##### Proxy\n\nThe REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.\n\n##### Keep-Alive\n\nEnable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.\n\n##### Compression\n\nEnable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.\n\n##### Retries\n\nConfigure 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.\n\n##### HTTPS Agent\n\nCustomize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.\n\n##### Key Pair Based Authentication\n\nThe 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.\n\n##### Certificate Pinning\n\nTo 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.\n\n#### Error Handling\n\nThe REST API provides detailed error types to help you handle issues effectively:\n\n- `ClientError`: Represents an error that occurred in the SDK client.\n- `RequiredError`: Thrown when a required parameter is missing or undefined.\n- `UnauthorizedError`: Indicates missing or invalid authentication credentials.\n- `ForbiddenError`: Access to the requested resource is forbidden.\n- `TooManyRequestsError`: Rate limit exceeded.\n- `RateLimitBanError`: IP address banned for exceeding rate limits.\n- `ServerError`: Internal server error, optionally includes a status code.\n- `NetworkError`: Issues with network connectivity.\n- `NotFoundError`: Resource not found.\n- `BadRequestError`: Invalid request or one that cannot be served.\n\nSee the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.\n\nIf `base_path` is not provided, it defaults to `https://api.binance.com`.\n\n### Websocket Streams\n\nWebSocket Streams in `derivatives-trading-portfolio-margin-pro` is used for subscribing to user data streams. Use the [websocket-streams](./src/binance_sdk_derivatives_trading_portfolio_margin_pro/websocket_streams/websocket_streams.py) module to interact with it.\n\n#### Configuration Options\n\nThe WebSocket Streams API supports the following advanced configuration options:\n\n- `reconnect_delay`: Delay (ms) between reconnections.\n- `compression`: Enable response compression.\n- `mode`: Choose between `single` and `pool` connection modes.\n  - `single`: A single WebSocket connection.\n  - `pool`: A pool of WebSocket connections.\n- `pool_size`: Define the number of WebSocket connections in pool mode.\n- `https_agent`: Custom HTTPS agent for advanced TLS configuration.\n- `user_agent`: Custom user agent string for WebSocket Streams.\n\n#### Subscribe to User Data Streams\n\nYou can consume the user data stream, which sends account-level events such as account and order updates. First create a listen-key via REST API; then:\n```python\nimport asyncio\nimport logging\n\nfrom binance_common.configuration import ConfigurationWebSocketStreams\nfrom binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL\nfrom binance_sdk_derivatives_trading_portfolio_margin_pro.derivatives_trading_portfolio_margin_pro import DerivativesTradingPortfolioMarginPro\n\nlogging.basicConfig(level=logging.INFO)\n\nconfiguration_ws_streams = ConfigurationWebSocketStreams(\n    stream_url=os.getenv(\"STREAM_URL\", DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL)\n)\nclient = DerivativesTradingPortfolioMarginPro(config_ws_streams=configuration_ws_streams)\n\ntry:\n    connection = await client.websocket_streams.create_connection()\n    stream = connection.user_data(listenKey=\"listen-key\")\n    stream.on(\"message\", lambda data: {\n        match data[\"e\"]:\n            case \"riskLevelChange\":\n                print(f\"Risk level change stream: {data}\")\n            case _:\n                print(f\"Unknown stream: {data}\")\n    })\nexcept Exception as e:\n    logging.error(f\"Error in user data stream: {e}\")\n```\n\n#### Unsubscribing from Streams\n\nYou can unsubscribe from specific WebSocket streams using the `unsubscribe` method. This is useful for managing active subscriptions without closing the connection.\n\n```python\nimport asyncio\nimport logging\n\nfrom binance_common.configuration import ConfigurationWebSocketStreams\nfrom binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL\nfrom binance_sdk_derivatives_trading_portfolio_margin_pro.derivatives_trading_portfolio_margin_pro import DerivativesTradingPortfolioMarginPro\n\nlogging.basicConfig(level=logging.INFO)\n\nconfiguration_ws_streams = ConfigurationWebSocketStreams(\n    stream_url=os.getenv(\"STREAM_URL\", DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL)\n)\nclient = DerivativesTradingPortfolioMarginPro(config_ws_streams=configuration_ws_streams)\n\nconnection = None\ntry:\n    connection = await client.websocket_streams.create_connection()\n    stream = connection.user_data(listenKey=\"listen-key\")\n    stream.on(\"message\", lambda data: {\n        match data[\"e\"]:\n            case \"riskLevelChange\":\n                print(f\"Risk level change stream: {data}\")\n            case _:\n                print(f\"Unknown stream: {data}\")\n    })\n\n    await asyncio.sleep(10)\n    await stream.unsubscribe()\nexcept Exception as e:\n    logging.error(f\"Error in user data stream: {e}\")\nfinally:\n    if connection:\n        await connection.close_connection(close_session=True)\n```\n\nIf `wsURL` is not provided, it defaults to `wss://fstream.binance.com/pm-classic`.\n\n### Automatic Connection Renewal\n\nThe WebSocket connection is automatically renewed for both WebSocket API and WebSocket Streams connections, before the 24 hours expiration of the API key. This ensures continuous connectivity.\n\n## Testing\n\nTo run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:\n\n```bash\npoetry install\npoetry run pytest ./tests\n```\n\nThe tests cover:\n* REST API endpoints\n* WebSocket Streams endpoints\n* Error handling\n* Edge cases\n\n## Migration Guide\n\nIf you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_derivatives_trading_portfolio_margin_pro_sdk.md) for detailed steps.\n\n## Contributing\n\nContributions are welcome!\n\nSince 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.\n\nTo contribute:\n\n1. Open a GitHub issue describing your suggestion or the bug you've identified.\n2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.\n\nPlease ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.\n\nThank you for your contributions!\n\n## Licence\n\nThis project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Official Binance Derivatives Trading Portfolio Margin Pro SDK - A lightweight library that provides a convenient interface to Binance's DerivativesTradingPortfolioMarginPro REST API and WebSocket Streams.",
    "version": "1.3.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc702eef84822f7d444201bc7d87aa9806a2ed360bb6edcb1d89a5e27901211f",
                "md5": "8a70eab7aa4a019833339ad3b1498fd3",
                "sha256": "9b4cc36cd998227cb0cc9fdd4ab9904a13a449ed752ac623df12eb7489462f90"
            },
            "downloads": -1,
            "filename": "binance_sdk_derivatives_trading_portfolio_margin_pro-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a70eab7aa4a019833339ad3b1498fd3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.9",
            "size": 74564,
            "upload_time": "2025-08-22T14:49:06",
            "upload_time_iso_8601": "2025-08-22T14:49:06.039369Z",
            "url": "https://files.pythonhosted.org/packages/bc/70/2eef84822f7d444201bc7d87aa9806a2ed360bb6edcb1d89a5e27901211f/binance_sdk_derivatives_trading_portfolio_margin_pro-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c1e7a7ac2514233cb9a9692208044883f0fb8166851db07d44b6f707b087c48",
                "md5": "ec7e3fa9e2e31a842c28ed59025883c2",
                "sha256": "deeb90a3ae580205d0a0767546c882df936e96d858b2d65339b007170dc64d25"
            },
            "downloads": -1,
            "filename": "binance_sdk_derivatives_trading_portfolio_margin_pro-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ec7e3fa9e2e31a842c28ed59025883c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.9",
            "size": 26598,
            "upload_time": "2025-08-22T14:49:07",
            "upload_time_iso_8601": "2025-08-22T14:49:07.618038Z",
            "url": "https://files.pythonhosted.org/packages/7c/1e/7a7ac2514233cb9a9692208044883f0fb8166851db07d44b6f707b087c48/binance_sdk_derivatives_trading_portfolio_margin_pro-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-22 14:49:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "binance-sdk-derivatives-trading-portfolio-margin-pro"
}
        
Elapsed time: 0.58216s