# 篩選窩輪 V2

get_warrant_screen(request)

  • 介紹

    窩輪篩選 V2。相比舊接口 get_warrant,返回 43 列窩輪屬性,支持港股 / 新加坡 / 馬來西亞市場,且支持僅返回總數(only_count)。所有數值字段直接傳原始值,OpenD 內部完成倍率轉換。

  • 參數

    參數 類型 說明
    request WarrantScreenRequest 窩輪篩選請求對象,構造時必傳 warrant_market
    • WarrantScreenRequest 字段:

      字段 類型 說明
      warrant_market WarrantMarket 市場
      is_delay bool 是否使用延時行情
      only_count bool 是否僅返回總數(不返回明細)
      page_from int 分頁起始位置
      page_count int 單頁最大返回數
    • 篩選條件 builder 方法(每次調用追加一條篩選條件):

      方法 說明
      add_interval_filter(field_id, min_val=None, max_val=None, min_included=True, max_included=True) 區間篩選
      add_choice_filter(field_id, choices) 多選篩選
      add_sort(field_id, desc=False) 排序
    • 常用 WarrantField field_id(完整列表見 WarrantField):

      field_id 含義 篩選方式
      4 ISSUER_ID 發行商 ID choice
      5 STOCK_OWNER 正股 choice
      6 WARRANT_TYPE 窩輪類型 choice
      8 CURRENT_PRICE 當前價 interval
      9 STREET_RATIO 街貨佔比 interval
      10 VOLUME 成交量 interval
      16 LEVERAGE_RATIO 槓桿比率 interval
      19 STATUS 狀態 choice
      23 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 窩輪類型
      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 窩輪狀態
      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()
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
  • 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
1
2
3
4
5
6
7