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 error_codes;
36mod ids;
37mod models;
38mod rate_limit;
39mod realtime;
40mod timestamp;
41mod token;
42
43pub use client::{Client, ClientBuilder, SessionValidator};
44pub use config::Endpoints;
45pub use credentials::{ApplicationCredentials, ApplicationCredentialsBuilder, Credentials};
46pub use error::{Error, ProviderError};
47pub use ids::{AccountId, ContractId, OrderId, PositionId, SymbolId, TradeId};
48pub use models::{
49    Account, Bar, BarUnit, Bracket, CancelOrder, CloseContract, Contract, DepthType,
50    HistoryRequest, HistoryRequestBuilder, MarketDepth, MarketQuote, MarketTrade, ModifyOrder,
51    ModifyOrderBuilder, OperationResponse, Order, OrderPage, OrderQuery, OrderQueryBuilder,
52    OrderResponse, OrderSearch, OrderSortBy, OrderSortDirection, OrderStatus, OrderType,
53    PartialCloseContract, PlaceOrder, PlaceOrderBuilder, Position, PositionType,
54    RequestValidationError, SearchContracts, Side, Trade, TradeLogType, TradeQuery,
55    TradeQueryBuilder, TradeSearch,
56};
57pub use rate_limit::{RateLimit, RateLimitConfig, RateLimitKind};
58pub use realtime::{
59    Hub, RealtimeClient, RealtimeError, RealtimeEvent, RealtimeEventReceiver, RealtimeGeneration,
60    RealtimeMessage, RealtimeSession, SignalRInvocation,
61};
62pub use rust_decimal::Decimal;
63pub use timestamp::{ProviderDate, ProviderDateError, Timestamp, TimestampError};