tesser_cli/
lib.rs

1pub mod alerts;
2pub mod analyze;
3pub mod app;
4pub mod control;
5pub mod data_validation;
6pub mod live;
7pub mod state;
8pub mod telemetry;
9
10pub use app::run as run_app;
11
12#[cfg(feature = "bybit")]
13pub use tesser_bybit::PublicChannel;
14
15#[cfg(not(feature = "bybit"))]
16pub use public_channel_stub::PublicChannel;
17
18#[cfg(not(feature = "bybit"))]
19mod public_channel_stub {
20    use std::str::FromStr;
21
22    use tesser_broker::BrokerError;
23
24    #[derive(Clone, Copy, Debug)]
25    pub enum PublicChannel {
26        Linear,
27        Inverse,
28        Spot,
29        Option,
30        Spread,
31    }
32
33    impl PublicChannel {
34        pub fn as_path(&self) -> &'static str {
35            match self {
36                Self::Linear => "linear",
37                Self::Inverse => "inverse",
38                Self::Spot => "spot",
39                Self::Option => "option",
40                Self::Spread => "spread",
41            }
42        }
43    }
44
45    impl FromStr for PublicChannel {
46        type Err = BrokerError;
47
48        fn from_str(value: &str) -> Result<Self, Self::Err> {
49            match value.to_lowercase().as_str() {
50                "linear" => Ok(Self::Linear),
51                "inverse" => Ok(Self::Inverse),
52                "spot" => Ok(Self::Spot),
53                "option" => Ok(Self::Option),
54                "spread" => Ok(Self::Spread),
55                other => Err(BrokerError::InvalidRequest(format!(
56                    "unsupported Bybit public channel '{other}'"
57                ))),
58            }
59        }
60    }
61}