Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

836 Commits

Repository files navigation

BinaryOptionsTools V2

✨ Build with Chipa Editor — the AI-powered strategy editor for Traders. Try it free!

DiscordPython VersionRustLicense

A high-performance, cross-platform package for automating binary options trading. Built with Rust for speed and memory safety, featuring Python bindings for ease of use.


Support the Development

This project is maintained by the ChipaDevTeam. Your support helps keep the updates coming.

Support ChannelLink
PayPalSupport ChipaDevTeam
PocketOption (Six)Join via Six's Affiliate Link
PocketOption (Chipa)Join via Chipa's Affiliate Link

Repositories

This project is mirrored and synchronized across both GitLab and GitHub:


Table of Contents


Known Bugs

Automatic email & password SSID fetching:

  • 2FA may not be supported

Overview

BinaryOptionsTools v2 is a complete rewrite of the original library. It bridges the gap between low-level performance and high-level usability.

Key Highlights

  • Rust Core: Maximum performance, concurrency, and memory safety.
  • Python Bindings: Seamless integration with the Python ecosystem via PyO3.
  • WebSocket Native: Real-time market data streaming and instant trade execution.
  • Robust Connectivity: Automatic reconnection, keep-alive monitoring, and robust error handling.
  • Type Safety: Strong typing across both Rust and Python interfaces.

Supported Platforms

  • PocketOption (Full Support: Quick Trading, Pending Orders, Assets, History)
  • ExpertOption (Alpha/Beta: Account Info, Keep-Alive, WebSocket Core)
  • IQ Option (On Roadmap)

Features

Trading and Account

  • Execution: Place Buy/Sell orders instantly.
  • Monitoring: Check trade results (Win/Loss) with configurable timeouts.
  • Balances: Real-time account balance retrieval.
  • Portfolio: Access active positions and closed deal history.

Market Data & Backtesting

  • Live Stream: Subscribe to real-time candles and price ticks.
  • Historical / UTC Candles: Fetch and compile custom or standard candles directly from 1-second ticks aligned strictly to UTC boundaries, ensuring no server-side gaps or overlaps (merges).
  • Virtual Market: Built-in simulator for backtesting strategies without financial risk.
  • Server Sync: Precision timing via NTP-like synchronization.

Bot Framework (New)

  • Event-Driven: Hooks for on_start and on_candle with JSON candle data.
  • Contextual API: Write once, run on any platform (PocketOption, ExpertOption, or Virtual).
  • Strategy Trait: Easily implement and swap trading algorithms.
  • Virtual Market: Built-in simulator for backtesting strategies without financial risk.

Framework Utilities

  • Raw Handler API: Low-level WebSocket access for custom protocols.
  • Validators: Built-in message filtering system.
  • Asset Logic: Automatic verification of trading pairs and OTC availability.

Architecture

The system uses a layered architecture to ensure stability and speed.

graph TD
User[User Application <br/> Python/Rust/JS] --> Bindings[Language Bindings <br/> PyO3 Async/Sync Wrappers]
Bindings --> Core[Rust Core Library]
subgraph Rust Core
Core --> WS[WebSocket Client <br/> Tungstenite]
Core --> Mgr[Connection Manager]
Core --> Router[Message Router & Validators]
end
WS <--> API[PocketOption WebSocket API]
Loading

Installation

Python

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.gitcd 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.

# 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"

Rust

Add this to your Cargo.toml:

[dependencies]
# Using GitHubbinary_options_tools = { git = "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2.git" }
# Or using GitLab# binary_options_tools = { git = "https://gitlab.chipatrade.com/chipadevorg/BinaryOptionsTools-v2.git" }

Quick Start

Async API (Recommended)

importasyncioimportosfromBinaryOptionsToolsV2importPocketOptionAsyncasyncdefmain():
ssid=os.getenv("POCKET_OPTION_SSID")
asyncwithPocketOptionAsync(ssid=ssid) asclient:
balance=awaitclient.balance()
print(f"Balance: ${balance}")
trade_id, deal=awaitclient.buy("EURUSD_otc", 1.0, 60)
print(f"Outcome: {awaitclient.check_win(trade_id)}")
if__name__=="__main__":
asyncio.run(main())

Bot Framework

Implement the Strategy trait (Rust) or inherit from PyStrategy (Python) for structured bot development.

importasyncioimportjsonimportosfromBinaryOptionsToolsV2importPyBot, PyStrategy, RawPocketOptionclassMyStrategy(PyStrategy):
defon_start(self, ctx):
print("Strategy started!")
defon_candle(self, ctx, asset, candle_json):
candle=json.loads(candle_json)
ifcandle["close"] >candle["open"]:
asyncio.create_task(ctx.buy(asset, 1.0, 60))
asyncdefmain():
ssid=os.getenv("POCKET_OPTION_SSID")
client=awaitRawPocketOption.create(ssid)
strategy=MyStrategy()
bot=PyBot(client, strategy)
bot.add_asset("EURUSD_otc", 60) # Monitor 60s candlesawaitbot.run()
if__name__=="__main__":
asyncio.run(main())

Real-time Data Streaming

asyncwithPocketOptionAsync(ssid="...") asclient:
asyncforcandleinawaitclient.subscribe_symbol("EURUSD_otc"):
print(f"Price: {candle['close']}")

Advanced Usage

For complex implementations, you can access the Raw Handler API. This allows you to construct custom WebSocket messages and filter responses.

fromBinaryOptionsToolsV2.validatorimportValidator# Create a validator to filter messages containing "balance"validator=Validator.contains("balance")
handler=awaitclient.create_raw_handler(validator)
# Send raw JSON requestawaithandler.send_text('42["getBalance"]')
# Listen to the filtered streamasyncformessageinawaithandler.subscribe():
print(f"Raw Update: {message}")

Note on Authentication: Authentication is handled via the SSID cookie. See our Tutorials Directory for instructions on how to extract this from your browser.


Examples

The examples/ directory contains ready-to-run scripts for both async and sync APIs.

Python Async

ExampleDescription
trade.pyBasic buy/sell with check_win
get_balance.pyAccount balance retrieval
get_candles.pyHistorical candle data
subscribe_symbol.pyReal-time candle subscription
strategy_example.pyPyBot/PyStrategy framework
comprehensive_demo.pyFull API walkthrough
raw_send.pyRaw WebSocket messages
create_raw_order.pyRaw order with validator
validator.pyValidator usage examples

Python Sync

A parallel set of examples using the synchronous PocketOption client is available in examples/python/sync/.

Other Languages

UniFFI-generated examples for Go, Kotlin, Swift, Ruby, C#, and Rust are available in their respective subdirectories under examples/.


Roadmap

  • PocketOption: Quick Trading & Pending Orders
  • ExpertOption: Core Implementation (Alpha/Beta)
  • Framework: Bot & Strategy System
  • Backtesting: Virtual Market Simulator
  • Platform: IQ Option Integration
  • Core: Multi-language support via UniFFI (Kotlin, Swift, C#)
  • Core: JavaScript/TypeScript Bindings
  • Core: WebAssembly (WASM) Support
  • Tools: Advanced Strategy Optimizer

Contributing

We welcome contributions!

  1. Fork the repo.
  2. Ensure tests pass (cargo test & pytest).
  3. Submit a Pull Request with clear descriptions.

Legal & Disclaimer

License

  • Personal Use: Free for personal, educational, and non-commercial use.
  • Commercial Use: Requires explicit written permission. Contact us on Discord.
  • See LICENSE for details.

Risk Warning

This software is provided "AS IS" without warranty of any kind.

  • Binary options trading involves high risk and may result in the loss of capital.
  • The authors and ChipaDevTeam are NOT responsible for any financial losses, trading errors, or software bugs.
  • Use this software entirely at your own risk.

Documentation | API Reference | Discord Community | Agents & AI

About

High-performance suite for binary options automation. Features full async support, robust error handling, and multi-platform integration.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

117 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages