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