MeowQuant is an independent third-party information site, not OKX official. The sign-up button carries invite code OK30001, and we may earn a promotion fee from it. Full disclosure →

OKX · Basics

How to Use OKX Demo Trading: Smooth Out Your Strategy with Play Money First

You've written a strategy script, finger hovering over the Enter key—should you let it run on a real account? That hesitation is correct. The most expensive tuition in beginner quant trading is usually lost not to the market but to a flipped condition or a missing decimal point—mistakes that would have surfaced in the demo in five minutes.

In this piece we (the MeowQuant desk) cover the OKX demo account thoroughly: what it is, why you must run it before real money, how to open it, how ccxt connects (the key is one line), and where it quietly fools you. By the end you should be able to switch your script into the demo to fiddle with safely and repeatedly, confirm everything works, then switch back to real money at the cost of changing one line of code.

What Demo Trading is

OKX's demo is called Demo Trading. Simply put, it's a parallel account running on virtual funds: the market, interface, and order flow are all identical to live, except what you spend placing orders isn't real money but a batch of fake USDT the system gives you. Buy, sell, set up grids, run scripts in it—gains and losses have nothing to do with your real balance.

For quant people it has one especially key upside: the demo shares the same API Key as your live account. You don't need to create a separate Key for the demo—just tell OKX in the request "this order goes to the demo" and the same credentials switch between two worlds. That means the script you wrote for live can be carried into the demo for a verification run almost untouched.

Why you must run it before real money

The logic is plain: a program doesn't hesitate. Placing an order by hand, you can still glance at the direction and size before hitting confirm; a script won't—it faithfully executes the logic you got wrong, continuously. A flipped buy/sell direction, an exit condition missing from a loop—on live, that's real money pouring out continuously.

The demo cuts the cost of this class of error to zero. You can let your script slam into walls without worry—wrong orders, wrong cancels, writing the price near market so it fills instantly—all of which in the demo merely burns virtual USDT, and each "slam" catches a bug ahead of time that would have cost you dearly live. In our experience, a new strategy run for its first few rounds on the demo will, nine times out of ten, surface at least one problem you didn't anticipate.

Beyond catching bugs, the demo also confirms two more basic things: whether auth works (did you enter the three credentials correctly), and whether the callbacks are right (are the fields returned after an order, the cancel status, and the balance changes what you assumed). None of this has to do with real money—it's pure flow-level verification, and the demo is the cheapest place to do it.

How to open a demo account

Opening the demo is far simpler than opening an API—no extra approval needed. Here's the rough path, per the current OKX interface (the entry point gets tweaked occasionally):

  1. Log in to OKX, find the "Demo Trading" entry in the account/trading area on the app or web, usually at the account switcher on the trading page, or in your profile center.
  2. Click in to switch to the demo environment. After switching, the interface has a clear marker (like a "Demo" label at the top) reminding you you're now spending play money.
  3. The system gives you a batch of virtual funds. When the balance runs out, you can usually reset it manually on the demo interface and keep practicing.
  4. If you only want to try grid, copy trading, and other built-in bots by clicking around on web/app, this is far enough—just set the parameters and run in the demo environment.
  5. If you want a script to connect to the demo, no separate API Key is needed—reuse your live one (see our API quant intro) and switch to the demo via the toggle in code.
Don't have an OKX account yet, or don't want to practice on your main account? You can open a separate clean account just for quant and the demo. Register with our invite code OK30001 for a fee discount, and when you switch from the demo to live, real-money orders get that discount too. Sign up for OKX here →

How ccxt connects to the demo

This section is what script writers care about most. Connecting ccxt to the demo differs from connecting to live by one extra line. The credentials are still the same three: apiKey, secret, and password (the Passphrase you set when creating the Key—in ccxt this field is called password, the one beginners most often miss).

import ccxt

okx = ccxt.okx({
    'apiKey':   'YOUR_apiKey',
    'secret':   'YOUR_secret',
    'password': 'YOUR_Passphrase',   # OKX-specific, called password in ccxt
})

# The key line: switch all requests to the demo (Demo Trading)
okx.set_sandbox_mode(True)

# After this, all requests go to the demo and use virtual funds
balance = okx.fetch_balance()
print('Demo USDT free:', balance['USDT']['free'])

What set_sandbox_mode(True) does is point all subsequent requests at OKX's demo endpoint. With it, your balance checks, orders, and cancels all run on play money; remove it (or set it to False) and the same code returns to real money.

Some ccxt versions also support configuring it directly at init:

okx = ccxt.okx({
    'apiKey':   'YOUR_apiKey',
    'secret':   'YOUR_secret',
    'password': 'YOUR_Passphrase',
    'options': {'sandboxMode': True},   # equivalent to set_sandbox_mode(True)
})

Both forms have the same effect—pick whichever runs on your version, you don't need both. One easily-overlooked point to stress here: the demo's API Key is the live API Key; you don't need to apply for a separate one for the demo. The whole difference is in that toggle line—it's OKX's design, and the part that's friendly to script writers. If you flip sandbox and still get auth errors, the problem is most likely in the three credentials themselves, not the sandbox toggle, and you can go back and check against the API errors checklist.

Once connected, take the place/cancel script you wrote (see the example in the intro piece), carry it over whole, add this sandbox toggle, and you can run it over and over without worry: even if you fat-finger a limit near the market and it actually fills, what you spend is just virtual USDT.

