Giter Club home page Giter Club logo

silverbars-demand's Introduction

Silver Bars Demand

Imagine you're working as a programmer for a company called Silver Bars Marketplace and you have just received a new requirement. In it we would like to display to our users how much demand for silver bars there is on the market.

To do this we would like to have a 'Live Order Board' that can provide us with the following functionality:

  1. Register an order. Order must contain these fields: user id order quantity (e.g.: 3.5 kg) price per kg (e.g.: £303) order type: BUY or SELL

  2. Cancel a registered order - this will remove the order from 'Live Order Board'

  3. Get summary information of live orders (see explanation below) Imagine we have received the following orders: a) SELL: 3.5 kg for £306 [user1] b) SELL: 1.2 kg for £310 [user2] c) SELL: 1.5 kg for £307 [user3] d) SELL: 2.0 kg for £306 [user4]

Our ‘Live Order Board’ should provide us the following summary information: 5.5 kg for £306 // order a + order d 1.5 kg for £307 // order c 1.2 kg for £310 // order b

The first thing to note here is that orders for the same price should be merged together (even when they are from different users). In this case it can be seen that order a) and d) were for the same amount (£306) and this is why only their sum (5.5 kg) is displayed (for £306) and not the individual orders (3.5 kg and 2.0 kg).The last thing to note is that for SELL orders the orders with lowest prices are displayed first. Opposite is true for the BUY orders.

Please provide the implementation of the live order board which will be packaged and shipped as a library to be used by the UI team. No database or UI/WEB is needed for this assignment (we're absolutely fine with in memory solution). The only important thing is that you just write it according to your normal standards.

NOTE: if during your implementation you'll find that something could be designed in multiple different ways, just implement the one which seems most reasonable to you and if you could provide a short (once sentence) reasoning why you choose this way and not another one, it would be great.

Assumptions

  • getOrderSummary() returns a Map of order summaries in which the key is the order type so that the orders are two separate sorted lists categorised based on whether they are BUY or SELL. The assumption is that it makes more sense for the orders data to be presented in two separate categories to the end users as it is easier to read rather than having them all together, since the order summary shown on the live board shows just the aggregate amount in kg and the price. Also the assumption is that only orders of the same type can be aggregated together.
  • The live order board will be used concurrently by multiple users

silverbars-demand's People

Contributors

ggavriilidis avatar

Watchers

 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.