数字货币行情

数字货币 HTTP 行情支持实时行情、K 线和当日分时。请求代码使用 BTC.USD 等格式,并在请求模型中设置 SecType = SecType.CC。当前不支持数字货币历史分时。

获取数字货币实时行情

使用 TigerRequest<QuoteRealTimeQuoteResponse>QuoteApiService.QUOTE_REAL_TIMEQuoteSymbolModel。设置 SecType = SecType.CC

RealTimeQuoteItem.Amount 对应 JSON 字段 amount,表示成交额。

TigerRequest<QuoteRealTimeQuoteResponse> request = new()
{
    ApiMethodName = QuoteApiService.QUOTE_REAL_TIME,
    ModelValue = new QuoteSymbolModel
    {
        Symbols = new List<string> { "BTC.USD" },
        SecType = SecType.CC
    }
};
QuoteRealTimeQuoteResponse? response = await quoteClient.ExecuteAsync(request);
double amount = response?.Data is { Count: > 0 } data ? data[0].Amount : 0;

获取数字货币 K 线

使用 TigerRequest<QuoteKlineResponse>QuoteApiService.KLINEQuoteKlineModel。数字货币请求将 QuoteKlineModel.SecType 设为 SecType.CC

分页时读取 KlineItem.NextPageToken,并在下一次请求中设置 QuoteKlineModel.PageToken;同时保留 SecType.CC

KlinePoint.VolumeDecimal 是可空的 double?,对应 JSON 字段 volumeDecimal。设置 SecType.CC 的数字货币 K 线使用该字段保留小数成交量;任何响应都可能缺失或为 null,此时使用整数 KlinePoint.Volume

返回

响应数据结构List<KlineItem>,每项的 ItemsList<KlinePoint>

KlineItem 字段

字段C# 类型说明
Symbolstring数字货币代码
PeriodstringK 线周期
NextPageTokenstring下一页标记
ItemsList<KlinePoint>K 线数据点列表

KlinePoint 字段

字段C# 类型说明
TimelongK 线时间戳
Opendouble开盘价
Highdouble最高价
Lowdouble最低价
Closedouble收盘价
Amountdouble成交额
Volumelong整数成交量
VolumeDecimaldouble?小数成交量

示例

TigerRequest<QuoteKlineResponse> request = new()
{
    ApiMethodName = QuoteApiService.KLINE,
    ModelValue = new QuoteKlineModel
    {
        Symbols = new List<string> { "BTC.USD" },
        Period = KLineType.day.Value,
        Limit = 300,
        SecType = SecType.CC
    }
};

QuoteKlineResponse? response = await quoteClient.ExecuteAsync(request);
double? volume = response?.Data?[0].Items?[0].VolumeDecimal;

获取数字货币当日分时

使用 TigerRequest<QuoteTimelineResponse>QuoteApiService.TIMELINEQuoteTimelineModel。数字货币请求将 QuoteTimelineModel.SecType 设为 SecType.CC

TimelinePoint.VolumeDecimal 是可空的 double?,对应 JSON 字段 volumeDecimal。设置 SecType.CC 的数字货币当前分时使用该字段保留小数成交量;任何响应都可能缺失或为 null,此时使用整数 TimelinePoint.Volume。此支持仅适用于 timeline 当日分时请求,不适用于 history_timeline 历史分时请求。

返回

响应数据结构List<TimelineItem>,其中 IntradayPreMarketAfterHours 均为 TimelineRange,其 ItemsList<TimelinePoint>

TimelineItem 字段

字段C# 类型说明
Symbolstring数字货币代码
Periodstring分时周期
PreClosedouble昨收价
IntradayTimelineRange盘中分时数据
PreMarketTimelineRange盘前分时数据
AfterHoursTimelineRange盘后分时数据

TimelineRange 字段

字段C# 类型说明
BeginTimelong时段开始时间戳
EndTimelong时段结束时间戳
ItemsList<TimelinePoint>分时数据点列表

TimelinePoint 字段

字段C# 类型说明
Timelong分时点时间戳
Pricedouble最新价
AvgPricedouble均价
Volumelong整数成交量
VolumeDecimaldouble?小数成交量

示例

TigerRequest<QuoteTimelineResponse> request = new()
{
    ApiMethodName = QuoteApiService.TIMELINE,
    ModelValue = new QuoteTimelineModel
    {
        Symbols = new List<string> { "BTC.USD" },
        SecType = SecType.CC
    }
};

QuoteTimelineResponse? response = await quoteClient.ExecuteAsync(request);
double? volume = response?.Data?[0].Intraday?.Items?[0].VolumeDecimal;

Did this page help you?