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("instrument '{symbol}' unavailable ({reason:?}): {details}")]
18 InstrumentUnavailable {
19 symbol: String,
20 reason: crate::rpc_types::InstrumentExclusionReasonMsg,
21 details: String,
22 },
23
24 #[error("instrument '{symbol}' is inactive at {at}: {details}")]
25 InactiveInstrument {
26 symbol: String,
27 at: chrono::DateTime<chrono::Utc>,
28 details: String,
29 },
30
31 #[error("no valid conversion tick for '{symbol}' strictly before {start}")]
32 ConversionWarmupUnavailable {
33 symbol: String,
34 start: chrono::NaiveDateTime,
35 },
36
37 #[error("replay admission rejected: {0}")]
38 AdmissionRejected(String),
39
40 #[error("Profile not found: '{0}'")]
41 ProfileNotFound(String),
42
43 #[error("Profile error: {0}")]
44 Profile(String),
45
46 #[error("Invalid request: {0}")]
47 InvalidRequest(String),
48
49 #[error("No market data found for {symbol} on {exchange} ({data_type})")]
50 NoDataFound {
51 symbol: String,
52 exchange: String,
53 data_type: String,
54 },
55
56 #[error("Backtest cancelled")]
57 Cancelled,
58
59 #[error("Backtest cancelled with a resumable research checkpoint")]
60 CancelledWithCheckpoint(Box<qs_research::SearchCheckpoint>),
61
62 #[error("Configured strategy replay failed: {0}")]
63 Strategy(String),
64
65 #[error("Market-data stream error: {0}")]
66 MarketStream(String),
67
68 #[error("{0}")]
69 MarketLoad(#[from] qs_market_loader::MarketLoadError),
70
71 #[error("Backtest engine error: {0}")]
72 Engine(#[from] qs_core::CoreError),
73
74 #[error("Currency conversion error: {0}")]
75 Currency(#[from] qs_backtest::ConversionError),
76
77 #[error("Currency plan error: {0}")]
78 CurrencyPlan(#[from] qs_backtest::RunCurrencyPlanError),
79
80 #[error("IO error: {0}")]
81 Io(#[from] std::io::Error),
82
83 #[error("RPC error: {0}")]
84 Rpc(String),
85
86 #[error("Serialization error: {0}")]
87 Serde(String),
88}
89
90pub type Result<T> = std::result::Result<T, BacktestServerError>;