C# SDK

The Tiger OpenAPI C# SDK provides market data, trading, account management, and real-time streaming. These pages follow the SDK 1.2.3 source.

Documentation

Invocation model

The uppercase members of QuoteApiService and TradeApiService are server operation-name constants, not callable methods. Except for five option-exercise convenience methods, HTTP APIs are invoked by putting an operation, request model, and exact response type in TigerRequest<TResponse>, then calling QuoteClient.ExecuteAsync or TradeClient.ExecuteAsync.

Installation

dotnet add package TigerBrokers.OpenAPI

Or search for TigerBrokers.OpenAPI in the Visual Studio NuGet Package Manager.

Configuration

Option 1: Properties file

TigerConfig config = new TigerConfig()
{
    ConfigFilePath = "your_config_directory_path"
};

File format:

tiger_id=your_developer_id
private_key=your_rsa_private_key
default_account=your_trading_account

Option 2: Code

TigerConfig config = new TigerConfig()
{
    TigerId = "your_tiger_id",
    PrivateKey = "your_rsa_private_key",
    DefaultAccount = "your_trading_account",
    Language = Language.en_US,
    TimeZone = CustomTimeZone.HK_ZONE
};

Config options

FieldDescriptionRequiredDefault
TigerIdDeveloper IDYes-
PrivateKeyRSA private keyYes-
DefaultAccountTrading accountNo-
LanguageLanguage (zh_CN/en_US)Nozh_CN
TimeZoneTime zoneNoHK_ZONE
ConfigFilePathPath to properties fileNo-

Quick Start

using TigerOpenAPI.Common;
using TigerOpenAPI.Common.Enum;
using TigerOpenAPI.Config;
using TigerOpenAPI.Model;
using TigerOpenAPI.Quote;
using TigerOpenAPI.Quote.Response;
using TigerOpenAPI.Quote.Model;

// Create config
TigerConfig config = new TigerConfig()
{
    ConfigFilePath = "your_config_directory_path",
    Language = Language.en_US
};

// Create quote client
QuoteClient quoteClient = new QuoteClient(config);

// Get market state
TigerRequest<MarketStateResponse> request = new TigerRequest<MarketStateResponse>()
{
    ApiMethodName = QuoteApiService.MARKET_STATE,
    ModelValue = new QuoteMarketModel() { Market = Market.US }
};
MarketStateResponse? response = await quoteClient.ExecuteAsync(request);
Console.WriteLine(response?.Data);

Did this page help you?