Overview
A strategy in Virtufin is the pair of morphisms (decide, execute)
modelled coalgebraically (see the behaviour spec). This devkit provides
the decide bridge and its supporting types.
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 (the strategy owns it; the driver threads it, never the caller).TMarket— the market observation (raw feed events or derived signals like candles, VWAP, volatility).TPortfolio— the folded holdings the strategy observes — the loop's feedback edge: fills fold into positions, positions feed the next decision.TAction[]— zero or more intents emitted per observation.
The three packages
| Package | Role | Depends on |
|---|---|---|
Virtufin.Strategy.DevKit |
runtime: StrategyWorkerBase, ConfigResolution, PortfolioState/PortfolioAlgebra |
.Events, Core, Base, Worker.DevKit |
Virtufin.Strategy.DevKit.Events |
wire mapping: mappers, enrichment, AmountJson |
Core, Base |
Virtufin.Strategy.DevKit.Indicators |
indicators: SimpleMovingAverage |
— |
The bridge (StrategyWorkerBase) implements the DevKit worker contract
(IWorker.ProcessAsync(CloudEvent)) on top of any IDecide, dispatching
each CloudEvent by type, folding position events into the portfolio,
stepping market events through decide, and encoding the resulting
actions into a response CloudEvent.
Next: Strategy Author Guide.