nautilus_bybit/python/urls.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 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 wrapper functions for Bybit URL helpers.
17
18use pyo3::prelude::*;
19
20use crate::common::{
21 enums::{BybitEnvironment, BybitProductType},
22 urls,
23};
24
25/// Gets the Bybit HTTP base URL for the given environment.
26#[pyfunction]
27#[pyo3(name = "get_bybit_http_base_url")]
28pub fn py_get_bybit_http_base_url(environment: BybitEnvironment) -> &'static str {
29 urls::bybit_http_base_url(environment)
30}
31
32/// Gets the Bybit WebSocket URL for public data (market data).
33#[pyfunction]
34#[pyo3(name = "get_bybit_ws_url_public")]
35pub fn py_get_bybit_ws_url_public(
36 product_type: BybitProductType,
37 environment: BybitEnvironment,
38) -> String {
39 urls::bybit_ws_public_url(product_type, environment)
40}
41
42/// Gets the Bybit WebSocket URL for private data (account/order management).
43#[pyfunction]
44#[pyo3(name = "get_bybit_ws_url_private")]
45pub fn py_get_bybit_ws_url_private(environment: BybitEnvironment) -> &'static str {
46 urls::bybit_ws_private_url(environment)
47}
48
49/// Gets the Bybit WebSocket URL for trade operations (order placement/modification).
50#[pyfunction]
51#[pyo3(name = "get_bybit_ws_url_trade")]
52pub fn py_get_bybit_ws_url_trade(environment: BybitEnvironment) -> &'static str {
53 urls::bybit_ws_trade_url(environment)
54}