Skip to content

alexnicholsamu/HFT-market-sim

Repository files navigation

HFT-market-sim

Tools used in the creation of this project:

Standard Libraries from chronos, threads, mutex, atomic, etc.

leaks & Valgrind memory management, g++/clang++ debugger (this project started off on Windows, but was completed on macOS)

Summary

This is my high-frequency trading market simulator, where through concurrent and parallel programming (through the use of multithreading) I have 25 traders all making and handling orders with their portfolio of Nasdaq100 stocks. All 25 traders are operating simultaneously across the computer's cores, concurrently with market fluctuations, generated market events, and orderbook executions.

Each trader thread has decisions decided by a number generator about buying/selling stocks or canceling an active order. The quantities, as well as specific stock, are also decided by a generator. The process of ordering is handled through the orderbook, and the portfolios of each individual trader are dynamically and independently updated at the fulfillment of their orders.

The fluctuation thread generates numbers that when passed to each stock, will randomly fluctuate the stocks independently of one another, so the price of each stock is changing. Note that this will not affect placed orders, as those set prices are final.

The market event thread generates market events (currently interest rate changes, public opinion changes, global economic changes, recessions, times of prosperity, an umbrella 'other government policy', or nothing). Each event (excluding nothing, of course) affects stock prices by multiplying their price (affected via the fluctuations thread) by a combined factor of events simply called 'factors'.

The orderbook execution thread does as the name suggests, executes the placed orders in the orderbook and adjust respective traders' portfolios and cash respectively.

Finally, the main thread sets up the simulation by reading in stock and trader data, setting up market event odds, and starting the threads. At the conclusion of 5 minutes (arbitrary time which can be modified in the Market::run() method), the simulation will stop, the threads will join, and everything will be reset. Future works include providing interesting statistics.

All files are necessary to run this program. The program should be run through the terminal ('./shellrun.sh'), making sure to have executable permissions('chmod +x shellrun.sh'). The license can be found here. All bugs and improvement suggestions should be emailed to alexander.k.nichols@gmail.com.

About

A HFT Market Simulation utilizing high-speed, efficient C++ and concurrent/parallel programming

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors