nautilus_databento/python/
factories.rs1use std::path::PathBuf;
19
20use nautilus_core::{python::to_pyruntime_err, time::get_atomic_clock_realtime};
21use nautilus_model::identifiers::ClientId;
22use pyo3::prelude::*;
23
24use crate::{
25 data::DatabentoDataClient,
26 factories::{DatabentoDataClientFactory, DatabentoLiveClientConfig},
27};
28
29#[pymethods]
30#[pyo3_stub_gen::derive::gen_stub_pymethods]
31impl DatabentoLiveClientConfig {
32 #[new]
34 #[pyo3(signature = (api_key, publishers_filepath, use_exchange_as_venue=false, bars_timestamp_on_close=true))]
35 fn py_new(
36 api_key: String,
37 publishers_filepath: std::path::PathBuf,
38 use_exchange_as_venue: bool,
39 bars_timestamp_on_close: bool,
40 ) -> Self {
41 Self::new(
42 api_key,
43 publishers_filepath,
44 use_exchange_as_venue,
45 bars_timestamp_on_close,
46 )
47 }
48
49 fn __repr__(&self) -> String {
50 format!("{self:?}")
51 }
52}
53
54#[pymethods]
55#[pyo3_stub_gen::derive::gen_stub_pymethods]
56impl DatabentoDataClientFactory {
57 #[new]
59 fn py_new() -> Self {
60 Self
61 }
62
63 #[pyo3(name = "name")]
64 fn py_name(&self) -> &'static str {
65 "DATABENTO"
66 }
67
68 #[staticmethod]
70 #[pyo3(signature = (client_id, api_key, publishers_filepath, use_exchange_as_venue = true, bars_timestamp_on_close = true))]
71 pub fn py_create_live_data_client(
72 client_id: ClientId,
73 api_key: String,
74 publishers_filepath: PathBuf,
75 use_exchange_as_venue: bool,
76 bars_timestamp_on_close: bool,
77 ) -> PyResult<DatabentoDataClient> {
78 Self::create_live_data_client(
79 client_id,
80 api_key,
81 publishers_filepath,
82 use_exchange_as_venue,
83 bars_timestamp_on_close,
84 get_atomic_clock_realtime(),
85 )
86 .map_err(to_pyruntime_err)
87 }
88}