# LLM Driving - AI-Powered Autonomous Strategy Development and Execution

**Last Updated**: 2026-03-17
**Version**: 1.0.0

## How It Works

### Open the LLM Driving Interface

Navigate to the LLM Driving page from the sidebar. The interface features a workflow table for strategy composition, an LLM provider/model selector, and an Execute section with backtest configuration controls.

### Build Your Strategy Workflow

Use the workflow table to define your trading strategy structure. Add rows for entry conditions, exit conditions, position sizing, and risk management rules. Each row supports multi-select dropdowns for configuring indicators, thresholds, and logical operators.

### Select the LLM Provider and Model

Choose your preferred LLM provider (e.g., OpenAI, Anthropic, DeepSeek) and specific model from the Execute section dropdown. Different models vary in reasoning depth, speed, and cost per request. The selected model will generate and refine the strategy code.

### Configure Backtest Parameters

Set the target asset via the company search field, define the date range for historical backtesting, select the data timeframe (1min to daily), and specify the initial capital amount. These parameters scope the environment where the LLM-generated strategy will be tested.

### Set Loop Count for Iterative Refinement

Configure the total loop count to control how many iterative refinement cycles the LLM performs. Each loop generates strategy code, backtests it, analyzes the results, and uses the performance feedback to improve the next iteration. More loops generally produce better strategies but consume more credits.

### Execute the LLM-Driven Strategy

Click the Execute button to launch the autonomous pipeline. The LLM reads your workflow definition, generates Python strategy code, submits it for backtesting, receives performance metrics, and iteratively refines the code across the configured number of loops.

### Monitor Real-Time Progress via WebSocket

Watch the live progress panel as each iteration completes. The WebSocket connection streams backtest metrics (Sharpe ratio, max drawdown, total return) for every loop. The equity curve updates in real time in the Perspective modal viewer.

### Review Final Results and Generated Code

After all loops complete, review the best-performing iteration's equity curve, performance metrics, and the AI-generated Python strategy code. Compare iterations side by side and save or export the winning strategy for deployment.

> LLM Driving uses large language models to autonomously generate, backtest, and iteratively refine quantitative trading strategies based on your workflow specification.

## Tips & Best Practices

- Start with a clear, specific workflow definition rather than a vague one. LLMs produce significantly better strategies when given concrete entry/exit logic, named indicators, and explicit risk constraints rather than open-ended instructions.

- Use at least 5-10 loops for meaningful iterative improvement. The first 1-2 loops establish a baseline, and subsequent loops refine edge cases, optimize parameters, and improve risk-adjusted returns based on backtest feedback.

- Different LLM models have distinct strengths: larger models like GPT-4 and Claude Opus excel at complex multi-factor strategies, while faster models like GPT-4o-mini work well for simpler momentum or mean-reversion strategies and cost fewer credits per loop.

- Always backtest the final LLM-generated strategy on a separate out-of-sample date range that was not included in the original training window to verify the strategy generalizes beyond the optimization period.

- Monitor credit consumption during execution. Each loop consumes LLM API credits proportional to the model size and context length. Cancel early if the strategy shows no improvement after several consecutive loops.

## Frequently Asked Questions

### How does the iterative loop refinement process work?

In each loop, the LLM generates Python strategy code based on your workflow and any previous performance feedback. The code is sent to the backtesting engine, which returns metrics like Sharpe ratio, max drawdown, and cumulative return. The LLM then analyzes what worked and what did not, and generates improved code for the next loop. This feedback loop continues for the configured number of iterations.

### Which LLM provider and model should I choose?

The choice depends on strategy complexity, speed requirements, and budget. For complex multi-factor strategies, use high-reasoning models like Claude Opus or GPT-4. For rapid prototyping of simple strategies, lighter models like DeepSeek or GPT-4o-mini provide faster results at lower credit cost. You can experiment with different models on the same workflow to compare outputs.

### Can the LLM generate strategies for any asset class?

LLM Driving supports any asset available in the platform's data feeds, including equities, ETFs, indices, and forex pairs. The LLM adapts its strategy logic based on the asset characteristics observed in the historical data. However, strategies may need different indicators and risk parameters for different asset classes.

### What happens if the LLM generates code that fails to execute?

The platform catches code execution errors automatically. When a loop produces invalid or crashing code, the error message is fed back to the LLM in the next iteration so it can debug and fix the issue. This self-correcting mechanism means transient code errors are typically resolved within 1-2 additional loops.

### How do I control credit usage during LLM Driving?

Credit consumption is determined by three factors: the LLM model selected (larger models cost more per request), the number of loops configured, and the context window size. You can reduce costs by using fewer loops, selecting a smaller model, or simplifying your workflow definition. The credits usage is visible in your API Credits page under Settings.

## Important Notes

> AI-generated strategies are produced by probabilistic language models and carry no guarantee of profitability. LLM outputs may contain errors, biases, or overfitted logic. Always validate generated strategies on out-of-sample data and apply proper risk management before any live deployment.

---

Source: https://stratcraft.ai/help/llm-driving/