# Freqtrade and Hummingbot

> Ask Nevarn before each Freqtrade or Hummingbot order. Exchange keys stay with your bot.

Canonical page: https://nevarn.com/docs/bots
Updated: 2026-11-19

Your bot keeps its strategy and its exchange keys. Before each order, the plugin sends Nevarn the order as an exchange intent; Decionis rules on it and Nevarn records the ruling. In obey mode the plugin places the order only when the ruling is execute. Nevarn never places, sees or signs an exchange order.

> The plugins are in nevarn-sdk 0.2.0 and later. Start in observe mode: see what the policy would have stopped before you let it stop anything.

## How it works

- The order goes to POST /machine/intents as strategy exchange: the exchange, the pair, spot or futures, the side, market or limit, the amount and the price. It needs a key with intents.
- obey: the order is placed only when the ruling is execute. When no ruling can be had - Nevarn or Decionis unreachable, the key's 60 intents a minute used up, nothing published - the order is dropped too, unless you set fail-open.
- observe: every order is placed, and every ruling is recorded and logged. Run this first to see what a policy would have stopped.
- Each ruling is one governed action, licensed like any other. One request per order, at most 5 seconds.
- Halt reaches your bots. While your account is halted - POST /machine/halt or the console's kill switch - every order that opens or adds to a position is stopped, in observe mode and with fail-open too. An order that closes or reduces one is never stopped, so a halt cannot trap a position.
- The plugin never raises into your bot's order path: every failure becomes an answer.

## Freqtrade

```python
from freqtrade.strategy import IStrategy
from nevarn.plugins.Freqtrade import NevarnGate

class MyStrategy(NevarnGate, IStrategy):   # the plugin first
    nevarn_mode = "obey"                    # or "observe"
    nevarn_exits = "observe"                # the default
    nevarn_fail_open = False
```

```bash
export NEVARN_API_KEY=nvk_…
export NEVARN_BASE_URL=https://<your platform API>   # or "nevarn": {"base_url": "…"} in the Freqtrade config
```

- Entries are asked from confirm_trade_entry: a long is a BUY, a short a SELL.
- Exits are asked from confirm_trade_exit and recorded, but not stopped unless nevarn_exits is obey: a stopped exit can keep a losing position open. A stop-loss, trailing stop, liquidation, emergency or forced exit is never stopped.
- Only live and dry runs ask. Backtests and hyperopt never call Nevarn.
- If your strategy defines confirm_trade_entry or confirm_trade_exit, call super() from it. A False from yours is final, and Nevarn is not asked.

## Hummingbot

```python
from hummingbot.strategy.strategy_v2_base import StrategyV2Base
from nevarn.plugins.Hummingbot import NevarnGate

class MyScript(NevarnGate, StrategyV2Base):   # the plugin first
    nevarn_mode = "obey"                       # or "observe"
    nevarn_pause_seconds = 30
```

- Every order a script, controller or executor places goes through the strategy's buy and sell, so the plugin sees them all.
- A market order is asked at the connector's mid price. A perpetual connector is futures, settled in its quote asset.
- A stopped order is not placed and buy or sell returns an empty order id; an executor treats it as an order that never opened. The same connector, pair and side are then not asked again for nevarn_pause_seconds, so a retrying executor is not ruled - and licensed - on every tick.
- A closing order (PositionAction.CLOSE) is asked and recorded, but never stopped.

## Verify what your bots did

A ruling your bot asked for is only half the story: it proves what the bot asked, not what it placed. Add a read-only key for Binance, Bybit or OKX in the console (Limits, Verify your bots' exchange orders) and Nevarn reads the account's fills every few minutes and matches each order to a ruling: ruled before it was placed, placed against a ruling, filled more than the ruling allowed, or placed without asking. Anything not ruled shows in the console and arrives as an exchange.fill_unruled webhook.

- The key must only read. Nevarn asks the exchange what it can do and refuses one that can trade, withdraw or transfer.
- Binance reads fills one pair at a time, so Nevarn reads the pairs your bots asked about in the last 30 days and any you add to the key's watch list. Bybit and OKX list every fill.
- A ruling covers one order on the same exchange, pair and side, placed within 10 minutes of it.

## Settings

| Setting | Default | What it does |
| --- | --- | --- |
| nevarn_mode | obey | obey drops an order unless ruled execute; observe places every order and records the ruling |
| nevarn_fail_open | False | True places an obeyed order when no ruling can be had. An unavailable ruling is still a ruling and still stops it. |
| nevarn_exits (Freqtrade) | observe | obey lets a ruling stop an ordinary exit; protective exits are never stopped |
| nevarn_pause_seconds (Hummingbot) | 30 | How long a stopped market and side wait before they are asked again |
