[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80204":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":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":15,"starSnapshotCount":15,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},80204,"coinbase-trading-bot","ChypherFish3r\u002Fcoinbase-trading-bot","ChypherFish3r","coinbase trading bot for momentum strategies with optional profit transfers, CSV backtests, and a clean CLI","https:\u002F\u002Fwww.coinbase.com\u002F",null,"JavaScript",75,151,71,0,3,6,9,51.65,false,"master",true,[24,25,26,27],"coinbase","momentum","trading","trading-bot","2026-06-12 04:01:27","# Coinbase Trading Bot\n\n**Node.js momentum strategies with optional profit transfers, CSV backtests, and a clean CLI.**\n\nOriginally inspired by the **CrypFinder** \u002F Coinbase Pro ecosystem, this repo packages several strategies behind one entrypoint (`index.js`), central logging, environment validation, and npm scripts so you can experiment without hunting through commented-out requires.\n\n---\n\n## Important: Coinbase Pro and this codebase\n\nCoinbase has **retired Coinbase Pro** in favor of Coinbase Advanced Trade. The `coinbase-pro` npm client and the REST\u002FWebSocket URLs used here target the **legacy Coinbase Pro API**. They remain useful as **reference implementations** (strategy logic, order flow, backtests), but **production trading may no longer be available** on those endpoints.\n\nTreat this project as:\n\n- A **learning sandbox** for peak\u002Fvalley momentum mechanics and limit-order workflows\n- A **backtesting harness** over historical OHLC CSV files\n- A **starting point** if you port the same ideas to [Coinbase Advanced Trade API](https:\u002F\u002Fdocs.cdp.coinbase.com\u002Fadvanced-trade\u002Fdocs\u002Fwelcome) or another exchange\n\n**Disclaimer:** Trading crypto carries risk of total loss. This software is not financial advice, has no warranty, and you are responsible for keys, compliance, taxes, and testing.\n\n---\n\n## Features\n\n| Capability | Description |\n|------------|-------------|\n| **Momentum** | Buys on strength after a valley→peak move; sells when price retraces by your delta while covering fees and minimum profit. |\n| **Reverse momentum** | Inverse framing: fades rallies and buys dips per your tuned deltas. |\n| **Momentum + stop-loss** | Same core idea with an extra stop-loss threshold (`STOP_LOSS_DELTA`). |\n| **CSV analyzers** | Replay strategies on minute OHLC data and summarize buys, sells, and P&L shape. |\n| **Resume state** | Persists position metadata to disk (default `positionData.json`) so restarts can continue safely. |\n| **Profit skim** | Optional transfer of a fraction of realized profit to another portfolio\u002Fprofile after a winning sell. |\n\n---\n\n## Quick start\n\n### Prerequisites\n\n- **Node.js 18+**\n- A Coinbase **portfolio** (profile) dedicated to the bot — avoid the default portfolio if you move funds manually\n- API key with appropriate permissions **if** you still have access to Coinbase Pro–compatible endpoints (see disclaimer above)\n\n### Install\n\n```bash\ngit clone \u003Cyour-fork-url>\ncd coinbase-trading-bot\nnpm install\ncp .env.example .env\n# Edit .env — never commit real keys\n```\n\n### Choose a strategy\n\nSet `STRATEGY` in `.env` or pass via npm script:\n\n| `STRATEGY` | npm shortcut | Needs API keys |\n|------------|----------------|----------------|\n| `momentum` (default) | `npm run start:momentum` | Yes |\n| `reverse` | `npm run start:reverse` | Yes |\n| `momentum_stoploss` | `npm run start:momentum-stoploss` | Yes |\n| `momentum_analyze` | `npm run analyze:momentum` | No |\n| `reverse_analyze` | `npm run analyze:reverse` | No |\n\n```bash\nnpm start\n# or explicitly:\nnpm run start:momentum\n```\n\nLive trading (when supported by your environment):\n\n```bash\n# In .env:\nTRADING_ENV=real\nAPI_KEY=...\nAPI_SECRET=...\nAPI_PASSPHRASE=...\n```\n\nSandbox-style defaults apply when `TRADING_ENV` is unset or not `real`.\n\n### Backtesting\n\n1. Obtain OHLC CSV data with a **`high`** column (see [Kaggle crypto minute data](https:\u002F\u002Fwww.kaggle.com\u002Fdatasets) or similar).\n2. Place the file in the project directory (or reference an absolute path).\n3. Set in `.env`:\n\n```bash\nCSV_DATA_FILE=your_pair.csv\nSTRATEGY=momentum_analyze   # or reverse_analyze\n```\n\n4. Tune constants at the top of the analyzer file under `tradingConfig`, then:\n\n```bash\nnpm run analyze:momentum\n```\n\n---\n\n## Configuration reference\n\nAll secrets and overrides belong in **`.env`** (see `.env.example`).\n\n**Credentials**\n\n- `API_KEY`, `API_SECRET`, `API_PASSPHRASE` — Coinbase Pro–style API trio\n- `TRADING_ENV` — `real` for production URI; otherwise sandbox URIs are used\n\n**Trading knobs** (optional; defaults live in each strategy file)\n\n- `SELL_POSITION_DELTA`, `BUY_POSITION_DELTA`, `ORDER_PRICE_DELTA`\n- `BASE_CURRENCY_NAME`, `QUOTE_CURRENCY_NAME` — e.g. `BTC` + `USD` → `BTC-USD`\n- `TRADING_PROFILE_NAME`, `DEPOSIT_PROFILE_NAME` — portfolio names as shown in Coinbase\n- `DEPOSITING_ENABLED`, `DEPOSITING_AMOUNT` — profit transfer after winning sells\n- `BALANCE_MINIMUM` — quote currency left aside to avoid rounding failures\n- `STOP_LOSS_DELTA` — **momentum_stoploss** only\n\n**Paths**\n\n- `POSITION_DATA_FILE` — state file for resume (default `positionData.json`)\n- `CSV_DATA_FILE` — input for analyzers\n\n**Logging**\n\n- `LOG_LEVEL` — e.g. `info`, `debug`\n\n---\n\n## How strategies think (short)\n\n1. **WebSocket ticker** keeps a live price for the product pair.\n2. The bot tracks **peaks and valleys** and compares moves against your **delta** thresholds.\n3. **Limit orders** (`FOK`) try to buy or sell with a small **order price cushion** (`ORDER_PRICE_DELTA`).\n4. After a profitable round-trip sell, an optional **profile transfer** moves part of the profit to your savings portfolio.\n\nFor a narrative deep-dive, see the markdown files under `strategies\u002F*\u002F`.\n\n---\n\n## Restarting and `positionData.json`\n\nIf the process stops, it reads `POSITION_DATA_FILE` to restore `positionExists`, acquisition price, and cost. Do not manually add coins to an open position the bot thinks it owns — cost basis will be wrong.\n\nTo start fresh: flatten the position in the UI for that portfolio, then delete your position state file (default `positionData.json`).\n\n---\n\n## Development\n\n```bash\nnpm run lint\n```\n\nProject layout:\n\n```text\nindex.js              # Loads .env, validates credentials, runs STRATEGY\nlib\u002F\n  logger.js           # Shared Pino logger\n  paths.js            # positionData path resolver\n  strategies.js       # Strategy registry\n  validateEnv.js      # API key checks\nbuyAndSell.js         # Shared limit-order buy\u002Fsell helpers\ncoinbaseProLibrary.js # Signed REST helpers (profiles, fees, transfers)\nstrategies\u002F\n  momentumTrading\u002F\n  momentumTradingWithStopLoss\u002F\n  reverseMomentumTrading\u002F\n```\n\n---\n\n## Contributing\n\n1. Fork the repository\n2. Create a branch for your change\n3. Run `npm run lint`\n4. Open a pull request with a clear description\n\n---\n\n## Credits & license\n\nBased on prior CrypFinder \u002F Coinbase Pro bot work by Levi Leuthold and community forks. Licensed under **ISC** unless otherwise noted in `package.json`.\n\n---\n\n## Links\n\n- [Coinbase Developer Platform (Advanced Trade)](https:\u002F\u002Fdocs.cdp.coinbase.com\u002F) — migration path for new integrations\n- [Historical crypto OHLC ideas](https:\u002F\u002Fmedium.com\u002Fcoinmonks\u002Fhow-to-get-historical-crypto-currency-data-954062d40d2d)\n- Community datasets on [Kaggle](https:\u002F\u002Fwww.kaggle.com\u002Fdatasets)\n","Coinbase Trading Bot 是一个基于Node.js的交易机器人，专为实现动量策略而设计，并支持可选的利润转移、CSV回测及简洁的命令行界面。其核心功能包括多种动量交易策略（如常规动量、反向动量以及带有止损机制的动量策略），能够根据价格波动自动执行买卖操作；同时提供CSV分析工具以评估历史数据上的策略表现，帮助用户优化参数设置。此外，项目还具备状态持久化能力，确保重启后可以安全地继续运行。该项目适用于希望在Coinbase平台上测试或实践动量交易策略的研究者与开发者，特别是那些对加密货币市场感兴趣且愿意通过模拟或小规模实盘来学习和探索的人士。需要注意的是，由于Coinbase Pro已停用，建议将此项目作为学习资料或参考实现使用，若需应用于生产环境，则应考虑迁移至Coinbase Advanced Trade API或其他交易所接口。",2,"2026-06-11 03:59:39","CREATED_QUERY"]