Preparation

Environment Requirements

  • Operating System:
    • Windows
    • MacOS
    • Linux
  • Programming Language: C++17 or above
  • Compiler: Any compiler supporting C++17 (e.g., GCC 7+, Clang 5+, MSVC 2017+)

Dependencies

The C++ SDK depends on the following third-party libraries:

LibraryPurpose
cpprestsdk (C++ REST SDK)HTTP requests and JSON processing
OpenSSLEncryption and signing
BoostBase library support
ProtobufSerialization and deserialization of push data

Get SDK and Build

The SDK source code is hosted on GitHub: tigerfintech/openapi-cpp-sdk

git clone https://github.com/tigerfintech/openapi-cpp-sdk.git
# Install dependencies
brew install boost openssl cpprestsdk protobuf

# Build
cd openapi-cpp-sdk
mkdir build && cd build
cmake ..
make

Development Tools

AI coding tools can automatically read Tiger OpenAPI documentation and generate runnable SDK code from natural language descriptions, greatly lowering the barrier to entry.

Usage

  1. Complete the SDK build following the steps above
  2. Place the configuration file tiger_openapi_config.properties into the project directory
  3. Add the Tiger OpenAPI Documentation as context for the AI tool (refer to the instructions below for each tool)
  4. Describe your requirements in natural language, and the AI will read the documentation and generate the corresponding SDK code

For example, you can simply say: "Get the daily K-line data for AAPL for the last 30 days" or "Place a limit buy order for NVDA", and the AI will automatically generate the complete code by referencing the documentation.

Cursor / Trae / Windsurf

Add documentation as context in the project:

  • Cursor: Add the Tiger OpenAPI documentation URL in Settings > Docs; the AI will automatically search it during conversations
  • Trae: Add the documentation link or key pages to the Knowledge Base; the AI will generate code based on the documentation
  • Windsurf: Reference online documentation via @docs, or place documentation content in the project directory for AI reading

VS Code + GitHub Copilot

Install the GitHub Copilot extension in VS Code and use the Chat panel to have the AI generate code. Use #file to reference documentation or code files in the project as context.

Claude Code / Kiro

Terminal AI tools; after launching, you can directly reference documentation links in the conversation, and the AI will fetch and understand the documentation content:

# Install Claude Code
npm install -g @anthropic-ai/claude-code

# Launch in project directory
cd openapi-cpp-sdk
claude

After launching, send the documentation link to the AI, for example: "Refer to https://docs.itigerup.com/docs/prepare-cpp and help me get position information".

Register Developer Information

Before using the API, please activate permissions first. Individual users should visit the API website to register developer identity. Chrome browser is recommended.

Note: To activate Open API, you need to have a Tiger Brokers account with deposited funds. Developers and users will be required to sign an API authorization agreement.

You will need to complete the developer information registration on this page. Please fill in and submit your information.

After successful registration, you can obtain the following information on this page:

  • tiger_id: A unique ID assigned by the Open Platform to each developer, used to identify a developer. All API calls require tiger_id.
  • account: The user's fund account, required when calling trade-related APIs. There are three types:
    • Global Account: Starts with uppercase letter U, e.g., U12300123
    • Standard Account: A shorter numeric string (5-10 digits), e.g., 51230321
    • Paper Account: 17-digit number, e.g., 20191106192858300

Note: You must save the private key locally and keep it secure to prevent leakage. If a leak is discovered, please update it immediately. The private key is not stored on Tiger's servers; you need to save it before refreshing the page.

The C++ SDK uses PKCS#8 format private keys. If you encounter issues using the SDK, first check whether the private key format is correct.

The generated configuration file tiger_openapi_config.properties has the following format. The account is the default account, which can be switched between live and paper trading accounts. For institutional accounts, secret_key must also be configured (obtained from the institution center).

private_key_pk8=MIICeAIBADANBgkqhkiG9w0BAQ...
tiger_id=20150001
account=12345678
license=TBHK
env=PROD

Purchase Market Data (Optional)

We provide free delayed market data, but real-time market data requires a separate purchase. Open API market data permissions are independent from the APP and PC platforms. Even if you have already purchased APP or PC market data, you still need to purchase Open API market data permissions separately to receive real-time data.

API Configuration

Before making API calls, you need to complete the API configuration.

Method 1: Using Configuration File (Recommended)

Export the configuration file tiger_openapi_config.properties from the developer website and place it in an appropriate system path. Then pass the path to the ClientConfig constructor:

#include "tigerapi/client_config.h"

using namespace TIGER_API;

// Initialize via configuration file (recommended)
ClientConfig config(false, U("/path/to/your/properties/"));

Method 2: Direct Configuration in Code

#include "tigerapi/client_config.h"

using namespace TIGER_API;

ClientConfig config(U("your_tiger_id"), U("your_private_key"), U("your_account"));
config.license = U("TBSG");
config.lang = U("zh_CN");

ClientConfig Common Properties

// Constructor
ClientConfig config(false, U("/path/to/your/properties/"));

// Main properties
config.tiger_id;       // Tiger ID
config.private_key;    // Private key
config.account;        // Fund account
config.license;        // License, e.g., "TBSG"
config.lang;           // Language, e.g., "zh_CN", "en_US"
config.secret_key;     // Institutional account secret key

// Push-related configuration
config.use_full_tick;    // Whether to use full tick data, default false
config.send_interval;    // Send interval (ms), default 10000
config.receive_interval; // Receive interval (ms), default 10000

What’s Next