Agent code (STSE)
Every Obside agent is backed by a small piece of code that the platform runs for you. Most people never see it: you describe what you want in plain language and Obside writes, checks and runs the code. But if you are a developer, or you connect a coding assistant like Claude Code or Codex through the AI connections (MCP), you can write that code yourself and hand it to Obside.
This section documents the agent runtime, the same one the assistant targets, so a coding agent can build strategies faithfully. Obside calls this engine STSE.
The mental model
Your code is the body of one function that receives a single object called manager. You never write the function wrapper or any import. Everything you need is already in scope: the manager object, every technical indicator and helper, the engine types, the z schema helper, and the Luxon date classes (DateTime, Duration, Interval). Writing an import is an error, and so is declaring your own variable with one of those names.
Think of the code as running in two phases.
Root phase (runs once, at startup). This is the top level of your code. Here you set things up: you create indicators, you read launch settings, and you attach listeners that say "when this happens, run that". You do not place orders or read live prices here, because at startup there is no "now" yet.
Callback phase (runs many times, later). Each listener you attached runs its callback whenever its event fires: a candle closes, a schedule ticks, a trade fills. Inside a callback you read values (getValue()), read the current time and price, and take actions (place an order, open or close a trade, send a notification).
The rule that follows from this: construct indicators and attach every listener at the root; read values and act only inside callbacks.
Assets are not in the code
Your code refers to an asset by a short symbol string you choose, for example 'BTC' or 'AAPL'. The mapping from that symbol to a real, tradable listing is decided separately when the agent runs (in a backtest or a live run), not written into the code. When you create an agent you declare, alongside the code, which real asset each symbol stands for. This is what lets one agent run on Binance in a backtest and on your broker live without any code change.
You never put an exchange-prefixed ticker or an internal identifier in the code. Just the short symbol.
A minimal example
An agent that buys a little Bitcoin every Monday morning:
const symbol = 'BTC';
// Root: subscribe to the price feed so a scheduled callback can act on this symbol.
manager.onPreciseCandle(symbol, () => {});
// Root: attach a weekly schedule.
manager.cron('0 9 * * 1', () => {
// Callback: this runs every Monday at 09:00.
manager.placeOrder({
symbol,
type: 'MARKET',
position: 'buy',
amount: 50,
amountCurrency: 'USD',
});
}, 'UTC');
An agent that watches an indicator and alerts you once:
const symbol = 'ETH';
const candles = manager.getIntervalData(symbol, 60); // 60-minute candles
const rsi = new RSI(new PartialIndicator(candles, 'close'), 14);
manager.onIntervalCandle(symbol, 60, () => {
if (!rsi.hasValue()) return;
const value = rsi.getValue();
if (value === undefined || value > 30) return;
manager.sendNotification(`ETH RSI is ${value.toFixed(1)}, below 30.`);
manager.stop();
});
The lifecycle
- Write the code (this section is your reference).
- Validate it: the deterministic checker reports type and rule errors so you can fix them before spending anything. Over the MCP connection this is the
validate_agent_codetool. - Create the agent from your intent, optionally seeding it with your validated code. Obside resolves the assets, reviews the code and persists the agent (
create_agent). - Backtest it over history, or run it live or in paper mode, and read the results.
Every complete code block in this section is compiled by the real validator as part of Obside's test suite, so what you copy passes as written. Blocks marked as fragments are partial code, and blocks under "refused" in the Validation rules are rejected on purpose.
Where to go next
Read in this order when writing your first agent:
- Structure and lifecycle: the root and callback phases, listeners, time zones, state, launch variables.
- Manager API: every method, with its exact signature and behaviour in backtests and live runs.
- Indicators and the Indicator reference: every indicator class, its constructor, value and warm-up.
- Orders, trades and risk: sizing, capital and auto-invest, rebalancing, stops.
- Schedules and launch actions: cron, acting at launch, period keys.
- News, data and AI: news, account follows, fundamentals, language models, notifications.
- Validation rules: every rule the checker enforces, with a refused example and the accepted rewrite.
- Examples: complete agents for the common shapes.
Reference pages: Types (every object shape), Helpers (utility functions in scope), Pitfalls (a pre-submit checklist).
- Build with Claude Code and Codex: the end-to-end workflow over MCP, plus the reusable skill.