Skip to content

Configuration Reference

The bot is configured via a YAML file. By default, it looks for ./config.example.yaml, but you can override this with the BOT_CONFIG environment variable.

Several preset configuration files are available in the configs/ directory for different risk profiles:

  • configs/conservative.yaml: Low risk, quarter-Kelly sizing, tight limits.
  • configs/aggressive.yaml: Higher risk, half-Kelly sizing, more aggressive thresholds.
  • configs/paper-testing.yaml: Relaxed settings optimized for development and testing.
mode: paper | replay | live
ipc:
host: "127.0.0.1" # IPC server bind address
port: 9876 # IPC server port (1-65535)
persistence:
outDir: "./out" # Output directory for sessions
snapshotIntervalMs: 1000 # State snapshot interval (min: 100)
risk:
staleness:
polymarketWsMs: 5000 # Max age for Polymarket data
binanceWsMs: 2000 # Max age for Binance data
chainlinkMs: 60000 # Max age for Chainlink data
reconciliation:
enabled: true # Enable position reconciliation
intervalMs: 60000 # Reconciliation interval (min: 1000)
limits:
maxDrawdownPercent: 10 # Max drawdown before kill (0-100)
maxPositionSizeUSDC: 1000 # Max single position size
maxTotalExposureUSDC: 5000 # Max total exposure across all positions
maxDailyLossUSDC: 500 # Max loss in a single UTC day
maxDailyLossPercent: 5 # Max % loss in a single UTC day
maxActiveMarkets: 3 # Max concurrent markets
maxOrdersPerMinute: 60 # Rate limit for orders
priceBanding:
minPrice: 0.02 # Min allowed price
maxPrice: 0.98 # Max allowed price
maxDeviationFromMid: 0.10 # Max deviation from mid
slippageProtection:
minLiquidityUSDC: 50 # Min liquidity at target price
maxSlippagePercent: 0.05 # Max slippage (5%)
simulation:
initialBalanceUSDC: 10000 # Initial balance for paper trading
feeModel:
maker: 0.0 # Maker fee (0 = 0%)
taker: 0.001 # Taker fee (0.001 = 0.1%)
latencyMs: 50 # Simulated execution latency
fillProbability: 0.95 # Probability of fill (0-1)
partialFillEnabled: true # Enable liquidity-aware fills
liquidityDepthUSDC: 1000 # Simulated liquidity per price level
slippagePerSize: 0.001 # Slippage per unit (0.001 = 0.1%)
markets:
coins: # Coins to trade
- Bitcoin
- Ethereum
durations: # Market durations to consider
- 5m
- 15m
maxMarkets: 5 # Max markets to trade simultaneously
scoring: # Market scoring parameters
minVolume24hr: 100 # Min 24h volume filter
minLiquidity: 100 # Min liquidity filter
maxSpread: 0.15 # Max bid-ask spread filter
maxStrikeDistancePercent: 0.15 # Max strike distance from spot
strikeProximityWeight: 0.35 # Weight for strike proximity
volumeWeight: 0.25 # Weight for volume
liquidityWeight: 0.20 # Weight for liquidity
spreadWeight: 0.10 # Weight for spread
edgeWeight: 0.10 # Weight for edge potential
strategies:
enabled: # Strategies to run
- latency_arb
latency_arb:
edgeThreshold: 0.02 # Min edge to trade (0-1)
maxPositionSize: 10 # Max contracts per position
cooldownMs: 5000 # Cooldown between trades
volatilityWindowMs: 300000 # Window for volatility calc
minVolatility: 0.1 # Min volatility to trade
takerFeeBps: 100 # Taker fee in basis points
assetMapping: # Map slug patterns to assets
bitcoin: BTC
ethereum: ETH
solana: SOL
kelly: # Kelly criterion position sizing
enabled: false
fraction: 0.25 # Quarter Kelly (less aggressive)
minSize: 1
maxSize: 100
bankroll: 10000
dip_arb:
slidingWindowMs: 60000 # Window for dip detection
dipThreshold: 0.05 # Min dip size
sumTarget: 1.0 # Target sum of YES+NO prices
leg2TimeoutSeconds: 30 # Timeout for second leg
minProfitRate: 0.01 # Min profit rate
splitOrders: false # Split orders across books
autoMerge: false # Auto-merge positions
threshold_farm:
sumTarget: 1.0 # Target YES+NO sum
minProfitRate: 0.005 # Min profit rate (-1 to 1)
replay:
input: "./out/record_xxx/events.jsonl" # Replay input file
alerting:
webhookUrl: "https://hooks.slack.com/..." # Webhook URL
events: # Events to alert on
- kill_switch
- risk_trip
- error
throttleMs: 60000 # Throttle per event type (ms)
priceFeed:
mode: single # single | consolidated
throttleMs: 0 # Throttle for consolidated mode (0 = disabled)
aggregationMethod: median # median | mean | first
exchanges:
binance:
enabled: true
coinbase:
enabled: false
telemetry:
enabled: false
host: "127.0.0.1"
port: 8094
protocol: udp
database: "hydra"
batchSize: 100
flushIntervalMs: 1000
globalTags:
env: production
ntp:
enabled: false
syncIntervalMs: 60000
maxOffsetWarningMs: 100
maxOffsetKillMs: 500

