# 篩選窩輪 V2
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_warrant_screen(request)
介紹
窩輪篩選 V2。相比舊接口 get_warrant,返回 43 列窩輪屬性,支持港股 / 新加坡 / 馬來西亞市場,且支持僅返回總數(only_count)。所有數值字段直接傳原始值,OpenD 內部完成倍率轉換。
參數
參數 類型 說明 request WarrantScreenRequest 窩輪篩選請求對象,構造時必傳 warrant_market WarrantScreenRequest 字段:
字段 類型 說明 warrant_market WarrantMarket 市場 HK=1、SG=4、MY=15is_delay bool 是否使用延時行情 不傳默認為 Falseonly_count bool 是否僅返回總數(不返回明細) 不傳默認為 False;True 時僅填充 all_count,DataFrame 為空page_from int 分頁起始位置 不傳默認為 0page_count int 單頁最大返回數 不傳默認為 200篩選條件 builder 方法(每次調用追加一條篩選條件):
方法 說明 add_interval_filter(field_id, min_val=None, max_val=None, min_included=True, max_included=True) 區間篩選 field_id 取自 WarrantField;min_val / max_val 直接傳原始值(OpenD 自動倍率轉換,如現價 5 元傳 5.0、街貨佔比 50% 傳 50.0、有效槓桿 > 3 傳 3.0);min_val / max_val 均為可選,全部不傳時該條件不會生效(等同於不篩選)add_choice_filter(field_id, choices) 多選篩選 choices 元素可為 int 枚舉或 str 代碼,例如 STOCK_OWNER 字段可直接傳 ["HK.00700"],WARRANT_TYPE 可傳 [WarrantType.CALL, WarrantType.PUT]add_sort(field_id, desc=False) 排序 desc=True 為降序,默認升序常用 WarrantField field_id(完整列表見 WarrantField):
field_id 含義 篩選方式 4 ISSUER_ID 發行商 ID choice 5 STOCK_OWNER 正股 choice 可傳 ["HK.00700"] 這樣的 code 字符串6 WARRANT_TYPE 窩輪類型 choice 1=認購、2=認沽、3=牛證、4=熊證、5=界內證;詳見 WarrantType8 CURRENT_PRICE 當前價 interval 9 STREET_RATIO 街貨佔比 interval 10 VOLUME 成交量 interval 16 LEVERAGE_RATIO 槓桿比率 interval 19 STATUS 狀態 choice 0=正常、1=終止交易、2=待上市;詳見 WarrantStatus23 EFFECTIVE_LEVERAGE 有效槓桿 interval
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data tuple 當 ret == RET_OK,返回 (last_page, all_count, DataFrame) str 當 ret != RET_OK,返回錯誤描述 返回 DataFrame 字段(共 43 列):
字段 類型 說明 stock_id int 窩輪股票 ID stock_owner int 所屬正股 ID issuer_id int 發行商 ID warrant_type int 窩輪類型 1=認購,2=認沽,3=牛證,4=熊證,5=界內證strike_price float 行權價 maturity_date str 到期日 last_trade_date str 最後交易日 conversion_ratio float 換股比率 last_close_price float 昨收價 recovery_price float 收回價(僅牛熊證) stock_owner_price float 正股價 current_price float 現價 volume int 成交量 turnover float 成交額 sell_vol int 賣量 buy_vol int 買量 sell_price float 賣價 buy_price float 買價 street_rate float 街貨比 high_price float 最高價 low_price float 最低價 implied_volatility float 引伸波幅(僅認購認沽) delta float 對沖值(僅認購認沽) status int 窩輪狀態 0=正常,1=終止交易,2=待上市street_rate_new float 街貨比(新) score float 綜合評分 premium float 溢價 leverage float 槓桿 effective_leverage float 有效槓桿 break_even_point float 打和點 ipop float 價內/價外 amplitude float 振幅 fx_score float 法興評分 ipo_time str 上市時間 street_vol int 街貨量 lot_size int 每手數量 issue_size int 發行量 ipo_price float 發行價 upper_strike_price float 上限價(僅界內證) lower_strike_price float 下限價(僅界內證) iw_price_status int 界內/界外 sensitivity float 敏感度 price_recovery_ratio float 正股距收回價(僅牛熊證)
Example
from futu import (
OpenQuoteContext, RET_OK, WarrantScreenRequest,
WarrantMarket, WarrantField, WarrantType,
)
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# 示例 1:港股低價高槓桿認購證 / 認沽證
req = WarrantScreenRequest(warrant_market=WarrantMarket.HK)
req.add_choice_filter(field_id=WarrantField.WARRANT_TYPE,
choices=[WarrantType.CALL, WarrantType.PUT]) # 認購 + 認沽
req.add_interval_filter(field_id=WarrantField.CURRENT_PRICE,
min_val=0.1, max_val=5.0) # 現價 0.1~5
req.add_interval_filter(field_id=WarrantField.EFFECTIVE_LEVERAGE,
min_val=3.0) # 有效槓桿 > 3
req.add_interval_filter(field_id=WarrantField.STREET_RATIO, max_val=50.0) # 街貨佔比 < 50%
req.add_sort(field_id=WarrantField.VOLUME, desc=True) # 成交量降序
req.page_count = 20
ret, data = quote_ctx.get_warrant_screen(req)
if ret == RET_OK:
last_page, all_count, df = data
print(df[['stock_id', 'warrant_type', 'current_price', 'effective_leverage']].head())
else:
print('error: ', data)
# 示例 2:僅查滿足條件的總數
req = WarrantScreenRequest(warrant_market=WarrantMarket.HK)
req.only_count = True
req.add_choice_filter(field_id=WarrantField.WARRANT_TYPE, choices=[WarrantType.CALL])
req.add_interval_filter(field_id=WarrantField.CURRENT_PRICE, min_val=1.0)
ret, data = quote_ctx.get_warrant_screen(req)
if ret == RET_OK:
_, all_count, _ = data
print(f"滿足條件的認購證總數:{all_count}")
# 示例 3:按正股代碼篩選(choice 直接傳 code 字符串)
req = WarrantScreenRequest(warrant_market=WarrantMarket.HK)
req.add_choice_filter(field_id=WarrantField.STOCK_OWNER, choices=["HK.00700"])
req.add_choice_filter(field_id=WarrantField.WARRANT_TYPE,
choices=[WarrantType.BULL, WarrantType.BEAR]) # 牛證 + 熊證
req.add_sort(field_id=WarrantField.TURNOVER, desc=True)
req.page_count = 50
ret, data = quote_ctx.get_warrant_screen(req)
quote_ctx.close()
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
- Output
stock_id warrant_type current_price effective_leverage
0 87930865475960 1 0.107 4.337
1 87939455410698 1 0.108 4.307
2 88231513189723 1 0.120 4.996
3 87969520182112 1 0.110 3.604
4 88356067241952 1 0.127 6.827
滿足條件的認購證總數:98
2
3
4
5
6
7
# Qot_WarrantScreen.proto
介紹
窩輪篩選 V2
參數
message Boundary
{
required double value = 1;
optional bool includes = 2; // 是否閉區間,默認 true
}
message Interval
{
optional Boundary filterMin = 1;
optional Boundary filterMax = 2;
}
message Choice
{
required int32 contentType = 1; // 1=數值, 2=文本
optional string text = 2;
optional int64 value = 3;
}
// 一條篩選條件:interval / choices 二選一
message ScreenGroup
{
required int32 fieldId = 1; // WarrantField 枚舉
optional Interval interval = 2; // 區間篩選
repeated Choice choices = 3; // 多選篩選
}
message Sort
{
required int32 sortFieldId = 1;
required int32 direction = 2; // 0=升序, 1=降序
}
message C2S
{
required int32 marketType = 1; // 市場,HK=1、SG=4、MY=15
optional bool isDelay = 2;
repeated ScreenGroup filterList = 3;
repeated Sort sortList = 4;
optional bool onlyCount = 5; // 僅返回總數
optional int32 pageFrom = 6;
optional int32 pageCount = 7;
}
message Request
{
required C2S c2s = 1;
}
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
- 返回
message WarrantItem
{
optional int64 stockId = 1;
optional int64 stockOwner = 2;
optional int32 issuerId = 3;
optional int32 warrantType = 4; // 1=認購,2=認沽,3=牛證,4=熊證,5=界內證
optional double strikePrice = 5;
optional string maturityDate = 6;
optional string lastTradeDate = 7;
optional double conversionRatio = 8;
optional double lastclosePrice = 9;
optional double recoveryPrice = 10;
optional double stockOwnerPrice = 11;
optional double currentPrice = 12;
optional int64 volume = 13;
optional double turnover = 14;
optional int64 sellVol = 15;
optional int64 buyVol = 16;
optional double sellPrice = 17;
optional double buyPrice = 18;
optional double streetRate = 19;
optional double highPrice = 20;
optional double lowPrice = 21;
optional double impliedVolatility = 22;
optional double delta = 23;
optional int32 status = 24;
optional double streetRateNew = 25;
optional double score = 26;
optional double premium = 27;
optional double leverage = 28;
optional double effectiveLeverage = 29;
optional double breakEvenPoint = 30;
optional double ipop = 31;
optional double amplitude = 32;
optional double fxScore = 33;
optional string ipoTime = 34;
optional int64 streetVol = 35;
optional int32 lotSize = 36;
optional int64 issueSize = 37;
optional double ipoPrice = 38;
optional double upperStrikePrice = 39;
optional double lowerStrikePrice = 40;
optional int32 iwPriceStatus = 41;
optional double sensitivity = 42;
optional double priceRecoveryRatio = 43;
}
message S2C
{
required bool lastPage = 1;
required int32 allCount = 2;
repeated WarrantItem warrants = 3;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口調用結果,結構參見 RetType
協議 ID
3254
uint WarrantScreen(QotWarrantScreen.Request req); virtual void OnReply_WarrantScreen(FTAPI_Conn client, uint nSerialNo, QotWarrantScreen.Response rsp);
介紹
窩輪篩選 V2
參數
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的請求結構。
返回
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的響應結構。
協議 ID
3254
int warrantScreen(QotWarrantScreen.Request req) onReply_WarrantScreen(FTAPI_Conn client, int nSerialNo, QotWarrantScreen.Response rsp)
介紹
窩輪篩選 V2
參數
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的請求結構。
返回
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的響應結構。
協議 ID
3254
bool WarrantScreen(uint32_t & nSerialNo, const Qot_WarrantScreen::Request & stReq); virtual void OnReply_WarrantScreen(FTAPI_Conn* pConn, uint32_t nSerialNo, const Qot_WarrantScreen::Response & stRsp)
介紹
窩輪篩選 V2
參數
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的請求結構。
返回
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的響應結構。
協議 ID
3254
warrantScreen(qotWarrantScreen)
介紹
窩輪篩選 V2
參數
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的請求結構。
返回
參考 Proto 標籤頁中 Qot_WarrantScreen.proto 的響應結構。
協議 ID
3254
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_warrant_screen(request)
介紹
窩輪篩選 V2,參數與返回字段同 nn 標籤頁。
Example
from moomoo import (
OpenQuoteContext, RET_OK, WarrantScreenRequest,
WarrantMarket, WarrantField, WarrantType,
)
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
req = WarrantScreenRequest(warrant_market=WarrantMarket.HK)
req.add_choice_filter(field_id=WarrantField.WARRANT_TYPE,
choices=[WarrantType.CALL, WarrantType.PUT])
req.add_interval_filter(field_id=WarrantField.CURRENT_PRICE,
min_val=0.1, max_val=5.0)
req.add_interval_filter(field_id=WarrantField.EFFECTIVE_LEVERAGE, min_val=3.0)
req.add_sort(field_id=WarrantField.VOLUME, desc=True)
req.page_count = 20
ret, data = quote_ctx.get_warrant_screen(req)
if ret == RET_OK:
last_page, all_count, df = data
print(df[['stock_id', 'warrant_type', 'current_price', 'effective_leverage']].head())
else:
print('error: ', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Qot_WarrantScreen.proto
參考 nn 標籤頁 Proto 內容,協議 ID 3254。
uint WarrantScreen(QotWarrantScreen.Request req); virtual void OnReply_WarrantScreen(FTAPI_Conn client, uint nSerialNo, QotWarrantScreen.Response rsp);
參考 nn 標籤頁 Proto 內容,協議 ID 3254。
int warrantScreen(QotWarrantScreen.Request req) onReply_WarrantScreen(FTAPI_Conn client, int nSerialNo, QotWarrantScreen.Response rsp)
參考 nn 標籤頁 Proto 內容,協議 ID 3254。
bool WarrantScreen(uint32_t & nSerialNo, const Qot_WarrantScreen::Request & stReq); virtual void OnReply_WarrantScreen(FTAPI_Conn* pConn, uint32_t nSerialNo, const Qot_WarrantScreen::Response & stRsp)
參考 nn 標籤頁 Proto 內容,協議 ID 3254。
warrantScreen(qotWarrantScreen)
參考 nn 標籤頁 Proto 內容,協議 ID 3254。