IMPORTANT
This is an old project and isn't being actively maintained. Some of the libraries have since been deprecated and this may cause some of the dependencies to fail. We're not providing any support for this project anymore.
Coin Exchange Backend
Introduction
The platform acts as cryptocurrency exchange server to be used for retail and institutional trading. It can be accessed by any front end or mobile service comsuming the provided REST API.
Context
The product serves as platform for trading different digital currencies. Currently following trading currencies are supported out of the box.
- Bitcoin
- Litecoin
The platform will mostly be a self contained product with not much integration required with external system(s). However, the billing module will have to support some different mechanisms for depositing and withdrawing money into user accounts that may include:
- Bitcoin deposit / withdrawal
- Litecon deposit / withdrawal
Problem Statement
Cryptocurrency market has been on rise in the recent years and has become a popular financial entity. The crypto market is decentralized it's not being controlled by any single authority offering more control to the users. Some of the cryptocurrencies can also be used by setting a fixed supply cap making them more imune to inflation. This makes the cryptocurrency market highly profitable.
Solution
To gain profit from cryptocurrency market apart from investing in trading cryptocurrencies itself one can take advantage from market liquidity by creating their own cryptocurrency exchange. Creating a cryptocurrency exchange offers the advantage of being a part of the cyrpto market itself and one can take advantage of the transaction fees to generate revenue.
Use Cases
Market Data
- Limit Order Book management.
- Currency Depth details.
- Currency Spread details.
Orders
- Place Limit Orders.
- Place Market Orders.
- Manage existing Open Orders.
- View Closed Orders.
- View Individual Order Details.
Trades
- Overview of users all executed trades.
- User Ledger details.
- Individual Trade details.
Deposit & Withdraw
- Deposit crypto currency funds into user account.
- Withdraw funds from user account into cyrpto currency wallet.
Screenshots are available in the frontend repository.
Technology Stack
- Visual Studio 2012
- .NET Framework 4.5
- Databases:
- MySql (preferably the latest version)
- RavenDB
- IIS
Frontend
A web based frontend is already available to be used: Web-UI
Infrastructure
The project runs as an IIS service.
Usage
Running
Project Structure
- Working code directory is coin-exchange-backend\src.
- Startup project is CoinExchange.Rest.Webhost.
Install IIS
- Follow this guide to setup IIS on windows machine: https://msdn.microsoft.com/en-us/Library/ms181052(v=vs.80).aspx
Setting up RavenDB
- Download the RavenDB from their website: https://ravendb.net/download
- Run the Setup installation using the provided instructions: https://ravendb.net/docs/article-page/4.0/csharp/start/installation/manual
- While installing the RavenDB, please select "Development" in Tragetting environment.
- Install the RavenDB as a service and chose enter port 8081.
- After the installtion completes, open "http://localhost:8081/studio/index.html" link in the browser.
- In the main screen,click on "New Database", type "InputEventStoreDev" in Name Field and click next.
- In the main screen,click on "New Database", type "OutputEventStoreDev" in Name Field and click next.
If the link "http://localhost:8081/studio/index.html" is inaccessible make sure that RavenDB service is running. The following link can be used to start or stop RavenDB service: https://ravendb.net/docs/article-page/4.0/csharp/start/installation/running-as-service
NOTE: RavenDB and Event Sourcing has been disabled for now as the library is no longer functional.
MySql
- Download latest version of MySql community server.
- Run .exe or .msi file and follow the instructions.
- Select Developer default.
- There should be no password for root user.
- Execute the "create" and "populate" scripts in the src\data\MySql folder.
Database Setup
- Create a new database named coinexchangedev.
- MySql Settings:
- username = root,
- host = localhost,
- port = 3306.
MySQL Connector for .NET:
Download and install the MySQL connector for .NET from here: http://dev.mysql.com/downloads/connector/net/
Bitcoin:
Download and install bitcoin core from bitcoin website.
If you want to run bitcoin in testnet, edit the configuration file named bitcoin.conf located in %appdata% under bitcoin directory and add the following propteris:
- testnet=1
- server=1
- rpcport=[Same as the value provided in Web.config file]
- rpcuser=[Same as the value provided in Web.config file]
- rpcpassword=[Same as the value provided in Web.config file]
Litecoin:
Similar to Bitcoin download and install litecoin core from litecoin website.
If you want to run bitcoin in testnet, edit the configuration file named litecoin.conf located in %appdata% under litecoin directory and add the following propteris:
- testnet=1
- server=1
- rpcport=[Same as the value provided in Web.config file]
- rpcuser=[Same as the value provided in Web.config file]
- rpcpassword=[Same as the value provided in Web.config file]
Once done, go to the litecoin installaion directory and perform the following tasks:
- Copy the executable file and make a shortcut on the desktop.
- Right click the shortcut and go to properties and in the shortcut tab edit the target location by adding -testnet at the of the existing value after which your target location will look something like this: "C:\Program Files\Litecoin\litecoin-qt.exe" -testnet
Dogecoin:
Download and install dogecoin core from dogecoin website.
Setting up the testnet for dogecoin is similar to the tasks performed for the litecoin setup.
Building
- Clone the repo: git clone https://github.com/coin-worx/coin-exchange-backend.git
- open command line and go to location where MySQL is installed e.g. C:\Program Files\MySQL\MySQL Server 5.7\bin
- Execute command: mysql -u root -h localhost -p and provide password when prompted.
- Then execute command to create the database (plz change path): SOURCE ..\coin-exchange-backend\src\Data\MySql\create.sql
- After that populate the database: SOURCE ..\coin-exchange-backend\src\Data\MySql\populate.sql
- NAnt and ccnet build scripts are available in ..\coin-exchange-backend\src\Build
Logs
Log files are created under the directory: C:\Logs
Performance Tests:
There are two performance test cases available in Project CoinExchange.Trades.Domain.Model.Tests under the class Performance.cs. With current configuration the application manages 5K order with simultaneous order matching in ~1.3 Seconds on machine with the following specs:
- CPU : Intel Core i7 7500U @ 2.70GHz
- RAM : 8.00GB @ 1063MHz
- Storage: SSD
Help
Got a question? File a GitHub issue, send us an email at [email protected] or reach out to us on social media Twitter, Facebook
Contributing
Bug Reports & Feature Requests
Please use the issue tracker to report any bugs or file feature requests.
Developing
PRs are welcome. In general, we follow the "fork-and-pull" Git workflow.
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes
NOTE: Be sure to merge the latest from "upstream" before making a pull request!
About
The project is created and maintained by Aurora Solutions. Like it? Please let us know at [email protected]
See our other projects