Python Documentation
Complete Python integration guide for BinaryOptionsToolsV2
Async Support
Sync Support
Type Hints
Installation
Get started with BinaryOptionsToolsV2 in Python
bash
pip install BinaryOptionsToolsV2
Quick Start
Basic usage examples for both sync and async operations
python
from BinaryOptionsToolsV2 import PocketOption
# Initialize the client
client = PocketOption(ssid="your_ssid_here")
# Get account balance
balance = client.get_balance()
print(f"Balance: ${balance}")
# Get candles data
candles = client.get_candles("EURUSD_otc", 60, 100)
for candle in candles:
print(f"Open: {candle.open}, Close: {candle.close}")
# Create a raw order
order_result = client.create_raw_order(
asset="EURUSD_otc",
amount=10.0,
action="call",
expiration=60
)
print(f"Order ID: {order_result.order_id}")
# Check win status
win_status = client.check_win(order_result.order_id)
print(f"Win status: {win_status}")
python
import asyncio
from BinaryOptionsToolsV2 import AsyncPocketOption
async def main():
# Initialize the async client
client = AsyncPocketOption(ssid="your_ssid_here")
# Get account balance
balance = await client.get_balance()
print(f"Balance: ${balance}")
# Get candles data
candles = await client.get_candles("EURUSD_otc", 60, 100)
for candle in candles:
print(f"Open: {candle.open}, Close: {candle.close}")
# Create multiple orders concurrently
orders = await asyncio.gather(
client.create_raw_order("EURUSD_otc", 10.0, "call", 60),
client.create_raw_order("GBPUSD_otc", 15.0, "put", 60),
client.create_raw_order("USDJPY_otc", 20.0, "call", 120)
)
# Check all orders
for order in orders:
print(f"Order ID: {order.order_id}")
# Run the async function
asyncio.run(main())
Core Classes
Main classes and their methods
PocketOption (Sync)
Synchronous client for PocketOption trading operations
get_balance()
Get account balance
get_candles(asset, timeframe, count)
Retrieve candlestick data
create_raw_order(asset, amount, action, expiration)
Place binary options order
check_win(order_id)
Check order win status
get_history(limit)
Get trading history
AsyncPocketOption
Asynchronous client with coroutine support
await get_balance()
Get account balance asynchronously
await get_candles(asset, timeframe, count)
Retrieve candlestick data
await create_raw_order(...)
Place order asynchronously
await stream_candles(asset, timeframe)
Stream real-time candle data
await stream_chunked(asset)
Stream chunked market data
Advanced Features
Powerful features for professional trading
Real-time Streaming
Stream live market data with async generators
async for candle in client.stream_candles("EURUSD_otc", 60):
print(f"New candle: {candle.close}")
Data Validation
Built-in validation for assets and parameters
from BinaryOptionsToolsV2 import validate_asset
is_valid = validate_asset("EURUSD_otc")
print(f"Asset valid: {is_valid}")
Comprehensive Logging
Detailed logging for debugging and monitoring
import logging
from BinaryOptionsToolsV2 import enable_logging
enable_logging(level=logging.DEBUG)
High Performance
Rust-powered backend for maximum speed
# Concurrent operations
results = await asyncio.gather(
client.get_balance(),
client.get_candles("EURUSD_otc", 60, 100)
)
Need Professional Bot Development?
Get custom trading bots built by experts at chipa.tech