stock-sdk 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +58 -13
- package/dist/index.d.ts +58 -13
- package/dist/index.js +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/stock-sdk)
|
|
4
4
|
[](https://www.npmjs.com/package/stock-sdk)
|
|
5
5
|
[](https://github.com/chengzuopeng/stock-sdk/blob/master/LICENSE)
|
|
6
|
-
[](https://www.npmjs.com/package/stock-sdk-mcp)
|
|
7
|
+
[](https://stock-sdk.linkdiary.cn/mcp/)
|
|
7
8
|
|
|
8
9
|
**[English](./README_EN.md)** | 中文
|
|
9
10
|
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|
无需 Python、无需后端服务,直接在 **浏览器或 Node.js** 中获取 **A 股 / 港股 / 美股 / 公募基金** 的实时行情与 K 线数据。
|
|
13
14
|
|
|
14
|
-
**✨ 零依赖 | 🌐 Browser + Node.js | 📦
|
|
15
|
+
**✨ 零依赖 | 🌐 Browser + Node.js | 📦 轻量发布包 | 🧠 完整 TypeScript 类型**
|
|
15
16
|
|
|
16
17
|
## Documentation
|
|
17
18
|
|
|
@@ -48,17 +49,19 @@
|
|
|
48
49
|
|
|
49
50
|
## 特性
|
|
50
51
|
|
|
51
|
-
- ✅
|
|
52
|
+
- ✅ **零依赖**,轻量级发布包
|
|
52
53
|
- ✅ 支持 **浏览器** 和 **Node.js 18+** 双端运行
|
|
53
54
|
- ✅ 同时提供 **ESM** 和 **CommonJS** 两种模块格式
|
|
54
55
|
- ✅ 完整的 **TypeScript** 类型定义和单元测试覆盖
|
|
55
56
|
- ✅ **A 股、港股、美股、公募基金**实时行情
|
|
56
57
|
- ✅ **历史 K 线**(日/周/月)、**分钟 K 线**(1/5/15/30/60 分钟)和**当日分时走势**数据
|
|
57
|
-
- ✅ **技术指标**:内置 MA、MACD、BOLL、KDJ、RSI、WR
|
|
58
|
+
- ✅ **技术指标**:内置 MA、MACD、BOLL、KDJ、RSI、WR、BIAS、CCI、ATR、OBV、ROC、DMI、SAR、KC
|
|
58
59
|
- ✅ **期货行情**:国内期货 K 线、全球期货实时行情与 K 线、期货库存数据
|
|
59
60
|
- ✅ **期权数据**:中金所股指期权、上交所 ETF 期权、商品期权的报价 / K 线 / 分钟行情
|
|
60
61
|
- ✅ **资金流向**、**盘口大单**等扩展数据
|
|
61
62
|
- ✅ 获取全部 **A 股代码列表**(5000+ 只股票)和批量获取**全市场行情**(内置并发控制)
|
|
63
|
+
- ✅ 支持 **provider 级重试 / 限流 / 熔断策略覆盖**,兼容旧的全局请求配置
|
|
64
|
+
- ✅ **AI / MCP 就绪** — 配套 [stock-sdk-mcp](https://www.npmjs.com/package/stock-sdk-mcp) MCP Server,一行命令接入 Cursor / Claude / Gemini 等 AI 工具
|
|
62
65
|
|
|
63
66
|
## 安装
|
|
64
67
|
|
|
@@ -104,6 +107,37 @@ const allQuotes = await sdk.getAllAShareQuotes({
|
|
|
104
107
|
console.log(`共获取 ${allQuotes.length} 只股票`);
|
|
105
108
|
```
|
|
106
109
|
|
|
110
|
+
## 🤖 AI / MCP 集成
|
|
111
|
+
|
|
112
|
+
Stock SDK 配套 MCP Server([stock-sdk-mcp](https://www.npmjs.com/package/stock-sdk-mcp)),可一键接入主流 AI 工具:
|
|
113
|
+
|
|
114
|
+
| AI 工具 | 配置方式 |
|
|
115
|
+
|---------|---------|
|
|
116
|
+
| Cursor | `~/.cursor/mcp.json` |
|
|
117
|
+
| Claude Desktop | `claude_desktop_config.json` |
|
|
118
|
+
| OpenClaw | `~/.clawdbot/config.yaml` |
|
|
119
|
+
| Codex CLI | `~/.codex/config.json` |
|
|
120
|
+
| Gemini CLI | `~/.gemini/settings.json` |
|
|
121
|
+
|
|
122
|
+
**配置示例:**
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"stock-sdk": {
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["-y", "stock-sdk-mcp"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**内置 4 个专业 AI Skills:** 技术分析 / 智能选股 / 市场概览 / 实时监控
|
|
136
|
+
|
|
137
|
+
👉 [完整 MCP 文档](https://stock-sdk.linkdiary.cn/mcp/)
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
107
141
|
## API 列表
|
|
108
142
|
|
|
109
143
|
💡 API 详细文档请查阅 [https://stock-sdk.linkdiary.cn/](https://stock-sdk.linkdiary.cn/)
|
|
@@ -142,6 +176,11 @@ console.log(`共获取 ${allQuotes.length} 只股票`);
|
|
|
142
176
|
| `calcBIAS` | 计算乖离率 |
|
|
143
177
|
| `calcCCI` | 计算商品通道指数 |
|
|
144
178
|
| `calcATR` | 计算平均真实波幅 |
|
|
179
|
+
| `calcOBV` | 计算能量潮 |
|
|
180
|
+
| `calcROC` | 计算变动率指标 |
|
|
181
|
+
| `calcDMI` | 计算趋向指标 |
|
|
182
|
+
| `calcSAR` | 计算抛物线转向 |
|
|
183
|
+
| `calcKC` | 计算肯特纳通道 |
|
|
145
184
|
|
|
146
185
|
### 行业板块
|
|
147
186
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var qe=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Xn=Object.prototype.hasOwnProperty;var Oe=(t,e)=>{for(var n in e)qe(t,n,{get:e[n],enumerable:!0})},Yn=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wn(e))!Xn.call(t,r)&&r!==n&&qe(t,r,{get:()=>e[r],enumerable:!(o=Vn(e,r))||o.enumerable});return t};var Zn=t=>Yn(qe({},"__esModule",{value:!0}),t);var Dr={};Oe(Dr,{HttpError:()=>B,StockSDK:()=>Ce,addIndicators:()=>ye,asyncPool:()=>H,calcATR:()=>$,calcBIAS:()=>ge,calcBOLL:()=>pe,calcCCI:()=>he,calcDMI:()=>jt,calcEMA:()=>K,calcKC:()=>$t,calcKDJ:()=>de,calcMA:()=>ue,calcMACD:()=>ce,calcOBV:()=>Ht,calcROC:()=>qt,calcRSI:()=>me,calcSAR:()=>Qt,calcSMA:()=>N,calcWMA:()=>He,calcWR:()=>fe,chunkArray:()=>v,decodeGBK:()=>X,default:()=>Gn,extractJsonFromJsonp:()=>Ie,jsonpRequest:()=>_,parseResponse:()=>Y,safeNumber:()=>y,safeNumberOrNull:()=>S});module.exports=Zn(Dr);function X(t){return new TextDecoder("gbk").decode(t)}function Y(t){let e=t.split(";").map(o=>o.trim()).filter(Boolean),n=[];for(let o of e){let r=o.indexOf("=");if(r<0)continue;let s=o.slice(0,r).trim();s.startsWith("v_")&&(s=s.slice(2));let i=o.slice(r+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let a=i.split("~");n.push({key:s,fields:a})}return n}function y(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function S(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function C(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:C(String(t))}var je="https://qt.gtimg.cn",Qe="https://web.ifzq.gtimg.cn/appstock/app/minute/query",$e="https://assets.linkdiary.cn/shares/zh_a_list.json",Ge="https://assets.linkdiary.cn/shares/us_list.json",ze="https://assets.linkdiary.cn/shares/hk_list.json",Ve="https://assets.linkdiary.cn/shares/fund_list",Gt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var Se="https://push2his.eastmoney.com/api/qt/stock/kline/get",We="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Xe="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Ye="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ze="https://17.push2.eastmoney.com/api/qt/clist/get",Je="https://91.push2.eastmoney.com/api/qt/stock/get",et="https://29.push2.eastmoney.com/api/qt/clist/get",tt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",nt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",rt="https://79.push2.eastmoney.com/api/qt/clist/get",ot="https://91.push2.eastmoney.com/api/qt/stock/get",st="https://29.push2.eastmoney.com/api/qt/clist/get",it="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",at="https://push2his.eastmoney.com/api/qt/stock/trends2/get",w="https://datacenter-web.eastmoney.com/api/data/v1/get",Z="https://push2his.eastmoney.com/api/qt/stock/kline/get",lt="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",J="58b2fa8f54638b60b87d69b31969089c",ut={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},z={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},Re={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},ee="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",te="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",ct="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",Ee="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",pt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",dt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",mt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",ft="https://futsseapi.eastmoney.com/list/option/221",gt="https://datacenter-web.eastmoney.com/api/data/get",ht="b2884a393a59ad64002292a3e90d46a5";var Te={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},yt=3e4,ne=500,re=500,oe=7,Ct=3,Ot=1e3,St=3e4,Rt=2,Et=[408,429,500,502,503,504];var _e=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),o=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+o),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var zt=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Tt=0;function Jn(){return typeof window<"u"&&typeof window.document<"u"}function Vt(){if(Jn())return;let t=zt[Tt];return Tt=(Tt+1)%zt.length,t}var se=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},be=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new se;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var B=class extends Error{constructor(n,o,r,s){let i=o?` ${o}`:"",a=r?`, url: ${r}`:"",l=s?`, provider: ${s}`:"";super(`HTTP error! status: ${n}${i}${a}${l}`);this.status=n;this.statusText=o;this.url=r;this.provider=s;this.name="HttpError"}},ie=class{constructor(e={}){this.baseUrl=e.baseUrl??je,this.timeout=e.timeout??yt,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new _e(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new be(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(o=>o.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Ct,baseDelay:e?.baseDelay??Ot,maxDelay:e?.maxDelay??St,backoffMultiplier:e?.backoffMultiplier??Rt,retryableStatusCodes:e?.retryableStatusCodes??Et,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof B?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let o=await e();return this.circuitBreaker?.recordSuccess(),o}catch(o){if(this.shouldRetry(o,n)){let r=this.calculateDelay(n);return this.retryOptions.onRetry&&o instanceof Error&&this.retryOptions.onRetry(n+1,o,r),await this.sleep(r),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),o}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new se("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let o=new AbortController,r=setTimeout(()=>o.abort(),this.timeout),s=this.inferProvider(e),i={...this.headers};if(this.rotateUserAgent){let a=Vt();a&&(i["User-Agent"]=a)}try{let a=await fetch(e,{signal:o.signal,headers:i});if(!a.ok)throw new B(a.status,a.statusText,e,s);switch(n.responseType){case"json":return await a.json();case"arraybuffer":return await a.arrayBuffer();default:return await a.text()}}catch(a){throw a instanceof Error&&(a.url=e,a.provider=s),a}finally{clearTimeout(r)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,o=await this.get(n,{responseType:"arraybuffer"}),r=X(o);return Y(r)}};var er=new Set(["daily","weekly","monthly"]),tr=new Set(["1","5","15","30","60"]),nr=new Set(["","qfq","hfq"]);function L(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function A(t){if(!er.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function ae(t){if(!tr.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function U(t){if(!nr.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function v(t,e){L(e,"chunkSize");let n=[];for(let o=0;o<t.length;o+=e)n.push(t.slice(o,o+e));return n}async function H(t,e){L(e,"concurrency");let n=[],o=[];for(let r of t){let s=Promise.resolve().then(()=>r()).then(i=>{n.push(i)});if(o.push(s),o.length>=e){await Promise.race(o);for(let i=o.length-1;i>=0;i--)await Promise.race([o[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&o.splice(i,1)}}return await Promise.all(o),n}function Ae(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function I(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function D(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var rr=typeof document<"u"&&typeof window<"u",or=0;function Wt(){return`__stock_sdk_jsonp_${Date.now()}_${or++}`}function Ie(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let o=e.indexOf("(");if(o===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let r=e.lastIndexOf(")");if(r===-1||r<=o)throw new Error("Invalid JSONP response: no closing parenthesis found");let s=e.slice(o+1,r);return JSON.parse(s)}function sr(t,e){let{timeout:n=15e3,callbackParam:o="callback",callbackMode:r="query"}=e;return new Promise((s,i)=>{let a=Wt(),l;if(r==="path")l=t.replace("{callback}",a);else{let h=t.includes("?")?"&":"?";l=`${t}${h}${o}=${a}`}let u=document.createElement("script"),c=!1,m=window,d=()=>{u.parentNode&&u.parentNode.removeChild(u),delete m[a]},f=setTimeout(()=>{c||(c=!0,d(),i(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);m[a]=h=>{c||(c=!0,clearTimeout(f),d(),s(h))},u.onerror=()=>{c||(c=!0,clearTimeout(f),d(),i(new Error(`JSONP script load failed: ${t}`)))},u.src=l,document.head.appendChild(u)})}async function ir(t,e){let{timeout:n=15e3,callbackParam:o="callback",callbackMode:r="query"}=e,s=Wt(),i;if(r==="path")i=t.replace("{callback}",s);else{let u=t.includes("?")?"&":"?";i=`${t}${u}${o}=${s}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let u=await fetch(i,{signal:a.signal});if(!u.ok)throw new Error(`JSONP fetch failed with status ${u.status}: ${t}`);let c=await u.text();return Ie(c)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):u}finally{clearTimeout(l)}}function _(t,e={}){return rr?sr(t,e):ir(t,e)}var T={};Oe(T,{getAShareCodeList:()=>tn,getAllHKQuotesByCodes:()=>sn,getAllQuotesByCodes:()=>on,getAllUSQuotesByCodes:()=>an,getFullQuotes:()=>xe,getFundCodeList:()=>ln,getFundFlow:()=>Yt,getFundQuotes:()=>Jt,getHKCodeList:()=>rn,getHKQuotes:()=>Me,getPanelLargeOrder:()=>Zt,getSimpleQuotes:()=>Xt,getTodayTimeline:()=>en,getTradingCalendar:()=>un,getUSCodeList:()=>nn,getUSQuotes:()=>Pe,parseFullQuote:()=>_t,parseFundFlow:()=>At,parseFundQuote:()=>Pt,parseHKQuote:()=>xt,parsePanelLargeOrder:()=>It,parseSimpleQuote:()=>bt,parseUSQuote:()=>Mt,search:()=>pn});function _t(t){let e=[];for(let o=0;o<5;o++)e.push({price:y(t[9+o*2]),volume:y(t[10+o*2])});let n=[];for(let o=0;o<5;o++)n.push({price:y(t[19+o*2]),volume:y(t[20+o*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),outerVolume:y(t[7]),innerVolume:y(t[8]),bid:e,ask:n,time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),volume2:y(t[36]),amount:y(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),pb:S(t[46]),limitUp:S(t[47]),limitDown:S(t[48]),volumeRatio:S(t[49]),avgPrice:S(t[51]),peStatic:S(t[52]),peDynamic:S(t[53]),high52w:S(t[67]),low52w:S(t[68]),circulatingShares:S(t[72]),totalShares:S(t[73]),raw:t}}function bt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),change:y(t[4]),changePercent:y(t[5]),volume:y(t[6]),amount:y(t[7]),marketCap:S(t[9]),marketType:t[10]??"",raw:t}}function At(t){return{code:t[0]??"",mainInflow:y(t[1]),mainOutflow:y(t[2]),mainNet:y(t[3]),mainNetRatio:y(t[4]),retailInflow:y(t[5]),retailOutflow:y(t[6]),retailNet:y(t[7]),retailNetRatio:y(t[8]),totalFlow:y(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function It(t){return{buyLargeRatio:y(t[0]),buySmallRatio:y(t[1]),sellLargeRatio:y(t[2]),sellSmallRatio:y(t[3]),raw:t}}function xt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),amount:y(t[37]),lotSize:S(t[40]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),currency:t[t.length-3]??"",raw:t}}function Mt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),amount:y(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),totalMarketCap:S(t[45]),pb:S(t[47]),high52w:S(t[48]),low52w:S(t[49]),raw:t}}function Pt(t){return{code:t[0]??"",name:t[1]??"",nav:y(t[5]),accNav:y(t[6]),change:y(t[7]),navDate:t[8]??"",raw:t}}async function xe(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>_t(o.fields))}async function Xt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>bt(r.fields))}async function Yt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>At(r.fields))}async function Zt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>It(r.fields))}async function Me(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>xt(r.fields))}async function Pe(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Mt(r.fields))}async function Jt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Pt(r.fields))}async function en(t,e){let n=t.getTimeout(),o=new AbortController,r=setTimeout(()=>o.abort(),n);try{let s=await fetch(`${Qe}?code=${e}`,{signal:o.signal});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);let i=await s.json();if(i.code!==0)throw new Error(i.msg||"API error");let a=i.data?.[e];if(!a)return{code:e,date:"",data:[]};let l=a.data?.data||[],u=a.data?.date||"",c=!1;if(l.length>0){let d=l[0].split(" "),f=parseFloat(d[1])||0,h=parseInt(d[2],10)||0,g=parseFloat(d[3])||0;h>0&&f>0&&g/h>f*50&&(c=!0)}let m=l.map(d=>{let f=d.split(" "),h=f[0],g=`${h.slice(0,2)}:${h.slice(2,4)}`,O=parseInt(f[2],10)||0,E=parseFloat(f[3])||0,b=c?O*100:O,k=b>0?E/b:0;return{time:g,price:parseFloat(f[1])||0,volume:b,amount:E,avgPrice:Math.round(k*100)/100}});return{code:e,date:u,data:m}}finally{clearTimeout(r)}}var Lt=null,ar=null,Le=null,lr=null,Ue=null,Ut=null;function ur(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function tn(t,e){let n=!1,o;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,o=e.market),!Lt){let i=(await t.get($e,{responseType:"json"}))?.list||[];Lt=i,ar=i.map(a=>a.replace(/^(sh|sz|bj)/,""))}let r=Lt;return o&&(r=r.filter(s=>ur(s,o))),n?r.map(s=>s.replace(/^(sh|sz|bj)/,"")):r.slice()}var cr={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function nn(t,e){let n=!1,o;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,o=e.market),Le||(Le=(await t.get(Ge,{responseType:"json"}))?.list||[],lr=Le.map(i=>i.replace(/^\d{3}\./,"")));let r=Le.slice();if(o){let s=cr[o];r=r.filter(i=>i.startsWith(s))}return n?r.map(s=>s.replace(/^\d{3}\./,"")):r}async function rn(t){return Ue||(Ue=(await t.get(ze,{responseType:"json"}))?.list||[]),Ue.slice()}async function on(t,e,n={}){let{batchSize:o=ne,concurrency:r=oe,onProgress:s}=n;L(o,"batchSize"),L(r,"concurrency");let i=Math.min(o,re),a=v(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await xe(t,d);return u++,s&&s(u,l),f});return(await H(c,r)).flat()}async function sn(t,e,n={}){let{batchSize:o=ne,concurrency:r=oe,onProgress:s}=n;L(o,"batchSize"),L(r,"concurrency");let i=Math.min(o,re),a=v(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await Me(t,d);return u++,s&&s(u,l),f});return(await H(c,r)).flat()}async function an(t,e,n={}){let{batchSize:o=ne,concurrency:r=oe,onProgress:s}=n;L(o,"batchSize"),L(r,"concurrency");let i=Math.min(o,re),a=v(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await Pe(t,d);return u++,s&&s(u,l),f});return(await H(c,r)).flat()}async function ln(t){if(Ut)return Ut.slice();let o=(await t.get(Ve,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return Ut=o,o.slice()}var V=null;async function un(t){if(V)return V.slice();let e=await t.get(Gt);return!e||e.trim()===""?(V=[],V.slice()):(V=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),V.slice())}var cn="https://smartbox.gtimg.cn/s3/";function pr(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function dr(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let o=n.split("~"),r=o[0]||"",s=o[1]||"",i=pr(o[2]||""),a=o[4]||"";return{code:r+s,name:i,market:r,type:a}})}function mr(t){return new Promise((e,n)=>{let o=`${cn}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=o,r.charset="utf-8",r.onload=()=>{let s=window.v_hint||"";document.body.removeChild(r),e(s)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function fr(t,e){let n=`${cn}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function gr(){return typeof window<"u"&&typeof document<"u"}async function pn(t,e){if(!e||!e.trim())return[];let n;return gr()?n=await mr(e):n=await fr(t,e),dr(n)}var R={};Oe(R,{extractVariety:()=>Ft,getCFFEXOptionQuotes:()=>Mn,getComexInventory:()=>Kn,getConceptConstituents:()=>Rn,getConceptKline:()=>En,getConceptList:()=>kt,getConceptMinuteKline:()=>Tn,getConceptSpot:()=>Sn,getDividendDetail:()=>_n,getFuturesHistoryKline:()=>An,getFuturesInventory:()=>Dn,getFuturesInventorySymbols:()=>Ln,getFuturesMarketCode:()=>Nt,getGlobalFuturesKline:()=>xn,getGlobalFuturesSpot:()=>In,getHKHistoryKline:()=>fn,getHistoryKline:()=>dn,getIndustryConstituents:()=>yn,getIndustryKline:()=>Cn,getIndustryList:()=>Kt,getIndustryMinuteKline:()=>On,getIndustrySpot:()=>hn,getMinuteKline:()=>mn,getOptionLHB:()=>Pn,getUSHistoryKline:()=>gn});async function Dt(t,e,n,o,r=100,s){let i=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(r),fields:o}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(l=d.total??0);let f=d.diff.map((h,g)=>s(h,i.length+g+1));i.push(...f),a++}while(i.length<l);return i}function x(t){let[e,n,o,r,s,i,a,l,u,c,m]=t.split(",");return{date:e,open:C(n),close:C(o),high:C(r),low:C(s),volume:C(i),amount:C(a),amplitude:C(l),changePercent:C(u),change:C(c),turnoverRate:C(m)}}async function M(t,e,n){let o=`${e}?${n.toString()}`,r=await t.get(o,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function dn(t,e,n={}){let{period:o="daily",adjust:r="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(o),U(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Ae(e)}.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:D(r),secid:l,beg:s,end:i}),c=Se,{klines:m}=await M(t,c,u);return m.length===0?[]:m.map(d=>({...x(d),code:a}))}async function mn(t,e,n={}){let{period:o="1",adjust:r="qfq",startDate:s="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;ae(o),U(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Ae(e)}.${a}`;if(o==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:l}),c=`${We}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let f=s.replace("T"," ").slice(0,16),h=i.replace("T"," ").slice(0,16);return d.map(g=>{let[O,E,b,k,W,F,G,zn]=g.split(",");return{time:O,open:C(E),close:C(b),high:C(k),low:C(W),volume:C(F),amount:C(G),avgPrice:C(zn)}}).filter(g=>g.time>=f&&g.time<=h)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:o,fqt:D(r||""),secid:l,beg:"0",end:"20500000"}),c=Se,{klines:m}=await M(t,c,u);if(m.length===0)return[];let d=s.replace("T"," ").slice(0,16),f=i.replace("T"," ").slice(0,16);return m.map(h=>{let g=x(h);return{...g,time:g.date}}).filter(h=>h.time>=d&&h.time<=f)}}async function fn(t,e,n={}){let{period:o="daily",adjust:r="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(o),U(r);let a=e.replace(/^hk/i,"").padStart(5,"0"),l=`116.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:D(r),secid:l,beg:s,end:i,lmt:"1000000"}),c=Xe,{klines:m,name:d}=await M(t,c,u);return m.length===0?[]:m.map(f=>({...x(f),code:a,name:d||""}))}async function gn(t,e,n={}){let{period:o="daily",adjust:r="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(o),U(r);let a=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:D(r),secid:e,beg:s,end:i,lmt:"1000000"}),l=Ye,{klines:u,name:c,code:m}=await M(t,l,a),d=m||e.split(".")[1]||e,f=c||"";return u.length===0?[]:u.map(h=>({...x(h),code:d,name:f}))}function De(t){let e=null;return{async getCode(n,o,r){if(o.startsWith("BK"))return o;if(!e){let i=await r(n);e=new Map(i.map(a=>[a.name,a.code]))}let s=e.get(o);if(!s)throw new Error(`${t.errorPrefix}: ${o}`);return s}}}async function Ke(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},o=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await Dt(t,e.listUrl,n,o,100,(s,i)=>({rank:i,name:String(s.f14??""),code:String(s.f12??""),price:p(s.f2),change:p(s.f4),changePercent:p(s.f3),totalMarketCap:p(s.f20),turnoverRate:p(s.f8),riseCount:p(s.f104),fallCount:p(s.f105),leadingStock:s.f128?String(s.f128):null,leadingStockChangePercent:p(s.f136)}));return r.sort((s,i)=>(i.changePercent??0)-(s.changePercent??0)),r.forEach((s,i)=>{s.rank=i+1}),r}async function ke(t,e,n){let o=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${o.toString()}`,i=(await t.get(r,{responseType:"json"}))?.data;return i?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:u,divide:c})=>{let m=i[l],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:u,value:d}}):[]}async function Fe(t,e,n){let o={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Dt(t,n,o,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(s,i)=>({rank:i,code:String(s.f12??""),name:String(s.f14??""),price:p(s.f2),changePercent:p(s.f3),change:p(s.f4),volume:p(s.f5),amount:p(s.f6),amplitude:p(s.f7),high:p(s.f15),low:p(s.f16),open:p(s.f17),prevClose:p(s.f18),turnoverRate:p(s.f8),pe:p(s.f9),pb:p(s.f23)}))}async function Ne(t,e,n,o={}){let{period:r="daily",adjust:s="",startDate:i="19700101",endDate:a="20500101"}=o;A(r),U(s);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:I(r),fqt:D(s),beg:i,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await M(t,n,l);return u.length===0?[]:u.map(c=>x(c))}async function we(t,e,n,o,r={}){let{period:s="5"}=r;if(ae(s),s==="1"){let i=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${o}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,f,h,g,O,E,b]=c.split(",");return{time:m,open:C(d),close:C(f),high:C(h),low:C(g),volume:C(O),amount:C(E),price:C(b)}})}else{let i=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:s,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,f,h,g,O,E,b,k,W,F]=c.split(",");return{time:m,open:C(d),close:C(f),high:C(h),low:C(g),changePercent:C(k),change:C(W),volume:C(O),amount:C(E),amplitude:C(b),turnoverRate:C(F)}})}}var q={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ze,spotUrl:Je,consUrl:et,klineUrl:tt,trendsUrl:nt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},hr=De(q);async function Be(t,e){return hr.getCode(t,e,Kt)}async function Kt(t){return Ke(t,q)}async function hn(t,e){let n=await Be(t,e);return ke(t,n,q.spotUrl)}async function yn(t,e){let n=await Be(t,e);return Fe(t,n,q.consUrl)}async function Cn(t,e,n={}){let o=await Be(t,e);return Ne(t,o,q.klineUrl,n)}async function On(t,e,n={}){let o=await Be(t,e);return we(t,o,q.klineUrl,q.trendsUrl,n)}var j={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:rt,spotUrl:ot,consUrl:st,klineUrl:it,trendsUrl:at,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},yr=De(j);async function ve(t,e){return yr.getCode(t,e,kt)}async function kt(t){return Ke(t,j)}async function Sn(t,e){let n=await ve(t,e);return ke(t,n,j.spotUrl)}async function Rn(t,e){let n=await ve(t,e);return Fe(t,n,j.consUrl)}async function En(t,e,n={}){let o=await ve(t,e);return Ne(t,o,j.klineUrl,n)}async function Tn(t,e,n={}){let o=await ve(t,e);return we(t,o,j.klineUrl,j.trendsUrl,n)}function Q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Cr(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:Q(t.REPORT_DATE),planNoticeDate:Q(t.PLAN_NOTICE_DATE),disclosureDate:Q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:Q(t.EQUITY_RECORD_DATE),exDividendDate:Q(t.EX_DIVIDEND_DATE),payDate:Q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:Q(t.NOTICE_DATE)}}async function _n(t,e){let n=e.replace(/^(sh|sz|bj)/,""),o=[],r=1,s=1;do{let i=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),a=`${w}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(s=u.pages??1);let c=u.data.map(Cr);o.push(...c),r++}while(r<=s);return o}function Ft(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function bn(t){return z[t]??z[t.toLowerCase()]??z[t.toUpperCase()]}function Nt(t){let e=bn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=bn(t.slice(0,-1))),!e){let o=Object.keys(z).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${o}`)}let n=ut[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function Or(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?C(n[12]):null}}async function An(t,e,n={}){let{period:o="daily",startDate:r="19700101",endDate:s="20500101"}=n;A(o);let i=Ft(e),l=`${Nt(i)}.${e}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:"0",secid:l,beg:r,end:s}),{klines:c,name:m,code:d}=await M(t,Z,u);return c.length===0?[]:c.map(f=>({...Or(f),code:d||e,name:m||""}))}async function In(t,e={}){let n=e.pageSize??20,o=[],r=0,s=0;do{let i=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(r),token:J,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${lt}?${i.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;r===0&&(s=l.total??0);let u=l.list.map(Sr);o.push(...u),r++}while(o.length<s);return o}function Sr(t){return{code:t.dm||"",name:t.name||"",price:C(String(t.p)),change:C(String(t.zde)),changePercent:C(String(t.zdf)),open:C(String(t.o)),high:C(String(t.h)),low:C(String(t.l)),prevSettle:C(String(t.zjsj)),volume:C(String(t.vol)),buyVolume:C(String(t.wp)),sellVolume:C(String(t.np)),openInterest:C(String(t.ccl))}}function Rr(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?C(n[12]):null}}function Er(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function xn(t,e,n={}){let{period:o="daily",startDate:r="19700101",endDate:s="20500101"}=n;A(o);let i=n.marketCode;if(i===void 0){let d=Er(e);if(i=Re[d],i===void 0){let f=Object.keys(Re).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${f}. Or specify marketCode manually via options.`)}}let a=`${i}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:"0",secid:a,beg:r,end:s}),{klines:u,name:c,code:m}=await M(t,Z,l);return u.length===0?[]:u.map(d=>({...Rr(d),code:m||e,name:c||""}))}async function Mn(t,e={}){let{pageSize:n=2e4}=e,o=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:J,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),r=`${ft}?${o.toString()}`,i=(await t.get(r,{responseType:"json"}))?.list;return Array.isArray(i)?i.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:p(a.p),change:p(a.zde),changePercent:p(a.zdf),volume:p(a.vol),amount:p(a.cje),openInterest:p(a.ccl),strikePrice:p(a.xqj),remainDays:p(a.syr),dailyChange:p(a.rz),prevSettle:p(a.zjsj),open:p(a.o)})):[]}async function Pn(t,e,n){let o=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:ht,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),r=`${gt}?${o.toString()}`,i=(await t.get(r,{responseType:"json"}))?.result?.data;if(!Array.isArray(i))return[];function a(l){if(!l)return"";let u=String(l),c=u.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:u}return i.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:p(l.MEMBER_RANK)??0,sellVolume:p(l.SELL_VOLUME),sellVolumeChange:p(l.SELL_VOLUME_CHANGE),netSellVolume:p(l.NET_SELL_VOLUME),sellVolumeRatio:p(l.SELL_VOLUME_RATIO),buyVolume:p(l.BUY_VOLUME),buyVolumeChange:p(l.BUY_VOLUME_CHANGE),netBuyVolume:p(l.NET_BUY_VOLUME),buyVolumeRatio:p(l.BUY_VOLUME_RATIO),sellPosition:p(l.SELL_POSITION),sellPositionChange:p(l.SELL_POSITION_CHANGE),netSellPosition:p(l.NET_SELL_POSITION),sellPositionRatio:p(l.SELL_POSITION_RATIO),buyPosition:p(l.BUY_POSITION),buyPositionChange:p(l.BUY_POSITION_CHANGE),netBuyPosition:p(l.NET_BUY_POSITION),buyPositionRatio:p(l.BUY_POSITION_RATIO)}))}var Tr={gold:"EMI00069026",silver:"EMI00069027"};async function Ln(t){let e=new URLSearchParams({reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageNumber:"1",pageSize:"500",source:"WEB",client:"WEB"}),n=`${w}?${e.toString()}`,r=(await t.get(n,{responseType:"json"}))?.result?.data;return Array.isArray(r)?r.map(s=>({code:String(s.TRADE_CODE??""),name:String(s.TRADE_TYPE??""),marketCode:String(s.TRADE_MARKET_CODE??"")})):[]}function Un(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function Dn(t,e,n={}){let{startDate:o="2020-10-28",pageSize:r=500}=n,s=e.toUpperCase(),i=[],a=1,l=1;do{let u=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${s}")(TRADE_DATE>='${o}')`,pageNumber:String(a),pageSize:String(r),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${w}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(l=d.pages??1);let f=d.data.map(h=>({code:String(h.SECURITY_CODE??e),date:Un(h.TRADE_DATE),inventory:p(h.ON_WARRANT_NUM),change:p(h.ADDCHANGE)}));i.push(...f),a++}while(a<=l);return i}async function Kn(t,e,n={}){let o=Tr[e];if(!o)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:r=500}=n,s=[],i=1,a=1,l={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let u=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(r),pageNumber:String(i),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${o}")(@STORAGE_TON<>"NULL")`}),c=`${w}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;i===1&&(a=d.pages??1);let f=d.data.map(h=>({date:Un(h.REPORT_DATE),name:l[e]??e,storageTon:p(h.STORAGE_TON),storageOunce:p(h.STORAGE_OUNCE)}));s.push(...f),i++}while(i<=a);return s}var P={};Oe(P,{getCommodityOptionKline:()=>Qn,getCommodityOptionSpot:()=>jn,getETFOption5DayMinute:()=>qn,getETFOptionDailyKline:()=>Hn,getETFOptionExpireDay:()=>wn,getETFOptionMinute:()=>vn,getETFOptionMonths:()=>Nn,getIndexOptionKline:()=>Fn,getIndexOptionSpot:()=>kn});function _r(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function br(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function kn(t,e){let n=`${ee}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,o=await _(n),r=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:r.map(_r),puts:s.map(br)}}async function Fn(t){let e=`${te}?symbol=${t}`,n=await _(e,{callbackMode:"path"});return Array.isArray(n)?n.map(o=>({date:o.d,open:p(o.o),high:p(o.h),low:p(o.l),close:p(o.c),volume:p(o.v)})):[]}async function Nn(t){let e=`${ct}?exchange=null&cate=${encodeURIComponent(t)}`,o=(await _(e))?.result?.data,r=o?.contractMonth??[];return{months:r.length>1?r.slice(1):r,stockId:o?.stockId??"",cateId:o?.cateId??"",cateList:o?.cateList??[]}}async function wn(t,e){let n=`${Ee}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,o=await _(n),r=o?.result?.data?.remainderDays;if(typeof r=="number"&&r<0){let i=`${Ee}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;o=await _(i)}let s=o?.result?.data;return{expireDay:s?.expireDay??"",remainderDays:s?.remainderDays??0,stockId:s?.stockId??"",name:s?.other?.name??""}}function Bn(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:p(n.p),volume:p(n.v),openInterest:p(n.t),avgPrice:p(n.a)}))}async function vn(t){let e=`CON_OP_${t}`,n=`${pt}?symbol=${e}`,r=(await _(n))?.result?.data;return Array.isArray(r)?Bn(r):[]}async function Hn(t){let e=`CON_OP_${t}`,n=`${dt}?symbol=${e}`,o=await _(n,{callbackMode:"path"});return Array.isArray(o)?o.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}async function qn(t){let e=`CON_OP_${t}`,n=`${mt}?symbol=${e}`,r=(await _(n))?.result?.data;if(!Array.isArray(r))return[];let s=[];for(let i of r)Array.isArray(i)&&s.push(...Bn(i));return s}function Ar(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Ir(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function jn(t,e){let n=Te[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(Te).join(", ")}`);let o=`${ee}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,r=await _(o),s=r?.result?.data?.up??[],i=r?.result?.data?.down??[];return{calls:s.map(Ar),puts:i.map(Ir)}}async function Qn(t){let e=`${te}?symbol=${t}`,n=await _(e,{callbackMode:"path"});return Array.isArray(n)?n.map(o=>({date:o.d,open:p(o.o),high:p(o.h),low:p(o.l),close:p(o.c),volume:p(o.v)})):[]}function le(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function N(t,e){let n=[];for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}let r=0,s=0;for(let i=o-e+1;i<=o;i++)t[i]!==null&&(r+=t[i],s++);n.push(s===e?le(r/e):null)}return n}function K(t,e){let n=[],o=2/(e+1),r=null,s=!1;for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}if(!s){let l=0,u=0;for(let c=i-e+1;c<=i;c++)t[c]!==null&&(l+=t[c],u++);u===e&&(r=l/e,s=!0),n.push(r!==null?le(r):null);continue}let a=t[i];a===null?n.push(r!==null?le(r):null):(r=o*a+(1-o)*r,n.push(le(r)))}return n}function He(t,e){let n=[],o=Array.from({length:e},(s,i)=>i+1),r=o.reduce((s,i)=>s+i,0);for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let i=0,a=!0;for(let l=0;l<e;l++){let u=t[s-e+1+l];if(u===null){a=!1;break}i+=u*o[l]}n.push(a?le(i/r):null)}return n}function ue(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:o="sma"}=e,r=o==="ema"?K:o==="wma"?He:N,s={};for(let i of n)s[`ma${i}`]=r(t,i);return t.map((i,a)=>{let l={};for(let u of n)l[`ma${u}`]=s[`ma${u}`][a];return l})}function $n(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ce(t,e={}){let{short:n=12,long:o=26,signal:r=9}=e,s=K(t,n),i=K(t,o),a=t.map((u,c)=>s[c]===null||i[c]===null?null:s[c]-i[c]),l=K(a,r);return t.map((u,c)=>({dif:a[c]!==null?$n(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?$n((a[c]-l[c])*2):null}))}function wt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function xr(t,e,n){let o=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){o.push(null);continue}let s=0,i=0;for(let a=r-e+1;a<=r;a++)t[a]!==null&&n[r]!==null&&(s+=Math.pow(t[a]-n[r],2),i++);o.push(i===e?Math.sqrt(s/e):null)}return o}function pe(t,e={}){let{period:n=20,stdDev:o=2}=e,r=N(t,n),s=xr(t,n,r);return t.map((i,a)=>{if(r[a]===null||s[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=r[a]+o*s[a],u=r[a]-o*s[a],c=r[a]!==0?wt((l-u)/r[a]*100):null;return{mid:r[a],upper:wt(l),lower:wt(u),bandwidth:c}})}function Bt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function de(t,e={}){let{period:n=9,kPeriod:o=3,dPeriod:r=3}=e,s=[],i=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){s.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,m=!0;for(let g=l-n+1;g<=l;g++){if(t[g].high===null||t[g].low===null){m=!1;break}u=Math.max(u,t[g].high),c=Math.min(c,t[g].low)}let d=t[l].close;if(!m||d===null||u===c){s.push({k:null,d:null,j:null});continue}let f=(d-c)/(u-c)*100;i=(o-1)/o*i+1/o*f,a=(r-1)/r*a+1/r*i;let h=3*i-2*a;s.push({k:Bt(i),d:Bt(a),j:Bt(h)})}return s}function Mr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function me(t,e={}){let{periods:n=[6,12,24]}=e,o=[null];for(let s=1;s<t.length;s++)t[s]===null||t[s-1]===null?o.push(null):o.push(t[s]-t[s-1]);let r={};for(let s of n){let i=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<s){i.push(null),o[u]!==null&&(o[u]>0?a+=o[u]:l+=Math.abs(o[u]));continue}if(u===s)a=a/s,l=l/s;else{let c=o[u]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(s-1)+m)/s,l=(l*(s-1)+d)/s}if(l===0)i.push(100);else if(a===0)i.push(0);else{let c=a/l;i.push(Mr(100-100/(1+c)))}}r[`rsi${s}`]=i}return t.map((s,i)=>{let a={};for(let l of n)a[`rsi${l}`]=r[`rsi${l}`][i];return a})}function Pr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function fe(t,e={}){let{periods:n=[6,10]}=e,o={};for(let r of n){let s=[];for(let i=0;i<t.length;i++){if(i<r-1){s.push(null);continue}let a=-1/0,l=1/0,u=!0;for(let d=i-r+1;d<=i;d++){if(t[d].high===null||t[d].low===null){u=!1;break}a=Math.max(a,t[d].high),l=Math.min(l,t[d].low)}let c=t[i].close;if(!u||c===null||a===l){s.push(null);continue}let m=(a-c)/(a-l)*100;s.push(Pr(m))}o[`wr${r}`]=s}return t.map((r,s)=>{let i={};for(let a of n)i[`wr${a}`]=o[`wr${a}`][s];return i})}function Lr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ge(t,e={}){let{periods:n=[6,12,24]}=e,o={};for(let r of n){let s=N(t,r),i=[];for(let a=0;a<t.length;a++)if(t[a]===null||s[a]===null||s[a]===0)i.push(null);else{let l=(t[a]-s[a])/s[a]*100;i.push(Lr(l))}o[`bias${r}`]=i}return t.map((r,s)=>{let i={};for(let a of n)i[`bias${a}`]=o[`bias${a}`][s];return i})}function Ur(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function he(t,e={}){let{period:n=14}=e,o=[],r=t.map(s=>s.high===null||s.low===null||s.close===null?null:(s.high+s.low+s.close)/3);for(let s=0;s<t.length;s++){if(s<n-1){o.push({cci:null});continue}let i=0,a=0;for(let m=s-n+1;m<=s;m++)r[m]!==null&&(i+=r[m],a++);if(a!==n||r[s]===null){o.push({cci:null});continue}let l=i/n,u=0;for(let m=s-n+1;m<=s;m++)u+=Math.abs(r[m]-l);let c=u/n;if(c===0)o.push({cci:0});else{let m=(r[s]-l)/(.015*c);o.push({cci:Ur(m)})}}return o}function vt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function $(t,e={}){let{period:n=14}=e,o=[],r=[];for(let i=0;i<t.length;i++){let{high:a,low:l,close:u}=t[i];if(a===null||l===null||u===null){r.push(null);continue}if(i===0)r.push(a-l);else{let c=t[i-1].close;if(c===null)r.push(a-l);else{let m=a-l,d=Math.abs(a-c),f=Math.abs(l-c);r.push(Math.max(m,d,f))}}}let s=null;for(let i=0;i<t.length;i++){if(i<n-1){o.push({tr:r[i]!==null?vt(r[i]):null,atr:null});continue}if(i===n-1){let a=0,l=0;for(let u=0;u<n;u++)r[u]!==null&&(a+=r[u],l++);l===n&&(s=a/n)}else s!==null&&r[i]!==null&&(s=(s*(n-1)+r[i])/n);o.push({tr:r[i]!==null?vt(r[i]):null,atr:s!==null?vt(s):null})}return o}function Ht(t,e={}){let{maPeriod:n}=e,o=[];if(t.length===0)return o;let r=t[0].volume??0;o.push({obv:r,obvMa:null});for(let s=1;s<t.length;s++){let i=t[s],a=t[s-1];if(i.close===null||a.close===null||i.volume===null||i.volume===void 0){o.push({obv:null,obvMa:null});continue}i.close>a.close?r+=i.volume:i.close<a.close&&(r-=i.volume),o.push({obv:r,obvMa:null})}if(n&&n>0)for(let s=n-1;s<o.length;s++){let i=0,a=0;for(let l=s-n+1;l<=s;l++)o[l].obv!==null&&(i+=o[l].obv,a++);a===n&&(o[s].obvMa=i/n)}return o}function qt(t,e={}){let{period:n=12,signalPeriod:o}=e,r=[];for(let s=0;s<t.length;s++){if(s<n){r.push({roc:null,signal:null});continue}let i=t[s].close,a=t[s-n].close;if(i===null||a===null||a===0){r.push({roc:null,signal:null});continue}let l=(i-a)/a*100;r.push({roc:l,signal:null})}if(o&&o>0)for(let s=n+o-1;s<r.length;s++){let i=0,a=0;for(let l=s-o+1;l<=s;l++)r[l].roc!==null&&(i+=r[l].roc,a++);a===o&&(r[s].signal=i/o)}return r}function jt(t,e={}){let{period:n=14,adxPeriod:o=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let s=[],i=[],a=[];for(let g=0;g<t.length;g++){if(g===0){s.push(0),i.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=t[g],E=t[g-1];if(O.high===null||O.low===null||O.close===null||E.high===null||E.low===null||E.close===null){s.push(0),i.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let b=O.high-O.low,k=Math.abs(O.high-E.close),W=Math.abs(O.low-E.close);a.push(Math.max(b,k,W));let F=O.high-E.high,G=E.low-O.low;F>G&&F>0?s.push(F):s.push(0),G>F&&G>0?i.push(G):i.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,u=0,c=0,m=[];for(let g=1;g<t.length;g++){if(g<n){l+=a[g],u+=s[g],c+=i[g],m.push(0);continue}g===n?(l=l,u=u,c=c):(l=l-l/n+a[g],u=u-u/n+s[g],c=c-c/n+i[g]);let O=l>0?u/l*100:0,E=l>0?c/l*100:0;r[g].pdi=O,r[g].mdi=E;let b=O+E,k=b>0?Math.abs(O-E)/b*100:0;m.push(k)}let d=0,f=0,h=0;for(let g=n;g<t.length;g++){if(g<n*2-1){d+=m[g-n+1]||0,f++;continue}if(g===n*2-1)d+=m[g-n+1]||0,h=d/o,r[g].adx=h;else{let O=m[g-n+1]||0;h=(h*(o-1)+O)/o,r[g].adx=h}}for(let g=n*2-1+o;g<t.length;g++){let O=r[g].adx,E=r[g-o]?.adx;O!==null&&E!==null&&(r[g].adxr=(O+E)/2)}return r}function Qt(t,e={}){let{afStart:n=.02,afIncrement:o=.02,afMax:r=.2}=e,s=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=1,a=n,l=t[0].high??0,u=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(i=-1,l=c.low??0,u=c.high??0),s.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let f=t[d],h=t[d-1];if(f.high===null||f.low===null||h.high===null||h.low===null){s.push({sar:null,trend:null,ep:null,af:null});continue}let g=u+a*(l-u);i===1?(g=Math.min(g,h.low,t[Math.max(0,d-2)]?.low??h.low),f.low<g?(i=-1,g=l,l=f.low,a=n):f.high>l&&(l=f.high,a=Math.min(a+o,r))):(g=Math.max(g,h.high,t[Math.max(0,d-2)]?.high??h.high),f.high>g?(i=1,g=l,l=f.high,a=n):f.low<l&&(l=f.low,a=Math.min(a+o,r))),u=g,s.push({sar:u,trend:i,ep:l,af:a})}return s}function $t(t,e={}){let{emaPeriod:n=20,atrPeriod:o=10,multiplier:r=2}=e,s=[],i=t.map(u=>u.close),a=K(i,n),l=$(t,{period:o});for(let u=0;u<t.length;u++){let c=a[u],m=l[u]?.atr;if(c===null||m===null){s.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*m,f=c-r*m,h=c>0?(d-f)/c*100:null;s.push({mid:c,upper:d,lower:f,width:h})}return s}function ye(t,e={}){if(t.length===0)return[];let n=t.map(f=>f.close),o=t.map(f=>({open:f.open,high:f.high,low:f.low,close:f.close,volume:f.volume})),r=e.ma?ue(n,typeof e.ma=="object"?e.ma:{}):null,s=e.macd?ce(n,typeof e.macd=="object"?e.macd:{}):null,i=e.boll?pe(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?de(o,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?me(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?fe(o,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?ge(n,typeof e.bias=="object"?e.bias:{}):null,m=e.cci?he(o,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?$(o,typeof e.atr=="object"?e.atr:{}):null;return t.map((f,h)=>({...f,...r&&{ma:r[h]},...s&&{macd:s[h]},...i&&{boll:i[h]},...a&&{kdj:a[h]},...l&&{rsi:l[h]},...u&&{wr:u[h]},...c&&{bias:c[h]},...m&&{cci:m[h]},...d&&{atr:d[h]}}))}var Ce=class{constructor(e={}){this.client=new ie(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return R.getIndustryList(this.client)}getIndustrySpot(e){return R.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return R.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return R.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return R.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return R.getConceptList(this.client)}getConceptSpot(e){return R.getConceptSpot(this.client,e)}getConceptConstituents(e){return R.getConceptConstituents(this.client,e)}getConceptKline(e,n){return R.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return R.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return R.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return R.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return R.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return R.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}getFundCodeList(){return T.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...o}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,o)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...o}=e,r=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,r,o)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return R.getDividendDetail(this.client,e)}getFuturesKline(e,n){return R.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return R.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return R.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return R.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return R.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return R.getComexInventory(this.client,e,n)}getIndexOptionSpot(e,n){return P.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return P.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return R.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return P.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return P.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return P.getETFOptionMinute(e)}getETFOptionDailyKline(e){return P.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return P.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return P.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return P.getCommodityOptionKline(e)}getOptionLHB(e,n){return R.getOptionLHB(this.client,e,n)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,o=!1;if(e.ma){let s=typeof e.ma=="object"?e.ma:{},i=s.periods??[5,10,20,30,60,120,250],a=s.type??"sma";n=Math.max(n,this.safeMax(i,20)),a==="ema"&&(o=!0)}if(e.macd){let s=typeof e.macd=="object"?e.macd:{},i=s.long??26,a=s.signal??9;n=Math.max(n,i*3+a),o=!0}if(e.boll){let s=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,s)}if(e.kdj){let s=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,s)}if(e.rsi){let s=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(s,14)+1)}if(e.wr){let s=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(s,10))}if(e.bias){let s=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(s,12))}if(e.cci){let s=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,s)}if(e.atr){let s=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,s)}return Math.ceil(n*(o?1.5:1.2))}calcActualStartDate(e,n,o=1.5){let r=Math.ceil(n*o),s=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));s.setDate(s.getDate()-r);let i=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${i}${a}${l}`}calcActualStartDateByCalendar(e,n,o){if(!o||o.length===0)return;let r=this.normalizeDate(e),s=o.findIndex(a=>a>=r);s===-1&&(s=o.length-1);let i=Math.max(0,s-n);return this.toCompactDate(o[i])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:o,endDate:r,indicators:s={}}=n,i=n.market??this.detectMarket(e),a=this.calcRequiredLookback(s),l={A:1.5,HK:1.46,US:1.45},u;if(o)if(i==="A")try{let f=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(o,a,f)??this.calcActualStartDate(o,a,l[i])}catch{u=this.calcActualStartDate(o,a,l[i])}else u=this.calcActualStartDate(o,a,l[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},m;switch(i){case"HK":m=await this.getHKHistoryKline(e,c);break;case"US":m=await this.getUSHistoryKline(e,c);break;default:m=await this.getHistoryKline(e,c)}if(o&&m.length<a)switch(i){case"HK":m=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=ye(m,s);if(o){let f=this.dateToTimestamp(o),h=r?this.dateToTimestamp(r):1/0;return d.filter(g=>{let O=this.dateToTimestamp(g.date);return O>=f&&O<=h})}return d}},Gn=Ce;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,extractJsonFromJsonp,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});
|
|
1
|
+
"use strict";var He=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Xn=Object.prototype.hasOwnProperty;var _e=(t,e)=>{for(var n in e)He(t,n,{get:e[n],enumerable:!0})},Yn=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wn(e))!Xn.call(t,r)&&r!==n&&He(t,r,{get:()=>e[r],enumerable:!(i=Vn(e,r))||i.enumerable});return t};var Zn=t=>Yn(He({},"__esModule",{value:!0}),t);var kr={};_e(kr,{HttpError:()=>v,StockSDK:()=>Ee,addIndicators:()=>Te,asyncPool:()=>H,calcATR:()=>j,calcBIAS:()=>ge,calcBOLL:()=>pe,calcCCI:()=>he,calcDMI:()=>Ce,calcEMA:()=>U,calcKC:()=>Oe,calcKDJ:()=>de,calcMA:()=>ue,calcMACD:()=>ce,calcOBV:()=>ye,calcROC:()=>Re,calcRSI:()=>me,calcSAR:()=>Se,calcSMA:()=>B,calcWMA:()=>we,calcWR:()=>fe,chunkArray:()=>w,decodeGBK:()=>V,default:()=>Gn,extractJsonFromJsonp:()=>Ke,jsonpRequest:()=>P,parseResponse:()=>W,safeNumber:()=>h,safeNumberOrNull:()=>S});module.exports=Zn(kr);function V(t){return new TextDecoder("gbk").decode(t)}function W(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let r=i.indexOf("=");if(r<0)continue;let o=i.slice(0,r).trim();o.startsWith("v_")&&(o=o.slice(2));let s=i.slice(r+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");n.push({key:o,fields:a})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function S(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function R(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:R(String(t))}var qe="https://qt.gtimg.cn",je="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Qe="https://assets.linkdiary.cn/shares/zh_a_list.json",$e="https://assets.linkdiary.cn/shares/us_list.json",Ge="https://assets.linkdiary.cn/shares/hk_list.json",ze="https://assets.linkdiary.cn/shares/fund_list",Ft="https://assets.linkdiary.cn/shares/trade-data-list.txt";var be="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ve="https://push2his.eastmoney.com/api/qt/stock/trends2/get",We="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Xe="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ye="https://17.push2.eastmoney.com/api/qt/clist/get",Ze="https://91.push2.eastmoney.com/api/qt/stock/get",Je="https://29.push2.eastmoney.com/api/qt/clist/get",et="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",tt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",nt="https://79.push2.eastmoney.com/api/qt/clist/get",rt="https://91.push2.eastmoney.com/api/qt/stock/get",ot="https://29.push2.eastmoney.com/api/qt/clist/get",it="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",st="https://push2his.eastmoney.com/api/qt/stock/trends2/get",F="https://datacenter-web.eastmoney.com/api/data/v1/get",X="https://push2his.eastmoney.com/api/qt/stock/kline/get",at="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",Y="58b2fa8f54638b60b87d69b31969089c",lt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},$={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},Pe={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},Z="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",J="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",ut="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",Ae="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",ct="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",pt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",dt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",mt="https://futsseapi.eastmoney.com/list/option/221",ft="https://datacenter-web.eastmoney.com/api/data/get",gt="b2884a393a59ad64002292a3e90d46a5";var Ie={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},ht=3e4,ee=500,te=500,ne=7,yt=3,Rt=1e3,Ct=3e4,St=2,Ot=[408,429,500,502,503,504];var Me=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var vt=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Tt=0;function Jn(){return typeof window<"u"&&typeof window.document<"u"}function wt(){if(Jn())return;let t=vt[Tt];return Tt=(Tt+1)%vt.length,t}var re=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},xe=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new re;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var v=class extends Error{constructor(n,i,r,o){let s=i?` ${i}`:"",a=r?`, url: ${r}`:"",l=o?`, provider: ${o}`:"";super(`HTTP error! status: ${n}${s}${a}${l}`);this.status=n;this.statusText=i;this.url=r;this.provider=o;this.name="HttpError"}},oe=class{constructor(e={}){this.baseUrl=e.baseUrl??qe;let n={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=this.resolveProviderPolicy(n),this.providerPolicies={},this.runtimeStates=new Map;for(let[i,r]of Object.entries(e.providerPolicies??{})){let o=this.mergeProviderPolicy(n,r);this.providerPolicies[i]=this.resolveProviderPolicy(o)}}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??yt,baseDelay:e?.baseDelay??Rt,maxDelay:e?.maxDelay??Ct,backoffMultiplier:e?.backoffMultiplier??St,retryableStatusCodes:e?.retryableStatusCodes??Ot,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}normalizeHeaders(e,n){let i={...e??{}};return n&&(Object.keys(i).some(o=>o.toLowerCase()==="user-agent")||(i["User-Agent"]=n)),i}mergeProviderPolicy(e,n){return n?{timeout:n.timeout??e.timeout,retry:n.retry?{...e.retry??{},...n.retry}:e.retry?{...e.retry}:void 0,headers:{...e.headers??{},...n.headers??{}},userAgent:n.userAgent??e.userAgent,rateLimit:n.rateLimit?{...e.rateLimit??{},...n.rateLimit}:e.rateLimit?{...e.rateLimit}:void 0,rotateUserAgent:n.rotateUserAgent??e.rotateUserAgent,circuitBreaker:n.circuitBreaker?{...e.circuitBreaker??{},...n.circuitBreaker}:e.circuitBreaker?{...e.circuitBreaker}:void 0}:{...e,headers:{...e.headers??{}},retry:e.retry?{...e.retry}:void 0,rateLimit:e.rateLimit?{...e.rateLimit}:void 0,circuitBreaker:e.circuitBreaker?{...e.circuitBreaker}:void 0}}resolveProviderPolicy(e={}){return{timeout:e.timeout??ht,retry:this.resolveRetryOptions(e.retry),headers:this.normalizeHeaders(e.headers,e.userAgent),rotateUserAgent:e.rotateUserAgent??!1,rateLimit:e.rateLimit?{...e.rateLimit}:void 0,circuitBreaker:e.circuitBreaker?{...e.circuitBreaker}:void 0}}getProviderState(e){let n=this.runtimeStates.get(e);if(n)return n;let i=this.providerPolicies[e]??this.defaultPolicy,r={policy:i,rateLimiter:i.rateLimit?new Me(i.rateLimit):null,circuitBreaker:i.circuitBreaker?new xe(i.circuitBreaker):null};return this.runtimeStates.set(e,r),r}inferProvider(e,n){if(n)return n;try{let i=new URL(e).hostname;if(i.includes("eastmoney.com"))return"eastmoney";if(i.includes("gtimg.cn"))return"tencent";if(i.includes("sina.com.cn"))return"sina";if(i.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}getTimeout(){return this.defaultPolicy.timeout}calculateDelay(e,n){return Math.min(n.baseDelay*Math.pow(n.backoffMultiplier,e),n.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n,i){return n>=i.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?i.retryOnTimeout:e instanceof TypeError?i.retryOnNetworkError:e instanceof v?i.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n,i,r=0){try{let o=await e();return n.circuitBreaker?.recordSuccess(),o}catch(o){if(this.shouldRetry(o,r,n.policy.retry)){let s=this.calculateDelay(r,n.policy.retry);return n.policy.retry.onRetry&&o instanceof Error&&n.policy.retry.onRetry(r+1,o,s),await this.sleep(s),this.executeWithRetry(e,n,i,r+1)}throw n.circuitBreaker?.recordFailure(),o instanceof Error&&(o.provider=i),o}}async get(e,n={}){let i=this.inferProvider(e,n.provider),r=this.getProviderState(i);if(r.circuitBreaker&&!r.circuitBreaker.canRequest())throw new re("Circuit breaker is OPEN, request rejected");return r.rateLimiter&&await r.rateLimiter.acquire(),this.executeWithRetry(async()=>{let o=new AbortController,s=setTimeout(()=>o.abort(),r.policy.timeout),a={...r.policy.headers};if(r.policy.rotateUserAgent){let l=wt();l&&(a["User-Agent"]=l)}try{let l=await fetch(e,{signal:o.signal,headers:a});if(!l.ok)throw new v(l.status,l.statusText,e,i);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=i),l}finally{clearTimeout(s)}},r,i)}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer",provider:"tencent"}),r=V(i);return W(r)}};var er=new Set(["daily","weekly","monthly"]),tr=new Set(["1","5","15","30","60"]),nr=new Set(["","qfq","hfq"]);function K(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function I(t){if(!er.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function ie(t){if(!tr.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function k(t){if(!nr.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function w(t,e){K(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function H(t,e,n=!1){if(K(e,"concurrency"),t.length===0)return[];let i=n?new Array(t.length):[],r=0,o=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let s=r++;if(s>=t.length)return;let a=await t[s]();n?i[s]=a:i.push(a)}});return await Promise.all(o),i}function Le(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function M(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function N(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var rr=typeof document<"u"&&typeof window<"u",or=0;function Ht(){return`__stock_sdk_jsonp_${Date.now()}_${or++}`}function Ke(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let i=e.indexOf("(");if(i===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let r=e.lastIndexOf(")");if(r===-1||r<=i)throw new Error("Invalid JSONP response: no closing parenthesis found");let o=e.slice(i+1,r);return JSON.parse(o)}function ir(t,e){let{timeout:n=15e3,callbackParam:i="callback",callbackMode:r="query"}=e;return new Promise((o,s)=>{let a=Ht(),l;if(r==="path")l=t.replace("{callback}",a);else{let y=t.includes("?")?"&":"?";l=`${t}${y}${i}=${a}`}let u=document.createElement("script"),c=!1,m=window,d=()=>{u.parentNode&&u.parentNode.removeChild(u),delete m[a]},g=setTimeout(()=>{c||(c=!0,d(),s(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);m[a]=y=>{c||(c=!0,clearTimeout(g),d(),o(y))},u.onerror=()=>{c||(c=!0,clearTimeout(g),d(),s(new Error(`JSONP script load failed: ${t}`)))},u.src=l,document.head.appendChild(u)})}async function sr(t,e){let{timeout:n=15e3,callbackParam:i="callback",callbackMode:r="query"}=e,o=Ht(),s;if(r==="path")s=t.replace("{callback}",o);else{let u=t.includes("?")?"&":"?";s=`${t}${u}${i}=${o}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let u=await fetch(s,{signal:a.signal});if(!u.ok)throw new Error(`JSONP fetch failed with status ${u.status}: ${t}`);let c=await u.text();return Ke(c)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):u}finally{clearTimeout(l)}}function P(t,e={}){return rr?ir(t,e):sr(t,e)}var b={};_e(b,{getAShareCodeList:()=>zt,getAllHKQuotesByCodes:()=>Yt,getAllQuotesByCodes:()=>Xt,getAllUSQuotesByCodes:()=>Zt,getFullQuotes:()=>Ue,getFundCodeList:()=>Jt,getFundFlow:()=>jt,getFundQuotes:()=>$t,getHKCodeList:()=>Wt,getHKQuotes:()=>De,getPanelLargeOrder:()=>Qt,getSimpleQuotes:()=>qt,getTodayTimeline:()=>Gt,getTradingCalendar:()=>en,getUSCodeList:()=>Vt,getUSQuotes:()=>ke,parseFullQuote:()=>Et,parseFundFlow:()=>bt,parseFundQuote:()=>Mt,parseHKQuote:()=>At,parsePanelLargeOrder:()=>Pt,parseSimpleQuote:()=>_t,parseUSQuote:()=>It,search:()=>nn});function Et(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),pb:S(t[46]),limitUp:S(t[47]),limitDown:S(t[48]),volumeRatio:S(t[49]),avgPrice:S(t[51]),peStatic:S(t[52]),peDynamic:S(t[53]),high52w:S(t[67]),low52w:S(t[68]),circulatingShares:S(t[72]),totalShares:S(t[73]),raw:t}}function _t(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:S(t[9]),marketType:t[10]??"",raw:t}}function bt(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function Pt(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function At(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:S(t[40]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),currency:t[t.length-3]??"",raw:t}}function It(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),totalMarketCap:S(t[45]),pb:S(t[47]),high52w:S(t[48]),low52w:S(t[49]),raw:t}}function Mt(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function Ue(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>Et(i.fields))}async function qt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>_t(r.fields))}async function jt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>bt(r.fields))}async function Qt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Pt(r.fields))}async function De(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>At(r.fields))}async function ke(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>It(r.fields))}async function $t(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Mt(r.fields))}async function Gt(t,e){let n=t.getTimeout(),i=new AbortController,r=setTimeout(()=>i.abort(),n);try{let o=await fetch(`${je}?code=${e}`,{signal:i.signal});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(s.code!==0)throw new Error(s.msg||"API error");let a=s.data?.[e];if(!a)return{code:e,date:"",data:[]};let l=a.data?.data||[],u=a.data?.date||"",c=!1;if(l.length>0){let d=l[0].split(" "),g=parseFloat(d[1])||0,y=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;y>0&&g>0&&f/y>g*50&&(c=!0)}let m=l.map(d=>{let g=d.split(" "),y=g[0],f=`${y.slice(0,2)}:${y.slice(2,4)}`,C=parseInt(g[2],10)||0,O=parseFloat(g[3])||0,E=c?C*100:C,_=E>0?O/E:0;return{time:f,price:parseFloat(g[1])||0,volume:E,amount:O,avgPrice:Math.round(_*100)/100}});return{code:e,date:u,data:m}}finally{clearTimeout(r)}}var xt=null,ar=null,Ne=null,lr=null,Be=null,Lt=null;function ur(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function zt(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!xt){let s=(await t.get(Qe,{responseType:"json"}))?.list||[];xt=s,ar=s.map(a=>a.replace(/^(sh|sz|bj)/,""))}let r=xt;return i&&(r=r.filter(o=>ur(o,i))),n?r.map(o=>o.replace(/^(sh|sz|bj)/,"")):r.slice()}var cr={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Vt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),Ne||(Ne=(await t.get($e,{responseType:"json"}))?.list||[],lr=Ne.map(s=>s.replace(/^\d{3}\./,"")));let r=Ne.slice();if(i){let o=cr[i];r=r.filter(s=>s.startsWith(o))}return n?r.map(o=>o.replace(/^\d{3}\./,"")):r}async function Wt(t){return Be||(Be=(await t.get(Ge,{responseType:"json"}))?.list||[]),Be.slice()}async function Xt(t,e,n={}){let{batchSize:i=ee,concurrency:r=ne,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,te),a=w(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await Ue(t,d);return u++,o&&o(u,l),g});return(await H(c,r,!0)).flat()}async function Yt(t,e,n={}){let{batchSize:i=ee,concurrency:r=ne,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,te),a=w(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await De(t,d);return u++,o&&o(u,l),g});return(await H(c,r,!0)).flat()}async function Zt(t,e,n={}){let{batchSize:i=ee,concurrency:r=ne,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,te),a=w(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await ke(t,d);return u++,o&&o(u,l),g});return(await H(c,r,!0)).flat()}async function Jt(t){if(Lt)return Lt.slice();let i=(await t.get(ze,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return Lt=i,i.slice()}var G=null;async function en(t){if(G)return G.slice();let e=await t.get(Ft);return!e||e.trim()===""?(G=[],G.slice()):(G=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),G.slice())}var tn="https://smartbox.gtimg.cn/s3/";function pr(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function dr(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),r=i[0]||"",o=i[1]||"",s=pr(i[2]||""),a=i[4]||"";return{code:r+o,name:s,market:r,type:a}})}function mr(t){return new Promise((e,n)=>{let i=`${tn}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=i,r.charset="utf-8",r.onload=()=>{let o=window.v_hint||"";document.body.removeChild(r),e(o)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function fr(t,e){let n=`${tn}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function gr(){return typeof window<"u"&&typeof document<"u"}async function nn(t,e){if(!e||!e.trim())return[];let n;return gr()?n=await mr(e):n=await fr(t,e),dr(n)}var T={};_e(T,{extractVariety:()=>Ut,getCFFEXOptionQuotes:()=>Mn,getComexInventory:()=>Dn,getConceptConstituents:()=>On,getConceptKline:()=>Tn,getConceptList:()=>Cn,getConceptMinuteKline:()=>En,getConceptSpot:()=>Sn,getDividendDetail:()=>_n,getFuturesHistoryKline:()=>Pn,getFuturesInventory:()=>Un,getFuturesInventorySymbols:()=>Ln,getFuturesMarketCode:()=>Dt,getGlobalFuturesKline:()=>In,getGlobalFuturesSpot:()=>An,getHKHistoryKline:()=>sn,getHistoryKline:()=>rn,getIndustryConstituents:()=>hn,getIndustryKline:()=>yn,getIndustryList:()=>fn,getIndustryMinuteKline:()=>Rn,getIndustrySpot:()=>gn,getMinuteKline:()=>on,getOptionLHB:()=>xn,getUSHistoryKline:()=>an});async function Kt(t,e,n,i,r=100,o){let s=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(r),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(l=d.total??0);let g=d.diff.map((y,f)=>o(y,s.length+f+1));s.push(...g),a++}while(s.length<l);return s}function x(t){let[e,n,i,r,o,s,a,l,u,c,m]=t.split(",");return{date:e,open:R(n),close:R(i),high:R(r),low:R(o),volume:R(s),amount:R(a),amplitude:R(l),changePercent:R(u),change:R(c),turnoverRate:R(m)}}async function L(t,e,n){let i=`${e}?${n.toString()}`,r=await t.get(i,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function rn(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:o="19700101",endDate:s="20500101"}=n;I(i),k(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Le(e)}.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:N(r),secid:l,beg:o,end:s}),c=be,{klines:m}=await L(t,c,u);return m.length===0?[]:m.map(d=>({...x(d),code:a}))}async function on(t,e,n={}){let{period:i="1",adjust:r="qfq",startDate:o="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=n;ie(i),k(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Le(e)}.${a}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:l}),c=`${Ve}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let g=o.replace("T"," ").slice(0,16),y=s.replace("T"," ").slice(0,16);return d.map(f=>{let[C,O,E,_,z,D,Q,zn]=f.split(",");return{time:C,open:R(O),close:R(E),high:R(_),low:R(z),volume:R(D),amount:R(Q),avgPrice:R(zn)}}).filter(f=>f.time>=g&&f.time<=y)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:N(r||""),secid:l,beg:"0",end:"20500000"}),c=be,{klines:m}=await L(t,c,u);if(m.length===0)return[];let d=o.replace("T"," ").slice(0,16),g=s.replace("T"," ").slice(0,16);return m.map(y=>{let f=x(y);return{...f,time:f.date}}).filter(y=>y.time>=d&&y.time<=g)}}function Fe(t){return async function(n,i,r={}){let{period:o="daily",adjust:s="qfq",startDate:a="19700101",endDate:l="20500101"}=r;I(o),k(s);let u=t.normalizeSymbol(i),c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(o),fqt:N(s),secid:u.secid,beg:a,end:l,lmt:"1000000"}),{klines:m,name:d,code:g}=await L(n,t.url,c);if(m.length===0)return[];let y=t.resolveResultMeta?t.resolveResultMeta(i,u,{code:g,name:d}):{code:g||u.fallbackCode,name:d||""};return m.map(f=>({...x(f),code:y.code,name:y.name}))}}var hr=Fe({url:We,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function sn(t,e,n={}){return hr(t,e,n)}var yr=Fe({url:Xe,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:n.code||e.fallbackCode,name:n.name||""})});async function an(t,e,n={}){return yr(t,e,n)}function ln(t){let e=null;return{async getCode(n,i,r){if(i.startsWith("BK"))return i;if(!e){let s=await r(n);e=new Map(s.map(a=>[a.name,a.code]))}let o=e.get(i);if(!o)throw new Error(`${t.errorPrefix}: ${i}`);return o}}}async function un(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await Kt(t,e.listUrl,n,i,100,(o,s)=>({rank:s,name:String(o.f14??""),code:String(o.f12??""),price:p(o.f2),change:p(o.f4),changePercent:p(o.f3),totalMarketCap:p(o.f20),turnoverRate:p(o.f8),riseCount:p(o.f104),fallCount:p(o.f105),leadingStock:o.f128?String(o.f128):null,leadingStockChangePercent:p(o.f136)}));return r.sort((o,s)=>(s.changePercent??0)-(o.changePercent??0)),r.forEach((o,s)=>{o.rank=s+1}),r}async function cn(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.data;return s?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:u,divide:c})=>{let m=s[l],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:u,value:d}}):[]}async function pn(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Kt(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(o,s)=>({rank:s,code:String(o.f12??""),name:String(o.f14??""),price:p(o.f2),changePercent:p(o.f3),change:p(o.f4),volume:p(o.f5),amount:p(o.f6),amplitude:p(o.f7),high:p(o.f15),low:p(o.f16),open:p(o.f17),prevClose:p(o.f18),turnoverRate:p(o.f8),pe:p(o.f9),pb:p(o.f23)}))}async function dn(t,e,n,i={}){let{period:r="daily",adjust:o="",startDate:s="19700101",endDate:a="20500101"}=i;I(r),k(o);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:M(r),fqt:N(o),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await L(t,n,l);return u.length===0?[]:u.map(c=>x(c))}async function mn(t,e,n,i,r={}){let{period:o="5"}=r;if(ie(o),o==="1"){let s=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${i}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,g,y,f,C,O,E]=c.split(",");return{time:m,open:R(d),close:R(g),high:R(y),low:R(f),volume:R(C),amount:R(O),price:R(E)}})}else{let s=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:o,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,g,y,f,C,O,E,_,z,D]=c.split(",");return{time:m,open:R(d),close:R(g),high:R(y),low:R(f),changePercent:R(_),change:R(z),volume:R(C),amount:R(O),amplitude:R(E),turnoverRate:R(D)}})}}function ve(t){let e=ln(t);async function n(r){return un(r,t)}async function i(r,o){return e.getCode(r,o,n)}return{async getList(r){return n(r)},async getSpot(r,o){let s=await i(r,o);return cn(r,s,t.spotUrl)},async getConstituents(r,o){let s=await i(r,o);return pn(r,s,t.consUrl)},async getKline(r,o,s={}){let a=await i(r,o);return dn(r,a,t.klineUrl,s)},async getMinuteKline(r,o,s={}){let a=await i(r,o);return mn(r,a,t.klineUrl,t.trendsUrl,s)}}}var Rr={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ye,spotUrl:Ze,consUrl:Je,klineUrl:et,trendsUrl:tt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},se=ve(Rr);async function fn(t){return se.getList(t)}async function gn(t,e){return se.getSpot(t,e)}async function hn(t,e){return se.getConstituents(t,e)}async function yn(t,e,n={}){return se.getKline(t,e,n)}async function Rn(t,e,n={}){return se.getMinuteKline(t,e,n)}var Cr={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:nt,spotUrl:rt,consUrl:ot,klineUrl:it,trendsUrl:st,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ae=ve(Cr);async function Cn(t){return ae.getList(t)}async function Sn(t,e){return ae.getSpot(t,e)}async function On(t,e){return ae.getConstituents(t,e)}async function Tn(t,e,n={}){return ae.getKline(t,e,n)}async function En(t,e,n={}){return ae.getMinuteKline(t,e,n)}function q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Sr(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:q(t.REPORT_DATE),planNoticeDate:q(t.PLAN_NOTICE_DATE),disclosureDate:q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:q(t.EQUITY_RECORD_DATE),exDividendDate:q(t.EX_DIVIDEND_DATE),payDate:q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:q(t.NOTICE_DATE)}}async function _n(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],r=1,o=1;do{let s=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),a=`${F}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(o=u.pages??1);let c=u.data.map(Sr);i.push(...c),r++}while(r<=o);return i}function Ut(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function bn(t){return $[t]??$[t.toLowerCase()]??$[t.toUpperCase()]}function Dt(t){let e=bn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=bn(t.slice(0,-1))),!e){let i=Object.keys($).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${i}`)}let n=lt[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function Or(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?R(n[12]):null}}async function Pn(t,e,n={}){let{period:i="daily",startDate:r="19700101",endDate:o="20500101"}=n;I(i);let s=Ut(e),l=`${Dt(s)}.${e}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:"0",secid:l,beg:r,end:o}),{klines:c,name:m,code:d}=await L(t,X,u);return c.length===0?[]:c.map(g=>({...Or(g),code:d||e,name:m||""}))}async function An(t,e={}){let n=e.pageSize??20,i=[],r=0,o=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(r),token:Y,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${at}?${s.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;r===0&&(o=l.total??0);let u=l.list.map(Tr);i.push(...u),r++}while(i.length<o);return i}function Tr(t){return{code:t.dm||"",name:t.name||"",price:R(String(t.p)),change:R(String(t.zde)),changePercent:R(String(t.zdf)),open:R(String(t.o)),high:R(String(t.h)),low:R(String(t.l)),prevSettle:R(String(t.zjsj)),volume:R(String(t.vol)),buyVolume:R(String(t.wp)),sellVolume:R(String(t.np)),openInterest:R(String(t.ccl))}}function Er(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?R(n[12]):null}}function _r(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function In(t,e,n={}){let{period:i="daily",startDate:r="19700101",endDate:o="20500101"}=n;I(i);let s=n.marketCode;if(s===void 0){let d=_r(e);if(s=Pe[d],s===void 0){let g=Object.keys(Pe).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${g}. Or specify marketCode manually via options.`)}}let a=`${s}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:"0",secid:a,beg:r,end:o}),{klines:u,name:c,code:m}=await L(t,X,l);return u.length===0?[]:u.map(d=>({...Er(d),code:m||e,name:c||""}))}async function Mn(t,e={}){let{pageSize:n=2e4}=e,i=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:Y,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),r=`${mt}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.list;return Array.isArray(s)?s.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:p(a.p),change:p(a.zde),changePercent:p(a.zdf),volume:p(a.vol),amount:p(a.cje),openInterest:p(a.ccl),strikePrice:p(a.xqj),remainDays:p(a.syr),dailyChange:p(a.rz),prevSettle:p(a.zjsj),open:p(a.o)})):[]}async function xn(t,e,n){let i=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:gt,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),r=`${ft}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function a(l){if(!l)return"";let u=String(l),c=u.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:u}return s.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:p(l.MEMBER_RANK)??0,sellVolume:p(l.SELL_VOLUME),sellVolumeChange:p(l.SELL_VOLUME_CHANGE),netSellVolume:p(l.NET_SELL_VOLUME),sellVolumeRatio:p(l.SELL_VOLUME_RATIO),buyVolume:p(l.BUY_VOLUME),buyVolumeChange:p(l.BUY_VOLUME_CHANGE),netBuyVolume:p(l.NET_BUY_VOLUME),buyVolumeRatio:p(l.BUY_VOLUME_RATIO),sellPosition:p(l.SELL_POSITION),sellPositionChange:p(l.SELL_POSITION_CHANGE),netSellPosition:p(l.NET_SELL_POSITION),sellPositionRatio:p(l.SELL_POSITION_RATIO),buyPosition:p(l.BUY_POSITION),buyPositionChange:p(l.BUY_POSITION_CHANGE),netBuyPosition:p(l.NET_BUY_POSITION),buyPositionRatio:p(l.BUY_POSITION_RATIO)}))}var br={gold:"EMI00069026",silver:"EMI00069027"};async function Ln(t){let e=new URLSearchParams({reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageNumber:"1",pageSize:"500",source:"WEB",client:"WEB"}),n=`${F}?${e.toString()}`,r=(await t.get(n,{responseType:"json"}))?.result?.data;return Array.isArray(r)?r.map(o=>({code:String(o.TRADE_CODE??""),name:String(o.TRADE_TYPE??""),marketCode:String(o.TRADE_MARKET_CODE??"")})):[]}function Kn(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function Un(t,e,n={}){let{startDate:i="2020-10-28",pageSize:r=500}=n,o=e.toUpperCase(),s=[],a=1,l=1;do{let u=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${o}")(TRADE_DATE>='${i}')`,pageNumber:String(a),pageSize:String(r),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${F}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(l=d.pages??1);let g=d.data.map(y=>({code:String(y.SECURITY_CODE??e),date:Kn(y.TRADE_DATE),inventory:p(y.ON_WARRANT_NUM),change:p(y.ADDCHANGE)}));s.push(...g),a++}while(a<=l);return s}async function Dn(t,e,n={}){let i=br[e];if(!i)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:r=500}=n,o=[],s=1,a=1,l={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let u=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(r),pageNumber:String(s),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${i}")(@STORAGE_TON<>"NULL")`}),c=`${F}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;s===1&&(a=d.pages??1);let g=d.data.map(y=>({date:Kn(y.REPORT_DATE),name:l[e]??e,storageTon:p(y.STORAGE_TON),storageOunce:p(y.STORAGE_OUNCE)}));o.push(...g),s++}while(s<=a);return o}var A={};_e(A,{getCommodityOptionKline:()=>Qn,getCommodityOptionSpot:()=>jn,getETFOption5DayMinute:()=>qn,getETFOptionDailyKline:()=>Hn,getETFOptionExpireDay:()=>Fn,getETFOptionMinute:()=>wn,getETFOptionMonths:()=>Bn,getIndexOptionKline:()=>Nn,getIndexOptionSpot:()=>kn});function Pr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Ar(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function kn(t,e){let n=`${Z}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,i=await P(n),r=i?.result?.data?.up??[],o=i?.result?.data?.down??[];return{calls:r.map(Pr),puts:o.map(Ar)}}async function Nn(t){let e=`${J}?symbol=${t}`,n=await P(e,{callbackMode:"path"});return Array.isArray(n)?n.map(i=>({date:i.d,open:p(i.o),high:p(i.h),low:p(i.l),close:p(i.c),volume:p(i.v)})):[]}async function Bn(t){let e=`${ut}?exchange=null&cate=${encodeURIComponent(t)}`,i=(await P(e))?.result?.data,r=i?.contractMonth??[];return{months:r.length>1?r.slice(1):r,stockId:i?.stockId??"",cateId:i?.cateId??"",cateList:i?.cateList??[]}}async function Fn(t,e){let n=`${Ae}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,i=await P(n),r=i?.result?.data?.remainderDays;if(typeof r=="number"&&r<0){let s=`${Ae}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;i=await P(s)}let o=i?.result?.data;return{expireDay:o?.expireDay??"",remainderDays:o?.remainderDays??0,stockId:o?.stockId??"",name:o?.other?.name??""}}function vn(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:p(n.p),volume:p(n.v),openInterest:p(n.t),avgPrice:p(n.a)}))}async function wn(t){let e=`CON_OP_${t}`,n=`${ct}?symbol=${e}`,r=(await P(n))?.result?.data;return Array.isArray(r)?vn(r):[]}async function Hn(t){let e=`CON_OP_${t}`,n=`${pt}?symbol=${e}`,i=await P(n,{callbackMode:"path"});return Array.isArray(i)?i.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}async function qn(t){let e=`CON_OP_${t}`,n=`${dt}?symbol=${e}`,r=(await P(n))?.result?.data;if(!Array.isArray(r))return[];let o=[];for(let s of r)Array.isArray(s)&&o.push(...vn(s));return o}function Ir(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Mr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function jn(t,e){let n=Ie[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(Ie).join(", ")}`);let i=`${Z}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,r=await P(i),o=r?.result?.data?.up??[],s=r?.result?.data?.down??[];return{calls:o.map(Ir),puts:s.map(Mr)}}async function Qn(t){let e=`${J}?symbol=${t}`,n=await P(e,{callbackMode:"path"});return Array.isArray(n)?n.map(i=>({date:i.d,open:p(i.o),high:p(i.h),low:p(i.l),close:p(i.c),volume:p(i.v)})):[]}function le(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function B(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let r=0,o=0;for(let s=i-e+1;s<=i;s++)t[s]!==null&&(r+=t[s],o++);n.push(o===e?le(r/e):null)}return n}function U(t,e){let n=[],i=2/(e+1),r=null,o=!1;for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}if(!o){let l=0,u=0;for(let c=s-e+1;c<=s;c++)t[c]!==null&&(l+=t[c],u++);u===e&&(r=l/e,o=!0),n.push(r!==null?le(r):null);continue}let a=t[s];a===null?n.push(r!==null?le(r):null):(r=i*a+(1-i)*r,n.push(le(r)))}return n}function we(t,e){let n=[],i=Array.from({length:e},(o,s)=>s+1),r=i.reduce((o,s)=>o+s,0);for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}let s=0,a=!0;for(let l=0;l<e;l++){let u=t[o-e+1+l];if(u===null){a=!1;break}s+=u*i[l]}n.push(a?le(s/r):null)}return n}function ue(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,r=i==="ema"?U:i==="wma"?we:B,o={};for(let s of n)o[`ma${s}`]=r(t,s);return t.map((s,a)=>{let l={};for(let u of n)l[`ma${u}`]=o[`ma${u}`][a];return l})}function $n(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ce(t,e={}){let{short:n=12,long:i=26,signal:r=9}=e,o=U(t,n),s=U(t,i),a=t.map((u,c)=>o[c]===null||s[c]===null?null:o[c]-s[c]),l=U(a,r);return t.map((u,c)=>({dif:a[c]!==null?$n(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?$n((a[c]-l[c])*2):null}))}function kt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function xr(t,e,n){let i=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){i.push(null);continue}let o=0,s=0;for(let a=r-e+1;a<=r;a++)t[a]!==null&&n[r]!==null&&(o+=Math.pow(t[a]-n[r],2),s++);i.push(s===e?Math.sqrt(o/e):null)}return i}function pe(t,e={}){let{period:n=20,stdDev:i=2}=e,r=B(t,n),o=xr(t,n,r);return t.map((s,a)=>{if(r[a]===null||o[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=r[a]+i*o[a],u=r[a]-i*o[a],c=r[a]!==0?kt((l-u)/r[a]*100):null;return{mid:r[a],upper:kt(l),lower:kt(u),bandwidth:c}})}function Nt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function de(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:r=3}=e,o=[],s=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){o.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,m=!0;for(let f=l-n+1;f<=l;f++){if(t[f].high===null||t[f].low===null){m=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[l].close;if(!m||d===null||u===c){o.push({k:null,d:null,j:null});continue}let g=(d-c)/(u-c)*100;s=(i-1)/i*s+1/i*g,a=(r-1)/r*a+1/r*s;let y=3*s-2*a;o.push({k:Nt(s),d:Nt(a),j:Nt(y)})}return o}function Lr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function me(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let o=1;o<t.length;o++)t[o]===null||t[o-1]===null?i.push(null):i.push(t[o]-t[o-1]);let r={};for(let o of n){let s=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<o){s.push(null),i[u]!==null&&(i[u]>0?a+=i[u]:l+=Math.abs(i[u]));continue}if(u===o)a=a/o,l=l/o;else{let c=i[u]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(o-1)+m)/o,l=(l*(o-1)+d)/o}if(l===0)s.push(100);else if(a===0)s.push(0);else{let c=a/l;s.push(Lr(100-100/(1+c)))}}r[`rsi${o}`]=s}return t.map((o,s)=>{let a={};for(let l of n)a[`rsi${l}`]=r[`rsi${l}`][s];return a})}function Kr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function fe(t,e={}){let{periods:n=[6,10]}=e,i={};for(let r of n){let o=[];for(let s=0;s<t.length;s++){if(s<r-1){o.push(null);continue}let a=-1/0,l=1/0,u=!0;for(let d=s-r+1;d<=s;d++){if(t[d].high===null||t[d].low===null){u=!1;break}a=Math.max(a,t[d].high),l=Math.min(l,t[d].low)}let c=t[s].close;if(!u||c===null||a===l){o.push(null);continue}let m=(a-c)/(a-l)*100;o.push(Kr(m))}i[`wr${r}`]=o}return t.map((r,o)=>{let s={};for(let a of n)s[`wr${a}`]=i[`wr${a}`][o];return s})}function Ur(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ge(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let r of n){let o=B(t,r),s=[];for(let a=0;a<t.length;a++)if(t[a]===null||o[a]===null||o[a]===0)s.push(null);else{let l=(t[a]-o[a])/o[a]*100;s.push(Ur(l))}i[`bias${r}`]=s}return t.map((r,o)=>{let s={};for(let a of n)s[`bias${a}`]=i[`bias${a}`][o];return s})}function Dr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function he(t,e={}){let{period:n=14}=e,i=[],r=t.map(o=>o.high===null||o.low===null||o.close===null?null:(o.high+o.low+o.close)/3);for(let o=0;o<t.length;o++){if(o<n-1){i.push({cci:null});continue}let s=0,a=0;for(let m=o-n+1;m<=o;m++)r[m]!==null&&(s+=r[m],a++);if(a!==n||r[o]===null){i.push({cci:null});continue}let l=s/n,u=0;for(let m=o-n+1;m<=o;m++)u+=Math.abs(r[m]-l);let c=u/n;if(c===0)i.push({cci:0});else{let m=(r[o]-l)/(.015*c);i.push({cci:Dr(m)})}}return i}function Bt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function j(t,e={}){let{period:n=14}=e,i=[],r=[];for(let s=0;s<t.length;s++){let{high:a,low:l,close:u}=t[s];if(a===null||l===null||u===null){r.push(null);continue}if(s===0)r.push(a-l);else{let c=t[s-1].close;if(c===null)r.push(a-l);else{let m=a-l,d=Math.abs(a-c),g=Math.abs(l-c);r.push(Math.max(m,d,g))}}}let o=null;for(let s=0;s<t.length;s++){if(s<n-1){i.push({tr:r[s]!==null?Bt(r[s]):null,atr:null});continue}if(s===n-1){let a=0,l=0;for(let u=0;u<n;u++)r[u]!==null&&(a+=r[u],l++);l===n&&(o=a/n)}else o!==null&&r[s]!==null&&(o=(o*(n-1)+r[s])/n);i.push({tr:r[s]!==null?Bt(r[s]):null,atr:o!==null?Bt(o):null})}return i}function ye(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let r=t[0].volume??0;i.push({obv:r,obvMa:null});for(let o=1;o<t.length;o++){let s=t[o],a=t[o-1];if(s.close===null||a.close===null||s.volume===null||s.volume===void 0){i.push({obv:null,obvMa:null});continue}s.close>a.close?r+=s.volume:s.close<a.close&&(r-=s.volume),i.push({obv:r,obvMa:null})}if(n&&n>0)for(let o=n-1;o<i.length;o++){let s=0,a=0;for(let l=o-n+1;l<=o;l++)i[l].obv!==null&&(s+=i[l].obv,a++);a===n&&(i[o].obvMa=s/n)}return i}function Re(t,e={}){let{period:n=12,signalPeriod:i}=e,r=[];for(let o=0;o<t.length;o++){if(o<n){r.push({roc:null,signal:null});continue}let s=t[o].close,a=t[o-n].close;if(s===null||a===null||a===0){r.push({roc:null,signal:null});continue}let l=(s-a)/a*100;r.push({roc:l,signal:null})}if(i&&i>0)for(let o=n+i-1;o<r.length;o++){let s=0,a=0;for(let l=o-i+1;l<=o;l++)r[l].roc!==null&&(s+=r[l].roc,a++);a===i&&(r[o].signal=s/i)}return r}function Ce(t,e={}){let{period:n=14,adxPeriod:i=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let o=[],s=[],a=[];for(let f=0;f<t.length;f++){if(f===0){o.push(0),s.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],O=t[f-1];if(C.high===null||C.low===null||C.close===null||O.high===null||O.low===null||O.close===null){o.push(0),s.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let E=C.high-C.low,_=Math.abs(C.high-O.close),z=Math.abs(C.low-O.close);a.push(Math.max(E,_,z));let D=C.high-O.high,Q=O.low-C.low;D>Q&&D>0?o.push(D):o.push(0),Q>D&&Q>0?s.push(Q):s.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,u=0,c=0,m=[];for(let f=1;f<t.length;f++){if(f<n){l+=a[f],u+=o[f],c+=s[f],m.push(0);continue}f===n?(l=l,u=u,c=c):(l=l-l/n+a[f],u=u-u/n+o[f],c=c-c/n+s[f]);let C=l>0?u/l*100:0,O=l>0?c/l*100:0;r[f].pdi=C,r[f].mdi=O;let E=C+O,_=E>0?Math.abs(C-O)/E*100:0;m.push(_)}let d=0,g=0,y=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=m[f-n+1]||0,g++;continue}if(f===n*2-1)d+=m[f-n+1]||0,y=d/i,r[f].adx=y;else{let C=m[f-n+1]||0;y=(y*(i-1)+C)/i,r[f].adx=y}}for(let f=n*2-1+i;f<t.length;f++){let C=r[f].adx,O=r[f-i]?.adx;C!==null&&O!==null&&(r[f].adxr=(C+O)/2)}return r}function Se(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:r=.2}=e,o=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,a=n,l=t[0].high??0,u=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(s=-1,l=c.low??0,u=c.high??0),o.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let g=t[d],y=t[d-1];if(g.high===null||g.low===null||y.high===null||y.low===null){o.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+a*(l-u);s===1?(f=Math.min(f,y.low,t[Math.max(0,d-2)]?.low??y.low),g.low<f?(s=-1,f=l,l=g.low,a=n):g.high>l&&(l=g.high,a=Math.min(a+i,r))):(f=Math.max(f,y.high,t[Math.max(0,d-2)]?.high??y.high),g.high>f?(s=1,f=l,l=g.high,a=n):g.low<l&&(l=g.low,a=Math.min(a+i,r))),u=f,o.push({sar:u,trend:s,ep:l,af:a})}return o}function Oe(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:r=2}=e,o=[],s=t.map(u=>u.close),a=U(s,n),l=j(t,{period:i});for(let u=0;u<t.length;u++){let c=a[u],m=l[u]?.atr;if(c===null||m===null){o.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*m,g=c-r*m,y=c>0?(d-g)/c*100:null;o.push({mid:c,upper:d,lower:g,width:y})}return o}function Te(t,e={}){if(t.length===0)return[];let n=t.map(E=>E.close),i=t.map(E=>({open:E.open,high:E.high,low:E.low,close:E.close,volume:E.volume})),r=e.ma?ue(n,typeof e.ma=="object"?e.ma:{}):null,o=e.macd?ce(n,typeof e.macd=="object"?e.macd:{}):null,s=e.boll?pe(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?de(i,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?me(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?fe(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?ge(n,typeof e.bias=="object"?e.bias:{}):null,m=e.cci?he(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?j(i,typeof e.atr=="object"?e.atr:{}):null,g=e.obv?ye(i,typeof e.obv=="object"?e.obv:{}):null,y=e.roc?Re(i,typeof e.roc=="object"?e.roc:{}):null,f=e.dmi?Ce(i,typeof e.dmi=="object"?e.dmi:{}):null,C=e.sar?Se(i,typeof e.sar=="object"?e.sar:{}):null,O=e.kc?Oe(i,typeof e.kc=="object"?e.kc:{}):null;return t.map((E,_)=>({...E,...r&&{ma:r[_]},...o&&{macd:o[_]},...s&&{boll:s[_]},...a&&{kdj:a[_]},...l&&{rsi:l[_]},...u&&{wr:u[_]},...c&&{bias:c[_]},...m&&{cci:m[_]},...d&&{atr:d[_]},...g&&{obv:g[_]},...y&&{roc:y[_]},...f&&{dmi:f[_]},...C&&{sar:C[_]},...O&&{kc:O[_]}}))}var Ee=class{constructor(e={}){this.client=new oe(e)}getFullQuotes(e){return b.getFullQuotes(this.client,e)}getSimpleQuotes(e){return b.getSimpleQuotes(this.client,e)}getHKQuotes(e){return b.getHKQuotes(this.client,e)}getUSQuotes(e){return b.getUSQuotes(this.client,e)}getFundQuotes(e){return b.getFundQuotes(this.client,e)}getFundFlow(e){return b.getFundFlow(this.client,e)}getPanelLargeOrder(e){return b.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return b.getTodayTimeline(this.client,e)}getIndustryList(){return T.getIndustryList(this.client)}getIndustrySpot(e){return T.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return T.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return T.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return T.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return T.getConceptList(this.client)}getConceptSpot(e){return T.getConceptSpot(this.client,e)}getConceptConstituents(e){return T.getConceptConstituents(this.client,e)}getConceptKline(e,n){return T.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return T.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return T.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return T.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return T.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return T.getUSHistoryKline(this.client,e,n)}search(e){return b.search(this.client,e)}getAShareCodeList(e){return b.getAShareCodeList(this.client,e)}getUSCodeList(e){return b.getUSCodeList(this.client,e)}getHKCodeList(){return b.getHKCodeList(this.client)}getFundCodeList(){return b.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return b.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,r=await this.getUSCodeList({simple:!0,market:n});return b.getAllUSQuotesByCodes(this.client,r,i)}getAllQuotesByCodes(e,n={}){return b.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return b.getTradingCalendar(this.client)}getDividendDetail(e){return T.getDividendDetail(this.client,e)}getFuturesKline(e,n){return T.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return T.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return T.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return T.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return T.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return T.getComexInventory(this.client,e,n)}getIndexOptionSpot(e,n){return A.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return A.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return T.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return A.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return A.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return A.getETFOptionMinute(e)}getETFOptionDailyKline(e){return A.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return A.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return A.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return A.getCommodityOptionKline(e)}getOptionLHB(e,n){return T.getOptionLHB(this.client,e,n)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let o=typeof e.ma=="object"?e.ma:{},s=o.periods??[5,10,20,30,60,120,250],a=o.type??"sma";n=Math.max(n,this.safeMax(s,20)),a==="ema"&&(i=!0)}if(e.macd){let o=typeof e.macd=="object"?e.macd:{},s=o.long??26,a=o.signal??9;n=Math.max(n,s*3+a),i=!0}if(e.boll){let o=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,o)}if(e.kdj){let o=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,o)}if(e.rsi){let o=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(o,14)+1)}if(e.wr){let o=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(o,10))}if(e.bias){let o=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(o,12))}if(e.cci){let o=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,o)}if(e.atr){let o=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,o)}if(e.obv){let o=typeof e.obv=="object"&&e.obv.maPeriod?e.obv.maPeriod:0;n=Math.max(n,Math.max(2,o))}if(e.roc){let o=typeof e.roc=="object"?e.roc:{},s=o.period??12,a=o.signalPeriod??0;n=Math.max(n,s+a)}if(e.dmi){let o=typeof e.dmi=="object"?e.dmi:{},s=o.period??14,a=o.adxPeriod??s;n=Math.max(n,s*2+a)}if(e.sar&&(n=Math.max(n,5)),e.kc){let o=typeof e.kc=="object"?e.kc:{},s=o.emaPeriod??20,a=o.atrPeriod??10;n=Math.max(n,Math.max(s*3,a)),i=!0}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let r=Math.ceil(n*i),o=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));o.setDate(o.getDate()-r);let s=o.getFullYear(),a=String(o.getMonth()+1).padStart(2,"0"),l=String(o.getDate()).padStart(2,"0");return`${s}${a}${l}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let r=this.normalizeDate(e),o=i.findIndex(a=>a>=r);o===-1&&(o=i.length-1);let s=Math.max(0,o-n);return this.toCompactDate(i[s])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:r,indicators:o={}}=n,s=n.market??this.detectMarket(e),a=this.calcRequiredLookback(o),l={A:1.5,HK:1.46,US:1.45},u;if(i)if(s==="A")try{let g=await b.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,a,g)??this.calcActualStartDate(i,a,l[s])}catch{u=this.calcActualStartDate(i,a,l[s])}else u=this.calcActualStartDate(i,a,l[s]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},m;switch(s){case"HK":m=await this.getHKHistoryKline(e,c);break;case"US":m=await this.getUSHistoryKline(e,c);break;default:m=await this.getHistoryKline(e,c)}if(i&&m.length<a)switch(s){case"HK":m=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=Te(m,o);if(i){let g=this.dateToTimestamp(i),y=r?this.dateToTimestamp(r):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=g&&C<=y})}return d}},Gn=Ee;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,extractJsonFromJsonp,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});
|
package/dist/index.d.cts
CHANGED
|
@@ -38,6 +38,10 @@ interface CircuitBreakerOptions {
|
|
|
38
38
|
onStateChange?: (from: CircuitState, to: CircuitState) => void;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 已知的数据源名称
|
|
43
|
+
*/
|
|
44
|
+
type ProviderName = 'tencent' | 'eastmoney' | 'sina' | 'linkdiary' | 'unknown';
|
|
41
45
|
/**
|
|
42
46
|
* HTTP 错误类
|
|
43
47
|
*/
|
|
@@ -69,6 +73,25 @@ interface RetryOptions {
|
|
|
69
73
|
/** 重试回调(用于日志等) */
|
|
70
74
|
onRetry?: (attempt: number, error: Error, delay: number) => void;
|
|
71
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Provider 级请求策略
|
|
78
|
+
*/
|
|
79
|
+
interface ProviderRequestPolicy {
|
|
80
|
+
/** 请求超时时间(毫秒) */
|
|
81
|
+
timeout?: number;
|
|
82
|
+
/** 重试配置 */
|
|
83
|
+
retry?: RetryOptions;
|
|
84
|
+
/** 自定义请求头 */
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
/** 自定义 User-Agent(浏览器环境可能会被忽略) */
|
|
87
|
+
userAgent?: string;
|
|
88
|
+
/** 限流配置(防止请求过快被频控) */
|
|
89
|
+
rateLimit?: RateLimiterOptions;
|
|
90
|
+
/** 是否启用 UA 轮换(仅 Node.js 有效) */
|
|
91
|
+
rotateUserAgent?: boolean;
|
|
92
|
+
/** 熔断器配置(连续失败时暂停请求) */
|
|
93
|
+
circuitBreaker?: CircuitBreakerOptions;
|
|
94
|
+
}
|
|
72
95
|
/**
|
|
73
96
|
* 请求客户端配置选项
|
|
74
97
|
*/
|
|
@@ -86,6 +109,11 @@ interface RequestClientOptions {
|
|
|
86
109
|
rotateUserAgent?: boolean;
|
|
87
110
|
/** 熔断器配置(连续失败时暂停请求) */
|
|
88
111
|
circuitBreaker?: CircuitBreakerOptions;
|
|
112
|
+
/**
|
|
113
|
+
* Provider 级请求策略。
|
|
114
|
+
* 未配置的 provider 会回退到全局默认配置。
|
|
115
|
+
*/
|
|
116
|
+
providerPolicies?: Partial<Record<ProviderName, ProviderRequestPolicy>>;
|
|
89
117
|
}
|
|
90
118
|
|
|
91
119
|
/**
|
|
@@ -122,7 +150,7 @@ declare function chunkArray<T>(array: T[], chunkSize: number): T[][];
|
|
|
122
150
|
* @param tasks 任务函数数组
|
|
123
151
|
* @param concurrency 最大并发数
|
|
124
152
|
*/
|
|
125
|
-
declare function asyncPool<T>(tasks: (() => Promise<T>)[], concurrency: number): Promise<T[]>;
|
|
153
|
+
declare function asyncPool<T>(tasks: (() => Promise<T>)[], concurrency: number, preserveOrder?: boolean): Promise<T[]>;
|
|
126
154
|
|
|
127
155
|
/**
|
|
128
156
|
* JSONP 双端请求工具
|
|
@@ -1159,10 +1187,13 @@ interface MinuteKlineOptions {
|
|
|
1159
1187
|
}
|
|
1160
1188
|
|
|
1161
1189
|
/**
|
|
1162
|
-
*
|
|
1190
|
+
* 东方财富历史 K 线 provider 工厂
|
|
1163
1191
|
*/
|
|
1164
1192
|
|
|
1165
|
-
|
|
1193
|
+
/**
|
|
1194
|
+
* 通用历史 K 线请求选项
|
|
1195
|
+
*/
|
|
1196
|
+
interface HistoryKlineRequestOptions {
|
|
1166
1197
|
/** K 线周期 */
|
|
1167
1198
|
period?: 'daily' | 'weekly' | 'monthly';
|
|
1168
1199
|
/** 复权类型 */
|
|
@@ -1173,19 +1204,18 @@ interface HKKlineOptions {
|
|
|
1173
1204
|
endDate?: string;
|
|
1174
1205
|
}
|
|
1175
1206
|
|
|
1207
|
+
/**
|
|
1208
|
+
* 东方财富 - 港股 K 线
|
|
1209
|
+
*/
|
|
1210
|
+
|
|
1211
|
+
interface HKKlineOptions extends HistoryKlineRequestOptions {
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1176
1214
|
/**
|
|
1177
1215
|
* 东方财富 - 美股 K 线
|
|
1178
1216
|
*/
|
|
1179
1217
|
|
|
1180
|
-
interface USKlineOptions {
|
|
1181
|
-
/** K 线周期 */
|
|
1182
|
-
period?: 'daily' | 'weekly' | 'monthly';
|
|
1183
|
-
/** 复权类型 */
|
|
1184
|
-
adjust?: '' | 'qfq' | 'hfq';
|
|
1185
|
-
/** 开始日期 YYYYMMDD */
|
|
1186
|
-
startDate?: string;
|
|
1187
|
-
/** 结束日期 YYYYMMDD */
|
|
1188
|
-
endDate?: string;
|
|
1218
|
+
interface USKlineOptions extends HistoryKlineRequestOptions {
|
|
1189
1219
|
}
|
|
1190
1220
|
|
|
1191
1221
|
/**
|
|
@@ -1352,6 +1382,11 @@ interface IndicatorOptions {
|
|
|
1352
1382
|
bias?: BIASOptions | boolean;
|
|
1353
1383
|
cci?: CCIOptions | boolean;
|
|
1354
1384
|
atr?: ATROptions | boolean;
|
|
1385
|
+
obv?: OBVOptions$1 | boolean;
|
|
1386
|
+
roc?: ROCOptions$1 | boolean;
|
|
1387
|
+
dmi?: DMIOptions$1 | boolean;
|
|
1388
|
+
sar?: SAROptions$1 | boolean;
|
|
1389
|
+
kc?: KCOptions$1 | boolean;
|
|
1355
1390
|
}
|
|
1356
1391
|
interface MAResult {
|
|
1357
1392
|
[key: string]: number | null;
|
|
@@ -1805,6 +1840,11 @@ type KlineWithIndicators<T extends HistoryKline | HKUSHistoryKline> = T & {
|
|
|
1805
1840
|
bias?: BIASResult;
|
|
1806
1841
|
cci?: CCIResult;
|
|
1807
1842
|
atr?: ATRResult;
|
|
1843
|
+
obv?: OBVResult$1;
|
|
1844
|
+
roc?: ROCResult$1;
|
|
1845
|
+
dmi?: DMIResult$1;
|
|
1846
|
+
sar?: SARResult$1;
|
|
1847
|
+
kc?: KCResult$1;
|
|
1808
1848
|
};
|
|
1809
1849
|
/**
|
|
1810
1850
|
* 为 K 线数据添加技术指标
|
|
@@ -1822,6 +1862,11 @@ declare function addIndicators<T extends HistoryKline | HKUSHistoryKline>(klines
|
|
|
1822
1862
|
type MarketType = 'A' | 'HK' | 'US';
|
|
1823
1863
|
declare class StockSDK {
|
|
1824
1864
|
private client;
|
|
1865
|
+
/**
|
|
1866
|
+
* 创建 Stock SDK 实例。
|
|
1867
|
+
* 旧的全局 `timeout` / `retry` / `rateLimit` / `circuitBreaker` 配置继续有效,
|
|
1868
|
+
* 也可以通过 `providerPolicies` 为不同数据源覆盖请求治理策略而不影响既有 API。
|
|
1869
|
+
*/
|
|
1825
1870
|
constructor(options?: RequestClientOptions);
|
|
1826
1871
|
/**
|
|
1827
1872
|
* 获取 A 股 / 指数 全量行情
|
|
@@ -2272,4 +2317,4 @@ declare class StockSDK {
|
|
|
2272
2317
|
}): Promise<KlineWithIndicators<HistoryKline | HKUSHistoryKline>[]>;
|
|
2273
2318
|
}
|
|
2274
2319
|
|
|
2275
|
-
export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DividendDetail, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type FullQuote, type FundFlow, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndexOptionProduct, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, extractJsonFromJsonp, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
|
|
2320
|
+
export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DividendDetail, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type FullQuote, type FundFlow, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndexOptionProduct, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ProviderName, type ProviderRequestPolicy, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, extractJsonFromJsonp, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ interface CircuitBreakerOptions {
|
|
|
38
38
|
onStateChange?: (from: CircuitState, to: CircuitState) => void;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 已知的数据源名称
|
|
43
|
+
*/
|
|
44
|
+
type ProviderName = 'tencent' | 'eastmoney' | 'sina' | 'linkdiary' | 'unknown';
|
|
41
45
|
/**
|
|
42
46
|
* HTTP 错误类
|
|
43
47
|
*/
|
|
@@ -69,6 +73,25 @@ interface RetryOptions {
|
|
|
69
73
|
/** 重试回调(用于日志等) */
|
|
70
74
|
onRetry?: (attempt: number, error: Error, delay: number) => void;
|
|
71
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Provider 级请求策略
|
|
78
|
+
*/
|
|
79
|
+
interface ProviderRequestPolicy {
|
|
80
|
+
/** 请求超时时间(毫秒) */
|
|
81
|
+
timeout?: number;
|
|
82
|
+
/** 重试配置 */
|
|
83
|
+
retry?: RetryOptions;
|
|
84
|
+
/** 自定义请求头 */
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
/** 自定义 User-Agent(浏览器环境可能会被忽略) */
|
|
87
|
+
userAgent?: string;
|
|
88
|
+
/** 限流配置(防止请求过快被频控) */
|
|
89
|
+
rateLimit?: RateLimiterOptions;
|
|
90
|
+
/** 是否启用 UA 轮换(仅 Node.js 有效) */
|
|
91
|
+
rotateUserAgent?: boolean;
|
|
92
|
+
/** 熔断器配置(连续失败时暂停请求) */
|
|
93
|
+
circuitBreaker?: CircuitBreakerOptions;
|
|
94
|
+
}
|
|
72
95
|
/**
|
|
73
96
|
* 请求客户端配置选项
|
|
74
97
|
*/
|
|
@@ -86,6 +109,11 @@ interface RequestClientOptions {
|
|
|
86
109
|
rotateUserAgent?: boolean;
|
|
87
110
|
/** 熔断器配置(连续失败时暂停请求) */
|
|
88
111
|
circuitBreaker?: CircuitBreakerOptions;
|
|
112
|
+
/**
|
|
113
|
+
* Provider 级请求策略。
|
|
114
|
+
* 未配置的 provider 会回退到全局默认配置。
|
|
115
|
+
*/
|
|
116
|
+
providerPolicies?: Partial<Record<ProviderName, ProviderRequestPolicy>>;
|
|
89
117
|
}
|
|
90
118
|
|
|
91
119
|
/**
|
|
@@ -122,7 +150,7 @@ declare function chunkArray<T>(array: T[], chunkSize: number): T[][];
|
|
|
122
150
|
* @param tasks 任务函数数组
|
|
123
151
|
* @param concurrency 最大并发数
|
|
124
152
|
*/
|
|
125
|
-
declare function asyncPool<T>(tasks: (() => Promise<T>)[], concurrency: number): Promise<T[]>;
|
|
153
|
+
declare function asyncPool<T>(tasks: (() => Promise<T>)[], concurrency: number, preserveOrder?: boolean): Promise<T[]>;
|
|
126
154
|
|
|
127
155
|
/**
|
|
128
156
|
* JSONP 双端请求工具
|
|
@@ -1159,10 +1187,13 @@ interface MinuteKlineOptions {
|
|
|
1159
1187
|
}
|
|
1160
1188
|
|
|
1161
1189
|
/**
|
|
1162
|
-
*
|
|
1190
|
+
* 东方财富历史 K 线 provider 工厂
|
|
1163
1191
|
*/
|
|
1164
1192
|
|
|
1165
|
-
|
|
1193
|
+
/**
|
|
1194
|
+
* 通用历史 K 线请求选项
|
|
1195
|
+
*/
|
|
1196
|
+
interface HistoryKlineRequestOptions {
|
|
1166
1197
|
/** K 线周期 */
|
|
1167
1198
|
period?: 'daily' | 'weekly' | 'monthly';
|
|
1168
1199
|
/** 复权类型 */
|
|
@@ -1173,19 +1204,18 @@ interface HKKlineOptions {
|
|
|
1173
1204
|
endDate?: string;
|
|
1174
1205
|
}
|
|
1175
1206
|
|
|
1207
|
+
/**
|
|
1208
|
+
* 东方财富 - 港股 K 线
|
|
1209
|
+
*/
|
|
1210
|
+
|
|
1211
|
+
interface HKKlineOptions extends HistoryKlineRequestOptions {
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1176
1214
|
/**
|
|
1177
1215
|
* 东方财富 - 美股 K 线
|
|
1178
1216
|
*/
|
|
1179
1217
|
|
|
1180
|
-
interface USKlineOptions {
|
|
1181
|
-
/** K 线周期 */
|
|
1182
|
-
period?: 'daily' | 'weekly' | 'monthly';
|
|
1183
|
-
/** 复权类型 */
|
|
1184
|
-
adjust?: '' | 'qfq' | 'hfq';
|
|
1185
|
-
/** 开始日期 YYYYMMDD */
|
|
1186
|
-
startDate?: string;
|
|
1187
|
-
/** 结束日期 YYYYMMDD */
|
|
1188
|
-
endDate?: string;
|
|
1218
|
+
interface USKlineOptions extends HistoryKlineRequestOptions {
|
|
1189
1219
|
}
|
|
1190
1220
|
|
|
1191
1221
|
/**
|
|
@@ -1352,6 +1382,11 @@ interface IndicatorOptions {
|
|
|
1352
1382
|
bias?: BIASOptions | boolean;
|
|
1353
1383
|
cci?: CCIOptions | boolean;
|
|
1354
1384
|
atr?: ATROptions | boolean;
|
|
1385
|
+
obv?: OBVOptions$1 | boolean;
|
|
1386
|
+
roc?: ROCOptions$1 | boolean;
|
|
1387
|
+
dmi?: DMIOptions$1 | boolean;
|
|
1388
|
+
sar?: SAROptions$1 | boolean;
|
|
1389
|
+
kc?: KCOptions$1 | boolean;
|
|
1355
1390
|
}
|
|
1356
1391
|
interface MAResult {
|
|
1357
1392
|
[key: string]: number | null;
|
|
@@ -1805,6 +1840,11 @@ type KlineWithIndicators<T extends HistoryKline | HKUSHistoryKline> = T & {
|
|
|
1805
1840
|
bias?: BIASResult;
|
|
1806
1841
|
cci?: CCIResult;
|
|
1807
1842
|
atr?: ATRResult;
|
|
1843
|
+
obv?: OBVResult$1;
|
|
1844
|
+
roc?: ROCResult$1;
|
|
1845
|
+
dmi?: DMIResult$1;
|
|
1846
|
+
sar?: SARResult$1;
|
|
1847
|
+
kc?: KCResult$1;
|
|
1808
1848
|
};
|
|
1809
1849
|
/**
|
|
1810
1850
|
* 为 K 线数据添加技术指标
|
|
@@ -1822,6 +1862,11 @@ declare function addIndicators<T extends HistoryKline | HKUSHistoryKline>(klines
|
|
|
1822
1862
|
type MarketType = 'A' | 'HK' | 'US';
|
|
1823
1863
|
declare class StockSDK {
|
|
1824
1864
|
private client;
|
|
1865
|
+
/**
|
|
1866
|
+
* 创建 Stock SDK 实例。
|
|
1867
|
+
* 旧的全局 `timeout` / `retry` / `rateLimit` / `circuitBreaker` 配置继续有效,
|
|
1868
|
+
* 也可以通过 `providerPolicies` 为不同数据源覆盖请求治理策略而不影响既有 API。
|
|
1869
|
+
*/
|
|
1825
1870
|
constructor(options?: RequestClientOptions);
|
|
1826
1871
|
/**
|
|
1827
1872
|
* 获取 A 股 / 指数 全量行情
|
|
@@ -2272,4 +2317,4 @@ declare class StockSDK {
|
|
|
2272
2317
|
}): Promise<KlineWithIndicators<HistoryKline | HKUSHistoryKline>[]>;
|
|
2273
2318
|
}
|
|
2274
2319
|
|
|
2275
|
-
export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DividendDetail, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type FullQuote, type FundFlow, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndexOptionProduct, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, extractJsonFromJsonp, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
|
|
2320
|
+
export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DividendDetail, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type FullQuote, type FundFlow, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndexOptionProduct, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ProviderName, type ProviderRequestPolicy, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, extractJsonFromJsonp, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Gn=Object.defineProperty;var Be=(t,e)=>{for(var n in e)Gn(t,n,{get:e[n],enumerable:!0})};function ae(t){return new TextDecoder("gbk").decode(t)}function le(t){let e=t.split(";").map(r=>r.trim()).filter(Boolean),n=[];for(let r of e){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim();s.startsWith("v_")&&(s=s.slice(2));let i=r.slice(o+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let a=i.split("~");n.push({key:s,fields:a})}return n}function y(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function S(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function C(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:C(String(t))}var ve="https://qt.gtimg.cn",He="https://web.ifzq.gtimg.cn/appstock/app/minute/query",qe="https://assets.linkdiary.cn/shares/zh_a_list.json",je="https://assets.linkdiary.cn/shares/us_list.json",Qe="https://assets.linkdiary.cn/shares/hk_list.json",$e="https://assets.linkdiary.cn/shares/fund_list",vt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ue="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ge="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ze="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Ve="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",We="https://17.push2.eastmoney.com/api/qt/clist/get",Xe="https://91.push2.eastmoney.com/api/qt/stock/get",Ye="https://29.push2.eastmoney.com/api/qt/clist/get",Ze="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Je="https://push2his.eastmoney.com/api/qt/stock/trends2/get",et="https://79.push2.eastmoney.com/api/qt/clist/get",tt="https://91.push2.eastmoney.com/api/qt/stock/get",nt="https://29.push2.eastmoney.com/api/qt/clist/get",rt="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",ot="https://push2his.eastmoney.com/api/qt/stock/trends2/get",N="https://datacenter-web.eastmoney.com/api/data/v1/get",X="https://push2his.eastmoney.com/api/qt/stock/kline/get",st="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",Y="58b2fa8f54638b60b87d69b31969089c",it={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},j={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},ce={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},Z="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",J="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",at="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",pe="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",lt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",ut="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",ct="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",pt="https://futsseapi.eastmoney.com/list/option/221",dt="https://datacenter-web.eastmoney.com/api/data/get",mt="b2884a393a59ad64002292a3e90d46a5";var de={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},ft=3e4,ee=500,te=500,ne=7,gt=3,ht=1e3,yt=3e4,Ct=2,Ot=[408,429,500,502,503,504];var me=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),r=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+r),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Ht=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],St=0;function zn(){return typeof window<"u"&&typeof window.document<"u"}function qt(){if(zn())return;let t=Ht[St];return St=(St+1)%Ht.length,t}var re=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},fe=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new re;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var Q=class extends Error{constructor(n,r,o,s){let i=r?` ${r}`:"",a=o?`, url: ${o}`:"",l=s?`, provider: ${s}`:"";super(`HTTP error! status: ${n}${i}${a}${l}`);this.status=n;this.statusText=r;this.url=o;this.provider=s;this.name="HttpError"}},oe=class{constructor(e={}){this.baseUrl=e.baseUrl??ve,this.timeout=e.timeout??ft,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new me(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new fe(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(r=>r.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??gt,baseDelay:e?.baseDelay??ht,maxDelay:e?.maxDelay??yt,backoffMultiplier:e?.backoffMultiplier??Ct,retryableStatusCodes:e?.retryableStatusCodes??Ot,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof Q?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let r=await e();return this.circuitBreaker?.recordSuccess(),r}catch(r){if(this.shouldRetry(r,n)){let o=this.calculateDelay(n);return this.retryOptions.onRetry&&r instanceof Error&&this.retryOptions.onRetry(n+1,r,o),await this.sleep(o),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),r}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new re("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let r=new AbortController,o=setTimeout(()=>r.abort(),this.timeout),s=this.inferProvider(e),i={...this.headers};if(this.rotateUserAgent){let a=qt();a&&(i["User-Agent"]=a)}try{let a=await fetch(e,{signal:r.signal,headers:i});if(!a.ok)throw new Q(a.status,a.statusText,e,s);switch(n.responseType){case"json":return await a.json();case"arraybuffer":return await a.arrayBuffer();default:return await a.text()}}catch(a){throw a instanceof Error&&(a.url=e,a.provider=s),a}finally{clearTimeout(o)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,r=await this.get(n,{responseType:"arraybuffer"}),o=ae(r);return le(o)}};var Vn=new Set(["daily","weekly","monthly"]),Wn=new Set(["1","5","15","30","60"]),Xn=new Set(["","qfq","hfq"]);function L(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function A(t){if(!Vn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function se(t){if(!Wn.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function U(t){if(!Xn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function $(t,e){L(e,"chunkSize");let n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}async function G(t,e){L(e,"concurrency");let n=[],r=[];for(let o of t){let s=Promise.resolve().then(()=>o()).then(i=>{n.push(i)});if(r.push(s),r.length>=e){await Promise.race(r);for(let i=r.length-1;i>=0;i--)await Promise.race([r[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&r.splice(i,1)}}return await Promise.all(r),n}function ge(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function I(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function D(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var Yn=typeof document<"u"&&typeof window<"u",Zn=0;function jt(){return`__stock_sdk_jsonp_${Date.now()}_${Zn++}`}function Rt(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let r=e.indexOf("(");if(r===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let o=e.lastIndexOf(")");if(o===-1||o<=r)throw new Error("Invalid JSONP response: no closing parenthesis found");let s=e.slice(r+1,o);return JSON.parse(s)}function Jn(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e;return new Promise((s,i)=>{let a=jt(),l;if(o==="path")l=t.replace("{callback}",a);else{let h=t.includes("?")?"&":"?";l=`${t}${h}${r}=${a}`}let u=document.createElement("script"),c=!1,m=window,d=()=>{u.parentNode&&u.parentNode.removeChild(u),delete m[a]},f=setTimeout(()=>{c||(c=!0,d(),i(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);m[a]=h=>{c||(c=!0,clearTimeout(f),d(),s(h))},u.onerror=()=>{c||(c=!0,clearTimeout(f),d(),i(new Error(`JSONP script load failed: ${t}`)))},u.src=l,document.head.appendChild(u)})}async function er(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e,s=jt(),i;if(o==="path")i=t.replace("{callback}",s);else{let u=t.includes("?")?"&":"?";i=`${t}${u}${r}=${s}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let u=await fetch(i,{signal:a.signal});if(!u.ok)throw new Error(`JSONP fetch failed with status ${u.status}: ${t}`);let c=await u.text();return Rt(c)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):u}finally{clearTimeout(l)}}function _(t,e={}){return Yn?Jn(t,e):er(t,e)}var T={};Be(T,{getAShareCodeList:()=>Wt,getAllHKQuotesByCodes:()=>Jt,getAllQuotesByCodes:()=>Zt,getAllUSQuotesByCodes:()=>en,getFullQuotes:()=>he,getFundCodeList:()=>tn,getFundFlow:()=>$t,getFundQuotes:()=>zt,getHKCodeList:()=>Yt,getHKQuotes:()=>ye,getPanelLargeOrder:()=>Gt,getSimpleQuotes:()=>Qt,getTodayTimeline:()=>Vt,getTradingCalendar:()=>nn,getUSCodeList:()=>Xt,getUSQuotes:()=>Ce,parseFullQuote:()=>Et,parseFundFlow:()=>_t,parseFundQuote:()=>xt,parseHKQuote:()=>At,parsePanelLargeOrder:()=>bt,parseSimpleQuote:()=>Tt,parseUSQuote:()=>It,search:()=>on});function Et(t){let e=[];for(let r=0;r<5;r++)e.push({price:y(t[9+r*2]),volume:y(t[10+r*2])});let n=[];for(let r=0;r<5;r++)n.push({price:y(t[19+r*2]),volume:y(t[20+r*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),outerVolume:y(t[7]),innerVolume:y(t[8]),bid:e,ask:n,time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),volume2:y(t[36]),amount:y(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),pb:S(t[46]),limitUp:S(t[47]),limitDown:S(t[48]),volumeRatio:S(t[49]),avgPrice:S(t[51]),peStatic:S(t[52]),peDynamic:S(t[53]),high52w:S(t[67]),low52w:S(t[68]),circulatingShares:S(t[72]),totalShares:S(t[73]),raw:t}}function Tt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),change:y(t[4]),changePercent:y(t[5]),volume:y(t[6]),amount:y(t[7]),marketCap:S(t[9]),marketType:t[10]??"",raw:t}}function _t(t){return{code:t[0]??"",mainInflow:y(t[1]),mainOutflow:y(t[2]),mainNet:y(t[3]),mainNetRatio:y(t[4]),retailInflow:y(t[5]),retailOutflow:y(t[6]),retailNet:y(t[7]),retailNetRatio:y(t[8]),totalFlow:y(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function bt(t){return{buyLargeRatio:y(t[0]),buySmallRatio:y(t[1]),sellLargeRatio:y(t[2]),sellSmallRatio:y(t[3]),raw:t}}function At(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),amount:y(t[37]),lotSize:S(t[40]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),currency:t[t.length-3]??"",raw:t}}function It(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),amount:y(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),totalMarketCap:S(t[45]),pb:S(t[47]),high52w:S(t[48]),low52w:S(t[49]),raw:t}}function xt(t){return{code:t[0]??"",name:t[1]??"",nav:y(t[5]),accNav:y(t[6]),change:y(t[7]),navDate:t[8]??"",raw:t}}async function he(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Et(r.fields))}async function Qt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`s_${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Tt(o.fields))}async function $t(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`ff_${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>_t(o.fields))}async function Gt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`s_pk${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>bt(o.fields))}async function ye(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`hk${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>At(o.fields))}async function Ce(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`us${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>It(o.fields))}async function zt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`jj${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>xt(o.fields))}async function Vt(t,e){let n=t.getTimeout(),r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let s=await fetch(`${He}?code=${e}`,{signal:r.signal});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);let i=await s.json();if(i.code!==0)throw new Error(i.msg||"API error");let a=i.data?.[e];if(!a)return{code:e,date:"",data:[]};let l=a.data?.data||[],u=a.data?.date||"",c=!1;if(l.length>0){let d=l[0].split(" "),f=parseFloat(d[1])||0,h=parseInt(d[2],10)||0,g=parseFloat(d[3])||0;h>0&&f>0&&g/h>f*50&&(c=!0)}let m=l.map(d=>{let f=d.split(" "),h=f[0],g=`${h.slice(0,2)}:${h.slice(2,4)}`,O=parseInt(f[2],10)||0,E=parseFloat(f[3])||0,b=c?O*100:O,K=b>0?E/b:0;return{time:g,price:parseFloat(f[1])||0,volume:b,amount:E,avgPrice:Math.round(K*100)/100}});return{code:e,date:u,data:m}}finally{clearTimeout(o)}}var Mt=null,tr=null,Oe=null,nr=null,Se=null,Pt=null;function rr(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function Wt(t,e){let n=!1,r;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,r=e.market),!Mt){let i=(await t.get(qe,{responseType:"json"}))?.list||[];Mt=i,tr=i.map(a=>a.replace(/^(sh|sz|bj)/,""))}let o=Mt;return r&&(o=o.filter(s=>rr(s,r))),n?o.map(s=>s.replace(/^(sh|sz|bj)/,"")):o.slice()}var or={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Xt(t,e){let n=!1,r;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,r=e.market),Oe||(Oe=(await t.get(je,{responseType:"json"}))?.list||[],nr=Oe.map(i=>i.replace(/^\d{3}\./,"")));let o=Oe.slice();if(r){let s=or[r];o=o.filter(i=>i.startsWith(s))}return n?o.map(s=>s.replace(/^\d{3}\./,"")):o}async function Yt(t){return Se||(Se=(await t.get(Qe,{responseType:"json"}))?.list||[]),Se.slice()}async function Zt(t,e,n={}){let{batchSize:r=ee,concurrency:o=ne,onProgress:s}=n;L(r,"batchSize"),L(o,"concurrency");let i=Math.min(r,te),a=$(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await he(t,d);return u++,s&&s(u,l),f});return(await G(c,o)).flat()}async function Jt(t,e,n={}){let{batchSize:r=ee,concurrency:o=ne,onProgress:s}=n;L(r,"batchSize"),L(o,"concurrency");let i=Math.min(r,te),a=$(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await ye(t,d);return u++,s&&s(u,l),f});return(await G(c,o)).flat()}async function en(t,e,n={}){let{batchSize:r=ee,concurrency:o=ne,onProgress:s}=n;L(r,"batchSize"),L(o,"concurrency");let i=Math.min(r,te),a=$(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await Ce(t,d);return u++,s&&s(u,l),f});return(await G(c,o)).flat()}async function tn(t){if(Pt)return Pt.slice();let r=(await t.get($e,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim());return Pt=r,r.slice()}var z=null;async function nn(t){if(z)return z.slice();let e=await t.get(vt);return!e||e.trim()===""?(z=[],z.slice()):(z=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),z.slice())}var rn="https://smartbox.gtimg.cn/s3/";function sr(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function ir(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let r=n.split("~"),o=r[0]||"",s=r[1]||"",i=sr(r[2]||""),a=r[4]||"";return{code:o+s,name:i,market:o,type:a}})}function ar(t){return new Promise((e,n)=>{let r=`${rn}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=r,o.charset="utf-8",o.onload=()=>{let s=window.v_hint||"";document.body.removeChild(o),e(s)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function lr(t,e){let n=`${rn}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function ur(){return typeof window<"u"&&typeof document<"u"}async function on(t,e){if(!e||!e.trim())return[];let n;return ur()?n=await ar(e):n=await lr(t,e),ir(n)}var R={};Be(R,{extractVariety:()=>Kt,getCFFEXOptionQuotes:()=>Tn,getComexInventory:()=>xn,getConceptConstituents:()=>gn,getConceptKline:()=>hn,getConceptList:()=>Dt,getConceptMinuteKline:()=>yn,getConceptSpot:()=>fn,getDividendDetail:()=>Cn,getFuturesHistoryKline:()=>Sn,getFuturesInventory:()=>In,getFuturesInventorySymbols:()=>bn,getFuturesMarketCode:()=>kt,getGlobalFuturesKline:()=>En,getGlobalFuturesSpot:()=>Rn,getHKHistoryKline:()=>ln,getHistoryKline:()=>sn,getIndustryConstituents:()=>pn,getIndustryKline:()=>dn,getIndustryList:()=>Ut,getIndustryMinuteKline:()=>mn,getIndustrySpot:()=>cn,getMinuteKline:()=>an,getOptionLHB:()=>_n,getUSHistoryKline:()=>un});async function Lt(t,e,n,r,o=100,s){let i=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(o),fields:r}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(l=d.total??0);let f=d.diff.map((h,g)=>s(h,i.length+g+1));i.push(...f),a++}while(i.length<l);return i}function x(t){let[e,n,r,o,s,i,a,l,u,c,m]=t.split(",");return{date:e,open:C(n),close:C(r),high:C(o),low:C(s),volume:C(i),amount:C(a),amplitude:C(l),changePercent:C(u),change:C(c),turnoverRate:C(m)}}async function M(t,e,n){let r=`${e}?${n.toString()}`,o=await t.get(r,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function sn(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(r),U(o);let a=e.replace(/^(sh|sz|bj)/,""),l=`${ge(e)}.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(r),fqt:D(o),secid:l,beg:s,end:i}),c=ue,{klines:m}=await M(t,c,u);return m.length===0?[]:m.map(d=>({...x(d),code:a}))}async function an(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:s="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;se(r),U(o);let a=e.replace(/^(sh|sz|bj)/,""),l=`${ge(e)}.${a}`;if(r==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:l}),c=`${Ge}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let f=s.replace("T"," ").slice(0,16),h=i.replace("T"," ").slice(0,16);return d.map(g=>{let[O,E,b,K,W,F,q,$n]=g.split(",");return{time:O,open:C(E),close:C(b),high:C(K),low:C(W),volume:C(F),amount:C(q),avgPrice:C($n)}}).filter(g=>g.time>=f&&g.time<=h)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:r,fqt:D(o||""),secid:l,beg:"0",end:"20500000"}),c=ue,{klines:m}=await M(t,c,u);if(m.length===0)return[];let d=s.replace("T"," ").slice(0,16),f=i.replace("T"," ").slice(0,16);return m.map(h=>{let g=x(h);return{...g,time:g.date}}).filter(h=>h.time>=d&&h.time<=f)}}async function ln(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(r),U(o);let a=e.replace(/^hk/i,"").padStart(5,"0"),l=`116.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(r),fqt:D(o),secid:l,beg:s,end:i,lmt:"1000000"}),c=ze,{klines:m,name:d}=await M(t,c,u);return m.length===0?[]:m.map(f=>({...x(f),code:a,name:d||""}))}async function un(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(r),U(o);let a=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(r),fqt:D(o),secid:e,beg:s,end:i,lmt:"1000000"}),l=Ve,{klines:u,name:c,code:m}=await M(t,l,a),d=m||e.split(".")[1]||e,f=c||"";return u.length===0?[]:u.map(h=>({...x(h),code:d,name:f}))}function Re(t){let e=null;return{async getCode(n,r,o){if(r.startsWith("BK"))return r;if(!e){let i=await o(n);e=new Map(i.map(a=>[a.name,a.code]))}let s=e.get(r);if(!s)throw new Error(`${t.errorPrefix}: ${r}`);return s}}}async function Ee(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},r=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await Lt(t,e.listUrl,n,r,100,(s,i)=>({rank:i,name:String(s.f14??""),code:String(s.f12??""),price:p(s.f2),change:p(s.f4),changePercent:p(s.f3),totalMarketCap:p(s.f20),turnoverRate:p(s.f8),riseCount:p(s.f104),fallCount:p(s.f105),leadingStock:s.f128?String(s.f128):null,leadingStockChangePercent:p(s.f136)}));return o.sort((s,i)=>(i.changePercent??0)-(s.changePercent??0)),o.forEach((s,i)=>{s.rank=i+1}),o}async function Te(t,e,n){let r=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${r.toString()}`,i=(await t.get(o,{responseType:"json"}))?.data;return i?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:u,divide:c})=>{let m=i[l],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:u,value:d}}):[]}async function _e(t,e,n){let r={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Lt(t,n,r,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(s,i)=>({rank:i,code:String(s.f12??""),name:String(s.f14??""),price:p(s.f2),changePercent:p(s.f3),change:p(s.f4),volume:p(s.f5),amount:p(s.f6),amplitude:p(s.f7),high:p(s.f15),low:p(s.f16),open:p(s.f17),prevClose:p(s.f18),turnoverRate:p(s.f8),pe:p(s.f9),pb:p(s.f23)}))}async function be(t,e,n,r={}){let{period:o="daily",adjust:s="",startDate:i="19700101",endDate:a="20500101"}=r;A(o),U(s);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:I(o),fqt:D(s),beg:i,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await M(t,n,l);return u.length===0?[]:u.map(c=>x(c))}async function Ae(t,e,n,r,o={}){let{period:s="5"}=o;if(se(s),s==="1"){let i=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${r}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,f,h,g,O,E,b]=c.split(",");return{time:m,open:C(d),close:C(f),high:C(h),low:C(g),volume:C(O),amount:C(E),price:C(b)}})}else{let i=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:s,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,f,h,g,O,E,b,K,W,F]=c.split(",");return{time:m,open:C(d),close:C(f),high:C(h),low:C(g),changePercent:C(K),change:C(W),volume:C(O),amount:C(E),amplitude:C(b),turnoverRate:C(F)}})}}var w={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:We,spotUrl:Xe,consUrl:Ye,klineUrl:Ze,trendsUrl:Je,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},cr=Re(w);async function Ie(t,e){return cr.getCode(t,e,Ut)}async function Ut(t){return Ee(t,w)}async function cn(t,e){let n=await Ie(t,e);return Te(t,n,w.spotUrl)}async function pn(t,e){let n=await Ie(t,e);return _e(t,n,w.consUrl)}async function dn(t,e,n={}){let r=await Ie(t,e);return be(t,r,w.klineUrl,n)}async function mn(t,e,n={}){let r=await Ie(t,e);return Ae(t,r,w.klineUrl,w.trendsUrl,n)}var B={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:et,spotUrl:tt,consUrl:nt,klineUrl:rt,trendsUrl:ot,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},pr=Re(B);async function xe(t,e){return pr.getCode(t,e,Dt)}async function Dt(t){return Ee(t,B)}async function fn(t,e){let n=await xe(t,e);return Te(t,n,B.spotUrl)}async function gn(t,e){let n=await xe(t,e);return _e(t,n,B.consUrl)}async function hn(t,e,n={}){let r=await xe(t,e);return be(t,r,B.klineUrl,n)}async function yn(t,e,n={}){let r=await xe(t,e);return Ae(t,r,B.klineUrl,B.trendsUrl,n)}function v(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function dr(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:v(t.REPORT_DATE),planNoticeDate:v(t.PLAN_NOTICE_DATE),disclosureDate:v(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:v(t.EQUITY_RECORD_DATE),exDividendDate:v(t.EX_DIVIDEND_DATE),payDate:v(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:v(t.NOTICE_DATE)}}async function Cn(t,e){let n=e.replace(/^(sh|sz|bj)/,""),r=[],o=1,s=1;do{let i=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(o),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),a=`${N}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;o===1&&(s=u.pages??1);let c=u.data.map(dr);r.push(...c),o++}while(o<=s);return r}function Kt(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function On(t){return j[t]??j[t.toLowerCase()]??j[t.toUpperCase()]}function kt(t){let e=On(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=On(t.slice(0,-1))),!e){let r=Object.keys(j).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${r}`)}let n=it[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function mr(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?C(n[12]):null}}async function Sn(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:s="20500101"}=n;A(r);let i=Kt(e),l=`${kt(i)}.${e}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(r),fqt:"0",secid:l,beg:o,end:s}),{klines:c,name:m,code:d}=await M(t,X,u);return c.length===0?[]:c.map(f=>({...mr(f),code:d||e,name:m||""}))}async function Rn(t,e={}){let n=e.pageSize??20,r=[],o=0,s=0;do{let i=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(o),token:Y,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${st}?${i.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;o===0&&(s=l.total??0);let u=l.list.map(fr);r.push(...u),o++}while(r.length<s);return r}function fr(t){return{code:t.dm||"",name:t.name||"",price:C(String(t.p)),change:C(String(t.zde)),changePercent:C(String(t.zdf)),open:C(String(t.o)),high:C(String(t.h)),low:C(String(t.l)),prevSettle:C(String(t.zjsj)),volume:C(String(t.vol)),buyVolume:C(String(t.wp)),sellVolume:C(String(t.np)),openInterest:C(String(t.ccl))}}function gr(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?C(n[12]):null}}function hr(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function En(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:s="20500101"}=n;A(r);let i=n.marketCode;if(i===void 0){let d=hr(e);if(i=ce[d],i===void 0){let f=Object.keys(ce).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${f}. Or specify marketCode manually via options.`)}}let a=`${i}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(r),fqt:"0",secid:a,beg:o,end:s}),{klines:u,name:c,code:m}=await M(t,X,l);return u.length===0?[]:u.map(d=>({...gr(d),code:m||e,name:c||""}))}async function Tn(t,e={}){let{pageSize:n=2e4}=e,r=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:Y,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${pt}?${r.toString()}`,i=(await t.get(o,{responseType:"json"}))?.list;return Array.isArray(i)?i.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:p(a.p),change:p(a.zde),changePercent:p(a.zdf),volume:p(a.vol),amount:p(a.cje),openInterest:p(a.ccl),strikePrice:p(a.xqj),remainDays:p(a.syr),dailyChange:p(a.rz),prevSettle:p(a.zjsj),open:p(a.o)})):[]}async function _n(t,e,n){let r=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:mt,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),o=`${dt}?${r.toString()}`,i=(await t.get(o,{responseType:"json"}))?.result?.data;if(!Array.isArray(i))return[];function a(l){if(!l)return"";let u=String(l),c=u.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:u}return i.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:p(l.MEMBER_RANK)??0,sellVolume:p(l.SELL_VOLUME),sellVolumeChange:p(l.SELL_VOLUME_CHANGE),netSellVolume:p(l.NET_SELL_VOLUME),sellVolumeRatio:p(l.SELL_VOLUME_RATIO),buyVolume:p(l.BUY_VOLUME),buyVolumeChange:p(l.BUY_VOLUME_CHANGE),netBuyVolume:p(l.NET_BUY_VOLUME),buyVolumeRatio:p(l.BUY_VOLUME_RATIO),sellPosition:p(l.SELL_POSITION),sellPositionChange:p(l.SELL_POSITION_CHANGE),netSellPosition:p(l.NET_SELL_POSITION),sellPositionRatio:p(l.SELL_POSITION_RATIO),buyPosition:p(l.BUY_POSITION),buyPositionChange:p(l.BUY_POSITION_CHANGE),netBuyPosition:p(l.NET_BUY_POSITION),buyPositionRatio:p(l.BUY_POSITION_RATIO)}))}var yr={gold:"EMI00069026",silver:"EMI00069027"};async function bn(t){let e=new URLSearchParams({reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageNumber:"1",pageSize:"500",source:"WEB",client:"WEB"}),n=`${N}?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.result?.data;return Array.isArray(o)?o.map(s=>({code:String(s.TRADE_CODE??""),name:String(s.TRADE_TYPE??""),marketCode:String(s.TRADE_MARKET_CODE??"")})):[]}function An(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function In(t,e,n={}){let{startDate:r="2020-10-28",pageSize:o=500}=n,s=e.toUpperCase(),i=[],a=1,l=1;do{let u=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${s}")(TRADE_DATE>='${r}')`,pageNumber:String(a),pageSize:String(o),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${N}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(l=d.pages??1);let f=d.data.map(h=>({code:String(h.SECURITY_CODE??e),date:An(h.TRADE_DATE),inventory:p(h.ON_WARRANT_NUM),change:p(h.ADDCHANGE)}));i.push(...f),a++}while(a<=l);return i}async function xn(t,e,n={}){let r=yr[e];if(!r)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:o=500}=n,s=[],i=1,a=1,l={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let u=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(o),pageNumber:String(i),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${r}")(@STORAGE_TON<>"NULL")`}),c=`${N}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;i===1&&(a=d.pages??1);let f=d.data.map(h=>({date:An(h.REPORT_DATE),name:l[e]??e,storageTon:p(h.STORAGE_TON),storageOunce:p(h.STORAGE_OUNCE)}));s.push(...f),i++}while(i<=a);return s}var P={};Be(P,{getCommodityOptionKline:()=>wn,getCommodityOptionSpot:()=>Nn,getETFOption5DayMinute:()=>Fn,getETFOptionDailyKline:()=>kn,getETFOptionExpireDay:()=>Un,getETFOptionMinute:()=>Kn,getETFOptionMonths:()=>Ln,getIndexOptionKline:()=>Pn,getIndexOptionSpot:()=>Mn});function Cr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Or(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function Mn(t,e){let n=`${Z}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,r=await _(n),o=r?.result?.data?.up??[],s=r?.result?.data?.down??[];return{calls:o.map(Cr),puts:s.map(Or)}}async function Pn(t){let e=`${J}?symbol=${t}`,n=await _(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}async function Ln(t){let e=`${at}?exchange=null&cate=${encodeURIComponent(t)}`,r=(await _(e))?.result?.data,o=r?.contractMonth??[];return{months:o.length>1?o.slice(1):o,stockId:r?.stockId??"",cateId:r?.cateId??"",cateList:r?.cateList??[]}}async function Un(t,e){let n=`${pe}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,r=await _(n),o=r?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let i=`${pe}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;r=await _(i)}let s=r?.result?.data;return{expireDay:s?.expireDay??"",remainderDays:s?.remainderDays??0,stockId:s?.stockId??"",name:s?.other?.name??""}}function Dn(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:p(n.p),volume:p(n.v),openInterest:p(n.t),avgPrice:p(n.a)}))}async function Kn(t){let e=`CON_OP_${t}`,n=`${lt}?symbol=${e}`,o=(await _(n))?.result?.data;return Array.isArray(o)?Dn(o):[]}async function kn(t){let e=`CON_OP_${t}`,n=`${ut}?symbol=${e}`,r=await _(n,{callbackMode:"path"});return Array.isArray(r)?r.map(o=>({date:o.d,open:p(o.o),high:p(o.h),low:p(o.l),close:p(o.c),volume:p(o.v)})):[]}async function Fn(t){let e=`CON_OP_${t}`,n=`${ct}?symbol=${e}`,o=(await _(n))?.result?.data;if(!Array.isArray(o))return[];let s=[];for(let i of o)Array.isArray(i)&&s.push(...Dn(i));return s}function Sr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Rr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function Nn(t,e){let n=de[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(de).join(", ")}`);let r=`${Z}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,o=await _(r),s=o?.result?.data?.up??[],i=o?.result?.data?.down??[];return{calls:s.map(Sr),puts:i.map(Rr)}}async function wn(t){let e=`${J}?symbol=${t}`,n=await _(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}function ie(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function H(t,e){let n=[];for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let o=0,s=0;for(let i=r-e+1;i<=r;i++)t[i]!==null&&(o+=t[i],s++);n.push(s===e?ie(o/e):null)}return n}function k(t,e){let n=[],r=2/(e+1),o=null,s=!1;for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}if(!s){let l=0,u=0;for(let c=i-e+1;c<=i;c++)t[c]!==null&&(l+=t[c],u++);u===e&&(o=l/e,s=!0),n.push(o!==null?ie(o):null);continue}let a=t[i];a===null?n.push(o!==null?ie(o):null):(o=r*a+(1-r)*o,n.push(ie(o)))}return n}function Ft(t,e){let n=[],r=Array.from({length:e},(s,i)=>i+1),o=r.reduce((s,i)=>s+i,0);for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let i=0,a=!0;for(let l=0;l<e;l++){let u=t[s-e+1+l];if(u===null){a=!1;break}i+=u*r[l]}n.push(a?ie(i/o):null)}return n}function Me(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:r="sma"}=e,o=r==="ema"?k:r==="wma"?Ft:H,s={};for(let i of n)s[`ma${i}`]=o(t,i);return t.map((i,a)=>{let l={};for(let u of n)l[`ma${u}`]=s[`ma${u}`][a];return l})}function Bn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Pe(t,e={}){let{short:n=12,long:r=26,signal:o=9}=e,s=k(t,n),i=k(t,r),a=t.map((u,c)=>s[c]===null||i[c]===null?null:s[c]-i[c]),l=k(a,o);return t.map((u,c)=>({dif:a[c]!==null?Bn(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?Bn((a[c]-l[c])*2):null}))}function Nt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Er(t,e,n){let r=[];for(let o=0;o<t.length;o++){if(o<e-1||n[o]===null){r.push(null);continue}let s=0,i=0;for(let a=o-e+1;a<=o;a++)t[a]!==null&&n[o]!==null&&(s+=Math.pow(t[a]-n[o],2),i++);r.push(i===e?Math.sqrt(s/e):null)}return r}function Le(t,e={}){let{period:n=20,stdDev:r=2}=e,o=H(t,n),s=Er(t,n,o);return t.map((i,a)=>{if(o[a]===null||s[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=o[a]+r*s[a],u=o[a]-r*s[a],c=o[a]!==0?Nt((l-u)/o[a]*100):null;return{mid:o[a],upper:Nt(l),lower:Nt(u),bandwidth:c}})}function wt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ue(t,e={}){let{period:n=9,kPeriod:r=3,dPeriod:o=3}=e,s=[],i=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){s.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,m=!0;for(let g=l-n+1;g<=l;g++){if(t[g].high===null||t[g].low===null){m=!1;break}u=Math.max(u,t[g].high),c=Math.min(c,t[g].low)}let d=t[l].close;if(!m||d===null||u===c){s.push({k:null,d:null,j:null});continue}let f=(d-c)/(u-c)*100;i=(r-1)/r*i+1/r*f,a=(o-1)/o*a+1/o*i;let h=3*i-2*a;s.push({k:wt(i),d:wt(a),j:wt(h)})}return s}function Tr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function De(t,e={}){let{periods:n=[6,12,24]}=e,r=[null];for(let s=1;s<t.length;s++)t[s]===null||t[s-1]===null?r.push(null):r.push(t[s]-t[s-1]);let o={};for(let s of n){let i=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<s){i.push(null),r[u]!==null&&(r[u]>0?a+=r[u]:l+=Math.abs(r[u]));continue}if(u===s)a=a/s,l=l/s;else{let c=r[u]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(s-1)+m)/s,l=(l*(s-1)+d)/s}if(l===0)i.push(100);else if(a===0)i.push(0);else{let c=a/l;i.push(Tr(100-100/(1+c)))}}o[`rsi${s}`]=i}return t.map((s,i)=>{let a={};for(let l of n)a[`rsi${l}`]=o[`rsi${l}`][i];return a})}function _r(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ke(t,e={}){let{periods:n=[6,10]}=e,r={};for(let o of n){let s=[];for(let i=0;i<t.length;i++){if(i<o-1){s.push(null);continue}let a=-1/0,l=1/0,u=!0;for(let d=i-o+1;d<=i;d++){if(t[d].high===null||t[d].low===null){u=!1;break}a=Math.max(a,t[d].high),l=Math.min(l,t[d].low)}let c=t[i].close;if(!u||c===null||a===l){s.push(null);continue}let m=(a-c)/(a-l)*100;s.push(_r(m))}r[`wr${o}`]=s}return t.map((o,s)=>{let i={};for(let a of n)i[`wr${a}`]=r[`wr${a}`][s];return i})}function br(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ke(t,e={}){let{periods:n=[6,12,24]}=e,r={};for(let o of n){let s=H(t,o),i=[];for(let a=0;a<t.length;a++)if(t[a]===null||s[a]===null||s[a]===0)i.push(null);else{let l=(t[a]-s[a])/s[a]*100;i.push(br(l))}r[`bias${o}`]=i}return t.map((o,s)=>{let i={};for(let a of n)i[`bias${a}`]=r[`bias${a}`][s];return i})}function Ar(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Fe(t,e={}){let{period:n=14}=e,r=[],o=t.map(s=>s.high===null||s.low===null||s.close===null?null:(s.high+s.low+s.close)/3);for(let s=0;s<t.length;s++){if(s<n-1){r.push({cci:null});continue}let i=0,a=0;for(let m=s-n+1;m<=s;m++)o[m]!==null&&(i+=o[m],a++);if(a!==n||o[s]===null){r.push({cci:null});continue}let l=i/n,u=0;for(let m=s-n+1;m<=s;m++)u+=Math.abs(o[m]-l);let c=u/n;if(c===0)r.push({cci:0});else{let m=(o[s]-l)/(.015*c);r.push({cci:Ar(m)})}}return r}function Bt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function V(t,e={}){let{period:n=14}=e,r=[],o=[];for(let i=0;i<t.length;i++){let{high:a,low:l,close:u}=t[i];if(a===null||l===null||u===null){o.push(null);continue}if(i===0)o.push(a-l);else{let c=t[i-1].close;if(c===null)o.push(a-l);else{let m=a-l,d=Math.abs(a-c),f=Math.abs(l-c);o.push(Math.max(m,d,f))}}}let s=null;for(let i=0;i<t.length;i++){if(i<n-1){r.push({tr:o[i]!==null?Bt(o[i]):null,atr:null});continue}if(i===n-1){let a=0,l=0;for(let u=0;u<n;u++)o[u]!==null&&(a+=o[u],l++);l===n&&(s=a/n)}else s!==null&&o[i]!==null&&(s=(s*(n-1)+o[i])/n);r.push({tr:o[i]!==null?Bt(o[i]):null,atr:s!==null?Bt(s):null})}return r}function vn(t,e={}){let{maPeriod:n}=e,r=[];if(t.length===0)return r;let o=t[0].volume??0;r.push({obv:o,obvMa:null});for(let s=1;s<t.length;s++){let i=t[s],a=t[s-1];if(i.close===null||a.close===null||i.volume===null||i.volume===void 0){r.push({obv:null,obvMa:null});continue}i.close>a.close?o+=i.volume:i.close<a.close&&(o-=i.volume),r.push({obv:o,obvMa:null})}if(n&&n>0)for(let s=n-1;s<r.length;s++){let i=0,a=0;for(let l=s-n+1;l<=s;l++)r[l].obv!==null&&(i+=r[l].obv,a++);a===n&&(r[s].obvMa=i/n)}return r}function Hn(t,e={}){let{period:n=12,signalPeriod:r}=e,o=[];for(let s=0;s<t.length;s++){if(s<n){o.push({roc:null,signal:null});continue}let i=t[s].close,a=t[s-n].close;if(i===null||a===null||a===0){o.push({roc:null,signal:null});continue}let l=(i-a)/a*100;o.push({roc:l,signal:null})}if(r&&r>0)for(let s=n+r-1;s<o.length;s++){let i=0,a=0;for(let l=s-r+1;l<=s;l++)o[l].roc!==null&&(i+=o[l].roc,a++);a===r&&(o[s].signal=i/r)}return o}function qn(t,e={}){let{period:n=14,adxPeriod:r=n}=e,o=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let s=[],i=[],a=[];for(let g=0;g<t.length;g++){if(g===0){s.push(0),i.push(0),a.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=t[g],E=t[g-1];if(O.high===null||O.low===null||O.close===null||E.high===null||E.low===null||E.close===null){s.push(0),i.push(0),a.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let b=O.high-O.low,K=Math.abs(O.high-E.close),W=Math.abs(O.low-E.close);a.push(Math.max(b,K,W));let F=O.high-E.high,q=E.low-O.low;F>q&&F>0?s.push(F):s.push(0),q>F&&q>0?i.push(q):i.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,u=0,c=0,m=[];for(let g=1;g<t.length;g++){if(g<n){l+=a[g],u+=s[g],c+=i[g],m.push(0);continue}g===n?(l=l,u=u,c=c):(l=l-l/n+a[g],u=u-u/n+s[g],c=c-c/n+i[g]);let O=l>0?u/l*100:0,E=l>0?c/l*100:0;o[g].pdi=O,o[g].mdi=E;let b=O+E,K=b>0?Math.abs(O-E)/b*100:0;m.push(K)}let d=0,f=0,h=0;for(let g=n;g<t.length;g++){if(g<n*2-1){d+=m[g-n+1]||0,f++;continue}if(g===n*2-1)d+=m[g-n+1]||0,h=d/r,o[g].adx=h;else{let O=m[g-n+1]||0;h=(h*(r-1)+O)/r,o[g].adx=h}}for(let g=n*2-1+r;g<t.length;g++){let O=o[g].adx,E=o[g-r]?.adx;O!==null&&E!==null&&(o[g].adxr=(O+E)/2)}return o}function jn(t,e={}){let{afStart:n=.02,afIncrement:r=.02,afMax:o=.2}=e,s=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=1,a=n,l=t[0].high??0,u=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(i=-1,l=c.low??0,u=c.high??0),s.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let f=t[d],h=t[d-1];if(f.high===null||f.low===null||h.high===null||h.low===null){s.push({sar:null,trend:null,ep:null,af:null});continue}let g=u+a*(l-u);i===1?(g=Math.min(g,h.low,t[Math.max(0,d-2)]?.low??h.low),f.low<g?(i=-1,g=l,l=f.low,a=n):f.high>l&&(l=f.high,a=Math.min(a+r,o))):(g=Math.max(g,h.high,t[Math.max(0,d-2)]?.high??h.high),f.high>g?(i=1,g=l,l=f.high,a=n):f.low<l&&(l=f.low,a=Math.min(a+r,o))),u=g,s.push({sar:u,trend:i,ep:l,af:a})}return s}function Qn(t,e={}){let{emaPeriod:n=20,atrPeriod:r=10,multiplier:o=2}=e,s=[],i=t.map(u=>u.close),a=k(i,n),l=V(t,{period:r});for(let u=0;u<t.length;u++){let c=a[u],m=l[u]?.atr;if(c===null||m===null){s.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+o*m,f=c-o*m,h=c>0?(d-f)/c*100:null;s.push({mid:c,upper:d,lower:f,width:h})}return s}function Ne(t,e={}){if(t.length===0)return[];let n=t.map(f=>f.close),r=t.map(f=>({open:f.open,high:f.high,low:f.low,close:f.close,volume:f.volume})),o=e.ma?Me(n,typeof e.ma=="object"?e.ma:{}):null,s=e.macd?Pe(n,typeof e.macd=="object"?e.macd:{}):null,i=e.boll?Le(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?Ue(r,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?De(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?Ke(r,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?ke(n,typeof e.bias=="object"?e.bias:{}):null,m=e.cci?Fe(r,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?V(r,typeof e.atr=="object"?e.atr:{}):null;return t.map((f,h)=>({...f,...o&&{ma:o[h]},...s&&{macd:s[h]},...i&&{boll:i[h]},...a&&{kdj:a[h]},...l&&{rsi:l[h]},...u&&{wr:u[h]},...c&&{bias:c[h]},...m&&{cci:m[h]},...d&&{atr:d[h]}}))}var we=class{constructor(e={}){this.client=new oe(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return R.getIndustryList(this.client)}getIndustrySpot(e){return R.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return R.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return R.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return R.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return R.getConceptList(this.client)}getConceptSpot(e){return R.getConceptSpot(this.client,e)}getConceptConstituents(e){return R.getConceptConstituents(this.client,e)}getConceptKline(e,n){return R.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return R.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return R.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return R.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return R.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return R.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}getFundCodeList(){return T.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...r}=e,o=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(o,r)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...r}=e,o=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,o,r)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return R.getDividendDetail(this.client,e)}getFuturesKline(e,n){return R.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return R.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return R.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return R.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return R.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return R.getComexInventory(this.client,e,n)}getIndexOptionSpot(e,n){return P.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return P.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return R.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return P.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return P.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return P.getETFOptionMinute(e)}getETFOptionDailyKline(e){return P.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return P.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return P.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return P.getCommodityOptionKline(e)}getOptionLHB(e,n){return R.getOptionLHB(this.client,e,n)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,r=!1;if(e.ma){let s=typeof e.ma=="object"?e.ma:{},i=s.periods??[5,10,20,30,60,120,250],a=s.type??"sma";n=Math.max(n,this.safeMax(i,20)),a==="ema"&&(r=!0)}if(e.macd){let s=typeof e.macd=="object"?e.macd:{},i=s.long??26,a=s.signal??9;n=Math.max(n,i*3+a),r=!0}if(e.boll){let s=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,s)}if(e.kdj){let s=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,s)}if(e.rsi){let s=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(s,14)+1)}if(e.wr){let s=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(s,10))}if(e.bias){let s=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(s,12))}if(e.cci){let s=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,s)}if(e.atr){let s=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,s)}return Math.ceil(n*(r?1.5:1.2))}calcActualStartDate(e,n,r=1.5){let o=Math.ceil(n*r),s=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));s.setDate(s.getDate()-o);let i=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${i}${a}${l}`}calcActualStartDateByCalendar(e,n,r){if(!r||r.length===0)return;let o=this.normalizeDate(e),s=r.findIndex(a=>a>=o);s===-1&&(s=r.length-1);let i=Math.max(0,s-n);return this.toCompactDate(r[i])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:r,endDate:o,indicators:s={}}=n,i=n.market??this.detectMarket(e),a=this.calcRequiredLookback(s),l={A:1.5,HK:1.46,US:1.45},u;if(r)if(i==="A")try{let f=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(r,a,f)??this.calcActualStartDate(r,a,l[i])}catch{u=this.calcActualStartDate(r,a,l[i])}else u=this.calcActualStartDate(r,a,l[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},m;switch(i){case"HK":m=await this.getHKHistoryKline(e,c);break;case"US":m=await this.getUSHistoryKline(e,c);break;default:m=await this.getHistoryKline(e,c)}if(r&&m.length<a)switch(i){case"HK":m=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=Ne(m,s);if(r){let f=this.dateToTimestamp(r),h=o?this.dateToTimestamp(o):1/0;return d.filter(g=>{let O=this.dateToTimestamp(g.date);return O>=f&&O<=h})}return d}},Ir=we;export{Q as HttpError,we as StockSDK,Ne as addIndicators,G as asyncPool,V as calcATR,ke as calcBIAS,Le as calcBOLL,Fe as calcCCI,qn as calcDMI,k as calcEMA,Qn as calcKC,Ue as calcKDJ,Me as calcMA,Pe as calcMACD,vn as calcOBV,Hn as calcROC,De as calcRSI,jn as calcSAR,H as calcSMA,Ft as calcWMA,Ke as calcWR,$ as chunkArray,ae as decodeGBK,Ir as default,Rt as extractJsonFromJsonp,_ as jsonpRequest,le as parseResponse,y as safeNumber,S as safeNumberOrNull};
|
|
1
|
+
var Gn=Object.defineProperty;var Fe=(t,e)=>{for(var n in e)Gn(t,n,{get:e[n],enumerable:!0})};function ae(t){return new TextDecoder("gbk").decode(t)}function le(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let r=i.indexOf("=");if(r<0)continue;let o=i.slice(0,r).trim();o.startsWith("v_")&&(o=o.slice(2));let s=i.slice(r+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");n.push({key:o,fields:a})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function S(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function R(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:R(String(t))}var ve="https://qt.gtimg.cn",we="https://web.ifzq.gtimg.cn/appstock/app/minute/query",He="https://assets.linkdiary.cn/shares/zh_a_list.json",qe="https://assets.linkdiary.cn/shares/us_list.json",je="https://assets.linkdiary.cn/shares/hk_list.json",Qe="https://assets.linkdiary.cn/shares/fund_list",Bt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ue="https://push2his.eastmoney.com/api/qt/stock/kline/get",$e="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ge="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",ze="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ve="https://17.push2.eastmoney.com/api/qt/clist/get",We="https://91.push2.eastmoney.com/api/qt/stock/get",Xe="https://29.push2.eastmoney.com/api/qt/clist/get",Ye="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Ze="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Je="https://79.push2.eastmoney.com/api/qt/clist/get",et="https://91.push2.eastmoney.com/api/qt/stock/get",tt="https://29.push2.eastmoney.com/api/qt/clist/get",nt="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",rt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",B="https://datacenter-web.eastmoney.com/api/data/v1/get",V="https://push2his.eastmoney.com/api/qt/stock/kline/get",ot="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",W="58b2fa8f54638b60b87d69b31969089c",it={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},H={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},ce={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},X="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",Y="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",st="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",pe="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",at="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",lt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",ut="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",ct="https://futsseapi.eastmoney.com/list/option/221",pt="https://datacenter-web.eastmoney.com/api/data/get",dt="b2884a393a59ad64002292a3e90d46a5";var de={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},mt=3e4,Z=500,J=500,ee=7,ft=3,gt=1e3,ht=3e4,yt=2,Rt=[408,429,500,502,503,504];var me=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Ft=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Ct=0;function zn(){return typeof window<"u"&&typeof window.document<"u"}function vt(){if(zn())return;let t=Ft[Ct];return Ct=(Ct+1)%Ft.length,t}var te=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},fe=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new te;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var q=class extends Error{constructor(n,i,r,o){let s=i?` ${i}`:"",a=r?`, url: ${r}`:"",l=o?`, provider: ${o}`:"";super(`HTTP error! status: ${n}${s}${a}${l}`);this.status=n;this.statusText=i;this.url=r;this.provider=o;this.name="HttpError"}},ne=class{constructor(e={}){this.baseUrl=e.baseUrl??ve;let n={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=this.resolveProviderPolicy(n),this.providerPolicies={},this.runtimeStates=new Map;for(let[i,r]of Object.entries(e.providerPolicies??{})){let o=this.mergeProviderPolicy(n,r);this.providerPolicies[i]=this.resolveProviderPolicy(o)}}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??ft,baseDelay:e?.baseDelay??gt,maxDelay:e?.maxDelay??ht,backoffMultiplier:e?.backoffMultiplier??yt,retryableStatusCodes:e?.retryableStatusCodes??Rt,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}normalizeHeaders(e,n){let i={...e??{}};return n&&(Object.keys(i).some(o=>o.toLowerCase()==="user-agent")||(i["User-Agent"]=n)),i}mergeProviderPolicy(e,n){return n?{timeout:n.timeout??e.timeout,retry:n.retry?{...e.retry??{},...n.retry}:e.retry?{...e.retry}:void 0,headers:{...e.headers??{},...n.headers??{}},userAgent:n.userAgent??e.userAgent,rateLimit:n.rateLimit?{...e.rateLimit??{},...n.rateLimit}:e.rateLimit?{...e.rateLimit}:void 0,rotateUserAgent:n.rotateUserAgent??e.rotateUserAgent,circuitBreaker:n.circuitBreaker?{...e.circuitBreaker??{},...n.circuitBreaker}:e.circuitBreaker?{...e.circuitBreaker}:void 0}:{...e,headers:{...e.headers??{}},retry:e.retry?{...e.retry}:void 0,rateLimit:e.rateLimit?{...e.rateLimit}:void 0,circuitBreaker:e.circuitBreaker?{...e.circuitBreaker}:void 0}}resolveProviderPolicy(e={}){return{timeout:e.timeout??mt,retry:this.resolveRetryOptions(e.retry),headers:this.normalizeHeaders(e.headers,e.userAgent),rotateUserAgent:e.rotateUserAgent??!1,rateLimit:e.rateLimit?{...e.rateLimit}:void 0,circuitBreaker:e.circuitBreaker?{...e.circuitBreaker}:void 0}}getProviderState(e){let n=this.runtimeStates.get(e);if(n)return n;let i=this.providerPolicies[e]??this.defaultPolicy,r={policy:i,rateLimiter:i.rateLimit?new me(i.rateLimit):null,circuitBreaker:i.circuitBreaker?new fe(i.circuitBreaker):null};return this.runtimeStates.set(e,r),r}inferProvider(e,n){if(n)return n;try{let i=new URL(e).hostname;if(i.includes("eastmoney.com"))return"eastmoney";if(i.includes("gtimg.cn"))return"tencent";if(i.includes("sina.com.cn"))return"sina";if(i.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}getTimeout(){return this.defaultPolicy.timeout}calculateDelay(e,n){return Math.min(n.baseDelay*Math.pow(n.backoffMultiplier,e),n.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n,i){return n>=i.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?i.retryOnTimeout:e instanceof TypeError?i.retryOnNetworkError:e instanceof q?i.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n,i,r=0){try{let o=await e();return n.circuitBreaker?.recordSuccess(),o}catch(o){if(this.shouldRetry(o,r,n.policy.retry)){let s=this.calculateDelay(r,n.policy.retry);return n.policy.retry.onRetry&&o instanceof Error&&n.policy.retry.onRetry(r+1,o,s),await this.sleep(s),this.executeWithRetry(e,n,i,r+1)}throw n.circuitBreaker?.recordFailure(),o instanceof Error&&(o.provider=i),o}}async get(e,n={}){let i=this.inferProvider(e,n.provider),r=this.getProviderState(i);if(r.circuitBreaker&&!r.circuitBreaker.canRequest())throw new te("Circuit breaker is OPEN, request rejected");return r.rateLimiter&&await r.rateLimiter.acquire(),this.executeWithRetry(async()=>{let o=new AbortController,s=setTimeout(()=>o.abort(),r.policy.timeout),a={...r.policy.headers};if(r.policy.rotateUserAgent){let l=vt();l&&(a["User-Agent"]=l)}try{let l=await fetch(e,{signal:o.signal,headers:a});if(!l.ok)throw new q(l.status,l.statusText,e,i);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=i),l}finally{clearTimeout(s)}},r,i)}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer",provider:"tencent"}),r=ae(i);return le(r)}};var Vn=new Set(["daily","weekly","monthly"]),Wn=new Set(["1","5","15","30","60"]),Xn=new Set(["","qfq","hfq"]);function K(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function I(t){if(!Vn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function re(t){if(!Wn.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function k(t){if(!Xn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function j(t,e){K(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function Q(t,e,n=!1){if(K(e,"concurrency"),t.length===0)return[];let i=n?new Array(t.length):[],r=0,o=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let s=r++;if(s>=t.length)return;let a=await t[s]();n?i[s]=a:i.push(a)}});return await Promise.all(o),i}function ge(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function M(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function N(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var Yn=typeof document<"u"&&typeof window<"u",Zn=0;function wt(){return`__stock_sdk_jsonp_${Date.now()}_${Zn++}`}function St(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let i=e.indexOf("(");if(i===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let r=e.lastIndexOf(")");if(r===-1||r<=i)throw new Error("Invalid JSONP response: no closing parenthesis found");let o=e.slice(i+1,r);return JSON.parse(o)}function Jn(t,e){let{timeout:n=15e3,callbackParam:i="callback",callbackMode:r="query"}=e;return new Promise((o,s)=>{let a=wt(),l;if(r==="path")l=t.replace("{callback}",a);else{let y=t.includes("?")?"&":"?";l=`${t}${y}${i}=${a}`}let u=document.createElement("script"),c=!1,m=window,d=()=>{u.parentNode&&u.parentNode.removeChild(u),delete m[a]},g=setTimeout(()=>{c||(c=!0,d(),s(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);m[a]=y=>{c||(c=!0,clearTimeout(g),d(),o(y))},u.onerror=()=>{c||(c=!0,clearTimeout(g),d(),s(new Error(`JSONP script load failed: ${t}`)))},u.src=l,document.head.appendChild(u)})}async function er(t,e){let{timeout:n=15e3,callbackParam:i="callback",callbackMode:r="query"}=e,o=wt(),s;if(r==="path")s=t.replace("{callback}",o);else{let u=t.includes("?")?"&":"?";s=`${t}${u}${i}=${o}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let u=await fetch(s,{signal:a.signal});if(!u.ok)throw new Error(`JSONP fetch failed with status ${u.status}: ${t}`);let c=await u.text();return St(c)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):u}finally{clearTimeout(l)}}function P(t,e={}){return Yn?Jn(t,e):er(t,e)}var b={};Fe(b,{getAShareCodeList:()=>Gt,getAllHKQuotesByCodes:()=>Xt,getAllQuotesByCodes:()=>Wt,getAllUSQuotesByCodes:()=>Yt,getFullQuotes:()=>he,getFundCodeList:()=>Zt,getFundFlow:()=>qt,getFundQuotes:()=>Qt,getHKCodeList:()=>Vt,getHKQuotes:()=>ye,getPanelLargeOrder:()=>jt,getSimpleQuotes:()=>Ht,getTodayTimeline:()=>$t,getTradingCalendar:()=>Jt,getUSCodeList:()=>zt,getUSQuotes:()=>Re,parseFullQuote:()=>Ot,parseFundFlow:()=>Et,parseFundQuote:()=>At,parseHKQuote:()=>bt,parsePanelLargeOrder:()=>_t,parseSimpleQuote:()=>Tt,parseUSQuote:()=>Pt,search:()=>tn});function Ot(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),pb:S(t[46]),limitUp:S(t[47]),limitDown:S(t[48]),volumeRatio:S(t[49]),avgPrice:S(t[51]),peStatic:S(t[52]),peDynamic:S(t[53]),high52w:S(t[67]),low52w:S(t[68]),circulatingShares:S(t[72]),totalShares:S(t[73]),raw:t}}function Tt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:S(t[9]),marketType:t[10]??"",raw:t}}function Et(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function _t(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function bt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:S(t[40]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),currency:t[t.length-3]??"",raw:t}}function Pt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),totalMarketCap:S(t[45]),pb:S(t[47]),high52w:S(t[48]),low52w:S(t[49]),raw:t}}function At(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function he(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>Ot(i.fields))}async function Ht(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Tt(r.fields))}async function qt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Et(r.fields))}async function jt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>_t(r.fields))}async function ye(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>bt(r.fields))}async function Re(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Pt(r.fields))}async function Qt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>At(r.fields))}async function $t(t,e){let n=t.getTimeout(),i=new AbortController,r=setTimeout(()=>i.abort(),n);try{let o=await fetch(`${we}?code=${e}`,{signal:i.signal});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(s.code!==0)throw new Error(s.msg||"API error");let a=s.data?.[e];if(!a)return{code:e,date:"",data:[]};let l=a.data?.data||[],u=a.data?.date||"",c=!1;if(l.length>0){let d=l[0].split(" "),g=parseFloat(d[1])||0,y=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;y>0&&g>0&&f/y>g*50&&(c=!0)}let m=l.map(d=>{let g=d.split(" "),y=g[0],f=`${y.slice(0,2)}:${y.slice(2,4)}`,C=parseInt(g[2],10)||0,O=parseFloat(g[3])||0,E=c?C*100:C,_=E>0?O/E:0;return{time:f,price:parseFloat(g[1])||0,volume:E,amount:O,avgPrice:Math.round(_*100)/100}});return{code:e,date:u,data:m}}finally{clearTimeout(r)}}var It=null,tr=null,Ce=null,nr=null,Se=null,Mt=null;function rr(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function Gt(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!It){let s=(await t.get(He,{responseType:"json"}))?.list||[];It=s,tr=s.map(a=>a.replace(/^(sh|sz|bj)/,""))}let r=It;return i&&(r=r.filter(o=>rr(o,i))),n?r.map(o=>o.replace(/^(sh|sz|bj)/,"")):r.slice()}var or={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function zt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),Ce||(Ce=(await t.get(qe,{responseType:"json"}))?.list||[],nr=Ce.map(s=>s.replace(/^\d{3}\./,"")));let r=Ce.slice();if(i){let o=or[i];r=r.filter(s=>s.startsWith(o))}return n?r.map(o=>o.replace(/^\d{3}\./,"")):r}async function Vt(t){return Se||(Se=(await t.get(je,{responseType:"json"}))?.list||[]),Se.slice()}async function Wt(t,e,n={}){let{batchSize:i=Z,concurrency:r=ee,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,J),a=j(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await he(t,d);return u++,o&&o(u,l),g});return(await Q(c,r,!0)).flat()}async function Xt(t,e,n={}){let{batchSize:i=Z,concurrency:r=ee,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,J),a=j(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await ye(t,d);return u++,o&&o(u,l),g});return(await Q(c,r,!0)).flat()}async function Yt(t,e,n={}){let{batchSize:i=Z,concurrency:r=ee,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,J),a=j(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await Re(t,d);return u++,o&&o(u,l),g});return(await Q(c,r,!0)).flat()}async function Zt(t){if(Mt)return Mt.slice();let i=(await t.get(Qe,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return Mt=i,i.slice()}var $=null;async function Jt(t){if($)return $.slice();let e=await t.get(Bt);return!e||e.trim()===""?($=[],$.slice()):($=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),$.slice())}var en="https://smartbox.gtimg.cn/s3/";function ir(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function sr(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),r=i[0]||"",o=i[1]||"",s=ir(i[2]||""),a=i[4]||"";return{code:r+o,name:s,market:r,type:a}})}function ar(t){return new Promise((e,n)=>{let i=`${en}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=i,r.charset="utf-8",r.onload=()=>{let o=window.v_hint||"";document.body.removeChild(r),e(o)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function lr(t,e){let n=`${en}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function ur(){return typeof window<"u"&&typeof document<"u"}async function tn(t,e){if(!e||!e.trim())return[];let n;return ur()?n=await ar(e):n=await lr(t,e),sr(n)}var T={};Fe(T,{extractVariety:()=>Lt,getCFFEXOptionQuotes:()=>In,getComexInventory:()=>Un,getConceptConstituents:()=>Sn,getConceptKline:()=>On,getConceptList:()=>Rn,getConceptMinuteKline:()=>Tn,getConceptSpot:()=>Cn,getDividendDetail:()=>En,getFuturesHistoryKline:()=>bn,getFuturesInventory:()=>Kn,getFuturesInventorySymbols:()=>xn,getFuturesMarketCode:()=>Kt,getGlobalFuturesKline:()=>An,getGlobalFuturesSpot:()=>Pn,getHKHistoryKline:()=>on,getHistoryKline:()=>nn,getIndustryConstituents:()=>gn,getIndustryKline:()=>hn,getIndustryList:()=>mn,getIndustryMinuteKline:()=>yn,getIndustrySpot:()=>fn,getMinuteKline:()=>rn,getOptionLHB:()=>Mn,getUSHistoryKline:()=>sn});async function xt(t,e,n,i,r=100,o){let s=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(r),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(l=d.total??0);let g=d.diff.map((y,f)=>o(y,s.length+f+1));s.push(...g),a++}while(s.length<l);return s}function x(t){let[e,n,i,r,o,s,a,l,u,c,m]=t.split(",");return{date:e,open:R(n),close:R(i),high:R(r),low:R(o),volume:R(s),amount:R(a),amplitude:R(l),changePercent:R(u),change:R(c),turnoverRate:R(m)}}async function L(t,e,n){let i=`${e}?${n.toString()}`,r=await t.get(i,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function nn(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:o="19700101",endDate:s="20500101"}=n;I(i),k(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${ge(e)}.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:N(r),secid:l,beg:o,end:s}),c=ue,{klines:m}=await L(t,c,u);return m.length===0?[]:m.map(d=>({...x(d),code:a}))}async function rn(t,e,n={}){let{period:i="1",adjust:r="qfq",startDate:o="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=n;re(i),k(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${ge(e)}.${a}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:l}),c=`${$e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let g=o.replace("T"," ").slice(0,16),y=s.replace("T"," ").slice(0,16);return d.map(f=>{let[C,O,E,_,z,D,w,$n]=f.split(",");return{time:C,open:R(O),close:R(E),high:R(_),low:R(z),volume:R(D),amount:R(w),avgPrice:R($n)}}).filter(f=>f.time>=g&&f.time<=y)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:N(r||""),secid:l,beg:"0",end:"20500000"}),c=ue,{klines:m}=await L(t,c,u);if(m.length===0)return[];let d=o.replace("T"," ").slice(0,16),g=s.replace("T"," ").slice(0,16);return m.map(y=>{let f=x(y);return{...f,time:f.date}}).filter(y=>y.time>=d&&y.time<=g)}}function Oe(t){return async function(n,i,r={}){let{period:o="daily",adjust:s="qfq",startDate:a="19700101",endDate:l="20500101"}=r;I(o),k(s);let u=t.normalizeSymbol(i),c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(o),fqt:N(s),secid:u.secid,beg:a,end:l,lmt:"1000000"}),{klines:m,name:d,code:g}=await L(n,t.url,c);if(m.length===0)return[];let y=t.resolveResultMeta?t.resolveResultMeta(i,u,{code:g,name:d}):{code:g||u.fallbackCode,name:d||""};return m.map(f=>({...x(f),code:y.code,name:y.name}))}}var cr=Oe({url:Ge,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function on(t,e,n={}){return cr(t,e,n)}var pr=Oe({url:ze,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:n.code||e.fallbackCode,name:n.name||""})});async function sn(t,e,n={}){return pr(t,e,n)}function an(t){let e=null;return{async getCode(n,i,r){if(i.startsWith("BK"))return i;if(!e){let s=await r(n);e=new Map(s.map(a=>[a.name,a.code]))}let o=e.get(i);if(!o)throw new Error(`${t.errorPrefix}: ${i}`);return o}}}async function ln(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await xt(t,e.listUrl,n,i,100,(o,s)=>({rank:s,name:String(o.f14??""),code:String(o.f12??""),price:p(o.f2),change:p(o.f4),changePercent:p(o.f3),totalMarketCap:p(o.f20),turnoverRate:p(o.f8),riseCount:p(o.f104),fallCount:p(o.f105),leadingStock:o.f128?String(o.f128):null,leadingStockChangePercent:p(o.f136)}));return r.sort((o,s)=>(s.changePercent??0)-(o.changePercent??0)),r.forEach((o,s)=>{o.rank=s+1}),r}async function un(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.data;return s?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:u,divide:c})=>{let m=s[l],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:u,value:d}}):[]}async function cn(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return xt(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(o,s)=>({rank:s,code:String(o.f12??""),name:String(o.f14??""),price:p(o.f2),changePercent:p(o.f3),change:p(o.f4),volume:p(o.f5),amount:p(o.f6),amplitude:p(o.f7),high:p(o.f15),low:p(o.f16),open:p(o.f17),prevClose:p(o.f18),turnoverRate:p(o.f8),pe:p(o.f9),pb:p(o.f23)}))}async function pn(t,e,n,i={}){let{period:r="daily",adjust:o="",startDate:s="19700101",endDate:a="20500101"}=i;I(r),k(o);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:M(r),fqt:N(o),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await L(t,n,l);return u.length===0?[]:u.map(c=>x(c))}async function dn(t,e,n,i,r={}){let{period:o="5"}=r;if(re(o),o==="1"){let s=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${i}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,g,y,f,C,O,E]=c.split(",");return{time:m,open:R(d),close:R(g),high:R(y),low:R(f),volume:R(C),amount:R(O),price:R(E)}})}else{let s=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:o,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,g,y,f,C,O,E,_,z,D]=c.split(",");return{time:m,open:R(d),close:R(g),high:R(y),low:R(f),changePercent:R(_),change:R(z),volume:R(C),amount:R(O),amplitude:R(E),turnoverRate:R(D)}})}}function Te(t){let e=an(t);async function n(r){return ln(r,t)}async function i(r,o){return e.getCode(r,o,n)}return{async getList(r){return n(r)},async getSpot(r,o){let s=await i(r,o);return un(r,s,t.spotUrl)},async getConstituents(r,o){let s=await i(r,o);return cn(r,s,t.consUrl)},async getKline(r,o,s={}){let a=await i(r,o);return pn(r,a,t.klineUrl,s)},async getMinuteKline(r,o,s={}){let a=await i(r,o);return dn(r,a,t.klineUrl,t.trendsUrl,s)}}}var dr={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ve,spotUrl:We,consUrl:Xe,klineUrl:Ye,trendsUrl:Ze,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},oe=Te(dr);async function mn(t){return oe.getList(t)}async function fn(t,e){return oe.getSpot(t,e)}async function gn(t,e){return oe.getConstituents(t,e)}async function hn(t,e,n={}){return oe.getKline(t,e,n)}async function yn(t,e,n={}){return oe.getMinuteKline(t,e,n)}var mr={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Je,spotUrl:et,consUrl:tt,klineUrl:nt,trendsUrl:rt,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ie=Te(mr);async function Rn(t){return ie.getList(t)}async function Cn(t,e){return ie.getSpot(t,e)}async function Sn(t,e){return ie.getConstituents(t,e)}async function On(t,e,n={}){return ie.getKline(t,e,n)}async function Tn(t,e,n={}){return ie.getMinuteKline(t,e,n)}function F(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function fr(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:F(t.REPORT_DATE),planNoticeDate:F(t.PLAN_NOTICE_DATE),disclosureDate:F(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:F(t.EQUITY_RECORD_DATE),exDividendDate:F(t.EX_DIVIDEND_DATE),payDate:F(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:F(t.NOTICE_DATE)}}async function En(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],r=1,o=1;do{let s=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),a=`${B}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(o=u.pages??1);let c=u.data.map(fr);i.push(...c),r++}while(r<=o);return i}function Lt(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function _n(t){return H[t]??H[t.toLowerCase()]??H[t.toUpperCase()]}function Kt(t){let e=_n(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=_n(t.slice(0,-1))),!e){let i=Object.keys(H).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${i}`)}let n=it[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function gr(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?R(n[12]):null}}async function bn(t,e,n={}){let{period:i="daily",startDate:r="19700101",endDate:o="20500101"}=n;I(i);let s=Lt(e),l=`${Kt(s)}.${e}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:"0",secid:l,beg:r,end:o}),{klines:c,name:m,code:d}=await L(t,V,u);return c.length===0?[]:c.map(g=>({...gr(g),code:d||e,name:m||""}))}async function Pn(t,e={}){let n=e.pageSize??20,i=[],r=0,o=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(r),token:W,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${ot}?${s.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;r===0&&(o=l.total??0);let u=l.list.map(hr);i.push(...u),r++}while(i.length<o);return i}function hr(t){return{code:t.dm||"",name:t.name||"",price:R(String(t.p)),change:R(String(t.zde)),changePercent:R(String(t.zdf)),open:R(String(t.o)),high:R(String(t.h)),low:R(String(t.l)),prevSettle:R(String(t.zjsj)),volume:R(String(t.vol)),buyVolume:R(String(t.wp)),sellVolume:R(String(t.np)),openInterest:R(String(t.ccl))}}function yr(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?R(n[12]):null}}function Rr(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function An(t,e,n={}){let{period:i="daily",startDate:r="19700101",endDate:o="20500101"}=n;I(i);let s=n.marketCode;if(s===void 0){let d=Rr(e);if(s=ce[d],s===void 0){let g=Object.keys(ce).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${g}. Or specify marketCode manually via options.`)}}let a=`${s}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:"0",secid:a,beg:r,end:o}),{klines:u,name:c,code:m}=await L(t,V,l);return u.length===0?[]:u.map(d=>({...yr(d),code:m||e,name:c||""}))}async function In(t,e={}){let{pageSize:n=2e4}=e,i=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:W,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),r=`${ct}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.list;return Array.isArray(s)?s.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:p(a.p),change:p(a.zde),changePercent:p(a.zdf),volume:p(a.vol),amount:p(a.cje),openInterest:p(a.ccl),strikePrice:p(a.xqj),remainDays:p(a.syr),dailyChange:p(a.rz),prevSettle:p(a.zjsj),open:p(a.o)})):[]}async function Mn(t,e,n){let i=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:dt,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),r=`${pt}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function a(l){if(!l)return"";let u=String(l),c=u.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:u}return s.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:p(l.MEMBER_RANK)??0,sellVolume:p(l.SELL_VOLUME),sellVolumeChange:p(l.SELL_VOLUME_CHANGE),netSellVolume:p(l.NET_SELL_VOLUME),sellVolumeRatio:p(l.SELL_VOLUME_RATIO),buyVolume:p(l.BUY_VOLUME),buyVolumeChange:p(l.BUY_VOLUME_CHANGE),netBuyVolume:p(l.NET_BUY_VOLUME),buyVolumeRatio:p(l.BUY_VOLUME_RATIO),sellPosition:p(l.SELL_POSITION),sellPositionChange:p(l.SELL_POSITION_CHANGE),netSellPosition:p(l.NET_SELL_POSITION),sellPositionRatio:p(l.SELL_POSITION_RATIO),buyPosition:p(l.BUY_POSITION),buyPositionChange:p(l.BUY_POSITION_CHANGE),netBuyPosition:p(l.NET_BUY_POSITION),buyPositionRatio:p(l.BUY_POSITION_RATIO)}))}var Cr={gold:"EMI00069026",silver:"EMI00069027"};async function xn(t){let e=new URLSearchParams({reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageNumber:"1",pageSize:"500",source:"WEB",client:"WEB"}),n=`${B}?${e.toString()}`,r=(await t.get(n,{responseType:"json"}))?.result?.data;return Array.isArray(r)?r.map(o=>({code:String(o.TRADE_CODE??""),name:String(o.TRADE_TYPE??""),marketCode:String(o.TRADE_MARKET_CODE??"")})):[]}function Ln(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function Kn(t,e,n={}){let{startDate:i="2020-10-28",pageSize:r=500}=n,o=e.toUpperCase(),s=[],a=1,l=1;do{let u=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${o}")(TRADE_DATE>='${i}')`,pageNumber:String(a),pageSize:String(r),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${B}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(l=d.pages??1);let g=d.data.map(y=>({code:String(y.SECURITY_CODE??e),date:Ln(y.TRADE_DATE),inventory:p(y.ON_WARRANT_NUM),change:p(y.ADDCHANGE)}));s.push(...g),a++}while(a<=l);return s}async function Un(t,e,n={}){let i=Cr[e];if(!i)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:r=500}=n,o=[],s=1,a=1,l={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let u=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(r),pageNumber:String(s),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${i}")(@STORAGE_TON<>"NULL")`}),c=`${B}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;s===1&&(a=d.pages??1);let g=d.data.map(y=>({date:Ln(y.REPORT_DATE),name:l[e]??e,storageTon:p(y.STORAGE_TON),storageOunce:p(y.STORAGE_OUNCE)}));o.push(...g),s++}while(s<=a);return o}var A={};Fe(A,{getCommodityOptionKline:()=>jn,getCommodityOptionSpot:()=>qn,getETFOption5DayMinute:()=>Hn,getETFOptionDailyKline:()=>wn,getETFOptionExpireDay:()=>Bn,getETFOptionMinute:()=>vn,getETFOptionMonths:()=>Nn,getIndexOptionKline:()=>kn,getIndexOptionSpot:()=>Dn});function Sr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Or(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function Dn(t,e){let n=`${X}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,i=await P(n),r=i?.result?.data?.up??[],o=i?.result?.data?.down??[];return{calls:r.map(Sr),puts:o.map(Or)}}async function kn(t){let e=`${Y}?symbol=${t}`,n=await P(e,{callbackMode:"path"});return Array.isArray(n)?n.map(i=>({date:i.d,open:p(i.o),high:p(i.h),low:p(i.l),close:p(i.c),volume:p(i.v)})):[]}async function Nn(t){let e=`${st}?exchange=null&cate=${encodeURIComponent(t)}`,i=(await P(e))?.result?.data,r=i?.contractMonth??[];return{months:r.length>1?r.slice(1):r,stockId:i?.stockId??"",cateId:i?.cateId??"",cateList:i?.cateList??[]}}async function Bn(t,e){let n=`${pe}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,i=await P(n),r=i?.result?.data?.remainderDays;if(typeof r=="number"&&r<0){let s=`${pe}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;i=await P(s)}let o=i?.result?.data;return{expireDay:o?.expireDay??"",remainderDays:o?.remainderDays??0,stockId:o?.stockId??"",name:o?.other?.name??""}}function Fn(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:p(n.p),volume:p(n.v),openInterest:p(n.t),avgPrice:p(n.a)}))}async function vn(t){let e=`CON_OP_${t}`,n=`${at}?symbol=${e}`,r=(await P(n))?.result?.data;return Array.isArray(r)?Fn(r):[]}async function wn(t){let e=`CON_OP_${t}`,n=`${lt}?symbol=${e}`,i=await P(n,{callbackMode:"path"});return Array.isArray(i)?i.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}async function Hn(t){let e=`CON_OP_${t}`,n=`${ut}?symbol=${e}`,r=(await P(n))?.result?.data;if(!Array.isArray(r))return[];let o=[];for(let s of r)Array.isArray(s)&&o.push(...Fn(s));return o}function Tr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Er(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function qn(t,e){let n=de[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(de).join(", ")}`);let i=`${X}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,r=await P(i),o=r?.result?.data?.up??[],s=r?.result?.data?.down??[];return{calls:o.map(Tr),puts:s.map(Er)}}async function jn(t){let e=`${Y}?symbol=${t}`,n=await P(e,{callbackMode:"path"});return Array.isArray(n)?n.map(i=>({date:i.d,open:p(i.o),high:p(i.h),low:p(i.l),close:p(i.c),volume:p(i.v)})):[]}function se(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function v(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let r=0,o=0;for(let s=i-e+1;s<=i;s++)t[s]!==null&&(r+=t[s],o++);n.push(o===e?se(r/e):null)}return n}function U(t,e){let n=[],i=2/(e+1),r=null,o=!1;for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}if(!o){let l=0,u=0;for(let c=s-e+1;c<=s;c++)t[c]!==null&&(l+=t[c],u++);u===e&&(r=l/e,o=!0),n.push(r!==null?se(r):null);continue}let a=t[s];a===null?n.push(r!==null?se(r):null):(r=i*a+(1-i)*r,n.push(se(r)))}return n}function Ut(t,e){let n=[],i=Array.from({length:e},(o,s)=>s+1),r=i.reduce((o,s)=>o+s,0);for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}let s=0,a=!0;for(let l=0;l<e;l++){let u=t[o-e+1+l];if(u===null){a=!1;break}s+=u*i[l]}n.push(a?se(s/r):null)}return n}function Ee(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,r=i==="ema"?U:i==="wma"?Ut:v,o={};for(let s of n)o[`ma${s}`]=r(t,s);return t.map((s,a)=>{let l={};for(let u of n)l[`ma${u}`]=o[`ma${u}`][a];return l})}function Qn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function _e(t,e={}){let{short:n=12,long:i=26,signal:r=9}=e,o=U(t,n),s=U(t,i),a=t.map((u,c)=>o[c]===null||s[c]===null?null:o[c]-s[c]),l=U(a,r);return t.map((u,c)=>({dif:a[c]!==null?Qn(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?Qn((a[c]-l[c])*2):null}))}function Dt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function _r(t,e,n){let i=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){i.push(null);continue}let o=0,s=0;for(let a=r-e+1;a<=r;a++)t[a]!==null&&n[r]!==null&&(o+=Math.pow(t[a]-n[r],2),s++);i.push(s===e?Math.sqrt(o/e):null)}return i}function be(t,e={}){let{period:n=20,stdDev:i=2}=e,r=v(t,n),o=_r(t,n,r);return t.map((s,a)=>{if(r[a]===null||o[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=r[a]+i*o[a],u=r[a]-i*o[a],c=r[a]!==0?Dt((l-u)/r[a]*100):null;return{mid:r[a],upper:Dt(l),lower:Dt(u),bandwidth:c}})}function kt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Pe(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:r=3}=e,o=[],s=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){o.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,m=!0;for(let f=l-n+1;f<=l;f++){if(t[f].high===null||t[f].low===null){m=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[l].close;if(!m||d===null||u===c){o.push({k:null,d:null,j:null});continue}let g=(d-c)/(u-c)*100;s=(i-1)/i*s+1/i*g,a=(r-1)/r*a+1/r*s;let y=3*s-2*a;o.push({k:kt(s),d:kt(a),j:kt(y)})}return o}function br(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ae(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let o=1;o<t.length;o++)t[o]===null||t[o-1]===null?i.push(null):i.push(t[o]-t[o-1]);let r={};for(let o of n){let s=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<o){s.push(null),i[u]!==null&&(i[u]>0?a+=i[u]:l+=Math.abs(i[u]));continue}if(u===o)a=a/o,l=l/o;else{let c=i[u]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(o-1)+m)/o,l=(l*(o-1)+d)/o}if(l===0)s.push(100);else if(a===0)s.push(0);else{let c=a/l;s.push(br(100-100/(1+c)))}}r[`rsi${o}`]=s}return t.map((o,s)=>{let a={};for(let l of n)a[`rsi${l}`]=r[`rsi${l}`][s];return a})}function Pr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ie(t,e={}){let{periods:n=[6,10]}=e,i={};for(let r of n){let o=[];for(let s=0;s<t.length;s++){if(s<r-1){o.push(null);continue}let a=-1/0,l=1/0,u=!0;for(let d=s-r+1;d<=s;d++){if(t[d].high===null||t[d].low===null){u=!1;break}a=Math.max(a,t[d].high),l=Math.min(l,t[d].low)}let c=t[s].close;if(!u||c===null||a===l){o.push(null);continue}let m=(a-c)/(a-l)*100;o.push(Pr(m))}i[`wr${r}`]=o}return t.map((r,o)=>{let s={};for(let a of n)s[`wr${a}`]=i[`wr${a}`][o];return s})}function Ar(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Me(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let r of n){let o=v(t,r),s=[];for(let a=0;a<t.length;a++)if(t[a]===null||o[a]===null||o[a]===0)s.push(null);else{let l=(t[a]-o[a])/o[a]*100;s.push(Ar(l))}i[`bias${r}`]=s}return t.map((r,o)=>{let s={};for(let a of n)s[`bias${a}`]=i[`bias${a}`][o];return s})}function Ir(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function xe(t,e={}){let{period:n=14}=e,i=[],r=t.map(o=>o.high===null||o.low===null||o.close===null?null:(o.high+o.low+o.close)/3);for(let o=0;o<t.length;o++){if(o<n-1){i.push({cci:null});continue}let s=0,a=0;for(let m=o-n+1;m<=o;m++)r[m]!==null&&(s+=r[m],a++);if(a!==n||r[o]===null){i.push({cci:null});continue}let l=s/n,u=0;for(let m=o-n+1;m<=o;m++)u+=Math.abs(r[m]-l);let c=u/n;if(c===0)i.push({cci:0});else{let m=(r[o]-l)/(.015*c);i.push({cci:Ir(m)})}}return i}function Nt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function G(t,e={}){let{period:n=14}=e,i=[],r=[];for(let s=0;s<t.length;s++){let{high:a,low:l,close:u}=t[s];if(a===null||l===null||u===null){r.push(null);continue}if(s===0)r.push(a-l);else{let c=t[s-1].close;if(c===null)r.push(a-l);else{let m=a-l,d=Math.abs(a-c),g=Math.abs(l-c);r.push(Math.max(m,d,g))}}}let o=null;for(let s=0;s<t.length;s++){if(s<n-1){i.push({tr:r[s]!==null?Nt(r[s]):null,atr:null});continue}if(s===n-1){let a=0,l=0;for(let u=0;u<n;u++)r[u]!==null&&(a+=r[u],l++);l===n&&(o=a/n)}else o!==null&&r[s]!==null&&(o=(o*(n-1)+r[s])/n);i.push({tr:r[s]!==null?Nt(r[s]):null,atr:o!==null?Nt(o):null})}return i}function Le(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let r=t[0].volume??0;i.push({obv:r,obvMa:null});for(let o=1;o<t.length;o++){let s=t[o],a=t[o-1];if(s.close===null||a.close===null||s.volume===null||s.volume===void 0){i.push({obv:null,obvMa:null});continue}s.close>a.close?r+=s.volume:s.close<a.close&&(r-=s.volume),i.push({obv:r,obvMa:null})}if(n&&n>0)for(let o=n-1;o<i.length;o++){let s=0,a=0;for(let l=o-n+1;l<=o;l++)i[l].obv!==null&&(s+=i[l].obv,a++);a===n&&(i[o].obvMa=s/n)}return i}function Ke(t,e={}){let{period:n=12,signalPeriod:i}=e,r=[];for(let o=0;o<t.length;o++){if(o<n){r.push({roc:null,signal:null});continue}let s=t[o].close,a=t[o-n].close;if(s===null||a===null||a===0){r.push({roc:null,signal:null});continue}let l=(s-a)/a*100;r.push({roc:l,signal:null})}if(i&&i>0)for(let o=n+i-1;o<r.length;o++){let s=0,a=0;for(let l=o-i+1;l<=o;l++)r[l].roc!==null&&(s+=r[l].roc,a++);a===i&&(r[o].signal=s/i)}return r}function Ue(t,e={}){let{period:n=14,adxPeriod:i=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let o=[],s=[],a=[];for(let f=0;f<t.length;f++){if(f===0){o.push(0),s.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],O=t[f-1];if(C.high===null||C.low===null||C.close===null||O.high===null||O.low===null||O.close===null){o.push(0),s.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let E=C.high-C.low,_=Math.abs(C.high-O.close),z=Math.abs(C.low-O.close);a.push(Math.max(E,_,z));let D=C.high-O.high,w=O.low-C.low;D>w&&D>0?o.push(D):o.push(0),w>D&&w>0?s.push(w):s.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,u=0,c=0,m=[];for(let f=1;f<t.length;f++){if(f<n){l+=a[f],u+=o[f],c+=s[f],m.push(0);continue}f===n?(l=l,u=u,c=c):(l=l-l/n+a[f],u=u-u/n+o[f],c=c-c/n+s[f]);let C=l>0?u/l*100:0,O=l>0?c/l*100:0;r[f].pdi=C,r[f].mdi=O;let E=C+O,_=E>0?Math.abs(C-O)/E*100:0;m.push(_)}let d=0,g=0,y=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=m[f-n+1]||0,g++;continue}if(f===n*2-1)d+=m[f-n+1]||0,y=d/i,r[f].adx=y;else{let C=m[f-n+1]||0;y=(y*(i-1)+C)/i,r[f].adx=y}}for(let f=n*2-1+i;f<t.length;f++){let C=r[f].adx,O=r[f-i]?.adx;C!==null&&O!==null&&(r[f].adxr=(C+O)/2)}return r}function De(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:r=.2}=e,o=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,a=n,l=t[0].high??0,u=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(s=-1,l=c.low??0,u=c.high??0),o.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let g=t[d],y=t[d-1];if(g.high===null||g.low===null||y.high===null||y.low===null){o.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+a*(l-u);s===1?(f=Math.min(f,y.low,t[Math.max(0,d-2)]?.low??y.low),g.low<f?(s=-1,f=l,l=g.low,a=n):g.high>l&&(l=g.high,a=Math.min(a+i,r))):(f=Math.max(f,y.high,t[Math.max(0,d-2)]?.high??y.high),g.high>f?(s=1,f=l,l=g.high,a=n):g.low<l&&(l=g.low,a=Math.min(a+i,r))),u=f,o.push({sar:u,trend:s,ep:l,af:a})}return o}function ke(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:r=2}=e,o=[],s=t.map(u=>u.close),a=U(s,n),l=G(t,{period:i});for(let u=0;u<t.length;u++){let c=a[u],m=l[u]?.atr;if(c===null||m===null){o.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*m,g=c-r*m,y=c>0?(d-g)/c*100:null;o.push({mid:c,upper:d,lower:g,width:y})}return o}function Ne(t,e={}){if(t.length===0)return[];let n=t.map(E=>E.close),i=t.map(E=>({open:E.open,high:E.high,low:E.low,close:E.close,volume:E.volume})),r=e.ma?Ee(n,typeof e.ma=="object"?e.ma:{}):null,o=e.macd?_e(n,typeof e.macd=="object"?e.macd:{}):null,s=e.boll?be(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?Pe(i,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?Ae(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?Ie(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?Me(n,typeof e.bias=="object"?e.bias:{}):null,m=e.cci?xe(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?G(i,typeof e.atr=="object"?e.atr:{}):null,g=e.obv?Le(i,typeof e.obv=="object"?e.obv:{}):null,y=e.roc?Ke(i,typeof e.roc=="object"?e.roc:{}):null,f=e.dmi?Ue(i,typeof e.dmi=="object"?e.dmi:{}):null,C=e.sar?De(i,typeof e.sar=="object"?e.sar:{}):null,O=e.kc?ke(i,typeof e.kc=="object"?e.kc:{}):null;return t.map((E,_)=>({...E,...r&&{ma:r[_]},...o&&{macd:o[_]},...s&&{boll:s[_]},...a&&{kdj:a[_]},...l&&{rsi:l[_]},...u&&{wr:u[_]},...c&&{bias:c[_]},...m&&{cci:m[_]},...d&&{atr:d[_]},...g&&{obv:g[_]},...y&&{roc:y[_]},...f&&{dmi:f[_]},...C&&{sar:C[_]},...O&&{kc:O[_]}}))}var Be=class{constructor(e={}){this.client=new ne(e)}getFullQuotes(e){return b.getFullQuotes(this.client,e)}getSimpleQuotes(e){return b.getSimpleQuotes(this.client,e)}getHKQuotes(e){return b.getHKQuotes(this.client,e)}getUSQuotes(e){return b.getUSQuotes(this.client,e)}getFundQuotes(e){return b.getFundQuotes(this.client,e)}getFundFlow(e){return b.getFundFlow(this.client,e)}getPanelLargeOrder(e){return b.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return b.getTodayTimeline(this.client,e)}getIndustryList(){return T.getIndustryList(this.client)}getIndustrySpot(e){return T.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return T.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return T.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return T.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return T.getConceptList(this.client)}getConceptSpot(e){return T.getConceptSpot(this.client,e)}getConceptConstituents(e){return T.getConceptConstituents(this.client,e)}getConceptKline(e,n){return T.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return T.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return T.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return T.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return T.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return T.getUSHistoryKline(this.client,e,n)}search(e){return b.search(this.client,e)}getAShareCodeList(e){return b.getAShareCodeList(this.client,e)}getUSCodeList(e){return b.getUSCodeList(this.client,e)}getHKCodeList(){return b.getHKCodeList(this.client)}getFundCodeList(){return b.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return b.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,r=await this.getUSCodeList({simple:!0,market:n});return b.getAllUSQuotesByCodes(this.client,r,i)}getAllQuotesByCodes(e,n={}){return b.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return b.getTradingCalendar(this.client)}getDividendDetail(e){return T.getDividendDetail(this.client,e)}getFuturesKline(e,n){return T.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return T.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return T.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return T.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return T.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return T.getComexInventory(this.client,e,n)}getIndexOptionSpot(e,n){return A.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return A.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return T.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return A.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return A.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return A.getETFOptionMinute(e)}getETFOptionDailyKline(e){return A.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return A.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return A.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return A.getCommodityOptionKline(e)}getOptionLHB(e,n){return T.getOptionLHB(this.client,e,n)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let o=typeof e.ma=="object"?e.ma:{},s=o.periods??[5,10,20,30,60,120,250],a=o.type??"sma";n=Math.max(n,this.safeMax(s,20)),a==="ema"&&(i=!0)}if(e.macd){let o=typeof e.macd=="object"?e.macd:{},s=o.long??26,a=o.signal??9;n=Math.max(n,s*3+a),i=!0}if(e.boll){let o=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,o)}if(e.kdj){let o=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,o)}if(e.rsi){let o=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(o,14)+1)}if(e.wr){let o=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(o,10))}if(e.bias){let o=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(o,12))}if(e.cci){let o=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,o)}if(e.atr){let o=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,o)}if(e.obv){let o=typeof e.obv=="object"&&e.obv.maPeriod?e.obv.maPeriod:0;n=Math.max(n,Math.max(2,o))}if(e.roc){let o=typeof e.roc=="object"?e.roc:{},s=o.period??12,a=o.signalPeriod??0;n=Math.max(n,s+a)}if(e.dmi){let o=typeof e.dmi=="object"?e.dmi:{},s=o.period??14,a=o.adxPeriod??s;n=Math.max(n,s*2+a)}if(e.sar&&(n=Math.max(n,5)),e.kc){let o=typeof e.kc=="object"?e.kc:{},s=o.emaPeriod??20,a=o.atrPeriod??10;n=Math.max(n,Math.max(s*3,a)),i=!0}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let r=Math.ceil(n*i),o=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));o.setDate(o.getDate()-r);let s=o.getFullYear(),a=String(o.getMonth()+1).padStart(2,"0"),l=String(o.getDate()).padStart(2,"0");return`${s}${a}${l}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let r=this.normalizeDate(e),o=i.findIndex(a=>a>=r);o===-1&&(o=i.length-1);let s=Math.max(0,o-n);return this.toCompactDate(i[s])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:r,indicators:o={}}=n,s=n.market??this.detectMarket(e),a=this.calcRequiredLookback(o),l={A:1.5,HK:1.46,US:1.45},u;if(i)if(s==="A")try{let g=await b.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,a,g)??this.calcActualStartDate(i,a,l[s])}catch{u=this.calcActualStartDate(i,a,l[s])}else u=this.calcActualStartDate(i,a,l[s]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},m;switch(s){case"HK":m=await this.getHKHistoryKline(e,c);break;case"US":m=await this.getUSHistoryKline(e,c);break;default:m=await this.getHistoryKline(e,c)}if(i&&m.length<a)switch(s){case"HK":m=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=Ne(m,o);if(i){let g=this.dateToTimestamp(i),y=r?this.dateToTimestamp(r):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=g&&C<=y})}return d}},Mr=Be;export{q as HttpError,Be as StockSDK,Ne as addIndicators,Q as asyncPool,G as calcATR,Me as calcBIAS,be as calcBOLL,xe as calcCCI,Ue as calcDMI,U as calcEMA,ke as calcKC,Pe as calcKDJ,Ee as calcMA,_e as calcMACD,Le as calcOBV,Ke as calcROC,Ae as calcRSI,De as calcSAR,v as calcSMA,Ut as calcWMA,Ie as calcWR,j as chunkArray,ae as decodeGBK,Mr as default,St as extractJsonFromJsonp,P as jsonpRequest,le as parseResponse,h as safeNumber,S as safeNumberOrNull};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stock-sdk",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
"test": "vitest run",
|
|
11
11
|
"test:unit": "vitest run",
|
|
12
12
|
"test:integration": "RUN_INTEGRATION=1 vitest run",
|
|
13
|
+
"docs:meta": "node ./scripts/generate-doc-meta.js",
|
|
14
|
+
"docs:check": "node ./scripts/check-doc-consistency.js",
|
|
13
15
|
"dev": "vitepress dev website",
|
|
14
16
|
"preview": "vitepress preview website",
|
|
15
|
-
"build:docs": "DOCS_BASE=/ vitepress build website",
|
|
16
|
-
"build:pages": "DOCS_BASE=/stock-sdk/ vitepress build website"
|
|
17
|
+
"build:docs": "yarn docs:meta && DOCS_BASE=/ vitepress build website",
|
|
18
|
+
"build:pages": "yarn docs:meta && DOCS_BASE=/stock-sdk/ vitepress build website"
|
|
17
19
|
},
|
|
18
20
|
"exports": {
|
|
19
21
|
".": {
|