Cryptocurrency

Cryptocurrency HTTP market data supports K-line data and current timelines. It does not support historical timelines.

Get Kline

Signature

pub async fn get_kline(&self, req: KlineRequest) -> Result<Vec<Kline>, TigerError>

Description

Returns cryptocurrency bars. symbols and period are required by the server; set sec_type to Some("CC".into()).

Parameters

ParameterRust typeRequirementSDK default
req.symbolsOption<Vec<String>>Required by the server; not prevalidated by the SDKNone (omitted)
req.periodOption<String>Required by the server; not prevalidated by the SDKNone (omitted)
req.rightOption<String>OptionalNone (omitted)
req.begin_timeOption<i64>OptionalNone (omitted)
req.end_timeOption<i64>OptionalNone (omitted)
req.limitOption<i32>OptionalNone (omitted)
req.begin_indexOption<i32>OptionalNone (omitted)
req.end_indexOption<i32>OptionalNone (omitted)
req.page_tokenOption<String>OptionalNone (omitted)
req.trade_sessionOption<String>OptionalNone (omitted)
req.dateOption<String>OptionalNone (omitted)
req.with_fundamentalOption<bool>OptionalNone (omitted)
req.sec_typeOption<String>Required for cryptocurrency; use CCNone (omitted)
req.langOption<String>OptionalNone (omitted)

Return

Result<Vec<Kline>, TigerError>

Rust fieldJSON fieldTypeDescription
symbolsymbolStringCryptocurrency symbol
periodperiodStringPeriod
next_page_tokennextPageTokenStringNext page token
itemsitemsVecData items

items elements (KlineItem):

Rust fieldJSON fieldTypeDescription
timetimei64Timestamp
volumevolumei64Integer volume; use when volume_decimal is absent
volume_decimalvolumeDecimalOption<f64>Optional fractional cryptocurrency volume; use volume when absent
openopenf64Open price
closeclosef64Close price
highhighf64High price
lowlowf64Low price
amountamountf64Turnover amount

Example

use tigeropen::config::ClientConfig;
use tigeropen::model::quote_requests::KlineRequest;
use tigeropen::quote::QuoteClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::builder().build()?;
    let quote = QuoteClient::from_config(config);

    let kline = quote.get_kline(KlineRequest {
        symbols: Some(vec!["BTC.USD".into()]),
        period: Some("day".into()),
        sec_type: Some("CC".into()),
        ..Default::default()
    }).await?;

    Ok(())
}

Rate limit

The base rate limit is 60 requests/min. Methods documented here that use kline share this quota.


Get Kline By Page

Signature

pub async fn get_kline_by_page(&self, req: KlineByPageRequest) -> Result<Vec<KlineItem>, TigerError>

Description

Client pagination for cryptocurrency bars. The SDK defaults page_size to 200 and total_size to 1000, then continues from the oldest bar time minus one. It passes sec_type to every page request; set it to Some("CC".into()).

Parameters

ParameterRust typeRequirementSDK default
req.symbolsOption<Vec<String>>OptionalNone (omitted)
req.periodOption<String>OptionalNone (omitted)
req.begin_timeOption<i64>OptionalNone (omitted)
req.end_timeOption<i64>OptionalNone (omitted)
req.total_sizeOption<i32>Optional1000 when None
req.page_sizeOption<i32>Optional200 when None
req.rightOption<String>OptionalNone (omitted)
req.trade_sessionOption<String>OptionalNone (omitted)
req.sec_typeOption<String>Required for cryptocurrency; use CCNone (omitted)
req.langOption<String>OptionalNone (omitted)

Return

Result<Vec<KlineItem>, TigerError>

Rust fieldJSON fieldTypeDescription
timetimei64Timestamp
volumevolumei64Integer volume; use when volume_decimal is absent
volume_decimalvolumeDecimalOption<f64>Optional fractional cryptocurrency volume; use volume when absent
openopenf64Open price
closeclosef64Close price
highhighf64High price
lowlowf64Low price
amountamountf64Turnover amount

Example

use tigeropen::config::ClientConfig;
use tigeropen::model::quote_requests::KlineByPageRequest;
use tigeropen::quote::QuoteClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::builder().build()?;
    let quote = QuoteClient::from_config(config);

    let kline = quote.get_kline_by_page(KlineByPageRequest {
        symbols: Some(vec!["BTC.USD".into()]),
        period: Some("day".into()),
        sec_type: Some("CC".into()),
        total_size: Some(100),
        ..Default::default()
    }).await?;

    Ok(())
}

Rate limit

The base rate limit is 60 requests/min. Methods documented here that use kline share this quota.


Get Current Timeline With Request

Signature

pub async fn get_timeline_with_request(&self, req: TimelineRequest) -> Result<Vec<Timeline>, TigerError>

Description

Returns current cryptocurrency timeline data. Set sec_type to Some("CC".into()). This method does not provide cryptocurrency historical timelines.

Parameters

ParameterRust typeRequirementSDK default
req.symbolsOption<Vec<String>>Required by the server; not prevalidated by the SDKNone (omitted)
req.sec_typeOption<String>Required for cryptocurrency; use CCNone (omitted)

Return

Result<Vec<Timeline>, TigerError>

Rust fieldJSON fieldTypeDescription
symbolsymbolStringCryptocurrency symbol
periodperiodStringPeriod
pre_closepreClosef64Previous close
intradayintradayOption<TimelineBucket>Intraday timeline data
pre_hourspreHoursOption<TimelineBucket>Pre-market timeline data
after_hoursafterHoursOption<TimelineBucket>After-hours timeline data

TimelineBucket fields:

Rust fieldJSON fieldTypeDescription
itemsitemsVec<TimelineItem>Timeline point list

Each TimelineBucket.items element is a TimelineItem:

Rust fieldJSON fieldTypeDescription
timetimei64Timestamp
volumevolumei64Integer volume; use when volume_decimal is absent
volume_decimalvolumeDecimalOption<f64>Optional fractional cryptocurrency volume; use volume when absent
pricepricef64Price
avg_priceavgPricef64Average price

Example

use tigeropen::config::ClientConfig;
use tigeropen::model::quote_requests::TimelineRequest;
use tigeropen::quote::QuoteClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::builder().build()?;
    let quote = QuoteClient::from_config(config);

    let timeline = quote.get_timeline_with_request(TimelineRequest {
        symbols: Some(vec!["BTC.USD".into()]),
        sec_type: Some("CC".into()),
    }).await?;

    Ok(())
}

Rate limit

The base rate limit is 120 requests/min.


Did this page help you?