Skip to main content

Crate projectx_client

Crate projectx_client 

Source
Expand description

Async Rust client for the ProjectX Gateway API.

This crate models ProjectX’s provider-native HTTP contract. It deliberately owns no trading-engine concepts, runtime, environment loading, or application state. Applications authenticate explicitly and translate these types at their own boundary.

Authenticated REST requests use shared rolling-window admission control. Safe queries wait asynchronously for capacity, while mutations return Error::LocallyRateLimited before sending when the local budget is full.

Successful list reads return ProviderList so an explicit provider array, including an authoritative empty one, stays distinguishable from a success envelope that omits the field or serializes it as JSON null.

§Example

use projectx_client::{Client, Credentials, ProviderList};

let credentials = Credentials::new("user", "api-key")?;
let client = Client::builder(credentials).build()?;
client.authenticate().await?;
match client.search_active_accounts().await? {
    ProviderList::Listed(accounts) => {
        for account in accounts {
            println!("{}", account.name);
        }
    }
    ProviderList::Absent => eprintln!("the provider omitted the account list"),
}

Structs§

Account
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX account.
AccountId
Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated ProjectX account identifier.
ApplicationCredentials
API-key and authorized-application credentials and their builder. API-key and authorized-application credentials and their builder. API-key and authorized-application credentials and their builder. ProjectX authorized-application credentials.
ApplicationCredentialsBuilder
API-key and authorized-application credentials and their builder. API-key and authorized-application credentials and their builder. API-key and authorized-application credentials and their builder. Builder for validated ApplicationCredentials.
Bar
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A historical OHLCV bar.
Bracket
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. ProjectX bracket-leg configuration.
CancelOrder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Order cancellation parameters.
Client
Authenticated REST client, its builder, and its session-validation guard. Authenticated REST client, its builder, and its session-validation guard. Authenticated REST client, its builder, and its session-validation guard. Authenticated ProjectX REST client.
ClientBuilder
Authenticated REST client, its builder, and its session-validation guard. Authenticated REST client, its builder, and its session-validation guard. Authenticated REST client, its builder, and its session-validation guard. Builder for Client.
CloseContract
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Position close parameters.
Contract
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX futures contract.
ContractId
Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated ProjectX contract identifier.
Credentials
API-key and authorized-application credentials and their builder. API-key and authorized-application credentials and their builder. API-key and authorized-application credentials and their builder. ProjectX API-key credentials.
Decimal
Decimal type used for provider prices, money, balances, fees, and P&L. Decimal represents a 128 bit representation of a fixed-precision decimal number. The finite set of values of type Decimal are of the form m / 10e, where m is an integer such that -296 < m < 296, and e is an integer between 0 and 28 inclusive.
Endpoints
REST and real-time endpoints for one ProjectX deployment. REST and real-time endpoints for one ProjectX deployment.
HistoryRequest
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Historical-bar request parameters.
HistoryRequestBuilder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Builder for a validated HistoryRequest.
MarketDepth
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Depth-of-market update from the market hub.
MarketQuote
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Sparse quote update from the market hub.
MarketTrade
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Trade print from the market hub.
ModifyOrder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Order modification parameters.
ModifyOrderBuilder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Builder for a validated ModifyOrder.
OperationResponse
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Successful response for an operation without a result body.
Order
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX order.
OrderId
Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated ProjectX order identifier.
OrderPage
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. One page returned by Client::query_orders.
OrderQuery
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Filtered, paginated order-query parameters.
OrderQueryBuilder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Builder for a validated OrderQuery.
OrderResponse
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Successful order-placement result.
OrderSearch
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Historical order search parameters.
PartialCloseContract
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Partial-position close parameters.
PlaceOrder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Order placement parameters.
PlaceOrderBuilder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Builder for a validated PlaceOrder.
Position
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX open position.
PositionId
Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated ProjectX position identifier.
ProviderDate
Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. A provider civil date parsed from an ISO-8601 YYYY-MM-DD value.
ProviderDateError
Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. A string was not a valid provider civil date.
ProviderError
Client errors, provider rejections, and ambiguous-mutation origins. Client errors, provider rejections, and ambiguous-mutation origins. Client errors, provider rejections, and ambiguous-mutation origins. A provider-declared failed operation.
RateLimit
Rolling-window REST rate-limit kinds, limits, and configuration. Rolling-window REST rate-limit kinds, limits, and configuration. Rolling-window REST rate-limit kinds, limits, and configuration. One rolling-window request limit.
RateLimitConfig
Rolling-window REST rate-limit kinds, limits, and configuration. Rolling-window REST rate-limit kinds, limits, and configuration. Rolling-window REST rate-limit kinds, limits, and configuration. Rate limits applied to authenticated ProjectX REST requests.
RealtimeClient
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. SignalR-over-WebSocket client for one ProjectX hub.
RealtimeEventReceiver
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Single-consumer receiver for real-time events.
RealtimeGeneration
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Identity of one ready socket, scoped to its owning real-time client.
RealtimeMessage
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. An observation attributed to the exact socket that produced it.
RealtimeSession
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Subscription and invocation admission bound to one exact ready socket. This handle cannot stop or reconnect the transport and does not keep its owner alive.
SearchContracts
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Contract search parameters.
SessionValidator
Authenticated REST client, its builder, and its session-validation guard. Authenticated REST client, its builder, and its session-validation guard. Authenticated REST client, its builder, and its session-validation guard. Guard for a periodic token-validation task.
SignalRInvocation
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. A decoded SignalR invocation frame.
SymbolId
Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated ProjectX symbol identifier.
Timestamp
Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. An absolute provider timestamp parsed from an ISO-8601/RFC-3339 value.
TimestampError
Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. Validated provider timestamps, civil dates, and their parse errors. A string was not a valid absolute provider timestamp.
Trade
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX execution trade.
TradeId
Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated provider account, contract, order, position, symbol, and trade identifiers. Validated ProjectX trade identifier.
TradeQuery
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Trade search parameters with independently optional timestamp bounds.
TradeQueryBuilder
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Builder for a validated TradeQuery.
TradeSearch
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Trade search parameters.

