A serverless Data Warehouse solution designed to ingest high-frequency cryptocurrency exchange rates and calculate statistical volatility metrics (OHLC, Standard Deviation) in real-time.
The system is powered by an Azure Function App with a Timer Trigger.
- Interval: Every 5 seconds.
- Extraction: Connects to the Binance Spot API to fetch real-time
bidPriceandaskPrice. - Transformation: Calculates spreads and mid-rates, then maps them to a consistent
dim_timehierarchy. - Loading: Streams data into
fact_exchange_ratesusing an UPSERT logic to handle concurrency.
At the turn of every hour, the system triggers a Batch Calculation:
- SQL Logic: Utilizes T-SQL CTEs to aggregate the previous hour's snapshots.
- Metrics: Generates Open, High, Low, Close (OHLC), Standard Deviation, and Hourly Change %.
- Materialized Views: Hourly data is further aggregated into Daily, Weekly, and Monthly Materialized Views to optimize dashboard performance.
Data is visualized via Grafana, connected directly to the Azure SQL instance.
- Real-time Panels: Live spread tracking and price action.
- Historical Panels: Trend analysis from Materialized Views (reduces query time by 90%).
- Azure Account (SQL Database & Function App)
- Binance API Keys
- Grafana Instance
- Database: Execute the scripts in
/sql/schema.sqlto build the Star Schema. - Environment: Create a
.envfile based on.env.example. - Azure Function: Deploy the
/azure_functionfolder using VS Code or Azure CLI.
If using the local tool (pdc.exe) to stream data or manage the dashboard:
- Ensure your authentication token is active.
- Run via CMD:
pdc.exe --token <YOUR_OWN_TOKEN>
The project utilizes a Star Schema to enable high-performance OLAP queries, focusing on financial fact tables linked to time and currency dimensions.
