# 機関プロフィールの取得
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_institution_profile(market, institution_id)
説明
機関概況を取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
パラメータ タイプ 説明 market Market 市場タイプ(HK/US)(必須) institution_id int 機関ID(get_institution_list から取得)(必須) 戻り値
パラメータ タイプ 説明 ret RET_CODE API呼び出し結果 data dict ret == RET_OK の場合、辞書データを返す str ret != RET_OK の場合、エラー説明を返す - データフォーマット:
フィールド タイプ 説明 institution_name str 機関名 description str 機関概要 position_value float 保有時価総額 last_position_value float 前期保有時価総額 position_value_change_pct float 時価総額変化率(%) total_holding_count int 総保有数 holding_change_count int 保有変動数 new_count int 新規ポジション銘柄数 sold_out_count int ポジション解消銘柄数 increase_count int 買い増し銘柄数 decrease_count int 保有削減銘柄数 top10_pct float Top10保有比率(%) top10_pct_change float Top10比率変動(%) disclosure_date str 開示日(yyyy-MM-dd) currency str 通貨
- データフォーマット:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# まず機関IDを取得
ret, data, _, _ = quote_ctx.get_institution_list(market=Market.US, count=1)
if ret == RET_OK and len(data) > 0:
inst_id = data.iloc[0]['institution_id']
# 機関概況を照会
ret, profile = quote_ctx.get_institution_profile(market=Market.US, institution_id=inst_id)
if ret == RET_OK:
for k, v in profile.items():
print(f"{k}: {v}")
else:
print('error:', profile)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- Output
institution_name: 贝莱德
description: 贝莱德集团是美国规模最大的资产管理集团之一,提供种类繁多的证券、固定收益、现金管理等投资产品。
position_value: 6959192681765.731
last_position_value: 6093992885377.756
position_value_change_pct: 14.1975
total_holding_count: 4443
holding_change_count: 12
new_count: 87
sold_out_count: 31
increase_count: 2364
decrease_count: 1682
top10_pct: 24.3287
top10_pct_change: 0.4142
disclosure_date: 2026-06-19
currency: USD
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Qot_GetInstitutionProfile.proto
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
プロトコルID
3419
uint GetInstitutionProfile(Qot_GetInstitutionProfile.Request req);
virtual void OnReply_GetInstitutionProfile(FTAPI_Conn client, uint nSerialNo, Qot_GetInstitutionProfile.Response rsp);
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3419
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;
QotGetInstitutionProfile.C2S c2s = QotGetInstitutionProfile.C2S.CreateBuilder()
.SetMarket(11)
.SetInstitutionId(403413)
.Build();
QotGetInstitutionProfile.Request req = QotGetInstitutionProfile.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetInstitutionProfile(req);
Console.Write("Send QotGetInstitutionProfile: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetInstitutionProfile(FTAPI_Conn client, uint nSerialNo, QotGetInstitutionProfile.Response rsp)
{
Console.Write("Reply: QotGetInstitutionProfile: {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 QotGetInstitutionProfile: 3
Reply: QotGetInstitutionProfile: 3
GetInstitutionProfile: errCode 0, retMsg , retType 0
{
"institutionName": "贝莱德",
"positionValue": 7040102678527.163,
"totalHoldingCount": 4443,
"currency": "USD"
}
2
3
4
5
6
7
8
9
int getInstitutionProfile(Qot_GetInstitutionProfile.Request req);
onReply_GetInstitutionProfile(FTAPI_Conn client, int nSerialNo, Qot_GetInstitutionProfile.Response rsp)
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3419
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;
QotGetInstitutionProfile.C2S c2s = QotGetInstitutionProfile.C2S.newBuilder()
.setMarket(11)
.setInstitutionId(403413)
.build();
QotGetInstitutionProfile.Request req = QotGetInstitutionProfile.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getInstitutionProfile(req);
System.out.printf("Send QotGetInstitutionProfile: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetInstitutionProfile(FTAPI_Conn client, int nSerialNo, QotGetInstitutionProfile.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetInstitutionProfile failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetInstitutionProfile: %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 QotGetInstitutionProfile: 3
Receive QotGetInstitutionProfile: {
"institutionName": "贝莱德",
"positionValue": 7040102678527.163,
"totalHoldingCount": 4443,
"currency": "USD"
}
2
3
4
5
6
7
Futu::u32_t GetInstitutionProfile(const Qot_GetInstitutionProfile::Request &stReq); virtual void OnReply_GetInstitutionProfile(Futu::u32_t nSerialNo, const Qot_GetInstitutionProfile::Response &stRsp) = 0;
概要
プロトコルリクエストとレスポンスの定義
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3419
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_GetInstitutionProfile::Request req;
Qot_GetInstitutionProfile::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_institutionid(1001); // example institution ID, obtain from GetInstitutionList
m_GetInstitutionProfileSerialNo = m_pQotApi->GetInstitutionProfile(req);
}
virtual void OnReply_GetInstitutionProfile(Futu::u32_t nSerialNo, const Qot_GetInstitutionProfile::Response &stRsp) {
if (nSerialNo != m_GetInstitutionProfileSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetInstitutionProfileSerialNo = 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": {
"institutionName": "Vanguard Group",
"positionValue": 8500000000000.0,
"lastPositionValue": 8200000000000.0,
"positionValueChangePct": 3.66,
"totalHoldingCount": 3850,
"newCount": 45,
"soldOutCount": 32,
"increaseCount": 280,
"decreaseCount": 175,
"top10Pct": 28.5,
"disclosureDate": "2024-03-31",
"currency": "USD"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
getInstitutionProfile(qotGetInstitutionProfile)
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3419
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetInstitutionProfile(){
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, institutionId: 403413 },
};
websocket.GetInstitutionProfile(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetInstitutionProfile: 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);
}
QotGetInstitutionProfile()
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
GetInstitutionProfile: errCode 0, retMsg , retType 0
{
"institutionName": "贝莱德",
"positionValue": 7040102678527.163,
"totalHoldingCount": 4443,
"currency": "USD"
}
2
3
4
5
6
7
API制限
- 30秒以内に最大60回のリクエストが可能です
- ページネーションリクエストは最初のページのみレート制限にカウントされます
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_institution_profile(market, institution_id)
説明
機関概況を取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
パラメータ タイプ 説明 market Market 市場タイプ(HK/US)(必須) institution_id int 機関ID(get_institution_list から取得)(必須) 戻り値
パラメータ タイプ 説明 ret RET_CODE API呼び出し結果 data dict ret == RET_OK の場合、辞書データを返す str ret != RET_OK の場合、エラー説明を返す - データフォーマット:
フィールド タイプ 説明 institution_name str 機関名 description str 機関概要 position_value float 保有時価総額 last_position_value float 前期保有時価総額 position_value_change_pct float 時価総額変化率(%) total_holding_count int 総保有数 holding_change_count int 保有変動数 new_count int 新規ポジション銘柄数 sold_out_count int ポジション解消銘柄数 increase_count int 買い増し銘柄数 decrease_count int 保有削減銘柄数 top10_pct float Top10保有比率(%) top10_pct_change float Top10比率変動(%) disclosure_date str 開示日(yyyy-MM-dd) currency str 通貨
- データフォーマット:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# まず機関IDを取得
ret, data, _, _ = quote_ctx.get_institution_list(market=Market.US, count=1)
if ret == RET_OK and len(data) > 0:
inst_id = data.iloc[0]['institution_id']
# 機関概況を照会
ret, profile = quote_ctx.get_institution_profile(market=Market.US, institution_id=inst_id)
if ret == RET_OK:
for k, v in profile.items():
print(f"{k}: {v}")
else:
print('error:', profile)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- Output
institution_name: 贝莱德
description: 贝莱德集团是美国规模最大的资产管理集团之一,提供种类繁多的证券、固定收益、现金管理等投资产品。
position_value: 6959192681765.731
last_position_value: 6093992885377.756
position_value_change_pct: 14.1975
total_holding_count: 4443
holding_change_count: 12
new_count: 87
sold_out_count: 31
increase_count: 2364
decrease_count: 1682
top10_pct: 24.3287
top10_pct_change: 0.4142
disclosure_date: 2026-06-19
currency: USD
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Qot_GetInstitutionProfile.proto
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
プロトコルID
3419
uint GetInstitutionProfile(Qot_GetInstitutionProfile.Request req);
virtual void OnReply_GetInstitutionProfile(FTAPI_Conn client, uint nSerialNo, Qot_GetInstitutionProfile.Response rsp);
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3419
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;
QotGetInstitutionProfile.C2S c2s = QotGetInstitutionProfile.C2S.CreateBuilder()
.SetMarket(11)
.SetInstitutionId(403413)
.Build();
QotGetInstitutionProfile.Request req = QotGetInstitutionProfile.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetInstitutionProfile(req);
Console.Write("Send QotGetInstitutionProfile: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetInstitutionProfile(MMAPI_Conn client, uint nSerialNo, QotGetInstitutionProfile.Response rsp)
{
Console.Write("Reply: QotGetInstitutionProfile: {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 QotGetInstitutionProfile: 3
Reply: QotGetInstitutionProfile: 3
GetInstitutionProfile: errCode 0, retMsg , retType 0
{
"institutionName": "贝莱德",
"positionValue": 7040102678527.163,
"totalHoldingCount": 4443,
"currency": "USD"
}
2
3
4
5
6
7
8
9
int getInstitutionProfile(Qot_GetInstitutionProfile.Request req);
onReply_GetInstitutionProfile(FTAPI_Conn client, int nSerialNo, Qot_GetInstitutionProfile.Response rsp)
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3419
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;
QotGetInstitutionProfile.C2S c2s = QotGetInstitutionProfile.C2S.newBuilder()
.setMarket(11)
.setInstitutionId(403413)
.build();
QotGetInstitutionProfile.Request req = QotGetInstitutionProfile.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getInstitutionProfile(req);
System.out.printf("Send QotGetInstitutionProfile: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetInstitutionProfile(MMAPI_Conn client, int nSerialNo, QotGetInstitutionProfile.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetInstitutionProfile failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetInstitutionProfile: %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 QotGetInstitutionProfile: 3
Receive QotGetInstitutionProfile: {
"institutionName": "贝莱德",
"positionValue": 7040102678527.163,
"totalHoldingCount": 4443,
"currency": "USD"
}
2
3
4
5
6
7
moomoo::u32_t GetInstitutionProfile(const Qot_GetInstitutionProfile::Request &stReq); virtual void OnReply_GetInstitutionProfile(moomoo::u32_t nSerialNo, const Qot_GetInstitutionProfile::Response &stRsp) = 0;
概要
プロトコルリクエストとレスポンスの定義
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3419
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_GetInstitutionProfile::Request req;
Qot_GetInstitutionProfile::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_institutionid(1001); // example institution ID, obtain from GetInstitutionList
m_GetInstitutionProfileSerialNo = m_pQotApi->GetInstitutionProfile(req);
}
virtual void OnReply_GetInstitutionProfile(moomoo::u32_t nSerialNo, const Qot_GetInstitutionProfile::Response &stRsp) {
if (nSerialNo != m_GetInstitutionProfileSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetInstitutionProfileSerialNo = 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": {
"institutionName": "Vanguard Group",
"positionValue": 8500000000000.0,
"lastPositionValue": 8200000000000.0,
"positionValueChangePct": 3.66,
"totalHoldingCount": 3850,
"newCount": 45,
"soldOutCount": 32,
"increaseCount": 280,
"decreaseCount": 175,
"top10Pct": 28.5,
"disclosureDate": "2024-03-31",
"currency": "USD"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
getInstitutionProfile(qotGetInstitutionProfile)
説明
機関プロフィールを取得します。指定機関の保有時価総額、保有変動統計、Top10保有比率などのプロファイルデータを返します。
パラメータ
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
required int32 institutionId = 2; // 機関投資家ID
}
message S2C {
optional string institutionName = 1; // 機関投資家名
optional string description = 2; // 機関投資家概要
optional double positionValue = 3; // 保有時価
optional double lastPositionValue = 4; // 前期保有時価
optional double positionValueChangePct = 5; // 時価総額変化比率(%)
optional int64 totalHoldingCount = 6; // 総保有数
optional int64 holdingChangeCount = 7; // 保有変動数
optional int32 newCount = 8; // 新規建て銘柄数
optional int32 soldOutCount = 9; // 全量売却銘柄数
optional int32 increaseCount = 10; // 買い増し銘柄数
optional int32 decreaseCount = 11; // 売却銘柄数
optional double top10Pct = 12; // Top10保有比率(%)
optional double top10PctChange = 13; // Top10比率変動(%)
optional string disclosureDate = 14; // 披露日付(yyyy-MM-dd)
optional string currency = 15; // 通貨
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType、戻り値
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
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3419
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetInstitutionProfile(){
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, institutionId: 403413 },
};
websocket.GetInstitutionProfile(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetInstitutionProfile: 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);
}
QotGetInstitutionProfile()
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
GetInstitutionProfile: errCode 0, retMsg , retType 0
{
"institutionName": "贝莱德",
"positionValue": 7040102678527.163,
"totalHoldingCount": 4443,
"currency": "USD"
}
2
3
4
5
6
7
API制限
- 30秒以内に最大60回のリクエストが可能です
- ページネーションリクエストは最初のページのみレート制限にカウントされます