Skip to content

[Educational] Implementation of Stock Exchange Order Book. Attempt to code a real world both limit and market order book using java

Notifications You must be signed in to change notification settings

monicbhanushali/orderbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Exchange Order Book Implemention

Implementation of Stock Exchange Order Book in Java For Educational Purposes

The core data structure used here is a binary search tree (red black tree to be specific) were each node itself is a linked list.

TreeMap would allow to get

Red Black Tree = Java's TreeMap implementation

Why TreeMap/Red Black Tree ?

  • Another option was PriorityQueue (Min & Max Heap) but contains operation take O(n). For TreeMap - contains operation takes O(logN)
  • Min/Max Heap find smallest & largest element take O(1) for treeMap it is O(logN)
  • PriorityQueue allows duplicate elements while tree map doesn't

Why LinkedList ?

  • Natural time based ordering for elements
  • Appending to linked list (adding an order) would take O(1)
  • deleting an order would take O(N)
    • Can we do it in O(1) ? store reference/index somewhere ?

For each symbol - there would be one orderbook with two sides (buy & sell )

About

[Educational] Implementation of Stock Exchange Order Book. Attempt to code a real world both limit and market order book using java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages