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