Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alphaleaks60-maker/docs2/llms.txt

Use this file to discover all available pages before exploring further.

The live trader (src/live/live-trader.ts) is a standalone process that subscribes to the trade:signals Redis channel, scores incoming signals using ONNX models loaded directly into its own runtime, and executes buys and sells on the Pump.fun bonding curve via Jito bundles. It runs alongside the main pipeline — not as part of it — which means it can be restarted, upgraded, or paused independently without affecting data collection or intelligence processing.
When LIVE_DRY_RUN is not set to true, the live trader submits real transactions to Solana mainnet and spends real SOL. Always validate new strategies and model versions in dry run mode before deploying capital.

How it works

The following diagram shows the full execution flow from signal arrival to position exit:
Redis: trade:signals (PubSub)

         ├── type: signal        → InlineScorer → strategy selection → buy
         ├── type: genesis_signal → InlineScorer → strategy selection → buy
         └── type: anti_signal   → force-exit any open position in that token


         PortfolioManager
         (phase check, concurrent position limit, circuit breakers, sizing)


         TradeExecutor
         (Pump.fun bonding curve math, Jito bundle construction)


         ExitMonitor (3s poll)
         (take-profit, stop-loss, timeout, anti-signal force exit)

Strategies

Phase-gated strategies, position sizing, and signal priority.

Circuit breakers

Hard stops for drawdown, consecutive losses, and minimum balance.

Monitoring

PostgreSQL tables, pipeline stats, and key log patterns.

Architecture

How the live trader fits into the full pipeline.

Inline scoring

Rather than waiting for the main pipeline’s MlInference service to score a signal and write it back to the database, the live trader runs ONNX inference inline — loading the same models and assembling the same feature vector independently. This eliminates the 5-second lag between signal emission and ML score availability. The signal payload published on Redis includes all the fields needed to build the feature vector, so no database round-trip is required for scoring. A decision is made within milliseconds of the signal arriving.
The same ONNX model files used by the pipeline’s MlInference service are loaded by the live trader. Hot-reloading every 5 minutes keeps both in sync when a new model is deployed.

Strategy selection

When a signal arrives, the trader evaluates all strategies that are eligible given the current phase and portfolio state. Six conditions are checked in order before a position is opened:
1

ML score threshold

The model’s calibrated probability must meet or exceed the strategy’s score_threshold (typically 80% for standard strategies, 90% for genesis strategies).
2

Dead probability veto

The dead_prob output must be below the strategy’s dead_threshold. Strategies with no dead threshold skip this check.
3

Phase eligibility

The current portfolio phase (determined by available balance) must be greater than or equal to the strategy’s min_phase.
4

Concurrent position slot

The number of currently open positions must be below the phase’s maximum concurrent position limit.
5

No existing position

No position may already be open in the same token mint.
6

Per-token cooldown

The token must not be in the 30-minute cooldown window that follows any closed position on that token.
If multiple strategies qualify, the one with the highest priority value in the strategy configuration is selected. Only one position is opened per signal event.

Execution

The TradeExecutor handles all on-chain execution and follows four steps for every buy:
1

Derive bonding curve account

The bonding curve program-derived address is computed from the token mint using the Pump.fun program address. No RPC lookup is required.
2

Calculate expected output

The exact expected token output is calculated from bonding curve math before the transaction is built, avoiding slippage surprises at submission time.
3

Construct transaction

A transaction is constructed with a compute unit price (priority fee) and a Jito tip instruction added to the tip account.
4

Submit as Jito bundle

The transaction is wrapped in a Jito bundle and submitted to the Jito tip endpoint. The Jito tip is fixed at 0.0001 SOL per transaction — two transactions per trade round-trip (one buy, one sell).

Why Jito bundles

Submitting as a Jito bundle provides two concrete advantages over standard transaction submission:
  • Atomicity — the buy either lands exactly as constructed or not at all. There is no partial execution or unexpected state.
  • Priority during congestion — validators running the Jito client service the bundle ahead of non-tipped transactions, reducing the chance of expiry during high-traffic periods on Pump.fun.

Exit monitoring

An exit monitor polls every 3 seconds for each open position, checking real-time price data from the token:<mint> Redis key maintained by the main pipeline’s CurveManager. Four exit conditions are evaluated in order:
ConditionTriggerLog reason
Take profitCurrent price ≥ entry price × take profit multipletake_profit
Trailing stopPrice has dropped more than 15% from its peak multipletrailing_stop
Stop lossCurrent price ≤ entry price × stop loss multiplestop_loss
TimeoutHold time has exceeded the strategy’s max_hold_minutestimeout
If an anti_signal arrives for a token with an open position, the position is force-exited immediately — the anti-signal response takes priority over all other exit logic regardless of current price, profit, or hold time.

Dry run mode

Set LIVE_DRY_RUN=true to run the trader in simulation mode. Every decision — score evaluation, strategy selection, position sizing, exit logic — executes exactly as in live mode, but no transactions are submitted to Solana.
Always run in dry run mode first when deploying a new model version or strategy configuration. All decisions are logged with full detail, giving you a complete view of what would have been traded.
LIVE_DRY_RUN=true npx ts-node src/live/live-trader.ts

Persistence and recovery

Every trade is fully persisted to PostgreSQL in the live_trades table before any transaction is submitted, and updated on exit. On restart, the trader loads all open positions from the database and immediately resumes monitoring them. No positions are lost across restarts. The live_portfolio table is the single source of truth for performance reporting:
TablePurpose
live_tradesOne row per trade: entry price, exit price, strategy, exit reason, net P&L
live_portfolioRunning portfolio state: balance, total P&L, win count, loss count, streak
The circuit breaker halted flag and cooldownUntil timestamp are in-memory only and reset on process restart. This is intentional — a restart is a deliberate action that acknowledges the halt condition.

Build docs developers (and LLMs) love