gitbitex / gitbitex-spot

An Open Source Cryptocurrency Exchange
https://gitbitex.com:8080/trade/BTC-USDT
488 stars 252 forks source link

Application work flow #15

Open amitsharma8891 opened 4 years ago

amitsharma8891 commented 4 years ago

Dear @greensheng,

First of all Awesome work. Can you help me to understand or have any documentation for how the order gets settled? For eg. When we place the it first goes to the MySQL database after that we push it into Kafka. After this, how/where we read it? I mean how we execute our code to settle the order. If you can share any block diagram that would be really helpful.

Also, I was thinking can we consider separate tables for each currency Pair order and order settlement. For e.g. Consider the Pair BTC_USDT for that, we'll have BTC_USDT_order, BTC_USDT_trade and so on

greensheng commented 4 years ago

Hi The match engine will use KafkaOrderReader to read the order, and the match engine will generate a series of match logs (MatchLog, DoneLog, OpenLog). FillMaker will read these logs and insert the Fill into the database, and then FillExecutor will execute these fill logs

It is necessary to operate separate tables, especially for high-frequency trading system. But it may take some work to accomplish this, and we will consider the implementation later.

amitsharma8891 commented 4 years ago

Thanks for your, response.

I am trying to build an exchange with a separate Currency pair table for each currency as mentioned above thread. But I couldn't understand the whole life cycle of the application. Also, I want to use MongoDB as a secondary database. That means all read data will come from mongo only and all order creation will take place in MongoDB.

It would be really helpful if you can explain a little bit more about Application life cycle(workflow) with block diagram

Also, Should we consider the MongoDB as a secondary database?

Sorry, if it's too much to ask.

greensheng commented 4 years ago

Sorry, there are not many documents at present. I will write some documents later to explain the design idea of gitbitex

If you want to use MongoDB as storage, you just need to implement the store.go interface, https://github.com/gitbitex/gitbitex-spot/blob/master/models/store.go

amitsharma8891 commented 4 years ago

Let me know if you need some helping hand to create the documentation as I have some spare time.

ztg1 commented 4 years ago

我还是有点看不到撮合是怎么实现