Historical K-line

Interface Description

Note: The server performs libz compression on the entire packet.

Request-Protocol Number: 14012

Data format:json

Data Structure

data definition

Fields

name

type

Required fields

illustrate

symbol_id

Product ID

uint64

yes

trade_type

Transaction Type

uint32

yes

1: Full position contract, 2: Isolated position contract, 3: Leverage, 5: Spot, 6: Stock

trade_mode

Trading Model

uint32

yes

1:MM, 2:ButterflyMM, 3:Matchmaking, 4:Aggregation

kline_type

K-line type

uint32

yes

1 minute K, 2 is 5 minute K, 3 is 15 minute K, 4 is 30 minute K, 5 is hour K, 6 is 2 hour K, 7 is 4 hour K, 8 is daily K, 9 is weekly K, 10 is monthly K

kline_timestamp_end

Line end timestamp

uint64

no

Unit: Seconds

query_kline_num

Query the number of K lines

uint32

yes

kline_timestamp_end is 0, query_kline_num is not 0, query the latest query_kline_num K-lines (including the current K-line) kline_timestamp_end is not 0, query_kline_num is not 0, query the query_kline_num K-lines from kline_timestamp_end to the previous query_kline_num K-lines In other cases, the interface directly returns an error, indicating that the query service is not supported

Request Example

Copy

{
    "cmd_id":14012,
    "seq_id":123,
    "ext":"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
    "data":{
        "symbol_id": 1,
        "trade_type": 1,
        "trade_mode": 0,
        "kline_type": 1,
        "kline_timestamp_end": 1605509068,
        "query_kline_num": 100,
    }
}

Response-Protocol Number: 14013

Data format:json

Data Structure

data definition

Fields

name

type

illustrate

symbol_id

Product ID

uint64

trade_type

Transaction Type

uint32

1: Full position contract, 2: Isolated position contract, 3: Leverage, 5: Spot, 6: Stock

trade_mode

Trading Model

uint32

1:MM, 2:ButterflyMM, 3:Matchmaking, 4:Aggregation

kline_type

K-line type

uint32

1 minute K, 2 is 5 minute K, 3 is 15 minute K, 4 is 30 minute K, 5 is hour K, 6 is 2 hour K, 7 is 4 hour K, 8 is daily K, 9 is weekly K, 10 is monthly K

price_digits

Price decimal places

uint32

kline_list

K-line list

array

See the kline_list definition below for the specific format.

kline_list definition

Fields

name

type

illustrate

timestamp

The timestamp of the K line

uint64

Unit: Seconds

open_price

The opening price of the K-line

string

close_price

The closing price of the K-line

string

high_price

The highest price of the K line

string

low_price

The lowest price of the K line

string

last_tick_time

The last tick time of the K line

uint64

Unit: milliseconds

last_tick_seq

The last tick number of the K-line

uint64

transactions_number

The number of transactions of this K line

string

Example Response

Copy

{
    "ret":200,
    "msg":"ok",
    "cmd_id":14013,
    "seq_id":123,
    "ext":"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
    "data":{
        "symbol_id": 1123,
        "trade_type": 1,
        "trade_mode": 0,
        "kline_type": 1,
        "price_digits": 2,
        "kline_list":[
            {
                "timestamp": 1605509068,
                "open_price": "651.12",
                "close_price": "623.12",
                "high_price": "674.12",
                "low_price": "619.12",
                "last_tick_time": 1605509068000001,
                "last_tick_seq": 1605509068000001,
                "transactions_number": "12345.6",
            },
        ]
    }    
}

Last updated