Enums§

AmbiguityOrigin
Client errors, provider rejections, and ambiguous-mutation origins. Client errors, provider rejections, and ambiguous-mutation origins. Client errors, provider rejections, and ambiguous-mutation origins. The transport-level origin of an ambiguous mutation outcome, when a provider rejection was not decoded.
BarUnit
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Historical-bar aggregation unit.
DepthType
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX depth-of-market update kind.
Error
Client errors, provider rejections, and ambiguous-mutation origins. Client errors, provider rejections, and ambiguous-mutation origins. Client errors, provider rejections, and ambiguous-mutation origins. Errors returned by the ProjectX client.
Hub
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. ProjectX real-time hub.
OrderSortBy
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Field used to sort an OrderQuery result page.
OrderSortDirection
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Direction used to sort an OrderQuery result page.
OrderStatus
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX order lifecycle status.
OrderType
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX order type.
PositionType
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX position direction.
ProviderList
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A provider list field read from a successful response body.
RateLimitKind
Rolling-window REST rate-limit kinds, limits, and configuration. Rolling-window REST rate-limit kinds, limits, and configuration. Rolling-window REST rate-limit kinds, limits, and configuration. Identifies one provider REST rate-limit budget.
RealtimeError
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Errors returned by the real-time transport.
RealtimeEvent
Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Real-time hubs, client, session, events, messages, and invocation decoding. Events emitted by a RealtimeClient.
RequestValidationError
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Validation failures while constructing a provider request.
Side
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX order side.
TradeLogType
Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. Provider-native request, response, order, position, trade, and market-data models. A ProjectX market-trade aggressor classification.