README ¶
match
- Order Matching Library for any asset (pkg/match)
- Partial Fill
- Price Improvement
- Limit Order / Market Order with Protection
- STPF Cancel Remainder of Newest
- Post Only Cancel
- Fill-and-Kill
- Fill-or-Kill
- Pre-trade Risk check on Balances
- REST API (internal/request)
- Integrates with mesors/clear
In this alternative exchange architecture, Exchange and Clearing functions are modular and can (if required) be hosted by different parties.
Funds or assets are only transferred to the clearer (for escrow purposes) after a trade. In order to ensure counter-party reliability and therefore a healthy market, new clients must clear funds prior to submitting their order, until the Clearer approves Post-trade Clearing for that Client.
This system differs from convention in that it:
- Is entirely Open-Source
- De-couples Clearing and Exchange functions (similar to institutional setups)
- Doesn't hold client funds apart from for Escrow purposes
- Is designed to support any asset including Financial tokens and Data (trade data for data or currency).
Run Software
Install
Requires Go v1.11 or higher
make
Run
./mrm
Options
Option | Abbreviated | Default | Details |
---|---|---|---|
--cleareraddr= | -c | cccccccccccccccc | Remote Clearer Address |
Use Library
Install
go get github.com/mesors/match/pkg/match
REST API
Add Order [client]
Endpoint: POST /orders
Content Type: application/json
Request Body:
Name | Type | Required | Criteria |
---|---|---|---|
client_address | string | yes | valid address |
clearer_address | string | no | |
buy_product | string | yes | < 50 length |
buy_quantity | uint | yes | > 0 |
sell_product | string | yes | < 50 length |
sell_quantity | uint | yes | > 0 |
status | string | yes | "new" |
modifier | string | no | "post only" / "fill or kill" / "fill and kill" |
expire | uint | yes | > 0 |
client_order_id | uint | yes | unique client id > 0 |
Response Body:
Name | Type | Required | Criteria |
---|---|---|---|
client_address | string | yes | valid address |
clearer_address | string | yes | valid address |
buy_product | string | yes | |
buy_quantity | uint | yes | |
sell_product | string | yes | |
sell_quantity | uint | yes | |
status | string | yes | "active" / "filled" / "partial" / "cancelled" / "cancelled remainder self trade" / "cancelled post only" / "cancelled remainder fill and kill" / "cancelled fill or kill" |
modifier | string | no | "post only" / "fill or kill" / "fill and kill" |
expire | uint | yes | > 0 |
client_order_id | uint | yes | unique client id |
Get Order [client]
Endpoint: GET /orders
Content Type: application/json
Request Body:
Name | Type | Required | Criteria |
---|---|---|---|
client_address | string | yes | valid address |
client_order_id | uint | no | unique client id |
Response Body:
Name | Type | Required | Criteria |
---|---|---|---|
client_address | string | yes | valid address |
clearer_address | string | yes | valid address |
buy_product | string | yes | |
buy_quantity | uint | yes | |
sell_product | string | yes | |
sell_quantity | uint | yes | |
status | string | yes | "active" / "partial" |
modifier | string | no | "post only" / "fill or kill" / "fill and kill" |
expire | uint | yes | > 0 |
client_order_id | uint | yes | unique client id |
Cancel Order [client]
Endpoint: DELETE /orders
Content Type: application/json
Request Body:
Name | Type | Required | Criteria |
---|---|---|---|
client_address | string | yes | valid address |
client_order_id | uint | yes | unique client id |
Response Body:
Name | Type | Required | Criteria |
---|---|---|---|
client_address | string | yes | valid address |
clearer_address | string | yes | valid address |
buy_product | string | yes | |
buy_quantity | uint | yes | |
sell_product | string | yes | |
sell_quantity | uint | yes | |
status | string | yes | "cancelled" |
modifier | string | no | "post only" / "fill or kill" / "fill and kill" |
expire | uint | yes | > 0 |
client_order_id | uint | yes | unique client id |
Get Deals [clearer]
Endpoint: GET /deals
Content Type: application/json
Request Body:
Name | Type | Required | Criteria |
---|---|---|---|
clearer_address | string | yes | valid address |
Response Body:
Name | Type | Required | Criteria |
---|---|---|---|
id | uint | yes | unique clearer fill id |
clearer_address | string | yes | valid address |
maker_fill: client_address | string | yes | valid address |
maker_fill: client_order_id | uint | yes | |
maker_fill: buy_product | string | yes | |
maker_fill: buy_quantity | uint | yes | |
maker_fill: sell_product | string | yes | |
maker_fill: sell_quantity | uint | yes | |
taker_fill: client_address | string | yes | valid address |
taker_fill: client_order_id | uint | yes | |
taker_fill: buy_product | string | yes | |
taker_fill: buy_quantity | uint | yes | |
taker_fill: sell_product | string | yes | |
taker_fill: sell_quantity | uint | yes | |
expire | uint | yes |
Update Client [clearer]
Endpoint: POST /clients
Content type: application/json
Request Body:
Name | Type | Required | Criteria |
---|---|---|---|
clearer_address | string | yes | valid address |
client_address | string | yes | valid address |
approved | bool | yes | |
balance | map[string]int | yes | (product : new balance) (updated balances only) |
Response Body:
"Client Update Accepted"