All flows
TradingAdvanced

Hermes + Polymarket: A Self-Learning Up/Down Trading Agent

A step-by-step guide to building a self-learning Hermes agent that trades Polymarket 5-minute up/down crypto markets — VPS setup, Telegram control, CLOB v2 execution, and a self-improving loop that adjusts probability estimates from live results.

YanXbt (@IBuzovskyi) on XYanXbt5 min read17 Jun 2026

Risk disclaimer. This flow describes an experimental, high-risk automated trading setup contributed by the community. Trading prediction markets can result in the total loss of your capital. Nothing here is financial advice. Start with tiny position sizes, keep DRY_RUN=true until you fully understand the behavior, and never risk money you can't afford to lose.

Why this flow exists

Automated bots have captured a large and growing share of prediction-market trading. Crypto up/down markets in particular show persistent, structural inefficiencies that reappear day after day. Most traders chase these windows manually and miss them — a self-learning agent doesn't.

Hermes is a strong foundation for this because it is open-source, runs continuously, and has a built-in self-learning loop that makes it more capable the longer it runs. This guide walks through launching Hermes and building the core trading logic for short-interval crypto up/down markets, then letting the agent refine its own strategy through live trades.

Why short-interval crypto up/down — not BTC

Up/down markets on a less-watched asset tend to carry more edge than BTC:

  • BTC is the most-watched asset on the planet. Every quant fund, HFT desk, and market maker stares at it. Mispricings vanish in seconds.
  • A less-watched asset gets less attention but moves more, and the prediction market reprices it more slowly.

That gap — between what the asset is doing on a spot exchange and what the prediction market thinks it's doing — is where bots make money.

How bots classify the opportunities

StrategyWhat it doesNotes
Arbitrage (pair cost)Buys both YES + NO when their combined price drops below $1.00Locks in a small risk-free profit per pair; very high win rate
DCA botWaits for one side to drop below ~$0.35, averages down until combined cost is under ~$0.99Patience-based
Momentum / latency botMonitors spot price on a major exchange, enters during the repricing delayTime-sensitive
Market makerPlaces two-sided orders on the 5-minute market, capturing the spreadContinuous
AI/ML botProbability forecasting ~20 minutes before close, acting on a meaningful edgeModel-driven

These inefficiencies are structural — they don't disappear, they just move faster than a human can follow.

What Hermes Agent contributes

Hermes is an open-source autonomous agent with a built-in self-learning loop. Three layers make it well-suited as the "brain" of a trading setup:

  • Knowledge layer — built-in memory, session search, and skills. Every trade it takes gets stored; every mistake gets learned from.
  • Execution layer — multi-agent profiles, child agents, a tool system, MCP support, and persistent machine access. It decomposes tasks, runs them in parallel, and delegates.
  • Output layer — cron jobs, gateway delivery to Telegram/Slack/Discord, a Web UI, and file output. Results flow back into your real workflow instead of being trapped in a chat window.

Together these make Hermes the brain of the setup — adapting to market conditions instead of blindly following instructions set once.

Installing Hermes Agent

The install takes under 5 minutes. Hermes supports Linux, macOS, and WSL2. Native Windows is not supported — use WSL2 (Ubuntu) if you're on Windows.

For 24/7 operation, deploy on a VPS. To run locally instead, skip Step 1 and start at Step 3.

Step 1 — Prepare a VPS

Create an account with a VPS provider, complete any required verification, and rent a basic Ubuntu 22.04 instance. The cheapest tier is fine for a trading agent.

Step 2 — Connect to the VPS

```bash ssh root@your_server_ip ```

On Windows, a client like Termius works well if you don't have a terminal set up.

Step 3 — Install Hermes

One command handles everything:

```bash curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash source ~/.bashrc ```

Step 4 — Choose a model

After installation you'll be prompted to choose a model. A strong general coding/reasoning model works well for trading-logic generation.

Step 5 — Set up the Telegram gateway

