[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-77188":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":41,"readmeContent":42,"aiSummary":43,"trendingCount":15,"starSnapshotCount":15,"syncStatus":44,"lastSyncTime":45,"discoverSource":46},77188,"coinbase-trading-bot","pro-tech-killers\u002Fcoinbase-trading-bot","pro-tech-killers","coinbase trading bot coinbase api advanced trade trading bot crypto trading bot automated trading coinbase trading bot typescript algorithmic trading ema atr coinbase bot crypto trading bot coinbase trading bot paper trading spot coinbase trading bot risk sizing zod nodejs coinbase trading bot fintech quant coinbase trading bot open source","https:\u002F\u002Fgithub.com\u002Fpro-tech-killers\u002Fcoinbase-trading-bot",null,"TypeScript",86,2960,1,0,120,10,false,"master",true,[22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"advanced-trade","algorithmic-trading","atr","automated-trading","coinbase","coinbase-api","crypto-bot","cryptocurrency","ema","fintech","nodejs","open-source","paper-trading","quant","sol","spot","trading-bot","typescript","zod","2026-06-12 02:03:42","# Coinbase Advanced Trade — Systematic EMA Bot\n\n**Repository (clone \u002F issues \u002F PRs):** [github.com\u002Fpro-tech-killers\u002Fcoinbase-trading-bot](https:\u002F\u002Fgithub.com\u002Fpro-tech-killers\u002Fcoinbase-trading-bot)\n\n**Keywords:** coinbase coinbase-api coinbase-bot advanced-trade cdp-api trading-bot ema-crossover atr trend-filter paper-trading market-ioc typescript btc eth sol crypto algorithmic-trading automated-trading automated-crypto quant fintech risk-sizing zod nodejs open-source institutional retail spot hft retail-pro api-keys portfolio tracker usd coinbase-pro legacy-hmac cdp-keys rest-client fill-or-kill ioc market-order cloud-api developer-platform\n\n**Related:** [binance-trading-bot](https:\u002F\u002Fgithub.com\u002Fpro-tech-killers\u002Fbinance-trading-bot) · [bybit-trading-bot](https:\u002F\u002Fgithub.com\u002FAI4FinanceFoundation\u002Fbybit-trading-bot) · [ai-trading-agent](https:\u002F\u002Fgithub.com\u002Fendless-sky-team\u002Fai-trading-agent)\n\n**Jump to:** [At a glance](#at-a-glance) · [Your journey](#your-journey-in-four-beats) · [Who this is for](#who-this-is-for) · [Quick start](#quick-start-first-time-users) · [npm scripts & dependencies](#npm-scripts--dependencies) · [Configuration](#configuration-reference) · [Coinbase API notes](#coinbase-api-notes) · [Project layout](#project-layout) · [Go live](#enabling-live-trading-read-carefully) · [Troubleshooting](#troubleshooting) · [Related projects (same workspace)](#related-projects-same-workspace) · [Your next move](#your-next-move-invitation)\n\n---\n\n## Related projects (same workspace)\n\n| Project | Venue | Focus |\n|---------|--------|--------|\n| [Binance Spot bot](https:\u002F\u002Fgithub.com\u002Fpro-tech-killers\u002Fbinance-trading-bot) | Binance Spot (CCXT) | SuperTrend \u002F EMA+RSI, long-only spot |\n| [Bybit trend bot](https:\u002F\u002Fgithub.com\u002FAI4FinanceFoundation\u002Fbybit-trading-bot) | Bybit V5 linear USDT perps | EMA + ADX + ATR, SL\u002FTP via trading-stop |\n| [AI trading agent](https:\u002F\u002Fgithub.com\u002Fendless-sky-team\u002Fai-trading-agent) | Lighter + OpenRouter | LLM tool-calling, PostgreSQL audit trail |\n\n---\n\n## The pitch — why people stick around\n\n**Most trading tools ask you to trust a logo. This one asks you to read the code.**\n\n- **Clarity you can build on** — One loop, one strategy module, and configuration that is **validated at startup** (so bad env vars fail fast, not in production).\n- **Discipline, baked in** — **Paper trading is the default.** You opt in to live orders with a single flag—on purpose.\n- **Risk you define** — Size entries with a **per-trade risk fraction** and an optional **hard cap** per order in your quote currency. The bot does not “guess” your tolerance.\n- **A strategy people actually recognize** — **EMA cross + long-term EMA filter** and **ATR** logging mirror ideas you will find in books, courses, and prop-style playbooks: trend follow when the market agrees, step aside when the cross says to exit.\n- **Serious stack** — [TypeScript 5](https:\u002F\u002Fwww.typescriptlang.org\u002F), **Node 20+**, and [coinbase-advanced-node](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fcoinbase-advanced-node) talking to the real Advanced Trade API—the same class of building blocks used by developers who treat execution as software engineering.\n\n**Ideal if you** want to **automate a rule you understand**, **learn systematic trading on real infrastructure**, or **ship a v1** you can later upgrade with your own risk engine—without starting from a fragile script you found in a forum thread.\n\n---\n\n## At a glance\n\n| You want to… | What this gives you |\n|--------------|---------------------|\n| **Get going in one session** | `npm install` → copy `.env` → `npm run dev` and you are pulling candles. |\n| **See signals before you risk capital** | **Paper mode on by default** — logs what would have traded. |\n| **Own your stack** | Full source: indicators, strategy, execution—fork it, don’t rent it. |\n| **Stay in control** | Tweak EMAs, pair, and poll interval in `.env` without touching the exchange UI every hour. |\n| **Grow from prototype to system** | Clean folders so you can add stops, websockets, or a second strategy without a rewrite. |\n\n**Under the hood (one sentence):** a production-style client that runs a **trend-following** EMA rule, applies **position sizing** from *your* settings, and only sends live **market** orders when you say so.\n\n---\n\n## Your journey in four beats\n\n1. **Connect in minutes** — Add keys to `.env`, run `npm run dev`, and you are already streaming **real** market structure into your terminal—not a demo with fake prices.\n2. **Watch the rules work in plain sight** — Every cycle logs **close, EMAs, ATR, signal, balances**. The story is in the data, not in someone else’s “AI.”\n3. **Tune like a product** — Swap pair, timeframes, and EMAs from configuration; iterate without rebuilding your *idea* from scratch every week.\n4. **Promote to live on your terms** — **Paper is default** for a reason. When the logs still make sense to you, **you** flip one flag. That’s the bar.\n\n**That’s the hook:** not “magic money,” but **a machine you understand** that can keep watching when you need to work, sleep, or think.\n\n---\n\n## Who this is for\n\n| You are… | You’ll care because… |\n|----------|----------------------|\n| **A developer** | You want **Git, TypeScript, and a real REST client** next to your trading idea—not a binary blob called “strategies.dll.” |\n| **A self-directed trader** | You want a **documented rule** and **reproducible logs** you can review when emotions have cooled. |\n| **A learner** | You want the **full path**: candles → math → *intent* → (optional) order—on the **same** exchange serious traders use. |\n| **A builder \u002F side-project founder** | You need a **credible v1** you can show: “this places orders through Coinbase; here’s the repo.” |\n| **Anyone burned by “bots” in a box** | **You** hold the code. If something is wrong, you can **find the line**—not file a support ticket and hope. |\n\n---\n\n## We’re straight with you (this builds trust, not hype)\n\n- We do **not** claim guaranteed **profits**, “passive income,” or a secret edge. **Markets change; rules break; capital is at risk.**\n- We **do** offer **full transparency**, **paper-by-default** execution, and a **serious** starting point to learn and extend—*if* you put in the work on testing and risk.\n- The goal isn’t a lottery ticket. It’s **ownership of your process** in a form you can run, measure, and improve.\n\n---\n\n## Why this project exists (technical promise)\n\n| Goal | How this project helps |\n|------|-------------------------|\n| **Clarity** | One strategy, one loop, explicit env-driven configuration (validated with [Zod](https:\u002F\u002Fzod.dev\u002F)). |\n| **Safety** | **Paper trading is the default**; real orders require you to opt in explicitly. |\n| **Control** | Risk per trade and optional per-order caps are separate from the signal logic. |\n| **Maintenance** | Typed code, [coinbase-advanced-node](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fcoinbase-advanced-node) for the exchange API, Node 20+. |\n\n> **Important:** Marketing copy does not change market reality. **Trading involves risk of loss. Past results do not predict future results.** This repository is **not** financial, tax, or legal advice. You are responsible for API keys, permissions, product choice, fees, and compliance with law and Coinbase terms. **Nothing here promises profit.**\n\n---\n\n## What the strategy does (in plain language)\n\nThe bot uses a **double EMA crossover** on candle closes, with a **long-term EMA** as a **trend filter**—a combination widely used in systematic trading and taught in many technical and quantitative finance resources.\n\n- **Entry (buy signal):** Shorter EMA crosses **above** longer EMA **and** price is on the “right side” of the trend EMA (configurable, default: above the 200-period EMA on your chosen candle size).\n- **Exit (sell signal):** Shorter EMA crosses **below** longer EMA (full base exit, subject to min order sizes).\n\n**ATR (Average True Range)** is calculated for each cycle and logged so you can extend the bot (e.g. dynamic stops, volatility-scaled size) without reverse-engineering the code.\n\nThis is **not** a guarantee of positive returns. **Edge** in live markets depends on product, timeframe, costs, slippage, and regime—and must be **measured** (backtest, walk-forward, paper trade) for *your* market and *your* parameters.\n\n---\n\n## High-level flow\n\n```mermaid\nflowchart LR\n  subgraph config [Config]\n    ENV[\".env\"]\n  end\n  subgraph exchange [Coinbase Advanced Trade]\n    API[\"REST API\"]\n  end\n  subgraph bot [Bot]\n    Candles[\"Fetch candles\"]\n    Indicators[\"EMA + ATR\"]\n    Rules[\"Rules engine\"]\n    Risk[\"Size & limits\"]\n    Exec[\"Market IOC orders\"]\n  end\n  ENV --> Candles\n  Candles --> Indicators\n  Indicators --> Rules\n  Rules --> Risk\n  Risk --> Exec\n  Candles --> API\n  Risk --> API\n  Exec --> API\n```\n\n---\n\n## Requirements\n\n- **Node.js 20+**\n- A **Coinbase** account with [Advanced Trade](https:\u002F\u002Fwww.coinbase.com\u002Fadvanced-trade) access\n- An **API key** with appropriate permissions (read balances, read market data, **trade** only if you disable paper mode)\n\n---\n\n## npm scripts & dependencies\n\nFrom `package.json` (**package:** `coinbase-adv-trade-bot`):\n\n| Script | Command | Purpose |\n|--------|---------|---------|\n| `npm run dev` | `node --import tsx src\u002Findex.ts` | Run TypeScript without a separate compile step. |\n| `npm run build` | `tsc` | Emit JavaScript to `dist\u002F` (`npm start` expects `dist\u002Findex.js`). |\n| `npm start` | `node dist\u002Findex.js` | Production-style run **after** `npm run build`. |\n| `npm run typecheck` | `tsc --noEmit` | CI \u002F local compile validation only. |\n\nMain runtime dependencies:\n\n| Dependency | Role |\n|------------|------|\n| [coinbase-advanced-node](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fcoinbase-advanced-node) | Typed client for Coinbase Advanced Trade REST endpoints. |\n| [zod](https:\u002F\u002Fzod.dev\u002F) | Validates `.env` once at startup. |\n| [dotenv](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fdotenv) | Loads `.env` locally. |\n\n---\n\n## Coinbase API notes\n\n- **Products:** `PRODUCT_ID` must be a live Advanced Trade **product ID** (e.g. `BTC-USD`). The bot validates format at startup—typos fail fast rather than silently polling the wrong instrument.\n- **Candles:** The loop requests historical candles until the strategy has enough bars for `EMA_TREND` **and** the crossover logic; coarse granularities (`ONE_DAY`) mean slower “strategy-ready” startup than `ONE_MINUTE`\u002F`FIVE_MINUTE`.\n- **Orders:** Entries use **market IOC** with **`quote_size`**; sizing merges **`RISK_PER_TRADE`** with optional **`MAX_QUOTE_PER_ORDER`**. Coinbase minimum increments (`quote_min_size`, `base_min_size`) still apply—the README troubleshooting lists rejects tied to minima.\n- **Rate limits:** Advanced Trade applies REST rate limits per key and endpoint class. For a single pair and **one poll every `POLL_MS`**, traffic is modest; if you shorten `POLL_MS` aggressively or run many forks of this bot on the **same** key, watch for `429`-style throttling in logs and back off.\n- **Not modeled here:** Full order book, historical fill reconstruction, or sub-account routing—extend the client layer if you need them.\n\n---\n\n## Quick start (first-time users)\n\n### 1. Install\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fpro-tech-killers\u002Fcoinbase-trading-bot.git\ncd \"coinbase trading bot\"\nnpm install\n```\n\n### 2. Configure environment\n\n```bash\ncopy .env.example .env\n```\n\nOn macOS or Linux:\n\n```bash\ncp .env.example .env\n```\n\nEdit `.env` and add credentials (see [Authentication](#authentication) below). **Leave `PAPER_TRADING=1` until you are ready.**\n\n### 3. Build and run\n\n```bash\nnpm run build\nnpm start\n```\n\n**Development (TypeScript without a separate build):**\n\n```bash\nnpm run dev\n```\n\nYou should see timestamped log lines: closes, EMAs, ATR, signal, and balances. In paper mode, **no orders** are sent.\n\n### That “it’s alive” moment\n\nThe first time you see a full **tick** in the log—**price, EMAs, ATR, signal, balances**—you’ve turned a loose idea into a **pipeline** you can re-run any day. *That* is the feeling most people are chasing when they say they want a bot. This repo is built to get you to that moment **fast**, then help you not ruin it with rushed live size.\n\n---\n\n## Authentication\n\nThe bot supports the same two styles supported by the underlying client:\n\n| Method | Environment variables | Notes |\n|--------|----------------------|--------|\n| **CDP (recommended)** | `CDP_API_KEY_NAME`, `CDP_API_KEY_SECRET` | Modern Coinbase [Developer Platform](https:\u002F\u002Fwww.coinbase.com\u002Fdeveloper-platform) \u002F Cloud API keys. |\n| **Legacy HMAC** | `API_KEY`, `API_SECRET` | Older key format, where still supported. |\n\n**Never commit** `.env` or keys. The repository includes `.gitignore` rules for `.env`.\n\n**Permissions:** For paper trading you still need valid keys so the client can read **candles** and **balances** (same as live). Ensure your key’s scopes match what you intend (view vs trade).\n\n---\n\n## Configuration reference\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `PAPER_TRADING` | `1` (on) | `1` \u002F `true` = log only; set to `0` to send real orders. |\n| `PRODUCT_ID` | `BTC-USD` | e.g. `ETH-USD`, `SOL-USD` (use Coinbase’s product IDs). |\n| `CANDLE_GRANULARITY` | `FIVE_MINUTE` | `ONE_MINUTE`, `FIVE_MINUTE`, `FIFTEEN_MINUTE`, `THIRTY_MINUTE`, `ONE_HOUR`, `TWO_HOUR`, `SIX_HOUR`, `ONE_DAY`. |\n| `POLL_MS` | `60000` | Milliseconds between loop iterations. |\n| `EMA_FAST` | `12` | Fast EMA length (closes). |\n| `EMA_SLOW` | `26` | Slow EMA length (same window family as many MACD definitions). |\n| `EMA_TREND` | `200` | Trend EMA; long entries require price context vs this line (see code). |\n| `ATR_PERIOD` | `14` | ATR lookback; used in logs; extend the code for risk logic. |\n| `RISK_PER_TRADE` | `0.02` | Fraction of **available quote** balance used to size a **new buy** (e.g. `0.02` = 2%). |\n| `MAX_QUOTE_PER_ORDER` | *(optional)* | Hard cap in **quote** currency on each buy (e.g. `500` for 500 USD). |\n\n---\n\n## Trading behavior (what to expect)\n\n- **Buys** use **market IOC** with **`quote_size`** (spend up to the risk- and cap-limited amount).\n- **Sells** use **market IOC** with **`base_size`**, using nearly all base balance on exit (minus rounding); minimum sizes come from the **product** API.\n- The bot does **not** manage partial take-profits, stop-loss orders, or pending-order reconciliation in the current version; treat it as a **minimal v1** you can extend.\n\n### Moving toward a more “professional” outcome (no empty promises)\n\nProfitable *process* in real markets usually combines:\n\n1. **Explicit costs** — fees, spread, and (for some products) funding; compare to the average trade’s expected move.\n2. **Stability of rules** — avoid changing parameters on every red day; document what you test.\n3. **Out-of-sample checks** — walk-forward or paper **after** any parameter search.\n4. **Risk of ruin** — keep per-trade risk small relative to what you can afford to lose.\n\nThis README is written so you can align expectations with that workflow—not with hype.\n\n---\n\n## Project layout\n\n| Path | Role |\n|------|------|\n| `src\u002Findex.ts` | Loads env, starts the engine. |\n| `src\u002Fconfig.ts` | Validated environment and `PRODUCT_ID` parsing. |\n| `src\u002Fcoinbase\u002FcreateClient.ts` | Authenticated `Coinbase` client. |\n| `src\u002Fstrategy\u002FemaCrossTrendStrategy.ts` | EMA\u002FATR signal logic. |\n| `src\u002Fengine\u002FbotEngine.ts` | Polling loop, balances, order placement, logging. |\n| `src\u002Findicators\u002F` | EMA and ATR helpers. |\n| `src\u002Futils\u002FsizeFormat.ts` | Order size strings vs exchange minima. |\n\n---\n\n## Scripts\n\n| Command | Description |\n|---------|-------------|\n| `npm run build` | Compile to `dist\u002F`. |\n| `npm start` | Run compiled `dist\u002Findex.js` (use after `build`). |\n| `npm run dev` | Run TypeScript with `tsx` (no `build` required). |\n| `npm run typecheck` | Type-check only. |\n\n---\n\n## Enabling live trading (read carefully)\n\n1. Confirm **paper** logs match your intent for several sessions and products.\n2. Set **`PAPER_TRADING=0`** in `.env`.\n3. Use **only capital you can afford to lose**; start with **small** `RISK_PER_TRADE` and optional **`MAX_QUOTE_PER_ORDER`**.\n4. Monitor the first live sessions; consider running on a small VPS or home machine you control, with a locked-down key.\n\n**Stop the bot** with `Ctrl+C` in the terminal (SIGINT).\n\n---\n\n## Troubleshooting\n\n| Symptom | What to check |\n|--------|----------------|\n| `Set CDP API keys...` | Missing or misnamed env vars; use `.env` in the project root. |\n| `Unknown product` | `PRODUCT_ID` must match a live Advanced Trade product (e.g. `BTC-USD`). |\n| Orders rejected \u002F below minimum | Check Coinbase `base_min_size` \u002F `quote_min_size` for that product; increase balance or `RISK_PER_TRADE` slightly if appropriate. |\n| “Need N candles” | The strategy needs a minimum history; wait for the feed to return enough bars or use a coarser `CANDLE_GRANULARITY` if the API limit is an issue. |\n| Too many requests \u002F throttling | Short `POLL_MS` or multiple processes on one key | Increase `POLL_MS`; separate keys or stagger runs; see [Coinbase API notes](#coinbase-api-notes). |\n| `401` \u002F auth after key rotation | Stale env or wrong key pair | Full process restart; ensure CDP keys are not mixed with legacy `API_KEY`\u002F`API_SECRET` unless that is what you use. |\n\n---\n\n## Your next move (invitation)\n\n- **Save it** — Star the repository so you can find it when you are ready to go from reading to running.\n- **Make it yours** — Fork, rename, strip what you do not need, add what you *do* (stops, another pair, a second strategy file). The license is on you and the rights holders—check the repo’s license if one is present.\n- **Show someone** — Send the link to the friend who says “I will automate that someday.” A working repo beats another bookmark on a “how to trade” article.\n- **Stay curious** — The interesting part is not the first run. It is what you **measure** and **change** next—*after* the excitement wears off and the log files stack up.\n\n---\n\n## License\n\nSee the `package.json` \u002F repository license if provided. The bot depends on **coinbase-advanced-node** and other packages under their respective licenses.\n\n---\n\n## Acknowledgment\n\nExchange connectivity is provided by the open-source **[coinbase-advanced-node](https:\u002F\u002Fgithub.com\u002FJoshJancula\u002Fcoinbase-advanced-node)** client, not by Coinbase, Inc. This project is an independent example and is not affiliated with or endorsed by Coinbase.\n\nIf you use this in production, **log retention**, **key rotation**, and **incident response** are your responsibility.\n\n---\n\n**Questions?** Open an issue in your repository, or adapt the code under `src\u002Fstrategy` for your own rules—after testing.\n","Coinbase Trading Bot 是一个基于 Coinbase API 的自动化交易机器人，专为加密货币市场设计。该项目利用 EMA（指数移动平均线）和 ATR（真实波动幅度均值）等技术指标进行算法交易，支持纸面交易与实盘交易模式，帮助用户在安全的环境下测试策略。其核心功能包括系统化的EMA交叉策略、风险管理和自动订单执行，通过 TypeScript 编写，确保代码质量和可维护性。适用于希望提高交易效率并减少人为错误的个人投资者或机构，尤其适合那些对量化交易感兴趣但又不想完全依赖第三方平台的用户。",2,"2026-06-11 03:55:10","CREATED_QUERY"]