ValueDescription
paperSimulated trading with live data
replayReplay recorded sessions
liveReal trading (coming soon)

IPC server for TUI and remote control.

FieldTypeDefaultDescription
hoststring127.0.0.1Bind address
portnumber-Port number (1-65535)

Session persistence settings.

FieldTypeDefaultDescription
outDirstring-Output directory path
snapshotIntervalMsnumber1000Snapshot interval in ms (min: 100)

Risk management configuration.

Maximum data age before considering it stale.

FieldTypeDescription
polymarketWsMsnumberMax Polymarket data age
binanceWsMsnumberMax Binance data age
chainlinkMsnumberMax Chainlink data age

Position reconciliation with exchange.

FieldTypeDefaultDescription
enabledbooleantrueEnable reconciliation
intervalMsnumber60000Check interval (min: 1000)
positionTolerancePercentnumber0.01Allowed position mismatch tolerance (1% default). Mismatches within this threshold are logged as warnings rather than triggering the kill switch.

Trading limits and circuit breakers.

FieldTypeDescription
maxDrawdownPercentnumberMax drawdown before kill (0-100)
maxPositionSizeUSDCnumberMax single position size
maxTotalExposureUSDCnumberMax total exposure across all positions
maxDailyLossUSDCnumberMax loss in a single UTC day (USDC)
maxDailyLossPercentnumberMax loss in a single UTC day (%)
maxOrdersPerMinutenumberOrder rate limit
maxActiveMarketsnumberMax concurrent markets with active positions

Price sanity checks to reject extreme orders.

FieldTypeDescription
minPricenumberMinimum allowed price (e.g., 0.02)
maxPricenumberMaximum allowed price (e.g., 0.98)
maxDeviationFromMidnumberMax deviation from mid price (e.g., 0.10 = 10%)

Liquidity checks before execution.

FieldTypeDescription
minLiquidityUSDCnumberMin available liquidity at target price
maxSlippagePercentnumberMax acceptable slippage (0.05 = 5%)

Remote webhook alerts for critical events.

FieldTypeDefaultDescription
webhookUrlstring-Webhook URL (Slack, Discord, etc.)
eventsstring[]["kill_switch", "risk_trip", "error"]Events to alert on
throttleMsnumber60000Throttle alerts per event type (ms)

Available events:

  • kill_switch - Kill switch triggered
  • risk_trip - Risk breaker tripped
  • order_placed - Order placed
  • order_filled - Order filled
  • error - Error occurred
  • session_start - Bot started
  • session_stop - Bot stopped

Reference price sourcing configuration.

FieldTypeDefaultDescription
modestringsinglePrice feed mode: single (Binance only) or consolidated (multi-exchange)
throttleMsnumber0Throttle consolidated price updates (ms). Default is 0 for minimum latency.
aggregationMethodstringmedianAggregation: median, mean, or first

The Binance feed includes built-in safety mechanisms that are active by default:

  • Sequence Gap Detection: Monitors Binance updateId for missing messages.
    • Warning: Triggered at a gap of 100 messages.
    • Kill Switch: Triggered at a gap of 500 messages to prevent trading on corrupt order book state.
  • Heartbeat: Maintains connection health during quiet market periods.
  • Backpressure Handling: Monitors message queue depth during high volatility.
    • Warning: Triggered when queue exceeds 100 messages.
    • Kill Switch: Triggered when queue exceeds 1000 messages to prevent memory exhaustion and stale data.

For advanced users, additional Binance WebSocket options are available:

