Git Product home page Git Product logo

coinfalcon-demo's Introduction

Coinfalcon Limit Bot

This project allows a user to create "batches" of limit orders that are a specific percentage above/below the current price for a specific market. A background job retrieves new prices from trades on Coinfalcon and then updates and batches where the price has gotten closer to the limit.

It will then delete the orders in a batch and create new ones using the percentage specified at by the batch.

It will also push any updates to batch prices / order_ids to the client browser using actioncable and websockets.

Dependencies

  • Ruby >= 2.3
  • Rails 5
  • Redis (locally)
  • ActiveJob
  • ActionCable

Architecture

Batches have many orders which use the batch percent and type to create the orders on coinfalcon. In the database an order is just a reference to a batch and a coinfalcon_id.

DelayedJobs

On the delayed jobs side of things, there is a background job called PriceUpdateJob that will:

  1. get latest prices
  2. enqueue a job for batches if there is a new price for their market using BatchUpdateJob
  3. Enqueue a new PriceUpdateJob for 15 seconds from now (this means the prices and batches will stay up to date) with the old prices so that the job can determine which markets have changed price.

Locally it is using Redis for the ActionCable pub/sub in order to allow testing updates with new prices from a seperate rails console instance.

ActionCable

When a batch is updated for a new market price (which I've called "balancing orders") it will broadcast the new order_ids and new batch price to an ActionCable stream called "batches" on the frontend there is some plain js to update the view when a batch is "balanced".

Notes

Rate Limits
  • Any Coinfalcon requests are limited to 3 requests per 2 seconds (the Coinfalcon API limits requets to 3 / 1 second).
Price formatting
  • Due to the api requiring prices for limit orders to be no more than 5 units after the decimal (precision '%.5f') all orders are priced using this convention.

install

  1. git clone https://github.com/NickPapacostas/coinfalcon-demo
  2. cd coinfalcon-demo
  3. bundle install
  4. rake db:create
  5. rake db:migrate
  6. redis-server &
  7. set coinfalcon api key and secret as CF_KEY and CF_SECRET
  8. rails s

Testing

rspec

coinfalcon-demo's People

Contributors

nickpapacostas 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.