/ OrderTypes / src / errors.jl
errors.jl
 1  @doc "Abstract type for order errors."
 2  abstract type OrderError <: Exception end
 3  @doc "There wasn't enough cash to setup the order."
 4  @kwdef struct NotEnoughCash{T<:Real} <: OrderError
 5      required::T
 6  end
 7  @doc "There weren't enough orders in the orderbook to match the amount."
 8  @kwdef struct NotEnoughLiquidity <: OrderError end
 9  @doc "Couldn't fullfill the order within the requested period."
10  @kwdef struct OrderTimeOut <: OrderError
11      order::O where {O<:Order}
12  end
13  @doc "Price and amount at execution time was outside the available ranges. (FOK)"
14  @kwdef struct NotMatched{T<:Real} <: OrderError
15      price::T
16      this_price::T
17      amount::T
18      this_volume::T
19  end
20  @doc "There wasn't enough volume to fill the order completely. (IOC)"
21  @kwdef struct NotFilled{T<:Real} <: OrderError
22      amount::T
23      this_volume::T
24  end
25  @doc "A generic error order prevented the order from being setup."
26  @kwdef struct OrderFailed <: OrderError
27      msg::Any
28  end
29  
30  @doc "When an order has been directly canceled by a strategy."
31  @kwdef struct OrderCanceled <: OrderError
32      order::O where {O<:Order}
33  end
34  
35  @doc "Order has been replaced by a liquidation order."
36  @kwdef struct LiquidationOverride <: OrderError
37      order::O where {O<:Order}
38      liqprice::T where {T<:Real}
39      liqdate::DateTime
40      p::PositionSide
41  end
42  
43  @doc "Abstract type for syncing errors (live)."
44  abstract type SyncError <: Exception end