Skip to content

Live Trading

Live trading mode enables the Hydra to execute real transactions using your funds. This mode should only be used after extensive testing in paper mode.

Before enabling live trading, ensure you have the following:

  1. Ethereum Wallet: A dedicated trading wallet. Do not use your primary personal wallet.
  2. Private Key: The Ethereum private key for your trading wallet.
  3. Funds on Polygon:
    • USDC: Your trading capital must be in the Polygon USDC contract (the version used by Polymarket).
    • MATIC: A small amount of MATIC is required to cover transaction fees (gas) on the Polygon network.
  4. Polymarket Account: Ensure your wallet is registered and has the necessary approvals to trade on Polymarket.

To enable live trading, set the execution mode to live in your config.yaml:

mode: live

For security, the bot does not store private keys in configuration files. You must provide credentials via environment variables.

If you created your Polymarket account via MetaMask or another browser wallet:

Terminal window
export POLYMARKET_PRIVATE_KEY="your_private_key_here"
hydra run --mode live

If you created your Polymarket account via email/Magic login, you need additional configuration. Polymarket uses a proxy wallet architecture where:

  • Your EOA (Externally Owned Account) is the wallet derived from Magic
  • Your Proxy Wallet is a smart contract wallet that holds your funds
Terminal window
# Export private key from: https://reveal.magic.link/polymarket
export POLYMARKET_PRIVATE_KEY="0x..."
# Your Polymarket profile address (NOT the EOA address)
export POLYMARKET_PROXY_ADDRESS="0x..."
hydra run --mode live

The bot includes several built-in safety mechanisms to protect your capital. Risk management operates on two levels: continuous monitoring and pre-trade validation.

Before any order is submitted to the exchange, the execution layer performs real-time validation:

  1. Risk Mode Check: Orders are blocked if the risk mode is not active (i.e., if the kill switch has been triggered or trading is paused).
  2. Position Limit Check: The system calculates whether the proposed trade would breach the maxPositionSizeUSDC limit for that specific market.
  3. Exposure Limit Check: The system calculates whether the proposed trade would breach the maxTotalExposureUSDC limit across all positions.

If any check fails, the order is rejected before it reaches the exchange.

Configure hard limits in the risk.limits section of your configuration file:

ParameterDescription
maxDrawdownPercentThe maximum allowed percentage loss from the peak equity. If breached, the kill switch is triggered.
maxPositionSizeUSDCThe maximum dollar value (in USDC) allowed for any single position. Enforced both reactively and preventively.
maxTotalExposureUSDCThe maximum total exposure across all positions. Enforced both reactively and preventively.
maxOrdersPerMinuteLimits the rate of order placement to prevent runaway execution or API rate limiting.

Example configuration:

risk:
limits:
maxDrawdownPercent: 10
maxPositionSizeUSDC: 500
maxTotalExposureUSDC: 2500
maxOrdersPerMinute: 30

The reconciliation feature periodically synchronizes the bot’s local state with the actual state on the Polymarket exchange. This ensures that the bot is always trading based on accurate balance and position information.

  • Sync Interval: Configured via risk.reconciliation.intervalMs (default is 60000ms).
  • Mismatch Protection: If a discrepancy is detected between local state and the exchange (e.g., unknown orders or missing positions), the bot will trigger the kill switch as a safety measure.
risk:
reconciliation:
enabled: true
intervalMs: 60000

The kill switch is a terminal state that halts all trading activity. Once triggered, the bot:

  1. Sets the risk mode to killed, blocking all new orders
  2. Cancels all open orders on the exchange
  3. Neutralizes all positions by selling any held tokens (UP/DOWN)
  4. Logs detailed warnings for investigation

The kill switch is triggered automatically if:

  • Any risk limit is breached (drawdown, position size, or exposure)
  • A reconciliation mismatch is detected
  • Data feeds become excessively stale

After a kill switch event, the bot will not resume trading until manually restarted.

You can manually trigger the kill switch at any time through the Terminal User Interface (TUI).

  1. Open the TUI.
  2. Ensure the interface is “Armed” (if arming is enabled).
  3. Select the Kill command to immediately halt the bot.

You can monitor your live trading performance through three primary channels:

  1. Terminal UI (TUI): Real-time dashboard showing current positions, P&L, and recent events.
  2. Trade Ledger: Durable, append-only history of every trade execution.
  3. Telemetry: High-resolution metrics streamed to InfluxDB/Grafana.

The Trade Ledger is the authoritative source for your trading history. It records every fill event with precise execution details.

To view your live trading history:

Terminal window
hydra trades --mode live

To view a summary of your live performance:

Terminal window
hydra trades --mode live --summary

See the Trade Ledger guide for more information.

In live trading mode, the bot maintains a heartbeat connection with the Polymarket API. This acts as a “dead man’s switch” - if the bot stops sending heartbeats (due to crash, network failure, or other issues), the exchange will automatically cancel all open orders.

  1. The RealExecution layer initializes a HeartbeatManager when starting
  2. The manager sends periodic heartbeat signals to Polymarket at a configurable interval
  3. If the bot crashes or loses connectivity, heartbeats stop
  4. The exchange detects the missing heartbeats and cancels all open orders
  5. This prevents orphaned orders from remaining on the book during outages
  • Crash Protection: Orders are automatically cleaned up if the bot crashes
  • Network Failure Safety: Connectivity issues don’t leave stale orders on the book
  • Capital Protection: Prevents unintended fills during bot downtime

This mechanism is critical for production deployments where unattended operation is expected.

For latency arbitrage strategies, deployment location is critical. The bot’s edge depends on receiving price data faster than the market can react.

RegionLatency to BinanceLatency to PolymarketNotes
AWS ap-northeast-1 (Tokyo)Best (~1-5ms)Good (~100-150ms)Binance matching engine location
AWS ap-southeast-1 (Singapore)Good (~20-30ms)Good (~120-150ms)Good balance
AWS us-east-1 (N. Virginia)Poor (~150-200ms)Best (~10-30ms)Polymarket servers

Recommendation: For latency arbitrage, deploy to ap-northeast-1 (Tokyo) to minimize Binance latency. The Polymarket leg is less latency-sensitive since you’re reacting to Binance price changes.

Use the built-in latency check utility to measure actual latency from your deployment location:

Terminal window
# Using the hydra binary
hydra latency # Check all exchanges
hydra latency -e binance # Check specific exchange
hydra latency -e polymarket
hydra latency -e coinbase
# Or from source
bun run latency
bun run latency -- -e binance

Run this utility from your production environment before going live to verify acceptable latency.

The heartbeat mechanism will cancel open orders if the bot disconnects, but positions will remain open. In a crash scenario, you must manually manage any open positions.

  • Start Small: Begin with very small maxPositionSizeUSDC values to verify execution logic in a live environment.
  • Paper Trade First: Run your configuration in mode: paper for at least 24-48 hours of active market time before going live.
  • Monitor Connectivity: Use the TUI to monitor WebSocket staleness. If your internet connection is unstable, the bot’s risk manager may pause trading frequently.
  • Dedicated Wallet: Always use a fresh wallet with only the amount of capital you are willing to risk.
  • Monitor the TUI: Keep the TUI dashboard open to track Bal, Real/Unrl PnL, and DD metrics in real-time.
  • Test Latency First: Run hydra latency from your production environment before going live.
  • Deploy to Low-Latency Region: For latency arbitrage, deploy to ap-northeast-1 (Tokyo) or ap-southeast-1 (Singapore).