{"id":20954575,"url":"https://github.com/arjunvachhani/order-matcher","last_synced_at":"2025-06-20T06:06:16.634Z","repository":{"id":37822489,"uuid":"167831948","full_name":"ArjunVachhani/order-matcher","owner":"ArjunVachhani","description":"simple, fast and feature rich order matching engine supports limit, market, stop-loss, iceberg, IOC, FOK, GTD orders","archived":false,"fork":false,"pushed_at":"2024-10-17T19:35:52.000Z","size":2932,"stargazers_count":153,"open_issues_count":1,"forks_count":76,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-17T04:03:52.038Z","etag":null,"topics":["cryptocurrency","cryptocurrency-exchanges","dotnet","dotnet-core","matching-engine","order-book","order-matching","orderbook","stocks","stocks-exchange","trading","trading-engine"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArjunVachhani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-01-27T16:41:22.000Z","updated_at":"2025-04-24T22:48:46.000Z","dependencies_parsed_at":"2024-07-07T07:46:17.255Z","dependency_job_id":"b657428a-37be-44f0-96e6-12cc61af1b28","html_url":"https://github.com/ArjunVachhani/order-matcher","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ArjunVachhani/order-matcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArjunVachhani%2Forder-matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArjunVachhani%2Forder-matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArjunVachhani%2Forder-matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArjunVachhani%2Forder-matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArjunVachhani","download_url":"https://codeload.github.com/ArjunVachhani/order-matcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArjunVachhani%2Forder-matcher/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260891143,"owners_count":23077909,"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":["cryptocurrency","cryptocurrency-exchanges","dotnet","dotnet-core","matching-engine","order-book","order-matching","orderbook","stocks","stocks-exchange","trading","trading-engine"],"created_at":"2024-11-19T01:15:13.959Z","updated_at":"2025-06-20T06:06:11.609Z","avatar_url":"https://github.com/ArjunVachhani.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"  \n# order-matcher\n\n![](https://github.com/ArjunVachhani/order-matcher/workflows/.NET%20Core/badge.svg?branch=master)\n\norder-matcher is a simple and fast library to build crypto-currency exchange, stock exchange or commodity exchange. order-matcher matches buy and sell orders using price-time priority algorithm. order-matcher supports multiple order types and able to excecute upto 1 million messages per seconds.\n\n - Support multiple order types\n\t - Limit \n\t - Market  \n\t - Stop Loss\n  \t - Stop Limit\n  - Supports multiple options on order\n\t - Book or Cancel\n\t - Immediate or Cancel(IOC) \n\t - Fill or kill(FOK)\n\t - Iceberg\n\t - Good till Date(GTD) \n  \t - Self Trade Prevention \t\n       \n**1 Million orders per seconds on AWS c6a.xlarge instance**\n\n**Supports integer \u0026 real numbers/decimal for price and quantity**\n\n**Hand written serializer faster than any serializer. x15 times faster than JSON, x5 times faster than messagepack**\n\n## Documentation\n[home](https://github.com/ArjunVachhani/order-matcher/wiki)\n\n[1. Terminology](https://github.com/ArjunVachhani/order-matcher/wiki/1.-Terminology)\n\n[2. Order](https://github.com/ArjunVachhani/order-matcher/wiki/2.-Order)\n\n[3. Frequently Asked Questions(FAQ)](https://github.com/ArjunVachhani/order-matcher/wiki/FAQ----Frequently-Asked-Questions)\n\n## Project Development Status : Actively maintained. \n\n## Community\nQuestions and pull requests are welcomed. \n\n## Are you building spot crypto exchange?\nChat with me on telegram at [https://t.me/Arjun_Vachhani](https://t.me/Arjun_Vachhani), I may be able to help you.\n\n## Code\n```csharp\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        //timeProvider will provide epoch \n        var timeProvider = new TimeProvider();\n\n        //create instance of matching engine.\n        MatchingEngine matchingEngine = new MatchingEngine(new MyTradeListener(), new MyFeeProvider(), new Quantity(0.0000_0001m), 8);\n\n        Order order1 = new Order { IsBuy = true, OrderId = 1, OpenQuantity = 0.01m, Price = 69_000 };\n        //push new order engine.\n        var addResult = matchingEngine.AddOrder(order1, timeProvider.GetSecondsFromEpoch());\n        if (addResult == OrderMatchingResult.OrderAccepted)\n        {\n            // matching engine has accepted order\n        }\n\n        //cancel existing orders\n        var cancelResult = matchingEngine.CancelOrder(1);//pass orderId to cancel\n        if (cancelResult == OrderMatchingResult.CancelAcepted)\n        {\n            // cancel request is accepted\n        }\n    }\n}\n\n\n\n//create a listener to receive events from matching engine. pass it to constructore of MatchingEngine\nclass MyTradeListener : ITradeListener\n{\n    public void OnAccept(OrderId orderId, UserId userId)\n    {\n        Console.WriteLine($\"Order Accepted.... orderId : {orderId}\");\n    }\n\n    public void OnCancel(OrderId orderId, UserId userId, Quantity remainingQuantity, Amount cost, Amount fee, CancelReason cancelReason)\n    {\n        Console.WriteLine($\"Order Cancelled.... orderId : {orderId}, remainingQuantity : {remainingQuantity}, cancelReason : {cancelReason}\");\n    }\n\n    public void OnOrderTriggered(OrderId orderId, UserId userId)\n    {\n        Console.WriteLine($\"Stop Order Triggered.... orderId : {orderId}\");\n    }\n\n    public void OnTrade(OrderId incomingOrderId, OrderId restingOrderId, UserId incomingUserId, UserId restingUserId, bool incomingOrderSide, Price matchPrice, Quantity matchQuantiy, Quantity? askRemainingQuantity, Amount? askFee, Amount? bidCost, Amount? bidFee)\n    {\n        if (bidCost.HasValue)\n        {\n            // buy order completed\n        }\n        if (askRemainingQuantity.HasValue)\n        {\n            // sell order completed\n        }\n\n        Console.WriteLine($\"Order matched.... incomingOrderId : {incomingOrderId}, restingOrderId : {restingOrderId}, executedQuantity : {matchQuantiy}, exetedPrice : {matchPrice}\");\n    }\n}\n\nclass MyFeeProvider : IFeeProvider\n{\n    public Fee GetFee(short feeId)\n    {\n        return new Fee\n        {\n            TakerFee = 0.5m, //0.5% taker fee\n            MakerFee = 0.1m, //0.1% maker fee\n        };\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farjunvachhani%2Forder-matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farjunvachhani%2Forder-matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farjunvachhani%2Forder-matcher/lists"}