Tiger OpenAPI C++ SDK is the official C++ client for Tiger Brokers Open Platform, providing trading, market data, and WebSocket push functionalities.
English | 中文
- 🚀 Complete trading API support (place orders, cancel orders, query positions, etc.)
- 📊 Real-time market data (K-line, quotes, tick-by-tick trades, etc.)
- 🔌 WebSocket push notifications (positions, orders, real-time quotes)
- ♻️ Persistent HTTP client reuses its built-in connection pool
- 🌐 Cross-platform support (macOS, Linux, Windows)
- 🛡️ Type-safe C++ API design
- 📦 Static and dynamic library compilation support
| Platform | Compiler | CMake | Package Manager |
|---|---|---|---|
| macOS | Clang (Xcode) | 3.15+ | Homebrew + Source |
| Linux | GCC/G++ | 3.15+ | apt + Source |
| Windows | MSVC 2019/2022 | 3.15+ | vcpkg |
- Boost 1.86.0 (system, thread, log, program_options, chrono, filesystem)
- OpenSSL 1.0.1+ (3.x recommended)
- cpprestsdk Latest (HTTP client)
- Protobuf 5.28.3
- Abseil 20240722.0 (pinned C++14-compatible Protobuf runtime dependency)
- C++ Standard: C++14 minimum build baseline; C++17 consumer projects are supported
# Grant execute permission (first time only)
chmod +x scripts/build_linux_mac.sh
# Default build (Debug mode, auto-install dependencies and run demo)
./scripts/build_linux_mac.sh
# Release mode build
BUILD_TYPE=Release ./scripts/build_linux_mac.sh
# Build SDK only, skip demo
SKIP_DEMO=1 ./scripts/build_linux_mac.shThe script will automatically:
- Install system dependencies (Homebrew/apt)
- Compile Boost, cpprestsdk, Abseil 20240722.0, and Protobuf
- Build SDK (Debug + Release)
- Build and run demo
# Build SDK + demo (x64 Release MD)
powershell -ExecutionPolicy Bypass -File scripts\build_windows.ps1 `
-Triplet x64-windows -BuildType Release -Runtime MD
# Rebuild all 8 Windows precompiled zip packages
powershell -ExecutionPolicy Bypass -File scripts\package_windows.ps1If you don't want to build from source, use the pre-compiled libraries in the output/ directory:
output/
├── Mac/
│ ├── Debug.zip # macOS Debug static library + headers
│ └── Release.zip # macOS Release static library + headers
├── Linux/
│ ├── Debug/
│ └── Release/
└── Windows/
├── readme.md
├── x64/
│ ├── Debug-MD.zip
│ ├── Debug-MT.zip
│ ├── Release-MD.zip
│ └── Release-MT.zip
└── Win32/
├── Debug-MD.zip
├── Debug-MT.zip
├── Release-MD.zip
└── Release-MT.zip
brew install cmake wget automake libtool pkg-config openssl@3
# The one-click script builds Protobuf v5.28.3 and pinned Abseil 20240722.0
# from source. Do not install or use the latest Homebrew Abseil separately.cd /usr/local
wget https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2
tar --bzip2 -xf boost_1_86_0.tar.bz2
cd boost_1_86_0
./bootstrap.sh
./b2 headers
./b2 -j $(sysctl -n hw.ncpu)cd /tmp
git clone https://github.com/microsoft/cpprestsdk.git
cd cpprestsdk
git submodule update --init
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr/local/opt/cpprestsdk \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_SAMPLES=OFF \
-DBUILD_TESTS=OFF \
-DBOOST_ROOT=/usr/local/boost_1_86_0 \
-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3) \
-DCMAKE_CXX_FLAGS="-Wno-error=null-pointer-subtraction -w"
cmake --build build -- -j $(sysctl -n hw.ncpu)
sudo cmake --install buildcd /tmp
git clone --depth 1 --branch 20240722.0 https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_INSTALL_PREFIX=/usr/local/opt/abseil-20240722.0 \
-DABSL_BUILD_TESTING=OFF \
-DABSL_PROPAGATE_CXX_STD=ON \
-DBUILD_SHARED_LIBS=ON
cmake --build build -- -j $(sysctl -n hw.ncpu)
sudo cmake --install buildcd /tmp
curl -sL https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protobuf-28.3.tar.gz -o protobuf-28.3.tar.gz
tar xzf protobuf-28.3.tar.gz
cd protobuf-28.3
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/opt/protobuf-v5.28.3 \
-DCMAKE_CXX_STANDARD=14 \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_ABSL_PROVIDER=package \
-Dabsl_DIR=/usr/local/opt/abseil-20240722.0/lib/cmake/absl \
-DCMAKE_PREFIX_PATH=/usr/local/opt/abseil-20240722.0
cmake --build build -- -j $(sysctl -n hw.ncpu)
sudo cmake --install buildcd <project_root>
cmake -S . -B build/Debug \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr/local/opt/tigerapi/Debug \
-DBOOST_ROOT=/usr/local/boost_1_86_0 \
-DCMAKE_PREFIX_PATH="/usr/local/opt/cpprestsdk;/usr/local/opt/abseil-20240722.0;/usr/local/opt/protobuf-v5.28.3" \
-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
cmake --build build/Debug -- -j $(sysctl -n hw.ncpu)
sudo cmake --install build/Debugcd demo
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DBOOST_ROOT=/usr/local/boost_1_86_0 \
-DTIGERAPI_INCLUDE_DIR=/usr/local/opt/tigerapi/Debug/include \
-DTIGERAPI_LIBRARY=/usr/local/opt/tigerapi/Debug/lib/libtigerapi.a \
-DCPPREST_INCLUDE_DIR=/usr/local/opt/cpprestsdk/include \
-DCPPREST_LIBRARY=/usr/local/opt/cpprestsdk/lib/libcpprest.dylib \
-DProtobuf_INCLUDE_DIR=/usr/local/opt/protobuf-v5.28.3/include \
-DProtobuf_LIBRARY=/usr/local/opt/protobuf-v5.28.3/lib/libprotobuf.dylib \
-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
cmake --build build -- -j $(sysctl -n hw.ncpu)
# Run demo (set dynamic library path)
export DYLD_LIBRARY_PATH="/usr/local/opt/cpprestsdk/lib:/usr/local/opt/protobuf-v5.28.3/lib:$DYLD_LIBRARY_PATH"
./build/openapi_cpp_testsudo apt-get update
sudo apt-get install -y git wget bzip2 unzip gcc g++ libtool automake autoconf \
build-essential cmake libssl-dev libabsl-dev zlib1g-dev pkg-configSimilar to macOS, main differences:
- Remove
OPENSSL_ROOT_DIRparameter (OpenSSL is in system path on Linux) - Use
LD_LIBRARY_PATHinstead ofDYLD_LIBRARY_PATH
export LD_LIBRARY_PATH="/usr/local/opt/cpprestsdk/lib:/usr/local/opt/protobuf-v5.28.3/lib:$LD_LIBRARY_PATH"Windows platform provides two build methods:
-
Prerequisites
- Visual Studio 2019 or 2022
- Install "Desktop development with C++" workload
-
Prepare Dependencies
The project uses vcpkg for dependency management, supporting two approaches:
Automatic Installation (Recommended):
# vcpkg will automatically install dependencies based on vcpkg.json # Triggered automatically when opening the solution for the first time
Manual Installation:
git clone https://github.com/microsoft/vcpkg .vcpkg .\.vcpkg\bootstrap-vcpkg.bat -disableMetrics .\.vcpkg\vcpkg install boost:x64-windows openssl:x64-windows cpprestsdk:x64-windows protobuf:x64-windows
-
Open and Build
- Double-click to open
openapi-cpp-sdk.sln - Select configuration (recommended:
Release-MD|x64) - Right-click solution → Build Solution
- Double-click to open
-
Configuration Options
The solution provides 8 configuration combinations:
Configuration Platform Runtime Library Description Debug-MD x64/Win32 /MDd Debug + Dynamic runtime Debug-MT x64/Win32 /MTd Debug + Static runtime Release-MD x64/Win32 /MD Release + Dynamic runtime (Recommended) Release-MT x64/Win32 /MT Release + Static runtime -
Build Artifacts
output/Windows/ ├── x64/ │ ├── Release-MD/ │ │ ├── openapi-cpp-sdk.dll │ │ ├── openapi-cpp-sdk.lib │ │ └── openapi_cpp_test.exe │ └── Release-MT/ └── Win32/ └── ... -
Dependency Path Configuration
Project files are pre-configured with dependency paths:
- Boost:
.deps/boost/boost_1_86_0(can be overridden byBOOST_ROOTenvironment variable) - vcpkg dependencies:
vcpkg_installed/x64-windows/(automatically managed) - SDK headers:
include/
- Boost:
-
Package all Windows zips
.\scripts\package_windows.bat # Re-compress existing output directories without rebuilding .\scripts\package_windows.bat -SkipBuild
- Install vcpkg
git clone https://github.com/microsoft/vcpkg .vcpkg
.\.vcpkg\bootstrap-vcpkg.bat -disableMetrics- Install Dependencies
.\.vcpkg\vcpkg install boost:x64-windows openssl:x64-windows cpprestsdk:x64-windows protobuf:x64-windows- Build SDK
$env:VCPKG_ROOT = "$PWD\.vcpkg"
$toolchain = "$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
cmake -S . -B build\windows -A x64 `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE=$toolchain `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DCMAKE_INSTALL_PREFIX=output\Windows\x64\Release-MD
cmake --build build\windows --config Release
cmake --install build\windows --config Release- Build Demo
cmake -S demo -B demo\build\windows -A x64 `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE=$toolchain `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DTIGERAPI_INCLUDE_DIR=output\Windows\x64\Release-MD\include `
-DTIGERAPI_LIBRARY=output\Windows\x64\Release-MD\lib\tigerapi.lib
cmake --build demo\build\windows --config Release --target openapi_cpp_test#include "tigerapi/quote_client.h"
TigerClient client;
client.init("your_tiger_id", "your_private_key", "your_account");
// Get K-line data
std::vector<std::string> symbols = {"AAPL", "TSLA"};
ResponseModel response = client.grab_quote_kline(symbols, "day", "2024-01-01", "2024-12-31");#include "tigerapi/push_client.h"
// Create push client
PushClient push_client(tiger_id, private_key, "your_language");
// Subscribe to position updates
push_client.subscribe_position();
// Subscribe to quote updates
push_client.subscribe_quote({"AAPL", "TSLA"});
// Connect and receive push notifications
push_client.connect();For more examples, see demo/openapi_cpp_test/openapi_cpp_test.cpp.
openapi-cpp-sdk/
├── include/ # Header files
│ ├── tigerapi/ # SDK public headers
│ ├── cpprest/ # cpprestsdk headers
│ ├── google/protobuf/ # Protobuf 5.28.3 headers
│ └── openapi_pb/ # Protobuf generated message definitions
├── src/ # SDK source implementation
├── demo/ # Example code
│ └── openapi_cpp_test/
├── scripts/ # Build scripts
│ ├── build_linux_mac.sh # macOS/Linux one-click build
│ ├── build_windows.ps1 # Windows CMake build
│ ├── package_windows.ps1 # Windows zip packaging
│ └── package_windows.bat # Execution-policy-safe Windows packaging wrapper
├── output/ # Build artifacts
│ ├── Mac/
│ ├── Linux/
│ └── Windows/
└── CMakeLists.txt # CMake configuration
Q: OpenSSL not found
# Specify OpenSSL path
-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3)Q: Architecture mismatch (arm64 vs x86_64)
Modify architecture parameter in CMakeLists.txt and demo/CMakeLists.txt:
# ARM Mac (default)
set(CMAKE_CXX_FLAGS "-arch arm64 -std=c++14 ...")
# Intel Mac
set(CMAKE_CXX_FLAGS "-arch x86_64 -std=c++14 ...")Q: Dynamic library not found at runtime
export DYLD_LIBRARY_PATH="/usr/local/opt/cpprestsdk/lib:/usr/local/opt/protobuf-v5.28.3/lib:$DYLD_LIBRARY_PATH"Q: .so file not found at runtime
export LD_LIBRARY_PATH="/usr/local/opt/cpprestsdk/lib:/usr/local/opt/protobuf-v5.28.3/lib:$LD_LIBRARY_PATH"Q: vcpkg bootstrap failed
Ensure Visual Studio "Desktop development with C++" workload is installed.
Q: Runtime library mismatch (MT vs MD)
Ensure SDK and demo use the same -DCMAKE_MSVC_RUNTIME_LIBRARY setting.
Q: Protobuf version conflict
Use Protobuf 5.28.3 with pinned Abseil 20240722.0 to retain C++14 support.
Q: Warnings treated as errors
# Add compile flag to disable warnings
-DCMAKE_CXX_FLAGS="-w"See CHANGELOG.md for version history.
Apache License 2.0
For questions or issues:
- Submit a GitHub Issue
- Email: openapi@tigerbrokers.com