Skip to main content

nautilus_kalshi/python/
factories.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 Kalshi factory types.
17
18use pyo3::prelude::*;
19
20use crate::{
21    common::consts::KALSHI,
22    factories::{KalshiDataClientFactory, KalshiExecutionClientFactory},
23};
24
25#[pymethods]
26#[pyo3_stub_gen::derive::gen_stub_pymethods]
27impl KalshiDataClientFactory {
28    /// Factory for creating Kalshi data clients.
29    ///
30    /// Streaming is limited to `instrument_ids` on the data config. Construction requires the
31    /// calling thread's data-event sender because the client cannot install one later.
32    #[new]
33    fn py_new() -> Self {
34        Self::new()
35    }
36
37    #[pyo3(name = "name")]
38    fn py_name(&self) -> &'static str {
39        KALSHI
40    }
41}
42
43#[pymethods]
44#[pyo3_stub_gen::derive::gen_stub_pymethods]
45impl KalshiExecutionClientFactory {
46    /// Factory for creating Kalshi execution clients.
47    ///
48    /// The node supplies `trader_id`. The client always uses a USD cash account and netting OMS.
49    /// A bound execution sender is installed during construction; `start` installs the sender again.
50    #[new]
51    fn py_new() -> Self {
52        Self::new()
53    }
54
55    #[pyo3(name = "name")]
56    fn py_name(&self) -> &'static str {
57        KALSHI
58    }
59}