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