Engine

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

From strategy configuration to executionApp configuration and historical or live market data feed a stage session. Its frame runner invokes L3, SJS, the applicable L2 and L1 algorithms, and native Pine. Execution requests pass automation controls and the L3 intent gate before the simulator or broker handles them. Results update session state. L3-originated requests bypass the L3 intent gate; manual requests override its decision.App configurationMarket dataStage sessionFrame processingExecution requestsExecution controlsSimulator or brokerInstrument · source · models · settingsHistorical replay or live feedCurrent bar · algorithms · orders · positions · stateL3 frame hook → SJS → applicable L2 / L1 → native PineOptional paths; policy actions can originate in the L3 hookPlace · modify · cancel · closeAutomation controls → L3 intent gate, with source-specific rulesOrder outcomes · fills · trades · updated session stateConceptual flow; requests can occur during frame processing.
Execution results feed back into the session. An accepted request is not a confirmed fill.

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

PieceResponsibilityWhere to learn more
AppSaved source, instrument, models, and execution settingsApps
Stage sessionRuntime context, positions, orders, logs, and stateGetting started
SJSMain algorithm, signals, state, entries, and exitsSJS guides
SQXDeclarative conditions and configured primitive actionsSQX guides
Pine ScriptCalculations, plots, signals, and supported strategy ordersPine Script guides
Algorithms and primitivesConfigured analysis and actionsPrimitives
L3 policiesModular frame decisions and execution checksPolicies

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

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.

On this page