Engine
Understand how market data, strategy code, policies, and execution work together.
The Stoqey engine runs your strategy inside a stage session: a running app instance with its own instrument, market data, algorithms, orders, positions, and strategy state. The app describes what to run; the session owns what happens during a run.
You can combine SJS strategy code, Pine Script, configured algorithms, and optional L3 policies. You do not need an AI provider to use policies: a policy can be an ordinary deterministic function.
Start with SJS for the main algorithm: signals, state, entries, and exits. Add L3 when you need higher-level coordination or execution checks.
Engine at a glance
In reading order: configuration and data create the session context; strategy paths inspect that context and request actions; execution controls decide whether those requests can proceed; the simulator or broker produces outcomes that subsequent decisions can inspect.
The diagram summarizes the shared frame runner. Session preparation and data updates surround that runner, and optional paths depend on your app configuration. See Execution flow for ordering and gate exceptions.
The pieces you work with
| Piece | Responsibility | Where to learn more |
|---|---|---|
| App | Saved source, instrument, models, and execution settings | Apps |
| Stage session | Runtime context, positions, orders, logs, and state | Getting started |
| SJS | Main algorithm, signals, state, entries, and exits | SJS guides |
| SQX | Declarative conditions and configured primitive actions | SQX guides |
| Pine Script | Calculations, plots, signals, and supported strategy orders | Pine Script guides |
| Algorithms and primitives | Configured analysis and actions | Primitives |
| L3 policies | Modular frame decisions and execution checks | Policies |
Where Agent Lab fits
Agent Lab helps you edit strategy source, save revisions, run historical experiments, and inspect results. The historical worker uses the engine runtime. The AI assisting with authoring is separate from an L3 script making model calls while a strategy runs.
Start with a deterministic SJS strategy so you can explain each result using its inputs, state, and decision. Add policies when oversight is useful. Publishing a Lab revision creates or updates an app; launching that app is a separate step.
Choose a starting point
- New to the runtime? Read Engine getting started.
- Writing your main algorithm? Build your first SJS strategy.
- Understanding strategy inputs? Read the market-data guides.
- Managing execution? Read Orders & Positions.
- Combining calculations and configured models? Read Indicators & Algorithms.
- Evaluating a strategy? Follow the backtesting guides.
- Adding advanced coordination? Read Advanced L3.
- Writing modular decision logic? Build your first policy.
- Investigating an unexpected order? Follow Execution flow and Policy debugging.
For parameter catalogs and known metadata differences, use the reference guide. Compare environments in the capability matrix, or look up shared terms in the glossary.