Skip to main content

Quickstart

Get up and running with the ZenOTC SDK in minutes.

Basic Usage

import asyncio
from zenotc import AsyncZenOTCClient

async def main():
async with AsyncZenOTCClient(
api_key="your_api_key",
api_secret="your_api_secret",
environment="sandbox"
) as client:
# Check balance
balances = await client.portfolio.get_balances()
for b in balances:
print(f"{b.asset}: {b.available}")

# Get prices
price = await client.market_data.get_price("BTC")
print(f"BTC: {price.mid}")

# Create order
order = await client.execution.create_order(
side="buy",
asset="BTC",
quantity=0.1,
price=float(price.ask)
)
print(f"Order: {order.id}")

asyncio.run(main())

Error Handling

from zenotc.exceptions import (
AuthenticationError,
RateLimitError,
InsufficientFundsError,
)

try:
order = await client.execution.create_order(...)
except AuthenticationError:
print("Invalid credentials")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except InsufficientFundsError as e:
print(f"Need {e.required}, have {e.available}")

Next Steps