All Projects → qyvlik → redis-matching-engine-server

qyvlik / redis-matching-engine-server

Licence: other
Implement exchange matching engine by lua script, run in redis

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to redis-matching-engine-server

dingir-exchange
A high performance crypto trading engine
Stars: ✭ 169 (+333.33%)
Mutual labels:  matching-engine, exchange-server
pytradesimulator
Python based exchange simulator using FIX protocol
Stars: ✭ 20 (-48.72%)
Mutual labels:  matching-engine, exchange-server
clob
Simple limit order book and matching engine.
Stars: ✭ 17 (-56.41%)
Mutual labels:  matching-engine
gome
gome- Golang Match Engine, uses Golang for calculations, gRPC for services, ProtoBuf for data exchange, RabbitMQ for queues, and Redis for cache implementation of high-performance matching engine microservices/ gome-高性能撮合引擎微服务
Stars: ✭ 47 (+20.51%)
Mutual labels:  matching-engine
roq-samples
How to use the Roq C++20 API for Live Cryptocurrency Algorithmic and High-Frequency Trading as well as for Back-Testing and Historical Simulation
Stars: ✭ 119 (+205.13%)
Mutual labels:  matching-engine
matching-engine
Superfast Matching Engine written in golang
Stars: ✭ 35 (-10.26%)
Mutual labels:  matching-engine
orderbook-rs
Basic order matching engine written in Rust
Stars: ✭ 276 (+607.69%)
Mutual labels:  matching-engine
Purge-LogFiles
PowerShell script for Exchange Server 2013+ environments to clean up Exchange and IIS log files.
Stars: ✭ 22 (-43.59%)
Mutual labels:  exchange-server
CVE-2021-33766
ProxyToken (CVE-2021-33766) : An Authentication Bypass in Microsoft Exchange Server POC exploit
Stars: ✭ 37 (-5.13%)
Mutual labels:  exchange-server
Remove-DuplicateItems
Script to remove duplicate items from Exchange mailboxes.
Stars: ✭ 32 (-17.95%)
Mutual labels:  exchange-server
xExchange
This module contains DSC resources for deployment and configuration of Microsoft Exchange Server.
Stars: ✭ 62 (+58.97%)
Mutual labels:  exchange-server
alfredToday
Today menu Plugin for Alfred (generalized for public consumption)
Stars: ✭ 39 (+0%)
Mutual labels:  exchange-server
ExchangeAnalyzer
Exchange Analyzer - Checks Exchange Server 2013 or 2016 organizations for common configuration issues and recommended practices.
Stars: ✭ 100 (+156.41%)
Mutual labels:  exchange-server

redis-matching-engine-server

Implement matching engine by lua script, run in redis

export lua function

The exchange.lua sha256 value is ${EXCHANGE_LUA_HASH}.

deposit_for_user

deposit for user.

  • ${USER_ID}: user's id
  • ${SYMBOL}: symbol
  • ${AMOUNT}: deposit amount

return true or false.

redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.deposit_for_user(ARGV[1], ARGV[2], ARGV[3] );" \
  0 ${USER_ID} ${SYMBOL} ${AMOUNT}
1) true

submit_order

submit order to the order book, but do not match.

  • ${USER_ID}: user' id
  • ${SYMBOL}: base currency
  • ${CURRENCY}: quote currency
  • ${SIDE}: order side, such as buy or sell
  • ${PRICE}: order price
  • ${AMOUNT}: order amount
  • ${TS}: order create timestamp, unit is ms.

return the order id.

redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.submit_order(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5], ARGV[6], ARGV[7] );" \
  0 ${USER_ID} ${SYMBOL} ${CURRENCY} ${SIDE} ${PRICE} ${AMOUNT} ${TS}
1) 10001

cancel_order

remove the order from order book, and release the frozen asset for user.

  • ${ORDER_ID}: the order id which will be canceled.

return 1 if success.

redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.cancel_order(ARGV[1]);" \
  0 ${ORDER_ID}
1) 1

match_order

trigger match order.

  • ${SYMBOL}: base currency
  • ${CURRENCY}: quote currency
  • ${LIMIT}: hom mach size of the order will take from order book for match.
  • ${TS}: match timestamp, unit is ms.

return the size of order which be executed.

redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.match_order(ARGV[1], ARGV[2], ARGV[3], ARGV[4] );" \
  0 ${SYMBOL} ${CURRENCY} ${LIMIT} ${TS}
1) 1

get_order_json

get order json string.

  • ${ORDER_ID}: order id

return the order json string

redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.get_order_json(ARGV[1]);" \
  0 ${ORDER_ID}

response such as follow:

{
  "id": 1,
  "user_id": 1,
  "side": "buy",
  "stock_id": "BTC",
  "money_id": "USDT",
  "price": 4000.00,
  "amount": 1.0,
  "money": 4000.00,
  "process_amount": 0.0,
  "process_money": 0.0,
  "create_time": 1,
  "update_time": 1,
  "status": "create"
}
  • status: order status, the value is create, part, cancel, finish

get_depth_json

get the depth json string.

  • ${SYMBOL}: base currency
  • ${CURRENCY}: quote currency
  • ${LIMIT}: depth size
redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.get_depth_json(ARGV[1], ARGV[2], ARGV[3] );" \
  0 ${SYMBOL} ${CURRENCY} ${LIMIT}

response such as follow:

{
  "asks": [
    [4000, 1],
    [4001, 1],
  ],
  "bids":[
    [3999, 1],
    [3998, 1],
  ]
}

get_last_price

get the last match price.

  • ${SYMBOL}: base currency
  • ${CURRENCY}: quote currency

return the last price.

redis-cli> eval "local e = f_${EXCHANGE_LUA_HASH}(); \
  return e.get_last_price(ARGV[1], ARGV[2] );" \
  0 ${SYMBOL} ${CURRENCY}
1) 4000.00
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].