API reference

class cryptocom.exchange.Account(*, api_key: str = '', api_secret: str = '', from_env: bool = False, exchange: Exchange | None = None, api: ApiProvider | None = None)[source]

Provides access to account actions and data. Balance, trades, orders.

async buy_limit(pair: Pair, quantity: float, price: float, force_type: OrderForceType | None = None, exec_type: OrderExecType | None = None, client_id: int | None = None) int[source]

Buy limit order.

async buy_market(pair: Pair, spend: float, wait_for_fill=False) str[source]

Buy market order.

async cancel_open_orders(pair: Pair | None = None) None[source]

Cancel all open orders.

async cancel_order(order_id: int, pair: Pair, check_status=False) None[source]

Cancel order.

async create_order(pair: Pair, side: OrderSide, type_: OrderType, quantity: float, price: float = 0, force_type: OrderForceType | None = None, exec_type: OrderExecType | None = None, client_id: int | None = None) str[source]

Create raw order with buy or sell side.

async get_balance() Dict[Instrument, Balance][source]

Return balance.

async get_deposit_history(instrument: Instrument | None = None, start_ts: int | None = None, end_ts: int | None = None, status: DepositStatus | None = None, page: int = 0, page_size: int = 20) List[Deposit][source]

Return all history withdrawals.

async get_interest_history(instrument: Instrument, start_ts: int | None = None, end_ts: int | None = None, page: int = 0, page_size: int = 20) List[Interest][source]

Return all history interest.

async get_open_orders(pair: Pair | None = None, page: int = 0, page_size: int = 200) List[Order][source]

Return open orders.

async get_order(order_id: str) Order[source]

Get order info.

async get_orders_history(pair: Pair | None = None, start_ts: int | None = None, end_ts: int | None = None, limit: int = 100) List[Order][source]

Return all history orders.

async get_trades(pair: Pair | None = None, start_ts: int | None = None, end_ts: int | None = None, limit: int = 100) List[PrivateTrade][source]

Return trades.

async get_withdrawal_history(instrument: Instrument, start_ts: int | None = None, end_ts: int | None = None, status: WithdrawalStatus | None = None, page: int = 0, page_size: int = 20) List[Withdrawal][source]

Return all history for withdrawal transactions.

async sell_limit(pair: Pair, quantity: float, price: float, force_type: OrderForceType | None = None, exec_type: OrderExecType | None = None, client_id: int | None = None) int[source]

Sell limit order.

async sell_market(pair: Pair, quantity: float, wait_for_fill=False) str[source]

Sell market order.

async wait_for_status(order_id: int, statuses, delay: int = 0.1) None[source]

Wait for order status.

exception cryptocom.exchange.ApiError[source]
class cryptocom.exchange.ApiProvider(*, api_key='', api_secret='', from_env=False, auth_required=True, timeout=5, retries=5, root_url='https://api.crypto.com/exchange/v1/', ws_root_url='wss://stream.crypto.com/exchange/v1/', logger=None)[source]

Provides HTTP-api requests and websocket requests.

class cryptocom.exchange.Candle(time: int, open: float, high: float, low: float, close: float, volume: float, pair: cryptocom.exchange.structs.Pair)[source]
class cryptocom.exchange.Deposit(instrument: cryptocom.exchange.structs.Instrument, fee: float, create_time: int, id: str, update_time: int, amount: float, address: str, status: cryptocom.exchange.structs.DepositStatus)[source]
class cryptocom.exchange.DepositStatus(value)[source]

An enumeration.

class cryptocom.exchange.Exchange(api: ApiProvider | None = None)[source]

Interface to base exchange methods.

async get_orderbook(pair: Pair, depth: int = 150) OrderBook[source]

Get the order book for a particular market.

async get_pairs() List[Pair][source]

List all available market pairs and store to provide pairs info.

async get_price(pair: Pair) float[source]

Get latest price of pair.

async get_ticker(pair: Pair) MarketTicker[source]

Get ticker in for provided pair.

async get_tickers() Dict[Pair, MarketTicker][source]

Get tickers in all available markets.

async get_trades(pair: Pair) List[MarketTrade][source]

Get last 200 trades in a specified market.

async sync_pairs()[source]

Use this method to sync pairs if you have issues with missing pairs in library side.

class cryptocom.exchange.Instrument(exchange_name: str)[source]
class cryptocom.exchange.MarketTrade(id: int, time: int, price: float, quantity: float, side: cryptocom.exchange.structs.OrderSide, pair: cryptocom.exchange.structs.Pair)[source]
class cryptocom.exchange.Order(id: str, client_id: str, account_id: str, type: cryptocom.exchange.structs.OrderType, status: cryptocom.exchange.structs.OrderStatus, side: cryptocom.exchange.structs.OrderSide, exec_type: cryptocom.exchange.structs.OrderExecType, limit_price: float | None, value: float, quantity: float, maker_fee_rate: float, taker_fee_rate: float, filled_price: float, filled_quantity: float, filled_value: float, filled_fee: float, update_user_id: str, order_date: str, pair: cryptocom.exchange.structs.Pair, fees_instrument: cryptocom.exchange.structs.Instrument, force_type: cryptocom.exchange.structs.OrderForceType, created_at: int, updated_at: int, create_time_ns: int)[source]
class cryptocom.exchange.OrderSide(value)[source]

An enumeration.

class cryptocom.exchange.OrderStatus(value)[source]

An enumeration.

class cryptocom.exchange.OrderType(value)[source]

An enumeration.

class cryptocom.exchange.Pair(exchange_name: str, price_precision: int, quantity_precision: int)[source]
class cryptocom.exchange.PrivateTrade(id: str, account_id: str, client_oid: str, event_date: str, quantity: float, price: float, fees: float, fees_instrument: cryptocom.exchange.structs.Instrument, pair: cryptocom.exchange.structs.Pair, side: cryptocom.exchange.structs.OrderSide, type: cryptocom.exchange.structs.TradeType, created_at: int, created_at_ns: int, order_id: str)[source]
class cryptocom.exchange.RecordApiProvider(*, cache_file: Path, capture: bool = False, divide_delay: int = 1, fake_account_id: bool = True)[source]

Captures API and websocket responses into json files. If capture=False it will read them to reproduce same responses in order.

class cryptocom.exchange.TimeDelta(value)[source]

An enumeration.

class cryptocom.exchange.Timeframe(value)[source]

An enumeration.

class cryptocom.exchange.Withdrawal(instrument: cryptocom.exchange.structs.Instrument, fee: float, create_time: int, id: str, update_time: int, amount: float, address: str, client_wid: str, status: cryptocom.exchange.structs.WithdrawalStatus, txid: str)[source]
class cryptocom.exchange.WithdrawalStatus(value)[source]

An enumeration.