GithubHelp home page GithubHelp logo

java-matching-engine-rest-api's Introduction

Java-Matching-Engine REST API

Java CI with Maven

A matching engine written in Java.

What is a matching engine?

A matching engine matches buy and sell orders in a market.

Matching Algorithm

The matching engine uses a price-time-priority algorithm. The matching priority is firstly price, then time. Market participants are rewarded for offering the best price and coming early.

Usage

It is recommended that every user of this service audits and verifies all underlying code for its validity and suitability. Mistakes and bugs happen.

To use this project, you will need to include the 'core' and 'restapi' packages as part of your Spring configuration scanning (as seen below).

@SpringBootApplication(scanBasePackages = {"net.laffyco.javamatchingengine.core", "net.laffyco.javamatchingengine.restapi"})
public class ExampleApp {

    public static void main(final String[] args) {
        SpringApplication.run(ExampleApp.class, args);
    }

}

Usage Examples

Buying and Selling Example

Creating a maker order

User A creates a buy order of 2 items (e.g. 2 shares, 2 bitcoin, etc) with a price of 5 (e.g. £5, $5, etc)

Request
POST /api/v1/order/
		?side=BUY
		&amount=2
		&price=5
Response
{
  "trades": [],
  "id": "02923822-070b-448d-9240-f3623f90927a"
}

A unique ID is generated for the order (so that it can be modified/viewed). A list of trades is also returned. In this example the list of trades returned is empty as no trades have been made (due to the order book being empty).

Creating a taker order

User B creates a sell order of 2 items with a price of 5.

Request
POST api/v1//order/
		?side=SELL
		&amount=2
		&price=5
Response
{
  "trades": [
    {
      "takerOrderId": "12964731-2cd4-401b-ac8d-3853f58f75c0",
      "makerOrderId": "02923822-070b-448d-9240-f3623f90927a",
      "amount": 2,
      "price": 5
    }
  ],
  "id": "12964731-2cd4-401b-ac8d-3853f58f75c0"
}

As the sell order matches the buy order created earlier we can see that a trade has taken place.

java-matching-engine-rest-api's People

Contributors

laffini avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

java-matching-engine-rest-api's Issues

Fix GitHub Actions

GitHub actions are failing when the build works locally. Needs further investigation.

COMPILATION ERROR :
[INFO] -------------------------------------------------------------
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[17,47] package net.laffyco.javamatchingengine.core.api does not exist
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[18,50] package net.laffyco.javamatchingengine.core.engine does not exist
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[19,50] package net.laffyco.javamatchingengine.core.engine does not exist
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[35,13] cannot find symbol
symbol: class OrderInterface
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[43,29] cannot find symbol
symbol: class Order
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[56,41] cannot find symbol
symbol: class Side
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[55,24] cannot find symbol
symbol: class Order
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[69,69] cannot find symbol
symbol: class Side
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[84,41] cannot find symbol
symbol: class Side
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[100,41] cannot find symbol
symbol: class Side
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/OrderController.java:[103,53] cannot find symbol
symbol: class Side
location: class net.laffyco.javamatchingengine.restapi.controllers.OrderController
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/SpreadController.java:[10,47] package net.laffyco.javamatchingengine.core.api does not exist
Error: /home/runner/work/Java-Matching-Engine-REST-API/Java-Matching-Engine-REST-API/src/main/java/net/laffyco/javamatchingengine/restapi/controllers/SpreadController.java:[26,13] cannot find symbol
symbol: class SpreadInterface
location: class net.laffyco.javamatchingengine.restapi.controllers.SpreadController

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.