BinaryOptionsToolsV2 - Python Package
✨ ChipaEditor — AI-powered algorithmic trading strategy builder: describe your edge, get working CHTL code, backtest it, deploy it. Free to start.
📈 Trade crypto perps, spot & margin on ChipaX — demo mode available.
Python bindings for BinaryOptionsTools - A powerful library for automated binary options trading on PocketOption platform.
Current Status
Available Features:
- Authentication: Secure connection with automated SSID sanitization.
- Trading: Instant Buy/Sell operations with real-time result tracking.
- Account: Balance retrieval, opened/closed deals management.
- Market Data: Real-time candle subscriptions (tick to 300s), historical data fetching.
- Resilience: Automated asset gathering, payout synchronization, and robust reconnection logic.
- Advanced: Raw WebSocket handler API and custom message validators.
How to install
Option A: Install from Source (Recommended)
# Clone from GitHub
git clone https://github.com/ChipaDevTeam/BinaryOptionsTools-v2.git
# Or clone from GitLab
# git clone https://gitlab.chipatrade.com/chipadevorg/BinaryOptionsTools-v2.git
cd BinaryOptionsTools-v2/python
git fetch --tags
git checkout "$(git tag -l --sort=-v:refname | head -n 1)"
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install .
Option B: Install from Source Automatically
Requires git, a C toolchain, and a Rust toolchain.
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install via GitHub
uv pip install "git+https://github.com/ChipaDevTeam/BinaryOptionsTools-v2.git@master#subdirectory=python"
# Or install via GitLab
# uv pip install "git+https://gitlab.chipatrade.com/chipadevorg/BinaryOptionsTools-v2.git@master#subdirectory=python"
Supported OS
Currently supported on Windows, Linux, and macOS.
Supported Python versions
Supports Python 3.8 to 3.13.
Docs
Comprehensive Documentation for BinaryOptionsToolsV2
__init__.py
This file initializes the Python module and organizes the imports for both synchronous and asynchronous functionality.
Key Details
- Imports
BinaryOptionsToolsV2: Imports all elements and documentation from the Rust module. - Includes Submodules: Imports and exposes
pocketoptionandtracingmodules for user convenience.
Purpose
Serves as the entry point for the package, exposing all essential components of the library.
Inside the pocketoption folder there are 2 main files
asynchronous.py
This file implements the PocketOptionAsync class, which provides an asynchronous interface to interact with Pocket Option.
Key Features of PocketOptionAsync
- Trade Operations:
buy(): Places a buy trade asynchronously.sell(): Places a sell trade asynchronously.check_win(): Checks the outcome of a trade ('win', 'draw', or 'loss').
- Market Data:
get_candles_live(): Streams real-time gap-free candles (closed and currently forming) with historical backfill.candles()/get_candles(): (Deprecated) Fetches historical candles (delegates toget_candles_live).history(): Retrieves recent historical data for a specific asset through the dedicated history endpoint.compile_candles(): Compiles custom-period candlesticks from base tick data using strict UTC boundaries.
- Account Management:
balance(): Returns the current account balance.opened_deals(): Lists all open trades.closed_deals(): Lists all closed trades.payout(): Returns payout percentages.
- Real-Time Data:
subscribe_symbol(): Provides an asynchronous iterator for real-time candle updates.subscribe_symbol_timed(): Provides an asynchronous iterator for timed real-time candle updates.subscribe_symbol_chunked(): Provides an asynchronous iterator for chunked real-time candle updates.
- Pending Orders:
open_pending_order(): Places a pending limit order.cancel_pending_order(): Cancels a specific pending order by ticket ID.cancel_pending_orders(): Cancels multiple pending orders in a batch.get_pending_deals(): Lists all active pending orders.get_pending_deal(): Retrieves details of a specific pending order.
- Server Information:
server_time(): Gets the current server time.
- Connection Management:
reconnect(): Manually reconnect to the server.shutdown(): Properly close the connection.
- Advanced / Utilities:
wait_for_assets(): Awaits until the assets list is fully loaded from the server.is_demo(): Returns whether the current session is a demo account.is_connected(): Returns connection status.create_raw_handler(): Sets up direct raw WebSocket message listeners with custom validators. Helper Class -AsyncSubscription
Facilitates asynchronous iteration over live data streams, enabling non-blocking operations.
Example Usage
from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync
import asyncio
async def main():
# Initialize the client
client = PocketOptionAsync(ssid="your-session-id")
# Get account balance
balance = await client.balance()
print(f"Account Balance: ${balance}")
# Place a buy trade
trade_id, deal = await client.buy("EURUSD_otc", 1.0, 60)
print(f"Trade placed: {deal}")
# Check result
result = await client.check_win(trade_id)
print(f"Trade result: {result}")
# Subscribe to real-time data
async for candle in client.subscribe_symbol("EURUSD_otc"):
print(f"New candle: {candle}")
break # Just print one candle for demo
asyncio.run(main())
synchronous.py
This file implements the PocketOption class, a synchronous wrapper around the asynchronous interface provided by PocketOptionAsync.
Key Features of PocketOption
- Trade Operations:
buy(): Places a buy trade using synchronous execution.sell(): Places a sell trade.check_win(): Checks the trade outcome synchronously.
- Market Data:
get_candles_live(): Streams real-time gap-free candles (closed and currently forming) with historical backfill.candles()/get_candles(): (Deprecated) Fetches historical candles (delegates toget_candles_live).history(): Retrieves recent historical data for a specific asset through the dedicated history endpoint.compile_candles(): Compiles custom-period candlesticks from base tick data using strict UTC boundaries.
- Account Management:
balance(): Retrieves account balance.opened_deals(): Lists all open trades.closed_deals(): Lists all closed trades.payout(): Returns payout percentages.
- Real-Time Data:
subscribe_symbol(): Provides a synchronous iterator for live data updates.subscribe_symbol_timed(): Provides a synchronous iterator for timed real-time candle updates.subscribe_symbol_chunked(): Provides a synchronous iterator for chunked real-time candle updates.
- Pending Orders:
open_pending_order(): Places a pending limit order.cancel_pending_order(): Cancels a specific pending order by ticket ID.cancel_pending_orders(): Cancels multiple pending orders in a batch.get_pending_deals(): Lists all active pending orders.get_pending_deal(): Retrieves details of a specific pending order.
- Server Information:
server_time(): Gets the current server time.
- Connection Management:
reconnect(): Manually reconnect to the server.shutdown(): Properly close the connection.
- Advanced / Utilities:
wait_for_assets(): Awaits until the assets list is fully loaded from the server.is_demo(): Returns whether the current session is a demo account.is_connected(): Returns connection status.create_raw_handler(): Sets up direct raw WebSocket message listeners with custom validators. Helper Class -SyncSubscription
Allows synchronous iteration over real-time data streams for compatibility with simpler scripts.
Example Usage
from BinaryOptionsToolsV2.pocketoption import PocketOption
import time
# Initialize the client
client = PocketOption(ssid="your-session-id")
# Get account balance
balance = client.balance()
print(f"Account Balance: ${balance}")
# Place a buy trade
trade_id, deal = client.buy("EURUSD_otc", 1.0, 60)
print(f"Trade placed: {deal}")
# Check result
result = client.check_win(trade_id)
print(f"Trade result: {result}")
# Subscribe to real-time data
stream = client.subscribe_symbol("EURUSD_otc")
for candle in stream:
print(f"New candle: {candle}")
break # Just print one candle for demo
- Differences Between PocketOption and PocketOptionAsync
| Feature | PocketOption (Synchronous) | PocketOptionAsync (Asynchronous) |
|---|---|---|
| Execution Type | Blocking | Non-blocking |
| Use Case | Simpler scripts | High-frequency or real-time tasks |
| Performance | Slower for concurrent tasks | Scales well with concurrent operations |
Tracing
The tracing module provides functionality to initialize and manage logging for the application.
Key Functions of Tracing
- start_logs():
- Initializes the logging system for the application.
- Arguments:
path(str): Path where log files will be stored.level(str): Logging level (default is "DEBUG").terminal(bool): Whether to display logs in the terminal (default is True).
- Returns: None
- Raises: Exception if there's an error starting the logging system.
Example Usage
from BinaryOptionsToolsV2.tracing import start_logs
# Initialize logging
start_logs(path="logs/", level="INFO", terminal=True)
📖 Detailed Examples
Basic Trading Example (Synchronous)
from BinaryOptionsToolsV2.pocketoption import PocketOption
import time
def main():
# Initialize client
client = PocketOption(ssid="your-session-id")
# Get balance
balance = client.balance()
print(f"Current Balance: ${balance}")
# Place a buy trade on EURUSD for 60 seconds with $1
trade_id, deal = client.buy(asset="EURUSD_otc", amount=1.0, time=60)
print(f"Trade ID: {trade_id}")
print(f"Deal Data: {deal}")
# Wait for trade to complete (60 seconds)
time.sleep(65)
# Check the result
result = client.check_win(trade_id)
print(f"Trade Result: {result['result']}") # 'win', 'loss', or 'draw'
print(f"Profit: ${result.get('profit', 0)}")
if __name__ == "__main__":
main()
Basic Trading Example (Asynchronous)
from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync
import asyncio
async def main():
# Initialize client
client = PocketOptionAsync(ssid="your-session-id")
# Get balance
balance = await client.balance()
print(f"Current Balance: ${balance}")
# Place a buy trade on EURUSD for 60 seconds with $1
trade_id, deal = await client.buy(asset="EURUSD_otc", amount=1.0, time=60)
print(f"Trade ID: {trade_id}")
print(f"Deal Data: {deal}")
# Wait for trade to complete (60 seconds)
await asyncio.sleep(65)
# Check the result
result = await client.check_win(trade_id)
print(f"Trade Result: {result['result']}") # 'win', 'loss', or 'draw'
print(f"Profit: ${result.get('profit', 0)}")
if __name__ == "__main__":
asyncio.run(main())
Retrieving Historical & Live Candles (Recommended)
To fetch historical backfill and stream gap-free live candles in real-time, use get_candles_live(). This method is available in both async and sync clients. It buffers incoming ticks, merges historical data, and yields updated candles (both closed candles and the forming candle).
Async Example:
from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync
import asyncio
async def main():
async with PocketOptionAsync(ssid="your-session-id") as client:
# Stream live candles (yields a tuple: closed_candles list, current_forming_candle dict)
async for closed, forming in client.get_candles_live("EURUSD_otc", period=60, hours=2.0, max_rows=100):
print(f"Closed candles count: {len(closed)}")
if forming:
print(f"Forming Candle Close Price: {forming['close']}")
if __name__ == "__main__":
asyncio.run(main())
Sync Example:
from BinaryOptionsToolsV2.pocketoption import PocketOption
client = PocketOption(ssid="your-session-id")
# Iterate over live candles
for closed, forming in client.get_candles_live("EURUSD_otc", period=60, hours=2.0, max_rows=100):
print(f"Closed candles count: {len(closed)}")
if forming:
print(f"Forming Candle Close Price: {forming['close']}")
Deprecated Candle Methods
The duplicate candle functions candles() and get_candles() are deprecated and will be removed in a future release.
- Reason: They only fetch closed historical candles, can introduce gaps when called sequentially during live trading, and do not include the currently forming candle.
- Compatibility: To preserve backward compatibility, these methods have been redirected to run
get_candles_live()internally under the hood (returning the first yielded list of closed candles).
Compiling Custom Period Candles
from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync
import asyncio
async def main():
client = PocketOptionAsync(ssid="your-session-id")
# Compile 5-minute candles from 1-minute base data
# Parameters: asset, custom_period, lookback_period
candles = await client.compile_candles("EURUSD_otc", 60, 300)
print(f"Compiled {len(candles)} custom candles")
if candles:
print("Latest compiled candle:", candles[-1])
if __name__ == "__main__":
asyncio.run(main())
Real-Time Data Subscription (Synchronous)
from BinaryOptionsToolsV2.pocketoption import PocketOption
import time
def main():
client = PocketOption(ssid="your-session-id")
# Subscribe to real-time candle data
stream = client.subscribe_symbol("EURUSD_otc")
print("Listening for real-time candles...")
for candle in stream:
print(f"Time: {candle.get('time')}")
print(f"Open: {candle.get('open')}")
print(f"High: {candle.get('high')}")
print(f"Low: {candle.get('low')}")
print(f"Close: {candle.get('close')}")
print("---")
if __name__ == "__main__":
main()
Real-Time Data Subscription (Asynchronous)
from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync
import asyncio
async def main():
client = PocketOptionAsync(ssid="your-session-id")
# Subscribe to real-time candle data
async for candle in client.subscribe_symbol("EURUSD_otc"):
print(f"Time: {candle.get('time')}")
print(f"Open: {candle.get('open')}")
print(f"High: {candle.get('high')}")
print(f"Low: {candle.get('low')}")
print(f"Close: {candle.get('close')}")
print("---")
if __name__ == "__main__":
asyncio.run(main())
Checking Opened Deals
from BinaryOptionsToolsV2.pocketoption import PocketOption
import time
def main():
client = PocketOption(ssid="your-session-id")
# Get all opened deals
opened_deals = client.opened_deals()
if opened_deals:
print(f"You have {len(opened_deals)} opened deals:")
for deal in opened_deals:
print(f" - Trade ID: {deal.get('id')}")
print(f" Asset: {deal.get('asset')}")
print(f" Amount: ${deal.get('amount')}")
print(f" Direction: {deal.get('action')}")
else:
print("No opened deals")
if __name__ == "__main__":
main()
🔑 Important Notes
Connection Initialization
The client automatically establishes a connection during initialization. You can also manually manage the connection using connect(), disconnect(), and reconnect() methods.
# Asynchronous
client = PocketOptionAsync(ssid="your-session-id")
# Connection is already established here
# Manual control
await client.disconnect()
await client.connect()
# Synchronous
client_sync = PocketOption(ssid="your-session-id")
# Connection is already established here
# Manual control
client_sync.disconnect()
client_sync.connect()
Getting Your SSID
- Go to PocketOption
- Open Developer Tools (F12)
- Go to Application/Storage → Cookies
- Find the cookie named
ssid - Copy its value
Supported Assets
Common assets include:
EURUSD_otc- Euro/US Dollar (OTC)GBPUSD_otc- British Pound/US Dollar (OTC)USDJPY_otc- US Dollar/Japanese Yen (OTC)AUDUSD_otc- Australian Dollar/US Dollar (OTC)- And many more...
Use _otc suffix for over-the-counter (24/7 available) assets.
📚 Additional Resources
- Full Examples: docs/examples/python
- API Documentation: https://chipatrade.gitlab.io/chipadevorg/BinaryOptionsTools-v2/python.html
- Discord Community: Join us
⚠️ Risk Warning
Trading binary options involves substantial risk and may result in the loss of all invested capital. This library is provided for educational purposes only. Always trade responsibly and never invest more than you can afford to lose.
Metadata
Release files for BinaryOptionsToolsV2 0.2.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| binaryoptionstoolsv2-0.2.14.tar.gz | 299.0 kB | Without provenance | Details |
Built distributions (wheels)
Total release size: 40.4 MB
Release files / binaryoptionstoolsv2-0.2.14.tar.gz
| Download URL | binaryoptionstoolsv2-0.2.14.tar.gz |
|---|---|
| Size | 299.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8edb1d082814d8738eca14d325148663fa8005880e61cf8a816aaff2412729b4
|
|
BLAKE2b-256 checksum How to use checksums |
1df95b9c704010368b4d28e4413e1c8a4a1f556583d749a842587b7c628b7fd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-win_amd64.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4cd27c8b85294fb36e732fcbf78f7b090c5c81890a7e10992a1819ba6775c36f
|
|
BLAKE2b-256 checksum How to use checksums |
9722aec15591ebd2e0e9c142f620bac83cd3924f44a70e1191d394cd93668cdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-win32.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-win32.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.10 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
82d59c923abe8646011bef8c155468c566352f1259fb1d6e00a1cd4e6c010484
|
|
BLAKE2b-256 checksum How to use checksums |
0aba77218a32718214e3e7bead1ce6e07b6f31fddd0b0760395c671d9329766e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-musllinux_1_1_x86_64.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-musllinux_1_1_x86_64.whl |
|---|---|
| Size | 5.0 MB |
| Tags | CPython 3.10 Linux musl 1.1+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
73eb68870399cf821c48cc26f88bb7041d9e9784c529b53ae7c250d8d05fcc38
|
|
BLAKE2b-256 checksum How to use checksums |
3b5954ead1ed4ba266224f0b37e3fc6ac4cdd615d184932d39e6468464a3b2a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-musllinux_1_1_aarch64.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-musllinux_1_1_aarch64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.10 Linux musl 1.1+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
777f04d855c944f54cd9b1fe9f30792a7ce6689c38df73acbcb4ba2c8e7f0cb2
|
|
BLAKE2b-256 checksum How to use checksums |
fb50c886cd2914c99beb6c9836133c10fdf640b1cb72b56a43b5b281a7eff1dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.0 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9cf9f4da37e2cc27561e73cf1fd065754c6569f4b7798589a5de37f6a9318acb
|
|
BLAKE2b-256 checksum How to use checksums |
b4f9e23e641cd324744244a7f89d0563bd700ef3f18954b5afccef0779a67ab6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-manylinux_2_28_armv7l.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-manylinux_2_28_armv7l.whl |
|---|---|
| Size | 4.1 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
034b63354de1644ed1cb69a18f4c4c582a08f827e29558dacecef2afc3b7e6bd
|
|
BLAKE2b-256 checksum How to use checksums |
8bd6285784f070aede11de37d4f624bd80e864d29f7c400baed876c32a162542
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
c4bbc9244768bf8907ee41ce605ef71aff75619fb4db3d11d04bfcdadb4e0e3b
|
|
BLAKE2b-256 checksum How to use checksums |
cf7275dba7be42b8fb83a955f380df5618b922a9f7be7dedc46477f7df882ea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / binaryoptionstoolsv2-0.2.14-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | binaryoptionstoolsv2-0.2.14-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2a38d905778d2d5368b2acc90400528283049540e7b54d7450d86cce6cee8386
|
|
BLAKE2b-256 checksum How to use checksums |
0799439240c8cc4634acb98139ae9a59c8fd93456294a3520d3a6f76480aaad7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for BinaryOptionsToolsV2 0.2.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.