# レーティング変動の取得
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_rating_change(market, change_type=None, count=None, page=None)
説明
レーティング変動を取得します。米国株のレーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
パラメータ タイプ 説明 market Market 市場タイプ(USのみ)(必須) change_type RatingChangeType レーティング変動タイプ("UPGRADE"/"DOWNGRADE"/"NEW_RATING") count int 取得数量 [1, 20]、デフォルト 10 page str ページカーソル 戻り値
パラメータ タイプ 説明 ret RET_CODE API呼び出し結果 data pd.DataFrame ret == RET_OK の場合、データを返す str ret != RET_OK の場合、エラー説明を返す - データフォーマット:
フィールド タイプ 説明 security str 銘柄コード(例 'US.TSLA')name str 銘柄名 rating str 現在のレーティング("BUY"/"HOLD"/"SELL") last_rating str 前回のレーティング("BUY"/"HOLD"/"SELL") target_price float 現在の目標株価 last_target_price float 前回の目標株価 change_type str レーティング変動タイプ("UPGRADE"/"DOWNGRADE"/"NEW_RATING") institution_name str 機関名 recommendation_date str 推奨日(yyyy-MM-dd) last_recommendation_date str 前回の推奨日(yyyy-MM-dd) "SELL" 売り "HOLD" 保持 "BUY" 買い
- データフォーマット:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_rating_change(market=Market.US, count=2)
if ret == RET_OK:
print(f'データ総数: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
データ総数: 5904
security name rating last_rating target_price last_target_price change_type institution_name recommendation_date last_recommendation_date
0 US.MU 美光科技 BUY BUY 1500.0 950.0 UPGRADE 美银证券 2026-06-23 2026-05-13
1 US.INTC 英特尔 BUY BUY 160.0 135.0 UPGRADE 美银证券 2026-06-23 2026-06-11
2
3
4
# Qot_GetRatingChange.proto
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
プロトコルID
3426
uint GetRatingChange(Qot_GetRatingChange.Request req);
virtual void OnReply_GetRatingChange(FTAPI_Conn client, uint nSerialNo, Qot_GetRatingChange.Response rsp);
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3426
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;
QotGetRatingChange.C2S c2s = QotGetRatingChange.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetRatingChange.Request req = QotGetRatingChange.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetRatingChange(req);
Console.Write("Send QotGetRatingChange: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetRatingChange(FTAPI_Conn client, uint nSerialNo, QotGetRatingChange.Response rsp)
{
Console.Write("Reply: QotGetRatingChange: {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 QotGetRatingChange: 3
Reply: QotGetRatingChange: 3
GetRatingChange: errCode 0, retMsg , retType 0
{
"allCount": 5907,
"dataList": [
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "Needham", "targetPrice": 1550.0 },
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "联博集团", "targetPrice": 1300.0 },
{ "security": { "market": 11, "code": "NUE" }, "name": "纽柯钢铁", "changeType": 1, "institutionName": "摩根士丹利", "targetPrice": 258.0 }
]
}
2
3
4
5
6
7
8
9
10
11
int getRatingChange(Qot_GetRatingChange.Request req);
onReply_GetRatingChange(FTAPI_Conn client, int nSerialNo, Qot_GetRatingChange.Response rsp)
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3426
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;
QotGetRatingChange.C2S c2s = QotGetRatingChange.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetRatingChange.Request req = QotGetRatingChange.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getRatingChange(req);
System.out.printf("Send QotGetRatingChange: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetRatingChange(FTAPI_Conn client, int nSerialNo, QotGetRatingChange.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetRatingChange failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetRatingChange: %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 QotGetRatingChange: 3
Receive QotGetRatingChange: {
"allCount": 5907,
"dataList": [
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "Needham", "targetPrice": 1550.0 },
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "联博集团", "targetPrice": 1300.0 },
{ "security": { "market": 11, "code": "NUE" }, "name": "纽柯钢铁", "changeType": 1, "institutionName": "摩根士丹利", "targetPrice": 258.0 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetRatingChange(const Qot_GetRatingChange::Request &stReq);
virtual void OnReply_GetRatingChange(Futu::u32_t nSerialNo, const Qot_GetRatingChange::Response &stRsp) = 0;
概要
プロトコルリクエストとレスポンスの定義
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3426
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_GetRatingChange::Request req;
Qot_GetRatingChange::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(10);
m_GetRatingChangeSerialNo = m_pQotApi->GetRatingChange(req);
}
virtual void OnReply_GetRatingChange(Futu::u32_t nSerialNo, const Qot_GetRatingChange::Response &stRsp) {
if (nSerialNo != m_GetRatingChangeSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetRatingChangeSerialNo = 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": {
"dataList": [
{
"security": {
"market": 11,
"code": "AAPL"
},
"name": "Apple",
"rating": 1,
"lastRating": 2,
"targetPrice": 230.0,
"lastTargetPrice": 210.0,
"changeType": 1,
"institutionName": "Goldman Sachs"
}
],
"allCount": 10
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
getRatingChange(qotGetRatingChange)
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3426
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetRatingChange(){
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.GetRatingChange(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetRatingChange: 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);
}
QotGetRatingChange()
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
GetRatingChange: errCode 0, retMsg , retType 0
{
"allCount": 5907,
"dataList": [
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "Needham", "targetPrice": 1550.0 },
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "联博集团", "targetPrice": 1300.0 },
{ "security": { "market": 11, "code": "NUE" }, "name": "纽柯钢铁", "changeType": 1, "institutionName": "摩根士丹利", "targetPrice": 258.0 }
]
}
2
3
4
5
6
7
8
9
API制限
- 30秒以内に最大60回のリクエストが可能です
- ページネーションリクエストは最初のページのみレート制限にカウントされます
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_rating_change(market, change_type=None, count=None, page=None)
説明
レーティング変動を取得します。米国株のレーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
パラメータ タイプ 説明 market Market 市場タイプ(USのみ)(必須) change_type RatingChangeType レーティング変動タイプ("UPGRADE"/"DOWNGRADE"/"NEW_RATING") count int 取得数量 [1, 20]、デフォルト 10 page str ページカーソル 戻り値
パラメータ タイプ 説明 ret RET_CODE API呼び出し結果 data pd.DataFrame ret == RET_OK の場合、データを返す str ret != RET_OK の場合、エラー説明を返す - データフォーマット:
フィールド タイプ 説明 security str 銘柄コード(例 'US.TSLA')name str 銘柄名 rating str 現在のレーティング("BUY"/"HOLD"/"SELL") last_rating str 前回のレーティング("BUY"/"HOLD"/"SELL") target_price float 現在の目標株価 last_target_price float 前回の目標株価 change_type str レーティング変動タイプ("UPGRADE"/"DOWNGRADE"/"NEW_RATING") institution_name str 機関名 recommendation_date str 推奨日(yyyy-MM-dd) last_recommendation_date str 前回の推奨日(yyyy-MM-dd) "SELL" 売り "HOLD" 保持 "BUY" 買い
- データフォーマット:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_rating_change(market=Market.US, count=2)
if ret == RET_OK:
print(f'データ総数: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
データ総数: 5904
security name rating last_rating target_price last_target_price change_type institution_name recommendation_date last_recommendation_date
0 US.MU 美光科技 BUY BUY 1500.0 950.0 UPGRADE 美银证券 2026-06-23 2026-05-13
1 US.INTC 英特尔 BUY BUY 160.0 135.0 UPGRADE 美银证券 2026-06-23 2026-06-11
2
3
4
# Qot_GetRatingChange.proto
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
プロトコルID
3426
uint GetRatingChange(Qot_GetRatingChange.Request req);
virtual void OnReply_GetRatingChange(FTAPI_Conn client, uint nSerialNo, Qot_GetRatingChange.Response rsp);
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3426
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;
QotGetRatingChange.C2S c2s = QotGetRatingChange.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetRatingChange.Request req = QotGetRatingChange.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetRatingChange(req);
Console.Write("Send QotGetRatingChange: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetRatingChange(MMAPI_Conn client, uint nSerialNo, QotGetRatingChange.Response rsp)
{
Console.Write("Reply: QotGetRatingChange: {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 QotGetRatingChange: 3
Reply: QotGetRatingChange: 3
GetRatingChange: errCode 0, retMsg , retType 0
{
"allCount": 5907,
"dataList": [
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "Needham", "targetPrice": 1550.0 },
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "联博集团", "targetPrice": 1300.0 },
{ "security": { "market": 11, "code": "NUE" }, "name": "纽柯钢铁", "changeType": 1, "institutionName": "摩根士丹利", "targetPrice": 258.0 }
]
}
2
3
4
5
6
7
8
9
10
11
int getRatingChange(Qot_GetRatingChange.Request req);
onReply_GetRatingChange(FTAPI_Conn client, int nSerialNo, Qot_GetRatingChange.Response rsp)
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3426
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;
QotGetRatingChange.C2S c2s = QotGetRatingChange.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetRatingChange.Request req = QotGetRatingChange.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getRatingChange(req);
System.out.printf("Send QotGetRatingChange: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetRatingChange(MMAPI_Conn client, int nSerialNo, QotGetRatingChange.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetRatingChange failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetRatingChange: %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 QotGetRatingChange: 3
Receive QotGetRatingChange: {
"allCount": 5907,
"dataList": [
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "Needham", "targetPrice": 1550.0 },
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "联博集团", "targetPrice": 1300.0 },
{ "security": { "market": 11, "code": "NUE" }, "name": "纽柯钢铁", "changeType": 1, "institutionName": "摩根士丹利", "targetPrice": 258.0 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetRatingChange(const Qot_GetRatingChange::Request &stReq);
virtual void OnReply_GetRatingChange(moomoo::u32_t nSerialNo, const Qot_GetRatingChange::Response &stRsp) = 0;
概要
プロトコルリクエストとレスポンスの定義
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3426
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_GetRatingChange::Request req;
Qot_GetRatingChange::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(10);
m_GetRatingChangeSerialNo = m_pQotApi->GetRatingChange(req);
}
virtual void OnReply_GetRatingChange(moomoo::u32_t nSerialNo, const Qot_GetRatingChange::Response &stRsp) {
if (nSerialNo != m_GetRatingChangeSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetRatingChangeSerialNo = 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": {
"dataList": [
{
"security": {
"market": 11,
"code": "AAPL"
},
"name": "Apple",
"rating": 1,
"lastRating": 2,
"targetPrice": 230.0,
"lastTargetPrice": 210.0,
"changeType": 1,
"institutionName": "Goldman Sachs"
}
],
"allCount": 10
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
getRatingChange(qotGetRatingChange)
説明
レーティング変動を取得します。米国株の銘柄レーティング変動記録(格上げ/格下げ/初回レーティング)を返します。機関名、目標株価変動などの情報を含み、ページングに対応しています。
パラメータ
// レーティング変動タイプ
enum RatingChangeType {
RatingChangeType_Upgrade = 1; // レーティング引き上げ
RatingChangeType_Downgrade = 2; // レーティング引き下げ
RatingChangeType_NewRating = 3; // 新規レーティング
}
// レーティングレベル
enum RatingLevel {
RatingLevel_Unknown = 0;
RatingLevel_Sell = 1; // 売り
RatingLevel_Hold = 2; // 保有
RatingLevel_Buy = 3; // 買い
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (US/CAのみ)
optional int32 changeType = 2; // RatingChangeType, デフォルト引き上げ
optional int32 count = 3; // 件数 [1,20], デフォルト10
optional string page = 4; // ページカーソル、初回は送信不要
}
message RatingChangeItem {
optional Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional int32 rating = 3; // 現在のレーティング RatingLevel
optional int32 lastRating = 4; // 前回レーティング RatingLevel
optional double targetPrice = 5; // 現在の目標株価
optional double lastTargetPrice = 6; // 前回目標株価
optional int32 changeType = 7; // RatingChangeType
optional string institutionName = 8; // 機関投資家名
optional string recommendationDate = 9; // 推奨日(文字列, 例"2025-06-15")
optional string lastRecommendationDate = 10; // 前回推奨日(文字列, 例"2025-06-15")
}
message S2C {
repeated RatingChangeItem dataList = 1;
optional int32 allCount = 2; // 合計
optional string nextPage = 3; // 次ページカーソル、空=データなし
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3426
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetRatingChange(){
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.GetRatingChange(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetRatingChange: 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);
}
QotGetRatingChange()
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
GetRatingChange: errCode 0, retMsg , retType 0
{
"allCount": 5907,
"dataList": [
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "Needham", "targetPrice": 1550.0 },
{ "security": { "market": 11, "code": "MU" }, "name": "美光科技", "changeType": 1, "institutionName": "联博集团", "targetPrice": 1300.0 },
{ "security": { "market": 11, "code": "NUE" }, "name": "纽柯钢铁", "changeType": 1, "institutionName": "摩根士丹利", "targetPrice": 258.0 }
]
}
2
3
4
5
6
7
8
9
API制限
- 30秒以内に最大60回のリクエストが可能です
- ページネーションリクエストは最初のページのみレート制限にカウントされます