Git Product home page Git Product logo

orderbook's Introduction

Project Overview

This document outlines the approach I've taken in implementing this solution, the challenges I encountered, and potential improvements that could be made to enhance efficiency and robustness.

Live Demo

The live version of this solution is hosted on Vercel and can be accessed at https://orderbook-beige.vercel.app/.

Approach

The solution was developed using React.js, acting as the backbone of the user interface, while Redux was chosen for state management.

  1. The initial step was to set up the required state to hold bid and ask orders. I represented the state in Redux as an initially empty object. Each order is an object comprised of properties such as price, size, total, and depth.
    interface Order {
      price: number;
      size: number;
      total: number;
      depth: number;
    }

    type OrderState = {
      bids: Order[];
      asks: Order[];
    }
  1. I then implemented a function to calculate a running total and depth for each order. Here, Running total is essentially the sum of the size of the current order and all preceding orders. Depth is a visual representation of the size of an order as a proportion of the maximum size amongst all bids and ask orders.
  2. To keep the state updated based on multiple, incoming orders, I built a function named updateOrders(). This function works by merging new, incoming orders with the existing Redux state.

Challenges

Managing the constant stream of data and synchronously updating the UI were the primary challenges I encountered. To address this, I leveraged the updateOrders() function to keep the state updated efficiently.

Another challenge was to ensure the total sizes of the orders were calculated before the slicing of data for display in the order book. It's a common mistake many developers overlook, but I've managed to correctly implement this in the given solution.

Possible Improvements

While the current solution is functional and reliable, there is always room for improvement. Here are a few areas that could be addressed to further enhance the solution's robustness and efficiency:

  • Data Error Handling: Edge cases involving errors or inconsistencies in incoming data can be better handled. It ensures that the order book doesn't get into an invalid state.
  • Testing Suite: A robust testing suite would greatly enhance the reliability of the solution since it would allow verification and validation of more varied cases.
  • Performance and UI Improvements: Both the user interface and performance can be improved to handle larger volumes of data more smoothly, thereby enhancing the user experience.

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

orderbook's People

Contributors

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