# Get Heat Map Data
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_heat_map_data(market, sort_field=None, ascend=None, count=None, page=None, plate_type=None)
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
Parameter Type Description market Market Market type (required) sort_field HeatMapSortField Sort field, default change rate ascend bool True=ascending, False=descending, default descending count int Return count [1, 200], default 30 page str Page cursor plate_type HeatMapPlateType Sector type, default industry sector Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns data str When ret != RET_OK, returns error description - Data format:
Field Type Description plate str Sector code (e.g. 'HK.BK1001')plate_name str Sector name cur_price float Latest price change_rate float Change rate (%) turnover float Turnover volume int Volume market_val float Market cap pe_avg float Average P/E ratio rise_count int Rise count fall_count int Fall count equal_count int Unchanged count leader_stock str Leading stock code description str Sector description
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_heat_map_data(market=Market.US, count=2)
if ret == RET_OK:
print(f'Total sectors: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
Total sectors: 145
plate plate_name cur_price change_rate turnover volume market_val pe_avg rise_count fall_count equal_count leader_stock description
0 US.LIST2496 人力资源与就业服务 1229.174414 4.717340 7.345543e+08 437599614 1.502404e+10 -6.112 15 3 2 US.ATLN N/A
1 US.LIST2473 糖果 1696.630748 3.295289 1.178965e+09 14299774 1.176028e+11 49.691 4 1 0 US.RMCF N/A
2
3
4
# Qot_GetHeatMapData.proto
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Protocol ID
3432
uint GetHeatMapData(Qot_GetHeatMapData.Request req);
virtual void OnReply_GetHeatMapData(FTAPI_Conn client, uint nSerialNo, Qot_GetHeatMapData.Response rsp);
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
public class Program : FTSPI_Qot, FTSPI_Conn {
FTAPI_Qot qot = new FTAPI_Qot();
public Program() {
qot.SetClientInfo("csharp", 1); //设置客户端信息
qot.SetConnCallback(this); //设置连接回调
qot.SetQotCallback(this); //设置行情回调
}
public void Start() {
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(FTAPI_Conn client, long errCode, String desc)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}
", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotGetHeatMapData.C2S c2s = QotGetHeatMapData.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetHeatMapData.Request req = QotGetHeatMapData.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetHeatMapData(req);
Console.Write("Send QotGetHeatMapData: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetHeatMapData(FTAPI_Conn client, uint nSerialNo, QotGetHeatMapData.Response rsp)
{
Console.Write("Reply: QotGetHeatMapData: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
FTAPI.Init();
Program program = new Program();
program.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- Output
Send QotGetHeatMapData: 3
Reply: QotGetHeatMapData: 3
GetHeatMapData: errCode 0, retMsg , retType 0
{
"allCount": 145,
"plateDataList": [
{ "plate": { "market": 11, "code": "LIST2479" }, "plateName": "抵押贷款金融", "changeRate": 7.543126 },
{ "plate": { "market": 11, "code": "LIST2493" }, "plateName": "电气设备及零件", "changeRate": 6.800033 },
{ "plate": { "market": 11, "code": "LIST2015" }, "plateName": "半导体", "changeRate": 5.358499 }
]
}
2
3
4
5
6
7
8
9
10
11
int getHeatMapData(Qot_GetHeatMapData.Request req);
onReply_GetHeatMapData(FTAPI_Conn client, int nSerialNo, Qot_GetHeatMapData.Response rsp)
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
public class QotDemo implements FTSPI_Qot, FTSPI_Conn {
FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 1); //设置客户端信息
qot.setConnSpi(this); //设置连接回调
qot.setQotSpi(this); //设置行情回调
}
public void start() {
qot.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc)
{
System.out.printf("Qot onInitConnect: ret=%d desc=%s connID=%d
", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotGetHeatMapData.C2S c2s = QotGetHeatMapData.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetHeatMapData.Request req = QotGetHeatMapData.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getHeatMapData(req);
System.out.printf("Send QotGetHeatMapData: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetHeatMapData(FTAPI_Conn client, int nSerialNo, QotGetHeatMapData.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetHeatMapData failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetHeatMapData: %s
", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
FTAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- Output
Send QotGetHeatMapData: 3
Receive QotGetHeatMapData: {
"allCount": 145,
"plateDataList": [
{ "plate": { "market": 11, "code": "LIST2479" }, "plateName": "抵押贷款金融", "changeRate": 7.543126 },
{ "plate": { "market": 11, "code": "LIST2493" }, "plateName": "电气设备及零件", "changeRate": 6.800033 },
{ "plate": { "market": 11, "code": "LIST2015" }, "plateName": "半导体", "changeRate": 5.358499 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetHeatMapData(const Qot_GetHeatMapData::Request &stReq);
virtual void OnReply_GetHeatMapData(Futu::u32_t nSerialNo, const Qot_GetHeatMapData::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
class Program : public FTSPI_Qot, public FTSPI_Conn
{
public:
Program() {
m_pQotApi = FTAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr) {
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
FTAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(FTAPI_Conn* pConn, Futu::i64_t nErrCode, const char* strDesc) {
Qot_GetHeatMapData::Request req;
Qot_GetHeatMapData::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(30);
m_GetHeatMapDataSerialNo = m_pQotApi->GetHeatMapData(req);
}
virtual void OnReply_GetHeatMapData(Futu::u32_t nSerialNo, const Qot_GetHeatMapData::Response &stRsp) {
if (nSerialNo != m_GetHeatMapDataSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetHeatMapDataSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"plateDataList": [
{
"plate": {
"market": 11,
"code": "BK1234"
},
"plateName": "Semiconductor",
"changeRate": 3.25,
"marketVal": 5200000000000.0,
"turnover": 28500000000.0
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
getHeatMapData(qotGetHeatMapData)
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetHeatMapData(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, count: 3 },
};
websocket.GetHeatMapData(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetHeatMapData: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), { indent_size: 2, space_in_empty_paren: true });
console.log(data);
}
})
.catch((error)=>{ console.log("error:", error); });
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetHeatMapData()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
- Output
GetHeatMapData: errCode 0, retMsg , retType 0
{
"allCount": 145,
"plateDataList": [
{ "plate": { "market": 11, "code": "LIST2479" }, "plateName": "抵押贷款金融", "changeRate": 7.543126 },
{ "plate": { "market": 11, "code": "LIST2493" }, "plateName": "电气设备及零件", "changeRate": 6.800033 },
{ "plate": { "market": 11, "code": "LIST2015" }, "plateName": "半导体", "changeRate": 5.358499 }
]
}
2
3
4
5
6
7
8
9
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts toward rate limiting
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_heat_map_data(market, sort_field=None, ascend=None, count=None, page=None, plate_type=None)
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
Parameter Type Description market Market Market type (required) sort_field HeatMapSortField Sort field, default change rate ascend bool True=ascending, False=descending, default descending count int Return count [1, 200], default 30 page str Page cursor plate_type HeatMapPlateType Sector type, default industry sector Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns data str When ret != RET_OK, returns error description - Data format:
Field Type Description plate str Sector code (e.g. 'HK.BK1001')plate_name str Sector name cur_price float Latest price change_rate float Change rate (%) turnover float Turnover volume int Volume market_val float Market cap pe_avg float Average P/E ratio rise_count int Rise count fall_count int Fall count equal_count int Unchanged count leader_stock str Leading stock code description str Sector description
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_heat_map_data(market=Market.US, count=2)
if ret == RET_OK:
print(f'Total sectors: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
Total sectors: 145
plate plate_name cur_price change_rate turnover volume market_val pe_avg rise_count fall_count equal_count leader_stock description
0 US.LIST2496 人力资源与就业服务 1229.174414 4.717340 7.345543e+08 437599614 1.502404e+10 -6.112 15 3 2 US.ATLN N/A
1 US.LIST2473 糖果 1696.630748 3.295289 1.178965e+09 14299774 1.176028e+11 49.691 4 1 0 US.RMCF N/A
2
3
4
# Qot_GetHeatMapData.proto
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Protocol ID
3432
uint GetHeatMapData(Qot_GetHeatMapData.Request req);
virtual void OnReply_GetHeatMapData(FTAPI_Conn client, uint nSerialNo, Qot_GetHeatMapData.Response rsp);
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
public class Program : MMSPI_Qot, MMSPI_Conn {
MMAPI_Qot qot = new MMAPI_Qot();
public Program() {
qot.SetClientInfo("csharp", 1); //设置客户端信息
qot.SetConnCallback(this); //设置连接回调
qot.SetQotCallback(this); //设置行情回调
}
public void Start() {
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(MMAPI_Conn client, long errCode, String desc)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}
", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotGetHeatMapData.C2S c2s = QotGetHeatMapData.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetHeatMapData.Request req = QotGetHeatMapData.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetHeatMapData(req);
Console.Write("Send QotGetHeatMapData: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetHeatMapData(MMAPI_Conn client, uint nSerialNo, QotGetHeatMapData.Response rsp)
{
Console.Write("Reply: QotGetHeatMapData: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
MMAPI.Init();
Program program = new Program();
program.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- Output
Send QotGetHeatMapData: 3
Reply: QotGetHeatMapData: 3
GetHeatMapData: errCode 0, retMsg , retType 0
{
"allCount": 145,
"plateDataList": [
{ "plate": { "market": 11, "code": "LIST2479" }, "plateName": "抵押贷款金融", "changeRate": 7.543126 },
{ "plate": { "market": 11, "code": "LIST2493" }, "plateName": "电气设备及零件", "changeRate": 6.800033 },
{ "plate": { "market": 11, "code": "LIST2015" }, "plateName": "半导体", "changeRate": 5.358499 }
]
}
2
3
4
5
6
7
8
9
10
11
int getHeatMapData(Qot_GetHeatMapData.Request req);
onReply_GetHeatMapData(FTAPI_Conn client, int nSerialNo, Qot_GetHeatMapData.Response rsp)
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
public class QotDemo implements MMSPI_Qot, MMSPI_Conn {
MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 1); //设置客户端信息
qot.setConnSpi(this); //设置连接回调
qot.setQotSpi(this); //设置行情回调
}
public void start() {
qot.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc)
{
System.out.printf("Qot onInitConnect: ret=%d desc=%s connID=%d
", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotGetHeatMapData.C2S c2s = QotGetHeatMapData.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetHeatMapData.Request req = QotGetHeatMapData.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getHeatMapData(req);
System.out.printf("Send QotGetHeatMapData: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetHeatMapData(MMAPI_Conn client, int nSerialNo, QotGetHeatMapData.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetHeatMapData failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetHeatMapData: %s
", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MMAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- Output
Send QotGetHeatMapData: 3
Receive QotGetHeatMapData: {
"allCount": 145,
"plateDataList": [
{ "plate": { "market": 11, "code": "LIST2479" }, "plateName": "抵押贷款金融", "changeRate": 7.543126 },
{ "plate": { "market": 11, "code": "LIST2493" }, "plateName": "电气设备及零件", "changeRate": 6.800033 },
{ "plate": { "market": 11, "code": "LIST2015" }, "plateName": "半导体", "changeRate": 5.358499 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetHeatMapData(const Qot_GetHeatMapData::Request &stReq);
virtual void OnReply_GetHeatMapData(moomoo::u32_t nSerialNo, const Qot_GetHeatMapData::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
class Program : public MMSPI_Qot, public MMSPI_Conn
{
public:
Program() {
m_pQotApi = MMAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr) {
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
MMAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(MMAPI_Conn* pConn, moomoo::i64_t nErrCode, const char* strDesc) {
Qot_GetHeatMapData::Request req;
Qot_GetHeatMapData::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(30);
m_GetHeatMapDataSerialNo = m_pQotApi->GetHeatMapData(req);
}
virtual void OnReply_GetHeatMapData(moomoo::u32_t nSerialNo, const Qot_GetHeatMapData::Response &stRsp) {
if (nSerialNo != m_GetHeatMapDataSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetHeatMapDataSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"plateDataList": [
{
"plate": {
"market": 11,
"code": "BK1234"
},
"plateName": "Semiconductor",
"changeRate": 3.25,
"marketVal": 5200000000000.0,
"turnover": 28500000000.0
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
getHeatMapData(qotGetHeatMapData)
Description
Get heat map data, returning sector heat map information for a specified market (including change rate, market value, turnover, rise/fall counts, leading stocks, etc.), with support for multi-dimensional sorting and cursor pagination.
Parameters
//Heat map plate type
enum HeatMapPlateType
{
HeatMapPlateType_Industry = 0; //Industry plate (default)
HeatMapPlateType_Concept = 1; //Concept plate
HeatMapPlateType_Theme = 2; //Theme plate
}
//Sort field
enum SortField
{
SortField_Unknow = 0;
SortField_ChangeRate = 1; //Change%
SortField_MarketVal = 2; //Market cap
SortField_Turnover = 3; //Turnover
SortField_Hot = 4; //Popularity
}
message C2S
{
required int32 market = 1; //Qot_Common.QotMarket, stock market
optional int32 sortField = 2; //SortField, sort field, default change% if not specified
optional bool ascend = 3; //Ascending true, descending false, default descending if omitted
optional int32 count = 4; //Return count [1,200], default 30 if not specified
optional string page = 5; //Page cursor, omit for first request, pass nextPage from previous response
optional int32 plateType = 6; //HeatMapPlateType, plate type, default industry plate if not specified
}
message HeatMapPlateData
{
optional Qot_Common.Security plate = 1; //Plate
optional string plateName = 2; //Plate name
optional double curPrice = 3; //Last price
optional double changeRate = 4; //Change(%)
optional double turnover = 5; //Turnover
optional int64 volume = 6; //Volume
optional double marketVal = 7; //Market cap
optional double peAvg = 8; //Average P/E ratio
optional int32 riseCount = 9; //Number of gainers
optional int32 fallCount = 10; //Number of decliners
optional int32 equalCount = 11; //Unchanged count
optional Qot_Common.Security leaderStock = 12; //Leading stock
optional string description = 13; //Plate description
}
message S2C
{
repeated HeatMapPlateData plateDataList = 1; //Plate data list
optional int32 allCount = 2; //Total plates
optional string nextPage = 3; //Next page cursor, empty means last page
}
message Request
{
required C2S c2s = 1;
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- For interface result, refer to RetType
Protocol ID
3432
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetHeatMapData(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, count: 3 },
};
websocket.GetHeatMapData(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetHeatMapData: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), { indent_size: 2, space_in_empty_paren: true });
console.log(data);
}
})
.catch((error)=>{ console.log("error:", error); });
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetHeatMapData()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
- Output
GetHeatMapData: errCode 0, retMsg , retType 0
{
"allCount": 145,
"plateDataList": [
{ "plate": { "market": 11, "code": "LIST2479" }, "plateName": "抵押贷款金融", "changeRate": 7.543126 },
{ "plate": { "market": 11, "code": "LIST2493" }, "plateName": "电气设备及零件", "changeRate": 6.800033 },
{ "plate": { "market": 11, "code": "LIST2015" }, "plateName": "半导体", "changeRate": 5.358499 }
]
}
2
3
4
5
6
7
8
9
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts toward rate limiting