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, DatabentoDataClientConfig},
27 factories::DatabentoDataClientFactory,
28};
29
30#[pymethods]
31#[pyo3_stub_gen::derive::gen_stub_pymethods]
32impl DatabentoDataClientConfig {
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]
82 #[pyo3(name = "create_live_data_client")]
83 #[pyo3(signature = (client_id, api_key, publishers_filepath, use_exchange_as_venue = true, bars_timestamp_on_close = true))]
84 pub fn py_create_live_data_client(
85 client_id: ClientId,
86 api_key: String,
87 publishers_filepath: PathBuf,
88 use_exchange_as_venue: bool,
89 bars_timestamp_on_close: bool,
90 ) -> PyResult<DatabentoDataClient> {
91 Self::create_live_data_client(
92 client_id,
93 api_key,
94 publishers_filepath,
95 use_exchange_as_venue,
96 bars_timestamp_on_close,
97 get_atomic_clock_realtime(),
98 )
99 .map_err(to_pyruntime_err)
100 }
101}