Skip to main content

nautilus_binance/python/
enums.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 Binance enums.
17
18use pyo3::prelude::*;
19
20use crate::common::enums::{BinanceEnvironment, BinanceProductType};
21
22#[pymethods]
23#[pyo3_stub_gen::derive::gen_stub_pymethods]
24impl BinanceProductType {
25    fn __repr__(&self) -> String {
26        format!(
27            "BinanceProductType.{}",
28            match self {
29                Self::Spot => "SPOT",
30                Self::Margin => "MARGIN",
31                Self::UsdM => "USD_M",
32                Self::CoinM => "COIN_M",
33                Self::Options => "OPTIONS",
34            }
35        )
36    }
37
38    fn __str__(&self) -> String {
39        match self {
40            Self::Spot => "SPOT",
41            Self::Margin => "MARGIN",
42            Self::UsdM => "USD_M",
43            Self::CoinM => "COIN_M",
44            Self::Options => "OPTIONS",
45        }
46        .to_string()
47    }
48}
49
50#[pymethods]
51#[pyo3_stub_gen::derive::gen_stub_pymethods]
52impl BinanceEnvironment {
53    fn __repr__(&self) -> String {
54        format!(
55            "BinanceEnvironment.{}",
56            match self {
57                Self::Mainnet => "MAINNET",
58                Self::Testnet => "TESTNET",
59                Self::Demo => "DEMO",
60            }
61        )
62    }
63
64    fn __str__(&self) -> String {
65        match self {
66            Self::Mainnet => "MAINNET",
67            Self::Testnet => "TESTNET",
68            Self::Demo => "DEMO",
69        }
70        .to_string()
71    }
72}