Skip to content

TL;DR

A simplified version of the tutorial.

Install the SDK

pip install emp-orderly-types emp-orderly

Import and setup your SDK

import os

from emp_orderly import (
    Strategy, EmpOrderly,
    crossover, plot_heatmaps,
    EMA, SMA, SLOPE, CHOP,
    EmpyrealOrderlySDK,
)
from emp_orderly_types import PerpetualAssetType, Interval, OrderType

pvt_hex = os.environ["PVT_KEY_HEX"]
sdk = EmpyrealOrderlySDK.register(pvt_hex)

Make a limit order

# make limit order for bitcoin at $59000
await sdk.make_limit_order(amount=100, price=59_000, asset=PerpetualAssetType.BTC, is_buy=True)

Make a Trade

# short bitcoin for $100
await sdk.make_order(100, asset=PerpetualAssetType.BTC, is_buy=False)

OHLCV Data

from emp_orderly_types import Interval, PerpetualAssetType

await sdk.get_ohlcv(
    asset=PerpetualAssetType.BTC,
    resolution=Interval.hour,
    start_days_behind=1,  # start 1 day back
    end_days_behind=0,  # end now
)

Close your Position

# close all open positions and orders
await sdk.close(PerpetualAssetType.BTC)