FieldTypeDefaultDescription
fastParsebooleanfalseUse regex-based parser instead of JSON.parse (~58% faster, less robust)
backpressure.enabledbooleantrueEnable queue depth monitoring
backpressure.warnThresholdnumber100Queue depth that triggers warning
backpressure.killThresholdnumber1000Queue depth that triggers kill switch

Note: fastParse is opt-in because while faster, it only handles the expected bookTicker format and may silently skip malformed messages. Only enable if latency is critical.

Exchange-specific settings for consolidated mode.

FieldTypeDefaultDescription
binance.enabledbooleantrueEnable Binance price feed
coinbase.enabledbooleanfalseEnable Coinbase price feed

Streaming metrics to InfluxDB via Telegraf using line protocol.

FieldTypeDefaultDescription
enabledbooleanfalseEnable telemetry
hoststring127.0.0.1Telegraf/InfluxDB host
portnumber8094Telegraf/InfluxDB port (8094 for UDP, 8086 for HTTP)
protocolstringudpudp or http
databasestringhydraInfluxDB database name
prefixstringhydraMeasurement prefix
batchSizenumber100Batch size before flushing
flushIntervalMsnumber100Flush interval in ms (min: 10)
globalTagsrecord-Global tags for all metrics

Hydra is designed for high-frequency trading where every microsecond counts. To maintain this performance, the telemetry system uses several specialized features:

  • Push-based Architecture: Unlike Prometheus which “pulls” metrics (causing CPU spikes and jitter), Hydra “pushes” metrics to Telegraf/InfluxDB. This ensures that metric collection never interrupts critical trading logic.
  • High-Resolution Timestamps: Uses performance.now() for sub-millisecond precision instead of the standard 1ms Date.now().
  • Tick-to-Trade Latency: Tracks the time from the exchange’s timestamp (exchangeTsMs) to the bot’s arrival time (arrivalTsMs) and finally to the order send time (sendTsMs).
  • Event Loop Monitoring: Detects when the JavaScript event loop is blocked for more than 10ms, which could delay order execution.

Clock synchronization via HTTP Date headers to ensure millisecond-level accuracy.

FieldTypeDefaultDescription
enabledbooleanfalseEnable NTP sync
serversstring[]See belowList of HTTP time servers
syncIntervalMsnumber60000Interval between syncs
timeoutMsnumber3000Request timeout
maxOffsetWarningMsnumber100Offset to trigger warning
maxOffsetKillMsnumber500Offset to trigger kill switch
samplesPerSyncnumber3Number of servers to sample per sync

Default servers:

  • https://time.cloudflare.com
  • https://www.google.com
  • https://www.microsoft.com

Paper trading simulation parameters.

FieldTypeDefaultDescription
makernumber-Maker fee rate (0.001 = 0.1%)
takernumber-Taker fee rate
FieldTypeDefaultDescription
initialBalanceUSDCnumber10000Initial USDC balance for simulation
latencyMsnumber0Simulated execution latency
fillProbabilitynumber1Fill probability (0-1)
partialFillEnabledbooleanfalseEnable liquidity-aware partial fills
liquidityDepthUSDCnumber1000Simulated liquidity at each price level
slippagePerSizenumber0.001Price impact per unit size (0.1% default)

Market selection and scoring.

FieldTypeDefaultDescription
discoveryModestringseriesDiscovery mode: series or legacy
coinsstring[]["Bitcoin", "Ethereum"]Coins to trade (filters discovered markets)
durationsstring[]["5m", "15m"]Market durations
maxMarketsnumber5Max concurrent markets

Configuration for series-based discovery.

FieldTypeDefaultDescription
categorystringcrypto-updownCategory of markets to discover
timeWindowsstring[]["15m", "hourly", "daily"]Time windows to target, in priority order

Market scoring parameters for smart discovery.

FieldTypeDefaultDescription
minVolume24hrnumber100Min 24h volume filter
minLiquiditynumber100Min liquidity filter
maxSpreadnumber0.15Max spread filter
maxStrikeDistancePercentnumber0.15Max strike distance
strikeProximityWeightnumber0.35Strike proximity weight
volumeWeightnumber0.25Volume weight
liquidityWeightnumber0.20Liquidity weight
spreadWeightnumber0.10Spread weight
edgeWeightnumber0.10Edge weight

Note: Weights should sum to 1.0 for normalized scoring.


Strategy configuration.

Array of strategy names to run. Options:

  • latency_arb - Latency arbitrage
  • dip_arb - Dip arbitrage
  • threshold_farm - Threshold farming
  • always_buy - Always buy (testing only)
