Skip to content

Virtufin Examples

Runnable examples for the Virtufin platform: C# notebooks that build, test and deploy workers with the devkits, and Python and TypeScript scripts that drive the platform's services with live market data from Binance and Alpaca.

What You'll Learn

  • How to write a market-data, indicator, strategy or executor worker with the devkits, test it offline on real market data, publish it and deploy it on the platform
  • How to chain the published engine workers (candles → indicators → strategy → executor) into a pipeline
  • How to connect external WebSocket streams (Binance, Alpaca) through WebSocketManager and read them back from pub/sub
  • How to run and manage workers with WorkManager, and keep state in the gateway's State service
  • How every example picks its Virtufin API with a context (demo by default)

Languages

Language Client package Examples
C# Virtufin.Api.Client and the devkits, loaded by the Virtufin.Examples.Notebooks package dotnet/*.verso notebooks, dotnet/workers/
Python virtufin-api python/websocketmanager/, python/workmanager/, python/API.py, scripts/
TypeScript @virtufin/api typescript/examples/

All packages come from the Virtufin registry on Gitea (see Installation).

Examples

Example What it shows
C# notebooks The devkits end to end (market data, indicator, strategy, executor), the published engines chained into a pipeline, live platform pipelines, and tours of Virtufin.Core/Base
Binance CLOB Stream BTC/USDT order-book depth from Binance through WebSocketManager and keep a local order book
Alpaca CLOB Stream the BTC/USD order book from Alpaca, with API-key authentication over the WebSocket
Alpaca Market Data Stream several Alpaca crypto symbols into one topic and print every frame
Order Flow Imbalance Compute the weighted bid/ask imbalance from the Binance order book in State

Overview lists every example, including the TypeScript ones and the Python client tour.

Quick Start

# 1. Registry access (packages) and, for Alpaca, the API keys
cp .env.example .env    # set VIRTUFIN_REGISTRY_USER/TOKEN, ALPACA_API_KEY/SECRET
source .env

# 2. The API: examples use the "demo" context from ~/.config/virtufin/api/contexts.toml
#    (see Getting Started); no local services needed.

# 3. Run an example
cd python
export UV_INDEX_VIRTUFIN_USERNAME=$VIRTUFIN_REGISTRY_USER
export UV_INDEX_VIRTUFIN_PASSWORD=$VIRTUFIN_REGISTRY_TOKEN
uv sync
uv run python websocketmanager/binance_clob_example.py

# TypeScript
cd typescript && npm install && npm run wsm

# C# notebook (headless)
cd dotnet && verso run binance-order-book-live.verso

To run against a backend of your own instead, start it (see Deployment) and set the example's context name to "local".