Git Product home page Git Product logo

futures-exchange's Introduction

Exchange

This is the backend for a prototype bitcoin futures exchange I made. The exchange and backend were never completed, but the sample front-end can be found at: http://exchange.ronen.io/trade

The exchange was intended to be a bitcoin futures exchange, which simply put, allows bitcoin holders to place speculative bets on the price of bitcoin by trading what's known as a swap contract.

Features

The backend features an order matching engine, located in the

place.php

file located in the order folder. The matching engine enables customer orders (limit and market) to execute against eachother (as if this were a stock exchange), in a strict price-time priority.

It features an innovative maker-taker fee model, so those who provide liquidity through limit orders, makers, are actually paid a rebate, rather than a fee.

It also features a fully operational API for users to place and cancel orders, liquidate positions, recieve market prices and trade data, as well tools for administrators to credit or even lock accounts.

There is also a sample server side websocket client to broadcast live trades. I never learned how to actual create an API nor a websocket system, so the sample is msot likely incredibly inefficient.

Lastly, passwords are hashed using sha256, to improve security, even though I'm sure a vulnerability exists somewhere.

Getting Started

  1. Create a MYSQL database
  2. Run the (massive)
main.sql

file located in the sql folder to generated tables to control administrative settings and user balances/trades/orders.

If you're interested in using the matching engine for yourself, just edit the configuration.php file in each folder and change

$servername = "Put your own host here";
$username = "Put your own user here";
$password = "Put your own database here";
$database = "Put your own password here";

to whatever your MYSQL password, username, database, and host are. 3. Have fun trading (most likely with yourself)!

While I wish I finished this project, I realized I wouldn't've been able to write all the code myself. Apparatus' to control actual deposits and withdrawals of funds still haven't been written, and the matching engine is incredibly slow (since it's written in PHP) and can process a maximum of 1000 trades/cancellations a second, which would be insufficient for an actual exchange.

Written from scratch by Ronen Singer.

futures-exchange's People

Contributors

ronensingerr avatar

Stargazers

 avatar

Watchers

 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.