Open the app
Quantitative core

Mathematical library

The authoritative, versioned formula catalogue — returns, PnL, True Range & ATR, volatility, momentum, moving averages, RSI, breakout and volume.

Clawlas never asks an LLM to compute a number. Prices, returns, volatility, PnL and every indicator come from this deterministic, versioned formula catalogue — pure functions with unit tests, explicit units and a defined treatment of missing data.

Price returns

returns_v1
Simple return

The intuitive percentage change between two prices — used for trade return, portfolio return and reporting.

price at time t
price at the previous step
python
def simple_return(current: float, previous: float) -> float:
    if previous <= 0:
        raise ValueError("previous must be > 0")
    return (current / previous) - 1.0
returns_v1
Logarithmic return

Additive across periods and symmetric — the basis for volatility and statistical analysis.

returns_v1
Cumulative return

Compounds a series of simple returns into one total return.

Trade PnL

Gross PnL for a Spot long is quantity times the price move; net PnL subtracts every cost. Clawlas always reports net.

pnl_v1
Gross PnL — Spot long
filled quantity
entry and exit prices
Net PnL — what actually lands
  • +gross PnL
  • -entry feeEntryCost × f_entry
  • -exit feeExitValue × f_exit
  • -other costsnetwork, bridge, conversion, realized slippage
= net PnL
pnl_v1
Net return

Net profit over the capital actually committed (entry cost plus the entry fee).

python
def net_return(net_pnl: float, entry_cost: float, entry_fee: float) -> float:
    return net_pnl / (entry_cost + entry_fee)

True Range & ATR

atr_v1
True Range

The largest of today's range and the gaps to yesterday's close — captures overnight jumps a high-minus-low misses.

high and low of the current candle
previous close
atr_v1
Average True Range

Average volatility over n periods (Wilder smoothing is also supported). Feeds stop distance and sizing — never a standalone signal.

python
def average_true_range(data, period: int = 14):
    tr = true_range(data)
    return tr.ewm(alpha=1 / period, adjust=False).mean()

Volatility

volatility_v1
Historical volatility

Standard deviation of returns. Local volatility drives stop distance and sizing; annualized volatility is mostly for comparison and reporting.

volatility_v1
Annualized volatility
periods per year for the timeframe

Volatility is bucketed into regimes per market, venue and timeframe:

RegimeCondition
LowCurrent volatility < 30th percentile
Normal30th ≤ current ≤ 80th percentile
HighCurrent volatility > 80th percentile
ExtremeCurrent volatility > 95th percentile

Momentum

momentum_v1
Rate of Change

Percentage move over n periods — the raw momentum measure.

momentum_v1
Volatility-normalized momentum

Momentum expressed in units of volatility, so the same threshold means the same thing across calm and wild markets.

momentum_v1
Positive-return ratio

How many of the recent returns were positive. A high ratio means an orderly move, not one isolated candle.

indicator: 1 if true, else 0

Moving averages & RSI

Trend filters and momentum confirmation only — never sufficient standalone entry signals.

ma_v1
Simple & exponential moving average
EMA smoothing factor
rsi_v1
Relative Strength Index

Momentum confirmation and overextension detection. A given RSI never automatically implies a reversal.

Breakout

breakout_v1
Price breakout (current candle excluded)

Close above the highest high of the prior n candles — the current candle is never part of the prior high.

breakout_v1
Breakout distance & volume ratio
previous highest high over n candles
median volume over n candles
volume threshold
A valid breakout is a conjunction
Price breakout volume momentum liquidity acceptable spread, slippage and risk. Any single condition failing rejects the candidate — see Position sizing & stops and Liquidity & slippage.

Volume

volume_v1
Robust relative volume

Median, not mean — for new and skewed tokens a single print should not move the baseline.

volume_v1
Quote volume

Value traded, comparable across assets — generally more useful than base-unit volume.

  • relative volume
  • quote volume
  • volume acceleration
  • volume concentration
Every formula is versioned
Each card carries a version tag (returns_v1, atr_v1, …). A trade stays reproducible even after a formula changes, because the version that produced it is pinned. Historical definitions are never overwritten in place — see Deterministic scripts.