Documentation for Deptle Terminal.

Guides for setup, scripting, troubleshooting, and more.

A whole strategy at a glance

One complete strategy showing the pieces you will use most often.

This one file uses every idea you need: two kinds of tunable input, a rolling-average indicator, a value that survives between ticks, the market event, the run context, and a price-capped order.

breakout.py
1from deptle.api import Strategy, Parameter, State, Order, Signal, base, price
2from deptle.indicators import RollingMean
3
4class Breakout(Strategy):
5 fast: int = Parameter(default=20, min=5, max=100) # whole-number window, swept by the Optimizer
6 size: float = Parameter(default=0.05, min=0.01, max=0.5) # decimal order size, also swept
7 cap: float = Parameter(default=42000.5) # fixed knob: no min/max means it never sweeps
8 sma = RollingMean(window=fast) # rolling average over the tunable window
9 seen: int = State(default=0) # remembers how many ticks we have seen
10
11 def on_tick(self, tick, sys):
12 self.seen += 1 # update per-tick memory
13 avg = self.sma.update(tick.price) # feed the price in, read the average back
14 if self.seen < self.fast: # still warming up: not enough data yet
15 return Order.Hold() # wait; keep any open position
16 if sys.position_base == 0 and tick.price > avg: # flat, and price is above the average
17 return Order.Buy(base(self.size), limit_price=price(self.cap)) # buy size units, price-capped
18 return Order.Hold() # otherwise do nothing

What this language is

Deptle strategies are written in a small, trading-focused slice of Python.

You write Python; only the parts that make sense for a trading strategy are available. Anything outside that set stops compilation with an error pointing at the exact spot.

Results are exact and reproducible everywhere.

Write with autocomplete

Install the deptle package so your editor understands strategy files.

Any editor using pyright or mypy — VS Code, PyCharm, and the rest — gets autocomplete, hover documentation, and red underlines before you run anything. Install from the repository root:

  • Start every strategy with from deptle.api import Strategy, Parameter, State, Extra, Tick, Sys, Order, Signal.
  • Add from deptle.indicators import RollingMean, RSI, RollingMeanF32, RSIF32 when you use indicators.
  • Every built-in helper (base, price, clamp, rand_ppm, portfolio_score, and the rest) is importable from deptle.api.

The package is editor help only. The Deptle compiler runs your strategy and ignores the import lines.

install
1pip install -e sdk/python

The entry point: on_tick

Every strategy is one class with an on_tick method, called on each market event.

  • Inherit from Strategy and write def on_tick(self, tick): or def on_tick(self, tick, sys):.
  • Add sys only when you read sys.* fields or call the portfolio lookups.
  • There is no on_bar. Choose bar data in the Optimizer feed settings; your logic stays in on_tick.
minimal_strategy.py
1class MyStrategy(Strategy):
2 def on_tick(self, tick):
3 if tick.price > price(100.0): # is the price above 100?
4 return Order.Buy(quantity=1) # buy one whole unit
5 return Order.Hold() # otherwise hold, keep any position

Numbers

int is a whole number. float is a decimal with up to 8 decimal places.

Prices and sizes are exact — write them naturally: price(42000.5), base(0.05).

  • A variable's kind is set by its first assignment and cannot change.
  • Assign a variable on every path before you read it.
  • and, or, not take true/false values — a bare number is not a condition.

/ between two whole numbers is a compile error (E0385). Use // for whole-number division, or wrap one side in float(...) for a decimal result.

Supported control flow

A small set of familiar Python statements.

  • if / elif / else.
  • for i in range(...) with 1, 2, or 3 arguments.
  • break, continue, pass, return Order.*(...).
  • A line that is only a string (a docstring) is ignored.

while, for ... else, and other unsupported statements stop compilation.

What is intentionally left out

Familiar Python features that are deliberately unavailable.

  • Imports of outside libraries in strategy logic (the deptle imports are the exception).
  • General-purpose functions, lambdas, comprehensions, and generators.
  • Writing to Extra(...) buffers — they are read-only.
  • Attributes on anything other than tick, sys, and self.
Need help?

If launch fails, include your loader version, OS, and latest crash log so support can reproduce the issue quickly.

Check service status