MyOKX(EEA) Trading Bot in Python

This guide shows how to build a MyOKX(EEA) trading bot in Python with LumiBot, for both AI agent trading and algorithmic trading. LumiBot connects to MyOKX(EEA) through CCXT, the open source library that talks to more than 100 crypto exchanges. You will create a MyOKX(EEA) 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.

MyOKX(EEA) at a glance

CCXT exchange id

myokx

Markets

Spot

Testnet (sandbox)

Yes

Credentials

API key, API passphrase (CCXT calls it password), API secret

Live data streams

prices, order book, trades, candles, your orders, your balance, your positions

CCXT request spacing

about 110 ms between requests

Official site

https://my.okx.com

API docs

https://my.okx.com/docs-v5/en/#overview

Fees

https://my.okx.com/pages/products/fees.html

What is MyOKX(EEA)?

MyOKX is the OKX exchange site at my.okx.com. It offers spot trading and Convert, using the OKX v5 API served from the eea.okx.com host.

Sign up for MyOKX(EEA)

  1. Register an OKX account on my.okx.com with your email, phone number, or an Apple or Google account.

  2. Complete identity verification (KYC). OKX says it usually takes a few minutes to submit and up to 24 hours to finish.

  3. For practice, open Trade, then Demo Trading. Your normal OKX login works there, and demo API keys are made separately from real ones.

Open a MyOKX(EEA) account

Create a MyOKX(EEA) API key

  1. Log in on my.okx.com and open the API page from your profile (https://my.okx.com/account/my-api).

  2. Click Create API key and pick the account it is for (your main account or a sub-account).

  3. Enter a name and a passphrase, and add the IP address of your bot (up to 20 per key).

  4. Under Permissions, choose Read and Trade.

  5. Save the API key, secret key and passphrase. OKX cannot recover the passphrase, so a lost one means making a new key.

Which permissions to turn on: Turn on Read (view balances and order history) and Trade (place and cancel orders). Leave Withdraw off. A bot never needs to move money out of your account.

Warning

Never turn on withdrawals for a MyOKX(EEA) trading bot key. Bind the key to your server’s IP address when MyOKX(EEA) lets you, keep the secret out of your code and out of Git, and delete the key if it ever leaks.

Connect MyOKX(EEA) to LumiBot

The simplest way: put these lines in a .env file next to your strategy. LumiBot loads the file, sees TRADING_BROKER=myokx and connects to MyOKX(EEA) for you, so your strategy needs no broker code.

TRADING_BROKER=myokx
MYOKX_API_KEY=your_apiKey
MYOKX_API_PASSPHRASE=your_password
MYOKX_API_SECRET=your_secret
MYOKX_SANDBOX=true   # testnet; remove this line for your live account

LumiBot reads exactly the fields CCXT needs for MyOKX(EEA) (apiKey, password, 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 MyOKX(EEA):

import os

MYOKX_CONFIG = {
    "exchange_id": "myokx",
    "apiKey": os.environ.get("MYOKX_API_KEY"),
    "password": os.environ.get("MYOKX_API_PASSPHRASE"),
    "secret": os.environ.get("MYOKX_API_SECRET"),
    "sandbox": True,  # testnet first; set False for your live account
}

from lumibot.brokers import Ccxt

broker = Ccxt(MYOKX_CONFIG)
# then: MyStrategy(broker=broker, ...)

Either way, LumiBot turns on CCXT’s built-in rate limiting for you.

Practice on the MyOKX(EEA) testnet

OKX runs Demo Trading for the API, using your normal OKX login. Create a separate key under Trade, Demo Trading, Personal Center, Demo Trading API. Demo keys only work in Demo Trading. Set MYOKX_SANDBOX=true (or "sandbox": True in a code config) to send LumiBot requests there. CCXT then adds OKX’s demo trading header on the same eea.okx.com host.

CCXT sends sandbox requests to: https://eea.okx.com. Testnet and live accounts use different keys.

Algorithmic trading example: a simple MyOKX(EEA) bot

This bot buys about 45 EUR of BTC on MyOKX(EEA) once 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.

from lumibot.entities import Asset
from lumibot.strategies import Strategy


class MyokxBuyOnce(Strategy):
    """Buy a small amount of BTC once, 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):
        coin = Asset("BTC", asset_type=Asset.AssetType.CRYPTO)
        if self.get_position(coin) is not None:
            return  # already holding BTC
        price = self.get_last_price(coin, quote=self.quote_asset)
        if price:
            quantity = round(45 / price, 6)  # about 45 EUR worth
            order = self.create_order(coin, quantity, "buy", quote=self.quote_asset)
            self.submit_order(order)


if __name__ == "__main__":
    # LumiBot reads TRADING_BROKER and the keys from your .env file.
    strategy = MyokxBuyOnce(quote_asset=Asset("EUR", asset_type=Asset.AssetType.CRYPTO))
    strategy.run_live()

Agentic trading example: an AI agent that trades on MyOKX(EEA)

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 MyOKX(EEA) 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.

from lumibot.entities import Asset
from lumibot.strategies import Strategy


class MyokxAITrader(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 MyOKX(EEA). "
                "You may trade BTC and ETH against EUR (asset_type 'crypto', quote_symbol 'EUR'), or hold cash. "
                "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/EUR and ETH/EUR prices and your current holdings, then decide whether to buy, sell or hold.",
            context={"exchange": "MyOKX(EEA)", "quote": "EUR", "date": self.get_datetime().isoformat()},
        )


if __name__ == "__main__":
    # LumiBot reads TRADING_BROKER and the keys from your .env file.
    strategy = MyokxAITrader(quote_asset=Asset("EUR", asset_type=Asset.AssetType.CRYPTO))
    strategy.run_live()

The agent needs a model key such as OPENAI_API_KEY in your environment. See the AI agents quickstart for models, tools and memory.

What you can trade on MyOKX(EEA) through CCXT

Market

Listed by CCXT

Spot

Yes

Margin

Not listed by CCXT

Perpetual swaps

No

Dated futures

No

Options

No

CCXT lists these order features for MyOKX(EEA): market orders, limit orders, stop orders, stop-loss orders, take-profit orders, reduce-only orders, editing open orders, canceling orders.

MyOKX(EEA) tips

  • MyOKX keys need three values: the API key, the secret key and the passphrase. Set MYOKX_API_KEY, MYOKX_API_SECRET and MYOKX_API_PASSPHRASE.

  • Bind an IP address to the key. OKX says keys with trade or withdraw permission and no bound IP expire after 14 days of inactivity (demo keys are not deleted).

  • Use the myokx id for accounts on my.okx.com. The okx id talks to the main okx.com API host instead, so a my.okx.com key belongs with myokx.

  • Spot symbols look like BTC/EUR. MyOKX also lists BTC/USDC and BTC/USDT.

Frequently asked questions

Can I build a MyOKX(EEA) trading bot in Python?

Yes. Install LumiBot (pip install lumibot), set your MyOKX(EEA) keys and use the myokx CCXT exchange id as shown above.

Does MyOKX(EEA) have a testnet?

Yes. Set MYOKX_SANDBOX=true and use keys from the MyOKX(EEA) testnet.

Which API permissions does a MyOKX(EEA) bot need?

Turn on Read (view balances and order history) and Trade (place and cancel orders). Leave Withdraw off. A bot never needs to move money out of your account.

Can an AI agent trade on MyOKX(EEA) 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 MyOKX(EEA) perpetual futures with LumiBot?

CCXT does not list perpetual swaps for MyOKX(EEA), so use spot markets.

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 MyOKX(EEA) 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

Sources