Technical White Paper · v10.37

TheOddCollective.io
Trading System

A GPU-accelerated ensemble of deep learning and gradient-boosted models for automated cryptocurrency trading via Alpaca Markets.

Published 2026·TheOddCollective.io

1. Dashboard Overview

The application uses a fixed two-panel layout: a 530-pixel sidebar on the left for controls and status, and an expanding chart panel on the right. A branded title bar spans the full width at the top.

1.1 Sidebar

The top portion of the sidebar is a signal display canvas showing the current price, market regime label (BULL · BEAR · NEUTRAL), a four-bar confidence meter for each class (BUY / SELL / HOLD_UP / HOLD_DOWN), and a live trade status indicator. Below that, three collapsible cards organize all user-configurable inputs:

ML Training Card
FieldWhat it controls
LROptimizer learning rate (default 0.000484)
SEQSequence length — bars fed per inference window
VALValidation split fraction (e.g. 0.2 = 20% held for val loss)
BARSHistorical bars to load from Alpaca (default 45,000)
REG WTRegime weight boost — amplifies loss on regime-matching bars
MIN ACCMinimum validation accuracy required before Full Auto proceeds
Backtest & Signal Params Card
FieldWhat it controls
BUY CONF / SELL CONFMinimum class confidence required to generate a signal
DELTAMinimum predicted price move required to trade
CONSECConsecutive bars that must agree before entry fires
STOP%Hard stop-loss as a percentage below entry price
EXPOMaximum fraction of capital allocated per position
BARSNumber of bars used in the backtest window
System Card
FieldWhat it controls
Auto-RetrainToggles scheduled background retraining
Retrain DaysDays between automatic retrains
Dynamic Position SizingScales position size by model confidence at entry
Bear FilterBlocks BUY signals when HTF regime is in downtrend
Bear LookbackWindow for the HTF bear/bull regime determination

The action row beneath the cards holds the primary workflow buttons: API Keys (encrypted Alpaca credentials), Opt Model (standalone model optimizer), Apply & Train (apply UI values and retrain immediately), Opt Params (execution parameter optimizer), and Backtest (run backtest with current model, no retraining). A second row provides Stop BG, Shutdown, Save Defaults, and Load Defaults.

1.2 Chart Panel

The right panel contains two stacked matplotlib charts sharing a common x-axis (bar index at the configured timeframe):

  • Price chart (top) — Candlestick or line plot of close price. Overlays include the dashed ZigZag pivot line, green valley markers (trained BUY labels), orange peak markers (trained SELL labels), green upward triangles (model BUY entries), red downward triangles (model SELL exits), and orange × markers (stop-loss exits).
  • Confidence chart (bottom) — Per-bar softmax probabilities for all four classes: BUY % (green), SELL % (red), HOLD_UP % (blue), HOLD_DOWN % (pink). A horizontal dashed line marks the active confidence threshold floor.

An Optimizer Status panel below the charts displays the current trial number, best score so far, and the parameter values of the current best trial. The chart updates live whenever a new best trial is found during Stage 2 or Stage 5 of Full Auto.

1.3 Trade History Panel

A fixed 215-pixel panel on the far right edge of the window displays the last 20 completed trades in reverse-chronological order (most recent at the top). Each row shows entry price, exit price, and P/L percentage (green for profit, red for loss). A dot indicator marks each row's source: orange for live executed trades, muted · for backtest trades. The panel populates immediately after any backtest run, so it is always filled with data even before the bot goes live. As real trades execute, they push backtest rows out from the bottom up.

Below the 20 rows, a summary strip shows:

  • 20-TRADE P/L — cumulative P/L across all 20 displayed trades
  • SOURCE — breakdown of live vs. backtest trade counts
  • LIVE PROFIT — cumulative P/L from real executed trades only (hidden until at least one live trade completes)

2. Model Input Features

