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) and data
19//! models for 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/indexer-client/http> |
27//! | Indexer WebSocket API                | <https://docs.dydx.xyz/indexer-client/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.xyz/node-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//! - `examples`: Enables the crate's example binaries.
48//! - `extension-module`: Builds as a Python extension module.
49//! - `high-precision` (default): Enables
50//!   [high-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation/#precision-mode)
51//!   to use 128-bit value types.
52//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
53
54#![warn(rustc::all)]
55#![deny(unsafe_code)]
56#![deny(nonstandard_style)]
57#![deny(missing_debug_implementations)]
58#![deny(clippy::missing_errors_doc)]
59#![deny(clippy::missing_panics_doc)]
60#![deny(rustdoc::broken_intra_doc_links)]
61// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
62// macro expansion; an item-level `allow` cannot reach the expansion
63#![allow(clippy::clone_on_copy)]
64
65pub mod common;
66pub mod config;
67pub mod data;
68pub mod error;
69pub mod execution;
70pub mod factories;
71pub mod grpc;
72pub mod http;
73pub mod proto;
74pub mod types;
75pub mod websocket;
76
77#[cfg(feature = "python")]
78pub mod python;
79
80pub use crate::{
81    common::{
82        enums::{
83            DydxCandleResolution, DydxMarketStatus, DydxOrderSide, DydxOrderStatus, DydxOrderType,
84            DydxTickerType, DydxTimeInForce,
85        },
86        models::DydxAccount,
87    },
88    data::DydxDataClient,
89    error::DydxError,
90    factories::{DydxDataClientFactory, DydxExecutionClientFactory},
91    http::{
92        client::DydxHttpClient,
93        error::DydxHttpError,
94        models::{MarketsResponse, PerpetualMarket},
95    },
96    types::DydxOraclePrice,
97    websocket::{
98        client::DydxWebSocketClient,
99        enums::{DydxWsChannel, DydxWsOperation},
100        error::DydxWsError,
101    },
102};