Cryptocurrency

Cryptocurrency market data uses SecType: "CC". Candlestick bars and current timelines are supported; historical cryptocurrency timelines are not supported.

GetKline

Signature

func (c *QuoteClient) GetKline(req model.KlineRequest) ([]model.Kline, error)

Parameters

model.KlineRequest

SDK fieldTypeDefaultConstraints/description
Symbols[]stringOmitted when nilCryptocurrency symbols
PeriodstringOmitted when emptyCandlestick period
RightstringOmitted when emptyAdjustment type
BeginTimeint64Omitted when 0Millisecond timestamp; cannot be combined with BeginIndex or EndIndex
EndTimeint64Omitted when 0Millisecond timestamp; cannot be combined with BeginIndex or EndIndex
LimitintOmitted when 0Result count
BeginIndexintOmitted when 0Index-range start; cannot be combined with BeginTime or EndTime
EndIndexintOmitted when 0Index-range end; cannot be combined with BeginTime or EndTime
PageTokenstringOmitted when emptyPagination cursor
TradeSessionstringOmitted when emptyTrading session
DatestringOmitted when emptyDate
WithFundamental*boolnilWhether to include fundamental data
SecTypestringOmitted when emptyMust be CC
LangstringOmitted when emptyLanguage

Returns

([]model.Kline, error)

Each model.Kline:

FieldTypeDescription
SymbolstringCryptocurrency symbol
PeriodstringBar period
NextPageTokenstringNext-page cursor
Items[]model.KlineItemBars

Each Items element (model.KlineItem):

FieldTypeDescription
Timeint64Bar timestamp in milliseconds
Volumeint64Integer volume; use when VolumeDecimal is nil
VolumeDecimal*float64Optional fractional cryptocurrency volume
Openfloat64Open price
Closefloat64Close price
Highfloat64High price
Lowfloat64Low price
Amountfloat64Turnover amount

Invocation example

package main

import (
	"fmt"
	"log"

	"github.com/tigerfintech/openapi-go-sdk/config"
	"github.com/tigerfintech/openapi-go-sdk/model"
	"github.com/tigerfintech/openapi-go-sdk/quote"
)

func main() {
	cfg, err := config.NewClientConfig()
	if err != nil {
		log.Fatal(err)
	}
	qc := quote.NewQuoteClientFromConfig(cfg)
	result, err := qc.GetKline(model.KlineRequest{
		Symbols: []string{"BTC.USD"},
		SecType: "CC",
		Period:  "day",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%#v\n", result)
}

Rate limit

The base rate limit is 60 requests/min.


GetKlineByPage

Signature

func (c *QuoteClient) GetKlineByPage(req model.KlineByPageRequest) ([]model.KlineItem, error)

This client-side pagination method passes SecType to every page request and returns merged items in ascending time order.

Parameters

model.KlineByPageRequest

SDK fieldTypeDefaultDescription
SymbolstringOmitted when emptyCryptocurrency symbol
SecTypestringOmitted when emptyMust be CC
PeriodstringOmitted when emptyCandlestick period
BeginTimeint64The SDK sends -1 when unsetMillisecond timestamp
EndTimeint64The SDK sends -1 when unsetMillisecond timestamp
TotalSizeint1000 when <= 0Total desired result count
PageSizeint200 when <= 0Result count per page
RightstringOmitted when emptyAdjustment type
LangstringOmitted when emptyLanguage
TradeSessionstringOmitted when emptyTrading session

Returns

([]model.KlineItem, error)

Each returned model.KlineItem:

FieldTypeDescription
Timeint64Bar timestamp in milliseconds
Volumeint64Integer volume; use when VolumeDecimal is nil
VolumeDecimal*float64Optional fractional cryptocurrency volume
Openfloat64Open price
Closefloat64Close price
Highfloat64High price
Lowfloat64Low price
Amountfloat64Turnover amount

Invocation example

package main

import (
	"fmt"
	"log"

	"github.com/tigerfintech/openapi-go-sdk/config"
	"github.com/tigerfintech/openapi-go-sdk/model"
	"github.com/tigerfintech/openapi-go-sdk/quote"
)

func main() {
	cfg, err := config.NewClientConfig()
	if err != nil {
		log.Fatal(err)
	}
	qc := quote.NewQuoteClientFromConfig(cfg)
	result, err := qc.GetKlineByPage(model.KlineByPageRequest{
		Symbol:    "BTC.USD",
		SecType:   "CC",
		Period:    "day",
		TotalSize: 100,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%#v\n", result)
}

GetTimelineByReq

Signature

func (c *QuoteClient) GetTimelineByReq(req model.TimelineRequest) ([]model.Timeline, error)

Retrieves current cryptocurrency timeline data only. It does not provide historical cryptocurrency timelines.

Parameters

SDK fieldTypeDescription
Symbols[]stringCryptocurrency symbols
SecTypestringMust be CC

Returns

([]model.Timeline, error)

Each model.Timeline:

FieldTypeDescription
SymbolstringCryptocurrency symbol
PeriodstringTimeline period
PreClosefloat64Previous close
Intraday*model.TimelineBucketOptional intraday bucket
PreHours*model.TimelineBucketOptional pre-market bucket
AfterHours*model.TimelineBucketOptional after-hours bucket

Each non-nil model.TimelineBucket:

FieldTypeDescription
Items[]model.TimelineItemTimeline points

Each Items element (model.TimelineItem):

FieldTypeDescription
Timeint64Point timestamp in milliseconds
Volumeint64Integer volume; use when VolumeDecimal is nil
VolumeDecimal*float64Optional fractional cryptocurrency volume
Pricefloat64Price
AvgPricefloat64Average price

Invocation example

package main

import (
	"fmt"
	"log"

	"github.com/tigerfintech/openapi-go-sdk/config"
	"github.com/tigerfintech/openapi-go-sdk/model"
	"github.com/tigerfintech/openapi-go-sdk/quote"
)

func main() {
	cfg, err := config.NewClientConfig()
	if err != nil {
		log.Fatal(err)
	}
	qc := quote.NewQuoteClientFromConfig(cfg)
	result, err := qc.GetTimelineByReq(model.TimelineRequest{
		Symbols: []string{"BTC.USD"},
		SecType: "CC",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%#v\n", result)
}

Rate limit

The base rate limit is 120 requests/min.


Did this page help you?