The model receives a sliding window of SEQUENCE_LENGTH consecutive bars (range 48–192, default 112), each bar described by 59 engineered features. The input tensor shape is (batch, seq_len, 59). All features are standardized with a fitted StandardScaler before being passed to the network, and clipped to ±3σ to suppress outlier bars.

Price Action & Momentum (3)
FeatureDescription
price_changeBar-over-bar return of close price
momentumN-bar cumulative price change
close_zscoreZ-score of close relative to a rolling window
Trend & Regime (4)
FeatureDescription
long_term_trendDirection of the long-period moving average
long_ma_slopeRate of change of the long MA
long_ma_deviationPrice distance from the long MA, normalised
bull_probabilitySmoothed probability score that current regime is bullish
Market Structure — Swing Analysis (9)
FeatureDescription
swing_lengthBar count of the most recent swing
swing_size_atrSize of the most recent swing in ATR units
last3_swing_avgAverage size of the last three swings
hh_count / hl_countRecent higher-high and higher-low counts (bullish structure)
lh_count / ll_countRecent lower-high and lower-low counts (bearish structure)
bull_structureBinary flag: HH+HL sequence active
swing_retracementCurrent bar's retracement depth into the last swing
Oscillators (4)
FeatureDescription
rsiRelative Strength Index (14-period)
macd_histMACD histogram (signal line divergence)
stoch_kStochastic %K
mfiMoney Flow Index — volume-weighted RSI variant
Volatility & Bands / Trend Strength / Volume / VWAP (11)
FeatureDescription
atrAverage True Range — normalised volatility measure
bb_percentPrice position within Bollinger Bands (0–1)
bb_squeezeBand width as fraction of midline — detects volatility compression
adxAverage Directional Index — trend strength magnitude
adx_trendADX trend direction (+1 / −1)
obvOn-Balance Volume — cumulative volume direction
volume_ratioCurrent bar volume relative to recent average
buying_pressureFraction of volume on up-ticks
price_vwap_ratioPrice relative to VWAP — above=bullish bias
vwap_slopeRate of change of VWAP
vwap_crossoverRecent price–VWAP crossover signal
BTC Cross-Asset & Lead/Lag Features (10)
FeatureDescription
btc_price_changeBTC bar-over-bar return (same timeframe)
btc_momentumBTC N-bar momentum
btc_price_vwap_ratioBTC price relative to its VWAP
btc_vwap_slopeRate of change of BTC VWAP
btc_vwap_leadBTC VWAP deviation 1 bar ahead (lead indicator)
btc_phase_markup / btc_phase_markdownBTC 4-phase regime flags
btc_lag1 / btc_lag2 / btc_lag3BTC return lagged 1–3 bars — captures the typical 1–3 bar lead BTC has over altcoins
Multi-Timeframe Features (11)
FeatureDescription
m5_price_change5-minute bar return (finer resolution momentum)
m5_momentum5-minute N-bar momentum
m5_volatility5-minute ATR-normalised volatility
m5_rsiRSI computed on the 5-minute series
htf_trend1-hour timeframe trend direction
htf_rsi1-hour RSI
htf_momentum1-hour momentum
htf_phase_markup / htf_phase_distribution / htf_phase_markdown1-hour 4-phase market regime flags
htf_vwap_devPrice deviation from 1-hour VWAP
Time Encoding & 15-Minute Regime (7)
FeatureDescription
hour_sin / hour_cosSine and cosine encoding of hour-of-day (captures intraday seasonality)
dow_sin / dow_cosSine and cosine encoding of day-of-week
phase_markup15-minute Wyckoff markup phase flag
phase_distribution15-minute distribution phase flag
phase_markdown15-minute markdown phase flag

Abstract

This document describes the architecture, training pipeline, optimization methodology, and risk management framework of TheOddCollective.io trading system. The system employs a hybrid ensemble of a HybridTransformerBiLSTM neural network and an XGBoost gradient-boosted classifier, trained on 4-class ZigZag pivot labels derived from ATR-normalized price action. Bayesian hyperparameter optimization via Optuna TPE searches across six dimensions simultaneously. Walk-forward validation with a withheld holdout set provides out-of-sample performance estimates uncorrupted by in-sample overfitting. Live execution is handled through Alpaca Markets with Fernet-encrypted, machine-bound API key storage.

