Skip to main content

nautilus_binance/python/
mod.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//! Python bindings for the Binance adapter.
17
18pub mod enums;
19pub mod http_futures;
20pub mod http_spot;
21pub mod websocket_futures;
22pub mod websocket_spot;
23
24use pyo3::prelude::*;
25
26use crate::{
27    common::enums::{BinanceEnvironment, BinancePositionSide, BinanceProductType},
28    futures::{
29        http::{
30            client::BinanceFuturesHttpClient,
31            query::{
32                BatchCancelItem as FuturesBatchCancelItem,
33                BatchModifyItem as FuturesBatchModifyItem, BatchOrderItem as FuturesBatchOrderItem,
34            },
35        },
36        websocket::client::BinanceFuturesWebSocketClient,
37    },
38    spot::{
39        http::{
40            client::BinanceSpotHttpClient,
41            query::{BatchCancelItem as SpotBatchCancelItem, BatchOrderItem as SpotBatchOrderItem},
42        },
43        websocket::streams::client::BinanceSpotWebSocketClient,
44    },
45};
46
47/// Binance adapter Python module.
48///
49/// Loaded as `nautilus_pyo3.binance`.
50///
51/// # Errors
52///
53/// Returns an error if module initialization fails.
54#[pymodule]
55pub fn binance(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
56    m.add_class::<BinanceProductType>()?;
57    m.add_class::<BinanceEnvironment>()?;
58    m.add_class::<BinancePositionSide>()?;
59    m.add_class::<BinanceSpotHttpClient>()?;
60    m.add_class::<BinanceFuturesHttpClient>()?;
61    m.add_class::<BinanceSpotWebSocketClient>()?;
62    m.add_class::<BinanceFuturesWebSocketClient>()?;
63    m.add_class::<FuturesBatchOrderItem>()?;
64    m.add_class::<FuturesBatchCancelItem>()?;
65    m.add_class::<FuturesBatchModifyItem>()?;
66    m.add_class::<SpotBatchOrderItem>()?;
67    m.add_class::<SpotBatchCancelItem>()?;
68
69    Ok(())
70}