Skip to main content

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](https://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.xyz/api_integration-indexer/indexer_api> |
27//! | Indexer WebSocket API                | <https://docs.dydx.xyz/api_integration-indexer/indexer_websocket> |
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.xyz/api_integration-clients/validator_client> |
31//!
32//! # NautilusTrader
33//!
34//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
35//! engine for multi-asset, multi-venue trading systems.
36//!
37//! The system spans research, deterministic simulation, and live execution within a single
38//! event-driven architecture, providing research-to-live semantic parity.
39//!
40//! # Feature Flags
41//!
42//! This crate provides feature flags to control source code inclusion during compilation,
43//! depending on the intended use case, i.e. whether to provide Python bindings
44//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
45//! or as part of a Rust only build.
46//!
47//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
48//! - `extension-module`: Builds as a Python extension module.
49//!
50//! [High-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation#precision-mode) (128-bit value types) is enabled by default.
51
52#![warn(rustc::all)]
53#![deny(unsafe_code)]
54#![deny(nonstandard_style)]
55#![deny(missing_debug_implementations)]
56#![deny(clippy::missing_errors_doc)]
57#![deny(clippy::missing_panics_doc)]
58#![deny(rustdoc::broken_intra_doc_links)]
59// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
60// macro expansion; an item-level `allow` cannot reach the expansion
61#![allow(clippy::clone_on_copy)]
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};