Trading
The C# SDK provides all trading APIs through TradeClient. All requests use the TigerRequest<TResponse> generic wrapper and are called asynchronously via await tradeClient.ExecuteAsync(request). Full runnable example:
using TigerOpenAPI.Common;
using TigerOpenAPI.Trade;
using TigerOpenAPI.Trade.Response;
using TigerOpenAPI.Trade.Model;
TigerConfig config = new TigerConfig()
{
ConfigFilePath = "/path/to/tiger_openapi_config.properties"
};
TradeClient tradeClient = new TradeClient(config);
// Get positions
TigerRequest<PositionResponse> request = new TigerRequest<PositionResponse>()
{
ApiMethodName = TradeApiService.POSITIONS,
ModelValue = new PositionModel() { Account = config.DefaultAccount }
};
PositionResponse response = await tradeClient.ExecuteAsync(request);
Console.WriteLine(response);Contract Query
contract Query Contract Info
Description
Query detailed information for a contract including name, currency, and minimum trade unit.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Symbol | string | Yes | Contract symbol, e.g. "AAPL", "00700" |
| SecType | string | Yes | Security type: "STK" (stock) / "OPT" (option) / "FUT" (future) / "WAR" (warrant) / "IOPT" (inline warrant) |
Returns
ContractResponse containing contract details with Symbol, Name, Currency, Exchange, LotSize, etc.
Example
// US stock contract
ContractItem contract = ContractItem.BuildStockContract("AAPL", Currency.USD.ToString());
TigerRequest<ContractResponse> request = new TigerRequest<ContractResponse>()
{
ApiMethodName = TradeApiService.CONTRACT,
ModelValue = new ContractModel() { ContractInfo = contract }
};
ContractResponse response = await tradeClient.ExecuteAsync(request);
// HK stock contract
ContractItem hkContract = ContractItem.BuildStockContract("00700", Currency.HKD.ToString());quoteContract Query Derivative Contract
Description
Query detailed info for options or futures contracts, including strike, expiry, multiplier, and other derivative-specific fields.
Example
// US option contract
ContractItem optContract = ContractItem.BuildOptionContract("AAPL", "20250117", 150.0D, "CALL");
// HK warrant contract
ContractItem warContract = ContractItem.BuildWarrantContract("13745", "20211217", 719.38D, Right.CALL.ToString());Orders
Order Object
Orders are built using ContractItem and PlaceOrderModel:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| ContractInfo | ContractItem | Contract object |
| Action | ActionType | Direction: ActionType.BUY / ActionType.SELL |
| OrderType | OrderType | Type: OrderType.MKT / OrderType.LMT / OrderType.STP / OrderType.STP_LMT / OrderType.TRAIL |
| TotalQuantity | double | Number of shares/contracts |
| LimitPrice | double | Limit price (required for LMT / STP_LMT) |
| AuxPrice | double | Stop trigger price (required for STP / STP_LMT / TRAIL) |
| TimeInForce | TimeInForce | TimeInForce.DAY / TimeInForce.GTC |
| OutsideRth | bool | Allow extended-hours trading (US stocks only) |
placeOrder Place Order
Description
Submit an order to the exchange. Returns an order ID on success.
Example
// Limit buy AAPL
ContractItem contract = ContractItem.BuildStockContract("AAPL", Currency.USD.ToString());
PlaceOrderModel orderModel = PlaceOrderModel.buildLimitOrder(
config.DefaultAccount, contract, ActionType.BUY, 10, 150.0D);
TigerRequest<PlaceOrderResponse> request = new TigerRequest<PlaceOrderResponse>()
{
ApiMethodName = TradeApiService.PLACE_ORDER,
ModelValue = orderModel
};
PlaceOrderResponse response = await tradeClient.ExecuteAsync(request);
Console.WriteLine("Order ID: " + response.OrderId);
// Market sell
PlaceOrderModel mktOrder = PlaceOrderModel.buildMarketOrder(
config.DefaultAccount, contract, ActionType.SELL, 10);
// Extended hours order
PlaceOrderModel extOrder = PlaceOrderModel.buildLimitOrder(
config.DefaultAccount, contract, ActionType.BUY, 5, 148.0D);
extOrder.OutsideRth = true;
extOrder.TimeInForce = TimeInForce.DAY;Data Sample
Response:
{
"orderId": 12345678,
"status": "Submitted",
"symbol": "AAPL"
}previewOrder Preview Order
Description
Estimate order costs and feasibility without actually submitting to the exchange.
Example
ContractItem contract = ContractItem.BuildStockContract("AAPL", Currency.USD.ToString());
PlaceOrderModel orderModel = PlaceOrderModel.buildLimitOrder(
config.DefaultAccount, contract, ActionType.BUY, 10, 150.0D);
TigerRequest<PreviewOrderResponse> request = new TigerRequest<PreviewOrderResponse>()
{
ApiMethodName = TradeApiService.PREVIEW_ORDER,
ModelValue = orderModel
};
PreviewOrderResponse response = await tradeClient.ExecuteAsync(request);
Console.WriteLine("Estimated commission: " + response.Commission);Special Order Types
Stop Order (STP)
PlaceOrderModel stpOrder = PlaceOrderModel.buildStopOrder(
config.DefaultAccount, contract, ActionType.SELL, 10, 145.0D);Stop Limit Order (STP_LMT)
PlaceOrderModel stpLmtOrder = PlaceOrderModel.buildStopLimitOrder(
config.DefaultAccount, contract, ActionType.SELL, 10, 145.0D, 144.0D);Trailing Stop Order (TRAIL)
PlaceOrderModel trailOrder = new PlaceOrderModel()
{
Account = config.DefaultAccount,
ContractInfo = contract,
Action = ActionType.SELL,
OrderType = OrderType.TRAIL,
TotalQuantity = 10,
AuxPrice = 5.0D // Trailing amount
};Auction Orders
// Auction market order (AM)
PlaceOrderModel amOrder = new PlaceOrderModel()
{
Account = config.DefaultAccount,
ContractInfo = contract,
Action = ActionType.BUY,
OrderType = OrderType.AUCTION_MKT,
TotalQuantity = 10
};
// Auction limit order (AL)
PlaceOrderModel alOrder = new PlaceOrderModel()
{
Account = config.DefaultAccount,
ContractInfo = contract,
Action = ActionType.BUY,
OrderType = OrderType.AUCTION_LIMIT,
TotalQuantity = 10,
LimitPrice = 150.0D
};Option Order
ContractItem optContract = ContractItem.BuildOptionContract("AAPL", "20250117", 150.0D, "CALL");
PlaceOrderModel optOrder = PlaceOrderModel.buildLimitOrder(
config.DefaultAccount, optContract, ActionType.BUY, 1, 9.50D);Futures Order
ContractItem futContract = ContractItem.BuildFutureContract("ES2506", Currency.USD.ToString());
PlaceOrderModel futOrder = PlaceOrderModel.buildLimitOrder(
config.DefaultAccount, futContract, ActionType.BUY, 1, 5900.0D);modifyOrder Modify Order
Description
Modify an open order (not yet fully filled). Supports changing price and quantity.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Id | long | Yes | Order ID to modify |
| LimitPrice | double | No | New limit price |
| TotalQuantity | double | No | New quantity |
Example
ModifyOrderModel modifyModel = new ModifyOrderModel()
{
Account = config.DefaultAccount,
Id = 12345,
LimitPrice = 148.0D,
TotalQuantity = 10
};
TigerRequest<ModifyOrderResponse> request = new TigerRequest<ModifyOrderResponse>()
{
ApiMethodName = TradeApiService.MODIFY_ORDER,
ModelValue = modifyModel
};
ModifyOrderResponse response = await tradeClient.ExecuteAsync(request);cancelOrder Cancel Order
Description
Cancel a pending order. Only orders with pending status can be cancelled.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Id | long | Yes | Order ID to cancel |
Example
CancelOrderModel cancelModel = new CancelOrderModel()
{
Account = config.DefaultAccount,
Id = 12345
};
TigerRequest<CancelOrderResponse> request = new TigerRequest<CancelOrderResponse>()
{
ApiMethodName = TradeApiService.CANCEL_ORDER,
ModelValue = cancelModel
};
CancelOrderResponse response = await tradeClient.ExecuteAsync(request);Order Queries
orders Get All Orders
Description
Query all historical orders for the account across all statuses.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Account ID |
| SecType | string | No | Security type filter |
| Market | Market | No | Market filter |
| Symbol | string | No | Symbol filter |
| StartTime | long | No | Start timestamp (ms) |
| EndTime | long | No | End timestamp (ms) |
| Limit | int | No | Max results, up to 100 |
Returns
OrdersResponse containing a list of orders, each with Id, Symbol, Action, Status, TotalQuantity, FilledQuantity, LimitPrice, AvgFillPrice, CreateTime, etc.
Example
TigerRequest<OrdersResponse> request = new TigerRequest<OrdersResponse>()
{
ApiMethodName = TradeApiService.ORDERS,
ModelValue = new OrdersModel() { Account = config.DefaultAccount }
};
OrdersResponse response = await tradeClient.ExecuteAsync(request);Data Sample
Response:
[
{
"id": 12345678,
"symbol": "AAPL",
"action": "BUY",
"status": "Filled",
"totalQuantity": 10,
"filledQuantity": 10,
"limitPrice": 150.0,
"avgFillPrice": 149.95,
"createTime": 1735042800000
}
]activeOrders Get Active Orders
Description
Get all open/pending orders that have not been fully filled.
Example
TigerRequest<OrdersResponse> request = new TigerRequest<OrdersResponse>()
{
ApiMethodName = TradeApiService.ACTIVE_ORDERS,
ModelValue = new OrdersModel() { Account = config.DefaultAccount }
};
OrdersResponse response = await tradeClient.ExecuteAsync(request);filledOrders Get Filled Orders
Description
Get all fully executed orders.
Example
TigerRequest<OrdersResponse> request = new TigerRequest<OrdersResponse>()
{
ApiMethodName = TradeApiService.FILLED_ORDERS,
ModelValue = new OrdersModel() { Account = config.DefaultAccount }
};
OrdersResponse response = await tradeClient.ExecuteAsync(request);inactiveOrders Get Inactive Orders
Description
Get all cancelled or expired orders.
Example
TigerRequest<OrdersResponse> request = new TigerRequest<OrdersResponse>()
{
ApiMethodName = TradeApiService.INACTIVE_ORDERS,
ModelValue = new OrdersModel() { Account = config.DefaultAccount }
};
OrdersResponse response = await tradeClient.ExecuteAsync(request);orderTransactions Get Order Fills
Description
Get individual fill records for an order. One order may have multiple partial fills.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Id | long | Yes | Order ID |
Example
TigerRequest<TransactionsResponse> request = new TigerRequest<TransactionsResponse>()
{
ApiMethodName = TradeApiService.ORDER_TRANSACTIONS,
ModelValue = new TransactionModel() { Id = 12345 }
};
TransactionsResponse response = await tradeClient.ExecuteAsync(request);Positions & Assets
positions Get Positions
Description
Query all current positions for the account across stocks, options, and futures.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Account ID |
| SecType | string | No | Security type filter |
| Market | Market | No | Market filter |
| Symbol | string | No | Symbol filter |
Returns
PositionResponse containing a list of positions, each with Symbol, Quantity, AverageCost, MarketValue, UnrealizedPnl, RealizedPnl, etc.
Example
TigerRequest<PositionResponse> request = new TigerRequest<PositionResponse>()
{
ApiMethodName = TradeApiService.POSITIONS,
ModelValue = new PositionModel() { Account = config.DefaultAccount }
};
PositionResponse response = await tradeClient.ExecuteAsync(request);Data Sample
Response:
[
{
"symbol": "AAPL",
"quantity": 100,
"averageCost": 145.50,
"marketValue": 22752.0,
"unrealizedPnl": 2202.0,
"realizedPnl": 500.0
}
]assets Get Assets
Description
Query account asset overview including net liquidation, cash balance, and margin usage.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Account ID |
Returns
AssetResponse containing NetLiquidation, CashBalance, BuyingPower, GrossPositionValue, UnrealizedPnl, RealizedPnl, etc.
Example
TigerRequest<AssetResponse> request = new TigerRequest<AssetResponse>()
{
ApiMethodName = TradeApiService.ASSETS,
ModelValue = new AssetModel() { Account = config.DefaultAccount }
};
AssetResponse response = await tradeClient.ExecuteAsync(request);Data Sample
Response:
{
"account": "123456789",
"netLiquidation": 250000.0,
"cashBalance": 50000.0,
"buyingPower": 100000.0,
"grossPositionValue": 200000.0,
"unrealizedPnl": 5000.0,
"realizedPnl": 3000.0
}primeAssets Get Prime Account Assets
Description
Query consolidated account (Prime account) assets including sub-account summaries.
Example
TigerRequest<PrimeAssetResponse> request = new TigerRequest<PrimeAssetResponse>()
{
ApiMethodName = TradeApiService.PRIME_ASSETS,
ModelValue = new AssetModel() { Account = config.DefaultAccount }
};
PrimeAssetResponse response = await tradeClient.ExecuteAsync(request);accountList Get Account List
Description
Query all accounts under the current user, including live and paper trading accounts.
Example
TigerRequest<AccountsResponse> request = new TigerRequest<AccountsResponse>()
{
ApiMethodName = TradeApiService.MANAGED_ACCOUNTS
};
AccountsResponse response = await tradeClient.ExecuteAsync(request);
Console.WriteLine("Accounts: " + string.Join(", ", response.Accounts));Fund & Asset Management
transferFund Query Deposit/Withdrawal Records
Description
Query deposit and withdrawal records for a trading account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Trading account ID |
| SegType | SegmentType | No | Segment: SegmentType.SEC / SegmentType.FUT |
| StartDate | string | No | Start date "YYYY-MM-DD" |
| EndDate | string | No | End date "YYYY-MM-DD" |
| Currency | string | No | Currency filter, e.g. "USD" |
| Page | int | No | Page number |
| Limit | int | No | Page size |
Returns
DepositWithdrawResponse → List<DepositWithdrawItem>
| Field | Type | Description |
|---|---|---|
| Id | long | Record ID |
| Type | string | Type |
| Currency | string | Currency |
| Amount | decimal | Amount |
| BusinessDate | string | Business date |
| CompletedStatus | string | Status |
| CreatedAt | long | Created timestamp (ms) |
Example
TigerRequest<DepositWithdrawResponse> request = new TigerRequest<DepositWithdrawResponse>()
{
ApiMethodName = TradeApiService.TRANSFER_FUND,
ModelValue = new DepositWithdrawModel { Account = config.DefaultAccount, SegType = SegmentType.SEC }
};
DepositWithdrawResponse response = await tradeClient.ExecuteAsync(request);fundDetails Query Fund Details
Description
Query fund flow details (capital ledger) for a trading account, supporting pagination.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Trading account ID |
| SegTypes | List<string> | Yes | Segment type list |
| FundType | string | No | Fund flow type filter |
| Currency | string | No | Currency filter |
| StartDate | string | No | Start date |
| EndDate | string | No | End date |
| Start | long | No | Pagination start offset |
| Limit | long | No | Page size |
Returns
FundDetailsResponse → FundDetailsPageItem → List<FundDetailsItem>
| Field | Type | Description |
|---|---|---|
| Page | int | Current page |
| Limit | long | Page size |
| PageCount | int | Total pages |
| ItemCount | long | Total items |
| Items | List<FundDetailsItem> | Detail list |
FundDetailsItem fields: Id, Currency, Type, Desc, ContractName, SegType, Amount, BusinessDate, UpdatedAt
Example
TigerRequest<FundDetailsResponse> request = new TigerRequest<FundDetailsResponse>()
{
ApiMethodName = TradeApiService.FUND_DETAILS,
ModelValue = new FundDetailsModel(config.DefaultAccount, new List<string> { "SEC" })
};
FundDetailsResponse response = await tradeClient.ExecuteAsync(request);aggregateAssets Query Aggregate Assets
Description
Query aggregated asset summary for a trading account, including net liquidation value, margin, available cash, and more.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Trading account ID |
| SegType | string | Yes | Segment: "SEC" / "FUT" |
| BaseCurrency | string | No | Base currency for conversion |
Returns
AggregateAssetResponse → AggregateAssetItem
| Field | Type | Description |
|---|---|---|
| Currency | string | Currency |
| CashBalance | decimal | Cash balance |
| NetLiquidation | decimal | Net liquidation value |
| InitMargin | decimal | Initial margin |
| MaintainMargin | decimal | Maintenance margin |
| AvailableCash | decimal | Available cash |
| ExcessEquity | decimal | Excess equity |
| BuyingPower | decimal | Buying power |
| GrossPositionValue | decimal | Gross position value |
Example
TigerRequest<AggregateAssetResponse> request = new TigerRequest<AggregateAssetResponse>()
{
ApiMethodName = TradeApiService.AGGREGATE_ASSETS,
ModelValue = new AggregateAssetModel(config.DefaultAccount, "SEC")
};
AggregateAssetResponse response = await tradeClient.ExecuteAsync(request);Position Transfer
positionTransfer Initiate Position Transfer
Description
Initiate an internal position transfer between two accounts.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| FromAccount | string | Yes | Source account ID |
| ToAccount | string | Yes | Target account ID |
| Market | string | Yes | Market |
| Items | List<PositionTransferDetail> | Yes | Positions to transfer |
PositionTransferDetail fields: Symbol, SecType, Expiry, Strike, Right, Quantity
Returns
PositionTransferResponse → PositionTransferItem
| Field | Type | Description |
|---|---|---|
| Id | long | Transfer ID |
| Status | string | Status |
| Direction | string | Direction |
| CreatedAt | long | Created timestamp (ms) |
Example
var items = new List<PositionTransferDetail>
{
new PositionTransferDetail { Symbol = "AAPL", SecType = "STK", Quantity = 100 }
};
TigerRequest<PositionTransferResponse> request = new TigerRequest<PositionTransferResponse>()
{
ApiMethodName = TradeApiService.POSITION_TRANSFER,
ModelValue = new PositionTransferModel(config.DefaultAccount, "account_b", "US", items)
};
PositionTransferResponse response = await tradeClient.ExecuteAsync(request);positionTransferRecords Query Position Transfer Records
Description
Query internal position transfer history for an account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Trading account ID |
| SinceDate | string | No | Start date "YYYY-MM-DD" |
| ToDate | string | No | End date "YYYY-MM-DD" |
| Status | string | No | Status filter |
| Market | string | No | Market filter |
| Symbol | string | No | Symbol filter |
Returns
PositionTransferRecordsResponse → List<PositionTransferRecordItem>
Fields: Id, AccountId, CounterpartyAccountId, Method, Direction, Status, Memo, CreatedAt, UpdatedAt
Example
TigerRequest<PositionTransferRecordsResponse> request = new TigerRequest<PositionTransferRecordsResponse>()
{
ApiMethodName = TradeApiService.POSITION_TRANSFER_RECORDS,
ModelValue = new PositionTransferRecordsModel(config.DefaultAccount, "2025-01-01", "2025-04-01")
};
PositionTransferRecordsResponse response = await tradeClient.ExecuteAsync(request);positionTransferDetail Query Position Transfer Detail
Description
Query the detail of a single position transfer, including per-symbol status.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Id | long | Yes | Transfer ID |
| Account | string | Yes | Trading account ID |
Returns
PositionTransferDetailResponse → PositionTransferDetailItem → List<PositionTransferStockDetail>
PositionTransferStockDetail fields: Symbol, Market, Quantity, Status, Message, UpdatedAt
Example
TigerRequest<PositionTransferDetailResponse> request = new TigerRequest<PositionTransferDetailResponse>()
{
ApiMethodName = TradeApiService.POSITION_TRANSFER_DETAIL,
ModelValue = new PositionTransferDetailModel(transferId, config.DefaultAccount)
};
PositionTransferDetailResponse response = await tradeClient.ExecuteAsync(request);positionTransferExternalRecords Query External Position Transfer Records
Description
Query external broker (ACATS) position transfer records for an account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Account | string | Yes | Trading account ID |
| SinceDate | string | No | Start date |
| ToDate | string | No | End date |
| Status | string | No | Status filter |
Returns
PositionTransferExternalRecordsResponse → List<PositionTransferExternalRecordItem>
Key fields: Id, Status, InstitutionName, DtcNumber, TransferMethod, Side, Market, FullPortfolio, AllFinished, CreatedAt
Example
TigerRequest<PositionTransferExternalRecordsResponse> request = new TigerRequest<PositionTransferExternalRecordsResponse>()
{
ApiMethodName = TradeApiService.POSITION_TRANSFER_EXTERNAL_RECORDS,
ModelValue = new PositionTransferRecordsModel(config.DefaultAccount, "2025-01-01", "2025-04-01")
};
PositionTransferExternalRecordsResponse response = await tradeClient.ExecuteAsync(request);Updated 4 days ago
