Virtufin Examples
Example applications demonstrating how to use Virtufin services with real-world market data APIs from Binance and Alpaca.
What You'll Learn
- How to connect external WebSocket streams (Binance, Alpaca) to Dapr pub/sub via WebSocketManager
- How to process real-time market data with WorkManager workers
- How to publish/subscribe to topics and persist state via API Gateway
- How to handle API authentication, reconnection, and error recovery
Languages
All examples are available in four languages, all using packages from the Gitea registry:
| Language | Package Registry | Key Files |
|---|---|---|
| Python | Gitea PyPI | python/websocketmanager/, python/workmanager/ |
| C# | Gitea NuGet | dotnet/Virtufin.Examples.CSharp/Program.cs |
| F# | Gitea NuGet | dotnet/Virtufin.Examples.FSharp/Program.fs |
| TypeScript | Gitea npm | typescript/examples/ |
Examples
| Example | Description | Concepts Demonstrated |
|---|---|---|
| Binance CLOB | Stream BTC/USDT order book depth from Binance | WebSocket connection, order book management, state store |
| Alpaca CLOB | Stream BTC/USD order book from Alpaca with API key auth | WebSocket auth, incremental updates, reconnect |
| Order Flow Imbalance | Calculate bid/ask imbalance from Binance depth | WorkManager, state change monitoring, signal calculation |
Quick Start
# 1. Configure Gitea registry access
cp .env.example .env
# Edit .env with your GITEA_USERNAME, GITEA_TOKEN, Alpaca keys, etc.
source .env
# 2. Start Virtufin services
docker compose up -d
# 3. Run an example
# Python
cd python
source ../.env
export UV_INDEX_GITEA_USERNAME=$GITEA_USERNAME
export UV_INDEX_GITEA_PASSWORD=$GITEA_TOKEN
uv sync
uv run python websocketmanager/binance_clob_example.py
# C#
cd dotnet && dotnet run --project Virtufin.Examples.CSharp
# TypeScript
cd typescript && npm install && npm run wsm