{"id":18322090,"url":"https://github.com/pranav-bot/rust-trading-engine","last_synced_at":"2025-06-18T16:37:00.413Z","repository":{"id":240661185,"uuid":"803238975","full_name":"pranav-bot/rust-trading-engine","owner":"pranav-bot","description":"This project is an implementation of a basic order book for a trading system, written in Rust.","archived":false,"fork":false,"pushed_at":"2024-05-28T13:31:14.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T14:41:31.488Z","etag":null,"topics":["rust","rust-lang","trading-engine"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pranav-bot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-20T10:47:09.000Z","updated_at":"2024-05-28T13:31:18.000Z","dependencies_parsed_at":"2024-05-20T12:30:36.089Z","dependency_job_id":"879971ed-5aff-48b7-bdbc-feeb41d06217","html_url":"https://github.com/pranav-bot/rust-trading-engine","commit_stats":null,"previous_names":["pranav-bot/rust-trading-engine"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pranav-bot/rust-trading-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-bot%2Frust-trading-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-bot%2Frust-trading-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-bot%2Frust-trading-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-bot%2Frust-trading-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranav-bot","download_url":"https://codeload.github.com/pranav-bot/rust-trading-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-bot%2Frust-trading-engine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260590309,"owners_count":23033035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","rust-lang","trading-engine"],"created_at":"2024-11-05T18:23:10.503Z","updated_at":"2025-06-18T16:36:54.623Z","avatar_url":"https://github.com/pranav-bot.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Order Book\n\nThis project implements an order book and a matching engine for managing and matching buy (bid) and sell (ask) orders in a financial market.\n\n## Project Structure\n\n```\norder_book/\n├── src/\n│   ├── main.rs\n│   ├── matching_engine/\n│   │   ├── mod.rs\n│   │   ├── orderbook.rs\n│   │   └── engine.rs\n├── Cargo.toml\n└── README.md\n```\n\n### Main Components\n\n- **main.rs**: The entry point of the application.\n- **matching_engine/mod.rs**: The module declaration for the matching engine.\n- **matching_engine/orderbook.rs**: Contains the `OrderBook`, `Order`, `Limit`, `Price`, and `BidOrAsk` enums.\n- **matching_engine/engine.rs**: Contains the `MatchingEngine` and `TradingPair` structs.\n\n## Getting Started\n\n### Prerequisites\n\nEnsure you have [Rust](https://www.rust-lang.org/tools/install) installed.\n\n### Running the Application\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/yourusername/order_book.git\n    cd order_book\n    ```\n\n2. Build and run the application:\n    ```bash\n    cargo run\n    ```\n\n## Code Overview\n\n### main.rs\n\n```rust\nmod matching_engine;\nuse matching_engine::engine::{MatchingEngine, TradingPair};\nuse matching_engine::orderbook::{Order, OrderBook, BidOrAsk};\n\nfn main() {\n    let buy_order = Order::new(BidOrAsk::Bid, 5.5);\n    let mut orderbook = OrderBook::new();  \n    orderbook.add_order(4.4, buy_order);\n    //println!(\"{:?}\", orderbook);\n    \n    let mut engine = MatchingEngine::new();\n    let pair = TradingPair::new(\"BTC\".to_string(), \"USD\".to_string());\n    engine.add_new_market(pair.clone());\n    \n    let buy_order = Order::new(BidOrAsk::Bid, 5.5);\n    engine.place_limit_order(pair, 10.000, buy_order).unwrap();\n}\n```\n\nThis is the entry point of the application where:\n- An `OrderBook` is created, and a buy order is added.\n- A `MatchingEngine` is initialized, and a new market (trading pair) is added.\n- A buy order is placed in the matching engine's order book for the specified trading pair.\n\n### matching_engine/orderbook.rs\n\nDefines the `OrderBook` and related structures:\n\n- **BidOrAsk**: Enum to differentiate between bid (buy) and ask (sell) orders.\n- **OrderBook**: Struct managing `bids` and `asks` at various price levels.\n- **Order**: Struct representing an order with size and type (bid or ask).\n- **Limit**: Struct grouping orders at a specific price.\n- **Price**: Struct for precise price representation, split into integral and fractional parts.\n\n### matching_engine/engine.rs\n\nDefines the `MatchingEngine` and `TradingPair`:\n\n- **TradingPair**: Struct representing a trading pair (e.g., BTC/USD).\n- **MatchingEngine**: Struct managing multiple order books for different trading pairs.\n    - `add_new_market`: Adds a new trading pair to the matching engine.\n    - `place_limit_order`: Places a limit order in the order book for the specified trading pair.\n\n### matching_engine/mod.rs\n\nModule declaration to include `orderbook` and `engine` modules.\n\n```rust\npub mod orderbook;\npub mod engine;\n```\n\n## Example Usage\n\n```rust\nfn main() {\n    let mut engine = MatchingEngine::new();\n    let pair = TradingPair::new(\"BTC\".to_string(), \"USD\".to_string());\n    engine.add_new_market(pair.clone());\n\n    let buy_order = Order::new(BidOrAsk::Bid, 5.5);\n    engine.place_limit_order(pair, 10.000, buy_order).unwrap();\n}\n```\n\nThis example initializes the matching engine, adds a new market (BTC/USD), and places a buy order at a specific price.\n\n## Contributing\n\nFeel free to submit pull requests or open issues to improve the project.\n\n---\n\nThis README provides an overview of the project, how to get started, and a brief explanation of the main components and their functionalities.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranav-bot%2Frust-trading-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranav-bot%2Frust-trading-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranav-bot%2Frust-trading-engine/lists"}