Live demo here: https://exchange.crypttops.com/
I am helping setup this exchange for anyone interested. It apears the initial master of the code: Jammy928 isn't keen on responding to querries from anyone.
Maybe The best open source core code exchange in the entire net, the architecture/code quality is visible.
Statement 1: I will charge setup fees on this project as it doesn't work as it's provided for by Jammy.
Statement 2: The APP source code and the trading robot source code are not open source (provided for a fee), if necessary, whatsapp: +254795557216
.
This project is a bitcoin exchange based on Java (SpringCloud) | BTC exchange | ETH exchange | digital currency exchange | trading platform | matching trading engine. This project is based on the development of Spring Cloud microservices, which can be used to build and secondary development digital currency exchanges, and has a complete system component.
- Match trading engine.
- Background management (back-end + front-end)
- Frontend (transaction page, event page, personal center, etc.))
- Native Android APP source code
- Native Apple APP source code
- Currency wallet RPC source code
- Multi Language Support(Simple Chinese、English)
Just draw a few sketches, just look at it。。。
PC front end (user web end):https://gitee.com/cexchange/CoinExchange/attach_files
Mobile APP:https://gitee.com/cexchange/CoinExchange/attach_files
Management background:https://gitee.com/cexchange/CoinExchange/attach_files
Development Reference Document:https://gitee.com/cexchange/CoinExchange/blob/master/DEVELOP.md
Manage background screenshots:https://gitee.com/cexchange/CoinExchange/tree/master/09_DOC/管理后台截图
If you want to build an exchange system on your computer or cloud server, I have prepared some basic deployment manuals. Of course, installing software on linux/unix is not a simple matter. You need to have a certain Linux basics and command line skills, but also the courage and patience to solve problems, I wish you success!
- Server Configuration Reference Manual
- Installation Basic Environment Manual
- Service deployment script
- Install MySql Manual
- Install Redis Manual
- Install Zookeeper Manual
- Install Kafka Manual
- nstall Mongodb manual
- Building a BTC wallet node manual
- Building ETH Wallet Node Manual
- Manual of Building USDT Wallet Node
Spring Cloud is an ordered collection of frameworks. It uses Spring Boot's development convenience to subtly simplify the development of distributed system infrastructure, such as service discovery registration, configuration center, message bus, load balancing, circuit breaker, data monitoring, etc., can be done using Spring Boot's development style One click to start and deploy. Spring Cloud does not repeat the manufacturing of wheels. It just combines the mature and practical service frameworks developed by various companies. The re-encapsulation through the Spring Boot style shields the complex configuration and implementation principles, and finally gives the development The author has left a set of distributed system development kits that are simple to understand, easy to deploy, and easy to maintain. In general, a complete Spring Cloud framework should be as shown in the following figure:
If you are unfamiliar with Spring Cloud, you can simply learn about Spring Cloud related tutorials first, so that you will come back to this project and it will be easier to get started. As a reminder, because the Springcloud framework diagram is a complete architecture, we will tailor some content appropriately during development to make development and deployment faster, so there are some discrepancies.
The system uses memory matching for the transaction queue, Kafka is used for matching order information transmission, MongoDB persists the order transaction details, and MySQL records the overall order transaction. Among them, the 01_Framework/Exchange project is mainly responsible for memory matching, and the 01_Framework/Market project is mainly responsible for order transaction persistence, market generation, market push and other services, including:
- K-line data, the intervals are: 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 1 day, 1 week, 1 month
- Market depth data for all trading pairs
- The latest prices of all trading pairs
- Recently traded pairs
Modes supported by memory matching transactions
- Matching of limit order and limit order
- Matching market orders and limit orders
- Matching limit orders with market orders
- Matching market orders with market orders
Limit & Market Order Processing Logic
Note: This picture is a long time ago, the logic in the latest code is more complicated
Other features supported by match engine
In addition to the ordinary matching functions of limit and market prices, the matching trading engine of this system also introduces an active transaction mode. By setting the trading start time, initial issuance volume, initial issuance price, and activity of trading pairs (such as BTC/USDT) Modes and other parameters can formulate a wealth of matching transaction modes to meet different matching modes.
for example
The exchange is expected to launch the trading pair AAA/USDT at 12:00:00 on August 8, 2020, but as a newly launched currency, how can it work without activity? The project party or the exchange decided to come up with 10,000 AAA at a price of 0.0001USDT (market price: 0.0005) for everyone to snap up. The system supports the setting of such activities.
In addition, if the project party or the exchange decides to take out 10,000 AAAs to issue at the price of 0.0001USDT, I don’t want everyone to snap up, but hope that all users who recharge USDT can divide 10,000 AAAs on average. This system also supports the setting of this activity .
to sum up
n short, this system supports a highly customized matching mode. At the same time, you can also develop your own matching transaction mode, just by modifying the matching logic in the Exchange project.
- Backend development:Spring、SpringMVC、SpringData、SpringCloud、SpringBoot
- DataBase:Mysql、Mongodb
- Other:redis、kafka、Ali OSS、Tencent Captcha
- Frontend:Vue、iView、less
This was done for the customer, but later the customer stopped operating, so this website was left, because I don’t have server permissions, so this website may not be accessible at any time.
Building a test site requires purchasing several cloud servers, which cost a lot, so I did not set up a test station myself, but the system is complete and has passed the commercial and practical operation test for nearly a year.
About trading robots
Trading robots are automatic trading programs that can automatically trade based on external market conditions, so that the exchange's trading pair prices are consistent with the external, preventing losses caused by some users "moving bricks".
==============================================
- Centos 6.8
- MySQL 5.5.16
- Redis-x64-3.2.100
- Mongodb 3.6.13
- kafka_2.11-2.2.1
- nginx-1.16.0
- JRE 8u241
- JDK 1.8
- Vue
- Zookeeper
00_framework
└─———admin Background management API
└─———bitrade-job Task management(Empty)
└─———chat OTC Chat
└─———cloud SpringCloud Eureka
└─———core Core
└─———exchange match trading
└─———exchange-api order API
└─———exchange-core order core
└─———jar Other lib
└─———market market API、K-line service
└─———otc-api OTC trade API
└─———otc-core OTC core
└─———sql SQL script
└─———ucenter-api user API
└─———wallet wallet
01_wallet_rpc
└─———bitcoin
└─———bsv
└─———btm
└─———eos
└─———erc-eusdt
└─———erc-token(可对接各种ERC20币种)
└─———eth
└─———ltc
└─———usdt
02_App_Android
03_App_IOS
04_Web_Admin
05_Web_Front
- Prepare the mysql database and create a database named "xxxx"
- Prepare redis cache database
- Prepare kafka streaming environment (first configure to run zookper, then configure to run kafka)
- Prepare mongodb database environment, create users admin, xxxx, create bitrade database
- Prepare Alibaba Cloud OSS (modify the place to be configured in the project)
- Prepare nginx and modify the configuration file (optional, need to be configured for official launch)
- Modify the configuration file in the framework code to prepare the environment configuration parameters
- Compile to generate jar executable file
- Run cloud.jar (microservices registration center)
- Run exchange.jar (match trading engine)
- Run market.jar (Quote Center, need to wait for Exchange.jar to fully start)
- Run ucenter.jar (User Center)
- Run other modules (wallet.jar, chat.jar, otc-api.jar, etc.)
- Open mysql and import the xxxxxxx.sql file in the sql folder in the framework code. Note that if the trigger sql reports an error, you need to add a trigger for the wallet table
- Run the front-end vue project
- Run the back-end vue project
- Run wallet RPC
- Run the automated trading robot program (the code in this part is not uploaded, but it does not affect)
- Run the Admin project (the service does not depend on other services, so you can just run this project and directly view the background)
This digital currency trading system is a project developed by my company for an exchange. The exchange has ceased operations due to team reasons, and our company was disbanded in February. Since I participated in the project, I was responsible for overall R&D management, architecture design and customer docking, so I mastered all the codes.
There are some places that need special attention in the use of the function of this system, such as other operations after the new transaction pair, improper operation will cause data disorder errors.
I can provide paid technical assistance and use training guidance!
Email:877070886@qq.com
When the memory is insufficient, enter top in the Linux console to view the java process occupies a lot of memory (a java process occupies more than 1G), because there are many jar packages to run, so you need to control the memory used by certain jar packages, you can choose A few less resource intensive projects are as follows:
java -jar -Xms128m -Xmx128m -Xmn200m -Xss256k admin-api.jar
java -jar -Xms512m -Xmx512m -Xmn200m -Xss256k cloud.jar
java -jar -Xms512m -Xmx512m -Xmn200m -Xss256k wallet.jar
- This system supports the operation status of the system for sending emails and short messages
- System notification/alarm support: user registration, user authentication, user recharge/withdrawal, currency RPC operation status, system resource usage monitoring, etc. 24 kinds of monitoring
Some reported that there is no complete SQL file. This is because the successfully compiled Jar will automatically map the Entity to a database structure after the first run. The SQL in the project only completes some database structures that Springcloud cannot complete. The automatic database configuration is located in the application.properties configuration file:
#jpa
spring.jpa.show-sql=true
spring.data.jpa.repositories.enabled=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=update This configuration will automatically update the database structure.
- 1. Registration/login/real-name authentication/audit (currently only supports mobile phones, secondary development can be added to the mail, very simple)
- 2. Banner/Announcement/Help/Customized page (Banner supports separate settings for PC and APP, helps support various classification modes)
- 3. Fiat currency C2C transaction/fiat currency OTC transaction (supports two fiat currency models, the platform can undertake C2C fiat currency exchange in the early stage of the project, and OTC transactions can be opened later)
- 4. Coin trading (support for limit order, market order, and other commission modes can be added for secondary development)
- 5. Invite registered/promotion partners (support for ranking statistics on the number of invited promoters and commissions by day, week and month)
- 6. Innovation Lab (there are many supported functions in this part, and itemized explanations. In addition, the APP does not support this function for the time being)
- 6-1. First launch panic buying activity mode (for example, when issuing a new trading pair, a certain number of currencies can be set on the trading pair for panic buying)
- 6-2. The first distribution mode of activity (for example, before issuing the BTC/USDT trading pair, the official took out 5BTC for the activity, and divided the BTC equally according to how much USDT the user recharged mortgaged)
- 6-3. Panic buying mode (for example, before the ZZZ/USDT trading pair is issued, the ZZZ currency price is 5USDT, and the official issuance activity price is 0.5USDT, you can use this mode)
- 6-4. Control panel sharing mode (such as 6-3, only average distribution)
- 6-5. Mining machine activity mode (support users to mortgage a certain amount of currency, and the official promise to return a certain amount of currency every month)
- 7. Red envelope function (support platform and official to issue a certain amount of currency red envelope, this function is suitable for user fission)
- 8. Various basic management such as user asset management, flow management, commission management, real name management
- 1. Summary (view platform operating data, including transaction amount, registered number, recharge, etc.)
- 2. Member management (member information management, member real name verification, member real name management, member balance management, member recharge/freeze balance, etc.)
- 3. Invitation management (member invitation information, member invitation ranking management)
- 4. CTC management (CTC order management, flow management, acceptor management)
- 5. Content management (PC advertising management, APP advertising management, announcement management, help management)
- 6. Financial management (charge and withdrawal management, financial flow management, reconciliation management, currency wallet balance management)
- 7. Currency management (new trading pair, management trading pair, new trading robot, setting trading robot parameters, setting market engine/trading engine, revoking all orders)
- 8. Event management (new activity, mining machine subscription, panic buying/division management)
- 9. Red envelope management (platform red envelope management, user red envelope management)
- 10. System management (role management, department management, user management, authority management, currency management, RPC management, version management)
- 11. Margin management (this function is considered in design, but not used during actual operation)
- 12. OTC management (advertising management, order management, OTC currency management, surrender management, etc., this function has not been verified by actual operation)
This project provides two wallet docking methods, one is self-built node + blockchain browser, and the other is third-party wallet docking. If you want to use a self-built node or blockchain browser, you can directly compile the code in 00_framework. If you want to use a third-party wallet for docking, you can download the project files of the YouDun wallet in the 07_Uduncloud folder and copy them to 00_framework.
After you get the code, you can not connect the blockchain nodes during the debugging and running of this project, which will not have much impact; even if you do not connect the blockchain nodes, you can deploy one of them with matching transaction function Trading platform (just that users cannot recharge their wallet addresses).
When you are gradually familiar with the entire system, and have a certain basic reserve of blockchain operation principles, node construction, and blockchain browser, you can start to study the projects under the 01_wallet_rpc folder. Each currency corresponds to different data access methods. Most blockchain projects have the same or very similar wallet operation methods. For example, Bitcoin derivatives such as BTC, LTC, BCH, BSV, BCD, etc., have almost the same API operations. The same; another example is ETH, when you master the operation of a contract currency, the operation of other digital currencies based on ETH is almost the same. So, basically when you spend time understanding one, you understand a bunch of currencies.
The wallet operation scheme used in this project is also different, and as far as possible to show you different usages:
- Self-built full nodes such as BTC and USDT now require almost 300G of hard disk space;
- Like ETH, self-built light nodes are used (Reference Article), because the full node requires too much hard disk space;
- Such as BCH, BSV, etc., use a third-party blockchain browser to obtain data;
- Like XRP, the official has provided an interface to access block data ([Ripple API GitHub address] (https://github.com/ripple/ripple-lib/))
Generally speaking, when the amount of funds exchanged by the exchange is not large, you can explore it yourself, but when the amount of funds exchanged is large, if you are not confident about operating your wallet, you can also use a third-party wallet service Of course, this requires you to negotiate with the wallet service provider to pay an annual fee or something.
The following figure is a brief explanatory diagram of the user recharge monitoring logic, just take a look at it:
Anyone who uses this source code to engage in commercial activities and causes losses to others and himself is not responsible for me!