Skip to main content

projectx_client/
lib.rs

1// SPDX-FileCopyrightText: 2026 Kevin Monaghan
2// SPDX-License-Identifier: MIT-0
3
4//! Async Rust client for the `ProjectX` Gateway API.
5//!
6//! This crate models `ProjectX`'s provider-native HTTP contract. It deliberately
7//! owns no trading-engine concepts, runtime, environment loading, or application
8//! state. Applications authenticate explicitly and translate these types at
9//! their own boundary.
10//!
11//! Authenticated REST requests use shared rolling-window admission control.
12//! Safe queries wait asynchronously for capacity, while mutations return
13//! [`Error::LocallyRateLimited`] before sending when the local budget is full.
14//!
15//! # Example
16//!
17//! ```no_run
18//! use projectx_client::{Client, Credentials};
19//!
20//! # async fn example() -> Result<(), projectx_client::Error> {
21//! let credentials = Credentials::new("user", "api-key")?;
22//! let client = Client::builder(credentials).build()?;
23//! client.authenticate().await?;
24//! let accounts = client.search_active_accounts().await?;
25//! # let _ = accounts;
26//! # Ok(())
27//! # }
28//! ```
29
30mod client;
31mod config;
32mod credentials;
33mod decimal_serde;
34mod error;
35mod ids;
36mod models;
37mod rate_limit;
38mod realtime;
39mod timestamp;
40mod token;
41
42pub use client::{Client, ClientBuilder, SessionValidator};
43pub use config::Endpoints;
44pub use credentials::{ApplicationCredentials, ApplicationCredentialsBuilder, Credentials};
45pub use error::{Error, ProviderError};
46pub use ids::{AccountId, ContractId, OrderId, PositionId, SymbolId, TradeId};
47pub use models::{
48    Account, Bar, BarUnit, Bracket, CancelOrder, CloseContract, Contract, DepthType,
49    HistoryRequest, HistoryRequestBuilder, MarketDepth, MarketQuote, MarketTrade, ModifyOrder,
50    ModifyOrderBuilder, OperationResponse, Order, OrderPage, OrderQuery, OrderQueryBuilder,
51    OrderResponse, OrderSearch, OrderSortBy, OrderSortDirection, OrderStatus, OrderType,
52    PartialCloseContract, PlaceOrder, PlaceOrderBuilder, Position, PositionType,
53    RequestValidationError, SearchContracts, Side, Trade, TradeLogType, TradeQuery,
54    TradeQueryBuilder, TradeSearch,
55};
56pub use rate_limit::{RateLimit, RateLimitConfig, RateLimitKind};
57pub use realtime::{
58    Hub, RealtimeClient, RealtimeError, RealtimeEvent, RealtimeEventReceiver, SignalRInvocation,
59};
60pub use rust_decimal::Decimal;
61pub use timestamp::{ProviderDate, ProviderDateError, Timestamp, TimestampError};