:seo_title: Kraken Futures Trading Bot in Python: AI Agent and Algorithmic Trading with LumiBot .. Generated by scripts/generate_ccxt_exchange_pages.py from docsrc/_data/. Edit the data, not this page. Kraken Futures Trading Bot in Python ==================================== .. meta:: :description: Build a Kraken Futures trading bot in Python with LumiBot and CCXT. Create Kraken Futures API keys, connect them, and run a regular or AI agent strategy. :keywords: Kraken Futures trading bot, Kraken Futures API, Kraken Futures Python, agentic trading Kraken Futures, AI trading bot Kraken Futures, algorithmic trading Kraken Futures, ccxt krakenfutures This guide shows how to build a Kraken Futures trading bot in Python with LumiBot, for both AI agent trading and algorithmic trading. LumiBot connects to Kraken Futures through CCXT, the open source library that talks to more than 100 crypto exchanges. You will create a Kraken Futures account and API key, connect it, and run two examples: a simple algorithmic trading bot and an agentic trading bot where an AI agent makes the calls. Kraken Futures at a glance -------------------------- .. list-table:: :widths: 35 65 * - CCXT exchange id - ``krakenfutures`` * - Markets - Perpetual swaps, Dated futures * - Testnet (sandbox) - No * - Credentials - API key, API secret * - Live data streams - prices, order book, trades, your orders, your balance, your positions * - CCXT request spacing - about 600 ms between requests * - Official site - https://futures.kraken.com/ * - API docs - https://docs.kraken.com/api/docs/futures-api/trading/market-data/ * - Fees - https://support.kraken.com/hc/en-us/articles/360022835771-Transaction-fees-and-rebates-for-Kraken-Futures What is Kraken Futures? ----------------------- Kraken Futures (Kraken Derivatives) is Kraken's derivatives platform for perpetual futures and dated futures on crypto. It has its own REST, WebSocket and FIX APIs, separate from Kraken's spot API. Sign up for Kraken Futures -------------------------- #. Create a Kraken account at https://www.kraken.com/sign-up. #. Get fully verified (https://www.kraken.com/u/verify). Kraken requires full verification for personal accounts before you can unlock derivatives trading. #. Unlock derivatives trading on your account, then sign in to your Kraken Derivatives account (https://www.kraken.com/login-futures). Kraken Futures has no working testnet right now, so plan to test with a very small amount. `Open a Kraken Futures account `_ Create a Kraken Futures API key ------------------------------- #. Sign in to your Kraken Derivatives account. #. Click your name in the upper-right corner and select Settings. #. In the API panel, select the Create Key tab. #. Set General API to Full Access and Withdrawal API to No Access (see below). #. Press Create Key. #. Save the public key and private key right away. Kraken shows the private key only once. **Which permissions to turn on:** Kraken Futures has two settings. Set General API to Full Access: it lets the bot read your account and place and cancel orders, and Kraken says it never includes withdrawals. Read Only cannot place orders. Set Withdrawal API to No Access. A bot never needs to move money out of your account. .. warning:: Never turn on withdrawals for a Kraken Futures trading bot key. Bind the key to your server's IP address when Kraken Futures lets you, keep the secret out of your code and out of Git, and delete the key if it ever leaks. Connect Kraken Futures to LumiBot --------------------------------- The simplest way: put these lines in a ``.env`` file next to your strategy. LumiBot loads the file, sees ``TRADING_BROKER=krakenfutures`` and connects to Kraken Futures for you, so your strategy needs no broker code. .. code-block:: bash TRADING_BROKER=krakenfutures KRAKENFUTURES_API_KEY=your_apiKey KRAKENFUTURES_API_SECRET=your_secret LumiBot reads exactly the fields CCXT needs for Kraken Futures (``apiKey``, ``secret``). If one is missing, LumiBot stops at start-up and names the variable you still need. You can also build the broker in code. This is handy when one script talks to more than one exchange, or when you need extra CCXT options. The keys in the config are CCXT's own credential names for Kraken Futures: .. code-block:: python import os KRAKENFUTURES_CONFIG = { "exchange_id": "krakenfutures", "apiKey": os.environ.get("KRAKENFUTURES_API_KEY"), "secret": os.environ.get("KRAKENFUTURES_API_SECRET"), "sandbox": False, # no sandbox for this exchange } from lumibot.brokers import Ccxt broker = Ccxt(KRAKENFUTURES_CONFIG) # then: MyStrategy(broker=broker, ...) Either way, LumiBot turns on CCXT's built-in rate limiting for you. Testing on Kraken Futures ------------------------- Kraken has said its old Futures demo site (demo-futures.kraken.com) is decommissioned, and on 2026-10-23 that address only redirects to Kraken's main website. CCXT still lists it as the test URL, but it no longer works, so treat Kraken Futures as having no sandbox and test with a very small amount. With environment variables, leave ``KRAKENFUTURES_SANDBOX`` unset. In a code config, set ``"sandbox": False``. Algorithmic trading example: a simple Kraken Futures bot -------------------------------------------------------- CCXT lists no spot market for Kraken Futures, so this example trades a perpetual contract. It opens one small long BTC position worth about 50 USD and then holds it. It is a starting point to check that your keys, balances and orders work. If the exchange's minimum order is larger, raise the amount. If your account uses hedge mode, add ``position_side="long"`` to ``create_order``. .. code-block:: python from lumibot.entities import Asset from lumibot.strategies import Strategy class KrakenfuturesOpenOneLong(Strategy): """Open one small long BTC perpetual position, then hold it.""" def initialize(self): self.sleeptime = "1H" self.set_market("24/7") # crypto trades all day, every day def on_trading_iteration(self): # The full CCXT symbol keeps the settlement currency clear. contract = self.broker.get_asset("BTC/USD:USD") if self.get_position(contract) is not None: return # already holding the position price = self.get_last_price(contract) if price: # Each contract covers contract.multiplier BTC; size the order to about 50 USD. quantity = round(50 / (price * contract.multiplier), 6) order = self.create_order(contract, quantity, "buy") self.submit_order(order) if __name__ == "__main__": # LumiBot reads TRADING_BROKER and the keys from your .env file. strategy = KrakenfuturesOpenOneLong(quote_asset=Asset("USD", asset_type=Asset.AssetType.CRYPTO)) strategy.run_live() Agentic trading example: an AI agent that trades on Kraken Futures ------------------------------------------------------------------ Agentic trading means an AI agent reads the market and decides what to do. In this example one LumiBot agent looks at prices and your Kraken Futures account, then places the orders itself. There is no Python logic in between: you set the rules in plain English in the prompt, such as what it may trade and how big each order can be. This follows the same pattern as LumiBot's AI trading team examples. .. code-block:: python from lumibot.entities import Asset from lumibot.strategies import Strategy class KrakenfuturesAITrader(Strategy): """One AI agent researches the market and places the trades itself.""" def initialize(self): self.sleeptime = "4H" self.set_market("24/7") self.agents.create( name="trader", model="openai/gpt-6-luna", reasoning_effort="high", allow_trading=True, system_prompt=( "You manage a small crypto account on Kraken Futures. " "You may trade the BTC/USD:USD perpetual contract (asset_type 'crypto_future'), long or short, or stay flat. " "Before every order, call account_portfolio, account_positions and " "market_last_price for that exact symbol in the same run. " "Keep each order under 10% of the account value. " "Explain each decision in one short paragraph." ), ) def on_trading_iteration(self): self.agents["trader"].run( task_prompt="Review recent BTC/USD:USD prices and your current position, then decide whether to buy, sell or hold.", context={"exchange": "Kraken Futures", "quote": "USD", "date": self.get_datetime().isoformat()}, ) if __name__ == "__main__": # LumiBot reads TRADING_BROKER and the keys from your .env file. strategy = KrakenfuturesAITrader(quote_asset=Asset("USD", asset_type=Asset.AssetType.CRYPTO)) strategy.run_live() The agent needs a model key such as ``OPENAI_API_KEY`` in your environment. See the :doc:`AI agents quickstart ` for models, tools and memory. What you can trade on Kraken Futures through CCXT ------------------------------------------------- .. list-table:: :header-rows: 1 :widths: 40 60 * - Market - Listed by CCXT * - Spot - No * - Margin - No * - Perpetual swaps - Yes * - Dated futures - Yes * - Options - No CCXT lists these order features for Kraken Futures: market orders, limit orders, stop orders, reduce-only orders, editing open orders, canceling orders. For perpetual contracts, use the full CCXT symbol so the settlement currency is clear, for example ``BTC/USD:USD``. See :doc:`the CCXT guide ` for contract quantities, position modes and leverage. Kraken Futures tips ------------------- * Kraken Futures has no spot markets. Use perpetual symbols in the full CCXT form: ``BTC/USD:USD`` is the USD-settled perpetual (Kraken's ``PF_XBTUSD``) and ``BTC/USD:BTC`` is the inverse perpetual settled in BTC (``PI_XBTUSD``). Kraken writes bitcoin as ``XBT``; CCXT converts it to ``BTC`` for you. * Kraken Futures keys do not work for Kraken spot trading, and spot keys do not work here. For Kraken spot, use the separate ``kraken`` CCXT id and a spot API key. * Kraken Derivatives sub-accounts each have their own API keys, rate limits and margin. Kraken links them on request through a support ticket, and withdrawals from sub-accounts are blocked, which suits a bot account. * You can create up to 50 API keys per account, and each has its own nonce. Give each bot its own key. Frequently asked questions -------------------------- **Can I build a Kraken Futures trading bot in Python?** Yes. Install LumiBot (``pip install lumibot``), set your Kraken Futures keys and use the ``krakenfutures`` CCXT exchange id as shown above. **Does Kraken Futures have a testnet?** No testnet is set up for Kraken Futures in LumiBot. Start with a small amount, and in a code config set ``"sandbox": False``. **Which API permissions does a Kraken Futures bot need?** Kraken Futures has two settings. Set General API to Full Access: it lets the bot read your account and place and cancel orders, and Kraken says it never includes withdrawals. Read Only cannot place orders. Set Withdrawal API to No Access. A bot never needs to move money out of your account. **Can an AI agent trade on Kraken Futures by itself?** Yes. The agentic example above gives one agent permission to trade. You control what it may trade and how much through its prompt. **Can I trade Kraken Futures perpetual futures with LumiBot?** CCXT lists perpetual swaps for this exchange. Use the full contract symbol, such as ``BTC/USD:USD``. **Is LumiBot free?** Yes. LumiBot is open source on GitHub at https://github.com/Lumiwealth/lumibot. You pay only your exchange's trading fees and, for AI agents, your model provider. Run it in the cloud with BotSpot -------------------------------- Do not want to keep a computer running for your Kraken Futures bot? BotSpot is the hosted home for LumiBot strategies and AI trading agents: build with AI, backtest, connect a broker, and watch every trade with logs and alerts. `Try BotSpot `_ Related guides -------------- * :doc:`CCXT crypto trading with LumiBot ` * :doc:`AI agents quickstart ` * :doc:`Binance COIN-M trading bot ` * :doc:`Binance USDⓈ-M trading bot ` * :doc:`KuCoin Futures trading bot ` * :doc:`AftermathFinance trading bot ` Sources ------- * `Kraken Support: How to create an API key for Kraken Derivatives `_ (read 2026-10-23) * `Kraken Developers: Derivatives (Futures) introduction `_ (read 2026-10-23) * `Kraken Support: API Testing Environment (Derivatives) `_ (read 2026-10-23) * `Kraken Support: Kraken Derivatives eligibility requirements `_ (read 2026-10-23) * `Kraken Support: Understanding Derivatives subaccounts `_ (read 2026-10-23) * Exchange id, URLs, markets, credentials and stream support: CCXT 4.5.64 metadata, generated 2026-10-23