📋 Desk test · 2026-06-06
At 10:18 we connected the ccxt script above to OKX Demo Trading. The first run, we forgot to add set_sandbox_mode(True), and it printed the balance of that empty live account—we nearly didn't catch it; after adding that line, fetch_balance returned the demo's batch of virtual USDT. We then placed a BTC/USDT limit buy (amount 0.0001, price hard-coded far below market so it sat unfilled), create_order returned an order ID normally, and after sleep(2), cancel_order cancelled it with status canceled. The whole "connect to demo → check balance → place order → cancel" ran smoothly in just a few minutes, at zero cost throughout. That little slip of forgetting the toggle actually reminded us: print-ing the balance before each run to confirm the environment is right is a habit worth building.

Where the demo fools you

The demo is great, but it has a ceiling, and that ceiling can create an illusion. The items below are things you must be clear-eyed about:

Slippage and fill prices are sugar-coated

On live, your orders have to match against real counterparties in the market, and the price often isn't as ideal as you placed it—this is slippage. The demo's matching tends to be more "obedient," with fill prices closer to your ideal. The result: the same parameters often produce a prettier equity curve on the demo than live. Don't treat the demo's returns as your live expectation.

Depth and liquidity aren't real

In a real market, a large order "eats through" the order book and moves the price; a thin pair may not match your order at all. The demo often simplifies this away, filling you smoothly no matter how big the order. On live—especially with thin-liquidity coins—that smoothness vanishes.

Your emotions are fake too

This one is most overlooked yet most lethal. A demo loss doesn't sting, so you can strictly follow your stop-loss and not fiddle with parameters. The moment real money is in, the floating-loss numbers are real, and your hands start itching—taking profit early, holding a loser past the stop, adding to a position on a whim. The demo can never teach you these emotional moves. However pretty a strategy runs on the demo, the first lesson live is often a fight with your own emotions.

Extreme conditions don't play out

Wicks, flash crashes, the occasional exchange congestion and latency—these extreme moments are where a strategy and its risk control are truly tested, and the demo's day-to-day running can hardly reproduce them. So running steadily on the demo doesn't mean your strategy will hold up in extreme conditions.

Don't be fooled by demo returns: the demo verifies "whether the flow is right," not "how much you can earn." Its slippage, depth, and emotion are simplified or wiped away, and returns are generally more optimistic than live. Treat it as a sandbox for debugging and practice, not a preview of returns. Crypto asset prices swing violently, and any demo performance doesn't represent live results.

The order for switching from demo to live

Putting all the above together, here's the fixed order we follow every time we put up a new strategy, and we suggest you copy it:

  • Run on the demo continuously for a stretch. Not just one successful run—let it run for enough time, covering a few up-and-down cycles, and confirm ordering, cancelling, callbacks, and balance changes all match expectations.
  • Change one line to go live. Remove set_sandbox_mode(True) or change it to False. This is exactly the value of verifying on the demo first—the cost of switching is squeezed down to one line.
  • Use only a tiny amount on your first live run. An amount you wouldn't mind losing entirely; treat it as tuition. The slippage and depth the demo can't reproduce only surface now.
  • Watch it for the first few days. Don't actually walk away; confirm live behavior matches what you saw on the demo, then scale up gradually.

This order isn't complicated, but it keeps "the deadliest mistakes most easily made in the beginner phase" out of real money. Demo first, then small-size live, survive first, talk returns later—the line we keep stressing.

FAQ

Does the demo account need a separate API Key?

No need to create a separate Key. Your live OKX API Key can also connect to the demo; the only difference is whether the request carries the demo flag. In ccxt you switch with the set_sandbox_mode(True) toggle, and the credential trio (apiKey, secret, Passphrase) is the same as live, so the code logic barely changes.

Is the demo money real? Do I have to cover losses?

The demo uses virtual funds, not real money, and a loss doesn't dock a cent from your account. Its job is to let you smooth out your script, parameters, and place/cancel flow in a zero-cost environment. When the balance runs out, you can usually reset it on the demo interface; go by OKX's current entry point for exact steps.

If I made money on the demo, will I make the same live?

You can't just copy it over. Demo fills are often more ideal than live—its slippage, depth, and matching speed are all simplified, and your mindset is more relaxed with play money. The same parameters can produce completely different live results due to worse fill prices, thin depth, or your own fat-fingering. The demo verifies whether the flow is right, not how much you can earn.

What's the difference between set_sandbox_mode and sandboxMode in the config?

They have the same effect—both make ccxt send requests to the demo endpoint. set_sandbox_mode(True) is a method you call once after initializing the object; writing 'sandboxMode': True in options configures it once when creating the object. Pick whichever one runs on your ccxt version; you don't need both.

Once the demo works, how many lines do I change to go live?

Ideally just one line—remove set_sandbox_mode(True) or change it to False. That's exactly the upside of running on the demo first: verify logic with play money, then change one line to go to real money. But for your first live run, always use only a tiny amount and watch it for a while, because the demo can't reproduce real slippage and depth.

Once you're comfortable with the demo, you've got a zero-cost test ground—any new strategy, any changed code, gets dropped in there to run smoothly first. Next you can read how to write risk control into the script, or use the grid estimator to work out the parameters first. Whichever road you take, remember the order from today's piece: demo first, then small-size live.

Demo running smoothly—ready to step up?

Get your account and API ready first, smooth out the flow on the demo, then switch to real money. A new account registered with the invite code gets a fee discount, and orders you place via the API get it too.

OK30001 Sign up for OKX with OK30001 →

Crypto asset prices swing violently, and futures and leverage can lead to a total loss of capital. Quant and automated trading don't guarantee profit, and demo performance doesn't represent live results—use only funds you can afford to lose.