1use thiserror::Error;
4
5#[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("Backtest cancelled with a resumable research checkpoint")]
37 CancelledWithCheckpoint(Box<qs_research::SearchCheckpoint>),
38
39 #[error("Configured strategy replay failed: {0}")]
40 Strategy(String),
41
42 #[error("Market-data stream error: {0}")]
43 MarketStream(String),
44
45 #[error("{0}")]
46 MarketLoad(#[from] qs_market_loader::MarketLoadError),
47
48 #[error("Backtest engine error: {0}")]
49 Engine(#[from] qs_core::CoreError),
50
51 #[error("Currency conversion error: {0}")]
52 Currency(#[from] qs_backtest::ConversionError),
53
54 #[error("Currency plan error: {0}")]
55 CurrencyPlan(#[from] qs_backtest::RunCurrencyPlanError),
56
57 #[error("IO error: {0}")]
58 Io(#[from] std::io::Error),
59
60 #[error("RPC error: {0}")]
61 Rpc(String),
62
63 #[error("Serialization error: {0}")]
64 Serde(String),
65}
66
67pub type Result<T> = std::result::Result<T, BacktestServerError>;