[][src]Crate lobster

Lobster implements a single-threaded order book. To use Lobster, create an order book instance with default parameters, and send orders for execution:

use lobster::{FillMetadata, OrderBook, OrderEvent, OrderType, Side};

let mut ob = OrderBook::default();
let event = ob.execute(OrderType::Market { id: 0, qty: 1, side: Side::Bid });
assert_eq!(event, OrderEvent::Unfilled { id: 0 });

let event = ob.execute(OrderType::Limit { id: 1, price: 120, qty: 3, side: Side::Ask });
assert_eq!(event, OrderEvent::Placed { id: 1 });

let event = ob.execute(OrderType::Market { id: 2, qty: 4, side: Side::Bid });
assert_eq!(
    event,
    OrderEvent::PartiallyFilled {
        id: 2,
        filled_qty: 3,
        fills: vec![
            FillMetadata {
                order_1: 2,
                order_2: 1,
                qty: 3,
                price: 120,
            }
        ],
    },
);

Lobster only deals in integer price points and quantities. Prices and quantities are represented as unsigned 64-bit integers. If the traded instrument supports fractional prices and quantities, the conversion needs to be handled by the user. At this time, Lobster does not support negative prices.

Structs

BookDepth

A snapshot of the order book up to a certain depth level. Multiple orders at the same price points are merged into a single BookLevel struct.

BookLevel

A single level in the order book. This struct is used both for the bid and ask side.

FillMetadata

Information on a single order fill. When an order is matched with multiple resting orders, it generates multiple FillMetadata values.

OrderBook

An order book that executes orders serially through the execute method.

Trade

A trade that happened as part of the matching process.

Enums

OrderEvent

An event resulting from the execution of an order.

OrderType

An order to be executed by the order book.

Side

An order book side.