A library to connect to PocketOption using python with async and sync support.
Project description
BinaryOptionsToolsV2
How to install
Install it with PyPi using the following command:
pip install binaryoptionstoolsv2==0.1.6a4
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
rustandcargoinstalled (Check here) -
Install
maturinin 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.whlfile
// 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
__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(): Fetches historical candle data.history(): Retrieves recent data for a specific asset.
- 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.
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())
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.history(): Retrieves recent data for a specific asset.
- 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.
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)
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file BinaryOptionsToolsV2-0.1.6a4.tar.gz.
File metadata
- Download URL: BinaryOptionsToolsV2-0.1.6a4.tar.gz
- Upload date:
- Size: 770.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf6c99e0dbb7728f1743b4b7be8bd58ad7d681304b32009e4a39d596d7933990
|
|
| MD5 |
758c51a2c39eafac9c77d10fcb436b69
|
|
| BLAKE2b-256 |
80fbfb252f2aa1aa16e3b426ed74d9a7b2b5af306003f4f2a0fae666de6b2cdc
|
File details
Details for the file BinaryOptionsToolsV2-0.1.6a4-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: BinaryOptionsToolsV2-0.1.6a4-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2a8c6dd5776b308e4cff2de333b401c45827b16aafec42c0a382aa0c31fed48
|
|
| MD5 |
12abac0d2cd630b1c70f8de555bdbe8c
|
|
| BLAKE2b-256 |
1ad0f323d042777facec16b5127608a59894d44505f38cca93e5ae8db1dd756c
|
File details
Details for the file BinaryOptionsToolsV2-0.1.6a4-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: BinaryOptionsToolsV2-0.1.6a4-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c55f13a6029fb473d0e71b97fa0f0c9f3540e2ea578f7607dfdb9ed0fc33159
|
|
| MD5 |
2c572102c731aede58751beb19d2afb5
|
|
| BLAKE2b-256 |
df48fbe903e16786cc388d219d2ab074181ec53875f3c8e81f63f2e5ed544e94
|
File details
Details for the file BinaryOptionsToolsV2-0.1.6a4-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: BinaryOptionsToolsV2-0.1.6a4-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ac0fb4b7d9b81ed3342374fa5b96303f7332f1e61d9b66bd288157fa3258b58
|
|
| MD5 |
0543a1094b81482657083a1972ebac19
|
|
| BLAKE2b-256 |
4bd13b4ea2b329f55372e6967d92ae5cf011586dc3bc01a068fbea33531becc2
|