Devircle System Architecture
Refresh: 5s Labels: hourly Retrain: daily

From Market Tape to Decisions

Each stage transforms raw exchange data into calibrated predictions. Select a node to inspect.

Input
Engine
Core Model
Output
ML-Powered
ML Candidate
Observe
1
Exchange APIs
OHLCV, OI, Funding Data source
2
Historical DB
Labels, Snapshots Storage
ingest
Interpret
3
Outlook Engine
14 factors -> score ML candidate
4
Gap Registry
FVG lifecycle ML candidate
5
Feature Builder
ML vectors Feeds ML
transform
Predict
6
Imminent Model
P(move) calibrated ML
7
Target Model
Selection Logic ML candidate
8
Interaction Model
P(fill), P(react) ML
decide
Act + Learn
9
Discord Alerts
Trigger notify Output
10
Dashboard
Live state Output
11
Learning Loop
Feedback -> Retrain ML
Observe
1
OANDA API
15M XAUUSD Candles Data source
2
Historical DB
numerian_gold.db Storage
ingest
Interpret
3
S/R Zone Detector
15M S/R zones ML candidate
4
Trendline Tracker
Channel detection ML candidate
5
Regime Classifier
Range / Trend / Breakout ML candidate
6
Feature Builder
S/R + Trendline vectors Feeds ML
transform
Predict
7
Imminent Model
P(breakout) + CVS Planned
8
Target Model
S/R zone or trendline Planned
9
Interaction Model
Bounce vs Break Planned
decide
Act + Learn
10
Discord Alerts
Gold notifications Output
11
Gold Dashboard
Live XAUUSD state Output
12
Learning Loop
Feedback -> Retrain Planned

Model Health Monitor

Loading model status...

Learning Systems

Imminent Model (Time)
"When will price move?"
Autopilot
What's happening here

Think of this like a weather forecast for price. Before a big move happens, there are usually signs - volume picks up, ranges get tight, funding rates shift. This system watches those signs and asks: "Is something about to happen?" Every night, it checks how it did. If it said "storm coming" and nothing happened, it notes that. If it missed a big move, it notes that too. Over time, it gets better at reading the signs.

Data Flow
Snapshot Captured
Wait for Outcome
Label (Move/No Move)
Retrain Daily @ 04:00
Key Files
label_outlook_move.py train_imminent_move_model.py ml/imminent_move_features.py models/imminent_move_h*.json
Interaction Model (Behavior)
"What will price do at the gap?"
Autopilot
What's happening here

When price reaches a gap level, two things can happen: it either punches through (a Fill) or it bounces off (a Reaction). This system keeps a record of every time price touched a gap. It waits to see what actually happened, then writes it down. After seeing hundreds of these, it starts to notice patterns - gaps with certain characteristics tend to hold, others tend to break. That's what the F and R percentages on the chart represent.

Data Flow
Gap Touched
Observe Outcome
Label (Fill/React)
Retrain Daily @ 03:00
Key Files
label_interaction.py train_gap_interaction_model.py ml/interaction_features.py models/gap_interaction_h*_*.json
Meta-Optimization (Code Heuristics)
"Are the rules themselves correct?"
Developer-Assist
What's happening here

The Outlook Score you see on the dashboard (the 0-100 number) is based on a set of rules we wrote. But rules can be wrong. This tool runs the numbers and tells us exactly where we're making mistakes. For example: "You're giving too much weight to volume spikes - they're causing false alarms 40% of the time." We then use that feedback to adjust the rules. It's not automatic - a person has to make the changes - but the diagnosis is handled for us.

Data Flow
Run Analysis
Calculate Precision/Recall
Generate Prompt
Developer Patches Code
Key Files
run_optimization_loop.py ml/outlook_performance.py ml/outlook_self_improve.py
Diagnostic Toolset
Manual verification and auditing
On-Demand
What are these for

