Coder Social home page Coder Social logo

damiancipolat / ratherlabschallege Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 0.0 15.13 MB

This is my solution to the challenge of Rather labs for SR backend develepor. The focus is to create a Market status api.

License: MIT License

JavaScript 13.28% TypeScript 58.88% Shell 0.75% CSS 7.99% HTML 18.83% Dockerfile 0.28%
nodejs trading api typesctipt bitfinex

ratherlabschallege's Introduction

RatherLabs challenge - Membrane

In this challenge I solve the statement proposed in the following pdf, which consists of creating a market status api. https://github.com/damiancipolat/RatherLabsChallege/blob/main/doc/challenge.pdf

Readme sections

Exchange provider:

For this challenge, I decided to use the bitfinex api through communication via websocket after analyzing both providers, bitfinex presents a better developer experience and better documentation.

Stack:

  • Node.js v16
  • Docker
  • Test: jest
  • config: dotenv
  • express.js
  • pino: For logging.

Configuration:

The project uses .env files to handle the configuration, the format is as follows.

#Provider websocker url.
BITFINEX_HOST="wss://api-pub.bitfinex.com/ws/2"

#Limit of pair name point length on memory.
TIPS_LIMIT=50

#Server port
SERVER_PORT=8000

Money pair-names: You can configure the pair names in the file: '/src/config/index.ts'.

  moneys: [
    'tBTCUSD',
    'tETHUSD',
  ],

Note: Trading pairs are prepended by a โ€œtโ€ before the pair (e.g. tBTCUSD, tETHUSD, ...), the project only works with bitfinex supported trading pairs. https://docs.bitfinex.com/docs/ws-general

Commands:

These are several useful commands to run the project.

  • Run unit test:
damian@challenge:~$ npm test
  • Run coverage report.
damian@challenge:~$ npm run coverage
  • Run app in development mode:
damian@challenge:~$ npm run dev
  • Run app:
damian@challenge:~$ npm start
  • Create and run docker container:
damian@challenge:~$ npm run build

Architecture:

The project is divided into several layers, each with different responsibilities. Three stand out consumer / memory / api server.

  • Comsumer: Get data from the socket and keep the book updated in memory, separated by buy and sell.
  • Api: HTTP interface to obtain the different features proposed.
  • Memory (Store): In this layer we store the data obtained from the bitfinex provider through the websocket.
  • Configuration: Here I centralize the configuration from which the api or the consumer obtained information
  • Utilis: Cross functionality, only the logger is found.

Layer diagrams:

Here we see the main layers of the project.

Component diagrams:

Here we see the component of every layers of the project.

Endpoints:

Here are examples of how to use the requested endpoints.

  • 1) BID ASK:

Receive a parir name and retrieve bid-ask prices, format: 'http://127.0.0.1:8000/orders/:pair-name/prices'

curl 'http://127.0.0.1:8000/orders/tBTCUSD/prices'
  • 2) Simulate order execution:

Receive a pair name a operation and ammount and return the price if the order is executed, format: 'http://127.0.0.1:8000/market/execute/:pair-name/[BUY/SELL]/:ammount'

curl 'http://127.0.0.1:8000/market/execute/tBTCUSD/BUY/0.5'
curl 'http://127.0.0.1:8000/market/execute/tBTCUSD/SELL/0.5'
  • 3) Simulate order execution with limit BONUS:

Receive a pair name a operation, ammount, limit and return the price if the order is executed, format: 'http://127.0.0.1:8000/market/execute/:pair-name/[BUY/SELL]/:ammount/limit/:limit-ammount'

curl 'http://127.0.0.1:8000/market/execute/tBTCUSD/BUY/0.5/limit/100'
curl 'http://127.0.0.1:8000/market/execute/tBTCUSD/SELL/0.5/limit/100'

ratherlabschallege's People

Stargazers

 avatar  avatar

Watchers

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