OrderMatcher 1.0.0

dotnet add package OrderMatcher --version 1.0.0                
NuGet\Install-Package OrderMatcher -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OrderMatcher" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OrderMatcher --version 1.0.0                
#r "nuget: OrderMatcher, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OrderMatcher as a Cake Addin
#addin nuget:?package=OrderMatcher&version=1.0.0

// Install OrderMatcher as a Cake Tool
#tool nuget:?package=OrderMatcher&version=1.0.0                

order-matcher

alternate text is missing from this package README image

order-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.

  • Support multiple order types
    • Limit
    • Market
    • Stop Loss
    • Stop Limit
  • Supports multiple options on order
    • Book or Cancel
    • Immediate or Cancel(IOC)
    • Fill or kill(FOK)
    • Iceberg
    • Good till Date(GTD)
    • Self Trade Prevention

1 Million orders per seconds on AWS c6a.xlarge instance

Supports integer & real numbers/decimal for price and quantity

Hand written serializer faster than any serializer. x15 times faster than JSON, x5 times faster than messagepack

Documentation

home

1. Terminology

2. Order

3. Frequently Asked Questions(FAQ)

Project Development Status : Actively maintained.

Community

Questions and pull requests are welcomed.

Code


class Program
{
    static void Main(string[] args)
    {
        //timeProvider will provide epoch 
        var timeProvider = new TimeProvider();

        //create instance of matching engine.
        MatchingEngine matchingEngine = new MatchingEngine(new MyTradeListener(), new MyFeeProvider(), new Quantity(0.0000_0001m), 8);

        Order order1 = new Order { IsBuy = true, OrderId = 1, OpenQuantity = 0.01m, Price = 69_000 };
        //push new order engine.
        var addResult = matchingEngine.AddOrder(order1, timeProvider.GetSecondsFromEpoch());
        if (addResult == OrderMatchingResult.OrderAccepted)
        {
            // matching engine has accepted order
        }

        //cancel existing orders
        var cancelResult = matchingEngine.CancelOrder(1);//pass orderId to cancel
        if (cancelResult == OrderMatchingResult.CancelAcepted)
        {
            // cancel request is accepted
        }
    }
}



//create a listener to receive events from matching engine. pass it to constructore of MatchingEngine
class MyTradeListener : ITradeListener
{
    public void OnAccept(OrderId orderId, UserId userId)
    {
        Console.WriteLine($"Order Accepted.... orderId : {orderId}");
    }

    public void OnCancel(OrderId orderId, UserId userId, Quantity remainingQuantity, Amount cost, Amount fee, CancelReason cancelReason)
    {
        Console.WriteLine($"Order Cancelled.... orderId : {orderId}, remainingQuantity : {remainingQuantity}, cancelReason : {cancelReason}");
    }

    public void OnOrderTriggered(OrderId orderId, UserId userId)
    {
        Console.WriteLine($"Stop Order Triggered.... orderId : {orderId}");
    }

    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)
    {
        if (bidCost.HasValue)
        {
            // buy order completed
        }
        if (askRemainingQuantity.HasValue)
        {
            // sell order completed
        }

        Console.WriteLine($"Order matched.... incomingOrderId : {incomingOrderId}, restingOrderId : {restingOrderId}, executedQuantity : {matchQuantiy}, exetedPrice : {matchPrice}");
    }
}

class MyFeeProvider : IFeeProvider
{
    public Fee GetFee(short feeId)
    {
        return new Fee
        {
            TakerFee = 0.5m, //0.5% taker fee
            MakerFee = 0.1m, //0.1% maker fee
        };
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 404 12/24/2023