Git Product home page Git Product logo

jlob's Introduction

jLOB

L3 Order Book and Matching Engine

jLOB has all the basic capabilities of a functional exchange. Custom business logic can be defined by implementing orderbook listeners. It currently supports HTTP and FIX protocol communication.

There is also a UI repository that allows interacting with the orderbook. Full sample deployment: https://lob.eliquinox.com/

Configuration

PersistenceLimitOrderBookListener.java defines logic for storing orderbook events and caching orderbook state. Events are stored in PostgreSQL and orderbook state is cached in Redis. Reference config.local.yaml defines parameters for local execution of the application:

database:
  host: 127.0.0.1
  name: jlob
  port: 5432
  username: postgres
  password: postgres

redis:
  host: 127.0.0.1
  port: 6379

Create and start these dependencies accordingly.

Reference FIX server and FIX client configurations are provided in fix.server.cfg and fix.client.cfg accordingly.

Quickstart

To start the service:

gradle runBook

The task will create needed JOOQ classes and run DB migrations, creating needed tables. It will then start HTTP and FIX servers on http://127.0.0.1:4567 and tcp://127.0.0.1:9877.

Import jLOB.postman_collection.json into Postman to start exploring the API.

jLOB supports the following endpoints:

GET /book

Retrieves the current state of the orderbook:

Example response:

{
    "bids": {
        "90": {
            "side": "BID",
            "price": 90,
            "placements": [
                {
                    "uuid": "77b778eb-4304-41f8-9a75-3113c459907a",
                    "timestamp": {
                        "seconds": 1587682193,
                        "nanos": 398559000
                    },
                    "side": "BID",
                    "price": 90,
                    "size": 100
                }
            ]
        }
    },
    "offers": {
        "100": {
            "side": "OFFER",
            "price": 100,
            "placements": [
                {
                    "uuid": "6a6a90cc-3f7d-4514-b70e-dca1e1706415",
                    "timestamp": {
                        "seconds": 1587682203,
                        "nanos": 9953000
                    },
                    "side": "OFFER",
                    "price": 100,
                    "size": 100
                }
            ]
        }
    }
}

POST /book

Sends an order to the orderbook.

Example Request:

{
    "side": "offer",
    "price": 100,
    "size": 100000
}

Example Response:

{
    "uuid": "e08f8a3b-f38b-4a72-a2a9-2ae0cb8c9d1f",
    "timestamp": {
        "seconds": 1587682282,
        "nanos": 259523000
    },
    "side": "OFFER",
    "price": 100,
    "size": 10000
}

DEL /book

Cancels a given amount of an existing order.

Example Request:

{
    "id": "e08f8a3b-f38b-4a72-a2a9-2ae0cb8c9d1f",
    "size": 20
}

Example Response:

{
    "placementUuid": "e08f8a3b-f38b-4a72-a2a9-2ae0cb8c9d1f",
    "timestamp": {
        "seconds": 1587682397,
        "nanos": 728419000
    },
    "size": 20
}

POST /vwap

Retrieves a volume-weighted average price from the orderbook, given a side and a size of a hypothetical order.

Example Request:

{
    "action": "bid",
    "size": 10000
}

Example Response:

{
    "price": 100.00
}

jlob's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.