Skip to content

Henrye28/crypto_assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real Time Portfolio Market Value Console

Gradle Version Gradle 4.8

Extra libs

  • commons-math3-3.6.1.jar : Apache commons maths for calculating the cumulative probability

  • awaitility-3.0.0.jar : Awaitility jar for testing message publish to queue with random interval

Design with message channel: BlockingQueue

Project can be divided into three components:

MarketDataProvider --queue--> PortfolioService --queue--> PortfolioConsole

With features as below:

  • All numbers are calculated based on BigDecimal for better precision
  • Multi-threading on price calculation to reduce market value publishing delay
  • Message queue to separate dependencies on each services
    • BlockingQueue as message queue for the sake of:
    • Limit queue size in case of OOM
    • Remove concurrency complexity
  • Components are connected by message queue
    • MarketDataProvider publishes real-time prices for tickers with random intervals using thread pool
    • PortfolioService consumes pricing message from MarketDataProvider, distributes calculation&publish tasks to a thread pool
    • PortfolioConsole consumes market value message from PortfolioService and print

Further enhancement:

  • Message queue should be non-blocking and asynchronous, for the case of large data volume. Can be improved with below options:
    • Using external messaging system
    • Creating a datastructure with multiple number of queues inside, message will be assigned to particular queue by header hash, concurrency number can be increased with this solution.
    • For this particular case, queue should be conflated
  • For saving time, stocks and options are stored in same security static data table
  • For saving time, only integration test is added

User guide

  • First gradle build the project under the root folder
  • cd to build/libs
  • Start service by:

java -jar portfolio-CRYPTO-SNAPSHOT.jar

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages