# 獲取快照
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_market_snapshot(code_list)
介紹
獲取快照數據
參數
參數 類型 説明 code_list list 股票代碼列表 每次最多可請求 400 個標的
list 內元素類型為 str
返回
參數 類型 説明 ret RET_CODE 介面呼叫結果 data pd.DataFrame 當 ret == RET_OK,返回股票快照數據 str 當 ret != RET_OK,返回錯誤描述 - 股票快照數據格式如下:
欄位 類型 説明 code str 股票代碼 name str 股票名稱 update_time str 當前價更新時間 格式:yyyy-MM-dd HH:mm:ss
港股和 A 股市場預設是北京時間,美股市場預設是美東時間last_price float 最新價格 open_price float 今日開盤價 high_price float 最高價格 low_price float 最低價格 prev_close_price float 昨收盤價格 volume int 成交數量 turnover float 成交金額 turnover_rate float 換手率 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%suspension bool 是否停牌 True:停牌listing_date str 上市日期 格式:yyyy-MM-ddequity_valid bool 是否正股 此欄位返回為 True 時,以下正股相關欄位才有合法數值issued_shares int 總股本 total_market_val float 總市值 單位:元net_asset int 資產淨值 net_profit int 淨利潤 earning_per_share float 每股盈利 outstanding_shares int 流通股本 net_asset_per_share float 每股淨資產 circular_market_val float 流通市值 單位:元ey_ratio float 收益率 該欄位為比例欄位,預設不顯示 %pe_ratio float 市盈率 該欄位為比例欄位,預設不顯示 %pb_ratio float 市淨率 該欄位為比例欄位,預設不顯示 %pe_ttm_ratio float 市盈率 TTM 該欄位為比例欄位,預設不顯示 %dividend_ttm float 股息 TTM,派息 dividend_ratio_ttm float 股息率 TTM 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%dividend_lfy float 股息 LFY,上一年度派息 dividend_lfy_ratio float 股息率 LFY 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%stock_owner str 窩輪所屬正股的代碼或期權的標的股代碼 wrt_valid bool 是否是窩輪 此欄位返回為 True 時,以下窩輪相關欄位才有合法數值wrt_conversion_ratio float 換股比率 wrt_type WrtType 窩輪類型 wrt_strike_price float 行使價格 wrt_maturity_date str 格式化窩輪到期時間 wrt_end_trade str 格式化窩輪最後交易時間 wrt_leverage float 槓桿比率 單位:倍wrt_ipop float 價內/價外 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_break_even_point float 打和點 wrt_conversion_price float 換股價 wrt_price_recovery_ratio float 正股距收回價 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_score float 窩輪綜合評分 wrt_code str 窩輪對應的正股(此欄位已廢除,修改為 stock_owner) wrt_recovery_price float 窩輪收回價 wrt_street_vol float 窩輪街貨量 wrt_issue_vol float 窩輪發行量 wrt_street_ratio float 窩輪街貨佔比 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_delta float 窩輪對沖值 wrt_implied_volatility float 窩輪引伸波幅 wrt_premium float 窩輪溢價 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_upper_strike_price float 上限價 僅界內證支援該欄位wrt_lower_strike_price float 下限價 僅界內證支援該欄位wrt_inline_price_status PriceType 界內界外 僅界內證支援該欄位wrt_issuer_code str 發行人代碼 option_valid bool 是否是期權 此欄位返回為 True 時,以下期權相關欄位才有合法數值option_type OptionType 期權類型 strike_time str 期權行權日 格式:yyyy-MM-dd
港股和 A 股市場預設是北京時間,美股市場預設是美東時間option_strike_price float 行權價 option_contract_size float 每份合約數 option_open_interest int 總未平倉合約數 option_implied_volatility float 隱含波動率 option_premium float 溢價 option_delta float 希臘值 Delta option_gamma float 希臘值 Gamma option_vega float 希臘值 Vega option_theta float 希臘值 Theta option_rho float 希臘值 Rho index_option_type IndexOptionType 指數期權類型 option_net_open_interest int 淨未平倉合約數 僅港股期權適用option_expiry_date_distance int 距離到期日天數 負數表示已過期option_contract_nominal_value float 合約名義金額 僅港股期權適用option_owner_lot_multiplier float 相等正股手數 指數期權無該欄位,僅港股期權適用option_area_type OptionAreaType 期權類型(按行權時間) option_contract_multiplier float 合約乘數 plate_valid bool 是否為板塊類型 此欄位返回為 True 時,以下板塊相關欄位才有合法數值plate_raise_count int 板塊類型上漲支數 plate_fall_count int 板塊類型下跌支數 plate_equal_count int 板塊類型平盤支數 index_valid bool 是否有指數類型 此欄位返回為 True 時,以下指數相關欄位才有合法數值index_raise_count int 指數類型上漲支數 index_fall_count int 指數類型下跌支數 index_equal_count int 指數類型平盤支數 lot_size int 每手股數,股票期權表示每份合約的股數 ,期貨表示合約乘數指數期權無該欄位price_spread float 當前向上的擺盤價差 即擺盤數據的賣一價相鄰檔位的報價差ask_price float 賣價 bid_price float 買價 ask_vol float 賣量 bid_vol float 買量 enable_margin bool 是否可融資(已廢棄) 請使用 獲取融資融券數據 介面獲取mortgage_ratio float 股票抵押率(已廢棄) long_margin_initial_ratio float 融資初始保證金率(已廢棄) 請使用 獲取融資融券數據 介面獲取enable_short_sell bool 是否可賣空(已廢棄) 請使用 獲取融資融券數據 介面獲取short_sell_rate float 賣空參考利率(已廢棄) 請使用 獲取融資融券數據 介面獲取short_available_volume int 剩餘可賣空數量(已廢棄) 請使用 獲取融資融券數據 介面獲取short_margin_initial_ratio float 賣空(融券)初始保證金率(已廢棄) 請使用 獲取融資融券數據 介面獲取sec_status SecurityStatus 股票狀態 amplitude float 振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%avg_price float 平均價 bid_ask_ratio float 委比 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%volume_ratio float 量比 highest52weeks_price float 52 周最高價 lowest52weeks_price float 52 周最低價 highest_history_price float 歷史最高價 lowest_history_price float 歷史最低價 pre_price float 盤前價格 pre_high_price float 盤前最高價 pre_low_price float 盤前最低價 pre_volume int 盤前成交量 pre_turnover float 盤前成交額 pre_change_val float 盤前漲跌額 pre_change_rate float 盤前漲跌幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%pre_amplitude float 盤前振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%after_price float 盤後價格 after_high_price float 盤後最高價 after_low_price float 盤後最低價 after_volume int 盤後成交量 科創板支援該數據after_turnover float 盤後成交額 科創板支援該數據after_change_val float 盤後漲跌額 after_change_rate float 盤後漲跌幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%after_amplitude float 盤後振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%overnight_price float 夜盤價格 overnight_high_price float 夜盤最高價 overnight_low_price float 夜盤最低價 overnight_volume int 夜盤成交量 overnight_turnover float 夜盤成交額 overnight_change_val float 夜盤漲跌額 overnight_change_rate float 夜盤漲跌幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%overnight_amplitude float 夜盤振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%future_valid bool 是否期貨 future_last_settle_price float 昨結 future_position float 持倉量 future_position_change float 日增倉 future_main_contract bool 是否主連合約 future_last_trade_time str 最後交易時間 主連,當月,下月等期貨沒有該欄位trust_valid bool 是否基金 trust_dividend_yield float 股息率 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%trust_aum float 資產規模 單位:元trust_outstanding_units int 總發行量 trust_netAssetValue float 單位淨值 trust_premium float 溢價 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%trust_assetClass AssetClass 資產類別
- 股票快照數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_market_snapshot(['HK.00700', 'US.AAPL'])
if ret == RET_OK:
print(data)
print(data['code'][0]) # 取第一條的股票代碼
print(data['code'].values.tolist()) # 轉為 list
else:
print('error:', data)
quote_ctx.close() # 結束後記得關閉當條連線,防止連線條數用盡
2
3
4
5
6
7
8
9
10
11
- Output
code name update_time last_price open_price high_price low_price prev_close_price volume turnover turnover_rate suspension listing_date lot_size price_spread stock_owner ask_price bid_price ask_vol bid_vol enable_margin mortgage_ratio long_margin_initial_ratio enable_short_sell short_sell_rate short_available_volume short_margin_initial_ratio amplitude avg_price bid_ask_ratio volume_ratio highest52weeks_price lowest52weeks_price highest_history_price lowest_history_price close_price_5min after_volume after_turnover sec_status equity_valid issued_shares total_market_val net_asset net_profit earning_per_share outstanding_shares circular_market_val net_asset_per_share ey_ratio pe_ratio pb_ratio pe_ttm_ratio dividend_ttm dividend_ratio_ttm dividend_lfy dividend_lfy_ratio wrt_valid wrt_conversion_ratio wrt_type wrt_strike_price wrt_maturity_date wrt_end_trade wrt_recovery_price wrt_street_vol \
0 HK.00700 騰訊控股 2025-04-07 16:09:07 435.40 441.80 462.40 431.00 497.80 123364114 5.499476e+10 1.341 False 2004-06-16 100 0.20 NaN 435.4 435.20 281300 17300 NaN NaN NaN NaN NaN NaN NaN 6.308 445.792 -68.499 5.627 547.00000 294.400000 706.100065 -13.202011 431.60 0 0.000000e+00 NORMAL True 9202391012 4.006721e+12 1.051300e+12 2.095753e+11 22.774 9202391012 4.006721e+12 114.242 0.199 19.118 3.811 19.118 3.48 0.80 3.48 0.799 False NaN N/A NaN NaN NaN NaN NaN
1 US.AAPL 蘋果 2025-04-07 05:30:43.301 188.38 193.89 199.88 187.34 203.19 125910913 2.424473e+10 0.838 False 1980-12-12 1 0.01 NaN 180.8 180.48 29 400 NaN NaN NaN NaN NaN NaN NaN 6.172 192.554 86.480 2.226 259.81389 163.300566 259.813890 0.053580 188.93 3151311 5.930968e+08 NORMAL True 15022073000 2.829858e+12 6.675809e+10 9.133420e+10 6.080 15016677308 2.828842e+12 4.444 1.417 30.983 42.389 29.901 0.99 0.53 0.98 0.520 False NaN N/A NaN NaN NaN NaN NaN
wrt_issue_vol wrt_street_ratio wrt_delta wrt_implied_volatility wrt_premium wrt_leverage wrt_ipop wrt_break_even_point wrt_conversion_price wrt_price_recovery_ratio wrt_score wrt_upper_strike_price wrt_lower_strike_price wrt_inline_price_status wrt_issuer_code option_valid option_type strike_time option_strike_price option_contract_size option_open_interest option_implied_volatility option_premium option_delta option_gamma option_vega option_theta option_rho option_net_open_interest option_expiry_date_distance option_contract_nominal_value option_owner_lot_multiplier option_area_type option_contract_multiplier index_option_type index_valid index_raise_count index_fall_count index_equal_count plate_valid plate_raise_count plate_fall_count plate_equal_count future_valid future_last_settle_price future_position future_position_change future_main_contract future_last_trade_time trust_valid trust_dividend_yield trust_aum \
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN False N/A NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN N/A False NaN NaN NaN False NaN NaN NaN False NaN NaN NaN NaN NaN False NaN NaN
1 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN False N/A NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN N/A False NaN NaN NaN False NaN NaN NaN False NaN NaN NaN NaN NaN False NaN NaN
trust_outstanding_units trust_netAssetValue trust_premium trust_assetClass pre_price pre_high_price pre_low_price pre_volume pre_turnover pre_change_val pre_change_rate pre_amplitude after_price after_high_price after_low_price after_change_val after_change_rate after_amplitude overnight_price overnight_high_price overnight_low_price overnight_volume overnight_turnover overnight_change_val overnight_change_rate overnight_amplitude
0 NaN NaN NaN N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
1 NaN NaN NaN N/A 180.68 181.98 177.47 276016 49809244.83 -7.7 -4.087 2.394 186.6 188.639 186.44 -1.78 -0.944 1.1673 176.94 186.5 174.4 533115 94944250.56 -11.44 -6.072 6.4231
HK.00700
['HK.00700', 'US.AAPL']
2
3
4
5
6
7
8
9
10
11
12
13
14
# Qot_GetSecuritySnapshot.proto
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData 盤後數據
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
協議 ID
3203
uint GetSecuritySnapshot(QotGetSecuritySnapshot.Request req);
virtual void OnReply_GetSecuritySnapshot(FTAPI_Conn client, uint nSerialNo, QotGetSecuritySnapshot.Response rsp);
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData 盤後數據
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- 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}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotGetSecuritySnapshot.C2S c2s = QotGetSecuritySnapshot.C2S.CreateBuilder()
.AddSecurityList(sec)
.Build();
QotGetSecuritySnapshot.Request req = QotGetSecuritySnapshot.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetSecuritySnapshot(req);
Console.Write("Send QotGetSecuritySnapshot: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetSecuritySnapshot(FTAPI_Conn client, uint nSerialNo, QotGetSecuritySnapshot.Response rsp)
{
Console.Write("Reply: QotGetSecuritySnapshot: {0} \n", nSerialNo);
Console.Write("basic price: {0}\n", rsp.S2C.SnapshotListList[0].Basic.CurPrice);
Console.Write("equityExData issuedShares: {0}\n", rsp.S2C.SnapshotListList[0].EquityExData.IssuedShares);
}
public static void Main(String[] args) {
FTAPI.Init();
Program qot = new Program();
qot.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
- Output
Qot onInitConnect: ret=0 desc= connID=6825619056039643630
Send QotGetSecuritySnapshot: 3
Reply: QotGetSecuritySnapshot: 3
basic price: 474.2
equityExData issuedShares: 9595900007
2
3
4
5
int getSecuritySnapshot(QotGetSecuritySnapshot.Request req);
void onReply_GetSecuritySnapshot(FTAPI_Conn client, int nSerialNo, QotGetSecuritySnapshot.Response rsp);
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- 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=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotGetSecuritySnapshot.C2S c2s = QotGetSecuritySnapshot.C2S.newBuilder()
.addSecurityList(sec)
.build();
QotGetSecuritySnapshot.Request req = QotGetSecuritySnapshot.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getSecuritySnapshot(req);
System.out.printf("Send QotGetSecuritySnapshot: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetSecuritySnapshot(FTAPI_Conn client, int nSerialNo, QotGetSecuritySnapshot.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetSecuritySnapshot failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetSecuritySnapshot: %s\n", 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 QotGetSecuritySnapshot: 2
Receive QotGetSecuritySnapshot: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [{
"basic": {
"security": {
"market": 1,
"code": "00700"
},
"type": 3,
"isSuspend": false,
"listTime": "2004-06-16",
"lotSize": 100,
"priceSpread": 0.5,
"updateTime": "2021-06-24 16:08:14",
"highPrice": 587.5,
"openPrice": 584.0,
"lowPrice": 580.0,
"lastClosePrice": 582.5,
"curPrice": 583.0,
"volume": "10947302",
"turnover": 6.387238277E9,
"turnoverRate": 0.114,
"listTimestamp": 1.0873152E9,
"updateTimestamp": 1.624522094E9,
"askPrice": 583.5,
"bidPrice": 583.0,
"askVol": "142300",
"bidVol": "52800",
"enableMargin": true,
"mortgageRatio": 0.0,
"longMarginInitialRatio": 35.0,
"enableShortSell": true,
"shortSellRate": 0.9,
"shortAvailableVolume": "2006700",
"shortMarginInitialRatio": 60.0,
"amplitude": 1.288,
"avgPrice": 583.453,
"bidAskRatio": -5.273,
"volumeRatio": 0.553,
"highest52WeeksPrice": 773.9,
"lowest52WeeksPrice": 479.4,
"highestHistoryPrice": 773.9,
"lowestHistoryPrice": -6.381,
"secStatus": 1,
"closePrice5Minute": 583.5
},
"equityExData": {
"issuedShares": "9595206625",
"issuedMarketVal": 5.594005462375E12,
"netAsset": 9.17675966408375E11,
"netProfit": 1.90378494646625E11,
"earningsPershare": 19.841,
"outstandingShares": "9595206625",
"outstandingMarketVal": 5.594005462375E12,
"netAssetPershare": 95.639,
"eyRate": 0.232,
"peRate": 29.383,
"pbRate": 6.095,
"peTTMRate": 26.249,
"dividendTTM": 1.6,
"dividendRatioTTM": 0.27,
"dividendLFY": 1.6,
"dividendLFYRatio": 0.274
}
}]
}
}
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
70
71
Futu::u32_t GetSecuritySnapshot(const Qot_GetSecuritySnapshot::Request &stReq);
virtual void OnReply_GetSecuritySnapshot(Futu::u32_t nSerialNo, const Qot_GetSecuritySnapshot::Response &stRsp) = 0;
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- Example
class Program : public FTSPI_Qot, public FTSPI_Trd, 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) {
cout << "connect" << endl;
// 組包
Qot_GetSecuritySnapshot::Request req;
Qot_GetSecuritySnapshot::C2S *c2s = req.mutable_c2s();
auto secList = c2s->mutable_securitylist();
Qot_Common::Security *sec = secList->Add();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_GetSecuritySnapshotSerialNo = m_pQotApi->GetSecuritySnapshot(req);
cout << "Request GetSecuritySnapshot SerialNo: " << m_GetSecuritySnapshotSerialNo << endl;
}
virtual void OnReply_GetSecuritySnapshot(Futu::u32_t nSerialNo, const Qot_GetSecuritySnapshot::Response &stRsp){
if(nSerialNo == m_GetSecuritySnapshotSerialNo)
{
cout << "OnReply_GetSecuritySnapshot SerialNo: " << nSerialNo << endl;
// 解析內部結構列印出來
// ProtoBufToBodyData和UTF8ToLocal函數的定義參見Sample中的tool.h檔案
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSecuritySnapshotSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
FTAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
FTAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
70
71
72
- Output
connect
Request GetSecuritySnapshot SerialNo: 4
OnReply_GetSecuritySnapshot SerialNo: 4
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"basic": {
"security": {
"market": 1,
"code": "00700"
},
"type": 3,
"isSuspend": false,
"listTime": "2004-06-16",
"lotSize": 100,
"priceSpread": 0.5,
"updateTime": "2021-06-09 11:01:40",
"highPrice": 605.5,
"openPrice": 600,
"lowPrice": 597.5,
"lastClosePrice": 601,
"curPrice": 604,
"volume": "2771395",
"turnover": 1668044020,
"turnoverRate": 0.029,
"listTimestamp": 1087315200,
"updateTimestamp": 1623207700,
"askPrice": 604.5,
"bidPrice": 604,
"askVol": "21500",
"bidVol": "9500",
"enableMargin": true,
"mortgageRatio": 0,
"longMarginInitialRatio": 35,
"enableShortSell": true,
"shortSellRate": 0.9,
"shortAvailableVolume": "1849300",
"shortMarginInitialRatio": 60,
"amplitude": 1.331,
"avgPrice": 601.878,
"bidAskRatio": -9.111,
"volumeRatio": 0.643,
"highest52WeeksPrice": 773.9,
"lowest52WeeksPrice": 430.6,
"highestHistoryPrice": 773.9,
"lowestHistoryPrice": -6.381,
"secStatus": 1,
"closePrice5Minute": 603.5
},
"equityExData": {
"issuedShares": "9595206625",
"issuedMarketVal": 5795504801500,
"netAsset": 917675966408.375,
"netProfit": 190378494646.625,
"earningsPershare": 19.841,
"outstandingShares": "9595206625",
"outstandingMarketVal": 5795504801500,
"netAssetPershare": 95.639,
"eyRate": 0.232,
"peRate": 30.442,
"pbRate": 6.315,
"peTTMRate": 27.194,
"dividendTTM": 1.6,
"dividendRatioTTM": 0.26,
"dividendLFY": 1.6,
"dividendLFYRatio": 0.264
}
}
]
}
}
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
70
71
72
73
74
75
76
GetSecuritySnapshot(req);
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- Example
import ftWebsocket from "futu-api";
import { ftCmdID } from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetSecuritySnapshot(){
const { RetType } = Common
const { SubType, QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) { // 登入成功
const req = {
c2s: {
securityList: [
{
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
],
},
};
websocket.GetSecuritySnapshot(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("Snapshot: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let snapshot = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(snapshot);
}
})
.catch((error) => {
console.log("error:", error);
});
} else {
console.log("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//關閉行情連線,連線不再使用之後,要關閉,否則佔用不必要資源
//同時OpenD也限制了最多128條連線
//也可以一個頁面或者一個專案維護一條連線,這裡範例請求一次建立一條連線
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // 5秒後斷開
}
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
- Output
Snapshot: errCode 0, retMsg , retType 0
{
"snapshotList": [{
"basic": {
"security": {
"market": 1,
"code": "00700"
},
"type": 3,
"isSuspend": false,
"listTime": "2004-06-16",
"lotSize": 100,
"priceSpread": 0.2,
"updateTime": "2021-09-09 16:08:17",
"highPrice": 511.5,
"openPrice": 509,
"lowPrice": 479,
"lastClosePrice": 524.5,
"curPrice": 480,
"volume": "54090872",
"turnover": 26716845932,
"turnoverRate": 0.563,
"listTimestamp": 1087315200,
"updateTimestamp": 1631174897,
"askPrice": 480.4,
"bidPrice": 480,
"askVol": "700",
"bidVol": "55300",
"enableMargin": true,
"mortgageRatio": 0,
"longMarginInitialRatio": 35,
"enableShortSell": true,
"shortSellRate": 0.92,
"shortAvailableVolume": "3059000",
"shortMarginInitialRatio": 50,
"amplitude": 6.196,
"avgPrice": 493.925,
"bidAskRatio": 22.703,
"volumeRatio": 1.775,
"highest52WeeksPrice": 773.9,
"lowest52WeeksPrice": 412.2,
"highestHistoryPrice": 773.9,
"lowestHistoryPrice": -6.381,
"secStatus": 1,
"closePrice5Minute": 483.4
},
"equityExData": {
"issuedShares": "9599810645",
"issuedMarketVal": 4607909109600,
"netAsset": 1016063158288.09,
"netProfit": 190383444711.64,
"earningsPershare": 19.832,
"outstandingShares": "9599810645",
"outstandingMarketVal": 4607909109600,
"netAssetPershare": 105.842,
"eyRate": 0.22,
"peRate": 24.203,
"pbRate": 4.535,
"peTTMRate": 20.532,
"dividendTTM": 1.599,
"dividendRatioTTM": 0.33,
"dividendLFY": 1.599,
"dividendLFYRatio": 0.333
}
}]
}
stop
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
介面限制
- 每 30 秒內最多請求 60 次快照。
- 每次請求,介面參數 股票代碼列表 支援傳入的標的數量上限是 400 個。
- 港股 BMP 權限下,單次請求的香港證券(含窩輪、牛熊、界內證)快照數量上限是 20 個。
- 港股期權期貨 BMP 權限下,單次請求的香港期貨和期權的快照數量上限是 20 個。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_market_snapshot(code_list)
介紹
獲取快照數據
參數
參數 類型 説明 code_list list 股票代碼列表 每次最多可請求 400 個標的
list 內元素類型為 str
返回
參數 類型 説明 ret RET_CODE 介面呼叫結果 data pd.DataFrame 當 ret == RET_OK,返回股票快照數據 str 當 ret != RET_OK,返回錯誤描述 - 股票快照數據格式如下:
欄位 類型 説明 code str 股票代碼 name str 股票名稱 update_time str 當前價更新時間 格式:yyyy-MM-dd HH:mm:ss
港股和 A 股市場預設是北京時間,美股市場預設是美東時間last_price float 最新價格 open_price float 今日開盤價 high_price float 最高價格 low_price float 最低價格 prev_close_price float 昨收盤價格 volume int 成交數量 turnover float 成交金額 turnover_rate float 換手率 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%suspension bool 是否停牌 True:停牌listing_date str 上市日期 格式:yyyy-MM-ddequity_valid bool 是否正股 此欄位返回為 True 時,以下正股相關欄位才有合法數值issued_shares int 總股本 total_market_val float 總市值 單位:元net_asset int 資產淨值 net_profit int 淨利潤 earning_per_share float 每股盈利 outstanding_shares int 流通股本 net_asset_per_share float 每股淨資產 circular_market_val float 流通市值 單位:元ey_ratio float 收益率 該欄位為比例欄位,預設不顯示 %pe_ratio float 市盈率 該欄位為比例欄位,預設不顯示 %pb_ratio float 市淨率 該欄位為比例欄位,預設不顯示 %pe_ttm_ratio float 市盈率 TTM 該欄位為比例欄位,預設不顯示 %dividend_ttm float 股息 TTM,派息 dividend_ratio_ttm float 股息率 TTM 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%dividend_lfy float 股息 LFY,上一年度派息 dividend_lfy_ratio float 股息率 LFY 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%stock_owner str 窩輪所屬正股的代碼或期權的標的股代碼 wrt_valid bool 是否是窩輪 此欄位返回為 True 時,以下窩輪相關欄位才有合法數值wrt_conversion_ratio float 換股比率 wrt_type WrtType 窩輪類型 wrt_strike_price float 行使價格 wrt_maturity_date str 格式化窩輪到期時間 wrt_end_trade str 格式化窩輪最後交易時間 wrt_leverage float 槓桿比率 單位:倍wrt_ipop float 價內/價外 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_break_even_point float 打和點 wrt_conversion_price float 換股價 wrt_price_recovery_ratio float 正股距收回價 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_score float 窩輪綜合評分 wrt_code str 窩輪對應的正股(此欄位已廢除,修改為 stock_owner) wrt_recovery_price float 窩輪收回價 wrt_street_vol float 窩輪街貨量 wrt_issue_vol float 窩輪發行量 wrt_street_ratio float 窩輪街貨佔比 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_delta float 窩輪對沖值 wrt_implied_volatility float 窩輪引伸波幅 wrt_premium float 窩輪溢價 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%wrt_upper_strike_price float 上限價 僅界內證支援該欄位wrt_lower_strike_price float 下限價 僅界內證支援該欄位wrt_inline_price_status PriceType 界內界外 僅界內證支援該欄位wrt_issuer_code str 發行人代碼 option_valid bool 是否是期權 此欄位返回為 True 時,以下期權相關欄位才有合法數值option_type OptionType 期權類型 strike_time str 期權行權日 格式:yyyy-MM-dd
港股和 A 股市場預設是北京時間,美股市場預設是美東時間option_strike_price float 行權價 option_contract_size float 每份合約數 option_open_interest int 總未平倉合約數 option_implied_volatility float 隱含波動率 option_premium float 溢價 option_delta float 希臘值 Delta option_gamma float 希臘值 Gamma option_vega float 希臘值 Vega option_theta float 希臘值 Theta option_rho float 希臘值 Rho index_option_type IndexOptionType 指數期權類型 option_net_open_interest int 淨未平倉合約數 僅港股期權適用option_expiry_date_distance int 距離到期日天數 負數表示已過期option_contract_nominal_value float 合約名義金額 僅港股期權適用option_owner_lot_multiplier float 相等正股手數 指數期權無該欄位,僅港股期權適用option_area_type OptionAreaType 期權類型(按行權時間) option_contract_multiplier float 合約乘數 plate_valid bool 是否為板塊類型 此欄位返回為 True 時,以下板塊相關欄位才有合法數值plate_raise_count int 板塊類型上漲支數 plate_fall_count int 板塊類型下跌支數 plate_equal_count int 板塊類型平盤支數 index_valid bool 是否有指數類型 此欄位返回為 True 時,以下指數相關欄位才有合法數值index_raise_count int 指數類型上漲支數 index_fall_count int 指數類型下跌支數 index_equal_count int 指數類型平盤支數 lot_size int 每手股數,股票期權表示每份合約的股數 ,期貨表示合約乘數指數期權無該欄位price_spread float 當前向上的擺盤價差 即擺盤數據的賣一價相鄰檔位的報價差ask_price float 賣價 bid_price float 買價 ask_vol float 賣量 bid_vol float 買量 enable_margin bool 是否可融資(已廢棄) 請使用 獲取融資融券數據 介面獲取mortgage_ratio float 股票抵押率(已廢棄) long_margin_initial_ratio float 融資初始保證金率(已廢棄) 請使用 獲取融資融券數據 介面獲取enable_short_sell bool 是否可賣空(已廢棄) 請使用 獲取融資融券數據 介面獲取short_sell_rate float 賣空參考利率(已廢棄) 請使用 獲取融資融券數據 介面獲取short_available_volume int 剩餘可賣空數量(已廢棄) 請使用 獲取融資融券數據 介面獲取short_margin_initial_ratio float 賣空(融券)初始保證金率(已廢棄) 請使用 獲取融資融券數據 介面獲取sec_status SecurityStatus 股票狀態 amplitude float 振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%avg_price float 平均價 bid_ask_ratio float 委比 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%volume_ratio float 量比 highest52weeks_price float 52 周最高價 lowest52weeks_price float 52 周最低價 highest_history_price float 歷史最高價 lowest_history_price float 歷史最低價 pre_price float 盤前價格 pre_high_price float 盤前最高價 pre_low_price float 盤前最低價 pre_volume int 盤前成交量 pre_turnover float 盤前成交額 pre_change_val float 盤前漲跌額 pre_change_rate float 盤前漲跌幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%pre_amplitude float 盤前振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%after_price float 盤後價格 after_high_price float 盤後最高價 after_low_price float 盤後最低價 after_volume int 盤後成交量 科創板支援該數據after_turnover float 盤後成交額 科創板支援該數據after_change_val float 盤後漲跌額 after_change_rate float 盤後漲跌幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%after_amplitude float 盤後振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%overnight_price float 夜盤價格 overnight_high_price float 夜盤最高價 overnight_low_price float 夜盤最低價 overnight_volume int 夜盤成交量 overnight_turnover float 夜盤成交額 overnight_change_val float 夜盤漲跌額 overnight_change_rate float 夜盤漲跌幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%overnight_amplitude float 夜盤振幅 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%future_valid bool 是否期貨 future_last_settle_price float 昨結 future_position float 持倉量 future_position_change float 日增倉 future_main_contract bool 是否主連合約 future_last_trade_time str 最後交易時間 主連,當月,下月等期貨沒有該欄位trust_valid bool 是否基金 trust_dividend_yield float 股息率 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%trust_aum float 資產規模 單位:元trust_outstanding_units int 總發行量 trust_netAssetValue float 單位淨值 trust_premium float 溢價 該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%trust_assetClass AssetClass 資產類別
- 股票快照數據格式如下:
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_market_snapshot(['HK.00700', 'US.AAPL'])
if ret == RET_OK:
print(data)
print(data['code'][0]) # 取第一條的股票代碼
print(data['code'].values.tolist()) # 轉為 list
else:
print('error:', data)
quote_ctx.close() # 結束後記得關閉當條連線,防止連線條數用盡
2
3
4
5
6
7
8
9
10
11
- Output
code name update_time last_price open_price high_price low_price prev_close_price volume turnover turnover_rate suspension listing_date lot_size price_spread stock_owner ask_price bid_price ask_vol bid_vol enable_margin mortgage_ratio long_margin_initial_ratio enable_short_sell short_sell_rate short_available_volume short_margin_initial_ratio amplitude avg_price bid_ask_ratio volume_ratio highest52weeks_price lowest52weeks_price highest_history_price lowest_history_price close_price_5min after_volume after_turnover sec_status equity_valid issued_shares total_market_val net_asset net_profit earning_per_share outstanding_shares circular_market_val net_asset_per_share ey_ratio pe_ratio pb_ratio pe_ttm_ratio dividend_ttm dividend_ratio_ttm dividend_lfy dividend_lfy_ratio wrt_valid wrt_conversion_ratio wrt_type wrt_strike_price wrt_maturity_date wrt_end_trade wrt_recovery_price wrt_street_vol \
0 HK.00700 騰訊控股 2025-04-07 16:09:07 435.40 441.80 462.40 431.00 497.80 123364114 5.499476e+10 1.341 False 2004-06-16 100 0.20 NaN 435.4 435.20 281300 17300 NaN NaN NaN NaN NaN NaN NaN 6.308 445.792 -68.499 5.627 547.00000 294.400000 706.100065 -13.202011 431.60 0 0.000000e+00 NORMAL True 9202391012 4.006721e+12 1.051300e+12 2.095753e+11 22.774 9202391012 4.006721e+12 114.242 0.199 19.118 3.811 19.118 3.48 0.80 3.48 0.799 False NaN N/A NaN NaN NaN NaN NaN
1 US.AAPL 蘋果 2025-04-07 05:30:43.301 188.38 193.89 199.88 187.34 203.19 125910913 2.424473e+10 0.838 False 1980-12-12 1 0.01 NaN 180.8 180.48 29 400 NaN NaN NaN NaN NaN NaN NaN 6.172 192.554 86.480 2.226 259.81389 163.300566 259.813890 0.053580 188.93 3151311 5.930968e+08 NORMAL True 15022073000 2.829858e+12 6.675809e+10 9.133420e+10 6.080 15016677308 2.828842e+12 4.444 1.417 30.983 42.389 29.901 0.99 0.53 0.98 0.520 False NaN N/A NaN NaN NaN NaN NaN
wrt_issue_vol wrt_street_ratio wrt_delta wrt_implied_volatility wrt_premium wrt_leverage wrt_ipop wrt_break_even_point wrt_conversion_price wrt_price_recovery_ratio wrt_score wrt_upper_strike_price wrt_lower_strike_price wrt_inline_price_status wrt_issuer_code option_valid option_type strike_time option_strike_price option_contract_size option_open_interest option_implied_volatility option_premium option_delta option_gamma option_vega option_theta option_rho option_net_open_interest option_expiry_date_distance option_contract_nominal_value option_owner_lot_multiplier option_area_type option_contract_multiplier index_option_type index_valid index_raise_count index_fall_count index_equal_count plate_valid plate_raise_count plate_fall_count plate_equal_count future_valid future_last_settle_price future_position future_position_change future_main_contract future_last_trade_time trust_valid trust_dividend_yield trust_aum \
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN False N/A NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN N/A False NaN NaN NaN False NaN NaN NaN False NaN NaN NaN NaN NaN False NaN NaN
1 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN False N/A NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN N/A NaN N/A False NaN NaN NaN False NaN NaN NaN False NaN NaN NaN NaN NaN False NaN NaN
trust_outstanding_units trust_netAssetValue trust_premium trust_assetClass pre_price pre_high_price pre_low_price pre_volume pre_turnover pre_change_val pre_change_rate pre_amplitude after_price after_high_price after_low_price after_change_val after_change_rate after_amplitude overnight_price overnight_high_price overnight_low_price overnight_volume overnight_turnover overnight_change_val overnight_change_rate overnight_amplitude
0 NaN NaN NaN N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
1 NaN NaN NaN N/A 180.68 181.98 177.47 276016 49809244.83 -7.7 -4.087 2.394 186.6 188.639 186.44 -1.78 -0.944 1.1673 176.94 186.5 174.4 533115 94944250.56 -11.44 -6.072 6.4231
HK.00700
['HK.00700', 'US.AAPL']
2
3
4
5
6
7
8
9
10
11
12
13
# Qot_GetSecuritySnapshot.proto
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData 盤後數據
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
協議 ID
3203
uint GetSecuritySnapshot(QotGetSecuritySnapshot.Request req);
virtual void OnReply_GetSecuritySnapshot(MMAPI_Conn client, uint nSerialNo, QotGetSecuritySnapshot.Response rsp);
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- 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}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotGetSecuritySnapshot.C2S c2s = QotGetSecuritySnapshot.C2S.CreateBuilder()
.AddSecurityList(sec)
.Build();
QotGetSecuritySnapshot.Request req = QotGetSecuritySnapshot.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetSecuritySnapshot(req);
Console.Write("Send QotGetSecuritySnapshot: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetSecuritySnapshot(MMAPI_Conn client, uint nSerialNo, QotGetSecuritySnapshot.Response rsp)
{
Console.Write("Reply: QotGetSecuritySnapshot: {0} \n", nSerialNo);
Console.Write("basic price: {0}\n", rsp.S2C.SnapshotListList[0].Basic.CurPrice);
Console.Write("equityExData issuedShares: {0}\n", rsp.S2C.SnapshotListList[0].EquityExData.IssuedShares);
}
public static void Main(String[] args) {
MMAPI.Init();
Program qot = new Program();
qot.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
- Output
Qot onInitConnect: ret=0 desc= connID=6825619056039643630
Send QotGetSecuritySnapshot: 3
Reply: QotGetSecuritySnapshot: 3
basic price: 474.2
equityExData issuedShares: 9595900007
2
3
4
5
int getSecuritySnapshot(QotGetSecuritySnapshot.Request req);
void onReply_GetSecuritySnapshot(MMAPI_Conn client, int nSerialNo, QotGetSecuritySnapshot.Response rsp);
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData 盤後數據
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- 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=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotGetSecuritySnapshot.C2S c2s = QotGetSecuritySnapshot.C2S.newBuilder()
.addSecurityList(sec)
.build();
QotGetSecuritySnapshot.Request req = QotGetSecuritySnapshot.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getSecuritySnapshot(req);
System.out.printf("Send QotGetSecuritySnapshot: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetSecuritySnapshot(MMAPI_Conn client, int nSerialNo, QotGetSecuritySnapshot.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetSecuritySnapshot failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetSecuritySnapshot: %s\n", 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 QotGetSecuritySnapshot: 2
Receive QotGetSecuritySnapshot: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [{
"basic": {
"security": {
"market": 1,
"code": "00700"
},
"type": 3,
"isSuspend": false,
"listTime": "2004-06-16",
"lotSize": 100,
"priceSpread": 0.5,
"updateTime": "2021-06-24 16:08:14",
"highPrice": 587.5,
"openPrice": 584.0,
"lowPrice": 580.0,
"lastClosePrice": 582.5,
"curPrice": 583.0,
"volume": "10947302",
"turnover": 6.387238277E9,
"turnoverRate": 0.114,
"listTimestamp": 1.0873152E9,
"updateTimestamp": 1.624522094E9,
"askPrice": 583.5,
"bidPrice": 583.0,
"askVol": "142300",
"bidVol": "52800",
"enableMargin": true,
"mortgageRatio": 0.0,
"longMarginInitialRatio": 35.0,
"enableShortSell": true,
"shortSellRate": 0.9,
"shortAvailableVolume": "2006700",
"shortMarginInitialRatio": 60.0,
"amplitude": 1.288,
"avgPrice": 583.453,
"bidAskRatio": -5.273,
"volumeRatio": 0.553,
"highest52WeeksPrice": 773.9,
"lowest52WeeksPrice": 479.4,
"highestHistoryPrice": 773.9,
"lowestHistoryPrice": -6.381,
"secStatus": 1,
"closePrice5Minute": 583.5
},
"equityExData": {
"issuedShares": "9595206625",
"issuedMarketVal": 5.594005462375E12,
"netAsset": 9.17675966408375E11,
"netProfit": 1.90378494646625E11,
"earningsPershare": 19.841,
"outstandingShares": "9595206625",
"outstandingMarketVal": 5.594005462375E12,
"netAssetPershare": 95.639,
"eyRate": 0.232,
"peRate": 29.383,
"pbRate": 6.095,
"peTTMRate": 26.249,
"dividendTTM": 1.6,
"dividendRatioTTM": 0.27,
"dividendLFY": 1.6,
"dividendLFYRatio": 0.274
}
}]
}
}
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
70
71
moomoo::u32_t GetSecuritySnapshot(const Qot_GetSecuritySnapshot::Request &stReq);
virtual void OnReply_GetSecuritySnapshot(moomoo::u32_t nSerialNo, const Qot_GetSecuritySnapshot::Response &stRsp) = 0;
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData 盤後數據
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- Example
class Program : public MMSPI_Qot, public MMSPI_Trd, 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) {
cout << "connect" << endl;
// 組包
Qot_GetSecuritySnapshot::Request req;
Qot_GetSecuritySnapshot::C2S *c2s = req.mutable_c2s();
auto secList = c2s->mutable_securitylist();
Qot_Common::Security *sec = secList->Add();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_GetSecuritySnapshotSerialNo = m_pQotApi->GetSecuritySnapshot(req);
cout << "Request GetSecuritySnapshot SerialNo: " << m_GetSecuritySnapshotSerialNo << endl;
}
virtual void OnReply_GetSecuritySnapshot(moomoo::u32_t nSerialNo, const Qot_GetSecuritySnapshot::Response &stRsp){
if(nSerialNo == m_GetSecuritySnapshotSerialNo)
{
cout << "OnReply_GetSecuritySnapshot SerialNo: " << nSerialNo << endl;
// 解析內部結構列印出來
// ProtoBufToBodyData和UTF8ToLocal函數的定義參見Sample中的tool.h檔案
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetSecuritySnapshotSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
MMAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
MMAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
70
71
72
- Output
connect
Request GetSecuritySnapshot SerialNo: 4
OnReply_GetSecuritySnapshot SerialNo: 4
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"basic": {
"security": {
"market": 1,
"code": "00700"
},
"type": 3,
"isSuspend": false,
"listTime": "2004-06-16",
"lotSize": 100,
"priceSpread": 0.5,
"updateTime": "2021-06-09 11:01:40",
"highPrice": 605.5,
"openPrice": 600,
"lowPrice": 597.5,
"lastClosePrice": 601,
"curPrice": 604,
"volume": "2771395",
"turnover": 1668044020,
"turnoverRate": 0.029,
"listTimestamp": 1087315200,
"updateTimestamp": 1623207700,
"askPrice": 604.5,
"bidPrice": 604,
"askVol": "21500",
"bidVol": "9500",
"enableMargin": true,
"mortgageRatio": 0,
"longMarginInitialRatio": 35,
"enableShortSell": true,
"shortSellRate": 0.9,
"shortAvailableVolume": "1849300",
"shortMarginInitialRatio": 60,
"amplitude": 1.331,
"avgPrice": 601.878,
"bidAskRatio": -9.111,
"volumeRatio": 0.643,
"highest52WeeksPrice": 773.9,
"lowest52WeeksPrice": 430.6,
"highestHistoryPrice": 773.9,
"lowestHistoryPrice": -6.381,
"secStatus": 1,
"closePrice5Minute": 603.5
},
"equityExData": {
"issuedShares": "9595206625",
"issuedMarketVal": 5795504801500,
"netAsset": 917675966408.375,
"netProfit": 190378494646.625,
"earningsPershare": 19.841,
"outstandingShares": "9595206625",
"outstandingMarketVal": 5795504801500,
"netAssetPershare": 95.639,
"eyRate": 0.232,
"peRate": 30.442,
"pbRate": 6.315,
"peTTMRate": 27.194,
"dividendTTM": 1.6,
"dividendRatioTTM": 0.26,
"dividendLFY": 1.6,
"dividendLFYRatio": 0.264
}
}
]
}
}
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
70
71
72
73
74
75
76
GetSecuritySnapshot(req);
介紹
獲取快照數據
參數
message C2S
{
repeated Qot_Common.Security securityList = 1; //股票
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票結構參見 Security
- 返回
// 正股類型額外數據
message EquitySnapshotExData
{
required int64 issuedShares = 1; // 總股本
required double issuedMarketVal = 2; // 總市值 =總股本*當前價格
required double netAsset = 3; // 資產淨值
required double netProfit = 4; // 盈利(虧損)
required double earningsPershare = 5; // 每股盈利
required int64 outstandingShares = 6; // 流通股本
required double outstandingMarketVal = 7; // 流通市值 =流通股本*當前價格
required double netAssetPershare = 8; // 每股淨資產
required double eyRate = 9; // 收益率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double peRate = 10; // 市盈率
required double pbRate = 11; // 市淨率
required double peTTMRate = 12; // 市盈率 TTM
optional double dividendTTM = 13; // 股息 TTM,派息
optional double dividendRatioTTM = 14; // 股息率 TTM(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double dividendLFY = 15; // 股息 LFY,上一年度派息
optional double dividendLFYRatio = 16; // 股息率 LFY(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
}
// 窩輪類型額外數據
message WarrantSnapshotExData
{
required double conversionRate = 1; //換股比率
required int32 warrantType = 2; //Qot_Common.WarrantType,窩輪類型
required double strikePrice = 3; //行使價
required string maturityTime = 4; //到期日時間字串
required string endTradeTime = 5; //最後交易日時間字串
required Qot_Common.Security owner = 6; //所屬正股
required double recoveryPrice = 7; //收回價,僅牛熊證支援該欄位
required int64 streetVolumn = 8; //街貨量
required int64 issueVolumn = 9; //發行量
required double streetRate = 10; //街貨佔比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 11; //對沖值,僅認購認沽支援該欄位
required double impliedVolatility = 12; //引申波幅,僅認購認沽支援該欄位
required double premium = 13; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double maturityTimestamp = 14; //到期日時間戳記
optional double endTradeTimestamp = 15; //最後交易日時間戳記
optional double leverage = 16; // 槓桿比率(倍)
optional double ipop = 17; // 價內/價外(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double breakEvenPoint = 18; // 打和點
optional double conversionPrice = 19; // 換股價
optional double priceRecoveryRatio = 20; // 正股距收回價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double score = 21; // 綜合評分
optional double upperStrikePrice = 22; //上限價,僅界內證支援該欄位
optional double lowerStrikePrice = 23; //下限價,僅界內證支援該欄位
optional int32 inLinePriceStatus = 24; //Qot_Common.PriceType,界內界外,僅界內證支援該欄位
optional string issuerCode = 25; //發行人代碼
}
// 期權類型額外數據
message OptionSnapshotExData
{
required int32 type = 1; //Qot_Common.OptionType,期權類型(按方向)
required Qot_Common.Security owner = 2; //標的股
required string strikeTime = 3; //行權日時間字串(格式:yyyy-MM-dd)
required double strikePrice = 4; //行權價
required int32 contractSize = 5; //每份合約數(整型數據)
optional double contractSizeFloat = 22; //每份合約數(浮點型數據)
required int32 openInterest = 6; //未平倉合約數
required double impliedVolatility = 7; //隱含波動率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double premium = 8; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double delta = 9; //希臘值 Delta
required double gamma = 10; //希臘值 Gamma
required double vega = 11; //希臘值 Vega
required double theta = 12; //希臘值 Theta
required double rho = 13; //希臘值 Rho
optional double strikeTimestamp = 14; //行權日時間戳記
optional int32 indexOptionType = 15; //Qot_Common.IndexOptionType,指數期權類型
optional int32 netOpenInterest = 16; //淨未平倉合約數,僅港股期權適用
optional int32 expiryDateDistance = 17; //距離到期日天數,負數表示已過期
optional double contractNominalValue = 18; //合約名義金額,僅港股期權適用
optional double ownerLotMultiplier = 19; //相等正股手數,指數期權無該欄位,僅港股期權適用
optional int32 optionAreaType = 20; //Qot_Common.OptionAreaType,期權類型(按行權時間)
optional double contractMultiplier = 21; //合約乘數
}
// 指數類型額外數據
message IndexSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
// 板塊類型額外數據
message PlateSnapshotExData
{
required int32 raiseCount = 1; // 上漲支數
required int32 fallCount = 2; // 下跌支數
required int32 equalCount = 3; // 平盤支數
}
//期貨類型額外數據
message FutureSnapshotExData
{
required double lastSettlePrice = 1; //昨結
required int32 position = 2; //持倉量
required int32 positionChange = 3; //日增倉
required string lastTradeTime = 4; //最後交易日,只有非主連期貨合約才有該欄位
optional double lastTradeTimestamp = 5; //最後交易日時間戳記,只有非主連期貨合約才有該欄位
required bool isMainContract = 6; //是否主連合約
}
//基金類型額外數據
message TrustSnapshotExData
{
required double dividendYield = 1; //股息率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required double aum = 2; //資產規模
required int64 outstandingUnits = 3; //總發行量
required double netAssetValue = 4; //單位淨值
required double premium = 5; //溢價(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
required int32 assetClass = 6; //Qot_Common.AssetClass,資產類別
}
//基本快照數據
message SnapshotBasicData
{
required Qot_Common.Security security = 1; //證券
optional string name = 41; //股票名稱
required int32 type = 2; //Qot_Common.SecurityType,證券類型
required bool isSuspend = 3; //是否停牌
required string listTime = 4; //上市時間字串(格式:yyyy-MM-dd)
required int32 lotSize = 5; //每手數量
required double priceSpread = 6; //價差
required string updateTime = 7; //更新時間字串(格式:yyyy-MM-dd HH:mm:ss)
required double highPrice = 8; //最高價
required double openPrice = 9; //開盤價
required double lowPrice = 10; //最低價
required double lastClosePrice = 11; //昨收價
required double curPrice = 12; //最新價
required int64 volume = 13; //成交量
required double turnover = 14; //成交額
required double turnoverRate = 15; //換手率(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double listTimestamp = 16; //上市時間戳記
optional double updateTimestamp = 17; //更新時間戳記
optional double askPrice = 18;//賣價
optional double bidPrice = 19;//買價
optional int64 askVol = 20;//賣量
optional int64 bidVol = 21;//買量
optional bool enableMargin = 22; // 是否可融資(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double mortgageRatio = 23; // 股票抵押率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double longMarginInitialRatio = 24; // 融資初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional bool enableShortSell = 25; // 是否可賣空(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortSellRate = 26; // 賣空參考利率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional int64 shortAvailableVolume = 27; // 剩餘可賣空數量(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double shortMarginInitialRatio = 28; // 賣空(融券)初始保證金率(已廢棄,請使用 獲取融資融券數據 介面獲取)
optional double amplitude = 29; // 振幅(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double avgPrice = 30; // 平均價
optional double bidAskRatio = 31; // 委比(該欄位為百分比欄位,預設不顯示 %,如 20 實際對應 20%)
optional double volumeRatio = 32; // 量比
optional double highest52WeeksPrice = 33; // 52周最高價
optional double lowest52WeeksPrice = 34; // 52周最低價
optional double highestHistoryPrice = 35; // 歷史最高價
optional double lowestHistoryPrice = 36; // 歷史最低價
optional Qot_Common.PreAfterMarketData preMarket = 37; //Qot_Common::PreAfterMarketData 盤前數據
optional Qot_Common.PreAfterMarketData afterMarket = 38; //Qot_Common::PreAfterMarketData 盤後數據
optional Qot_Common.PreAfterMarketData overnight = 42; //Qot_Common::PreAfterMarketData 夜盤數據
optional int32 secStatus = 39; //Qot_Common::SecurityStatus 股票狀態
optional double closePrice5Minute = 40; //5分鐘收盤價
}
message Snapshot
{
required SnapshotBasicData basic = 1; //快照基本數據
optional EquitySnapshotExData equityExData = 2; //正股快照額外數據
optional WarrantSnapshotExData warrantExData = 3; //窩輪快照額外數據
optional OptionSnapshotExData optionExData = 4; //期權快照額外數據
optional IndexSnapshotExData indexExData = 5; //指數快照額外數據
optional PlateSnapshotExData plateExData = 6; //板塊快照額外數據
optional FutureSnapshotExData futureExData = 7; //期貨類型額外數據
optional TrustSnapshotExData trustExData = 8; //基金類型額外數據
}
message S2C
{
repeated Snapshot snapshotList = 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
- Example
import mmWebsocket from "moomoo-api";
import { mmCmdID } from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetSecuritySnapshot(){
const { RetType } = Common
const { SubType, QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) { // 登入成功
const req = {
c2s: {
securityList: [
{
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
],
},
};
websocket.GetSecuritySnapshot(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("Snapshot: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let snapshot = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(snapshot);
}
})
.catch((error) => {
console.log("error:", error);
});
} else {
console.log("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//關閉行情連線,連線不再使用之後,要關閉,否則佔用不必要資源
//同時OpenD也限制了最多128條連線
//也可以一個頁面或者一個專案維護一條連線,這裡範例請求一次建立一條連線
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // 5秒後斷開
}
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
- Output
Snapshot: errCode 0, retMsg , retType 0
{
"snapshotList": [{
"basic": {
"security": {
"market": 1,
"code": "00700"
},
"type": 3,
"isSuspend": false,
"listTime": "2004-06-16",
"lotSize": 100,
"priceSpread": 0.2,
"updateTime": "2021-09-09 16:08:17",
"highPrice": 511.5,
"openPrice": 509,
"lowPrice": 479,
"lastClosePrice": 524.5,
"curPrice": 480,
"volume": "54090872",
"turnover": 26716845932,
"turnoverRate": 0.563,
"listTimestamp": 1087315200,
"updateTimestamp": 1631174897,
"askPrice": 480.4,
"bidPrice": 480,
"askVol": "700",
"bidVol": "55300",
"enableMargin": true,
"mortgageRatio": 0,
"longMarginInitialRatio": 35,
"enableShortSell": true,
"shortSellRate": 0.92,
"shortAvailableVolume": "3059000",
"shortMarginInitialRatio": 50,
"amplitude": 6.196,
"avgPrice": 493.925,
"bidAskRatio": 22.703,
"volumeRatio": 1.775,
"highest52WeeksPrice": 773.9,
"lowest52WeeksPrice": 412.2,
"highestHistoryPrice": 773.9,
"lowestHistoryPrice": -6.381,
"secStatus": 1,
"closePrice5Minute": 483.4
},
"equityExData": {
"issuedShares": "9599810645",
"issuedMarketVal": 4607909109600,
"netAsset": 1016063158288.09,
"netProfit": 190383444711.64,
"earningsPershare": 19.832,
"outstandingShares": "9599810645",
"outstandingMarketVal": 4607909109600,
"netAssetPershare": 105.842,
"eyRate": 0.22,
"peRate": 24.203,
"pbRate": 4.535,
"peTTMRate": 20.532,
"dividendTTM": 1.599,
"dividendRatioTTM": 0.33,
"dividendLFY": 1.599,
"dividendLFYRatio": 0.333
}
}]
}
stop
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
介面限制
- 每 30 秒內最多請求 60 次快照。
- 每次請求,介面參數 股票代碼列表 支援傳入的標的數量上限是 400 個。