Exchange v0.1.0 Exchange.MatchingEngine View Source

This is the core of the Exchange The matching engine is responsible for matching the orders on the order book

Link to this section Summary

Functions

Returns the current minimum asking price

Returns the current highest asking volume

Returns the current maximum biding price

Returns the current maximum biding price

Cancels an order and removes it from the Order Book

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Returns the list of open orders

Returns the list of open orders from a trader

Returns the current Order Book

Places a limit order on the matching engine identified by the ticker. If there is a match the order is fullfilled otherwise it enters the orderbook queue at the chosen price point

Places an order on the matching engine identified by the ticker.

Places a marketable limit order on the matching engine identified by the ticker. The price of this order's price point is set with the min price (ask_min) if it is a buy order or with the max price(bid_max) if it is a sell order. If there is a match the order is fullfilled otherwise it enters the orderbook queue at the chosen price point

Returns the current Spread

Returns the number of open sell orders

Returns the number of open buy orders

Link to this section Types

Specs

ticker() :: atom()

Link to this section Functions

Specs

ask_min(ticker()) :: {atom(), number()}

Returns the current minimum asking price

Specs

ask_volume(ticker()) :: {atom(), number()}

Returns the current highest asking volume

Specs

bid_max(ticker()) :: {atom(), number()}

Returns the current maximum biding price

Specs

bid_volume(ticker()) :: {atom(), number()}

Returns the current maximum biding price

Link to this function

cancel_order(ticker, order_id)

View Source

Specs

cancel_order(ticker(), String.t()) :: atom()

Cancels an order and removes it from the Order Book

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for GenServer.init/1.

Specs

open_orders(ticker()) :: {atom(), list()}

Returns the list of open orders

Link to this function

open_orders_by_trader(ticker, trader_id)

View Source

Specs

open_orders_by_trader(ticker(), String.t()) :: {atom(), list()}

Returns the list of open orders from a trader

Link to this function

order_book_entries(ticker)

View Source

Specs

order_book_entries(ticker()) :: {atom(), Exchange.OrderBook.order_book()}

Returns the current Order Book

Link to this function

order_book_restore!(order_book)

View Source
Link to this function

place_limit_order(ticker, order)

View Source

Specs

place_limit_order(ticker(), Exchange.Order.order()) :: atom()

Places a limit order on the matching engine identified by the ticker. If there is a match the order is fullfilled otherwise it enters the orderbook queue at the chosen price point

Link to this function

place_market_order(ticker, order)

View Source

Specs

place_market_order(ticker(), Exchange.Order.order()) :: atom()

Places an order on the matching engine identified by the ticker.

The market order is set with the highest max_price for buying or the min_price for selling If there is sufficient liquidity on the order book the order is fullfilled otherwise the remaining unfulfilled order is put on the orderbook with the max/min price set

Link to this function

place_marketable_limit_order(ticker, order)

View Source

Specs

place_marketable_limit_order(ticker(), Exchange.Order.order()) :: atom()

Places a marketable limit order on the matching engine identified by the ticker. The price of this order's price point is set with the min price (ask_min) if it is a buy order or with the max price(bid_max) if it is a sell order. If there is a match the order is fullfilled otherwise it enters the orderbook queue at the chosen price point

Specs

spread(ticker()) :: {atom(), number()}

Returns the current Spread

Link to this function

total_ask_orders(ticker)

View Source

Specs

total_ask_orders(ticker()) :: {atom(), number()}

Returns the number of open sell orders

Link to this function

total_bid_orders(ticker)

View Source

Specs

total_bid_orders(ticker()) :: {atom(), number()}

Returns the number of open buy orders