Hermes has a built-in gateway that connects the agent directly to Telegram, so you get trade alerts and can send commands from your phone even when your laptop is off.

Create your bot via @BotFather in Telegram (/newbot), then copy the token. Connect the gateway:

```bash hermes gateway setup ```

Choose Telegram and paste your bot token. Start the gateway:

```bash hermes gateway start ```

Open your bot, press /start, get the pairing code, and approve it:

```bash hermes pairing approve telegram <pairing_code> ```

Your agent is now connected to Telegram and trade alerts will flow there automatically once the bot is running.

Step 6 — Start Hermes

```bash hermes ```

You now have a running agent with an interactive CLI and a live Telegram connection.

Building the trading logic

Rather than building from scratch, the approach is: find open-source repositories with proven crypto up/down trading logic, feed that logic to Hermes, and let it find the most efficient strategy through live trades.

Several open-source Polymarket crypto-trading repos implement approaches like Quarter-Kelly sizing, Black-Scholes / EWMA volatility models, pure arbitrage, and momentum strategies, often with circuit breakers and Telegram alerts. Pick one whose math and risk controls you understand, then have Hermes modernize it for the current CLOB v2 API.

Below are the prompts to send your Hermes agent — paste them into Telegram or the CLI.

Prompt 1 — Build the core logic

```text Build a Polymarket 5-minute crypto up/down trading agent from this repo: <REPO_URL>

Update it for Polymarket CLOB v2 and make it ready for safe live trading.

Requirements:

  • Keep the existing architecture if possible
  • Use Python
  • Migrate execution to py_clob_client_v2
  • Support SAFE_ADDRESS for Polymarket Safe/proxy wallets
  • Use collateral balance terminology, not legacy USDC-only wording
  • Add fee-aware trade evaluation using CLOB v2 market metadata
  • Switch all market references to the chosen 5-minute up/down market
  • Keep DRY_RUN=true by default
  • Add or update tests for the core logic
  • Update README.md, SETUP.md, and .env.example
  • Verify everything with tests before finishing
  • Do not expose private keys in chat or logs ```

Prompt 2 — Create a wallet

Hermes has built-in safety checks. Confirm you understand the risks, then ask it to create a wallet it will manage:

```text Create a new Polygon wallet for me using eth_account in Python. Show me the address and private key. Save the private key to the bot's .env file as:

PK=... WALLET=... SIG_TYPE=0 ```

Save the wallet address and private key somewhere safe and offline.

Prompt 3 — Fund the wallet (you do this yourself)

Send to your new wallet address on the Polygon network:

  • USDC.e — your trading capital (start small)
  • POL — roughly 2 POL for gas fees

Then verify with your agent:

```text Check the balance of my wallet on Polygon. Address is 0xYOUR_ADDRESS. Check both POL and USDC.e (contract: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174) ```

Prompt 4 — Approve Polymarket contracts

```text I need to approve USDC.e spending for 3 Polymarket contracts on Polygon. My wallet private key is in the .env file in the bot folder.

Send on-chain ERC20 approve (max uint256) transactions for USDC.e (0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174) to these 3 spenders:

  1. CTF Exchange: 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E
  2. Neg Risk Exchange: 0xC5d563A36AE78145C45a50134d48A1215220f80a
  3. Router: 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296

Also approve the Conditional Tokens contract (0x4D97DCd97eC945f40cF65F87097ACe5EA0476045) using setApprovalForAll for the same 3 spenders above. This is needed for selling positions later.

Use web3.py, EIP-1559 tx type, 200 gwei maxFeePerGas, wait for each receipt. Chain id is 137 (Polygon). Verify all approvals after. ```

Prompt 5 — Migrate the executor to CLOB v2

```text In executor.py, migrate from legacy py_clob_client to py_clob_client_v2.

Initialize ClobClient with:

  • host=<CLOB_HOST>
  • key from PRIVATE_KEY
  • chain_id=POLYGON
  • funder=SAFE_ADDRESS if present
  • signature_type=2 when using Safe, otherwise 0
  • builder_config from env vars
  • use_server_time=True
  • retry_on_error=True

Use create_or_derive_api_key() for API creds. Read collateral balance using AssetType.COLLATERAL. Add market metadata refresh and fee estimation support. Keep buy/sell execution working. ```

