A distributed fault-tolerant order book matching engine

Overview

Go - Between

Go Report Card License MIT Go Doc Release

A distributed fault-tolerant order book matching engine.

Features

  • Limit orders
  • Market orders
  • Order book depth
  • Calculate market price for a given quantity
  • Standard price/time priority
  • Distributed and fault-tolerant based on Raft Consensus Algorithm

Download binaries

You can download a pre-built binary here.

Build from source

First, install Go.

Next, fetch and build the binary.

go get -u github.com/danielgatis/go-between

How to init a cluster

First of all, start a new cluster:

go-between start --id=1 --market=USD/BTC --port=3001

And add a two more nodes:

go-between start --id=2 --market=USD/BTC --port=3002 --join=localhost:3001
go-between start --id=3 --market=USD/BTC --port=3003 --join=localhost:3001

API Endpoints

Each node publishes a REST API with the following endpoints.

Adding a new limit order

curl --request POST \
  --url http://127.0.0.1:3001/orders/limit \
  --header 'Content-Type: application/json' \
  --data '{
	"orderId": "1",
	"traderId": "1",
	"market": "USD/BTC",
	"side": "sell",
	"quantity": "1",
	"price": "400.00"
}'

Adding a new market order

curl --request POST \
  --url http://127.0.0.1:3001/orders/market \
  --header 'Content-Type: application/json' \
  --data '{
	"orderId": "2",
	"traderId": "1",
	"market": "USD/BTC",
	"side": "sell",
	"quantity": "1",
	"price": "400.00"
}'

Cancel an order

curl --request DELETE --url http://127.0.0.1:3001/orders/1

Calculate a market price

curl --request POST \
  --url http://127.0.0.1:3001/prices/market \
  --header 'Content-Type: application/json' \
  --data '{
	"traderId": "1",
	"market": "USD/BTC",
	"side": "sell",
	"quantity": "10"
}'

Get the order book price depth

curl --request GET --url http://127.0.0.1:3001/prices/depth

Get the full order book

curl --request GET --url http://127.0.0.1:3001/orderbook

Get the raft node stats

curl --request GET --url http://127.0.0.1:3001/raft/stats

License

Copyright (c) 2021-present Daniel Gatis

Licensed under MIT License

Buy me a coffee

Liked some of my work? Buy me a coffee (or more likely a beer)

Buy Me A Coffee

Owner
Daniel Gatis
Daniel Gatis
The lightweight, distributed relational database built on SQLite

rqlite is a lightweight, distributed relational database, which uses SQLite as its storage engine. Forming a cluster is very straightforward, it grace

rqlite 8.9k Sep 17, 2021
Fast, efficient, and scalable distributed map/reduce system, DAG execution, in memory or on disk, written in pure Go, runs standalone or distributedly.

Gleam Gleam is a high performance and efficient distributed execution system, and also simple, generic, flexible and easy to customize. Gleam is built

Chris Lu 2.9k Sep 18, 2021
Lightweight, fault-tolerant message streams.

Liftbridge provides lightweight, fault-tolerant message streams by implementing a durable stream augmentation for the NATS messaging system. It extend

Liftbridge 2.1k Sep 16, 2021
High performance, distributed and low latency publish-subscribe platform.

Emitter: Distributed Publish-Subscribe Platform Emitter is a distributed, scalable and fault-tolerant publish-subscribe platform built with MQTT proto

emitter 3k Sep 17, 2021
Scalable, fault-tolerant application-layer sharding for Go applications

ringpop-go (This project is no longer under active development.) Ringpop is a library that brings cooperation and coordination to distributed applicat

Uber Open Source 696 Sep 12, 2021
⟁ Tendermint Core (BFT Consensus) in Go

Tendermint Byzantine-Fault Tolerant State Machines. Or Blockchain, for short. Branch Tests Coverage Linting master Tendermint Core is Byzantine Fault

Tendermint 4.3k Sep 26, 2021
Go Open Source, Distributed, Simple and efficient Search Engine

Go Open Source, Distributed, Simple and efficient full text search engine.

ego 6k Sep 26, 2021
ecommerce microservice

Digota - ecommerce microservice Digota is ecommerce microservice built to be the modern standard for ecommerce systems.It is based on grpc,protocol-bu

Digota 405 Sep 11, 2021
Kafka implemented in Golang with built-in coordination (No ZK dep, single binary install, Cloud Native)

Jocko Kafka/distributed commit log service in Go. Goals of this project: Implement Kafka in Go Protocol compatible with Kafka so Kafka clients and ser

Travis Jeffery 4.4k Sep 18, 2021
Compute cluster (HPC) job submission library for Go (#golang) based on the open DRMAA standard.

go-drmaa This is a job submission library for Go (#golang) which is compatible to the DRMAA standard. The Go library is a wrapper around the DRMAA C l

Daniel Gruber 34 Sep 19, 2021
A distributed key-value storage system developed by Alibaba Group

Product Overview Tair is fast-access memory (MDB)/persistent (LDB) storage service. Using a high-performance and high-availability distributed cluster

Alibaba 1.8k Sep 14, 2021
Distributed Named Pipes

dnpipes Distributed Named Pipes (or: dnpipes) are essentially a distributed version of Unix named pipes comparable to, for example, SQS in AWS or the

Michael Hausenblas 451 Aug 17, 2021
Golang implementation of the Raft consensus protocol

raft raft is a Go library that manages a replicated log and can be used with an FSM to manage replicated state machines. It is a library for providing

HashiCorp 5.1k Sep 26, 2021
CockroachDB - the open source, cloud-native distributed SQL database.

CockroachDB is a cloud-native distributed SQL database designed to build, scale, and manage modern, data-intensive applications. What is CockroachDB?

CockroachDB 22.1k Sep 17, 2021
A feature complete and high performance multi-group Raft library in Go.

Dragonboat - A Multi-Group Raft library in Go / δΈ­ζ–‡η‰ˆ News 2021-01-20 Dragonboat v3.3 has been released, please check CHANGELOG for all changes. 2020-03

lni 3.8k Sep 22, 2021
Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.

Dapr is a portable, serverless, event-driven runtime that makes it easy for developers to build resilient, stateless and stateful microservices that run on the cloud and edge and embraces the diversity of languages and developer frameworks.

Dapr 14.7k Sep 21, 2021
A standard library for microservices.

Go kit Go kit is a programming toolkit for building microservices (or elegant monoliths) in Go. We solve common problems in distributed systems and ap

Go kit 21.3k Sep 18, 2021
JuiceFS is a distributed POSIX file system built on top of Redis and S3.

JuiceFS is a high-performance POSIX file system released under GNU Affero General Public License v3.0. It is specially optimized for the cloud-native

Juicedata, Inc 3.7k Sep 24, 2021