Namespace Virtufin.Core.Behaviour
Classes
- ProcessExtensions
Drivers that fold an IProcess<TState, TInput, TOutput> coalgebra over a stream of inputs. The coalgebra itself stays pure and pull-based; these extensions add the reactive layer on demand — the
scancombinator of the domain spec (§10.4).
Interfaces
- IAlgebra<TEvent, TState>
An F-algebra over an event log. Given a current state and an event, produce the next state. Combined with the initial state and an event log, the algebra defines a derived signal via the fold (or scan for running computation).
- IDecide<TState, TMarket, TPortfolio, TAction>
The
decidemorphism of the trading loop: given the strategy's hidden state, a market observation, and the folded portfolio state, produce the next strategy state and zero or more trade actions. This is the coalgebraStrategyState × MarketEvent × PortfolioState → StrategyState × TradeAction[]of the domain spec (§6.4), exposed as an IProcess<TState, TInput, TOutput> so strategies compose with the genericscan/folddrivers (ProcessExtensions).
- IIndicator<TSelf, TSample, TValue>
An immutable, self-folding indicator: consumes samples one at a time and exposes its current value via ISignal<T>. Composes with ISignal<T> rather than IAlgebra<TEvent, TState> or IProcess<S,E> because the indicator's own state doesn't need to be threaded as an explicit external parameter —
thisalready is the state.
- IPortfolioState
Marker for any type that represents the folded portfolio state — the derived holdings (positions, cash, average entry prices) a strategy observes at each step of the trading loop. Counterpart of the raw
IPositionEventstream: the state is produced by folding the events with an IAlgebra<TEvent, TState>.
- IProcess<TState, TInput, TOutput>
Coalgebra shape for a stateful process: given the current state and an input observation, produce the next state and an output. The domain instantiations are IDecide<TState, TMarket, TPortfolio, TAction> (
decide) andIExecutor(execute), where the process carries hidden state that must be exposed explicitly. Drive a process over an observable stream of inputs with Run<TState, TInput, TOutput>(IProcess<TState, TInput, TOutput>, IObservable<TInput>).
- ISignal<T>
A continuously derivable value computed from an event log. Signals are never transported on Dapr topics; consumers reconstruct them on demand by folding the log.
- IStrategyState
Marker for any type that carries the hidden state of a strategy: indicator values, model weights, momentum windows, cooldown timers. Counterpart of IExecutionState on the executor side — it exists so IDecide<TState, TMarket, TPortfolio, TAction> can constrain its state parameter.