Giter VIP home page Giter VIP logo

orderbook's Introduction

Orderbook Data Structure

This project implements an orderbook data structure in C++. An orderbook is a critical component of financial markets, used to manage and match buy and sell orders efficiently.

Overview

The project consists of several key components:

  • Orderbook: The main class representing the orderbook. It manages buy and sell orders and matches them based on price-time priority.

  • Order: Represents an individual order with attributes such as order type, side (buy/sell), price, and quantity.

  • Order Modify: Handles modifications to existing orders, such as price or quantity adjustments.

  • Trade: Represents a trade executed between a buy and sell order.

  • Google Tests: The project includes tests implemented using Google Test framework to ensure correctness and reliability.

Usage

To use the orderbook, you can create an instance of the Orderbook class and interact with it by adding, canceling, or modifying orders. Here's a simple example:

Orderbook orderbook;

// Add a buy order
const OrderId orderId = 1;
orderbook.addOrder(std::make_shared<Order>(OrderType::GoodTillCancel, orderId, Side::Buy, 100, 10));

// Check the size of the orderbook
std::cout << "Orderbook size: " << orderbook.Size() << std::endl;

// Cancel the order
orderbook.CancelOrder(orderId);

// Check the size again
std::cout << "Orderbook size after cancellation: " << orderbook.Size() << std::endl;

Order Types

The project supports various order types including:

  • Good Till Cancel: The order remains active until filled, canceled, or expires.
  • Fill and Kill: The order is filled as much as possible, and any remaining quantity is canceled immediately.
  • Market Order: Filled at the best available price.
  • Good For Day: Similar to Good Till Cancel, but automatically canceled at the end of the trading day.
  • Fill or Kill: Must be filled immediately and entirely or canceled.

Dependencies

The project relies on standard C++ libraries and includes Google Test framework for testing purposes.

Testing

The project includes comprehensive unit tests implemented using Google Test framework to ensure correctness and reliability. To run the tests, you can run the following file:

test.cpp

Contributing

Contributions are welcome! Feel free to open issues or pull requests for any improvements or bug fixes.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Feel free to customize this README further to provide more detailed information about your project's features, usage, or any other relevant details.

orderbook's People

Contributors

jideoyelayo1 avatar

Watchers

 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.