import { KlineData } from './kline';
import { QuoteData } from './quote';
import { DepthData } from './depth';
import { TickData } from './tick';
/**
 * Market Data Subscription Types
 * Supports both kline@1m and kline@1 formats
 */
export declare const SubscribeType: {
    readonly QUOTE: "quote";
    readonly DEPTH: "depth";
    readonly TICK: "tick";
    readonly KLINE_1M: "kline@1m";
    readonly KLINE_5M: "kline@5m";
    readonly KLINE_15M: "kline@15m";
    readonly KLINE_30M: "kline@30m";
    readonly KLINE_1H: "kline@1h";
    readonly KLINE_2H: "kline@2h";
    readonly KLINE_4H: "kline@4h";
    readonly KLINE_1D: "kline@1d";
    readonly KLINE_1W: "kline@1w";
    readonly KLINE_1MTH: "kline@1M";
};
export declare const SubscribeTypeCode: {
    readonly "kline@1m": "kline@1";
    readonly "kline@5m": "kline@2";
    readonly "kline@15m": "kline@3";
    readonly "kline@30m": "kline@4";
    readonly "kline@1h": "kline@5";
    readonly "kline@2h": "kline@6";
    readonly "kline@4h": "kline@7";
    readonly "kline@1d": "kline@8";
    readonly "kline@1w": "kline@9";
    readonly "kline@1M": "kline@10";
};
/**
 * Subscription Type Enum
 *
 * Supported subscription type formats:
 * - quote: Real-time quotes
 * - depth: Real-time order book
 * - tick: Real-time trades
 * - kline@${period}: Real-time K-lines
 *
 * Supported K-line periods (string/numeric equivalents):
 * - 1m  / 1  - 1-minute K-line
 * - 5m  / 2  - 5-minute K-line
 * - 15m / 3  - 15-minute K-line
 * - 30m / 4  - 30-minute K-line
 * - 1h  / 5  - 1-hour K-line
 * - 2h  / 6  - 2-hour K-line (crypto only)
 * - 4h  / 7  - 4-hour K-line (crypto only)
 * - 1d  / 8  - 1-day K-line
 * - 1w  / 9  - 1-week K-line
 *
 * Usage examples:
 * - kline@1m  and  kline@1  have the same effect
 * - kline@5m  and  kline@2  have the same effect
 */
export type SubscribeType = keyof typeof SubscribeTypeCode | (typeof SubscribeType)[keyof typeof SubscribeType] | (typeof SubscribeTypeCode)[keyof typeof SubscribeTypeCode];
export type SymbolType = `${string}$${string}`;
/**
 * WebSocket Subscription Message Options
 * Used to specify subscription or unsubscription types and parameters
 *
 */
export type MessageOption = {
    ac: 'subscribe' | 'unsubscribe';
    types: SubscribeType[] | string;
    codes: SymbolType[] | string;
};
/**
 * Subscription Data
 * Data types and codes for product subscription
 * - types: data types such as quote, depth, tick, kline@1m, etc. Supports two formats: string or string array, {@link SubscribeType}
 * - codes: product codes in format "code$region" (e.g., "AAPL$US") Supports two formats: string or string array, SDK will automatically handle formatting
 */
export interface SubscribeData {
    types: SubscribeType[] | string;
    codes: SymbolType[] | string;
}
/**
 * Options for Creating WebSocket Instance
 * @description Contains configuration parameters for WebSocket connection and subscription data
 * - maxReconnectTimes: maximum reconnection attempts, defaults to unlimited if not provided or 0
 * - reconnectInterval: reconnection interval, default 5 seconds
 * - pingInterval: ping interval, default 30 seconds
 * - subscribeData: subscription data including subscription types and product codes {@link SubscribeData}
 */
export interface CreateSocketOptions {
    /** Maximum reconnection attempts, defaults to unlimited if not provided or 0 */
    maxReconnectTimes?: number;
    /** Reconnection interval, default 5s */
    reconnectInterval?: number;
    /** Ping interval, default 30s */
    pingInterval?: number;
    /** Subscription data */
    subscribeData?: SubscribeData;
}
/**
* WebSocket Configuration Options
* Configuration parameters for WebSocket connection
* - wssURL: WebSocket service address
* - wsPath: WebSocket path
* - maxReconnectTimes: maximum reconnection attempts
* - reconnectInterval: reconnection interval
* - pingInterval: ping interval
* - subscribeData: subscription data
*/
export interface WsOptions extends CreateSocketOptions {
    /** WebSocket service address */
    wssURL?: string;
    /** WebSocket path */
    wsPath: string;
}
export type KType = (typeof SubscribeTypeCode)[keyof typeof SubscribeTypeCode];
/**
* Base WebSocket Data Structure
* Base class for all WebSocket messages, contains product code and country/region code
*/
interface BaseSocket {
    /** Product code */
    s: string;
    /** Country/region code */
    r: string;
}
/**
* Socket Kline Data
* Message format for pushing K-line data
* - type data type kline@{number} {@link KType}
* - r country/region code
* - s product code
* - o open price
* - c close price
* - h high price
* - l low price
* - v trade volume
* - t timestamp
* - tu trade amount
*/
export interface SocketKlineData extends BaseSocket, KlineData {
    /** Data type */
    type: (typeof SubscribeTypeCode)[keyof typeof SubscribeTypeCode];
}
/**
* Socket Quote Real-Time Quote Data
* Message format for pushing quote real-time quote data
* - type data type quote
* - r country/region code
* - s product code
* - ld: last price
* - o: open price
* - h: high price
* - l: low price
* - p: previous close price
* - t: timestamp (milliseconds)
* - v: trade volume
* - tu: trade amount
* - ts: trading status 0:normal 1:suspended 2:delisted 3:circuit breaker
* - ch: change amount
* - chp: change percentage
*/
export interface SocketQuoteData extends BaseSocket, QuoteData {
    /** Data type */
    type: 'quote';
}
/**
* Socket Tick Real-Time Trade Data
* Message format for pushing tick real-time trade data
* - type data type tick
* - r country/region code
* - s product code
* - ld: last price
* - t: timestamp (milliseconds)
* - v: trade volume
* - d: trade direction 0:neutral 1:sell 2:buy (stock only)
* - te: trading session 0:regular 1:pre-market 2:after-hours (stock only)
* - tu: trade amount (crypto only)
* - ts: trading status 0:normal 1:suspended 2:delisted 3:circuit breaker (crypto only)
*/
export interface SocketTickData extends BaseSocket, TickData {
    /** Data type */
    type: 'tick';
}
/**
* Socket Depth Order Book Data
* Message format for pushing depth order book data
* - type data type depth
* - r country/region code
* - s product code
* - a: ask levels array {@link DepthLevel}
* - b: bid levels array {@link DepthLevel}
*/
export interface SocketDepthData extends BaseSocket, DepthData {
    /** Data type */
    type: 'depth';
}
/**
 * WebSocket Response Object
 * Standard response format returned by all WebSocket endpoints
 * - code: 1 indicates success, non-1 indicates failure; Note: code is empty when resAc=pong
 * - msg: response message or error information
 * - resAc: response type, possible values include 'subscribe', 'unsubscribe', 'pong', 'auth'
 * - data: response data {@link SocketKlineData | SocketTickData | SocketDepthData | SocketQuoteData}
 */
export interface SocketResponse {
    /** Response status code: 1 indicates success, non-1 indicates failure; Note: code is empty when resAc=pong */
    code?: number;
    /** Response message or error information */
    msg?: string;
    /** Response type */
    resAc?: 'subscribe' | 'unsubscribe' | 'pong' | 'auth';
    /** Response data */
    data?: SocketKlineData | SocketTickData | SocketDepthData | SocketQuoteData;
}
/**
 * WebSocket Message Handler Function
 * Called when a WebSocket message is received
 * @param data Received message content {@link SocketResponse}
 */
export type OnMessageHandler = (data: SocketResponse) => void;
/**
 * WebSocket Error Handler Function
 * Called when a WebSocket connection encounters an error
 * @param error Error object
 */
export type ErrorHandler = (event: Event | Error) => void;
/**
 * WebSocket Connection Open Handler Function
 * Called when a WebSocket connection is successfully established
 */
export type OpenHandler = () => void;
/**
 * WebSocket Connection Close Handler Function
 * Called when a WebSocket connection is closed
 */
export type CloseHandler = (event: CloseEvent) => void;
export {};
//# sourceMappingURL=socket.d.ts.map