Skip to content

Getting Started

Install

The library is published to a private NuGet feed as a single package per project:

# Configure the private feed (one-time)
dotnet nuget add source https://nuget.haenerconsulting.com/api/packages/virtufin/nuget/ \
    --name virtufin

# Add the packages you need
dotnet add package Virtufin.Core
dotnet add package Virtufin.Base     # depends on Core
dotnet add package Virtufin.Data     # depends on Core + Base
dotnet add package Virtufin.Util     # standalone utilities

For a strategy worker that needs the execution algebra and the EAV primitives:

<ItemGroup>
  <PackageReference Include="Virtufin.Core" />
  <PackageReference Include="Virtufin.Base" />
</ItemGroup>

Target framework

The library targets net10.0. Set your consumer project's TargetFramework accordingly:

<PropertyGroup>
  <TargetFramework>net10.0</TargetFramework>
  <Nullable>enable</Nullable>
</PropertyGroup>

Hello, Variant

using Virtufin.Data;

// Implicit construction from primitives
Variant v1 = 42;            // -> Variant.Int32
Variant v2 = "hello";       // -> Variant.String
Variant v3 = true;          // -> Variant.Bool
Variant v4 = new Dictionary<string, Variant> {
    ["price"] = 100.5m,
    ["symbol"] = "BTCUSDT",
};                          // -> Variant.Dictionary

// Pattern matching to extract
string result = v1 switch {
    Variant.Int32 i => $"int: {i.Value}",
    Variant.String s => $"str: {s.Value}",
    _ => "other",
};

// Round-trip through FlatBuffers
byte[] bytes = v4.Serialize();
Variant restored = Variant.Deserialize(bytes);

Register an entity

using Virtufin.Core;

var registry = new Registry();

// Register an entity-attribute-value schema
var entityId = new EntityIdentifier<MyEntity>("order-123");
registry.Register(entityId);

// Attach a value provider
registry.AttachValueProvider(entityId, "price", () => currentMarketPrice);

Define an executor

using Virtufin.Base.Events.Trade;
using Virtufin.Base.Execution;

public sealed class LimitPriceExecutor
    : DeterministicExecutorBase<DeterministicState, RichTradeAction, TradeEvent>
{
    public override DeterministicState Initial => DeterministicState.Instance;

    protected override (DeterministicState, TradeEvent) Process(
        DeterministicState state, RichTradeAction action)
    {
        // case-by-case fill logic on RichTradeAction
        // ...
    }
}

For a working example, see the Architecture page or the test projects in the repository.

Next steps

  • Architecture — project boundaries, dependency direction, the trait/concrete split
  • Core EAVIEntity<V, I>, IAttribute<V>, IValueProvider<V, I>, the global Registry
  • Variant Type — the Variant discriminated union in depth
  • API Reference — full public API surface