Waveband, Cardano crypto trading bot

Automated two‑way swaps on Cardano using an EMA‑band strategy

Open‑source trading bot that accumulates target assets over time. Quotes via the Minswap Aggregator API and optional backtesting via TapTools. Run safely in dry mode, then go live with PM2.

Not financial advice. Use at your own risk. Understand slippage, fees, and wallet security.

Sample log (dry mode):
[env] DRY_RUN(resolved)= true
[tick] mid≈ 0.508182 STRIKE/ADA | band [0.4945, 0.5106] | center≈ 0.5026
[trade] BUY 10 ADA → STRIKE at edge; slippage guard 0.50%; fees ≤ 0.20%

What it is

A configurable bot that watches a trading pair and executes swaps when price moves outside an adaptive band around an Exponential Moving Average. The band widens or tightens using BAND_ALPHA and BAND_BPS, with an execution edge set by EDGE_BPS. Quotes route through the Minswap Aggregator for best‑path pricing.

Risk controls include slippage caps, fee caps, cooldowns, minimum notional outputs, and reserves. It can run in dry mode to simulate fills before going live.

Features

EMA‑Band Strategy

Dynamic bands around EMA with execution edge. Tunable via BAND_ALPHA, BAND_BPS, and EDGE_BPS.

Aggregator Quotes

Uses Minswap Aggregator for pathfinding and pricing with ONLY_VERIFIED pool option.

Risk Controls

Slippage and fee caps, cooldowns, min notional out, reserve ADA, and min trade sizes.

Backtesting & Sweeps

TapTools‑powered backtests and parameter sweeps to discover robust settings.

Operational Logs

CSV fills and rolling band centre file for analysis and dashboards.

Production Ready

Run under PM2 with separate pair‑specific .env files.

How to get started

Prerequisites

  • Node.js 18+ and pnpm or npm
  • Blockfrost project ID (Mainnet or testnet)
  • Optional TapTools API key for backtesting
  • ed25519 private key for a small hot wallet (low balances recommended)

Security tip: keep your hot wallet balance minimal and rotate keys.

Install

# 1) Clone
git clone https://github.com/pbwebdev/cardano-trading-bot
cd cardano-trading-bot

# 2) Install deps
pnpm i   # or: npm i

# 3) Copy an example env
cp .env.example.dry-mode .env.ada-strike

# 4) Edit .env.ada-strike with your pair and keys

Run in dry mode

# Run a pair in dry mode
$env:DOTENV_CONFIG_PATH=".env.ada-strike"     # PowerShell
DOTENV_CONFIG_PATH=.env.ada-strike pnpm tsx src/bot-twoway.ts

Watch the console and CSV fills. Tweak band size, edge, cooldown, and trade sizes until behaviour matches your intent.

Go live with PM2

# Example (see ecosystem.config.cjs in repo)
pm2 start ecosystem.config.cjs
pm2 logs bot:ada-strike

Use separate .env files per pair. Keep DRY_RUN=false only when you are ready.

Documentation

Key environment variables

  • TOKEN_A, TOKEN_B – Trading pair.
  • AMOUNT_A_DEC, AMOUNT_B_DEC – Base trade sizing.
  • BAND_BPS, BAND_ALPHA, EDGE_BPS – Strategy shape and trigger.
  • SLIPPAGE_PCT, FEE_CAP_PCT – Execution guards.
  • COOLDOWN_MS, POLL_MS – Control frequency.
  • MIN_NOTIONAL_OUT, MIN_TRADE_*, RESERVE_ADA_DEC – Risk and dust control.
  • DRY_RUN, ONLY_VERIFIED – Safety flags.
  • LOG, CENTER_FILE – CSV fills and band centre tracking.

See the repository README for a commented example env and advanced options.

Backtesting

Use TapTools data to simulate the EMA‑band rules with fees, slippage, and cooldowns. Run parameter sweeps to locate robust regimes, then promote those settings to live.

# Example backtest run (see scripts in repo)
pnpm tsx src/backtest-taptools.ts
pnpm tsx src/backtest-sweep.ts

FAQs

Is this financial advice?+

No. This is research software. You are responsible for your own risk. Test in dry mode first and start small.

What DEXs are used?+

Routing and pricing use the Minswap Aggregator API. Pools can be restricted to verified only.

How do I keep fees and slippage under control?+

Set SLIPPAGE_PCT and FEE_CAP_PCT. Consider higher cooldowns and minimum notionals to avoid churn in low‑liquidity periods.

Which wallet format is used?+

The bot signs with an ed25519 private key file. Do not place primary funds in this wallet. No mnemonic operations are required.

Can I throttle how often it trades?+

Yes. Use COOLDOWN_MS and POLL_MS. You can target 4‑hour rhythm or slower to avoid over‑trading.

Where do I see results?+

Check your CSV fills (LOG) and the band centre file (CENTER_FILE). You can chart these for performance review.

Join the community

Star the repository, open issues, and share sweep results and configs. PRs that improve safety, docs, or performance are welcome.

Safety checklist

  • Start in dry mode. Inspect logs.
  • Run small. Verify fees and slippage.
  • Keep hot wallet balances low.
  • Use verified pools where possible.
  • Backtest and sweep before live.