Coder Social home page Coder Social logo

arbitrage-system's Introduction

Arbitrage System

A Javascript library for for arbitrage of cryptocurrency sales.

This API is meant to be consumed by private networking since no security features are implemented.

Current feature list

  • Support for producing quotes that expire in 30 seconds
  • Arbitrage for a list of exchanges provided by the ccxt library.
  • Filters for balances and chooses the best price within the available exchanges
  • Proxy requests to exchange APIs to avoid rate limiting
  • Works with Nodejs version 8+

This API does not currently:

  • Check minimums and maximums amounts for orders on exchanges
  • Lock balances for the duration of the quote
  • Encrypt or cipher any of the exchange credentials

Install

Clone it locally first:

git clone https://github.com/Burtonium/arbitrage-system.git

Install required dependencies

cd arbitrage-system && npm install

Copy the .example.env file. Remember to fill in your environment variables for your setup. Leaving proxies variable empty just means your app will not be using any proxies.

cd new-alts && cp .example.env ./.env

Make a .env.test file and enter in the name of a test database. This will ensure none of the development data is lost when testing. You may also override any other environment variables here.

echo 'DB_NAME=test' > .env.test 

Migrate the database to the latest version

knex migrate:latest

Seed the database with all the supported currencies

knex seed:run

Fetch all markets supported by the ccxt library. This should be done periodically if the any of the markets your app depends on become unsupported.

npm run update-markets

Run your app

npm start

Routes

Create quote

Creates a quote according to the criterion provided.

  • URL

    /:baseCurrency/:quoteCurrency/quote

  • Method:

    POST

  • Data Params

    Required:

    amount:[float] > 0, side:[string:'buy' || 'sell']

  • Success Response:

    • Code: 201
      Content:
      {"quoted":{"price":0.18225843300000003,"side":"buy","amount":0.1,"marketId":"4","created_at":"2018-05-10T20:45:41.385Z","id":"dc075490-b660-4a12-adec-673bc9fe96f4"}}
  • Error Responses:

    • HTTP Status Code: 400 Bad Request
      Code 4 Invalid Parameters

    • HTTP Status Code: 404 Not Found
      Message Pair not found

    • HTTP Status Code: 500 Error
      Message Something went wrong

    • HTTP Status Code: 503 Service Unavailable
      Code 5 OrderbookOverflow
      Code 6 InsufficientFunds
      Code 8 IncorrectCredentials
      Code 9 NoExchangesAvailable

Place order

Creates an order on the exchange quoted exchange

  • URL

    /order

  • Method:

    POST

  • Data Params

    Required:

    quoteId: [uuid]

  • Success Response:

    • Code: 201
      Content:
      {"order":{"orderId":"5919788691279685","side":"buy","status":"closed","createdAt":"2018-05-10T21:25:48.659Z","filled":0.1,"price":0.2}}
  • Error Responses:

    • HTTP Status Code: 400 Bad Request
      Code 3 InvalidParameters
      Code 10 OrderDuplicate
      Code 11 QuoteExpired

    • HTTP Status Code: 404 Not Found
      Message Quote not found

    • HTTP Status Code: 500 Error
      Message Something Went Wrong

    • HTTP Status Code: 503 Service Unavailable
      Code 7 OrderNotFilled

Get exchanges

Returns all available exchanges, their required credentials, settings and available markets

  • URL

    /exchanges

  • Method:

    GET

  • Success Response:

    • Code: 200
      Content:
    {"exchanges":[{"id":"binance","name":"Binance","settings":{"sellMarginPercent":5,"buyMarginPercent":5,"apiKey":"testkey","uid":null,"login":null},"markets":[{"symbol":"ETH/BTC"},{"symbol":"BCH/BTC"},{"symbol":"LTC/BTC"}],"requires":{"apiKey":true,"secret":true,"uid":false,"login":false,"password":false,"twofa":false}},{"id":"bitstamp","name":"Bitstamp","settings":{"sellMarginPercent":5,"buyMarginPercent":5,"apiKey":"testkey","uid":null,"login":null},"markets":[{"symbol":"ETH/BTC"},{"symbol":"BCH/BTC"},{"symbol":"LTC/BTC"}],"requires":{"apiKey":true,"secret":true,"uid":false,"login":false,"password":false,"twofa":false}},{"id":"poloniex","name":"Poloniex","settings":{"sellMarginPercent":5,"buyMarginPercent":5,"apiKey":"testkey","uid":null,"login":null},"markets":[{"symbol":"ETH/BTC"},{"symbol":"BCH/BTC"},{"symbol":"LTC/BTC"}],"requires":{"apiKey":true,"secret":true,"uid":false,"login":false,"password":false,"twofa":false}}]}

Create exchange settings

Creates an exchange setting required for arbitrage

  • URL

    /:id/settings

  • Method:

    PUT

  • Params

    Required:

    id: [string]

  • Success Response:

    • Code: 201
      Content: 'Success'
  • Error Responses:

    • HTTP Status Code: 404 Not Found
      Message Exchange not found

    • HTTP Status Code: 500 Error
      Message Something Went Wrong

Contributors

Matt Burton

License

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

arbitrage-system's People

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.