πΎ Database System
WATA uses DuckDB for fast in-memory analytics to store and analyze trading data. This approach provides several advantages for a trading system that needs to track performance metrics and analyze historical data.
Database Architectureβ
DuckDB was chosen for WATA because it provides:
- High-speed analytics: In-memory processing with fast query execution
- SQL compatibility: Familiar query language for data analysis
- Data integrity: Reduced risk of database corruption
- Lightweight footprint: Minimal server resource requirements
- Analytical capabilities: Optimized for data analysis workloads
Data Structureβ
The database stores several types of information:
-
Order Tracking
- Complete order history
- Execution details (price, time, size)
- Order states and status changes
-
Position Management
- Current and historical positions
- Entry and exit points
- Performance metrics (P&L, duration)
- Position attributes (instrument, direction)
-
Performance Analytics
- Daily statistics
- Cumulative performance
- Win/loss metrics
- Trading patterns
Database Configurationβ
The database location is specified in the config.json
file:
"duckdb": {
"persistant": {
"db_path": "/app/var/lib/duckdb/trading_data.duckdb"
}
}
This configurable path allows you to:
- Back up the database easily
- Set a custom location based on your server setup
- Ensure data persistence across application restarts
Data Extraction for Reportingβ
The database can be exported for use with the reporting dashboard:
- Data is extracted from the DuckDB database
- Converted to Parquet format for efficient storage
- Used by the Observable Framework dashboard for visualization
This extraction process is handled by the reporting scripts in the reporting/
directory.