请求、响应与操作名
TigerRequest
public class TigerRequest<T> where T : TigerResponse| 属性 | 类型 | SDK 默认值 | 用途 |
|---|---|---|---|
ApiMethodName | string | 无 | QuoteApiService/TradeApiService 操作名常量 |
ModelValue | ApiModel | 客户端空模型 | 业务请求;序列化为 biz_content |
ApiVersion | string | TigerApiConstants.DEFAULT_VERSION | 协议版本 |
Charset | string | UTF-8 常量 | 签名字符集 |
SignType | string | RSA 常量 | 签名算法 |
TigerId、Timestamp、Sign、DeviceId | string | 客户端填写 | 通常不要手工设置 |
*ApiService 类不是服务客户端。IsQuoteApi(string) 和 IsTradeApi(string) 仅验证操作名是否在集合中;实际网络调用在 QuoteClient/TradeClient 的 Execute 和 ExecuteAsync。
TigerResponse
所有响应继承 TigerResponse,共同字段为 Code (int)、Message (string)、Timestamp (long) 和 Sign (string);IsSuccess() 判断 Code == 0。具体数据读取响应类声明的 Data:可能是强类型对象、列表、Dictionary<string, object> 或 object。
频率与错误
- SDK 最多按
TigerConfig.FailRetryCounts重试可重试 HTTP 失败。 - 同步下单和令牌刷新不自动重试;应用不得把业务失败当网络失败重提。
- 批量数量、日期窗口、分页和频率由服务端接口及账户许可决定。使用响应业务码、分页令牌和退避,而不是假设其他 SDK 默认值。
- 行情、交易、期权、期货、深度和推送权限彼此独立。
协议字段模型
下列五个服务端操作已在 QuoteApiService 注册,但 C# SDK 1.2.3 没有专用请求类。匿名对象不能赋给 TigerRequest.ModelValue;应用应定义继承 ApiModel 的小型模型:
using Newtonsoft.Json;
using TigerOpenAPI.Common.Enum;
using TigerOpenAPI.Model;
public sealed class StockDetailModel : ApiModel
{
[JsonProperty(PropertyName = "symbols")]
public List<string> Symbols { get; set; } = new();
[JsonProperty(PropertyName = "sec_type", NullValueHandling = NullValueHandling.Ignore)]
public string? SecType { get; set; }
}
public sealed class OptionTimelineQuery
{
[JsonProperty(PropertyName = "symbol")]
public string Symbol { get; set; } = string.Empty;
[JsonProperty(PropertyName = "expiry")]
public long Expiry { get; set; }
[JsonProperty(PropertyName = "right")]
public string Right { get; set; } = string.Empty;
[JsonProperty(PropertyName = "strike")]
public string Strike { get; set; } = string.Empty;
[JsonProperty(PropertyName = "begin_time", NullValueHandling = NullValueHandling.Ignore)]
public long? BeginTime { get; set; }
}
public sealed class OptionTimelineModel : ApiModel
{
[JsonProperty(PropertyName = "option_query")]
public List<OptionTimelineQuery> OptionQuery { get; set; } = new();
[JsonProperty(PropertyName = "market")]
public Market Market { get; set; }
}
public sealed class IndustryListModel : ApiModel
{
[JsonProperty(PropertyName = "industry_level", NullValueHandling = NullValueHandling.Ignore)]
public string? IndustryLevel { get; set; }
}
public sealed class IndustryStocksModel : ApiModel
{
[JsonProperty(PropertyName = "industry_id")]
public string IndustryId { get; set; } = string.Empty;
[JsonProperty(PropertyName = "market", NullValueHandling = NullValueHandling.Ignore)]
public string? Market { get; set; }
}
public sealed class StockIndustryModel : ApiModel
{
[JsonProperty(PropertyName = "symbol")]
public string Symbol { get; set; } = string.Empty;
[JsonProperty(PropertyName = "market", NullValueHandling = NullValueHandling.Ignore)]
public string? Market { get; set; }
[JsonProperty(PropertyName = "sec_type", NullValueHandling = NullValueHandling.Ignore)]
public string? SecType { get; set; }
}Updated 21 days ago
Did this page help you?