FieldTypeDefaultDescription
edgeThresholdnumber0.02Min edge to trade (0-1)
maxPositionSizenumber10Max contracts
cooldownMsnumber5000Trade cooldown
volatilityWindowMsnumber300000Volatility window
minVolatilitynumber0.1Min volatility
takerFeeBpsnumber100Taker fee in basis points
closeoutBufferMsnumber60000Time before expiry to stop entering new trades
modelUncertaintyEnabledbooleantrueAdd dynamic buffer to edge threshold
assetMappingrecordSee belowMaps slug patterns to assets

Exit logic configuration.

FieldTypeDefaultDescription
reverseEdgeThresholdnumber0.01Exit when edge reverses beyond this (1%)
minEdgeToHoldnumber0.005Exit when edge decays below this (0.5%)
flattenOnCloseoutbooleantrueForce flatten positions in closeout buffer
exitCooldownMsnumber2000Cooldown between exit attempts

Allows adding support for new assets without code changes.

assetMapping:
bitcoin: BTC
btc: BTC
ethereum: ETH
eth: ETH
solana: SOL
sol: SOL
dogecoin: DOGE
doge: DOGE

Kelly criterion position sizing for optimal bet sizing based on edge.

FieldTypeDefaultDescription
enabledbooleanfalseEnable Kelly sizing
fractionnumber0.25Kelly fraction (0.25 = quarter Kelly)
minSizenumber1Minimum position size
maxSizenumber100Maximum position size
bankrollnumber10000Bankroll for Kelly calculation
uncertaintyDiscountnumber1.0Reduce size by this factor (0-1) to account for edge estimation uncertainty
correlatedPositionsnumber1Number of correlated positions; size reduced by 1/sqrt(N)

Note: Full Kelly (fraction=1.0) is mathematically optimal but very aggressive. Quarter Kelly (0.25) is recommended for real trading to reduce variance.

Uncertainty adjustments:

  • uncertaintyDiscount: 0.7 means “I’m 70% confident in my edge estimate”, so size = 70% of Kelly size
  • correlatedPositions: 4 with 4 BTC markets means each gets 50% size (1/sqrt(4)) to account for correlated outcomes
FieldTypeDefaultDescription
slidingWindowMsnumber-Dip detection window
dipThresholdnumber-Min dip size
sumTargetnumber-Target YES+NO sum
leg2TimeoutSecondsnumber-Second leg timeout
minProfitRatenumber-Min profit rate
splitOrdersbooleanfalseSplit orders
autoMergebooleanfalseAuto-merge positions
FieldTypeDefaultDescription
sumTargetnumber-Target YES+NO sum
minProfitRatenumber-Min profit rate (-1 to 1)

Replay mode configuration.

FieldTypeDescription
inputstringPath to events.jsonl file

mode: paper
ipc:
host: "127.0.0.1"
port: 9876
persistence:
outDir: "./out"
snapshotIntervalMs: 1000
risk:
staleness:
polymarketWsMs: 3000
binanceWsMs: 1000
chainlinkMs: 30000
limits:
maxDrawdownPercent: 5
maxPositionSizeUSDC: 100
maxOrdersPerMinute: 10
simulation:
initialBalanceUSDC: 5000
feeModel:
maker: 0.0
taker: 0.002
latencyMs: 100
fillProbability: 0.9
markets:
coins:
- Bitcoin
maxMarkets: 2
scoring:
minVolume24hr: 500
maxSpread: 0.10
strategies:
enabled:
- latency_arb
latency_arb:
edgeThreshold: 0.03
maxPositionSize: 5
cooldownMs: 10000
mode: paper
ipc:
host: "127.0.0.1"
port: 9876
persistence:
outDir: "./out"
risk:
staleness:
polymarketWsMs: 5000
binanceWsMs: 2000
chainlinkMs: 60000
simulation:
initialBalanceUSDC: 50000
feeModel:
maker: 0.0
taker: 0.001
latencyMs: 25
fillProbability: 1.0
markets:
coins:
- Bitcoin
- Ethereum
- Solana
durations:
- 5m
- 15m
- 1h
maxMarkets: 10
scoring:
minVolume24hr: 50
maxSpread: 0.20
maxStrikeDistancePercent: 0.20
strategies:
enabled:
- latency_arb
latency_arb:
edgeThreshold: 0.015
maxPositionSize: 20
cooldownMs: 2000
minVolatility: 0.05