Guides / Cookbooks
Cookbooks · Risk and execution · Advanced · about 12 min
Risk guardrail before an order
Before an order goes out, ask for its drawdown odds and trend, and send block, reduce or allow to your order system.
- A webhook connection named
my-oms, or call the API inline from your order path.
When to use it
A last check before execution: no new long when a large drawdown is likely and the stock is already under its 50-day average; a half-size order when only the drawdown odds are high; otherwise allow. The three actions are exclusive, so exactly one decision arrives.
The request
{ "model": "ora-fin1", "state": { "symbol": "TSLA" }, "questions": { "drop5": { "type": "yes_no", "instructions": "Will it drop at least 5% at some point in the next month?" }, "down_week": { "type": "yes_no", "instructions": "Will the stock be lower in a week?" }, "below_50d": { "type": "yes_no", "ask": "C < sma(C,50)" } }, "actions": [ { "id": "block", "when": "drop5 >= 0.6 and below_50d >= 0.6", "do": "webhook", "connection": "my-oms", "body": { "symbol": "{{symbol}}", "decision": "block", "reason": "drawdown_risk_in_downtrend", "p_drop5": "{{drop5}}", "p_below_50d": "{{below_50d}}", "as_of": "{{as_of}}" } }, { "id": "reduce", "when": "drop5 >= 0.6 and below_50d < 0.6", "do": "webhook", "connection": "my-oms", "body": { "symbol": "{{symbol}}", "decision": "reduce_size", "max_fraction": 0.5, "p_drop5": "{{drop5}}", "as_of": "{{as_of}}" } }, { "id": "allow", "when": "else", "do": "webhook", "connection": "my-oms", "body": { "symbol": "{{symbol}}", "decision": "allow", "p_drop5": "{{drop5}}", "as_of": "{{as_of}}" } } ], "dry_run": true }Open this in the PlaygroundThe real response
{ "model": "ora-fin1", "answers": { "drop5": { "type": "yes_no", "yes_no": 0.638 }, "down_week": { "type": "yes_no", "yes_no": 0.455 }, "below_50d": { "type": "yes_no", "yes_no": 0.1039, "rule": "C < sma(C,50)", "basis": "rule" } }, "usage": { "input_tokens": 358, "output_tokens": 12 }, "context": { "source": "server", "symbol": "TSLA", "as_of": "2026-10-30" }, "version": "ora-fin-0.1.1", "actions": [ { "id": "block", "fired": false, "status": "skipped" }, { "id": "reduce", "fired": true, "status": "dry_run", "do": "webhook", "connection": "my-oms", "preview": { "body": { "symbol": "TSLA", "decision": "reduce_size", "max_fraction": 0.5, "p_drop5": 0.638, "as_of": "2026-10-30" } } }, { "id": "allow", "fired": false, "status": "skipped" } ] }drop5is 0.638 but TSLA is not under its 50-day average (below_50d0.1039), soblockwas skipped andreducefired withmax_fraction: 0.5.The code
Requires curl 7.76+. Save as run.sh, then: bash run.shcurl -sS https://oramodel.com/v1/systemone \ -H "Authorization: Bearer $JEV_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "ora-fin1", "state": { "symbol": "TSLA" }, "questions": { "drop5": { "type": "yes_no", "instructions": "Will it drop at least 5% at some point in the next month?" }, "down_week": { "type": "yes_no", "instructions": "Will the stock be lower in a week?" }, "below_50d": { "type": "yes_no", "ask": "C < sma(C,50)" } }, "actions": [ { "id": "block", "when": "drop5 >= 0.6 and below_50d >= 0.6", "do": "webhook", "connection": "my-oms", "body": { "symbol": "{{symbol}}", "decision": "block", "reason": "drawdown_risk_in_downtrend", "p_drop5": "{{drop5}}", "p_below_50d": "{{below_50d}}", "as_of": "{{as_of}}" } }, { "id": "reduce", "when": "drop5 >= 0.6 and below_50d < 0.6", "do": "webhook", "connection": "my-oms", "body": { "symbol": "{{symbol}}", "decision": "reduce_size", "max_fraction": 0.5, "p_drop5": "{{drop5}}", "as_of": "{{as_of}}" } }, { "id": "allow", "when": "else", "do": "webhook", "connection": "my-oms", "body": { "symbol": "{{symbol}}", "decision": "allow", "p_drop5": "{{drop5}}", "as_of": "{{as_of}}" } } ], "dry_run": true }'Or inline in the order path, without a webhook. Decide what happens when the check itself fails (here: fail closed, the order waits):
import os import requests URL = "https://oramodel.com/v1/systemone" HEADERS = {"Authorization": f"Bearer {os.environ['JEV_API_KEY']}"} QUESTIONS = { "drop5": { "type": "yes_no", "instructions": "Will it drop at least 5% at some point in the next month?" }, "down_week": { "type": "yes_no", "instructions": "Will the stock be lower in a week?" }, "below_50d": { "type": "yes_no", "ask": "C < sma(C,50)" } } def pre_trade_check(symbol): try: r = requests.post(URL, headers=HEADERS, timeout=10, json={"model": "ora-fin1", "state": {"symbol": symbol}, "questions": QUESTIONS}) r.raise_for_status() except requests.RequestException: return "hold", None # fail closed a = {k: v["yes_no"] for k, v in r.json()["answers"].items()} if a["drop5"] >= 0.6 and a["below_50d"] >= 0.6: return "block", a if a["drop5"] >= 0.6: return "reduce_size", a return "allow", aAct on it
Make the guardrail advisory before it is binding: log its decision next to every order for a few weeks, compare with what happened, then let
blockstop orders. Keep a manual override, and record when it was used.Variations
- Shorter horizon: add
down_weekto the block rule for short-term trades. - Sell-side check: block a short when
rally5is high. - Combine with the volatility multiplier so the size and the guardrail come from one request.
- Shorter horizon: add
Information, not investment advice. Every number on this page is a real response for the session shown; answers change with each session.