Implementing Live Cryptocurrency Trading with DolphinDB

Polly_Liu2 pts0 comments

From Backtest to Production: Implementing Live Cryptocurrency Trading with DolphinDB | by DolphinDB | MediumSitemapOpen in appSign up<br>Sign in

Medium Logo

Get app<br>Write

Search

Sign up<br>Sign in

From Backtest to Production: Implementing Live Cryptocurrency Trading with DolphinDB

DolphinDB

6 min read·<br>Mar 5, 2026

Listen

Share

Press enter or click to view image in full size

Building a quantitative trading system is one thing — putting it into real-world execution is another. For most quant developers, the gap between a well-performing backtest and a robust live trading system is filled with API integrations, error handling, order management, and infrastructure challenges. This post walks through how DolphinDB bridges that gap for cryptocurrency trading, offering a live trading module that integrates seamlessly with its existing backtesting and simulation framework.<br>By leveraging DolphinDB’s httpClient plugin alongside the official trading APIs of Binance and OKX , the live trading module lets you take a strategy straight from backtesting into production — with minimal code changes.<br>Why DolphinDB for Live Trading?<br>DolphinDB is a high-performance time-series database and analytics platform widely used in quantitative finance. Its built-in backtesting and simulation framework is designed to handle high-frequency data efficiently. The live trading module described here extends this framework so that backtesting, simulation, and live execution all share the same codebase and callback interface — dramatically reducing the learning curve and the risk of introducing bugs during the transition to production.<br>Supported Functions<br>The live trading module exposes four core functions:<br>Press enter or click to view image in full size

All activity — including successful orders, cancellations, network errors, and exchange API errors — is persisted to a stream table named by convention:<br>Cryptocurrency_BinanceTradeDetails for Binance<br>Cryptocurrency_OKXTradeDetails for OKX<br>This makes it easy to audit order status and diagnose failures without hammering exchange APIs with repeated queries.<br>Prerequisites: Obtaining API Keys<br>Before going live, you need API credentials for your chosen exchange.<br>Binance<br>Register and log in to your Binance account.<br>Go to API Management in the account settings to obtain the API key and HMAC key.<br>Press enter or click to view image in full size

Obtain keys on BinanceIf you do not want to trade with a personal account for now, you can use the Binance Spot Test Network.<br>Log in to your Binance account and sign in using a GitHub account.

Obtain keys on the Binance test siteClick Generate HMAC-SHA-256 Key to generate the required keys.

Generate keys on the Binance test siteOKX<br>Register and log in to your OKX account.<br>Go to the API section in the account settings and create an API key.<br>Press enter or click to view image in full size

Obtain API keys on OKXFill in the IP whitelist and passphrase, and select key permissions (read, withdraw, trade) as needed.<br>Press enter or click to view image in full size

Creating an API key on OKXNote: If you do not have a static IP address, it is not recommended to set an IP whitelist, as IP changes may cause order failures. Also, API keys without a bound IP address will be automatically deleted after 14 days of inactivity.<br>After creation, click View to obtain the API key and secret. Please store them securely.<br>Implementation Walkthrough<br>The following steps take you from a simulation strategy all the way to live execution. The full script is provided in the Appendix. For strategy development, see Stop Backtesting in Theory.<br>Compile the OKX signature plugin (Linux ). For compilation details, see the plugin document.<br>Download the DolphinDBPlugin project based on your server version, and place the source code (hex2Base64-main.zip) in the root directory.<br>Run the following commands to generate .so and .txt files in the output folder.<br>Place the output/hex2Base64-main folder in the server/plugins directory.<br>cd ../DolphinDBPlugin/hex2Base64-main<br>export CMAKE_INSTALL_PREFIX="$(pwd)/output/$PluginName"<br># Default ABI1<br>export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" # Specify ABI0 via environment variable<br>CXX=g++-8 CC=gcc-8 bash -x ./build.sh # Modify compiler version as needed2. Place the CryptocurrencySolution module in the modules directory under the home directory (getHomeDir()), move files in CryptocurrencyTrading.zip to the CryptocurrencySolution directory, and modify the OKXTradingModule.dos file based on the plugin path.<br>try{loadPlugin("/.../server/plugins/hex2Base64-main/PluginHex2Base64.txt")}catch(ex){print(ex)}<br>go3. Load the modules as follows:<br>use CryptocurrencySolution::simulatedTrading<br>use CryptocurrencySolution::CryptocurrencyTrading<br>go4. Retrieve and store asset precision information.<br>tb = CryptocurrencySolution::CryptocurrencyTrading::getAssetPrecision()<br>dbName = "dfs://CryptocurrencyDay"<br>tbName = "precision"<br>colNames =...

live trading dolphindb binance keys account

Related Articles