Examples

Ready-to-use scripts and code snippets for BinaryOptionsToolsAsync and BinaryOptionsTools.

Minimal Async Example

import asyncio
from BinaryOptionsToolsAsync.pocketoption import PocketOptionAsync

async def main():
    api = PocketOptionAsync(ssid, demo=True)
    balance = await api.balance()
    print(balance)
    await api.close()

asyncio.run(main())

Advanced Async Trading Example

import pandas as pd
candles = await api.get_candles("EURUSD_otc", period=60, duration=1200)
df = pd.DataFrame(candles)
df['SMA_5'] = df['close'].rolling(window=5).mean()
if df['close'].iloc[-1] > df['SMA_5'].iloc[-1]:
    trade_id, success = await api.buy("EURUSD_otc", amount=1, time=60)
else:
    trade_id, success = await api.sell("EURUSD_otc", amount=1, time=60)

SMA Crossover Bot

# See examples/sma-crossoverbot.py for a full implementation

Telegram Bot Integration

# See examples/telegram_bot/telegram-bot.py for a full implementation