Documentation for Deptle Terminal.
Guides for setup, scripting, troubleshooting, and more.
Math helpers
Common math for strategy expressions.
abs(x),min(a, b),max(a, b),clamp(x, lo, hi).sqrt(x),exp(x),log(x),sin(x),cos(x),tan(x),pow(x, y).round(x)rounds to the nearest whole number, halves away from zero (0.5 becomes 1, -0.5 becomes -1) — unlike Python'sround, which sends halves to the nearest even number.min,max, andclamptake arguments of one kind of number.
Conversion helpers: base and price
base(...) and price(...) turn the numbers you write into order sizes and prices.
- Both accept numbers and expressions:
price(99.5),price(self.cap),base(computed). - Numbers you write and
floatparameters convert exactly. Other computed decimals round to the nearest unit, halves away from zero. A decimal string with too many places is rejected. base_units(n)turns a whole number of units into a quantity;as_base(x)re-labels an already-converted value without changing it.
Converting a value twice is a compile error (E0437) — the message names the original source, even when it went through a variable or State first. tick.price, sys.position_base, sys.equity_quote, indicator outputs, and price()/base() results are already converted: pass them directly.
Casts, randomness, and portfolio lookups
Type conversion, reproducible randomness, cross-asset lookups.
int(x),float(x).rand_u32(salt)— a reproducible pseudo-random 32-bit whole number.rand_ppm(max_ppm, salt)— a reproducible value in parts per million (1,000,000 = 100%).portfolio_score_live(asset_id),portfolio_score(asset_id).portfolio_rank_desc(asset_id),portfolio_rank_asc(asset_id).
Length and indexing
len and indexing stay safe at the edges.
len(self.<state_array>)andlen(self.<extra_buffer>)are supported.- Negative indexes count from the end, then snap into valid bounds.
- Out-of-range indexes snap to the nearest valid element.
- A missing or empty
Extrabuffer reads as 0 (or 0.0).
Operators
Arithmetic, comparison, boolean, and bitwise operators.
- Arithmetic:
+,-,*,/,//,%. - Bitwise:
&,|,^,~,<<,>>(whole-number operands). Shift amounts are clamped to[0, 63]. - Comparisons:
<,<=,>,>=,==,!=, including chained comparisons likelo < x < hi. - Boolean:
and,or,not. //and%are exact; dividing or taking a remainder by zero returns 0.
/ between two whole numbers is a compile error (E0385). Use // for whole-number division, or wrap one side in float(...) for a decimal result. / works when either side is a decimal.
If launch fails, include your loader version, OS, and latest crash log so support can reproduce the issue quickly.