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 workers (candles → indicators → strategy → executor) into a pipeline
  • How to connect external WebSocket streams (Binance, Alpaca) as WebSocketFeed workers 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/*.py
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 workers chained into a pipeline, live platform pipelines, and tours of Virtufin.Core/Base
Binance order book Stream BTC/USDT order-book depth from Binance through a WebSocketFeed worker and keep a local order book
Alpaca order book Stream the BTC/USD order book from Alpaca; the feed logs in from worker secrets
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)
cp .env.example .env    # set VIRTUFIN_REGISTRY_USER/TOKEN
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 binance_order_book.py

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

# 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".