1. Model Architecture

1.1 HybridTransformerBiLSTM

The primary model is a hybrid architecture that combines the global attention mechanism of Transformer encoders with the sequential state-tracking capability of a bidirectional LSTM. The input projection maps raw features to a 320-dimensional embedding. Six Transformer blocks (each with multi-head self-attention and a feed-forward sublayer) process the full sequence in parallel. The output is then passed through a BiLSTM with hidden size 160, producing a 320-dimensional bidirectional representation. Layer normalization stabilizes gradients before the classification heads.

Architecture Summary
Input projection→ 320 dims
Transformer blocks6 layers, multi-head attention
BiLSTMhidden=160, bidirectional → 320 out
Layer Normpre-classification
FC1320 → 128 + ReLU + Dropout
Classification head (fc2)128 → 4 classes
Magnitude head (mag_head)128 → 1 (scalar)
Leg head (leg_head)128 → 2 (bull/bear logits)

1.2 XGBoost Ensemble Component

An XGBoost gradient-boosted tree classifier runs in parallel with the neural network. Both models emit class probability vectors. Their outputs are fused via a weighted average (tunable via the optimizer), and the final signal is determined by the argmax of the fused distribution. When the two models disagree significantly, the ensemble falls back to HOLD, reducing false signal frequency in ambiguous market conditions.

1.3 Regime Filter

A regime weight boost (REGIME_WEIGHT_BOOST) up-weights BUY and SELL class probabilities when a high-timeframe bullish regime is detected. This helps the model distinguish trending from ranging markets and reduces whipsaw trades during lateral price action. The regime filter is applied post-inference and does not affect the model weights.

2. ZigZag Label Engine

Training labels are derived from a ZigZag pivot detection algorithm scaled by the Average True Range (ATR). Rather than fixed percentage thresholds, the pivot size adapts to current volatility via an ATR multiplier (ATR_LABEL_MULTIPLIER). This produces labels that are meaningful across different volatility regimes.

Each bar in the training set is assigned one of four classes:

ClassLabelMeaning
0SELLBar is at or near a confirmed ZigZag peak
1HOLD_DOWNBar is in a bear leg between peak and trough
2HOLD_UPBar is in a bull leg between trough and peak
3BUYBar is at or near a confirmed ZigZag trough

Labels are computed using a forward-looking window (ZIGZAG_LABEL_WINDOW) during training. This look-ahead is appropriate for label generation only and is never applied during live inference.

3. Bayesian Hyperparameter Optimization

3.1 Model Optimizer (Stage 2)

The model optimizer uses Optuna's Tree-structured Parzen Estimator (TPE) to search the training hyperparameter space. TPE is a form of Bayesian optimization that builds probabilistic models of the parameter regions associated with high and low scores, then proposes new candidates from the high-scoring region. This is substantially more efficient than grid search across multi-dimensional spaces.

A MedianPruner monitors validation loss at each epoch. Trials that fall below the median of completed trials at the same epoch step are stopped early, saving compute time on clearly suboptimal configurations.

Model Search Space
ParameterRange
Learning rate1e-5 – 1e-3 (log scale)
ATR label multiplier0.5 – 3.0
Regime weight boost1.0 – 3.0
Predict horizon1 – 10
Sequence length48 – 192
ZigZag window (if enabled)3 – 15

3.2 Execution Parameter Optimizer (Stage 5)

After the model is trained, a second optimizer searches over execution parameters — the thresholds and filters that govern when the trained model actually triggers a trade. These are optimized via backtest score (profit factor × Sharpe ratio) rather than training loss, which more directly targets live profitability.

