binary_options_tools 0.2.0

High-level library for binary options trading automation. Supports PocketOption and ExpertOption with real-time data streaming, WebSocket API access, and automated trading strategies.
Documentation
use crate::pocketoption::error::PocketResult;
use crate::pocketoption::types::Deal;
use async_trait::async_trait;
use rust_decimal::Decimal;
use uuid::Uuid;

/// The Market trait abstracts trading operations.
/// This allows strategies to run against live accounts, demo accounts, or local simulations (backtesting).
#[async_trait]
pub trait Market: Send + Sync {
    /// Executes a BUY (CALL) order.
    async fn buy(&self, asset: &str, amount: Decimal, time: u32) -> PocketResult<(Uuid, Deal)>;

    /// Executes a SELL (PUT) order.
    async fn sell(&self, asset: &str, amount: Decimal, time: u32) -> PocketResult<(Uuid, Deal)>;

    /// Returns the current balance.
    /// This method should be really lightweight, the balance should be stored by the client and simply retrieved
    /// No server call should be performed here, otherwise it will cause performance issues and may lead to rate limits.
    async fn balance(&self) -> Decimal;

    /// Checks the result of a trade.
    async fn result(&self, trade_id: Uuid) -> PocketResult<Deal>;
}