Type safe limit order book
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.gitignore
.travis.yml
README.md
package.yaml
stack.yaml

README.md

Limit order book using safe-money

This library implements a limit order book using the safe-money library.

It supports two types of queries on order books:

  1. Sell/buy per quote/count currency: e.g. for the BTCUSD market, find out how many BTC you can purchase for a given amount of USD, or how many BTC you need to sell in order to earn a given USD amount
  2. Sell/buy per slippage: find out how much you can buy/sell while moving the market price up/down by the specified percentage

About the implementation

An order book is currently represented as follows:

data OrderBook (venue :: Symbol) (base :: Symbol) (quote :: Symbol) = OrderBook
   { obBids  :: Vector (Order base quote)
   , obAsks  :: Vector (Order base quote)
   }

that is, as a Vector of buy orders (bids) and sell orders (asks). The OrderBook type is parametized over -- using Symbols, ie. type-level strings -- the venue (exchange) in question, as well as the base currency (the currency in which order amounts are quoted) and the quote currency (the currency in which order prices are quoted).