Algorithmic Trading Guide
Build algorithmic trading strategies with the ZenOTC SDK.
Basic Strategy Pattern
import asyncio
from zenotc import AsyncZenOTCClient
async def trading_strategy(client):
while True:
# Get market data
price = await client.market_data.get_price("BTC")
# Check risk
check = await client.risk.pre_trade_check(
side="buy",
asset="BTC",
quantity=0.1,
price=float(price.ask)
)
if check.approved:
# Execute trade
order = await client.execution.create_order(
side="buy",
asset="BTC",
quantity=0.1,
price=float(price.ask)
)
print(f"Order: {order.id}")
await asyncio.sleep(60)
Real-Time Strategy
async def realtime_strategy(client):
async def on_price(price):
# React to price changes
if price.mid < 50000:
await client.execution.create_order(...)
await client.market_data.subscribe_prices(["BTC"], on_price)
Risk Management
Always use pre-trade checks:
check = await client.risk.pre_trade_check(...)
if not check.approved:
print(f"Blocked: {check.reason}")