# 末日期权标的筛选
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_zero_dte_screener(market, sort_type=None, is_asc=None, count=None, page=None, filter_list=None)
介绍
获取末日期权标的筛选列表,返回当日到期(0DTE)期权对应的标的股票信息,包含波动率、期权成交量、持仓量及期权链信息等数据。
参数
参数 类型 说明 market OptionMarket 期权市场类型 US_SECURITY=美股股票期权、US_INDEX=美股指数期权(仅支持美股市场)sort_type ZeroDteSortType 排序类型 VOLUME=期权成交量、IV=隐含波动率、CHANGE_RATIO=涨跌幅、OPEN_INTEREST=持仓量、MARKET_CAP=市值is_asc bool 是否升序 默认 False(降序)count int 每页数量 范围 [1,500],默认 50page str 分页游标 首次不传或传空,翻页传 next_pagefilter_list list[ZeroDteFilter] 筛选条件列表 多条件为 AND 关系。支持 OWNER_LIST、HAS_EARNINGS_THIS_WEEK、VOLUME、OPEN_INTEREST、IV、HV、IV_RANK、IV_PERCENTILE、PRICE、CHANGE_RATIO筛选器(ZeroDteFilter)
通过 ZeroDteFilter 构造筛选条件,多个条件为 AND 关系。
ZeroDteFilter(indicator_type, value_list=None, interval_min=None, interval_max=None, min_inclusive=True, max_inclusive=True, security_list=None)1
2参数 类型 说明 indicator_type ZeroDteIndicatorType 筛选因子类型 value_list list 确切值列表(枚举值或整数) interval_min float 区间下限 interval_max float 区间上限 min_inclusive bool 下限是否闭区间,默认 True max_inclusive bool 上限是否闭区间,默认 True security_list list[str] 证券代码列表 筛选因子(完整枚举见 ZeroDteIndicatorType),按筛选方式分组:
筛选方式 用哪个参数 适用因子 语义 security_list security_listOWNER_LIST只看指定标的 value_list value_listHAS_EARNINGS_THIS_WEEK命中枚举值集合(0=不限, 1=本周有财报, 2=无) 范围 interval_min/interval_maxIV、IV_RANK、IV_PERCENTILE、HV、VOLUME、OPEN_INTEREST、PRICE、CHANGE_RATIO落在区间内 涉及百分比的因子(如 IV_RANK、IV_PERCENTILE)直接输入小数,0.2 代表 20%。一个条件只承载一种筛选方式,三种互斥,按因子所属方式对号入座。`HAS_EARNINGS_THIS_WEEK` 传 value_list=[1](本周有财报)/[2](无)。
返回
参数 类型 说明 ret RET_CODE 接口调用结果 data dict 当 ret == RET_OK,返回字典,包含 item_list(DataFrame)、next_page(str/None)、update_timestamp(float) str 当 ret != RET_OK,返回错误描述 返回 DataFrame 字段:
字段 类型 说明 owner str 标的股票代码 name str 标的名称 price float 标的当前价格 change_ratio float 涨跌幅(百分比) market_cap float 市值 iv float 隐含波动率(百分比) iv_rank float IV 排名(百分比) iv_percentile float IV 百分位(百分比) hv float 历史波动率(百分比) volume int 期权成交量 open_interest int 期权持仓量 last_trading_time int 最后交易时间戳(Unix 秒) earnings_timestamp int 财报日期时间戳(秒) earnings_time str 财报时间字符串 earnings_pub_type str 财报发布类型(BEFORE/AFTER) chain_info dict 期权链信息 用于 get_option_zero_dte_contract 调用
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# 筛选器用法引导(按需取消注释,构造后传入 filter_list,多条件为 AND 关系):
# # ① 标的列表筛选 — 只看自选标的
# f_owner = ZeroDteFilter(ZeroDteIndicatorType.OWNER_LIST,
# security_list=['US.SPX', 'US.SPY', 'US.QQQ'])
# # ② 确切值筛选 — 本周无财报(避开财报不确定性)
# f_earn = ZeroDteFilter(ZeroDteIndicatorType.HAS_EARNINGS_THIS_WEEK, value_list=[2])
# # ③ 范围筛选 — IV 等级 > 60%(入参用小数 0.6)、期权成交量 > 1000
# f_ivrank = ZeroDteFilter(ZeroDteIndicatorType.IV_RANK, interval_min=0.6)
# f_vol = ZeroDteFilter(ZeroDteIndicatorType.VOLUME, interval_min=1000)
ret, data = quote_ctx.get_option_zero_dte_screener(
market=OptionMarket.US_SECURITY,
sort_type=ZeroDteSortType.VOLUME,
is_asc=False,
count=5
# filter_list=[f_ivrank, f_vol] # 多条件 AND,传入上方构造的筛选条件
)
if ret == RET_OK:
print(data['item_list'])
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
25
26
27
- Output
owner name price change_ratio market_cap iv iv_rank iv_percentile hv volume open_interest last_trading_time earnings_timestamp earnings_time earnings_pub_type chain_info
0 US.SPY 标普500ETF-SPDR 741.75 0.540 7.830717e+11 17.675 27.143 61.111 15.031 14228830 19909256 1781554500 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'SPY', 'multiplier': 100.0, ...}
1 US.QQQ 纳指100ETF-Invesco QQQ Trust 721.34 0.588 4.805349e+11 27.652 62.918 91.269 26.196 8239190 12964422 1781554500 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'QQQ', 'multiplier': 100.0, ...}
2 US.TSLA 特斯拉 406.43 1.823 1.526439e+12 55.053 39.265 64.285 49.359 3623504 7088459 1781553600 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'TSLA', 'multiplier': 100.0, ...}
3 US.NVDA 英伟达 205.19 0.156 4.965598e+12 41.975 27.062 42.460 45.921 3157331 16744961 1781553600 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'NVDA', 'multiplier': 100.0, ...}
4 US.IWM 罗素2000ETF-iShares 292.95 0.874 8.143528e+10 24.857 33.930 64.285 24.802 2840729 11791964 1781554500 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'IWM', 'multiplier': 100.0, ...}
2
3
4
5
6
# Qot_GetOptionZeroDteScreener.proto
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
uint GetOptionZeroDteScreener(Qot_GetOptionZeroDteScreener.Request req); virtual void OnReply_GetOptionZeroDteScreener(FTAPI_Conn client, uint nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp);
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
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)
{
if (errCode != 0) return;
var c2s = Qot_GetOptionZeroDteScreener.C2S.CreateBuilder()
// TODO: 按 proto 填充 c2s 字段
.Build();
var req = Qot_GetOptionZeroDteScreener.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetOptionZeroDteScreener(req);
Console.Write("Send GetOptionZeroDteScreener: {0}\n", seqNo);
}
public void OnReply_GetOptionZeroDteScreener(FTAPI_Conn client, uint nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
FTAPI.Init();
new 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
int getOptionZeroDteScreener(Qot_GetOptionZeroDteScreener.Request req) onReply_GetOptionZeroDteScreener(FTAPI_Conn client, int nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp)
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
Example
public class Program implements FTSPI_Qot, FTSPI_Conn {
private FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnCallback(this);
qot.setQotCallback(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
Qot_GetOptionZeroDteScreener.C2S c2s = Qot_GetOptionZeroDteScreener.C2S.newBuilder()
// TODO: 按 proto 填充 c2s 字段
.build();
Qot_GetOptionZeroDteScreener.Request req = Qot_GetOptionZeroDteScreener.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getOptionZeroDteScreener(req);
System.out.println("Send getOptionZeroDteScreener: " + seqNo);
}
@Override
public void onReply_GetOptionZeroDteScreener(FTAPI_Conn client, int nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
FTAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
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
Futu::u32_t GetOptionZeroDteScreener(const Qot_GetOptionZeroDteScreener::Request &stReq);
virtual void OnReply_GetOptionZeroDteScreener(Futu::u32_t nSerialNo, const Qot_GetOptionZeroDteScreener::Response &stRsp) = 0;
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
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_GetOptionZeroDteScreener::Request req;
Qot_GetOptionZeroDteScreener::C2S *c2s = req.mutable_c2s();
// TODO: 按 proto 填充 c2s 字段
m_GetOptionZeroDteScreenerSerialNo = m_pQotApi->GetOptionZeroDteScreener(req);
}
virtual void OnReply_GetOptionZeroDteScreener(Futu::u32_t nSerialNo, const Qot_GetOptionZeroDteScreener::Response &stRsp) {
if (nSerialNo != m_GetOptionZeroDteScreenerSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetOptionZeroDteScreenerSerialNo = 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
getOptionZeroDteScreener(qotGetOptionZeroDteScreener)
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
Example
import ftWebsocket from "futu-api";
import { Common, Qot_OptionCommon } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetOptionZeroDteScreener(){
const { RetType } = Common
const { OptionMarket, ZeroDteSortType } = Qot_OptionCommon
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11112, false, ''];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
optionMarket: OptionMarket.OptionMarket_US_Security,
sortType: ZeroDteSortType.ZeroDteSortType_Volume,
count: 5,
},
};
websocket.GetOptionZeroDteScreener(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionZeroDteScreener: 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);
}
QotGetOptionZeroDteScreener()
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
- Output
GetOptionZeroDteScreener: errCode 0, retMsg , retType 0
{
"itemList": [
{
"owner": { "market": 1, "code": "SPY" },
"name": "标普500ETF-SPDR",
"price": 741.75,
"changeRate": 0.54,
"marketCap": 783071700000,
"iv": 17.675,
"ivRank": 27.143,
"ivPercentile": 61.111,
"hv": 15.031,
"volume": 14228830,
"openInterest": 19909256,
"lastTradingTime": 1781554500,
"chainInfo": {
"strikeDateTimestamp": 1781499600,
"productCode": "SPY",
"multiplier": 100,
"contractShareSize": 100
}
},
{
"owner": { "market": 1, "code": "QQQ" },
"name": "纳指100ETF-Invesco QQQ Trust",
"price": 721.34,
"changeRate": 0.588,
"marketCap": 480534900000,
"iv": 27.652,
"ivRank": 62.918,
"ivPercentile": 91.269,
"hv": 26.196,
"volume": 8239190,
"openInterest": 12964422,
"lastTradingTime": 1781554500,
"chainInfo": {
"strikeDateTimestamp": 1781499600,
"productCode": "QQQ",
"multiplier": 100,
"contractShareSize": 100
}
}
],
"updateTimestamp": 1781554500
}
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
接口限制
- 30 秒内最多请求 60 次末日期权标的筛选接口(支持分页的接口,仅首次调用纳入统计)
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_zero_dte_screener(market, sort_type=None, is_asc=None, count=None, page=None, filter_list=None)
介绍
获取末日期权标的筛选列表,返回当日到期(0DTE)期权对应的标的股票信息,包含波动率、期权成交量、持仓量及期权链信息等数据。
参数
参数 类型 说明 market OptionMarket 期权市场类型 US_SECURITY=美股股票期权、US_INDEX=美股指数期权(仅支持美股市场)sort_type ZeroDteSortType 排序类型 VOLUME=期权成交量、IV=隐含波动率、CHANGE_RATIO=涨跌幅、OPEN_INTEREST=持仓量、MARKET_CAP=市值is_asc bool 是否升序 默认 False(降序)count int 每页数量 范围 [1,500],默认 50page str 分页游标 首次不传或传空,翻页传 next_pagefilter_list list[ZeroDteFilter] 筛选条件列表 多条件为 AND 关系。支持 OWNER_LIST、HAS_EARNINGS_THIS_WEEK、VOLUME、OPEN_INTEREST、IV、HV、IV_RANK、IV_PERCENTILE、PRICE、CHANGE_RATIO筛选器(ZeroDteFilter)
通过 ZeroDteFilter 构造筛选条件,多个条件为 AND 关系。
ZeroDteFilter(indicator_type, value_list=None, interval_min=None, interval_max=None, min_inclusive=True, max_inclusive=True, security_list=None)1
2参数 类型 说明 indicator_type ZeroDteIndicatorType 筛选因子类型 value_list list 确切值列表(枚举值或整数) interval_min float 区间下限 interval_max float 区间上限 min_inclusive bool 下限是否闭区间,默认 True max_inclusive bool 上限是否闭区间,默认 True security_list list[str] 证券代码列表 筛选因子(完整枚举见 ZeroDteIndicatorType),按筛选方式分组:
筛选方式 用哪个参数 适用因子 语义 security_list security_listOWNER_LIST只看指定标的 value_list value_listHAS_EARNINGS_THIS_WEEK命中枚举值集合(0=不限, 1=本周有财报, 2=无) 范围 interval_min/interval_maxIV、IV_RANK、IV_PERCENTILE、HV、VOLUME、OPEN_INTEREST、PRICE、CHANGE_RATIO落在区间内 涉及百分比的因子(如 IV_RANK、IV_PERCENTILE)直接输入小数,0.2 代表 20%。一个条件只承载一种筛选方式,三种互斥,按因子所属方式对号入座。`HAS_EARNINGS_THIS_WEEK` 传 value_list=[1](本周有财报)/[2](无)。
返回
参数 类型 说明 ret RET_CODE 接口调用结果 data dict 当 ret == RET_OK,返回字典,包含 item_list(DataFrame)、next_page(str/None)、update_timestamp(float) str 当 ret != RET_OK,返回错误描述 返回 DataFrame 字段:
字段 类型 说明 owner str 标的股票代码 name str 标的名称 price float 标的当前价格 change_ratio float 涨跌幅(百分比) market_cap float 市值 iv float 隐含波动率(百分比) iv_rank float IV 排名(百分比) iv_percentile float IV 百分位(百分比) hv float 历史波动率(百分比) volume int 期权成交量 open_interest int 期权持仓量 last_trading_time int 最后交易时间戳(Unix 秒) earnings_timestamp int 财报日期时间戳(秒) earnings_time str 财报时间字符串 earnings_pub_type str 财报发布类型(BEFORE/AFTER) chain_info dict 期权链信息 用于 get_option_zero_dte_contract 调用
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# 筛选器用法引导(按需取消注释,构造后传入 filter_list,多条件为 AND 关系):
# # ① 标的列表筛选 — 只看自选标的
# f_owner = ZeroDteFilter(ZeroDteIndicatorType.OWNER_LIST,
# security_list=['US.SPX', 'US.SPY', 'US.QQQ'])
# # ② 确切值筛选 — 本周无财报(避开财报不确定性)
# f_earn = ZeroDteFilter(ZeroDteIndicatorType.HAS_EARNINGS_THIS_WEEK, value_list=[2])
# # ③ 范围筛选 — IV 等级 > 60%(入参用小数 0.6)、期权成交量 > 1000
# f_ivrank = ZeroDteFilter(ZeroDteIndicatorType.IV_RANK, interval_min=0.6)
# f_vol = ZeroDteFilter(ZeroDteIndicatorType.VOLUME, interval_min=1000)
ret, data = quote_ctx.get_option_zero_dte_screener(
market=OptionMarket.US_SECURITY,
sort_type=ZeroDteSortType.VOLUME,
is_asc=False,
count=5
# filter_list=[f_ivrank, f_vol] # 多条件 AND,传入上方构造的筛选条件
)
if ret == RET_OK:
print(data['item_list'])
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
25
26
27
- Output
owner name price change_ratio market_cap iv iv_rank iv_percentile hv volume open_interest last_trading_time earnings_timestamp earnings_time earnings_pub_type chain_info
0 US.SPY 标普500ETF-SPDR 741.75 0.540 7.830717e+11 17.675 27.143 61.111 15.031 14228830 19909256 1781554500 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'SPY', 'multiplier': 100.0, ...}
1 US.QQQ 纳指100ETF-Invesco QQQ Trust 721.34 0.588 4.805349e+11 27.652 62.918 91.269 26.196 8239190 12964422 1781554500 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'QQQ', 'multiplier': 100.0, ...}
2 US.TSLA 特斯拉 406.43 1.823 1.526439e+12 55.053 39.265 64.285 49.359 3623504 7088459 1781553600 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'TSLA', 'multiplier': 100.0, ...}
3 US.NVDA 英伟达 205.19 0.156 4.965598e+12 41.975 27.062 42.460 45.921 3157331 16744961 1781553600 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'NVDA', 'multiplier': 100.0, ...}
4 US.IWM 罗素2000ETF-iShares 292.95 0.874 8.143528e+10 24.857 33.930 64.285 24.802 2840729 11791964 1781554500 N/A N/A N/A {'strike_date_timestamp': 1781499600, 'product_code': 'IWM', 'multiplier': 100.0, ...}
2
3
4
5
6
# Qot_GetOptionZeroDteScreener.proto
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
uint GetOptionZeroDteScreener(Qot_GetOptionZeroDteScreener.Request req); virtual void OnReply_GetOptionZeroDteScreener(MMAPI_Conn client, uint nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp);
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
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)
{
if (errCode != 0) return;
var c2s = Qot_GetOptionZeroDteScreener.C2S.CreateBuilder()
// TODO: 按 proto 填充 c2s 字段
.Build();
var req = Qot_GetOptionZeroDteScreener.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetOptionZeroDteScreener(req);
Console.Write("Send GetOptionZeroDteScreener: {0}\n", seqNo);
}
public void OnReply_GetOptionZeroDteScreener(MMAPI_Conn client, uint nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
MMAPI.Init();
new 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
int getOptionZeroDteScreener(Qot_GetOptionZeroDteScreener.Request req) onReply_GetOptionZeroDteScreener(MMAPI_Conn client, int nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp)
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
Example
public class Program implements MMSPI_Qot, MMSPI_Conn {
private MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnCallback(this);
qot.setQotCallback(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
Qot_GetOptionZeroDteScreener.C2S c2s = Qot_GetOptionZeroDteScreener.C2S.newBuilder()
// TODO: 按 proto 填充 c2s 字段
.build();
Qot_GetOptionZeroDteScreener.Request req = Qot_GetOptionZeroDteScreener.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getOptionZeroDteScreener(req);
System.out.println("Send getOptionZeroDteScreener: " + seqNo);
}
@Override
public void onReply_GetOptionZeroDteScreener(MMAPI_Conn client, int nSerialNo, Qot_GetOptionZeroDteScreener.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
MMAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
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
Moomoo::u32_t GetOptionZeroDteScreener(const Qot_GetOptionZeroDteScreener::Request &stReq);
virtual void OnReply_GetOptionZeroDteScreener(Moomoo::u32_t nSerialNo, const Qot_GetOptionZeroDteScreener::Response &stRsp) = 0;
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
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_GetOptionZeroDteScreener::Request req;
Qot_GetOptionZeroDteScreener::C2S *c2s = req.mutable_c2s();
// TODO: 按 proto 填充 c2s 字段
m_GetOptionZeroDteScreenerSerialNo = m_pQotApi->GetOptionZeroDteScreener(req);
}
virtual void OnReply_GetOptionZeroDteScreener(Moomoo::u32_t nSerialNo, const Qot_GetOptionZeroDteScreener::Response &stRsp) {
if (nSerialNo != m_GetOptionZeroDteScreenerSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
Moomoo::u32_t m_GetOptionZeroDteScreenerSerialNo = 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
getOptionZeroDteScreener(qotGetOptionZeroDteScreener)
介绍
获取末日期权标的筛选列表
参数
message C2S {
required int32 optionMarket = 1;
optional int32 sortType = 2; //ZeroDteSortType
optional bool isAsc = 3;
optional int32 count = 4; //[1,500],默认50
optional string page = 5;
repeated Qot_OptionCommon.ZeroDteIndicator filterList = 6;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
message OptionChainInfo {
optional int64 strikeDateTimestamp = 1;
optional string productCode = 2;
optional double multiplier = 3;
optional double contractShareSize = 4;
optional int32 expirationType = 5;
optional Qot_Common.Security underlying = 6;
}
message ZeroDteScreenerItem {
required Qot_Common.Security owner = 1;
optional string name = 2;
optional double price = 3;
optional double changeRate = 4;
optional double marketCap = 5;
optional double iv = 6;
optional double ivRank = 7;
optional double ivPercentile = 8;
optional double hv = 9;
optional int64 volume = 10;
optional int64 openInterest = 11;
optional int64 lastTradingTime = 12;
optional int64 earningsTimestamp = 13;
optional string earningsTime = 14;
optional int32 earningsPubType = 15;
optional OptionChainInfo chainInfo = 16;
}
message S2C {
repeated ZeroDteScreenerItem itemList = 1;
optional string nextPage = 2;
optional double updateTimestamp = 3;
}
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
- 接口调用结果,结构参见 RetType
协议 ID
3311
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_OptionCommon } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetOptionZeroDteScreener(){
const { RetType } = Common
const { OptionMarket, ZeroDteSortType } = Qot_OptionCommon
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11112, false, ''];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
optionMarket: OptionMarket.OptionMarket_US_Security,
sortType: ZeroDteSortType.ZeroDteSortType_Volume,
count: 5,
},
};
websocket.GetOptionZeroDteScreener(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionZeroDteScreener: 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);
}
QotGetOptionZeroDteScreener()
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
- Output
GetOptionZeroDteScreener: errCode 0, retMsg , retType 0
{
"itemList": [
{
"owner": { "market": 1, "code": "SPY" },
"name": "标普500ETF-SPDR",
"price": 741.75,
"changeRate": 0.54,
"marketCap": 783071700000,
"iv": 17.675,
"ivRank": 27.143,
"ivPercentile": 61.111,
"hv": 15.031,
"volume": 14228830,
"openInterest": 19909256,
"lastTradingTime": 1781554500,
"chainInfo": {
"strikeDateTimestamp": 1781499600,
"productCode": "SPY",
"multiplier": 100,
"contractShareSize": 100
}
},
{
"owner": { "market": 1, "code": "QQQ" },
"name": "纳指100ETF-Invesco QQQ Trust",
"price": 721.34,
"changeRate": 0.588,
"marketCap": 480534900000,
"iv": 27.652,
"ivRank": 62.918,
"ivPercentile": 91.269,
"hv": 26.196,
"volume": 8239190,
"openInterest": 12964422,
"lastTradingTime": 1781554500,
"chainInfo": {
"strikeDateTimestamp": 1781499600,
"productCode": "QQQ",
"multiplier": 100,
"contractShareSize": 100
}
}
],
"updateTimestamp": 1781554500
}
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
接口限制
- 30 秒内最多请求 60 次末日期权标的筛选接口(支持分页的接口,仅首次调用纳入统计)