How am1403x/financial-agent-india works
This repo is a Python CLI-based “financial analysis agent” (not a web app, not a service) that:
• Authenticates to AngelOne SmartAPI (with API key + client credentials + TOTP) to obtain session/feed tokens
• Fetches market data (cash OHLCV candles; optionally options chain/Greeks)
• Sends structured data to Anthropic Claude API
• Prints a structured technical/options analysis report
• Includes a reference order placement script (dry-run by default)
File tree → architectural components
• config.py
• Configuration/Secrets Loader: reads .env (from .env.example template)
• Outputs: ANGELONE_*, ANTHROPIC_API_KEY
• connect.py
• SmartAPI Auth Session Factory
• Inputs: client ID, password, TOTP secret, API key
• Outputs: authenticated SmartAPI session + session token/feed token
• fetch_data.py
• Market Data Retrieval
• Calls SmartAPI endpoints for 30 days daily OHLCV (per README)
• Output: normalized candle series used by the agent
• agent.py
• Core Agent Orchestrator
• Orchestration flow: connect → fetch candles → create prompt → call Claude → parse/format structured output
• agent_with_options.py
• Enhanced Agent Orchestrator
• Everything in agent.py plus:
• Options Chain Retrieval from SmartAPI (IV, OI, Greeks)
• Combines options signals + price action before calling Claude (or sends both to Claude)
• place_order.py
• Trade Execution Adapter (reference)
• SmartAPI order placement scaffolding (dry-run default)
• requirements.txt
• Dependency boundary indicator (external libs, SmartAPI SDK, Anthropic SDK, dotenv, etc.)
CLI Entry Points
• agent.py
• agent_with_options.py
• fetch_data.py
• connect.py
• place_order.py
Config/Security
• config.py + .env
• Secrets (API keys, password, TOTP secret)
SmartAPI Adapter
• Session/auth generation (from connect.py)
• Data endpoints (candles, option chain)
• Order endpoint (place order)
LLM Adapter
• Claude API call (within agent scripts)
• Prompt construction + response parsing/formatting (within agent scripts)
• AngelOne SmartAPI
• Auth
• Market data (candles, option chain)
• Orders (optional)
• Anthropic Claude API
• Model inference endpoint
• Credentials: API key/clientID/password/TOTP secret
• Session artifacts: session token / feed token
• Market data: OHLCV candle series (30 days daily)
• Options data: chain + IV/OI/Greeks
• Prompt payload: structured JSON/text sent to Claude
• Result: structured analysis (trend/support/resistance/volume + summary)
agent.py calls connect.py to
• Generate TOTP
• Authenticate SmartAPI
• Receive session/feed tokens
agent.py formats and prints report
For agent_with_options.py, insert:
• Fetch options chain from SmartAPI
• Merge options signals + price candles before step 5
For place_order.py, show it as:
• Separate CLI path: load config → connect → (dry-run) → SmartAPI placeOrder()