1use rust_decimal::Decimal;
7
8#[derive(Debug, thiserror::Error)]
10pub enum FinError {
11 #[error("Symbol '{0}' is invalid (empty or contains whitespace)")]
13 InvalidSymbol(String),
14
15 #[error("Price must be positive, got {0}")]
17 InvalidPrice(Decimal),
18
19 #[error("Quantity must be non-negative, got {0}")]
21 InvalidQuantity(Decimal),
22
23 #[error("Order book sequence mismatch: expected {expected}, got {got}")]
25 SequenceMismatch { expected: u64, got: u64 },
26
27 #[error("No liquidity available for requested quantity {0}")]
29 InsufficientLiquidity(Decimal),
30
31 #[error("OHLCV bar invariant violated: {0}")]
33 BarInvariant(String),
34
35 #[error("Signal '{name}' not ready (requires {required} periods, have {have})")]
37 SignalNotReady {
38 name: String,
39 required: usize,
40 have: usize,
41 },
42
43 #[error("Position not found for symbol '{0}'")]
45 PositionNotFound(String),
46
47 #[error("Insufficient funds: need {need}, have {have}")]
49 InsufficientFunds {
50 need: Decimal,
51 have: Decimal,
52 },
53
54 #[error("Timeframe duration must be positive")]
56 InvalidTimeframe,
57
58 #[error("CSV parse error: {0}")]
60 CsvParse(String),
61
62 #[error("Arithmetic overflow in financial calculation")]
64 ArithmeticOverflow,
65}