Dexter is an autonomous long-only trading agent that thinks, plans, and iterates as it builds conviction. It plans tasks, inspects quantitative edges, and produces risk-aware playbooks designed to maximize upside while protecting capital.
Dexter turns ambitious return targets into sequenced trading workflows. It pulls market data from free sources, validates fundamentals, quantifies technical momentum, and returns a ready-to-execute long thesis with position sizing and risk notes.
Key Capabilities:
- Task Planning: Breaks complex trading prompts into targeted data pulls and analyses.
- Market Data Access: Uses Yahoo Finance (no paid key needed) for prices and fundamentals.
- Long Strategy Analytics: Evaluates moving-average crossover performance versus benchmarks.
- Risk Management Guidance: Surfaces volatility, drawdown, and monitoring triggers.
- Safety Features: Built-in loop detection and step caps prevent runaway execution.
- Python 3.10 or higher
- uv package manager
- xAI API key with access to Grok 4 (get here)
(Optional: setDEXTER_LLM_PROVIDER=openaito use OpenAI instead) - No paid market data key required (Yahoo Finance powers the trading tools)
- Clone the repository:
git clone https://github.com/virattt/dexter.git
cd dexter- Install dependencies with uv:
uv sync- Set up your environment variables:
# Copy the example environment file
cp env.example .env
# Edit .env and add your API keys
# DEXTER_LLM_PROVIDER=xai
# XAI_API_KEY=your-xai-api-key
# XAI_MODEL=grok-4-fast-reasoning
# (Optional) configure the OPENAI_* variables if you want to use OpenAI instead
# No market data key required (Yahoo Finance)Run Dexter in interactive mode:
uv run dexter-agentTry asking Dexter questions like:
- "Build a long plan for NVDA that maximizes risk-adjusted returns."
- "Is MSFT still a buy if I'm targeting 15% annualized with limited drawdowns?"
- "Compare AAPL versus SPY and tell me if now is a good long entry."
- "Identify the best entry plan for META with moving average confirmation."
Dexter will automatically:
- Break your request into market data, fundamentals, and strategy evaluation tasks.
- Fetch prices and fundamentals from Yahoo Finance.
- Quantify trend strength, returns, drawdown, and benchmark advantage.
- Produce an actionable long recommendation with position management guidance.
Dexter uses a multi-agent architecture with specialized components:
- Planning Agent: Breaks a trading question into sequenced data pulls.
- Action Agent: Chooses the right tool (prices, fundamentals, strategy eval) for each step.
- Validation Agent: Confirms when tasks have enough evidence to proceed.
- Answer Agent: Synthesizes the final long recommendation, risks, and execution plan.
dexter/
├── src/
│ ├── dexter/
│ │ ├── agent.py # Main agent orchestration logic
│ │ ├── model.py # LLM interface (Grok 4 by default)
│ │ ├── prompts.py # System prompts for each component
│ │ ├── schemas.py # Pydantic models
│ │ ├── tools/
│ │ │ ├── market_data.py # Yahoo Finance OHLCV access
│ │ │ ├── fundamentals.py # Fundamental snapshot helper
│ │ │ └── long_strategy.py # Long-only strategy evaluation
│ │ ├── utils/ # UI + logging helpers
│ │ └── cli.py # CLI entry point
├── pyproject.toml
└── uv.lock
Dexter supports configuration via the Agent class initialization:
from dexter.agent import Agent
agent = Agent(
max_steps=20, # Global safety limit
max_steps_per_task=5 # Per-task iteration limit
)- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Important: Please keep your pull requests small and focused. This will make it easier to review and merge.
This project is licensed under the MIT License.