Automations Protocol
Below is a reference architecture and a simple, reusable execution protocol that will let you support any type of Automations use-cases with a single, consistent flow. Treat each flow as just a directed graph of nodes + edges, driven by a tiny βFlow Engineβ that implements this protocol:
1. High-Level Architecture
2. Core Concepts & Protocol
2.1. Graph Definition
Everything is a JSON object with two arrays:
2.2. Execution Context
A mutable object passed around:
2.3. Node Handler Interface
Each type
of node registers a handler:
passed = whether the flow continues from this node
outputs get merged into
ctx.variables
2.4. Flow Engine Loop (Pseudo-Code)
3. Built-In Node Types
start
Seed the run β define tickers or cron trigger.
tickers: "AAPL,MSFT"
or cron: "0 9 * * 1"
indicator
Compute & compare a market signal
indicator:"rsi", timeframe:"1h", op:"<", threshold:20
action
Execute a trade, set a stop, place order, etc.
action:"buy", size:100, symbol:ctx.currentTicker
scheduler
Pause or re-enter flow on schedule
interval:"5m"
loop
Iterate an array (e.g. tickers, historical dates)
varName:"historicalDates"
notification
Send email/Slack/Webhook
channel:"slack", msg:"Alert: low RSI"
custom
Hook your own connector (news, sentiment, ML)
module:"newsSentiment", params:{...}
4. How to Build Any Use-Case
Define your nodes in the React Flow canvas; each plug-and-play node maps to one of the types above (or a new custom type you register).
Wire them in the canvas: edges always flow ββΆ next step.β
Configure node data in the side-panel: thresholds, symbols, cron expressions, API keys.
On βRunβ, Next.js fetches the JSON, hands it plus a fresh
Context
torunFlow()
.runFlow
uses the protocol above to traverse, call your handlers, andctx.logger()
every step.LogsPanel subscribes (via simple React state or a WebSocket) to stream those messages in real time.
5. Example: Multi-Ticker Oversold Scan
That single graph will loop through each ticker, check RSI, buy when conditionβs met, and ping Slack. Swap or chain in any of the node types in section 3 to cover all your 15+ use-casesβstop-loss, take-profit, scheduled rebalance, sentiment alerts, grid trading, backtests, you name it.
βοΈ Next Steps:
Build/Flesh out any custom node handler (e.g.
scheduler
,notification
).Add a node registry in your
flowEngine.ts
that mapstype β handler
.Persist graphs in your DB so users can save/load flows.
Hook your real trading/data APIs inside each handler.
With this protocol in place, every automation you dreamed up becomes just βanother nodeβ in the same simple engine.
Last updated