Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trading Order

Autonomous multi-strategy algorithmic trading system for Indian markets (NSE), built with Node.js.
It combines market data, curated financial news sentiment, and Anthropic Claude-based decision logic with strict risk controls and paper-trading analytics.

Features

  • Multi-strategy decisioning for F&O intraday and equity swing logic.
  • Claude-powered macro bias, sentiment scoring, and trade recommendations.
  • Curated financial news ingestion (CNBC-TV18, ET, Mint, Moneycontrol, NSE, and more via domain filters).
  • Strict risk framework: per-trade allocation cap, mandatory SL/TP, and daily drawdown halt.
  • IST market scheduler (pre-market, live loop, square-off, post-market analysis).
  • Paper-trading mode with deep JSONL telemetry and daily analytics reports.
  • Optional Redis-backed state store (falls back to in-memory).

Architecture

  • src/app.js: Bootstrap and dependency wiring.
  • src/scheduler.js: Indian market-hours cron orchestration.
  • src/tradingEngine.js: Core execution loop, paper/live handling, risk checks, logging.
  • src/aiEngine.js: Anthropic client and strict JSON response parsing.
  • src/growwClient.js: Groww REST integration with exponential backoff.
  • src/newsClient.js: Multi-provider + curated-domain financial news collector.
  • src/riskManager.js: Position sizing, SL/TP enforcement, drawdown checks.
  • src/store.js: In-memory/Redis state for positions and daily trading context.

Requirements

  • Node.js >=18.18.0 (recommended)
  • npm
  • API keys for Anthropic + News provider(s)
  • Groww credentials for live market data / live execution

Note: On older Node versions, npm run dev may fail due to --watch. Use npm start.

Setup

  1. Install dependencies:
npm install
  1. Copy and configure environment variables:
cp .env.example .env
  1. Update required keys in .env:
  • ANTHROPIC_API_KEY
  • NEWSAPI_KEY (for curated/newsapi mode)
  • Groww keys/tokens for market data or live execution

Run

Production mode:

npm start

Development mode (Node 18+):

npm run dev

Paper Trading (Safe Testing)

Set in .env:

ENABLE_LIVE_TRADING=false
PAPER_TRADING=true
PAPER_TRADING_SLIPPAGE_PCT=0.05

Then run:

npm start

Paper mode behavior:

  • Simulates order placement and square-off.
  • Tracks positions and realized PnL in internal state.
  • Produces structured logs for analysis.

Logging & Analytics Outputs

  • paper_trades.jsonl: Paper order + square-off events.
  • deep_analysis.jsonl: Per-cycle telemetry, API timings, decisions, rejections, risk events.
  • paper_daily_report.jsonl: End-of-day summary metrics (PnL, win rate, profit factor, etc.).

These files are ignored by git via .gitignore.

Scheduler Windows (IST)

  • 08:30 Pre-market: macro scan + news analysis.
  • 09:15 to 15:30 Live cycle loop.
  • 15:15 Intraday/F&O forced square-off.
  • 15:30 to 17:00 Post-market reporting windows.

Risk Controls

  • Max trading capital from MAX_TRADING_AMOUNT.
  • Single high-risk F&O trade allocation capped at 10% (or lower if configured).
  • Mandatory stop-loss and target enforcement on each trade.
  • Global halt when daily drawdown breaches DAILY_MAX_DRAWDOWN_PCT.

Important Notes

  • Groww endpoints in the client are scaffold-style and may need alignment with your exact broker API contract.
  • This project is for educational/research use. Validate thoroughly in paper mode before enabling live trading.
  • You are responsible for regulatory and broker compliance.

About

Node.js algo-trading bot for Indian markets with Claude AI signals, curated news sentiment, risk-first execution, and paper-trading logs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages