pub struct Trader {
pub client: Client,
}Expand description
Manages trading operations: order creation, cancellation, status lookup, orderbook access, historical prices, and user-specific order/market data.
Most endpoints require authentication via scoped HMAC token or legacy API key.
§Convenience Methods
For the most common trading workflows, use the high-level methods:
buy_gtc/sell_gtc— Place limit ordersbuy_fok/sell_fok— Place market orderscancel_all— Cancel all orders in a market
Fields§
§client: ClientImplementations§
Source§impl Trader
impl Trader
Sourcepub async fn create_order(
&self,
order_request: &str,
) -> Result<CreateOrderResponse, LimitlessError>
pub async fn create_order( &self, order_request: &str, ) -> Result<CreateOrderResponse, LimitlessError>
Create a new order on a prediction market.
Supports GTC (Good Till Cancelled) and FOK (Fill or Kill) order types. CLOB orders require EIP-712 signatures; AMM orders use a different flow.
§Arguments
order_request— Serialized JSON body matching the Create Order schema.
Sourcepub async fn order_status_batch(
&self,
request_body: &str,
) -> Result<OrderStatusBatchResponse, LimitlessError>
pub async fn order_status_batch( &self, request_body: &str, ) -> Result<OrderStatusBatchResponse, LimitlessError>
Fetch statuses for multiple orders in batch.
Look up by orderId or clientOrderId (provide exactly one per item).
Accepts up to 50 items per request.
Sourcepub async fn cancel_combined(
&self,
request_body: &str,
) -> Result<CancelOrderResponse, LimitlessError>
pub async fn cancel_combined( &self, request_body: &str, ) -> Result<CancelOrderResponse, LimitlessError>
Cancel a single order by orderId or clientOrderId (combined endpoint).
Sourcepub async fn cancel_batch(
&self,
request_body: &str,
) -> Result<CancelBatchResponse, LimitlessError>
pub async fn cancel_batch( &self, request_body: &str, ) -> Result<CancelBatchResponse, LimitlessError>
Cancel multiple orders by internal orderIds (batch).
Sourcepub async fn cancel_order_by_id(
&self,
order_id: &str,
) -> Result<CancelOrderResponse, LimitlessError>
pub async fn cancel_order_by_id( &self, order_id: &str, ) -> Result<CancelOrderResponse, LimitlessError>
Cancel a single order by internal orderId (legacy endpoint).
Sourcepub async fn cancel_all_in_market(
&self,
slug: &str,
) -> Result<CancelAllResponse, LimitlessError>
pub async fn cancel_all_in_market( &self, slug: &str, ) -> Result<CancelAllResponse, LimitlessError>
Cancel all orders for the authenticated user in a specific market.
Sourcepub async fn get_orderbook(
&self,
slug: &str,
) -> Result<OrderbookResponse, LimitlessError>
pub async fn get_orderbook( &self, slug: &str, ) -> Result<OrderbookResponse, LimitlessError>
Get the current orderbook for a market.
Sourcepub async fn get_historical_prices(
&self,
slug: &str,
interval: Option<&str>,
) -> Result<Vec<HistoricalPriceData>, LimitlessError>
pub async fn get_historical_prices( &self, slug: &str, interval: Option<&str>, ) -> Result<Vec<HistoricalPriceData>, LimitlessError>
Get historical price data for a market.
Sourcepub async fn get_locked_balance(
&self,
slug: &str,
) -> Result<LockedBalanceResponse, LimitlessError>
pub async fn get_locked_balance( &self, slug: &str, ) -> Result<LockedBalanceResponse, LimitlessError>
Get the amount of funds locked in open orders for the authenticated user.
Sourcepub async fn get_user_orders(
&self,
slug: &str,
statuses: Option<&[&str]>,
limit: Option<u64>,
) -> Result<UserOrdersResponse, LimitlessError>
pub async fn get_user_orders( &self, slug: &str, statuses: Option<&[&str]>, limit: Option<u64>, ) -> Result<UserOrdersResponse, LimitlessError>
Get all orders placed by the authenticated user for a specific market.
Sourcepub async fn get_market_events(
&self,
slug: &str,
page: Option<u64>,
limit: Option<u64>,
) -> Result<MarketEventsResponse, LimitlessError>
pub async fn get_market_events( &self, slug: &str, page: Option<u64>, limit: Option<u64>, ) -> Result<MarketEventsResponse, LimitlessError>
Get recent market events (trades, orders, liquidity changes).
Sourcepub async fn buy_gtc(
&self,
private_key: &str,
market_slug: &str,
token_id: &str,
price: f64,
size: f64,
owner_id: u64,
) -> Result<CreateOrderResponse, LimitlessError>
pub async fn buy_gtc( &self, private_key: &str, market_slug: &str, token_id: &str, price: f64, size: f64, owner_id: u64, ) -> Result<CreateOrderResponse, LimitlessError>
Place a GTC buy limit order — the simplest way to buy YES/NO shares.
Handles: fetch venue contract → validate → build EIP-712 order → sign → submit.
§Arguments
private_key— 0x-prefixed hex private key for signingmarket_slug— Market identifier (e.g., “btc-above-100k-jul-4”)token_id— The outcome token ID as a decimal string (e.g., frommarket.outcomes[0].token_id)price— Price between 0 and 1 (e.g., 0.55 for $0.55)size— Number of shares to buyowner_id— Your profile ID (fromGET /profiles/:address)
Sourcepub async fn sell_gtc(
&self,
private_key: &str,
market_slug: &str,
token_id: &str,
price: f64,
size: f64,
owner_id: u64,
) -> Result<CreateOrderResponse, LimitlessError>
pub async fn sell_gtc( &self, private_key: &str, market_slug: &str, token_id: &str, price: f64, size: f64, owner_id: u64, ) -> Result<CreateOrderResponse, LimitlessError>
Place a GTC sell limit order — the simplest way to sell YES/NO shares.
Sourcepub async fn buy_fok(
&self,
private_key: &str,
market_slug: &str,
token_id: &str,
usdc_amount: f64,
owner_id: u64,
) -> Result<CreateOrderResponse, LimitlessError>
pub async fn buy_fok( &self, private_key: &str, market_slug: &str, token_id: &str, usdc_amount: f64, owner_id: u64, ) -> Result<CreateOrderResponse, LimitlessError>
Place a FOK buy market order — buy shares at market price.
Sourcepub async fn sell_fok(
&self,
private_key: &str,
market_slug: &str,
token_id: &str,
share_amount: f64,
owner_id: u64,
) -> Result<CreateOrderResponse, LimitlessError>
pub async fn sell_fok( &self, private_key: &str, market_slug: &str, token_id: &str, share_amount: f64, owner_id: u64, ) -> Result<CreateOrderResponse, LimitlessError>
Place a FOK sell market order — sell shares at market price.
Sourcepub async fn cancel_all(
&self,
slug: &str,
) -> Result<CancelAllResponse, LimitlessError>
pub async fn cancel_all( &self, slug: &str, ) -> Result<CancelAllResponse, LimitlessError>
Cancel all open orders in a market (convenience alias).