How sainikhil573/crypto-agent works
Purpose and Entry Points
CryptoAgent is a Node.js crypto-futures signal scanner and browser dashboard. It scans roughly the top 30 instruments, evaluates technical signals, persists trade candidates and outcomes, and can alert a human operator via Telegram. The runtime starts at server.js; the self-contained UI is index.html; REST routes are defined in backend/api.js.
HTTP Server, Dashboard, and Proxy Boundary
server.js hosts the static dashboard, exposes health checking, serves API routes, proxies OKX data to avoid browser CORS restrictions, and fetches/caches crypto RSS news. The browser is intentionally thin and has no build pipeline:
• server.js
• index.html
• backend/api.js
External-facing boundaries are the dashboard/API consumer, OKX v5 market-data API, RSS sources, and deployment health endpoint /api/health.
Scheduled Signal Pipeline
The scanner is the primary control loop: a five-minute cron job obtains futures market data, runs analysis, records qualifying signals, sends alerts, and monitors signal performance. It is the orchestration point between acquisition, analysis, persistence, and notification:
• backend/scanner.js
• backend/fetcher.js
• backend/analysis.js
A human remains responsible for making trades and later marking outcomes; the system does not execute orders.
Market Data Acquisition
backend/fetcher.js encapsulates retrieval of OKX v5 exchange data used by scanning and analysis. server.js also acts as an OKX proxy for browser-originated requests. This separates exchange-specific network handling from signal logic:
• backend/fetcher.js
• server.js
The exchange dependency is OKX v5, selected in part for availability from the stated deployment geography.
Signal Analysis Engine
backend/analysis.js implements the ten-layer technical-analysis engine that turns fetched market data into candidate futures signals. Its results feed scanner qualification/alerting and stored signal records:
• backend/analysis.js
• backend/scanner.js
Optional Claude/Anthropic macro analysis is enabled through ANTHROPIC_API_KEY; core operation can run without it.
Persistence, Outcomes, and Validation
SQLite is the system of record for signals, manually supplied WIN/LOSS/BREAKEVEN outcomes, and backtest results. The database uses WAL mode and is accessed through a dedicated data module:
• backend/db.js
• backend/backtester.js
• backend/api.js
The backtester evaluates historical performance and identifies disabled or caution patterns. API endpoints expose active/history views, aggregate stats, manual outcome updates, and explicit backtest execution.
Notifications and Deployment
Telegram is an optional outbound alert channel invoked by the scanner, controlled by TG_BOT_TOKEN and TG_CHAT_ID:
• backend/scanner.js
• .env.example
The application is containerized and deployable as a single web service on Railway or Render. Persistent SQLite storage must be considered when selecting platform storage behavior:
• Dockerfile
• railway.toml
• render.yaml
Main entry points: server.js HTTP Server · scanner.js Five-Minute Scanner · api.js REST API · db.js Data Module
Components 16
Web & API
- Browser Dashboard · Thin self-contained operator dashboard.
index.html - HTTP Server · Serves UI, health, API, OKX proxy, and cached news.
server.js - REST API · Provides signals, stats, outcomes, and backtest endpoints.
backend/api.js - Health Endpoint
server.js
Signal Pipeline
- Five-Minute Scanner · Qualifies signals, alerts operators, and monitors performance.
backend/scanner.js - Market Fetcher
backend/fetcher.js - Technical Analysis · Ten-layer engine producing futures candidates.
backend/analysis.js
Records & Evaluation
- Backtester · Identifies disabled and caution patterns.
backend/backtester.js - Data Module · Dedicated WAL-mode data access.
backend/db.js - SQLite Records · Stores signals, outcomes, and backtest results.
External Services
- OKX v5
- RSS Sources
- Telegram · Optional outbound signal alerts.
- Anthropic Claude · Enabled only when an API key is configured.
Other components
- Human Operator · Makes trades and manually records outcomes.
- Container Deployment · Deployable to Railway or Render; persistent SQLite storage is required.
Dockerfile
Connections 18
- Browser Dashboard → HTTP Server: loads UI and calls API
- HTTP Server → REST API: routes requests
- HTTP Server → Health Endpoint: serves
- HTTP Server → OKX v5: browser CORS proxy
- HTTP Server → RSS Sources: fetches and caches news
- REST API → Data Module: reads and updates records
- REST API → Backtester: runs on request
- Five-Minute Scanner → Market Fetcher: gets futures data
- Market Fetcher → OKX v5: retrieves market data
- Five-Minute Scanner → Technical Analysis: evaluates instruments
- Technical Analysis → Anthropic Claude: optional macro context
- Five-Minute Scanner → Data Module: records candidates and performance
- Five-Minute Scanner → Telegram: sends qualifying alerts
- Data Module → SQLite Records: persists
- Backtester → Data Module: uses history and saves results
- Human Operator → Browser Dashboard: reviews signals
- Human Operator → REST API: marks WIN/LOSS/BREAKEVEN
- Container Deployment → HTTP Server: runs