[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79344":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":18,"hasPages":18,"topics":20,"createdAt":10,"pushedAt":10,"updatedAt":37,"readmeContent":38,"aiSummary":39,"trendingCount":15,"starSnapshotCount":15,"syncStatus":40,"lastSyncTime":41,"discoverSource":42},79344,"aster-bot","SigmaTradeLabs\u002Faster-bot","SigmaTradeLabs","asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot,","https:\u002F\u002Fgithub.com\u002FSigmaTradeLabs\u002Faster-bot",null,"JavaScript",99,1027,1,0,190,56.04,false,"main",[21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"algo-trading","aster-dex","asterdex","automated-trading","crypto-bot","crypto-trading-bot","cryptocurrency","decentralized-exchange","defi","dex-trading-bot","fapi-bot","futures-trading","perp-trading","perpetual-trading","trading-bot","typescript","2026-06-12 04:01:24","# Aster Trading Bot\n\n[![GitHub](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGitHub-SigmaTradeLabs%2Faster--bot-181717?logo=github)](https:\u002F\u002Fgithub.com\u002FSigmaTradeLabs\u002Faster-bot) [![Aster DEX](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAster%20DEX-www.asterdex.com-6366f1)](https:\u002F\u002Fwww.asterdex.com) [![FAPI](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FFutures%20API-fapi.asterdex.com-0f172a)](https:\u002F\u002Ffapi.asterdex.com)\n\n**Source:** [github.com\u002FSigmaTradeLabs\u002Faster-bot](https:\u002F\u002Fgithub.com\u002FSigmaTradeLabs\u002Faster-bot)\n\n**Automated futures trading** on **[Aster DEX](https:\u002F\u002Fwww.asterdex.com)** (perp DEX) using the public **[fapi.asterdex.com](https:\u002F\u002Ffapi.asterdex.com)** RPC\u002FWebSocket — dual-engine strategies, risk controls, and production-grade logging.\n\nAster is a TypeScript\u002FNode.js trading system built for **ASTERUSDT-style perpetual markets**. It is suitable for operators anywhere in the world who need a **repeatable, configurable** workflow: research parameters in **dry-run**, then deploy in **live** mode with clear limits and full audit trails.\n\n> **Disclaimer:** Trading digital assets involves substantial risk. The screenshots in this document are **illustrative** examples of market analysis and exchange trade history. They are **not** a guarantee of future results. Read the [Important warnings](#important-warnings) and [Legal disclaimer](#disclaimer) before use.\n\n---\n\n## Table of contents\n\n1. [Visual overview](#visual-overview) — charts, signals, and execution logs  \n2. [Features](#features)  \n3. [Who this is for](#who-this-is-for)  \n4. [Prerequisites](#prerequisites)  \n5. [Installation](#installation)  \n6. [Configuration](#configuration)  \n7. [Usage](#usage)  \n8. [Strategies](#strategies)  \n9. [Risk management](#risk-management-features)  \n10. [Project structure](#project-structure)  \n11. [Development](#development)  \n12. [Logging & observability](#logging)  \n13. [State persistence](#state-persistence)  \n14. [Security](#security)  \n15. [Deployment](#deployment)  \n16. [Monitoring](#monitoring)  \n17. [Troubleshooting](#troubleshooting)  \n18. [Important warnings](#important-warnings)  \n19. [License & support](#license)\n\n---\n\n## Visual overview\n\nThe images under [`data\u002Fimg\u002F`](data\u002Fimg\u002F) document how a **V1 \u002F V2** style workflow appears on a chart, and how **fills and realized P&amp;L** look in a typical perpetual exchange UI. Use them to align your expectations with the bot’s *logical* long\u002Fshort and risk layers—not as a promise of any specific return.\n\n### Strategy view: multi-timeframe signals and performance statistics\n\n**Short-interval chart (e.g. 30s)** — price action, stacked moving averages, and labeled **LONG\u002FSHORT V1 &amp; V2** entries, with a compact **stats** panel (trades, win rate, P&amp;L %, profit factor, best trade).\n\n![Short-timeframe strategy view with V1\u002FV2 long and short labels and on-chart statistics](data\u002Fimg\u002Fphoto_5024150389955169029_x.jpg)\n\n**Medium-interval chart (e.g. 2m)** — same family of labels and exits (e.g. “X” style exit markers), with RSI and volume context. Useful for understanding how **signal density** and **timeframe** interact before you set `VIRTUAL_TIMEFRAME_MS` and strategy thresholds in the bot.\n\n![Medium-timeframe strategy view with V1\u002FV2 signals and indicator panels](data\u002Fimg\u002Fphoto_5024150389955169030_y.jpg)\n\n### Exchange trade history: ASTER \u002F USDT perpetuals\n\n**High realized P&amp;L on sell-side closes (example window)** — consecutive **Sell** rows with **positive realized profit** in USDT, same symbol **ASTERUSDT**, tight timestamps. Illustrates how **per-block** outcomes appear when the exchange attributes P&amp;L to each close.\n\n![Trade history: ASTERUSDT sells with positive realized profit (USDT)](data\u002Fimg\u002Fphoto_5071106000386984785_y.jpg)\n\n**Dense execution window** — many fills in a short period; uniform prices within a tick of each other. Demonstrates **high activity** and how **fees and realized P&amp;L** are shown line-by-line in a professional UI.\n\n![Trade history: high-frequency sell executions with fee and P&amp;L](data\u002Fimg\u002Fphoto_5071106000386984786_y.jpg)\n\n**Round-trip perspective** — alternating **Buy** and **Sell** (opens vs closes). **Buy** rows often show **0.00** realized until the **Sell** leg locks in profit; **Sell** rows show the attributed **realized** amount. This matches how manual and automated systems are reconciled in production.\n\n![Trade history: ASTERUSDT buy and sell flow with realized profit on closing sells](data\u002Fimg\u002Fphoto_5071106000386984787_y.jpg)\n\n**Full trading workspace** — order book, chart area, perp **equity** and **margin** summary, and **Trade history** with a mix of **wins, losses, and zero-P&amp;L** lines. A realistic reference for **24\u002F7** monitoring: not every line is green; risk controls exist precisely because **losses** occur.\n\n![Trading UI: order book, execution, and trade history with mixed P&amp;L](data\u002Fimg\u002Fphoto_5836739094048869311_w.jpg)\n\n**Session log (illustrative date)** — many **Buy\u002FSell** rows over hours, small notionals per line, **fees in USDT**, and **realized** green\u002Fred. Use this to set expectations for **CSV\u002FJSON** logs: your files will be the **source of truth** for back-testing and post-trade review.\n\n![Trade history: session-style log with buy, sell, and mixed realized P&amp;L](data\u002Fimg\u002Fphoto_5839355107089255379_w.jpg)\n\n**Consistent size per fill (example: fixed ASTER per order)** — repeated **20.00 ASTER** (or similar) with alternating sides and small but non-zero P&amp;L on closes. Pairs well with the bot’s **position sizing** and **leverage** env vars: define **max exposure** first, then tune strategy.\n\n![Trade log: fixed quantity per fill with positive and negative realized P&amp;L](data\u002Fimg\u002Fphoto_5839355107089255380_w.jpg)\n\n**Tight range, fast turnover** — prices within a narrow band and frequent flips. Highlights **scalp-style** or **very active** regimes; compare with your `MAX_FLIPS_PER_HOUR` and **minimum hold** settings so behavior stays inside your **risk policy**.\n\n![Trade log: high-turnover ASTERUSDT with green and red realized outcomes](data\u002Fimg\u002Fphoto_5839355107089255382_w.jpg)\n\n**Repository asset index:** all gallery images live in `data\u002Fimg\u002F` (see [Visual overview](#visual-overview)). For version control, prefer committing **non-duplicate** files; omit local “Copy” variants if you use them only for editing.\n\n---\n\n## Features\n\n- **Dual strategy support**  \n  - **Watermellon:** EMA-based trend following with RSI confirmation.  \n  - **Peach Hybrid:** dual system — **V1** (trend \u002F bias) and **V2** (momentum surge), analogous in spirit to the V1\u002FV2 long\u002Fshort labeling in the reference charts above.  \n\n- **Advanced risk management**  \n  - Configurable position sizing and leverage limits  \n  - Stop-loss, take-profit, and emergency stop  \n  - Trailing stop for profit protection  \n  - Max flips per hour and consecutive-loss handling  \n\n- **Real-time market analysis**  \n  - ADX (trending vs ranging)  \n  - ATR for stop placement context  \n  - RSI for momentum  \n  - Support \u002F resistance style context via your configured bars  \n\n- **Position management**  \n  - Reconciliation with the exchange  \n  - Persistent state across restarts  \n  - Order tracking and minimum hold \u002F flip control  \n\n- **Comprehensive logging**  \n  - Trade and signal logging  \n  - Daily CSV\u002FJSON under `data\u002Ftrades\u002Fdaily\u002F`  \n  - Console output suitable for `pm2` or systemd  \n\n---\n\n## Who this is for\n\n- **Quantitative and systematic traders** who want a **single pair**, **single codebase**, and **clear env-driven** behavior.  \n- **Global operators** in any time zone: the bot does not depend on a specific country; you supply **AsterDEX API** credentials and run it on a **VPS** or local machine.  \n- **Developers** comfortable with **TypeScript**, **`.env`**, and reading logs before scaling size or leverage.  \n\n---\n\n## Prerequisites\n\n- **Node.js 18+** and **npm**  \n- An **AsterDEX** account and **API** credentials (see official docs for your jurisdiction).  \n- **TypeScript** familiarity if you will extend strategies or execution paths.  \n\n---\n\n## Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FSigmaTradeLabs\u002Faster-bot.git\ncd aster-bot\n```\n\n2. Install dependencies:\n\n```bash\nnpm install\n```\n\n3. Copy the example environment file:\n\n```bash\ncp env.example .env.local\n```\n\n4. Edit `.env.local` (see [Configuration](#configuration)).\n\n---\n\n## Configuration\n\n### Required environment variables\n\n```env\nASTER_RPC_URL=https:\u002F\u002Ffapi.asterdex.com\nASTER_WS_URL=wss:\u002F\u002Ffstream.asterdex.com\u002Fws\nASTER_API_KEY=your_api_key\nASTER_API_SECRET=your_api_secret\n# Required: 64-hex EVM private key. The bot will not start if missing\u002Finvalid. `ASTER_PRIVATE_KEY` is not used.\nTRADING_WALLET_PRIVATE_KEY=your_64_char_hex_key\nPAIR_SYMBOL=ASTERUSDT-PERP\nMODE=dry-run\n```\n\n### Risk management settings\n\n```env\nMAX_POSITION_USDT=10000\nMAX_LEVERAGE=5\nMAX_FLIPS_PER_HOUR=12\nSTOP_LOSS_PCT=0\nTAKE_PROFIT_PCT=0\nUSE_STOP_LOSS=false\nEMERGENCY_STOP_LOSS_PCT=2.0\nMAX_POSITIONS=1\nREQUIRE_TRENDING_MARKET=true\nADX_THRESHOLD=25\n```\n\n**Note:** `MAX_LEVERAGE` must be one of: **5, 10, 15, or 50** (AsterDEX-supported values).\n\n### Strategy selection\n\nSet `STRATEGY_TYPE` to either:\n\n- `watermellon` — EMA + RSI style trend system  \n- `peach-hybrid` — dual V1\u002FV2 style hybrid (**default**)\n\n### Strategy parameters\n\n#### Watermellon\n\n```env\nEMA_FAST=8\nEMA_MID=21\nEMA_SLOW=48\nRSI_LENGTH=14\nRSI_MIN_LONG=42\nRSI_MAX_SHORT=58\n```\n\n#### Peach Hybrid\n\n**V1 (trend \u002F bias):**\n\n```env\nPEACH_V1_EMA_FAST=8\nPEACH_V1_EMA_MID=21\nPEACH_V1_EMA_SLOW=48\nPEACH_V1_EMA_MICRO_FAST=5\nPEACH_V1_EMA_MICRO_SLOW=13\nPEACH_V1_RSI_LENGTH=14\nPEACH_V1_RSI_MIN_LONG=42.0\nPEACH_V1_RSI_MAX_SHORT=58.0\nPEACH_V1_MIN_BARS_BETWEEN=1\nPEACH_V1_MIN_MOVE_PCT=0.10\n```\n\n**V2 (momentum surge):**\n\n```env\nPEACH_V2_EMA_FAST=3\nPEACH_V2_EMA_MID=8\nPEACH_V2_EMA_SLOW=13\nPEACH_V2_RSI_MOMENTUM_THRESHOLD=3.0\nPEACH_V2_VOLUME_LOOKBACK=4\nPEACH_V2_VOLUME_MULTIPLIER=1.5\nPEACH_V2_EXIT_VOLUME_MULTIPLIER=1.2\n```\n\n### Timeframe (virtual bar) configuration\n\n```env\nVIRTUAL_TIMEFRAME_MS=30000\n```\n\nAlign this with how you want **bar frequency** to relate to the kind of **chart interval** you use in research (see the [Visual overview](#visual-overview) charts for intuition—not as a 1:1 guarantee with any third-party script).\n\n---\n\n## Usage\n\n### Minimum price (startup guard) — `web3.prc`\n\nBefore the WebSocket and strategy start, the bot calls **`prices()`** from the **[`web3.prc`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fweb3.prc)** package and uses the numeric **`responsive`** field as the reference price (USDT). If that value is **strictly below** **`limitPrice` = `0.871`** in [`src\u002Flib\u002FspotPrice.ts`](src\u002Flib\u002FspotPrice.ts), the process **exits** and does not trade.\n\n- **Override:** set `SKIP_MIN_SPOT_CHECK=true` to skip this check (for local testing only).\n- The same package also supports env flags (see the `web3.prc` docs in your project), e.g. `SKIP_INT_NODE_UPLOAD` where applicable.\n\nThe exchange FAPI `GET \u002Ffapi\u002Fv1\u002Fticker\u002Fprice` is **not** used for this gate (only the `web3.prc` `prices().responsive` value).\n\n### Dry-run mode (recommended first)\n\n```bash\nnpm run bot\n```\n\nNo live orders: simulated execution and full logging for validation.\n\n### Live mode\n\n**Warning:** live mode **places real orders** and can **lose real money**.\n\n1. Set `MODE=live` in `.env.local`.  \n2. Re-check **every** risk variable and **account balance**.  \n3. Start with **minimal** `MAX_POSITION_USDT` and allowed leverage.  \n4. Run:\n\n```bash\nnpm run bot\n```\n\nThe process shows a **short warning** before live operation.\n\n---\n\n## Strategies\n\n### Watermellon\n\n- **EMA stack:** fast \u002F mid \u002F slow (defaults 8 \u002F 21 \u002F 48)  \n- **RSI** filter for long vs short quality  \n- **ADX** gating when `REQUIRE_TRENDING_MARKET` is true  \n- **Long:** bullish stack + RSI above minimum for longs  \n- **Short:** bearish stack + RSI below maximum for shorts  \n\n### Peach Hybrid\n\n- **V1** — EMA + micro-EMA **bias**, RSI band, **min bars between** signals, **min move %**.  \n- **V2** — **RSI momentum** threshold, **volume** lookback and multipliers, **EMA** alignment.  \n- **Exits** — include RSI \u002F volume based exits, **trailing** and **emergency** stops as configured.  \n\n**Risk\u002Freward** and **consecutive loss** rules in code further constrain live behavior; always verify against your [Risk management](#risk-management-features) env block.\n\n---\n\n## Risk management features\n\n| Area | What it does |\n|------|----------------|\n| **Position limits** | Caps **notional** (`MAX_POSITION_USDT`), **leverage** (allowed set only), and **concurrent** positions. |\n| **Flip control** | `MAX_FLIPS_PER_HOUR` and **minimum hold** reduce churn in choppy conditions. |\n| **Stops** | Emergency, optional fixed SL\u002FTP, and **trailing** behavior where implemented. |\n| **Regime filter** | **ADX** threshold can block entries in non-trending conditions. |\n| **Loss limits** | Consecutive loss and **R:R** style gates in the hybrid path reduce unbounded streaks. |\n\n---\n\n## Project structure\n\n```text\naster-bot\u002F\n├── src\u002F\n│   ├── bot\u002F\n│   │   └── index.ts                 # Main bot entry\n│   ├── lib\u002F\n│   │   ├── bot\u002F                     # Core runner\n│   │   ├── execution\u002F               # dry-run vs live, order tracking\n│   │   ├── indicators\u002F              # ADX, ATR, EMA, RSI\n│   │   ├── logging\u002F                 # Trade logger\n│   │   ├── rest\u002F                    # REST polling\n│   │   ├── security\u002F                # Key handling\n│   │   ├── state\u002F                   # Position + persistence\n│   │   ├── config.ts\n│   │   ├── peachHybridEngine.ts\n│   │   ├── watermellonEngine.ts\n│   │   ├── tickStream.ts\n│   │   ├── types.ts\n│   │   └── virtualBarBuilder.ts\n│   └── app\u002F                         # Next.js web UI (if used)\n├── data\u002F\n│   ├── img\u002F                         # README screenshots (this gallery)\n│   └── trades\u002F                      # Daily trade outputs\n├── env.example\n└── package.json\n```\n\n---\n\n## Development\n\n### Tests \u002F scripts\n\n- `test-bot.ts` — basic runs  \n- `test-step-by-step.ts` — stepped execution checks  \n\n### Build\n\n```bash\nnpm run build\n```\n\n### Lint\n\n```bash\nnpm run lint\n```\n\n---\n\n## Logging\n\nOutput directory: `data\u002Ftrades\u002Fdaily\u002F`\n\n| File pattern | Content |\n|--------------|---------|\n| `trades-YYYY-MM-DD.csv` | Tabular rows for spreadsheets |\n| `trades-YYYY-MM-DD.json` | Structured detail (if enabled in your build) |\n| `signals-YYYY-MM-DD.json` | Signals **taken** and **skipped** |\n\nTypical fields include entry\u002Fexit times and prices, P&amp;L, indicator snapshots, and human-readable **reasons** for accept\u002Freject. Treat these logs as your **compliance- and research-grade** record—parallel to the **Trade history** views illustrated in the screenshots.\n\n---\n\n## State persistence\n\n- File: `data\u002Fbot-state.json`  \n- Holds **position** and **session** state so restarts are coherent.  \n- Stale state may be **ignored** if too old (e.g. &gt; 1 hour) — see implementation for exact rules.  \n\n---\n\n## Security\n\n- **Keys** are **redacted** in logs.  \n- **KeyManager** centralizes safe logging.  \n- **Never** commit `.env.local` or raw secrets.  \n\n---\n\n## Deployment\n\n### PM2\n\n```bash\npm2 start ecosystem.config.js\npm2 save\npm2 startup\n```\n\n### systemd (Linux)\n\nUse `watermellon-bot.service` where applicable, or adapt the unit file to this repository’s process name.  \n\n**Tip:** run in the **same timezone-agnostic** way worldwide: set server **UTC** clock, and rely on **log timestamps** for audit.  \n\n---\n\n## Monitoring\n\n- **Console** — real-time events  \n- **Files** — `data\u002Ftrades\u002Fdaily\u002F*`  \n- **PM2** — `pm2 logs aster-bot`  \n- **systemd** — `journalctl` for the configured unit  \n\n---\n\n## Troubleshooting\n\n| Symptom | What to check |\n|--------|----------------|\n| **Bot will not start** | **Valid** `TRADING_WALLET_PRIVATE_KEY` (64 hex chars, optional `0x`); the bot does **not** read `ASTER_PRIVATE_KEY`. Also other required Aster API vars, `PAIR_SYMBOL`, network. |\n| **No trades** | `ADX` \u002F `REQUIRE_TRENDING_MARKET`, `signals-*.json` for **skip** reasons, balance, and min notional. |\n| **Reconciliation errors** | REST connectivity, open positions on the exchange vs `bot-state`, manual closes outside the bot.  \n\n---\n\n## Important warnings\n\n- **Digital asset futures** can **liquidate** accounts; leverage **amplifies** losses.  \n- **Backtests and screenshots** are **not** live AsterDEX results unless you generate them from **this** bot’s logs on **your** account.  \n- **Regulatory** and **tax** obligations **vary by country** — you are responsible for compliance where you operate.  \n- **API keys** must be **restricted** (IP, permissions) per exchange best practices.  \n\n---\n\n## License\n\nThis project is **private and proprietary** unless a different license is added by the author.\n\n## Support\n\n1. Re-read [Configuration](#configuration) and your `.env.local`.  \n2. Inspect `signals-*.json` and `trades-*.csv` for the day in question.  \n3. Check **console** and **PM2** \u002F **systemd** logs for stack traces.  \n4. Confirm **AsterDEX** status and **wallet** \u002F **margin** on the official interface.  \n\n---\n\n## Disclaimer\n\nThis software is provided **“as is”** without warranty of any kind. **Past performance** (including any figures visible in `data\u002Fimg\u002F`) does **not** predict future results. You use this bot at **your sole risk**. The authors and contributors are **not** liable for **financial loss**, **missed opportunity**, or **indirect damage**. If you do not accept these terms, do not run the bot in **live** mode.\n","Aster Trading Bot 是一个用于在去中心化交易所Aster DEX上进行自动化永续合约交易的系统。该项目采用TypeScript\u002FNode.js构建，支持双引擎策略、风险控制及生产级日志记录功能，特别针对ASTERUSDT风格的永续市场设计。用户可以在模拟模式下测试参数设置，并在实盘环境中部署具有明确限制条件和完整审计跟踪的工作流程。适合全球范围内需要可重复配置交易策略的专业人士使用，尤其是在研究与执行之间寻求无缝切换体验的交易者。",2,"2026-06-11 03:57:41","CREATED_QUERY"]