StockBud.io Metrics and Analytics Schema
Schema for metrics collection, analytics, and performance tracking in StockBud.io
📊 StockBud.io Metrics and Analytics Schema
Version: 1.0.0
Schema for metrics collection, analytics, and performance tracking in StockBud.io
Overview
This schema defines 9 data structures:
MetricPoint- Individual metric data point...MetricSeries- Time series of metric points...PerformanceMetrics- Portfolio and trading performance metrics...Alert- System alert based on metrics...Insight- AI-generated insight from analytics...SystemMetrics- System performance and health metrics...TradingMetrics- Trading-specific metrics and statistics...Dashboard- Dashboard configuration and layout...Widget- Dashboard widget configuration...
Definitions
MetricPoint
Individual metric data point
Properties
| Property | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Metric name/identifier |
value | number | ✓ | Metric value |
timestamp | string | ✓ | Metric timestamp |
tags | object | Metric tags for filtering and grouping | |
metadata | object | Additional metric metadata |
TypeScript
MetricSeries
Time series of metric points
Properties
| Property | Type | Required | Description |
|---|---|---|---|
metric_name | string | ✓ | Name of the metric |
data_points | Array<MetricPoint> | ✓ | Array of metric data points |
aggregation_type | enum: 'sum', 'average', 'min', 'max', 'count', 'percentile', 'rate' | Aggregation method used | |
time_window | enum: 'minute', 'hour', 'day', 'week', 'month', 'year' | Time window for aggregation | |
start_time | string | Series start time | |
end_time | string | Series end time |
TypeScript
PerformanceMetrics
Portfolio and trading performance metrics
Properties
| Property | Type | Required | Description |
|---|---|---|---|
total_return | number | Total return percentage | |
annualized_return | number | Annualized return percentage | |
sharpe_ratio | number | Sharpe ratio | |
sortino_ratio | number | Sortino ratio | |
calmar_ratio | number | Calmar ratio | |
max_drawdown | number | Maximum drawdown percentage | |
volatility | number | Portfolio volatility | |
beta | number | Portfolio beta vs benchmark | |
alpha | number | Portfolio alpha vs benchmark | |
win_rate | number | Win rate (percentage of profitable trades) | |
profit_factor | number | Profit factor (gross profit / gross loss) | |
average_win | number | Average winning trade amount | |
average_loss | number | Average losing trade amount | |
largest_win | number | Largest winning trade amount | |
largest_loss | number | Largest losing trade amount | |
total_trades | integer | Total number of trades | |
winning_trades | integer | Number of winning trades | |
losing_trades | integer | Number of losing trades | |
avg_trade_duration | number | Average trade duration in hours | |
turnover_rate | number | Portfolio turnover rate | |
information_ratio | number | Information ratio vs benchmark | |
tracking_error | number | Tracking error vs benchmark | |
var_95 | number | Value at Risk (95% confidence) | |
cvar_95 | number | Conditional Value at Risk (95% confidence) | |
period_start | string | Performance period start | |
period_end | string | Performance period end | |
benchmark | string | Benchmark symbol used for comparison |
TypeScript
Alert
System alert based on metrics
Properties
| Property | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | Unique alert identifier |
alert_type | enum: 'performance', 'risk', 'system', 'compliance', 'market', 'portfolio', 'trade_execution' | ✓ | Type of alert |
severity | enum: 'low', 'medium', 'high', 'critical' | ✓ | Alert severity level |
title | string | Alert title | |
message | string | ✓ | Alert message |
metric_name | string | Related metric name | |
metric_value | number | Metric value that triggered alert | |
threshold | number | Threshold that was breached | |
condition | enum: 'above', 'below', 'equal', 'not_equal', 'change_rate' | Condition that triggered alert | |
affected_symbols | Array<string> | Symbols affected by this alert | |
recommended_actions | Array<string> | Recommended actions | |
acknowledged | boolean | Whether alert has been acknowledged | |
acknowledged_by | string | Who acknowledged the alert | |
acknowledged_at | string | When alert was acknowledged | |
resolved | boolean | Whether alert has been resolved | |
resolved_at | string | When alert was resolved | |
timestamp | string | ✓ | Alert creation timestamp |
expires_at | string | Alert expiration timestamp |
TypeScript
Insight
AI-generated insight from analytics
Properties
| Property | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | Unique insight identifier |
insight_type | enum: 'performance_analysis', 'risk_assessment', 'market_opportunity', 'portfolio_optimization', 'trend_analysis', 'anomaly_detection', 'correlation_analysis', 'predictive_analysis' | ✓ | Type of insight |
confidence | number | ✓ | Confidence level (0-1) |
title | string | ✓ | Insight title |
description | string | ✓ | Detailed insight description |
supporting_data | object | Data supporting the insight | |
affected_metrics | Array<string> | Metrics related to this insight | |
affected_symbols | Array<string> | Symbols affected by this insight | |
recommended_actions | Array<string> | Recommended actions based on insight | |
impact_score | number | Expected impact score (0-10) | |
time_horizon | enum: 'immediate', 'short_term', 'medium_term', 'long_term' | Time horizon for the insight | |
generated_at | string | Insight generation timestamp | |
valid_until | string | Insight validity expiration |
TypeScript
SystemMetrics
System performance and health metrics
Properties
| Property | Type | Required | Description |
|---|---|---|---|
cpu_usage | number | CPU usage percentage | |
memory_usage | number | Memory usage percentage | |
disk_usage | number | Disk usage percentage | |
network_latency | number | Network latency in milliseconds | |
api_response_time | number | Average API response time in milliseconds | |
database_connections | integer | Active database connections | |
active_users | integer | Number of active users | |
error_rate | number | Error rate (0-1) | |
uptime | number | System uptime in hours | |
last_backup | string | Last backup timestamp | |
timestamp | string | Metrics collection timestamp |
TypeScript
TradingMetrics
Trading-specific metrics and statistics
Properties
| Property | Type | Required | Description |
|---|---|---|---|
orders_placed | integer | Number of orders placed | |
orders_filled | integer | Number of orders filled | |
orders_cancelled | integer | Number of orders cancelled | |
fill_rate | number | Order fill rate (0-1) | |
avg_fill_time | number | Average fill time in seconds | |
slippage | number | Average slippage in basis points | |
commission_paid | number | Total commission paid | |
market_impact | number | Average market impact in basis points | |
trading_volume | number | Total trading volume | |
active_positions | integer | Number of active positions | |
portfolio_concentration | number | Portfolio concentration (Herfindahl index) | |
sector_diversification | number | Sector diversification score | |
timestamp | string | Metrics timestamp |
TypeScript
Dashboard
Dashboard configuration and layout
Properties
| Property | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | Unique dashboard identifier |
name | string | ✓ | Dashboard name |
description | string | Dashboard description | |
widgets | Array<Widget> | ✓ | Dashboard widgets |
layout | object | Dashboard layout configuration | |
refresh_interval | integer | Refresh interval in seconds | |
created_by | string | Dashboard creator | |
created_at | string | Creation timestamp | |
updated_at | string | Last update timestamp |
TypeScript
Widget
Dashboard widget configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | Unique widget identifier |
type | enum: 'line_chart', 'bar_chart', 'pie_chart', 'table', 'metric_card', 'gauge', 'heatmap', 'candlestick', 'scatter_plot' | ✓ | Widget type |
title | string | ✓ | Widget title |
description | string | Widget description | |
data_source | string | Data source for the widget | |
metrics | Array<string> | Metrics to display | |
filters | object | Data filters | |
time_range | object | Time range for data | |
position | object | Widget position and size | |
options | object | Widget-specific options |