Skip to main content

nautilus_bybit/python/
urls.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 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_stub_gen::derive::gen_stub_pyfunction(module = "nautilus_trader.bybit")]
28#[pyo3(name = "get_bybit_http_base_url")]
29pub fn py_get_bybit_http_base_url(environment: BybitEnvironment) -> &'static str {
30    urls::bybit_http_base_url(environment)
31}
32
33/// Gets the Bybit WebSocket URL for public data (market data).
34#[pyfunction]
35#[pyo3_stub_gen::derive::gen_stub_pyfunction(module = "nautilus_trader.bybit")]
36#[pyo3(name = "get_bybit_ws_url_public")]
37pub fn py_get_bybit_ws_url_public(
38    product_type: BybitProductType,
39    environment: BybitEnvironment,
40) -> String {
41    urls::bybit_ws_public_url(product_type, environment)
42}
43
44/// Gets the Bybit WebSocket URL for private data (account/order management).
45#[pyfunction]
46#[pyo3_stub_gen::derive::gen_stub_pyfunction(module = "nautilus_trader.bybit")]
47#[pyo3(name = "get_bybit_ws_url_private")]
48pub fn py_get_bybit_ws_url_private(environment: BybitEnvironment) -> &'static str {
49    urls::bybit_ws_private_url(environment)
50}
51
52/// Gets the Bybit WebSocket URL for trade operations (order placement/modification).
53#[pyfunction]
54#[pyo3_stub_gen::derive::gen_stub_pyfunction(module = "nautilus_trader.bybit")]
55#[pyo3(name = "get_bybit_ws_url_trade")]
56pub fn py_get_bybit_ws_url_trade(environment: BybitEnvironment) -> &'static str {
57    urls::bybit_ws_trade_url(environment)
58}