← Back to OpenClaw

Neural Trading Documentation

BrainJar integration for the IG Trading Dashboard — a biologically-inspired spiking neural network for autonomous market analysis and trading.

Contents

  1. Overview
  2. Dashboard Tabs
  3. Network Architecture
  4. Training Modes
  5. Volume Antenna System
  6. Cortex Auto-Trade
  7. Mushroom Body Memory
  8. Network Sizing Guide
  9. API Reference
  10. Configuration Defaults

Overview

Neural Trading uses a Leaky Integrate-and-Fire (LIF) spiking neural network inspired by the Drosophila (fruit fly) connectome. Unlike traditional neural networks that use backpropagation, this brain works through biological spiking dynamics:

The brain engine runs as an internal Node.js server (skills/bots/brain-engine-server.cjs), auto-spawned by the bot manager, communicating via /api/brain/* proxy routes.

Dashboard Tabs

The Neural Trading interface has four sub-tabs accessible from the IG Dashboard:

1. Neural Dashboard

The main overview — instrument selector, live tick feed, connection status, price/volume charts, and manual trade triggers (Force Buy/Sell).

Neural Dashboard showing live tick feed, price chart, and connection status

2. Brain Tab (Neural Cortex)

The cortex auto-trade view — per-instrument pattern cards with maturity tracking, signal summary table, auto-trade execution panel with cortex controls, trade log, training controls, and auto-calibration.

Brain tab showing Neural Cortex with instrument cards, auto-trade controls, and training

3. Brain Config

Full network configuration — dynamic architecture with configurable neuron counts, timeframe presets, sensory assignments, mushroom body settings, motor region layout, timeframe budget calculator, and neural backtest training.

Brain Config tab showing network architecture, sensory assignments, mushroom body, and training

4. Dev Console

Real-time brain activity logs for debugging and monitoring brain engine internals.

Network Architecture

The network consists of three layers of neurons with configurable sizes:

LayerRoleDefault (1s)Configurable
SensoryInput — receives market data stimuli600 neuronsYes
InterneuronsProcessing — pattern recognition core3600 neuronsYes
MotorOutput — buy/sell/hold decisions800 neuronsYes

Sensory Neuron Groups

GroupDefault %Purpose
Price Up20%Fires stronger when price increases
Price Down20%Fires stronger when price decreases
Volume20%Encodes trade volume intensity
Spread20%Encodes bid-ask spread width (liquidity)
Momentum10%Fires on price acceleration / rapid moves
Antenna10%Pressure sensing — flash crashes, volume spikes, rapid directional moves

Motor Region

Motor neurons are split into three equal populations. The population with the highest average firing rate over the last 10 steps determines the brain's output signal:

Timeframe Presets

PresetNeuronsSynapsesUse Case
1s Scalp350~5,000Ultra-fast scalping
5s Quick700~15,000Quick scalping
30s Med1,500~45,000Medium-speed trading
1min Full5,000~148,000Standard operation
5min Deep10,000~400,000Deep analysis
15min Ultra20,000~1,200,000Maximum pattern depth

Training Modes

The brain supports multiple training approaches, all integrated with the Volume Antenna system:

Backtest Training

Feed historical candles through the brain. Automatic sugar/pain feedback based on P&L outcomes. Configurable stop-loss, take-profit, min hold candles, signal threshold, and confirmation candles.

Live Training

Train on live market data candle-by-candle. The frontend computes real antenna pressure from the tick accumulator and sends it with each candle. Brain returns signals with antenna alerts.

Auto-Test

Multi-cycle autonomous backtest training with calibration. Runs multiple passes over historical data, adjusting parameters between cycles for optimal performance.

Proof Test

Quick validation — stimulates the brain with a small dataset and reports buy/sell accuracy without modifying weights.

Training Parameters

ParameterDefaultDescription
Min Hold (candles)5Minimum candles to hold a position before evaluating exit
Signal Threshold10Motor rate difference required to generate a buy/sell signal
Confirm (candles)3Consecutive same-direction candles before entering a trade
Stop Loss %1.0Maximum loss before forced exit
Take Profit %2.0Target profit for position exit
P&L Multiplier1Scales sugar/pain feedback intensity

Volume Antenna System

The Volume Antenna is a market pressure sensing system with 180 antenna neurons organized into 7 sub-groups. It detects anomalous market conditions and feeds pressure data into the brain's spiking network.

Volume Antenna panel with pressure gauges and cortex decision monitor

Antenna Sub-Groups (180 neurons total)

Sub-GroupNeuronsWhat it Detects
Tick Velocity26Speed of incoming price ticks
Volume Acceleration26Rate of change in volume
Buy/Sell Pressure26Directional bias from order flow
Absorption26Large orders absorbing opposing flow
Flash Crash26Sudden price drops with volume spikes
Dead Cat Bounce26Temporary recovery after sharp decline
Divergence24Price/volume divergence patterns

Pressure Data Fields

{
  tickVelocity,       // ticks per second
  volumeAccel,        // volume acceleration %
  buySellRatio,       // 0=all sell, 1=all buy
  absorptionScore,    // 0-1 absorption detection
  flashCrashScore,    // 0-5+ flash crash severity
  deadCatScore,       // 0-1 dead cat bounce probability
  fallingKnifeScore,  // 0-1 falling knife detection
  divergenceScore,    // 0-1 price/volume divergence
  priceVelocity,      // price change rate
  priceDelta          // raw price delta
}

Antenna-Cortex Integration

Cortex Auto-Trade

The Cortex is the autonomous trading execution layer that reads brain signals and manages positions on the IG platform.

Cortex Parameters

ParameterDefaultDescription
Hold Zone2Signal spread threshold — signals within this range are treated as HOLD
Min Hold (ticks)5Minimum ticks to hold a position before considering exit
Signal Confirm3Consecutive ticks with same signal before entering a trade
Exit Confirm2Consecutive opposing ticks before closing a position
Buy/Sell Threshold5Minimum motor rate to trigger a signal
Stop Loss (pips)50Maximum loss per trade
Take Profit (pips)100Target profit per trade

Mushroom Body Memory

The Mushroom Body is a densely-connected sub-cluster within the interneuron layer, inspired by the insect brain structure responsible for associative learning and memory consolidation.

Network Sizing Guide

The key constraint is timeframe budget — each candle timeframe gives you a processing window. Larger networks provide deeper pattern recognition but require more time per step.

Use the Timeframe Budget Calculator in the Brain Config tab to see exactly how many simulation steps you can run per candle at your current network size. The calculator shows feasibility for each timeframe.

Critical Parameter

The synaptic weight w_syn must be 12.0 for motor neurons to spike. This is the default and should not be changed unless you understand the LIF dynamics.

API Reference

All brain endpoints are proxied through /api/brain/* on the CEO proxy (port 5000). The brain engine port is stored in ~/.openclaw/brain-engine-port.

EndpointMethodDescription
/api/brain/statusGETBrain engine status, architecture info
/api/brain/stimulate-pricePOSTFeed a price tick with optional pressure data
/api/brain/backtest-trainPOSTBacktest training with historical candles
/api/brain/live-trainPOSTLive training with single candle + pressure
/api/brain/configurePOSTUpdate network architecture (neuron counts)
/api/brain/test-firePOSTBenchmark — measure processing time per step
/api/brain/sugarPOSTPositive reward feedback
/api/brain/painPOSTNegative punishment feedback
/api/brain/save-statePOSTSave brain state to disk
/api/brain/load-statePOSTLoad brain state from disk
/api/brain/resetPOSTReset brain (clear all weights)
/api/brain/cortex-statusGETCortex pattern memory for all instruments

stimulate-price Request

POST /api/brain/stimulate-price
{
  "epic": "CS.D.CFASILVER.CFA.IP",
  "price": 5185.0,
  "prevPrice": 5180.0,
  "volume": 800,
  "spread": 4.2,
  "pressure": {
    "tickVelocity": 2.5,
    "volumeAccel": 0.8,
    "buySellRatio": 0.65,
    "absorptionScore": 0.5,
    "flashCrashScore": 0.3,
    "deadCatScore": 0,
    "fallingKnifeScore": 0,
    "divergenceScore": 0
  }
}

backtest-train Request

POST /api/brain/backtest-train
{
  "epic": "CS.D.CFASILVER.CFA.IP",
  "candles": [...],
  "stopLossPct": 1.0,
  "takeProfitPct": 2.0,
  "minHoldCandles": 5,
  "signalThreshold": 10,
  "confirmCandles": 3,
  "antennaEnabled": true
}

Configuration Defaults

Brain State File

Pattern memory and brain weights persist at ~/.openclaw/brain-state.json. This file is loaded on boot and saved on demand or automatically after training sessions.

Key Defaults Summary

CategoryParameterValue
NetworkDefault neurons5,000 (S:600 I:3600 M:800)
Networkw_syn12.0
NetworkPoisson rate150 Hz
CortexHold Zone2
CortexMin Hold5 ticks
CortexSignal Confirm3
CortexExit Confirm2
AntennaFlash Threshold3.0
AntennaDead Cat Sensitivity0.5
TrainingMin Hold Candles5
TrainingSignal Threshold10
TrainingConfirm Candles3

OpenClaw Mechanicus — Neural Trading Documentation. Generated 2026-03-12.