Skip to content

Overview

A strategy in Virtufin is the pair of morphisms (decide, execute) modelled coalgebraically (see the behaviour spec). The strategy devkit provides the decide bridge; this repo ships the deployable workers built on it.

The coalgebra

decide is an IDecide<TState, TMarket, TPortfolio, TAction>:

public interface IDecide<TState, TMarket, TPortfolio, TAction>
    : IProcess<TState, (TMarket, TPortfolio), TAction[]>
    where TState : IStrategyState
    where TMarket : IMarketEvent
    where TPortfolio : IPortfolioState
    where TAction : ITradeAction
{ }
  • TState — hidden indicator state.
  • TMarket — the market observation (raw feed or derived signals).
  • TPortfolio — the folded holdings (the loop's feedback edge).
  • TAction[] — zero or more intents per observation.

The bridge

StrategyWorkerBase<TS, TM, TP, TA> (from Virtufin.Strategy.DevKit) implements the WorkManager worker contract on top of any IDecide. See the devkit's strategy author guide for how to build one.

The two example workers

Both implement the same rule — buy when the close crosses above the N-day SMA while flat, sell when it crosses below while long — on two engines, proving the contract is language-portable.

Worker Engine Language
MovingAverage application/x-dotnet-dll C#
MovingAveragePython text/x-python Python

Next: Getting Started.