nautilus_dydx/lib.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! [NautilusTrader](http://nautilustrader.io) adapter for the [dYdX](https://dydx.trade/) decentralized derivatives exchange.
17//!
18//! The `nautilus-dydx` crate provides client bindings (HTTP, WebSocket & gRPC), data
19//! models, and helper utilities that wrap the official **dYdX v4 API**.
20//!
21//! # Official Documentation
22//!
23//! | Resource | Reference |
24//! |--------------------------------------|--------------------------------------------------------|
25//! | Main documentation | <https://docs.dydx.xyz> |
26//! | Indexer HTTP API | <https://docs.dydx.exchange/api_integration-indexer/indexer_api> |
27//! | Indexer WebSocket API | <https://docs.dydx.trade/developers/indexer/websockets> |
28//! | Order types | <https://docs.dydx.xyz/concepts/trading/orders> |
29//! | Permissioned keys | <https://docs.dydx.xyz/concepts/trading/authenticators> |
30//! | Validator client (gRPC) | <https://docs.dydx.exchange/api_integration-clients/validator_client> |
31//!
32//! # Platform
33//!
34//! [NautilusTrader](http://nautilustrader.io) is an open-source, high-performance, production-grade
35//! algorithmic trading platform, providing quantitative traders with the ability to backtest
36//! portfolios of automated trading strategies on historical data with an event-driven engine,
37//! and also deploy those same strategies live, with no code changes.
38//!
39//! NautilusTrader's design, architecture, and implementation philosophy prioritizes software
40//! correctness and safety at the highest level, with the aim of supporting mission-critical trading
41//! system backtesting and live deployment workloads.
42//!
43//! # Feature Flags
44//!
45//! This crate provides feature flags to control source code inclusion during compilation,
46//! depending on the intended use case, i.e. whether to provide Python bindings
47//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
48//! or as part of a Rust only build.
49//!
50//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
51//! - `extension-module`: Builds as a Python extension module (used with `python`).
52//!
53//! [High-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation#precision-mode) (128-bit value types) is enabled by default.
54
55#![warn(rustc::all)]
56#![deny(unsafe_code)]
57#![deny(nonstandard_style)]
58#![deny(missing_debug_implementations)]
59#![deny(clippy::missing_errors_doc)]
60#![deny(clippy::missing_panics_doc)]
61#![deny(rustdoc::broken_intra_doc_links)]
62
63pub mod common;
64pub mod config;
65pub mod data;
66pub mod error;
67pub mod execution;
68pub mod factories;
69pub mod grpc;
70pub mod http;
71pub mod proto;
72pub mod types;
73pub mod websocket;
74
75#[cfg(feature = "python")]
76pub mod python;
77
78pub use crate::{
79 common::{
80 enums::{
81 DydxCandleResolution, DydxMarketStatus, DydxOrderSide, DydxOrderStatus, DydxOrderType,
82 DydxTickerType, DydxTimeInForce,
83 },
84 models::DydxAccount,
85 },
86 data::DydxDataClient,
87 error::DydxError,
88 factories::{DydxDataClientFactory, DydxExecutionClientFactory},
89 http::{
90 client::DydxHttpClient,
91 error::DydxHttpError,
92 models::{MarketsResponse, PerpetualMarket},
93 },
94 types::DydxOraclePrice,
95 websocket::{
96 client::DydxWebSocketClient,
97 enums::{DydxWsChannel, DydxWsOperation},
98 error::DydxWsError,
99 },
100};