1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
/// Defines the possible order errors that can occur when submitting a new order
pub enum OrderError {
    /// Maximum number of active orders reached
    MaxActiveOrders,
    /// Invalid limit price of order
    InvalidLimitPrice,
    /// Invalid trigger price for order. e.g.: sell stop market order trigger price > ask
    InvalidTriggerPrice,
    /// Invalid order size
    InvalidOrderSize,
    /// The account does not have enough available balance to submit the order
    NotEnoughAvailableBalance,
}

/// Describes possible Errors that may occur when calling methods in this crate
#[derive(thiserror::Error, Debug)]
pub enum Error {
    /// Config::new was provided an invalid leverage value
    #[error("Wrong leverage provided")]
    ConfigWrongLeverage,

    /// Config::new was provided an invalid starting balance
    #[error("Wrong starting balance provided")]
    ConfigWrongStartingBalance,
}

/// This is defined as a convenience.
pub type Result<T> = std::result::Result<T, Error>;