Skip to main content

backtest_server/
error.rs

1//! Error types for the backtest server.
2
3use thiserror::Error;
4
5/// All error variants the backtest server can produce.
6#[derive(Debug, Error)]
7pub enum BacktestServerError {
8    #[error("Configuration error: {0}")]
9    Config(String),
10
11    #[error("Database error: {0}")]
12    Database(#[from] data_preprocess::DataError),
13
14    #[error("Symbol not found: '{0}'")]
15    SymbolNotFound(String),
16
17    #[error("Profile not found: '{0}'")]
18    ProfileNotFound(String),
19
20    #[error("Profile error: {0}")]
21    Profile(String),
22
23    #[error("Invalid request: {0}")]
24    InvalidRequest(String),
25
26    #[error("No market data found for {symbol} on {exchange} ({data_type})")]
27    NoDataFound {
28        symbol: String,
29        exchange: String,
30        data_type: String,
31    },
32
33    #[error("Backtest cancelled")]
34    Cancelled,
35
36    #[error("Market-data stream error: {0}")]
37    MarketStream(String),
38
39    #[error("Backtest engine error: {0}")]
40    Engine(#[from] qs_core::CoreError),
41
42    #[error("Currency conversion error: {0}")]
43    Currency(#[from] qs_backtest::ConversionError),
44
45    #[error("Currency plan error: {0}")]
46    CurrencyPlan(#[from] qs_backtest::RunCurrencyPlanError),
47
48    #[error("IO error: {0}")]
49    Io(#[from] std::io::Error),
50
51    #[error("RPC error: {0}")]
52    Rpc(String),
53
54    #[error("Serialization error: {0}")]
55    Serde(String),
56}
57
58/// Convenience alias used throughout the backtest server.
59pub type Result<T> = std::result::Result<T, BacktestServerError>;