Prompt 6 — Environment config

```text Update .env.example with:

PRIVATE_KEY SAFE_ADDRESS CLOB_HOST=<CLOB_HOST> DRY_RUN=true MIN_EDGE=0.08 MIN_PROB=0.10 MIN_BET=1.00 MAX_BET=5.00 BANKROLL=100 BUILDER_ADDRESS BUILDER_CODE MARKET_ASSET=<ASSET>

Use a small default MIN_BET for testing. Keep DRY_RUN=true until output is verified. ```

Prompt 7 — Telegram trade notifications

```text Add a Telegram notification system to the trading bot using the Hermes gateway.

For every trade executed, send a Telegram message with:

  • Market: UP or DOWN
  • Side: BUY or SELL
  • Price at entry
  • Position size in USDC
  • Expected value (EV) of the trade
  • Current wallet balance after the trade

Also send a daily summary at 00:00 UTC with:

  • Total trades today
  • Win rate today
  • PnL today (realized)
  • Total PnL since start
  • Current open positions

Add a command handler so I can send these commands from Telegram: /status — current open positions and balance /pause — pause trading, don't open new positions /resume — resume trading /pnl — full PnL breakdown since launch /stop — stop the bot completely

Use the Hermes gateway Telegram channel already configured. Do not hardcode the bot token — read it from .env as TELEGRAM_BOT_TOKEN. ```

Prompt 8 — Testing in dry-run

```text cd into the bot folder, activate the venv, and run: python3 bot_v3.py scan

Show me what trades it found and what it would have placed in DRY_RUN mode. ```

Expected output looks like:

```text [DRY_RUN] BUY 5min | UP @ $0.430 | EV +4.12% | $2.00 [DRY_RUN] ARB pair | UP+DOWN combined @ $0.962 | edge $0.038 | $5.00 [DRY_RUN] SKIP | DOWN @ $0.510 | EV -1.2% | below MIN_EDGE threshold ```

Prompt 9 — Go live (carefully)

Only when dry-run output looks clean, switch DRY_RUN=false and send:

```text Start the trading bot in continuous mode as a background process. Self-learning mode enabled — log every trade outcome and adjust probability estimates based on results over time.

Scan every 5 minutes for up/down markets on Polymarket. Send Telegram alerts for every executed trade. Send a daily summary at 00:00 UTC.

Show me the Polymarket portfolio link for my wallet. ```

The agent is now trading, sending real-time alerts, and accepting commands from Telegram — using Quarter-Kelly position sizing, CLOB v2 execution, and a self-learning loop that improves with every position.

Managing the bot from Telegram

Once live, Telegram is your entire interface — no need to SSH into the server.

  • Morning: /status — check open positions and balance
  • During the day: alerts arrive automatically, no action needed
  • If something looks off: /pause — stop opening new positions while managing existing ones
  • End of day: /pnl — full breakdown of what the bot did
  • If it does something unexpected: /stop to halt everything, then SSH in, check the logs, fix the prompt or config, and restart

The self-learning loop means the bot's behavior gradually shifts over the first couple of weeks — avoiding windows where it consistently loses and concentrating on the ones where it wins.

Conclusion

With Hermes running on a VPS, Telegram as your command center, and a self-learning loop that compounds every trade, you don't need to be a senior developer — you need the right prompts, a small starting position, and the patience to let the agent learn.

Recommendation: start with $1–$2 trades for the first week. Let the agent collect data and build its own logic before scaling. The self-learning loop is the whole point — don't rush past it. And again: this is experimental, high-risk software. Only ever trade with money you can afford to lose.

This flow was shared by a community member. The Hermes Bible is an unofficial, community-built resource and is not affiliated with Nous Research.

Related flows