Giter VIP home page Giter VIP logo

galois's Introduction

Galois

License GitHub Workflow Status (branch)

免责声明

Galois是一款在Apache2许可协议下发布的开源软件。根据**2021年9月24日发布的政策文件,任何组织或个人,不得向**大陆境内公民提供虚拟货币交易服务,任何私自使用Galois向**大陆境内公民提供数字货币交易及相关服务的,面临的法律风险由使用者自行承担。

Introduction

Galois is an extremely high performance matching engine written in Rust.

Galois uses Event Sourcing pattern to handle tens of thousands of orders per second or even better, depending on the performance of persistence. Basic architecture is shown below.

                   core dump(disk)
                        ^
                        ^
                   +----------+
events(mysql)  >>  |  galois  |  >> match results(mysql)/best n price(redis)
                   +----------+
                        ^
                        ^
                 query requests(TCP) 
                       

Galois works as a component of Fusotao which is being WIP. The version without fusotao feature enabled can be used for building a high performance exchange with broker(refer to Guide to implement a broker). Buttttt, we strongly recommend you shall hire an expert before you do the business, seriously.

Getting Started

Dependencies

  • MySQL: persist the events and output the match result
  • Redis: output the best n price of the orderbook

Quick Start

Compile galois with nightly version. Then cp galois.toml.example galois.toml and modify the galois.toml the mysql and redis configurations, as well as the snapshot directory.

# init mysql
mysql -u {user_name} -p {database} < init.sql

# start redis
redis-server

galois -c galois.toml

Galois is now waiting for the incoming events and execute. Before you can execute orders, you need to issue a new pair and create a mysql table to receive the matching result outputs. The UserId is hex format of H256 with a mandatory 0x prefix or ss58check when fusotao enabled.

# create a table to receive outputs from galois, 100 and 101 represent the base currency code and the quote currency code.
create table t_clearing_result_100_101 like t_clearing_result;

# tell galois to create a new trading pair 101/100 with base_scale=4, quote_scale=4 and other parameters.
insert into t_sequence(f_cmd) values('{"base":101,"quote":100,"base_scale":4,"quote_scale":4,"taker_fee":"0.002","maker_fee":"0.002","min_amount":"0.1","min_vol":"10","enable_market_order":false,"open":true,"cmd":13}');

# account 1 tranfer 100.0 100 currency into galois
insert into t_sequence(f_cmd) values('{"currency":100,"amount":"100.0","cmd":11,"user_id":"0x0000000000000000000000000000000000000000000000000000000000000001"}');

# account 1 place an order(bid,symbol=101100,price=10.0,amount=0.5,user_id=1,order_id=1), order_id is generated by broker
insert into t_sequence(f_cmd) values('{"quote":100,"base":101,"cmd":1,"price":"10.0","amount":"0.5","order_id":1,"user_id":"0x0000000000000000000000000000000000000000000000000000000000000001"}');

If everything is ok, you could see a record in t_clearing_result_100_101 which means the order has been accepted. At the same time, a key V2_DEPTH_L32_101_100 would be available in redis to render the markets depth of 101100.

Instructions

ASK_LIMIT = 0;
BID_LIMIT = 1;
CANCEL = 4;
CANCEL_ALL = 5; # only available when fusotao disabled
TRANSFER_OUT = 10;
TRANSFER_IN = 11;
UPDATE_SYMBOL = 13;
QUERY_ORDER = 14;
QUERY_BALANCE = 15;
QUERY_ACCOUNTS = 16;
DUMP = 17;

License

Galois is licensed under Apache 2.0

galois's People

Contributors

kb1ns avatar hermannkowski avatar calldata avatar stewartye avatar pymongo avatar

Watchers

James Cloos avatar

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.