Visualize the metrics
CHARTPass the returned series to a chart, a dashboard, or a table.
Arcana is a language for trading strategies. It reads time series, calculates signals and produces metrics and action intents your app can use.
Write it yourself or with your AI. Embed its compiler and runtime in your own application, or use ftw.trade's data and execution.
const close = bars.close("DEMO-USD", "1h");const average = isNa(close[2]) ? na : sma(close, 3);const above = close > average;metric("close", close);metric("average", average);when (above) { signals.publish({ message: "above average", close: close }); }when (!above) { signals.publish({ message: "at or below average", close: close }); }Data keeps arriving. Your strategy waits for a completed bar, checks its rules, then acts or waits.
fast & slowcrossover(fast, slow)!inPosition()EMA crossover · ftw.trade paper strategy ↗
paper.buy({ quote: 100 })A paper buy needs both a cross above and no position.
Spot prices collect into market bars.
Illustrated events, not live data. Each cycle is an independent example on closed bars.Chart its metrics. Inspect its activity. Send structured output to your own app.
Pass the returned series to a chart, a dashboard, or a table.
Build a log from text states and decisions returned by the run.
{
"time": 1767229200,
"close": 100,
"average": null,
"state": "warming up",
"actions": []
}Store a row, publish an event, or expose an API through your host.
Pass the returned series to a chart, a dashboard, or a table.
Build a log from text states and decisions returned by the run.
{
"time": 1767232800,
"close": 102,
"average": null,
"state": "warming up",
"actions": []
}Store a row, publish an event, or expose an API through your host.
Pass the returned series to a chart, a dashboard, or a table.
Build a log from text states and decisions returned by the run.
{
"time": 1767236400,
"close": 104,
"average": 102,
"state": "above average",
"actions": [
"signals.publish"
]
}Store a row, publish an event, or expose an API through your host.
Pass the returned series to a chart, a dashboard, or a table.
Build a log from text states and decisions returned by the run.
{
"time": 1767240000,
"close": 101,
"average": 102.33333333333333,
"state": "at or below average",
"actions": [
"signals.publish"
]
}Store a row, publish an event, or expose an API through your host.
Pass the returned series to a chart, a dashboard, or a table.
Build a log from text states and decisions returned by the run.
{
"time": 1767243600,
"close": 99,
"average": 101.33333333333333,
"state": "at or below average",
"actions": []
}Store a row, publish an event, or expose an API through your host.
Pass the returned series to a chart, a dashboard, or a table.
Build a log from text states and decisions returned by the run.
{
"time": 1767247200,
"close": 105,
"average": 101.66666666666667,
"state": "above average",
"actions": [
"signals.publish"
]
}Store a row, publish an event, or expose an API through your host.
arcana "0.1";
uses { bars: "^1", signals: "^1" }
const close = bars.close("DEMO-USD", "1h");
const average = isNa(close[2]) ? na : sma(close, 3);
const above = close > average;
metric("close", close);
metric("average", average);
metric("state", isNa(average) ? "warming up" : above ? "above average" : "at or below average");
when (above) { signals.publish({ message: "above average", close: close }); }
when (!above) { signals.publish({ message: "at or below average", close: close }); }
The example uses six illustrated hourly closes. Its host declares the price source and signals.publish action. Arcana returns data; your application owns charts, storage, delivery, and execution.
Follow the introduction from top to bottom, or go straight to the part you need.
Compile a complete program against an explicit host and replay an illustrated price sequence with @arcana/core.
02Install the standalone package, declare your own typed sources, evaluate JSONL files or producer pipes, and save and resume a local run.
03Update source files and developer tools while preserving historical programs, signatures and checkpoints.
04Values and series, missing observations, expressions, functions, folds, enums and phases.
05Moving averages, oscillators, windows, sessions, market profile and models over the inputs your host supplies.
06The compiler-owned reference for syntax, types, hosts, actions, functions, diagnostics and runtime semantics.
07Use the compiler and runtime in your own application: declare a host, replay data, step a live run and retain checkpoints.
08Compose and test your own libraries, declare custom data and actions, and feed recorded external model predictions into an incremental strategy.
09Compose primitive actions on confirmed settlement, inspect captured inputs, handle each failed leg and retain uncertain submissions through recovery.
10Choose native or WASM embedding, measure retained evaluation and execution latency, bound memory and queues, and account for ML training and host scheduling.
11Consume evaluated metrics, text and action intents in charts, application logs and your own data consumers, with delivery and storage owned by the host.
Open the editor on ftw.trade, or connect your AI. Check the code, backtest it and run on paper before choosing to use real funds.