API Reference

Complete reference for all OlympTrade API methods and functionality

Authentication

All API requests require authentication using email and password credentials.

INIT

Initialize Connection

Create and authenticate a new API connection.

Parameters

email
string
required
Your OlympTrade account email
password
string
required
Your OlympTrade account password

Example

import asyncio
from olymptrade_ws import OlympTradeClient

async def main():
    client = OlympTradeClient(access_token="YOUR_ACCESS_TOKEN")
    await client.start()
    if client.is_connected:
        print("Successfully connected to OlympTrade API")
    else:
        print("Failed to connect")
    await client.stop()

if __name__ == "__main__":
    asyncio.run(main())

Connection Management

GET

is_connected

Check if the API connection is active and authenticated.

Returns

bool True if connected, False otherwise

Example

# After starting the client
print(f"Connection status: {client.is_connected}")
POST

stop()

Disconnect from the OlympTrade API and close the session.

Example

await client.stop()
print("Disconnected from API")

Account Methods

GET

get_balance()

Retrieve current account balance information.

Returns

dict Account balance details

Example

balance = await client.balance.get_balance()
demo_acc = next(acc for acc in balance['d'] if acc['group'] == 'demo')
print(f"Demo account balance: {demo_acc['amount']}")
GET

get_profile()

Get detailed profile information for the authenticated account.

Returns

dict User profile data

Example

profile = await client.get_profile()
print(f"User ID: {profile['user_id']}")
print(f"Account type: {profile['account_type']}")
print(f"Registration date: {profile['created_at']}")
GET

get_open_trades()

Retrieve all currently open trading positions.

Returns

list List of open position objects

Example

positions = await client.trade.get_open_trades(account_id, group="demo")
for position in positions:
    print(f"Asset: {position['asset']}")
    print(f"Amount: ${position['amount']}")
    print(f"Direction: {position['direction']}")
    print(f"Profit/Loss: ${position['pnl']}")
    print("---")

Trading Methods

POST

place_order()

Place a trade order on a specified asset.

Example

order_result = await client.trade.place_order(
    pair="LATAM_X",
    amount=1,
    direction="up",
    duration=60,
    account_id=demo_acc['account_id'],
    group="demo"
)
print("Order result:", order_result)
DELETE

close_position()

Close an open position before expiration (if available).

Example

result = await client.trade.close_position(position_id)
if result['success']:
    print(f"Position closed. Final PnL: ${result['pnl']}")
else:
    print(f"Failed to close position: {result['error']}")
GET

get_candles()

Retrieve historical candlestick data for technical analysis.

Example

candles = await client.market.get_candles("LATAM_X", size=60, count=10)
for candle in candles:
    print(f"Time: {candle['time']}")
    print(f"OHLC: {candle['open']}, {candle['high']}, {candle['low']}, {candle['close']}")
    print(f"Volume: {candle['volume']}")
    print("---")

Real-time Data

WS

subscribe_ticks()

Subscribe to real-time price ticks for a specified asset.

Example

async def on_tick(tick):
    print("Tick:", tick)
await client.market.subscribe_ticks("LATAM_X")
# You can then listen for tick events via your event handler
WS

subscribe_to_candles()

Subscribe to real-time candlestick updates.

Example

async def on_candle(candle):
    print("New candle:", candle)
await client.market.subscribe_candles("LATAM_X", size=60)
# Listen for candle events via your event handler

Error Handling

The API uses standard HTTP status codes and provides detailed error messages.

Common Error Codes

401
Unauthorized
Invalid credentials or session expired
400
Bad Request
Invalid parameters or malformed request
429
Rate Limited
Too many requests, please slow down
500
Server Error
Internal server error, try again later

Exception Handling Example

from olymptrade_ws import OlympTradeClient

async def main():
    client = OlympTradeClient(access_token="YOUR_ACCESS_TOKEN")
    try:
        await client.start()
        balance = await client.balance.get_balance()
        print(f"Balance: {balance}")
    except Exception as e:
        print(f"API Error: {e}")
    finally:
        await client.stop()

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Need Professional Bot Development?

Get custom trading bots built by experts using the OlympTrade API

Custom Strategies
Risk Management
Advanced Analytics
24/7 Support
Create Your Bot Now