These are checkup tools. You run them when you want to verify something is working or when something seems off. Think of them like running diagnostics on your car - you don't use them every day, but they're there when you need to figure out what's going on under the hood.

analyze_moves.py
Reality check: Downloads raw Binance data to find actual big moves independent of internal logs.
check_imminent_v3.py
State inspector: Lists recent times the system went into IMMINENT mode.
analyze_fvg_logs.py
Gap audit: Checks if the gap detector is creating valid gaps or "hallucinating" them.
evaluate_frc.py
Score tester: Checks if F/R/C chips are accurate probability indicators.
check_phase5.py
Integration test: Confirms AI predictions attach correctly to database events.
verify_interaction_model.py
Model integrity: Loads live JSON model, checks schema validity, verifies features.
check_db.py
Database health: Quick check of table row counts and WAL file status.
diagnose_targets.py
Target accuracy: Tests if the Primary Target selector picks the correct gap.

Data MapEverything the system ingests, stores, transforms, models, and outputs

1
Sources
- External data feeds
Binance Spot Klines
Active
1H OHLCV candles for BTCUSDT. The backbone of all FVG detection, outlook scoring, and label computation.
open high low close volume timestamp
api.binance.com/api/v3/klines 5 min
Binance Futures Funding
Active
Funding rate and mark price from the perpetual contract. Feeds the funding_rate factor in the Outlook Engine.
funding_rate mark_price next_funding_time
fapi/v1/premiumIndex 5 min
Binance Open Interest
Active
Spot + historical OI data. Powers oi_divergence and oi_momentum factors - key structural indicators.
open_interest sum_open_interest_value timestamp
fapi/v1/openInterest 5 min
Taker Long/Short Ratio
Active
Taker buy/sell volume ratio. Feeds the aggressor_flow factor - the single highest-weighted factor in the Outlook Engine.
buy_sell_ratio buy_vol sell_vol
takerlongshortRatio 5 min
aggTrade WebSocket (VPIN)
Streaming
Real-time tick-by-tick trade stream from Binance Futures. Classified as buy/sell-initiated, accumulated into volume buckets for VPIN computation.
price quantity is_buyer_maker trade_time agg_trade_id
fstream.binance.com Live
ForexFactory Calendar
Active
Macro news events (high/medium impact for USD/EUR/GBP). Powers calendar alerts, daily digests, and next_event ML features.
title country impact datetime
nfs.faireconomy.media 30 min cache
2
Storage
- 16 tables across 2 databases
fvg_registry
Active
Master record of every detected gap. Tracks full lifecycle: open, partial_fill, filled, invalidated. Central table for Target + Interaction models.
gap_id gap_type top_price bottom_price gap_quality_score status fill_score reaction_score confluence_score test_count ml_quality_prob dormant_type
numerian.db Every candle
outlook_target_snapshots
Active
System state snapshot every cycle: outlook score, all factor values, target gap, ML features. The primary training data source for the Imminent Model.
observed_at outlook_score factors_json features_json state target_gap_id passed_quality_gate
numerian.db Every 5 min
outlook_move_labels
Active
Ground truth: did a large price move actually occur within H hours? Labels for training the Imminent Model.
snapshot_id horizon_hours label_large_move max_excursion_pct threshold_pct
numerian.db Every 15 min
interaction_labels
Active
What happened when price touched a gap: FILL (broke through), REACTION (bounced), INDETERMINATE, or NOISE. Training data for the Interaction Model.
gap_id touch_ts outcome max_reversal_pct max_continuation_pct
numerian.db Every 30 min
fvg_score_snapshots
Active
Per-candle score history for every gap. Captures how FRC scores evolve over a gap's lifetime. Used in interaction feature engineering.
gap_id candle_ts fill_score reaction_score features_json
numerian.db Every candle
fvg_events
Active
Granular event log: every time price creates, tests, enters, fills, or invalidates a gap. Audit trail for all gap interactions.
gap_id event_type price penetration_pct distance_pct
numerian.db Event-driven
control_centre_snapshots
Active
Daily and 4H regime state: trend direction, volatility classification, and target path planning.
daily_key regime_json plan_json
numerian.db Daily / 4H
shock_events
Active
Attribution log for large price moves. Was it news-driven, a liquidation cascade, or organic? Matches against macro calendar.
trigger_ts direction move_pct attribution_label
numerian.db Event-driven
vpin_buckets
Streaming
Volume buckets from the adaptive bucket engine. Each bucket accumulates trades until a target BTC volume is reached, then seals.
bucket_start bucket_end buy_volume sell_volume trade_count vwap
vpin_store.db ~5 min
vpin_snapshots
Streaming
Rolling VPIN values at 3 window sizes (20/50/100 buckets). Includes 7-day percentile rank and buy pressure ratio.
vpin_20 vpin_50 vpin_100 vpin_pctl_7d bucket_rate buy_pressure
vpin_store.db Every bucket
3
Feature Engineering
- Transforms raw data into ML vectors
Outlook Engine (14 Factors)
Active
Heuristic breakout scoring. Each factor scores 0-100 based on market structure. Combined into a weighted outlook score with quality gates.
Rules - ML candidate
volume_compression (11%) range_shrinkage (11%) coiling_pattern (12%) bb_squeeze (8%) price_compression (3%) oi_divergence (13%) aggressor_flow (26%) funding_rate (7%) session_time (7%) funding_time (2%) oi_momentum (new) crowding_score (new) cvd_divergence (new) volume_surge (new)
numerian.py - calculate_outlook_score() Rules-based
Imminent Feature Vector (32 dims)
Active
Structured numeric vector built from outlook snapshots. Fed to the Imminent Model for P(large move) prediction.
Feeds ML
price (current) outlook_score strong_factors count passed_quality_gate state_heating (bool) state_imminent (bool) 14x factor scores 4x gate booleans next_event_funding next_event_session hour_utc dow_utc
ml/imminent_move_features.py 32 features
Interaction Feature Vector (~35 dims)
Active
Built from FVG score snapshots. Captures gap characteristics, FRC scores, session context, and event history. Fed to Fill + Reaction models.
Feeds ML
fill_score reaction_score confluence_score gap_quality_score test_count is_bullish / is_bearish session (tok/lon/ny) volatility_regime gap_age_hours distance_pct distance_atr is_tag / is_test is_reject / is_accept is_sweep_reject 5x missing-value flags
ml/interaction_features.py ~35 features
Gap Quality Features (12 dims)
Disabled
At-detection-time features for the gap quality gate. Disabled because the gate was rejecting 99.7% of gaps (wrong target variable).
gap_size_pct gap_quality_score is_bearish displacement_body_atr displacement_close_pos atr_ratio_to_median hour_sin / hour_cos nearby_gap_count trend_momentum volume_ratio
numerian_lib/ml/gap_quality.py 12 features
FVG Detection Engine
Active
Scans candle data for 3-candle FVGs and 2-candle voids. Applies ATR capping, displacement analysis, trend-aware relaxation.
Rules - ML candidate
min $25 or 10% ATR impulse check ATR cap bullish/bearish
numerian_lib/gaps/fvg.py detect_gaps_v2()
Primary Target Selector
Active
Picks the best nearby unfilled gap using composite ranking: 45% distance + 45% quality + 10% FRC. Outputs the "WHERE will price go?" answer.
Rules - ML candidate
distance_score quality_score frc_score direction
numerian_lib/targets/primary.py Rank-based
4
ML Models
- Calibrated Logistic Regression (pure-stdlib, no sklearn)
Imminent Model H1 (Primary)
Active
Predicts P(large move within 1 hour). Drives the dashboard state badge: QUIET / HEATING / BUILDING / IMMINENT. The main decision engine.
ML-Powered
Features
32
Precision
20.7%
Threshold
0.55
L2 regularization Platt scaling 5,825 training rows
models/imminent_move_h1.json Daily 04:00
Imminent Model H6 (Early Warning)
Active
Predicts P(large move within 6 hours). Drives Discord early-warning alerts. Higher precision than H1 - catches moves well ahead of time.
ML-Powered
Features
32
Precision
60.3%
Threshold
0.431
L2 regularization Platt scaling 5,766 training rows
models/imminent_move_h6.json Daily 04:00
Imminent Model H24
Active
Predicts P(large move within 24 hours). Near-100% precision but low practical value - almost always predicts "yes" because big moves happen daily.
ML-Powered
Features
32
Precision
98.6%
Threshold
0.001
models/imminent_move_h24.json Daily 04:00
Interaction Fill Model
Active
Predicts P(gap fills within H hours). Powers the "F" chip on the dashboard. Trained on labeled gap-touch outcomes.
ML-Powered
Features
~35
Horizon
24h
Labels
FILL
models/gap_interaction_h*_fill.json Daily 03:00
Interaction Reaction Model
Active
Predicts P(gap produces a bounce). Powers the "R" chip on the dashboard. Trained on the same labeled outcomes but targeting bounce events.
ML-Powered
Features
~35
Horizon
24h
Labels
REACT
models/gap_interaction_h*_reaction.json Daily 03:00
Gap Quality Gate
Disabled
Was predicting P(gap produces reaction) at detection time. Rejected 99.7% of gaps because the target variable was wrong - 97% of gaps fill regardless. Needs retrain with reaction-quality labels.
Features
12
Avg Prob
0.15
Reject %
99.7%
models/gap_quality.json Disabled 2026-02-08
VPIN Factor (Phase 3+)
Planned
Volume-Synchronized Probability of Informed Trading. Will be added as a shadow factor in the Imminent Model feature vector once Phase 2 validation completes (after 7 days of data).
vpin_score (0-100) vpin_available vpin_fast (20-bucket) vpin_slow (100-bucket)
Phase 2 research in progress Awaiting data
5
Outputs
- What the system produces
Dashboard UI
Active
Live web interface at num.devircle.com. Shows chart with gap overlays, state badge, outlook score, FRC chips, calendar, and logs.
Chart + FVGs State badge Outlook score FRC chips Calendar
dashboard/index.html 5s refresh
Discord: Imminent (H1)
Active
Edge-triggered alert when ML primary model crosses the IMMINENT threshold. "A large move is likely within the next hour."
probability state transition target gap 1h cooldown
Discord webhook Edge-triggered
Discord: Early Warning (H6)
Active
Early warning when the 6-hour model detects elevated probability. Gives more lead time than H1 with higher precision.
probability threshold cross 1h cooldown
Discord webhook Edge-triggered
Discord: Macro Calendar
Active
Pre-event warnings (1 hour + 5 min) for high/medium impact macro news. Daily digest at 09:00 UK time.
1h warning 5min warning daily digest 09:00
Discord webhook Pre-event
Discord: Reaction Confirmed
Active
Fires when price bounces off a gap level. High-signal confirmation that the gap acted as support/resistance.
gap_id bounce_pct direction
Discord webhook Event-driven
Flask API Server (22 endpoints)
Active
HTTP API serving all dashboard data, learning status, model health, gap data, and chart candles. Runs as a separate systemd service.
/api/outlook/current /api/chart/gaps /api/learning-status /api/health /api/calendar /api/model-improvements
api_server.py (port 5000) On-demand
Labeling Pipelines (feedback loop)
Active
Automated scripts that check what actually happened after each prediction. They write the ground truth labels that ML models train on.
label_outlook_move.py (15 min) label_interaction.py (30 min) H1 / H6 / H24 horizons
numerian-labeler.timer 15-30 min
-
-