# アフターアワーズランキングの取得
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_us_after_hours_rank(sort_dir=None, count=10, offset=None, filter_list=None)
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高等のデータを含みます。
パラメータ
パラメータ タイプ 説明 sort_dir RankSortDir ソート方向、デフォルト降順(値上がり) count int 取得数量 [1, 200]、デフォルト 10 offset int 開始位置、デフォルト 0 filter_list list[ SimpleRankFilter]フィルター条件リスト(複数条件はAND関係) 入力制限
filter_listフィルター条件(SimpleRankFilter):SimpleRankFilterでフィルター条件を構築:コンストラクタパラメータ 説明 indicator_typeフィルター指標タイプ( SimpleRankIndicatorType、必須)interval_min範囲最小値(閉区間、MARKET_CAP/PE に使用) interval_max範囲最大値(閉区間、MARKET_CAP/PE に使用) price_filter価格フィルター列挙( PriceFilter、PRICE タイプ必須)
戻り値
パラメータ タイプ 説明 ret RET_CODE API呼び出し結果 data pd.DataFrame ret == RET_OK の場合、(all_count, DataFrame) タプルを返す str ret != RET_OK の場合、エラー説明を返す - データフォーマット:
フィールド タイプ 説明 security str 銘柄コード(例: 'US.TSLA')name str 銘柄名 after_hours_price float アフターマーケット価格 after_hours_change_ratio float アフターマーケット騰落率(%) after_hours_change_amount float アフターマーケット騰落額 after_hours_turnover float アフターマーケット売買代金 after_hours_volume int アフターマーケット出来高 close_price float 終値(前取引日) change_ratio float 日中騰落率(%) change_amount float 日中騰落額
- データフォーマット:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_us_after_hours_rank(count=2)
if ret == RET_OK:
all_count, df = data
print(f'データ総数: {all_count}')
print(df)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
データ総数: 17728
security name after_hours_price after_hours_change_ratio after_hours_change_amount after_hours_turnover after_hours_volume close_price change_ratio change_amount
0 US.MGN Megan 0.33 92.048 0.158 2.811130e+07 90547558 0.172 30.303030 0.04
1 US.QNRX Quoin Pharmaceuticals 4.85 49.230 1.600 1.498305e+07 3050404 3.250 -26.303855 -1.16
2
3
4
# Qot_GetUSAfterHoursRank.proto
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
プロトコルID
3411
uint GetUSAfterHoursRank(Qot_GetUSAfterHoursRank.Request req);
virtual void OnReply_GetUSAfterHoursRank(FTAPI_Conn client, uint nSerialNo, Qot_GetUSAfterHoursRank.Response rsp);
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3411
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;
QotGetUSAfterHoursRank.C2S c2s = QotGetUSAfterHoursRank.C2S.CreateBuilder()
.SetCount(3)
.Build();
QotGetUSAfterHoursRank.Request req = QotGetUSAfterHoursRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetUSAfterHoursRank(req);
Console.Write("Send QotGetUSAfterHoursRank: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetUSAfterHoursRank(FTAPI_Conn client, uint nSerialNo, QotGetUSAfterHoursRank.Response rsp)
{
Console.Write("Reply: QotGetUSAfterHoursRank: {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
- Output
Send QotGetUSAfterHoursRank: 3
Reply: QotGetUSAfterHoursRank: 3
GetUSAfterHoursRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "TNON" }, "name": "Tenon Medical", "afterHoursPrice": 0.640, "afterHoursChangeRatio": 82.857 },
{ "security": { "market": 11, "code": "SAGT" }, "name": "Sagtec Global", "afterHoursPrice": 1.806, "afterHoursChangeRatio": 82.434 },
{ "security": { "market": 11, "code": "CANG" }, "name": "灿谷", "afterHoursPrice": 0.280, "afterHoursChangeRatio": 47.421 }
]
}
2
3
4
5
6
7
8
9
10
11
int getUSAfterHoursRank(Qot_GetUSAfterHoursRank.Request req);
onReply_GetUSAfterHoursRank(FTAPI_Conn client, int nSerialNo, Qot_GetUSAfterHoursRank.Response rsp)
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3411
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;
QotGetUSAfterHoursRank.C2S c2s = QotGetUSAfterHoursRank.C2S.newBuilder()
.setCount(3)
.build();
QotGetUSAfterHoursRank.Request req = QotGetUSAfterHoursRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getUSAfterHoursRank(req);
System.out.printf("Send QotGetUSAfterHoursRank: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetUSAfterHoursRank(FTAPI_Conn client, int nSerialNo, QotGetUSAfterHoursRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetUSAfterHoursRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetUSAfterHoursRank: %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
- Output
Send QotGetUSAfterHoursRank: 3
Receive QotGetUSAfterHoursRank: {
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "TNON" }, "name": "Tenon Medical", "afterHoursPrice": 0.640, "afterHoursChangeRatio": 82.857 },
{ "security": { "market": 11, "code": "SAGT" }, "name": "Sagtec Global", "afterHoursPrice": 1.806, "afterHoursChangeRatio": 82.434 },
{ "security": { "market": 11, "code": "CANG" }, "name": "灿谷", "afterHoursPrice": 0.280, "afterHoursChangeRatio": 47.421 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetUSAfterHoursRank(const Qot_GetUSAfterHoursRank::Request &stReq);
virtual void OnReply_GetUSAfterHoursRank(Futu::u32_t nSerialNo, const Qot_GetUSAfterHoursRank::Response &stRsp) = 0;
概要
プロトコルリクエストとレスポンスの定義
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3411
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_GetUSAfterHoursRank::Request req;
Qot_GetUSAfterHoursRank::C2S *c2s = req.mutable_c2s();
c2s->set_count(50);
m_GetUSAfterHoursRankSerialNo = m_pQotApi->GetUSAfterHoursRank(req);
}
virtual void OnReply_GetUSAfterHoursRank(Futu::u32_t nSerialNo, const Qot_GetUSAfterHoursRank::Response &stRsp) {
if (nSerialNo != m_GetUSAfterHoursRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetUSAfterHoursRankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 11,
"code": "AAPL"
},
"name": "Apple",
"afterHoursPrice": 196.5,
"afterHoursChangeRatio": 1.25,
"afterHoursChangeAmount": 2.43,
"closePrice": 194.07
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getUSAfterHoursRank(qotGetUSAfterHoursRank)
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3411
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetUSAfterHoursRank(){
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: { count: 3 },
};
websocket.GetUSAfterHoursRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetUSAfterHoursRank: 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);
}
QotGetUSAfterHoursRank()
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
GetUSAfterHoursRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "TNON" }, "name": "Tenon Medical", "afterHoursPrice": 0.640, "afterHoursChangeRatio": 82.857 },
{ "security": { "market": 11, "code": "SAGT" }, "name": "Sagtec Global", "afterHoursPrice": 1.806, "afterHoursChangeRatio": 82.434 },
{ "security": { "market": 11, "code": "CANG" }, "name": "灿谷", "afterHoursPrice": 0.280, "afterHoursChangeRatio": 47.421 }
]
}
2
3
4
5
6
7
8
9
API制限
- 30秒以内に最大60回のリクエストが可能です
- ページネーションリクエストは最初のページのみレート制限にカウントされます
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_us_after_hours_rank(sort_dir=None, count=10, offset=None, filter_list=None)
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高等のデータを含みます。
パラメータ
パラメータ タイプ 説明 sort_dir RankSortDir ソート方向、デフォルト降順(値上がり) count int 取得数量 [1, 200]、デフォルト 10 offset int 開始位置、デフォルト 0 filter_list list[ SimpleRankFilter]フィルター条件リスト(複数条件はAND関係) 入力制限
filter_listフィルター条件(SimpleRankFilter):SimpleRankFilterでフィルター条件を構築:コンストラクタパラメータ 説明 indicator_typeフィルター指標タイプ( SimpleRankIndicatorType、必須)interval_min範囲最小値(閉区間、MARKET_CAP/PE に使用) interval_max範囲最大値(閉区間、MARKET_CAP/PE に使用) price_filter価格フィルター列挙( PriceFilter、PRICE タイプ必須)
戻り値
パラメータ タイプ 説明 ret RET_CODE API呼び出し結果 data pd.DataFrame ret == RET_OK の場合、(all_count, DataFrame) タプルを返す str ret != RET_OK の場合、エラー説明を返す - データフォーマット:
フィールド タイプ 説明 security str 銘柄コード(例: 'US.TSLA')name str 銘柄名 after_hours_price float アフターマーケット価格 after_hours_change_ratio float アフターマーケット騰落率(%) after_hours_change_amount float アフターマーケット騰落額 after_hours_turnover float アフターマーケット売買代金 after_hours_volume int アフターマーケット出来高 close_price float 終値(前取引日) change_ratio float 日中騰落率(%) change_amount float 日中騰落額
- データフォーマット:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_us_after_hours_rank(count=2)
if ret == RET_OK:
all_count, df = data
print(f'データ総数: {all_count}')
print(df)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
データ総数: 17728
security name after_hours_price after_hours_change_ratio after_hours_change_amount after_hours_turnover after_hours_volume close_price change_ratio change_amount
0 US.MGN Megan 0.33 92.048 0.158 2.811130e+07 90547558 0.172 30.303030 0.04
1 US.QNRX Quoin Pharmaceuticals 4.85 49.230 1.600 1.498305e+07 3050404 3.250 -26.303855 -1.16
2
3
4
# Qot_GetUSAfterHoursRank.proto
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
プロトコルID
3411
uint GetUSAfterHoursRank(Qot_GetUSAfterHoursRank.Request req);
virtual void OnReply_GetUSAfterHoursRank(FTAPI_Conn client, uint nSerialNo, Qot_GetUSAfterHoursRank.Response rsp);
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3411
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;
QotGetUSAfterHoursRank.C2S c2s = QotGetUSAfterHoursRank.C2S.CreateBuilder()
.SetCount(3)
.Build();
QotGetUSAfterHoursRank.Request req = QotGetUSAfterHoursRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetUSAfterHoursRank(req);
Console.Write("Send QotGetUSAfterHoursRank: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetUSAfterHoursRank(MMAPI_Conn client, uint nSerialNo, QotGetUSAfterHoursRank.Response rsp)
{
Console.Write("Reply: QotGetUSAfterHoursRank: {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
- Output
Send QotGetUSAfterHoursRank: 3
Reply: QotGetUSAfterHoursRank: 3
GetUSAfterHoursRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "TNON" }, "name": "Tenon Medical", "afterHoursPrice": 0.640, "afterHoursChangeRatio": 82.857 },
{ "security": { "market": 11, "code": "SAGT" }, "name": "Sagtec Global", "afterHoursPrice": 1.806, "afterHoursChangeRatio": 82.434 },
{ "security": { "market": 11, "code": "CANG" }, "name": "灿谷", "afterHoursPrice": 0.280, "afterHoursChangeRatio": 47.421 }
]
}
2
3
4
5
6
7
8
9
10
11
int getUSAfterHoursRank(Qot_GetUSAfterHoursRank.Request req);
onReply_GetUSAfterHoursRank(FTAPI_Conn client, int nSerialNo, Qot_GetUSAfterHoursRank.Response rsp)
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3411
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;
QotGetUSAfterHoursRank.C2S c2s = QotGetUSAfterHoursRank.C2S.newBuilder()
.setCount(3)
.build();
QotGetUSAfterHoursRank.Request req = QotGetUSAfterHoursRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getUSAfterHoursRank(req);
System.out.printf("Send QotGetUSAfterHoursRank: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetUSAfterHoursRank(MMAPI_Conn client, int nSerialNo, QotGetUSAfterHoursRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetUSAfterHoursRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetUSAfterHoursRank: %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
- Output
Send QotGetUSAfterHoursRank: 3
Receive QotGetUSAfterHoursRank: {
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "TNON" }, "name": "Tenon Medical", "afterHoursPrice": 0.640, "afterHoursChangeRatio": 82.857 },
{ "security": { "market": 11, "code": "SAGT" }, "name": "Sagtec Global", "afterHoursPrice": 1.806, "afterHoursChangeRatio": 82.434 },
{ "security": { "market": 11, "code": "CANG" }, "name": "灿谷", "afterHoursPrice": 0.280, "afterHoursChangeRatio": 47.421 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetUSAfterHoursRank(const Qot_GetUSAfterHoursRank::Request &stReq);
virtual void OnReply_GetUSAfterHoursRank(moomoo::u32_t nSerialNo, const Qot_GetUSAfterHoursRank::Response &stRsp) = 0;
概要
プロトコルリクエストとレスポンスの定義
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3411
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_GetUSAfterHoursRank::Request req;
Qot_GetUSAfterHoursRank::C2S *c2s = req.mutable_c2s();
c2s->set_count(50);
m_GetUSAfterHoursRankSerialNo = m_pQotApi->GetUSAfterHoursRank(req);
}
virtual void OnReply_GetUSAfterHoursRank(moomoo::u32_t nSerialNo, const Qot_GetUSAfterHoursRank::Response &stRsp) {
if (nSerialNo != m_GetUSAfterHoursRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetUSAfterHoursRankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 11,
"code": "AAPL"
},
"name": "Apple",
"afterHoursPrice": 196.5,
"afterHoursChangeRatio": 1.25,
"afterHoursChangeAmount": 2.43,
"closePrice": 194.07
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getUSAfterHoursRank(qotGetUSAfterHoursRank)
説明
米国株アフターマーケットランキングを取得します。アフターマーケット取引時間帯の騰落率ランキングを返します。アフターマーケット価格、騰落率、売買代金、出来高などのデータを含みます。
パラメータ
// ソート方向
enum SortDir {
SortDir_Descending = 0; // 降順(値上がり, デフォルト)
SortDir_Ascending = 1; // 昇順(値下がり)
}
// スクリーニング条件タイプ
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 価格フィルタ(列挙型, PriceFilter参照)
IndicatorType_MarketCap = 2; // 時価総額範囲
IndicatorType_PE = 3; // PER範囲
}
// 価格フィルタ列挙型
enum PriceFilter {
PriceFilter_All = 0; // 全て(デフォルト)
PriceFilter_LessThan1 = 1; // 1未満
PriceFilter_Between1And10 = 2; // 1~10の間
PriceFilter_Between10And100 = 3; // 10~100の間
PriceFilter_GreaterThan100 = 4; // 100超
PriceFilter_Near52WeekHigh = 5; // 52週高値付近
PriceFilter_Near52WeekLow = 6; // 52週安値付近
}
// スクリーニング条件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // フィルタ範囲(MarketCap/PE使用)
optional int32 priceFilter = 3; // PriceFilter, 価格フィルタ列挙型(IndicatorType_Price使用時)
}
message C2S {
optional int32 sortDir = 1; // SortDir, ソート方向, デフォルト降順(値上がり)
optional int32 offset = 2; // 開始位置、デフォルト0
optional int32 count = 3; // 取得数量 [1,200]、デフォルト50
repeated Indicator filterList = 4; // スクリーニング条件(AND关系)
}
// アフターマーケットランキングデータ項目
message AfterHoursRankItem {
required Qot_Common.Security security = 1; // 銘柄
optional string name = 2; // 名称
optional double afterHoursPrice = 10; // アフターマーケット価格
optional double afterHoursChangeRatio = 11; // アフターマーケット騰落率(%)
optional double afterHoursChangeAmount = 12; // アフターマーケット騰落額
optional double afterHoursTurnover = 13; // アフターマーケット売買代金
optional int64 afterHoursVolume = 14; // アフターマーケット出来高
optional double closePrice = 15; // 終値(前取引日)
optional double changeRatio = 16; // 場中騰落率(%)
optional double changeAmount = 17; // 場中騰落額
}
message S2C {
repeated AfterHoursRankItem dataList = 1; // データリスト
optional int32 allCount = 2; // 条件に合致するデータ総数
}
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- API呼び出し結果、構造体については以下を参照 RetType
プロトコルID
3411
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetUSAfterHoursRank(){
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: { count: 3 },
};
websocket.GetUSAfterHoursRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetUSAfterHoursRank: 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);
}
QotGetUSAfterHoursRank()
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
GetUSAfterHoursRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "TNON" }, "name": "Tenon Medical", "afterHoursPrice": 0.640, "afterHoursChangeRatio": 82.857 },
{ "security": { "market": 11, "code": "SAGT" }, "name": "Sagtec Global", "afterHoursPrice": 1.806, "afterHoursChangeRatio": 82.434 },
{ "security": { "market": 11, "code": "CANG" }, "name": "灿谷", "afterHoursPrice": 0.280, "afterHoursChangeRatio": 47.421 }
]
}
2
3
4
5
6
7
8
9
API制限
- 30秒以内に最大60回のリクエストが可能です
- ページネーションリクエストは最初のページのみレート制限にカウントされます