@itick/browser-sdk
Version:
Official iTick API SDK for browser. Real-time & historical data for global Stocks, Forex, Crypto, Indices, Futures, Funds, Precious Metals. REST (OHLCV/K-line) + low-latency WebSocket. Promise-based, TypeScript-ready. For quant trading & fintech
182 lines • 4.91 kB
TypeScript
/**
* Kline Period Enum (Standard Text Identifiers + Numeric Codes)
* Centrally maintained for global reuse
*/
export declare const KlinePeriod: {
readonly ONE_MIN: "1m";
readonly FIVE_MIN: "5m";
readonly FIFTEEN_MIN: "15m";
readonly THIRTY_MIN: "30m";
readonly ONE_HOUR: "1h";
readonly TWO_HOUR: "2h";
readonly FOUR_HOUR: "4h";
readonly ONE_DAY: "1d";
readonly ONE_WEEK: "1w";
readonly ONE_MONTH: "1M";
};
export declare const KlineTypeCode: {
readonly "1m": 1;
readonly "5m": 2;
readonly "15m": 3;
readonly "30m": 4;
readonly "1h": 5;
readonly "2h": 6;
readonly "4h": 7;
readonly "1d": 8;
readonly "1w": 9;
readonly "1M": 10;
};
/**
* Kline Type Enum
* Defines various supported K-line time intervals
*
* 1 | 1m: 1-minute K-line
*
* 2 | 5m: 5-minute K-line
*
* 3 | 15m: 15-minute K-line
*
* 4 | 30m: 30-minute K-line
*
* 5 | 1h: 1-hour K-line
*
* 6 | 2h: 2-hour K-line (crypto only)
*
* 7 | 4h: 4-hour K-line (crypto only)
*
* 8 | 1d: 1-day K-line
*
* 9 | 1w: 1-week K-line
*
* 10 | 1M: 1-month K-line
*/
export type KlineType = keyof typeof KlineTypeCode | (typeof KlinePeriod)[keyof typeof KlinePeriod] | (typeof KlineTypeCode)[keyof typeof KlineTypeCode];
/**
* Kline Data
* Contains OHLCV data for a specified time period along with product identifier
* - o: open price
* - c: close price
* - h: high price
* - l: low price
* - v: trade volume
* - tu: trade amount
* - t: timestamp (milliseconds)
*/
export interface KlineData {
/** Open price */
o: number;
/** Close price */
c: number;
/** High price */
h: number;
/** Low price */
l: number;
/** Trade volume */
v: number;
/** Trade amount */
tu: number;
/** Timestamp */
t: number;
}
/**
* Kline Data Array
* Collection of batch K-line data
* @property key - Product code
* @property value - K-line data array for corresponding product {@link KlineData}
*/
export type KlineDataMap = {
[key: string]: KlineData[];
};
/**
* Parameters for fetching K-line data, where `kType` and `interval` are mutually exclusive.
* The SDK handles it automatically.
*
* @remarks
* You must provide either `kType` or `interval`, but not both, and not neither.
* It is recommended to use the `interval` parameter.
*
* - region: Market code
* - code: Symbol code
* - kType: K-line interval
* - interval: K-line interval
* - limit: Number of records to return (max 500)
* - et?: Optional, end time (timestamp), defaults to current time
*
* @example
* options = { region: 'BA', code: 'BTCUSDT', kType: '1h', limit: 10 }
* options = { region: 'BA', code: 'BTCUSDT', interval: '1h', limit: 10 }
*/
export type GetKlineOptions = {
/** Market code */
region: string;
/** Symbol code */
code: string;
/** K-line interval */
kType: KlineType;
/** K-line interval */
interval?: never;
/** Number of records to return (max 500) */
limit: number;
/** Optional, end time (timestamp), defaults to current time */
et?: string | number;
} | {
/** Market code */
region: string;
/** Symbol code */
code: string;
/** K-line interval */
interval: KlineType;
/** K-line interval */
kType?: never;
/** Number of records to return (max 500) */
limit: number;
/** Optional, end time (timestamp), defaults to current time */
et?: string | number;
};
/**
* Parameters for fetching K-lines data, where `kType` and `interval` are mutually exclusive.
* The SDK handles it automatically.
*
* @remarks
* You must provide either `kType` or `interval`, but not both, and not neither.
* It is recommended to use the `interval` parameter.
*
* - region: Market code
* - codes: Symbol code list
* - kType: K-line interval
* - interval: K-line interval
* - limit: Number of K-lines
* - et?: End timestamp
*
* @example
* options = { region: 'BA', codes: ['BTCUSDT', 'ETHUSDT'], kType: '1h', limit: 10 }
* options = { region: 'BA', codes: ['BTCUSDT', 'ETHUSDT'], interval: '1h', limit: 10 }
*/
export type GetKlinesOptions = {
/** Market code */
region: string;
/** Symbol code list*/
codes: string[] | string;
/** K-line interval */
kType: KlineType;
/** K-line interval */
interval?: never;
/** Number of records to return (max 500) */
limit: number;
/** Optional, end time (timestamp), defaults to current time */
et?: string | number;
} | {
/** Market code */
region: string;
/** Symbol code list*/
codes: string[] | string;
/** K-line interval */
interval: KlineType;
/** K-line interval */
kType?: never;
/** Number of records to return (max 500) */
limit: number;
/** Optional, end time (timestamp), defaults to current time */
et?: string | number;
};
//# sourceMappingURL=kline.d.ts.map