Execution Search Space
ParameterDescription
MIN_DELTAMinimum predicted price move required to trade
CONSECUTIVE_SIGNAL_REQUIREDHow many consecutive bars must agree before entry
LSTM_ENSEMBLE_WEIGHTNeural net weight in the fused signal
XGB_ENSEMBLE_WEIGHTXGBoost weight in the fused signal
BULL_FILTER_LOOKBACKHigh-timeframe trend filter window
ZIGZAG_ARGMAX_FLOORMinimum confidence threshold for BUY/SELL signals

4. Full Auto Pipeline

The Full Auto pipeline executes all optimization, training, and validation stages in a single unattended run. It is designed to run overnight and save the best discovered configuration as the default for paper trading.

Stage 1
Data Fetch
Pulls historical OHLCV bars from Alpaca for the configured symbol and timeframe.
Stage 2
Model Optimizer
40-trial Optuna TPE search over LR, ATR multiplier, regime weight, horizon, and sequence length.
Stage 3
Val-Accuracy Gate
Escalating retry phases (more data → lower LR → shorter horizon) until accuracy threshold is met.
Stage 4
Baseline Backtest
Out-of-sample backtest; auto-calculates execution param starting points.
Stage 5
Execution Optimizer
20-trial Optuna search over entry thresholds — scored by profit factor × Sharpe.
Stage 6
Final Backtest
Full backtest with all winning parameters applied.
Stage 7
Save Defaults
Persists all winning parameters as the application defaults.
Stage 8
Walk-Forward + Holdout
Evaluates on the withheld holdout window — data the model never saw at any prior stage.

5. Validation Methodology

A fixed holdout set — the most recent bars of the dataset — is withheld from all training, optimization, and intermediate backtesting. This holdout set is only evaluated in Stage 8, after all parameter decisions have been finalized. This prevents the common issue of inadvertent optimization on test data that occurs when backtests are repeatedly run and parameters adjusted.

Walk-forward validation slices the training history into sequential windows and evaluates model generalization across different market periods. This provides an estimate of how well the model adapts to non-stationary crypto price dynamics over time.

5.1 Trade-Level Sharpe Ratio

The Sharpe ratio is computed at the trade level — mean and standard deviation are calculated across completed round-trip returns only. Including flat-period bars in the denominator artificially suppresses standard deviation and produces misleadingly large Sharpe values when trade count is low. The trade-level approach gives a statistically honest measure of risk-adjusted return per trade, annualized by observed trade frequency. Note that Sharpe estimates remain wide with fewer than ~30 trades; a larger sample is required for the number to be statistically reliable.

5.2 Per-Trade Audit Log

Every backtest run appends a structured entry-by-entry record to the daily debug log at %APPDATA%\OddCollective\logs\debug_signal_YYYYMMDD.log. Each completed trade is logged with its entry price, exit price, exit reason (sell signal, stop loss, or trailing stop), P&L contribution, position size multiplier, and running total. A summary line records total trades, cumulative P&L, Sharpe, and capture rate — allowing independent verification of any backtest result shown in the dashboard.

6. Risk Management

The system incorporates several risk controls at both the model and execution layer:

  • Stop-loss percentage — A configurable per-trade stop-loss is applied at the execution layer. The stop level is optimized alongside execution parameters.
  • Minimum confidence threshold — Trades are only executed when the model's signal confidence exceeds a tunable floor, reducing low-conviction entries.
  • Consecutive signal confirmation — Multiple consecutive bars must agree before a position is entered, reducing false positives from single-bar noise.
  • Maximum position exposure — A hard cap on the fraction of available capital allocated to any single position.
  • Paper trading mode — All features are available in paper trading mode via Alpaca, enabling live market testing without capital at risk.

7. Risk Disclosure

Trading cryptocurrency involves substantial risk of loss and is not suitable for all investors. Past performance, backtested results, and simulated trading results do not guarantee future performance. TheOddCollective.io is a software tool and does not constitute financial advice. All trading decisions and their consequences remain the sole responsibility of the user.