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 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_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.
- 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.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_trades(pair: Pair) List[MarketTrade][source]
Get last 200 trades in a specified market.
- 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.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.