Docs / Rule language
Rule language
Error messages
A rule that cannot be read or run is a 422, before anything is billed. detail lists every bad question, each pointing at its ask, so one response shows every problem.
Rule errors
One request with eleven broken rules on SPY returned one 422 listing all of them:
| Question | Rule | Message |
|---|---|---|
typo | C > smaa(C, 50) | Unknown function 'smaa()'. Did you mean sma()? |
pattern_typo | hamer() | Unknown function 'hamer()'. Did you mean hammer()? |
state_field | rsi > 70 | No field "rsi" — this request has no named state, only price bars (O, H, L, C, V and the functions). |
arity | C > sma(C) | sma() takes 2 argument(s), got 1. |
zero_period | C > sma(C, 0) | sma(): period must be greater than 0, got 0. |
offset_on_function | sma(C, 20)[-1] > 0 | Unexpected token '[' at column 11 |
incomplete | C > | Unexpected token 'EOF' at column 3 |
unbalanced | (C > O | Expected ')', got 'EOF' at column 6 |
intraday | C > vwap() | vwap() needs intraday bars. Ask for them with "prices": {"interval": "5m"} (or 1m/15m/30m/1h). |
timeframe | C@5m > O@5m | '@5m' needs 5m bars, which this request did not load. Ask for them with "prices": {"interval": "5m"}, or compare on 1d instead. |
rec_without_self | rec(C, C) > 0 | rec(): the step must refer to `self`, otherwise nothing is recursive — use the expression on its own instead. |
Parse errors also carry the column and a caret under the problem, after the first line:
Unexpected token 'EOF' at column 3 C > ^
Intraday names
The messages for vwap() and @5m mention a "prices" option. Ora does not offer it: rules run on daily bars only, so write the rule on daily data instead.
Request errors around rules
| Case | Response |
|---|---|
| A rule without a symbol | {
"detail": [
{
"loc": [
"body",
"state",
"symbol"
],
"type": "missing",
"msg": "Rules (`ask`) are evaluated on a symbol's price history: add \"state\": {\"symbol\": \"TSLA\"}."
}
]
} |
| A symbol Ora does not cover | {
"detail": [
{
"loc": [
"body",
"state",
"symbol"
],
"type": "value_error",
"msg": "No market data for `ZZQXW`. Asking by symbol covers about 2,000 liquid US stocks and ETFs; for anything else send `state.context` yourself."
}
]
} |
An empty ask | {
"detail": [
{
"loc": [
"body",
"questions",
"above_50d",
"ask"
],
"type": "string_type",
"msg": "`ask` must be a rule, e.g. \"C > sma(C, 50)\""
}
]
} |
When the rule engine is paused
During maintenance, requests that contain ask rules get a 503 with a Retry-After header; English questions and forecasts keep working. Retry after the number of seconds given.
Status codes for everything else: Errors.
Create an account Open the Playground
Everything here also lives in the console, next to your keys and usage.