How it works
Your Python code implements ashould_trade function that receives market data and returns a trading decision. The function runs inside Eryx (CPython 3.14 compiled to WASM) with restricted access for security.
Writing a strategy
A minimal strategy class:MarketData API
Thedata parameter passed to should_trade provides these methods:
| Method | Parameters | Returns |
|---|---|---|
get_price(symbol) | Symbol name | Current price as float |
get_klines(symbol, interval, limit) | Symbol, timeframe (1m, 5m, 1h, 4h, 1d), count | List of OHLCV candles |
get_indicator(symbol, name, period) | Symbol, indicator name, lookback period | Indicator value(s) |
get_positions() | — | List of open positions |
get_balance() | — | Available account balance |
get_regime(symbol) | Symbol name | Current market regime string |
get_factor(symbol, factor_name) | Symbol, factor expression name | Factor value as float |
Supported indicators
Decision fields
TheDecision object returned by should_trade:
| Field | Type | Required | Description |
|---|---|---|---|
operation | string | Yes | "long", "short", or "hold" |
symbol | string | If not hold | Trading pair symbol |
leverage | float | If not hold | Position leverage multiplier |
take_profit_pct | float | No | Take-profit percentage from entry |
stop_loss_pct | float | No | Stop-loss percentage from entry |
size_pct | float | No | Percentage of available balance to use |
reasoning | string | No | Human-readable explanation of the decision |
Security sandbox
Programs run inside a restricted WASM environment with multiple safety layers:Forbidden imports
os, sys, subprocess, socket, http, urllib, and other system/network modules are blocked.Restricted builtins
exec, eval, compile, __import__, open, and file I/O builtins are removed.Execution timeout
Each execution is capped at 30 seconds. Strategies that exceed this limit are terminated.
No filesystem access
The WASM sandbox has no access to the host filesystem. All data comes through the MarketData API.
Creating and binding a program
Backtest
Validate your strategy against historical data before going live. See Backtesting.