1use crate::order::{Price, Symbol};
2use crate::order_book_side::BookSide;
3use fastnum::D128 as Dec;
4use fastnum::decimal::ParseError;
5
6#[derive(thiserror::Error, Debug)]
8pub enum Error {
9 #[error("expected: {expected}, received: {received}")]
11 InvalidSymbol { expected: Symbol, received: Symbol },
12
13 #[error(
15 "Limit buy order price {limit_price} must be better than top of sell price {sell_price}"
16 )]
17 LimitBuyOrderWorstThanTopOfSells { limit_price: Dec, sell_price: Dec },
18
19 #[error(
21 "Limit sell order price {limit_price} must be better than top of buy price {buy_price}"
22 )]
23 LimitSellOrderWorstThanTopOfBuys { limit_price: Dec, buy_price: Dec },
24
25 #[error(
27 "Limit price {limit_price} not better than top order price {top_order_price}"
28 )]
29 LimitPriceNotBetterThanTop {
30 book_side: BookSide,
31 limit_price: Price,
32 top_order_price: Price,
33 },
34
35 #[error("cannot parse decimal: {0}")]
37 DecimalParseError(#[from] ParseError),
38}