All Projects → Crypto-toolbox → Hft Orderbook

Crypto-toolbox / Hft Orderbook

Licence: mit
Limit Order Book for high-frequency trading (HFT), as described by WK Selph, implemented in Python3 and C

Programming Languages

c
50402 projects - #5 most used programming language
python3
1442 projects

Labels

Projects that are alternatives of or similar to Hft Orderbook

Imtools
Fast and memory-efficient immutable collections and helper data structures
Stars: ✭ 85 (-79.27%)
Mutual labels:  avl-tree
AVL-Tree
Implementation of an AVL tree in Java
Stars: ✭ 20 (-95.12%)
Mutual labels:  avl-tree
DSA
Data Structures and Algorithms
Stars: ✭ 13 (-96.83%)
Mutual labels:  avl-tree
Gods
GoDS (Go Data Structures). Containers (Sets, Lists, Stacks, Maps, Trees), Sets (HashSet, TreeSet, LinkedHashSet), Lists (ArrayList, SinglyLinkedList, DoublyLinkedList), Stacks (LinkedListStack, ArrayStack), Maps (HashMap, TreeMap, HashBidiMap, TreeBidiMap, LinkedHashMap), Trees (RedBlackTree, AVLTree, BTree, BinaryHeap), Comparators, Iterators, …
Stars: ✭ 10,883 (+2554.39%)
Mutual labels:  avl-tree
avl array
High performance templated AVL tree using a fixed size array. Extensive test suite passing.
Stars: ✭ 33 (-91.95%)
Mutual labels:  avl-tree
avl tree set rs
Rust repository for the my article: Understanding Rust Through AVL Trees
Stars: ✭ 31 (-92.44%)
Mutual labels:  avl-tree
Treeplayground
Tree Visualization Tool for Learning Data Structure and Algorithm.
Stars: ✭ 17 (-95.85%)
Mutual labels:  avl-tree
Klib
A standalone and lightweight C library
Stars: ✭ 3,442 (+739.51%)
Mutual labels:  avl-tree
go-avltree
AVL tree with some useful extensions written in Go
Stars: ✭ 29 (-92.93%)
Mutual labels:  avl-tree
bbst-showdown
Fast AVL Trees & WAVL Trees in Java
Stars: ✭ 24 (-94.15%)
Mutual labels:  avl-tree
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (-69.51%)
Mutual labels:  avl-tree
Libdict
C library of key-value data structures.
Stars: ✭ 234 (-42.93%)
Mutual labels:  avl-tree
TUMGAD
Exercise generator and helpful materials for the Introduction to Algorithms and Data Structures 📚
Stars: ✭ 27 (-93.41%)
Mutual labels:  avl-tree
Python3 data structures
Code from Youtube Tutorial Series
Stars: ✭ 90 (-78.05%)
Mutual labels:  avl-tree
Data-Structures-and-Algorithms
Implementation of various Data Structures and algorithms - Linked List, Stacks, Queues, Binary Search Tree, AVL tree,Red Black Trees, Trie, Graph Algorithms, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Segment Trees etc.
Stars: ✭ 144 (-64.88%)
Mutual labels:  avl-tree
Cdcontainers
Library of data containers and data structures for C programming language.
Stars: ✭ 57 (-86.1%)
Mutual labels:  avl-tree
data-structures-algorithms
Self-practice in Data Structures & Algorithms
Stars: ✭ 29 (-92.93%)
Mutual labels:  avl-tree
Data Structures
Go datastructures.
Stars: ✭ 336 (-18.05%)
Mutual labels:  avl-tree
Javascript Datastructures Algorithms
📚 collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book
Stars: ✭ 3,221 (+685.61%)
Mutual labels:  avl-tree
consistent-hashing
an implementation of Consistent Hashing in pure Ruby using an AVL tree
Stars: ✭ 40 (-90.24%)
Mutual labels:  avl-tree

HFT-Orderbook

Limit Order Book for high-frequency trading (HFT), as described by WK Selph, implemented in Python3 (C implementation on the way)

Based on WK Selph's Blogpost:

http://howtohft.wordpress.com/2011/02/15/how-to-build-a-fast-limit-order-book/

Available at Archive.org's WayBackMachine:

https://goo.gl/KF1SRm

"There are three main operations that a limit order book (LOB) has to
implement: add, cancel, and execute.  The goal is to implement these
operations in O(1) time while making it possible for the trading model to
efficiently ask questions like “what are the best bid and offer?”, “how much
volume is there between prices A and B?” or “what is order X’s current
position in the book?”.

The vast majority of the activity in a book is usually made up of add and
cancel operations as market makers jockey for position, with executions a
distant third (in fact I would argue that the bulk of the useful information
on many stocks, particularly in the morning, is in the pattern of adds and
cancels, not executions, but that is a topic for another post).  An add
operation places an order at the end of a list of orders to be executed at
a particular limit price, a cancel operation removes an order from anywhere
in the book, and an execution removes an order from the inside of the book
(the inside of the book is defined as the oldest buy order at the highest
buying price and the oldest sell order at the lowest selling price).  Each
of these operations is keyed off an id number (Order.idNumber in the
pseudo-code below), making a hash table a natural structure for tracking
them.

Depending on the expected sparsity of the book (sparsity being the
average distance in cents between limits that have volume, which is
generally positively correlated with the instrument price), there are a
number of slightly different implementations I’ve used.  First it will help
to define a few objects:

    Order
      int idNumber;
      bool buyOrSell;
      int shares; // order size
      int limit;
      int entryTime;
      int eventTime;
      Order *nextOrder;
      Order *prevOrder;
      Limit *parentLimit;

    Limit  // representing a single limit price
      int limitPrice;
      int size;
      int totalVolume;
      Limit *parent;
      Limit *leftChild;
      Limit *rightChild;
      Order *headOrder;
      Order *tailOrder;

    Book
      Limit *buyTree;
      Limit *sellTree;
      Limit *lowestSell;
      Limit *highestBuy;

The idea is to have a binary tree of Limit objects sorted by limitPrice,
each of which is itself a doubly linked list of Order objects.  Each side
of the book, the buy Limits and the sell Limits, should be in separate trees
so that the inside of the book corresponds to the end and beginning of the
buy Limit tree and sell Limit tree, respectively.  Each order is also an
entry in a map keyed off idNumber, and each Limit is also an entry in a
map keyed off limitPrice.

With this structure you can easily implement these key operations with
good performance:

Add – O(log M) for the first order at a limit, O(1) for all others
Cancel – O(1)
Execute – O(1)
GetVolumeAtLimit – O(1)
GetBestBid/Offer – O(1)

where M is the number of price Limits (generally << N the number of orders).
Some strategy for keeping the limit tree balanced should be used because the
nature of markets is such that orders will be being removed from one side
of the tree as they’re being added to the other.  Keep in mind, though,
that it is important to be able to update Book.lowestSell/highestBuy
in O(1) time when a limit is deleted (which is why each Limit has a Limit
*parent) so that GetBestBid/Offer can remain O(1)."
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].