Skip to main content

A library to connect to PocketOption using python with async and sync support.

Project description

👉 Join us on Discord

BinaryOptionsToolsV2

⚠️ Work in Progress Notice

Current Status: This version is undergoing major refactoring to use a new, more stable API implementation. Many features are temporarily unavailable while we transition to the new architecture.

Available Features:

  • Basic authentication and connection
  • Buy/Sell operations
  • Balance retrieval
  • Basic symbol subscriptions
  • Server time synchronization

Temporarily Unavailable Features (returning "work in progress" errors):

  • Historical candle data (get_candles, get_candles_advanced)
  • Trade history (history)
  • Closed deals management
  • Payout information
  • Raw message sending
  • Advanced validators
  • Deal end time queries

We're actively working to restore all functionality with improved stability and performance.

How to install

Install it with PyPi using the following command:

pip install binaryoptionstoolsv2==0.1.6a3

Supported OS

Currently, only support for Windows is available.

Supported Python versions

Currently, only Python 3.9 to 3.12 is supported.

Compile from source (Not recommended)

  • Make sure you have rust and cargo installed (Check here)

  • Install maturin in order to compile the library

  • Once the source is downloaded (using git clone https://github.com/ChipaDevTeam/BinaryOptionsTools-v2.git) execute the following commands: To create the .whl file

// Inside the root folder
cd BinaryOptionsToolsV2
maturin build -r 

// Once the command is executed it should print a path to a .whl file, copy it and then run
pip install path/to/file.whl

To install the library in a local virtual environment

// Inside the root folder
cd BinaryOptionsToolsV2

// Activate the virtual environment if not done already 

// Execute the following command and it should automatically install the library in the VM
maturin develop

Docs

Comprehensive Documentation for BinaryOptionsToolsV2

  1. __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 pocketoption and tracing modules 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

  1. 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(): Fetches historical candle data. (Work in Progress)
    • history(): Retrieves recent data for a specific asset. (Work in Progress)
  • Account Management:
    • balance(): Returns the current account balance.
    • opened_deals(): Lists all open trades.
    • closed_deals(): Lists all closed trades. (Work in Progress)
    • payout(): Returns payout percentages. (Work in Progress)
  • 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.

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(): 
    client = PocketOptionAsync(ssid="your-session-id") 
    await asyncio.sleep(5)
    balance = await client.balance() 
    print("Account Balance:", balance) 
 
asyncio.run(main()) 
  1. 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(): Fetches historical candle data. (Work in Progress)
    • history(): Retrieves recent data for a specific asset. (Work in Progress)
  • Account Management:
    • balance(): Retrieves account balance.
    • opened_deals(): Lists all open trades.
    • closed_deals(): Lists all closed trades. (Work in Progress)
    • payout(): Returns payout percentages. (Work in Progress)
  • 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.

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

client = PocketOption(ssid="your-session-id") 
time.sleep(5)
balance = client.balance() 
print("Account Balance:", balance) 
  1. 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BinaryOptionsToolsV2-0.1.8.tar.gz (326.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

BinaryOptionsToolsV2-0.1.8-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

BinaryOptionsToolsV2-0.1.8-cp313-cp313-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

BinaryOptionsToolsV2-0.1.8-cp313-cp313-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

Details for the file BinaryOptionsToolsV2-0.1.8.tar.gz.

File metadata

  • Download URL: BinaryOptionsToolsV2-0.1.8.tar.gz
  • Upload date:
  • Size: 326.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.1

File hashes

Hashes for BinaryOptionsToolsV2-0.1.8.tar.gz
Algorithm Hash digest
SHA256 1911eb5c3f5649d8074c2cf90b6d63464811118d777d08de666ae6fc0cfa9bf9
MD5 a1ef584933572bafc0fa2f7c2db3bc39
BLAKE2b-256 465dccf4bb279313c8e2e1693634884ab3372e5fe784327f68ded8b75d456f89

See more details on using hashes here.

File details

Details for the file BinaryOptionsToolsV2-0.1.8-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for BinaryOptionsToolsV2-0.1.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7c0722bf245f56ae855b4af95b6bec1d47d03e3aca65c73c893074f00e33bfcb
MD5 7b21ebc195c6540d7bda5dd44bb454a1
BLAKE2b-256 a13ced8d9c6b572c9589dc400dfda01060ddbc469b2a19b137e23c8809b8d7d8

See more details on using hashes here.

File details

Details for the file BinaryOptionsToolsV2-0.1.8-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for BinaryOptionsToolsV2-0.1.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 330cc0644416ea13dd6d5a827a4475ca2648d685dc0d332aac711aca0d71ee84
MD5 36cb8439104a521ad1cc47a4a24e863c
BLAKE2b-256 77da393e548f6c40d19baa1f8ff4839e2c5b1d0eca1f54d8fe2e658db18dc1e5

See more details on using hashes here.

File details

Details for the file BinaryOptionsToolsV2-0.1.8-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for BinaryOptionsToolsV2-0.1.8-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 00070546c6f3c2120b44c232e99500079a839f676a8bf30b8dec9135ddbfaae6
MD5 3b84dfd2dc26ed74ca56bbcded08d037
BLAKE2b-256 71edb5db8e0d023a9dc0958f3bf842c7361f4cfe58e931fa92561e5ce6c59c70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page