README ¶
ex
- Order Matching Library for any asset (pkg/ex)
- Partial Fill
- Price Improvement
- Limit Order / Market Order with Protection
- STPF Cancel Remainder of Newest
- Post Only Cancel
- Fill-and-Kill
- Fill-or-Kill
- REST API (internal/request)
- Integrates with mesors/bc
Run Software
Install
Requires Go v1.11 or higher
make
Run
./mrex
Use Library
Install
go get github.com/mesors/ex/pkg/ex
Public Methods
// NewDB initializes a Data Storage Object
func NewDB() *DB
// AddOrder adds an Order to the Order Book or Matches it
func (db *DB) AddOrder(o *Order) error
// GetOrders finds and Returns all resting Client Orders from the Order Book using the Client Orders array
// If an Order ID is provided, one Client Order will be returned if it exists
func (db *DB) GetOrder(o *Order) error
// CancelOrder finds a Resting Order from the Order Book using Client Orders, and Cancels it
func (db *DB) CancelOrder(o *Order) error
// AddFeedback updates a Client's Feedback
func (db *DB) AddFeedback(f *Feedback) error
// CheckExpired searches for Expiring Objects and deletes them. Updates expiration counters
// To be called at ExpireCheck frequency
func (db *DB) CheckExpired()
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 | yes | valid address |
buy_product | string | yes | < 50 length |
buy_quantity | uint | yes | > 0 |
sell_product | string | yes | < 50 length |
sell_quantity | uint | yes | > 0 |
min_feedback | uint | yes | |
min_transact | uint | yes | |
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 | |
min_feedback | uint | yes | |
min_transact | 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 | |
min_feedback | uint | yes | |
min_transact | 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 | |
min_feedback | uint | yes | |
min_transact | 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 Fills [clearer]
Endpoint: GET /fills
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 |
Add Feedback [clearer]
Endpoint: POST /feedback
Content type: application/json
Request Body:
Name | Type | Required | Criteria |
---|---|---|---|
clearer_address | string | yes | valid address |
clearer_fill_id | uint | yes | valid fill ID |
maker_address | string | yes | valid address |
maker_feedback | bool | yes | |
taker_address | string | yes | valid address |
taker_feedback | bool | yes |
Response Body:
"Feedback Accepted"
Click to show internal directories.
Click to hide internal directories.