stock-sdk 1.8.3 → 1.9.0
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 +54 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +856 -1
- package/dist/index.d.ts +856 -1
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -58,7 +58,10 @@
|
|
|
58
58
|
- ✅ **技术指标**:内置 MA、MACD、BOLL、KDJ、RSI、WR、BIAS、CCI、ATR、OBV、ROC、DMI、SAR、KC
|
|
59
59
|
- ✅ **期货行情**:国内期货 K 线、全球期货实时行情与 K 线、期货库存数据
|
|
60
60
|
- ✅ **期权数据**:中金所股指期权、上交所 ETF 期权、商品期权的报价 / K 线 / 分钟行情
|
|
61
|
-
- ✅
|
|
61
|
+
- ✅ **资金流向**(个股/大盘/排名/板块)、**盘口大单**、**涨停板池**、**盘口异动** 等扩展数据
|
|
62
|
+
- ✅ **沪深港通 / 北向资金**(分时、汇总、持股排行、历史、个股持仓)
|
|
63
|
+
- ✅ **龙虎榜**(详情、个股统计、机构买卖、营业部排行、席位明细)
|
|
64
|
+
- ✅ **大宗交易** + **融资融券** 全套数据
|
|
62
65
|
- ✅ 获取全部 **A 股代码列表**(5000+ 只股票)和批量获取**全市场行情**(内置并发控制)
|
|
63
66
|
- ✅ 支持 **provider 级重试 / 限流 / 熔断策略覆盖**,兼容旧的全局请求配置
|
|
64
67
|
- ✅ **AI / MCP 就绪** — 配套 [stock-sdk-mcp](https://www.npmjs.com/package/stock-sdk-mcp) MCP Server,一行命令接入 Cursor / Claude / Gemini 等 AI 工具
|
|
@@ -272,9 +275,58 @@ Stock SDK 配套 MCP Server([stock-sdk-mcp](https://www.npmjs.com/package/stoc
|
|
|
272
275
|
|
|
273
276
|
| 方法 | 说明 |
|
|
274
277
|
|------|------|
|
|
275
|
-
| `getFundFlow` |
|
|
278
|
+
| `getFundFlow` | 资金流向(按代码批量查询) |
|
|
276
279
|
| `getPanelLargeOrder` | 盘口大单占比 |
|
|
277
280
|
| `getTradingCalendar` | A 股交易日历 |
|
|
281
|
+
| `getDividendDetail` | 股票分红派送详情 |
|
|
282
|
+
|
|
283
|
+
### 资金流向(深度)
|
|
284
|
+
|
|
285
|
+
| 方法 | 说明 |
|
|
286
|
+
|------|------|
|
|
287
|
+
| `getIndividualFundFlow` | 个股资金流历史(日/周/月) |
|
|
288
|
+
| `getMarketFundFlow` | 大盘(上证 + 深证)资金流历史 |
|
|
289
|
+
| `getFundFlowRank` | 个股资金流排名(今日 / 3 日 / 5 日 / 10 日) |
|
|
290
|
+
| `getSectorFundFlowRank` | 板块资金流排名(行业 / 概念 / 地域) |
|
|
291
|
+
| `getSectorFundFlowHistory` | 单个板块的历史资金流 |
|
|
292
|
+
|
|
293
|
+
### 沪深港通 / 北向资金
|
|
294
|
+
|
|
295
|
+
| 方法 | 说明 |
|
|
296
|
+
|------|------|
|
|
297
|
+
| `getNorthboundMinute` | 北向 / 南向资金分时数据 |
|
|
298
|
+
| `getNorthboundFlowSummary` | 沪深港通市场资金流向汇总 |
|
|
299
|
+
| `getNorthboundHoldingRank` | 北向 / 沪股通 / 深股通持股个股排行 |
|
|
300
|
+
| `getNorthboundHistory` | 北向 / 南向资金历史 |
|
|
301
|
+
| `getNorthboundIndividual` | 个股北向持仓历史 |
|
|
302
|
+
|
|
303
|
+
### 涨停板 / 盘口异动
|
|
304
|
+
|
|
305
|
+
| 方法 | 说明 |
|
|
306
|
+
|------|------|
|
|
307
|
+
| `getZTPool` | 涨停 / 昨日涨停 / 强势 / 次新 / 炸板 / 跌停 6 大股池 |
|
|
308
|
+
| `getStockChanges` | 22 种盘口异动(火箭发射 / 大笔买入 / 封涨停 等) |
|
|
309
|
+
| `getBoardChanges` | 当日板块异动详情 |
|
|
310
|
+
|
|
311
|
+
### 龙虎榜
|
|
312
|
+
|
|
313
|
+
| 方法 | 说明 |
|
|
314
|
+
|------|------|
|
|
315
|
+
| `getDragonTigerDetail` | 龙虎榜详情(按日期范围) |
|
|
316
|
+
| `getDragonTigerStockStats` | 个股上榜统计(近 1/3/6 月、1 年) |
|
|
317
|
+
| `getDragonTigerInstitution` | 机构买卖统计 |
|
|
318
|
+
| `getDragonTigerBranchRank` | 营业部排行 |
|
|
319
|
+
| `getDragonTigerStockSeatDetail` | 个股某日上榜席位明细(买入榜 + 卖出榜) |
|
|
320
|
+
|
|
321
|
+
### 大宗交易 / 融资融券
|
|
322
|
+
|
|
323
|
+
| 方法 | 说明 |
|
|
324
|
+
|------|------|
|
|
325
|
+
| `getBlockTradeMarketStat` | 大宗交易市场每日总览 |
|
|
326
|
+
| `getBlockTradeDetail` | 大宗交易明细 |
|
|
327
|
+
| `getBlockTradeDailyStat` | 大宗交易每日统计(按股票汇总) |
|
|
328
|
+
| `getMarginAccountInfo` | 融资融券账户统计 |
|
|
329
|
+
| `getMarginTargetList` | 融资融券标的明细 |
|
|
278
330
|
|
|
279
331
|
### 批量查询
|
|
280
332
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ot=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var Cn=Object.prototype.hasOwnProperty;var Be=(t,e)=>{for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},On=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Sn(e))!Cn.call(t,n)&&n!==r&&ot(t,n,{get:()=>e[n],enumerable:!(o=yn(e,n))||o.enumerable});return t};var Rn=t=>On(ot({},"__esModule",{value:!0}),t);var mo={};Be(mo,{HttpError:()=>M,INDICATOR_REGISTRY:()=>V,SdkError:()=>P,StockSDK:()=>Ne,addIndicators:()=>Fe,asyncPool:()=>$,buildIndicatorContext:()=>ke,calcATR:()=>W,calcBIAS:()=>Pe,calcBOLL:()=>Te,calcCCI:()=>Ae,calcDMI:()=>Le,calcEMA:()=>D,calcKC:()=>Ke,calcKDJ:()=>Ie,calcMA:()=>Re,calcMACD:()=>Ee,calcOBV:()=>xe,calcROC:()=>Me,calcRSI:()=>be,calcSAR:()=>ve,calcSMA:()=>q,calcWMA:()=>rt,calcWR:()=>_e,chunkArray:()=>j,decodeGBK:()=>ee,default:()=>gn,estimateIndicatorLookback:()=>Ue,extractJsonFromJsonp:()=>Ye,getEnabledIndicatorKeys:()=>J,getSdkErrorCode:()=>B,jsonpRequest:()=>I,parseResponse:()=>te,safeNumber:()=>g,safeNumberOrNull:()=>O});module.exports=Rn(mo);function ee(t){return new TextDecoder("gbk").decode(t)}function te(t){let e=t.split(";").map(o=>o.trim()).filter(Boolean),r=[];for(let o of e){let n=o.indexOf("=");if(n<0)continue;let i=o.slice(0,n).trim();i.startsWith("v_")&&(i=i.slice(2));let s=o.slice(n+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");r.push({key:i,fields:a})}return r}function g(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function O(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function S(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:S(String(t))}var it="https://qt.gtimg.cn",st="https://web.ifzq.gtimg.cn/appstock/app/minute/query",at="https://assets.linkdiary.cn/shares/zh_a_list.json",ut="https://assets.linkdiary.cn/shares/us_list.json",lt="https://assets.linkdiary.cn/shares/hk_list.json",ct="https://assets.linkdiary.cn/shares/fund_list",tr="https://assets.linkdiary.cn/shares/trade-data-list.txt";var we="https://push2his.eastmoney.com/api/qt/stock/kline/get",pt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",dt="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",mt="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",ft="https://17.push2.eastmoney.com/api/qt/clist/get",gt="https://91.push2.eastmoney.com/api/qt/stock/get",ht="https://29.push2.eastmoney.com/api/qt/clist/get",yt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",St="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ct="https://79.push2.eastmoney.com/api/qt/clist/get",Ot="https://91.push2.eastmoney.com/api/qt/stock/get",Rt="https://29.push2.eastmoney.com/api/qt/clist/get",Et="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Tt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Q="https://datacenter-web.eastmoney.com/api/data/v1/get",re="https://push2his.eastmoney.com/api/qt/stock/kline/get",It="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",ne="58b2fa8f54638b60b87d69b31969089c",bt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},X={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"},He={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},oe="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",ie="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",_t="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",qe="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",At="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",xt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",Mt="https://futsseapi.eastmoney.com/list/option/221",Lt="https://datacenter-web.eastmoney.com/api/data/get",vt="b2884a393a59ad64002292a3e90d46a5";var Qe={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"}},Kt=3e4,se=500,ae=500,ue=7,kt=3,Ut=1e3,Ft=3e4,Dt=2,Nt=[408,429,500,502,503,504];var je=class{constructor(e={}){let r=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??r,this.tokens=this.maxTokens,this.refillRate=r/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(r=>setTimeout(r,e))}getAvailableTokens(){return this.refill(),this.tokens}};var rr=["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"],Bt=0;function En(){return typeof window<"u"&&typeof window.document<"u"}function nr(){if(En())return;let t=rr[Bt];return Bt=(Bt+1)%rr.length,t}var P=class extends Error{constructor(e){super(e.message),this.name="SdkError",this.code=e.code,this.provider=e.provider,this.url=e.url,this.status=e.status,this.details=e.details,e.cause!==void 0&&(this.cause=e.cause)}},M=class extends P{constructor(r,o,n,i){let s=o?` ${o}`:"",a=n?`, url: ${n}`:"",u=i?`, provider: ${i}`:"";super({code:r===429?"RATE_LIMITED":"HTTP_ERROR",message:`HTTP error! status: ${r}${s}${a}${u}`,status:r,url:n,provider:i,details:{statusText:o}});this.status=r;this.name="HttpError",this.statusText=o}};var ce=class extends P{constructor(e,r,o){super({code:"NOT_FOUND",message:e,provider:r,url:o}),this.name="NotFoundError"}};function le(t,e){let r=t;return!r.sdkCode&&e.sdkCode&&(r.sdkCode=e.sdkCode),!r.provider&&e.provider&&(r.provider=e.provider),!r.url&&e.url&&(r.url=e.url),r.status===void 0&&e.status!==void 0&&(r.status=e.status),!r.details&&e.details&&(r.details=e.details),r}function Tn(t,e){return le(t,{provider:e.provider,url:e.url})}function B(t){if(t instanceof P||t instanceof M)return t.code;if(t instanceof DOMException&&t.name==="AbortError")return"TIMEOUT";if(t instanceof TypeError)return t.sdkCode??"NETWORK_ERROR";if(t instanceof Error)return t.sdkCode}function $e(t,e={}){return t instanceof P?Tn(t,e):t instanceof DOMException&&t.name==="AbortError"?le(t,{sdkCode:"TIMEOUT",provider:e.provider,url:e.url,details:e.timeout?{timeout:e.timeout}:void 0}):t instanceof TypeError?le(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):t instanceof Error?le(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):new P({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var Z=class extends P{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},Ge=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 r=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(r,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new Z;try{let r=await e();return this.recordSuccess(),r}catch(r){throw this.recordFailure(),r}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var In=3e4,bn=1,or=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],ir=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function _n(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?or:t.includes("push2.eastmoney.com")?ir:[t]}function Pn(t){return Array.from(new Set(t))}var ze=class{constructor(e=In,r=bn){this.cooldownMs=e;this.failureThreshold=r;this.states=new Map}getCandidateUrls(e,r){let o;try{o=new URL(e)}catch{return[e]}let n=Date.now(),i=_n(o.hostname,r);if(i.length<=1)return[e];let s=i.filter(l=>{let c=this.states.get(l);return!c||c.cooldownUntil<=n}),a=i.filter(l=>{let c=this.states.get(l);return c&&c.cooldownUntil>n});return Pn([...s.includes(o.hostname)?[o.hostname]:[],...s.filter(l=>l!==o.hostname),...a.includes(o.hostname)?[o.hostname]:[],...a.filter(l=>l!==o.hostname)]).map(l=>{let c=new URL(e);return c.hostname=l,c.toString()})}recordSuccess(e){let r=this.safeGetHost(e);if(!r)return;let o=this.getState(r);o.failureCount=0,o.cooldownUntil=0,o.successCount++,o.lastErrorCode=void 0}recordFailure(e,r){let o=this.safeGetHost(e);if(!o)return;let n=this.getState(o);n.failureCount++,n.lastFailureAt=Date.now(),n.lastErrorCode=B(r),n.failureCount>=this.failureThreshold&&(n.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let r=B(e);return r==="NETWORK_ERROR"||r==="TIMEOUT"?!0:e instanceof M?e.status===408||e.status===429||e.status>=500:!1}getStats(e){let r=Array.from(this.states.values()).map(n=>({...n}));if(!e)return r;if(e!=="eastmoney")return[];let o=new Set([...or,...ir]);return r.filter(n=>o.has(n.host))}safeGetHost(e){try{return new URL(e).hostname}catch{return null}}getState(e){let r=this.states.get(e);if(r)return r;let o={host:e,failureCount:0,successCount:0,cooldownUntil:0,lastFailureAt:0};return this.states.set(e,o),o}};function An(t){return{maxRetries:t?.maxRetries??kt,baseDelay:t?.baseDelay??Ut,maxDelay:t?.maxDelay??Ft,backoffMultiplier:t?.backoffMultiplier??Dt,retryableStatusCodes:t?.retryableStatusCodes??Nt,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function xn(t,e){let r={...t??{}};return e&&(Object.keys(r).some(n=>n.toLowerCase()==="user-agent")||(r["User-Agent"]=e)),r}function sr(t,e){return e?{timeout:e.timeout??t.timeout,retry:e.retry?{...t.retry??{},...e.retry}:t.retry?{...t.retry}:void 0,headers:{...t.headers??{},...e.headers??{}},userAgent:e.userAgent??t.userAgent,rateLimit:e.rateLimit?{...t.rateLimit??{},...e.rateLimit}:t.rateLimit?{...t.rateLimit}:void 0,rotateUserAgent:e.rotateUserAgent??t.rotateUserAgent,circuitBreaker:e.circuitBreaker?{...t.circuitBreaker??{},...e.circuitBreaker}:t.circuitBreaker?{...t.circuitBreaker}:void 0}:{...t,headers:{...t.headers??{}},retry:t.retry?{...t.retry}:void 0,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function wt(t={}){return{timeout:t.timeout??Kt,retry:An(t.retry),headers:xn(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function ar(t,e){if(e)return e;try{let r=new URL(t).hostname;if(r.includes("eastmoney.com"))return"eastmoney";if(r.includes("gtimg.cn"))return"tencent";if(r.includes("sina.com.cn"))return"sina";if(r.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}var pe=class{constructor(e={}){this.baseUrl=e.baseUrl??it;let r={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=wt(r),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new ze;for(let[o,n]of Object.entries(e.providerPolicies??{})){let i=sr(r,n);this.providerPolicies[o]=wt(i)}}getProviderState(e){let r=this.runtimeStates.get(e);if(r)return r;let o=this.providerPolicies[e]??this.defaultPolicy,n={policy:o,rateLimiter:o.rateLimit?new je(o.rateLimit):null,circuitBreaker:o.circuitBreaker?new Ge(o.circuitBreaker):null};return this.runtimeStates.set(e,n),n}getTimeout(){return this.defaultPolicy.timeout}getHostHealth(e){return this.fallbackManager.getStats(e)}calculateDelay(e,r){return Math.min(r.baseDelay*Math.pow(r.backoffMultiplier,e),r.maxDelay)+Math.random()*100}sleep(e){return new Promise(r=>setTimeout(r,e))}shouldRetry(e,r,o){if(r>=o.maxRetries)return!1;let n=B(e);return n==="TIMEOUT"?o.retryOnTimeout:n==="NETWORK_ERROR"?o.retryOnNetworkError:e instanceof M?o.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,r,o,n=0){try{return await e()}catch(i){let s=$e(i,o);if(this.shouldRetry(s,n,r)){let a=this.calculateDelay(n,r);return r.onRetry&&r.onRetry(n+1,s,a),await this.sleep(a),this.executeWithRetry(e,r,o,n+1)}throw s}}async performRequest(e,r,o,n="text"){r.rateLimiter&&await r.rateLimiter.acquire();let i=new AbortController,s=setTimeout(()=>i.abort(),r.policy.timeout),a={...r.policy.headers};if(r.policy.rotateUserAgent){let u=nr();if(u){for(let l of Object.keys(a))l.toLowerCase()==="user-agent"&&delete a[l];a["User-Agent"]=u}}try{let u=await fetch(e,{signal:i.signal,headers:a});if(!u.ok)throw new M(u.status,u.statusText,e,o);switch(n){case"json":return await u.json();case"arraybuffer":return await u.arrayBuffer();default:return await u.text()}}finally{clearTimeout(s)}}async get(e,r={}){let o=ar(e,r.provider),n=this.getProviderState(o);if(n.circuitBreaker&&!n.circuitBreaker.canRequest())throw new Z("Circuit breaker is OPEN, request rejected");let i=this.fallbackManager.getCandidateUrls(e,o),s;for(let a=0;a<i.length;a++){let u=i[a],l=a===0?n.policy.retry:{...n.policy.retry,maxRetries:0};try{let c=await this.executeWithRetry(()=>this.performRequest(u,n,o,r.responseType),l,{provider:o,url:u,timeout:n.policy.timeout});return n.circuitBreaker?.recordSuccess(),this.fallbackManager.recordSuccess(u),c}catch(c){let m=$e(c,{provider:o,url:u,timeout:n.policy.timeout});if(s=m,this.fallbackManager.recordFailure(u,m),a<i.length-1&&this.fallbackManager.shouldFallback(m))continue;throw n.circuitBreaker?.recordFailure(),m}}throw n.circuitBreaker?.recordFailure(),s??new Z("Request failed without a concrete error")}async getTencentQuote(e){let r=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,o=await this.get(r,{responseType:"arraybuffer",provider:"tencent"}),n=ee(o);return te(n)}};var Mn=new Set(["daily","weekly","monthly"]),Ln=new Set(["1","5","15","30","60"]),vn=new Set(["","qfq","hfq"]);function F(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function L(t){if(!Mn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function de(t){if(!Ln.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function w(t){if(!vn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function j(t,e){F(e,"chunkSize");let r=[];for(let o=0;o<t.length;o+=e)r.push(t.slice(o,o+e));return r}async function $(t,e,r=!1){if(F(e,"concurrency"),t.length===0)return[];let o=r?new Array(t.length):[],n=0,i=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let s=n++;if(s>=t.length)return;let a=await t[s]();r?o[s]=a:o.push(a)}});return await Promise.all(i),o}function We(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function v(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function H(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var Ve=class{constructor(e={}){this.cache=new Map;this.inflight=new Map;this.defaultTTL=e.defaultTTL??0,this.maxSize=e.maxSize??1e3}get(e){let r=this.cache.get(e);if(r){if(r.expireAt>0&&Date.now()>r.expireAt){this.cache.delete(e);return}return r.lastAccess=Date.now(),r.value}}set(e,r,o){this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictLRU();let n=o??this.defaultTTL,i=Date.now();this.cache.set(e,{value:r,expireAt:n>0?i+n:0,lastAccess:i})}has(e){return this.get(e)!==void 0}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.inflight.clear()}get size(){return this.cache.size}cleanup(){let e=Date.now(),r=0;for(let[o,n]of this.cache)n.expireAt>0&&e>n.expireAt&&(this.cache.delete(o),r++);return r}evictLRU(){let e=null,r=1/0;for(let[o,n]of this.cache)n.lastAccess<r&&(r=n.lastAccess,e=o);e&&this.cache.delete(e)}async getOrFetch(e,r,o){let n=this.get(e);if(n!==void 0)return n;let i=this.inflight.get(e);if(i)return i;let s=r().then(a=>(this.set(e,a,o),a)).finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,s),s}},ur=new Map;function G(t,e){let r=ur.get(t);if(r)return r;let o=new Ve(e);return ur.set(t,o),o}var Kn=typeof document<"u"&&typeof window<"u",kn=0;function lr(){return`__stock_sdk_jsonp_${Date.now()}_${kn++}`}function Ye(t){let e=t,r=e.indexOf("*/");r!==-1&&(e=e.slice(r+2).trim());let o=e.indexOf("(");if(o===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let n=e.lastIndexOf(")");if(n===-1||n<=o)throw new Error("Invalid JSONP response: no closing parenthesis found");let i=e.slice(o+1,n);return JSON.parse(i)}function Un(t,e){let{timeout:r=15e3,callbackParam:o="callback",callbackMode:n="query"}=e;return new Promise((i,s)=>{let a=lr(),u;if(n==="path")u=t.replace("{callback}",a);else{let y=t.includes("?")?"&":"?";u=`${t}${y}${o}=${a}`}let l=document.createElement("script"),c=!1,m=window,d=()=>{l.parentNode&&l.parentNode.removeChild(l),delete m[a]},h=setTimeout(()=>{c||(c=!0,d(),s(new Error(`JSONP request timed out after ${r}ms: ${t}`)))},r);m[a]=y=>{c||(c=!0,clearTimeout(h),d(),i(y))},l.onerror=()=>{c||(c=!0,clearTimeout(h),d(),s(new Error(`JSONP script load failed: ${t}`)))},l.src=u,document.head.appendChild(l)})}async function Fn(t,e){let{timeout:r=15e3,callbackParam:o="callback",callbackMode:n="query"}=e,i=lr(),s;if(n==="path")s=t.replace("{callback}",i);else{let l=t.includes("?")?"&":"?";s=`${t}${l}${o}=${i}`}let a=new AbortController,u=setTimeout(()=>a.abort(),r);try{let l=await fetch(s,{signal:a.signal});if(!l.ok)throw new Error(`JSONP fetch failed with status ${l.status}: ${t}`);let c=await l.text();return Ye(c)}catch(l){throw l instanceof DOMException&&l.name==="AbortError"?new Error(`JSONP request timed out after ${r}ms: ${t}`):l}finally{clearTimeout(u)}}function I(t,e={}){return Kn?Un(t,e):Fn(t,e)}var T={};Be(T,{getAShareCodeList:()=>hr,getAllHKQuotesByCodes:()=>Or,getAllQuotesByCodes:()=>Cr,getAllUSQuotesByCodes:()=>Rr,getFullQuotes:()=>Xe,getFundCodeList:()=>Er,getFundFlow:()=>pr,getFundQuotes:()=>mr,getHKCodeList:()=>Sr,getHKQuotes:()=>Ze,getPanelLargeOrder:()=>dr,getSimpleQuotes:()=>cr,getTodayTimeline:()=>fr,getTradingCalendar:()=>Tr,getUSCodeList:()=>yr,getUSQuotes:()=>Je,parseFullQuote:()=>Ht,parseFundFlow:()=>Qt,parseFundQuote:()=>zt,parseHKQuote:()=>$t,parsePanelLargeOrder:()=>jt,parseSimpleQuote:()=>qt,parseUSQuote:()=>Gt,search:()=>br});function Ht(t){let e=[];for(let o=0;o<5;o++)e.push({price:g(t[9+o*2]),volume:g(t[10+o*2])});let r=[];for(let o=0;o<5;o++)r.push({price:g(t[19+o*2]),volume:g(t[20+o*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:g(t[3]),prevClose:g(t[4]),open:g(t[5]),volume:g(t[6]),outerVolume:g(t[7]),innerVolume:g(t[8]),bid:e,ask:r,time:t[30]??"",change:g(t[31]),changePercent:g(t[32]),high:g(t[33]),low:g(t[34]),volume2:g(t[36]),amount:g(t[37]),turnoverRate:O(t[38]),pe:O(t[39]),amplitude:O(t[43]),circulatingMarketCap:O(t[44]),totalMarketCap:O(t[45]),pb:O(t[46]),limitUp:O(t[47]),limitDown:O(t[48]),volumeRatio:O(t[49]),avgPrice:O(t[51]),peStatic:O(t[52]),peDynamic:O(t[53]),high52w:O(t[67]),low52w:O(t[68]),circulatingShares:O(t[72]),totalShares:O(t[73]),raw:t}}function qt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:g(t[3]),change:g(t[4]),changePercent:g(t[5]),volume:g(t[6]),amount:g(t[7]),marketCap:O(t[9]),marketType:t[10]??"",raw:t}}function Qt(t){return{code:t[0]??"",mainInflow:g(t[1]),mainOutflow:g(t[2]),mainNet:g(t[3]),mainNetRatio:g(t[4]),retailInflow:g(t[5]),retailOutflow:g(t[6]),retailNet:g(t[7]),retailNetRatio:g(t[8]),totalFlow:g(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function jt(t){return{buyLargeRatio:g(t[0]),buySmallRatio:g(t[1]),sellLargeRatio:g(t[2]),sellSmallRatio:g(t[3]),raw:t}}function $t(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:g(t[3]),prevClose:g(t[4]),open:g(t[5]),volume:g(t[6]),time:t[30]??"",change:g(t[31]),changePercent:g(t[32]),high:g(t[33]),low:g(t[34]),amount:g(t[37]),lotSize:O(t[40]),circulatingMarketCap:O(t[44]),totalMarketCap:O(t[45]),currency:t[t.length-3]??"",raw:t}}function Gt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:g(t[3]),prevClose:g(t[4]),open:g(t[5]),volume:g(t[6]),time:t[30]??"",change:g(t[31]),changePercent:g(t[32]),high:g(t[33]),low:g(t[34]),amount:g(t[37]),turnoverRate:O(t[38]),pe:O(t[39]),amplitude:O(t[43]),totalMarketCap:O(t[45]),pb:O(t[47]),high52w:O(t[48]),low52w:O(t[49]),raw:t}}function zt(t){return{code:t[0]??"",name:t[1]??"",nav:g(t[5]),accNav:g(t[6]),change:g(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=>Ht(o.fields))}async function cr(t,e){if(!e||e.length===0)return[];let r=e.map(n=>`s_${n}`);return(await t.getTencentQuote(r.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>qt(n.fields))}async function pr(t,e){if(!e||e.length===0)return[];let r=e.map(n=>`ff_${n}`);return(await t.getTencentQuote(r.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>Qt(n.fields))}async function dr(t,e){if(!e||e.length===0)return[];let r=e.map(n=>`s_pk${n}`);return(await t.getTencentQuote(r.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>jt(n.fields))}async function Ze(t,e){if(!e||e.length===0)return[];let r=e.map(n=>`hk${n}`);return(await t.getTencentQuote(r.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>$t(n.fields))}async function Je(t,e){if(!e||e.length===0)return[];let r=e.map(n=>`us${n}`);return(await t.getTencentQuote(r.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>Gt(n.fields))}async function mr(t,e){if(!e||e.length===0)return[];let r=e.map(n=>`jj${n}`);return(await t.getTencentQuote(r.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>zt(n.fields))}async function fr(t,e){let r=t.getTimeout(),o=new AbortController,n=setTimeout(()=>o.abort(),r);try{let i=await fetch(`${st}?code=${e}`,{signal:o.signal});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let s=await i.json();if(s.code!==0)throw new Error(s.msg||"API error");let a=s.data?.[e];if(!a)return{code:e,date:"",preClose:0,data:[]};let u=a.data?.data||[],l=a.data?.date||"",c=Array.isArray(a.qt?.[e])?a.qt[e]:[],m=parseFloat(c[4]??"")||0,d=!1;if(u.length>0){let y=u[0].split(" "),f=parseFloat(y[1])||0,C=parseInt(y[2],10)||0,E=parseFloat(y[3])||0;C>0&&f>0&&E/C>f*50&&(d=!0)}let h=u.map(y=>{let f=y.split(" "),C=f[0],E=`${C.slice(0,2)}:${C.slice(2,4)}`,b=parseInt(f[2],10)||0,_=parseFloat(f[3])||0,N=d?b*100:b,U=N>0?_/N:0;return{time:E,price:parseFloat(f[1])||0,volume:N,amount:_,avgPrice:Math.round(U*100)/100}});return{code:e,date:l,preClose:m,data:h}}finally{clearTimeout(n)}}var gr=G("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function Wt(t,e,r){return gr.getOrFetch(e,async()=>(await t.get(r,{responseType:"json"}))?.list||[])}function Dn(t,e){let r=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return r.startsWith("6");case"sz":return r.startsWith("0")||r.startsWith("3");case"bj":return r.startsWith("92");case"kc":return r.startsWith("688");case"cy":return r.startsWith("30");default:return!0}}async function hr(t,e){let r=!1,o;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,o=e.market);let i=await Wt(t,"a-share:full",at);return o&&(i=i.filter(s=>Dn(s,o))),r?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var Nn={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function yr(t,e){let r=!1,o;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,o=e.market);let i=(await Wt(t,"us:full",ut)).slice();if(o){let s=Nn[o];i=i.filter(a=>a.startsWith(s))}return r?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function Sr(t){return(await Wt(t,"hk:full",lt)).slice()}async function Cr(t,e,r={}){let{batchSize:o=se,concurrency:n=ue,onProgress:i}=r;F(o,"batchSize"),F(n,"concurrency");let s=Math.min(o,ae),a=j(e,s),u=a.length,l=0,c=a.map(d=>async()=>{let h=await Xe(t,d);return l++,i&&i(l,u),h});return(await $(c,n,!0)).flat()}async function Or(t,e,r={}){let{batchSize:o=se,concurrency:n=ue,onProgress:i}=r;F(o,"batchSize"),F(n,"concurrency");let s=Math.min(o,ae),a=j(e,s),u=a.length,l=0,c=a.map(d=>async()=>{let h=await Ze(t,d);return l++,i&&i(l,u),h});return(await $(c,n,!0)).flat()}async function Rr(t,e,r={}){let{batchSize:o=se,concurrency:n=ue,onProgress:i}=r;F(o,"batchSize"),F(n,"concurrency");let s=Math.min(o,ae),a=j(e,s),u=a.length,l=0,c=a.map(d=>async()=>{let h=await Je(t,d);return l++,i&&i(l,u),h});return(await $(c,n,!0)).flat()}async function Er(t){return(await gr.getOrFetch("fund:full",async()=>(await t.get(ct,{responseType:"text"})).split(",").slice(1).filter(n=>n.trim()))).slice()}var Bn=G("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function Tr(t){return(await Bn.getOrFetch("a-share",async()=>{let r=await t.get(tr);return!r||r.trim()===""?[]:r.trim().split(",").map(o=>o.trim()).filter(o=>o.length>0)})).slice()}var Ir="https://smartbox.gtimg.cn/s3/";function wn(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function Hn(t){let e=t.toUpperCase();return e.startsWith("QDII")||e.startsWith("ETF")||e.startsWith("LOF")||e.startsWith("KJ")||e.startsWith("JJ")||e.includes("FUND")?"fund":e.startsWith("GP")||e.includes("STOCK")?"stock":e==="ZS"||e.includes("INDEX")?"index":e.startsWith("ZQ")||e.includes("BOND")?"bond":e.startsWith("QH")||e.includes("FUTURE")?"futures":e.startsWith("QZ")||e.includes("OPTION")?"option":"other"}function qn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(r=>{let o=r.split("~"),n=o[0]||"",i=o[1]||"",s=wn(o[2]||""),a=o[4]||"";return{code:n+i,name:s,market:n,type:a,category:Hn(a)}})}function Qn(t){return new Promise((e,r)=>{let o=`${Ir}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let n=document.createElement("script");n.src=o,n.charset="utf-8",n.onload=()=>{let i=window.v_hint||"";document.body.removeChild(n),e(i)},n.onerror=()=>{document.body.removeChild(n),r(new Error("Network error calling Smartbox"))},document.body.appendChild(n)})}async function jn(t,e){let r=`${Ir}?v=2&t=all&q=${encodeURIComponent(e)}`,n=(await t.get(r)).match(/v_hint="([^"]*)"/);return n?n[1]:""}function $n(){return typeof window<"u"&&typeof document<"u"}async function br(t,e){if(!e||!e.trim())return[];let r;return $n()?r=await Qn(e):r=await jn(t,e),qn(r)}var R={};Be(R,{extractVariety:()=>Yt,getCFFEXOptionQuotes:()=>Xr,getComexInventory:()=>rn,getConceptConstituents:()=>Qr,getConceptKline:()=>jr,getConceptList:()=>Hr,getConceptMinuteKline:()=>$r,getConceptSpot:()=>qr,getDividendDetail:()=>Gr,getFuturesHistoryKline:()=>Wr,getFuturesInventory:()=>tn,getFuturesInventorySymbols:()=>Jr,getFuturesMarketCode:()=>Xt,getGlobalFuturesKline:()=>Yr,getGlobalFuturesSpot:()=>Vr,getHKHistoryKline:()=>Ar,getHistoryKline:()=>_r,getIndustryConstituents:()=>Nr,getIndustryKline:()=>Br,getIndustryList:()=>Fr,getIndustryMinuteKline:()=>wr,getIndustrySpot:()=>Dr,getMinuteKline:()=>Pr,getOptionLHB:()=>Zr,getUSHistoryKline:()=>xr});async function Vt(t,e,r,o,n=100,i){let s=[],a=1,u=0;do{let l=new URLSearchParams({...r,pn:String(a),pz:String(n),fields:o}),c=`${e}?${l.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(u=d.total??0);let h=d.diff.map((y,f)=>i(y,s.length+f+1));s.push(...h),a++}while(s.length<u);return s}function K(t){let[e,r,o,n,i,s,a,u,l,c,m]=t.split(",");return{date:e,open:S(r),close:S(o),high:S(n),low:S(i),volume:S(s),amount:S(a),amplitude:S(u),changePercent:S(l),change:S(c),turnoverRate:S(m)}}async function k(t,e,r){let o=`${e}?${r.toString()}`,n=await t.get(o,{responseType:"json"});return{klines:n?.data?.klines||[],name:n?.data?.name,code:n?.data?.code}}async function _r(t,e,r={}){let{period:o="daily",adjust:n="qfq",startDate:i="19700101",endDate:s="20500101"}=r;L(o),w(n);let a=e.replace(/^(sh|sz|bj)/,""),u=`${We(e)}.${a}`,l=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:v(o),fqt:H(n),secid:u,beg:i,end:s}),c=we,{klines:m}=await k(t,c,l);return m.length===0?[]:m.map(d=>({...K(d),code:a}))}async function Pr(t,e,r={}){let{period:o="1",adjust:n="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=r;de(o),w(n);let a=e.replace(/^(sh|sz|bj)/,""),u=`${We(e)}.${a}`;if(o==="1"){let l=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:u}),c=`${pt}?${l.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let h=i.replace("T"," ").slice(0,16),y=s.replace("T"," ").slice(0,16);return d.map(f=>{let[C,E,b,_,N,U,Y,hn]=f.split(",");return{time:C,open:S(E),close:S(b),high:S(_),low:S(N),volume:S(U),amount:S(Y),avgPrice:S(hn)}}).filter(f=>f.time>=h&&f.time<=y)}else{let l=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:H(n||""),secid:u,beg:"0",end:"20500000"}),c=we,{klines:m}=await k(t,c,l);if(m.length===0)return[];let d=i.replace("T"," ").slice(0,16),h=s.replace("T"," ").slice(0,16);return m.map(y=>{let f=K(y);return{...f,time:f.date}}).filter(y=>y.time>=d&&y.time<=h)}}function et(t){return async function(r,o,n={}){let{period:i="daily",adjust:s="qfq",startDate:a="19700101",endDate:u="20500101"}=n;L(i),w(s);let l=t.normalizeSymbol(o),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:v(i),fqt:H(s),secid:l.secid,beg:a,end:u,lmt:"1000000"}),{klines:m,name:d,code:h}=await k(r,t.url,c);if(m.length===0)return[];let y=t.resolveResultMeta?t.resolveResultMeta(o,l,{code:h,name:d}):{code:h||l.fallbackCode,name:d||""};return m.map(f=>({...K(f),code:y.code,name:y.name}))}}var Gn=et({url:dt,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function Ar(t,e,r={}){return Gn(t,e,r)}var zn=et({url:mt,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,r)=>({code:r.code||e.fallbackCode,name:r.name||""})});async function xr(t,e,r={}){return zn(t,e,r)}function Mr(t){let e=G(`eastmoney:board-code-map:${t.type}`,{defaultTTL:36e5,maxSize:4});return{async getCode(r,o,n){if(o.startsWith("BK"))return o;let s=(await e.getOrFetch("name-code-map",async()=>{let a=await n(r);return Object.fromEntries(a.map(u=>[u.name,u.code]))}))[o];if(!s)throw new ce(`${t.errorPrefix}: ${o}`,"eastmoney");return s}}}async function Lr(t,e){let r={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",n=await Vt(t,e.listUrl,r,o,100,(i,s)=>({rank:s,name:String(i.f14??""),code:String(i.f12??""),price:p(i.f2),change:p(i.f4),changePercent:p(i.f3),totalMarketCap:p(i.f20),turnoverRate:p(i.f8),riseCount:p(i.f104),fallCount:p(i.f105),leadingStock:i.f128?String(i.f128):null,leadingStockChangePercent:p(i.f136)}));return n.sort((i,s)=>(s.changePercent??0)-(i.changePercent??0)),n.forEach((i,s)=>{i.rank=s+1}),n}async function vr(t,e,r){let o=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),n=`${r}?${o.toString()}`,s=(await t.get(n,{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:u,name:l,divide:c})=>{let m=s[u],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:l,value:d}}):[]}async function Kr(t,e,r){let o={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Vt(t,r,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,(i,s)=>({rank:s,code:String(i.f12??""),name:String(i.f14??""),price:p(i.f2),changePercent:p(i.f3),change:p(i.f4),volume:p(i.f5),amount:p(i.f6),amplitude:p(i.f7),high:p(i.f15),low:p(i.f16),open:p(i.f17),prevClose:p(i.f18),turnoverRate:p(i.f8),pe:p(i.f9),pb:p(i.f23)}))}async function kr(t,e,r,o={}){let{period:n="daily",adjust:i="",startDate:s="19700101",endDate:a="20500101"}=o;L(n),w(i);let u=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:v(n),fqt:H(i),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:l}=await k(t,r,u);return l.length===0?[]:l.map(c=>K(c))}async function Ur(t,e,r,o,n={}){let{period:i="5"}=n;if(de(i),i==="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=`${o}?${s.toString()}`,l=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(l)||l.length===0?[]:l.map(c=>{let[m,d,h,y,f,C,E,b]=c.split(","),_=S(b);return{time:m,open:S(d),close:S(h),high:S(y),low:S(f),volume:S(C),amount:S(E),price:_,avgPrice:_}})}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:i,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${r}?${s.toString()}`,l=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(l)||l.length===0?[]:l.map(c=>{let[m,d,h,y,f,C,E,b,_,N,U]=c.split(",");return{time:m,open:S(d),close:S(h),high:S(y),low:S(f),changePercent:S(_),change:S(N),volume:S(C),amount:S(E),amplitude:S(b),turnoverRate:S(U)}})}}function tt(t){let e=Mr(t);async function r(n){return Lr(n,t)}async function o(n,i){return e.getCode(n,i,r)}return{async getList(n){return r(n)},async getSpot(n,i){let s=await o(n,i);return vr(n,s,t.spotUrl)},async getConstituents(n,i){let s=await o(n,i);return Kr(n,s,t.consUrl)},async getKline(n,i,s={}){let a=await o(n,i);return kr(n,a,t.klineUrl,s)},async getMinuteKline(n,i,s={}){let a=await o(n,i);return Ur(n,a,t.klineUrl,t.trendsUrl,s)}}}var Wn={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:ft,spotUrl:gt,consUrl:ht,klineUrl:yt,trendsUrl:St,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},me=tt(Wn);async function Fr(t){return me.getList(t)}async function Dr(t,e){return me.getSpot(t,e)}async function Nr(t,e){return me.getConstituents(t,e)}async function Br(t,e,r={}){return me.getKline(t,e,r)}async function wr(t,e,r={}){return me.getMinuteKline(t,e,r)}var Vn={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Ct,spotUrl:Ot,consUrl:Rt,klineUrl:Et,trendsUrl:Tt,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},fe=tt(Vn);async function Hr(t){return fe.getList(t)}async function qr(t,e){return fe.getSpot(t,e)}async function Qr(t,e){return fe.getConstituents(t,e)}async function jr(t,e,r={}){return fe.getKline(t,e,r)}async function $r(t,e,r={}){return fe.getMinuteKline(t,e,r)}function z(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Yn(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:z(t.REPORT_DATE),planNoticeDate:z(t.PLAN_NOTICE_DATE),disclosureDate:z(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:z(t.EQUITY_RECORD_DATE),exDividendDate:z(t.EX_DIVIDEND_DATE),payDate:z(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:z(t.NOTICE_DATE)}}async function Gr(t,e){let r=e.replace(/^(sh|sz|bj)/,""),o=[],n=1,i=1;do{let s=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(n),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${r}")`}),a=`${Q}?${s.toString()}`,l=(await t.get(a,{responseType:"json"}))?.result;if(!l||!Array.isArray(l.data))break;n===1&&(i=l.pages??1);let c=l.data.map(Yn);o.push(...c),n++}while(n<=i);return o}function Yt(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 zr(t){return X[t]??X[t.toLowerCase()]??X[t.toUpperCase()]}function Xt(t){let e=zr(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=zr(t.slice(0,-1))),!e){let o=Object.keys(X).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${o}`)}let r=bt[e];if(r===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return r}function Xn(t){let e=K(t),r=t.split(",");return{...e,openInterest:r.length>12?S(r[12]):null}}async function Wr(t,e,r={}){let{period:o="daily",startDate:n="19700101",endDate:i="20500101"}=r;L(o);let s=Yt(e),u=`${Xt(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:v(o),fqt:"0",secid:u,beg:n,end:i}),{klines:c,name:m,code:d}=await k(t,re,l);return c.length===0?[]:c.map(h=>({...Xn(h),code:d||e,name:m||""}))}async function Vr(t,e={}){let r=e.pageSize??20,o=[],n=0,i=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(r),pageIndex:String(n),token:ne,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${It}?${s.toString()}`,u=await t.get(a,{responseType:"json"});if(!u||!Array.isArray(u.list))break;n===0&&(i=u.total??0);let l=u.list.map(Zn);o.push(...l),n++}while(o.length<i);return o}function Zn(t){return{code:t.dm||"",name:t.name||"",price:S(String(t.p)),change:S(String(t.zde)),changePercent:S(String(t.zdf)),open:S(String(t.o)),high:S(String(t.h)),low:S(String(t.l)),prevSettle:S(String(t.zjsj)),volume:S(String(t.vol)),buyVolume:S(String(t.wp)),sellVolume:S(String(t.np)),openInterest:S(String(t.ccl))}}function Jn(t){let e=K(t),r=t.split(",");return{...e,openInterest:r.length>12?S(r[12]):null}}function eo(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 Yr(t,e,r={}){let{period:o="daily",startDate:n="19700101",endDate:i="20500101"}=r;L(o);let s=r.marketCode;if(s===void 0){let d=eo(e);if(s=He[d],s===void 0){let h=Object.keys(He).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${h}. Or specify marketCode manually via options.`)}}let a=`${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:v(o),fqt:"0",secid:a,beg:n,end:i}),{klines:l,name:c,code:m}=await k(t,re,u);return l.length===0?[]:l.map(d=>({...Jn(d),code:m||e,name:c||""}))}async function Xr(t,e={}){let{pageSize:r=2e4}=e,o=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(r),pageIndex:"0",token:ne,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),n=`${Mt}?${o.toString()}`,s=(await t.get(n,{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)})):[]}function to(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function Zr(t,e,r){let o=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:vt,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${r}')`}),n=`${Lt}?${o.toString()}`,s=(await t.get(n,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function a(u){if(!u)return"";let l=String(u),c=l.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:l}return s.map(u=>({tradeType:String(u.TRADE_TYPE??""),date:a(u.TRADE_DATE),symbol:String(u.SECURITY_CODE??""),targetName:String(u.TARGET_NAME??""),memberName:String(u.MEMBER_NAME_ABBR??""),rank:p(u.MEMBER_RANK)??0,sellVolume:p(u.SELL_VOLUME),sellVolumeChange:p(u.SELL_VOLUME_CHANGE),netSellVolume:p(u.NET_SELL_VOLUME),sellVolumeRatio:p(u.SELL_VOLUME_RATIO),buyVolume:p(u.BUY_VOLUME),buyVolumeChange:p(u.BUY_VOLUME_CHANGE),netBuyVolume:p(u.NET_BUY_VOLUME),buyVolumeRatio:p(u.BUY_VOLUME_RATIO),sellPosition:p(u.SELL_POSITION),sellPositionChange:p(u.SELL_POSITION_CHANGE),netSellPosition:p(u.NET_SELL_POSITION),sellPositionRatio:p(u.SELL_POSITION_RATIO),buyPosition:p(u.BUY_POSITION),buyPositionChange:p(u.BUY_POSITION_CHANGE),netBuyPosition:p(u.NET_BUY_POSITION),buyPositionRatio:p(u.BUY_POSITION_RATIO),tradeDate:a(u.TRADE_DATE),volume:p(u.BUY_VOLUME)??p(u.SELL_VOLUME)??p(u.NET_BUY_VOLUME)??p(u.NET_SELL_VOLUME),volumeChange:p(u.BUY_VOLUME_CHANGE)??p(u.SELL_VOLUME_CHANGE),amount:p(u.BUY_POSITION)??p(u.SELL_POSITION)??p(u.NET_BUY_POSITION)??p(u.NET_SELL_POSITION),amountChange:p(u.BUY_POSITION_CHANGE)??p(u.SELL_POSITION_CHANGE),openInterest:p(u.BUY_POSITION)??p(u.SELL_POSITION),openInterestChange:p(u.BUY_POSITION_CHANGE)??p(u.SELL_POSITION_CHANGE),side:to(String(u.TRADE_TYPE??""))}))}var ro={gold:"EMI00069026",silver:"EMI00069027"};async function Jr(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"}),r=`${Q}?${e.toString()}`,n=(await t.get(r,{responseType:"json"}))?.result?.data;return Array.isArray(n)?n.map(i=>({code:String(i.TRADE_CODE??""),name:String(i.TRADE_TYPE??""),marketCode:String(i.TRADE_MARKET_CODE??"")})):[]}function en(t){if(!t)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}async function tn(t,e,r={}){let{startDate:o="2020-10-28",pageSize:n=500}=r,i=e.toUpperCase(),s=[],a=1,u=1;do{let l=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${i}")(TRADE_DATE>='${o}')`,pageNumber:String(a),pageSize:String(n),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${Q}?${l.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(u=d.pages??1);let h=d.data.map(y=>({code:String(y.SECURITY_CODE??e),date:en(y.TRADE_DATE),inventory:p(y.ON_WARRANT_NUM),change:p(y.ADDCHANGE)}));s.push(...h),a++}while(a<=u);return s}async function rn(t,e,r={}){let o=ro[e];if(!o)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:n=500}=r,i=[],s=1,a=1,u={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let l=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(n),pageNumber:String(s),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${o}")(@STORAGE_TON<>"NULL")`}),c=`${Q}?${l.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;s===1&&(a=d.pages??1);let h=d.data.map(y=>({date:en(y.REPORT_DATE),name:u[e]??e,storageTon:p(y.STORAGE_TON),storageOunce:p(y.STORAGE_OUNCE),inventory:p(y.STORAGE_TON),change:null,market:e}));i.push(...h),s++}while(s<=a);return i}var A={};Be(A,{getCommodityOptionKline:()=>mn,getCommodityOptionSpot:()=>dn,getETFOption5DayMinute:()=>pn,getETFOptionDailyKline:()=>cn,getETFOptionExpireDay:()=>an,getETFOptionMinute:()=>ln,getETFOptionMonths:()=>sn,getIndexOptionKline:()=>on,getIndexOptionSpot:()=>nn});function no(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 oo(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 r=`${oe}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,o=await I(r),n=o?.result?.data?.up??[],i=o?.result?.data?.down??[];return{calls:n.map(no),puts:i.map(oo)}}async function on(t){let e=`${ie}?symbol=${t}`,r=await I(e,{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 sn(t){let e=`${_t}?exchange=null&cate=${encodeURIComponent(t)}`,o=(await I(e))?.result?.data,n=o?.contractMonth??[];return{months:n.length>1?n.slice(1):n,stockId:o?.stockId??"",cateId:o?.cateId??"",cateList:o?.cateList??[]}}async function an(t,e){let r=`${qe}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,o=await I(r),n=o?.result?.data?.remainderDays;if(typeof n=="number"&&n<0){let s=`${qe}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;o=await I(s)}let i=o?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function un(t){let e="";return t.map(r=>(r.d&&(e=r.d),{time:r.i,date:e,price:p(r.p),volume:p(r.v),openInterest:p(r.t),avgPrice:p(r.a)}))}async function ln(t){let e=`CON_OP_${t}`,r=`${Pt}?symbol=${e}`,n=(await I(r))?.result?.data;return Array.isArray(n)?un(n):[]}async function cn(t){let e=`CON_OP_${t}`,r=`${At}?symbol=${e}`,o=await I(r,{callbackMode:"path"});return Array.isArray(o)?o.map(n=>({date:n.d,open:p(n.o),high:p(n.h),low:p(n.l),close:p(n.c),volume:p(n.v)})):[]}async function pn(t){let e=`CON_OP_${t}`,r=`${xt}?symbol=${e}`,n=(await I(r))?.result?.data;if(!Array.isArray(n))return[];let i=[];for(let s of n)Array.isArray(s)&&i.push(...un(s));return i}function io(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 so(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 r=Qe[t];if(!r)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(Qe).join(", ")}`);let o=`${oe}?type=futures&product=${r.product}&exchange=${r.exchange}&pinzhong=${e}`,n=await I(o),i=n?.result?.data?.up??[],s=n?.result?.data?.down??[];return{calls:i.map(io),puts:s.map(so)}}async function mn(t){let e=`${ie}?symbol=${t}`,r=await I(e,{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)})):[]}var x=class{constructor(e){this.client=e}};var ge=class extends x{constructor(e){super(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)}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:r,...o}=e,n=await this.getAShareCodeList({market:r});return T.getAllQuotesByCodes(this.client,n,o)}async getAllHKShareQuotes(e={}){let r=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,r,e)}async getAllUSShareQuotes(e={}){let{market:r,...o}=e,n=await this.getUSCodeList({simple:!0,market:r});return T.getAllUSQuotesByCodes(this.client,n,o)}getAllQuotesByCodes(e,r={}){return T.getAllQuotesByCodes(this.client,e,r)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return R.getDividendDetail(this.client,e)}};var he=class extends x{constructor(e){super(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,r){return R.getIndustryKline(this.client,e,r)}getIndustryMinuteKline(e,r){return R.getIndustryMinuteKline(this.client,e,r)}getConceptList(){return R.getConceptList(this.client)}getConceptSpot(e){return R.getConceptSpot(this.client,e)}getConceptConstituents(e){return R.getConceptConstituents(this.client,e)}getConceptKline(e,r){return R.getConceptKline(this.client,e,r)}getConceptMinuteKline(e,r){return R.getConceptMinuteKline(this.client,e,r)}};var ye=class extends x{constructor(e){super(e)}getHistoryKline(e,r){return R.getHistoryKline(this.client,e,r)}getMinuteKline(e,r){return R.getMinuteKline(this.client,e,r)}getHKHistoryKline(e,r){return R.getHKHistoryKline(this.client,e,r)}getUSHistoryKline(e,r){return R.getUSHistoryKline(this.client,e,r)}};var Se=class extends x{constructor(e){super(e)}getFuturesKline(e,r){return R.getFuturesHistoryKline(this.client,e,r)}getGlobalFuturesSpot(e){return R.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,r){return R.getGlobalFuturesKline(this.client,e,r)}getFuturesInventorySymbols(){return R.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,r){return R.getFuturesInventory(this.client,e,r)}getComexInventory(e,r){return R.getComexInventory(this.client,e,r)}};var Ce=class extends x{constructor(e){super(e)}getIndexOptionSpot(e,r){return A.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return A.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return R.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return A.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return A.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return A.getETFOptionMinute(e)}getETFOptionDailyKline(e){return A.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return A.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return A.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return A.getCommodityOptionKline(e)}getOptionLHB(e,r){return R.getOptionLHB(this.client,e,r)}};function Oe(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function q(t,e){let r=[];for(let o=0;o<t.length;o++){if(o<e-1){r.push(null);continue}let n=0,i=0;for(let s=o-e+1;s<=o;s++)t[s]!==null&&(n+=t[s],i++);r.push(i===e?Oe(n/e):null)}return r}function D(t,e){let r=[],o=2/(e+1),n=null,i=!1;for(let s=0;s<t.length;s++){if(s<e-1){r.push(null);continue}if(!i){let u=0,l=0;for(let c=s-e+1;c<=s;c++)t[c]!==null&&(u+=t[c],l++);l===e&&(n=u/e,i=!0),r.push(n!==null?Oe(n):null);continue}let a=t[s];a===null?r.push(n!==null?Oe(n):null):(n=o*a+(1-o)*n,r.push(Oe(n)))}return r}function rt(t,e){let r=[],o=Array.from({length:e},(i,s)=>s+1),n=o.reduce((i,s)=>i+s,0);for(let i=0;i<t.length;i++){if(i<e-1){r.push(null);continue}let s=0,a=!0;for(let u=0;u<e;u++){let l=t[i-e+1+u];if(l===null){a=!1;break}s+=l*o[u]}r.push(a?Oe(s/n):null)}return r}function Re(t,e={}){let{periods:r=[5,10,20,30,60,120,250],type:o="sma"}=e,n=o==="ema"?D:o==="wma"?rt:q,i={};for(let s of r)i[`ma${s}`]=n(t,s);return t.map((s,a)=>{let u={};for(let l of r)u[`ma${l}`]=i[`ma${l}`][a];return u})}function fn(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ee(t,e={}){let{short:r=12,long:o=26,signal:n=9}=e,i=D(t,r),s=D(t,o),a=t.map((l,c)=>i[c]===null||s[c]===null?null:i[c]-s[c]),u=D(a,n);return t.map((l,c)=>({dif:a[c]!==null?fn(a[c]):null,dea:u[c],macd:a[c]!==null&&u[c]!==null?fn((a[c]-u[c])*2):null}))}function Zt(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function ao(t,e,r){let o=[];for(let n=0;n<t.length;n++){if(n<e-1||r[n]===null){o.push(null);continue}let i=0,s=0;for(let a=n-e+1;a<=n;a++)t[a]!==null&&r[n]!==null&&(i+=Math.pow(t[a]-r[n],2),s++);o.push(s===e?Math.sqrt(i/e):null)}return o}function Te(t,e={}){let{period:r=20,stdDev:o=2}=e,n=q(t,r),i=ao(t,r,n);return t.map((s,a)=>{if(n[a]===null||i[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let u=n[a]+o*i[a],l=n[a]-o*i[a],c=n[a]!==0?Zt((u-l)/n[a]*100):null;return{mid:n[a],upper:Zt(u),lower:Zt(l),bandwidth:c}})}function Jt(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ie(t,e={}){let{period:r=9,kPeriod:o=3,dPeriod:n=3}=e,i=[],s=50,a=50;for(let u=0;u<t.length;u++){if(u<r-1){i.push({k:null,d:null,j:null});continue}let l=-1/0,c=1/0,m=!0;for(let f=u-r+1;f<=u;f++){if(t[f].high===null||t[f].low===null){m=!1;break}l=Math.max(l,t[f].high),c=Math.min(c,t[f].low)}let d=t[u].close;if(!m||d===null||l===c){i.push({k:null,d:null,j:null});continue}let h=(d-c)/(l-c)*100;s=(o-1)/o*s+1/o*h,a=(n-1)/n*a+1/n*s;let y=3*s-2*a;i.push({k:Jt(s),d:Jt(a),j:Jt(y)})}return i}function uo(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function be(t,e={}){let{periods:r=[6,12,24]}=e,o=[null];for(let i=1;i<t.length;i++)t[i]===null||t[i-1]===null?o.push(null):o.push(t[i]-t[i-1]);let n={};for(let i of r){let s=[],a=0,u=0;for(let l=0;l<t.length;l++){if(l<i){s.push(null),o[l]!==null&&(o[l]>0?a+=o[l]:u+=Math.abs(o[l]));continue}if(l===i)a=a/i,u=u/i;else{let c=o[l]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(i-1)+m)/i,u=(u*(i-1)+d)/i}if(u===0)s.push(100);else if(a===0)s.push(0);else{let c=a/u;s.push(uo(100-100/(1+c)))}}n[`rsi${i}`]=s}return t.map((i,s)=>{let a={};for(let u of r)a[`rsi${u}`]=n[`rsi${u}`][s];return a})}function lo(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function _e(t,e={}){let{periods:r=[6,10]}=e,o={};for(let n of r){let i=[];for(let s=0;s<t.length;s++){if(s<n-1){i.push(null);continue}let a=-1/0,u=1/0,l=!0;for(let d=s-n+1;d<=s;d++){if(t[d].high===null||t[d].low===null){l=!1;break}a=Math.max(a,t[d].high),u=Math.min(u,t[d].low)}let c=t[s].close;if(!l||c===null||a===u){i.push(null);continue}let m=(a-c)/(a-u)*100;i.push(lo(m))}o[`wr${n}`]=i}return t.map((n,i)=>{let s={};for(let a of r)s[`wr${a}`]=o[`wr${a}`][i];return s})}function co(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Pe(t,e={}){let{periods:r=[6,12,24]}=e,o={};for(let n of r){let i=q(t,n),s=[];for(let a=0;a<t.length;a++)if(t[a]===null||i[a]===null||i[a]===0)s.push(null);else{let u=(t[a]-i[a])/i[a]*100;s.push(co(u))}o[`bias${n}`]=s}return t.map((n,i)=>{let s={};for(let a of r)s[`bias${a}`]=o[`bias${a}`][i];return s})}function po(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ae(t,e={}){let{period:r=14}=e,o=[],n=t.map(i=>i.high===null||i.low===null||i.close===null?null:(i.high+i.low+i.close)/3);for(let i=0;i<t.length;i++){if(i<r-1){o.push({cci:null});continue}let s=0,a=0;for(let m=i-r+1;m<=i;m++)n[m]!==null&&(s+=n[m],a++);if(a!==r||n[i]===null){o.push({cci:null});continue}let u=s/r,l=0;for(let m=i-r+1;m<=i;m++)l+=Math.abs(n[m]-u);let c=l/r;if(c===0)o.push({cci:0});else{let m=(n[i]-u)/(.015*c);o.push({cci:po(m)})}}return o}function er(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function W(t,e={}){let{period:r=14}=e,o=[],n=[];for(let s=0;s<t.length;s++){let{high:a,low:u,close:l}=t[s];if(a===null||u===null||l===null){n.push(null);continue}if(s===0)n.push(a-u);else{let c=t[s-1].close;if(c===null)n.push(a-u);else{let m=a-u,d=Math.abs(a-c),h=Math.abs(u-c);n.push(Math.max(m,d,h))}}}let i=null;for(let s=0;s<t.length;s++){if(s<r-1){o.push({tr:n[s]!==null?er(n[s]):null,atr:null});continue}if(s===r-1){let a=0,u=0;for(let l=0;l<r;l++)n[l]!==null&&(a+=n[l],u++);u===r&&(i=a/r)}else i!==null&&n[s]!==null&&(i=(i*(r-1)+n[s])/r);o.push({tr:n[s]!==null?er(n[s]):null,atr:i!==null?er(i):null})}return o}function xe(t,e={}){let{maPeriod:r}=e,o=[];if(t.length===0)return o;let n=t[0].volume??0;o.push({obv:n,obvMa:null});for(let i=1;i<t.length;i++){let s=t[i],a=t[i-1];if(s.close===null||a.close===null||s.volume===null||s.volume===void 0){o.push({obv:null,obvMa:null});continue}s.close>a.close?n+=s.volume:s.close<a.close&&(n-=s.volume),o.push({obv:n,obvMa:null})}if(r&&r>0)for(let i=r-1;i<o.length;i++){let s=0,a=0;for(let u=i-r+1;u<=i;u++)o[u].obv!==null&&(s+=o[u].obv,a++);a===r&&(o[i].obvMa=s/r)}return o}function Me(t,e={}){let{period:r=12,signalPeriod:o}=e,n=[];for(let i=0;i<t.length;i++){if(i<r){n.push({roc:null,signal:null});continue}let s=t[i].close,a=t[i-r].close;if(s===null||a===null||a===0){n.push({roc:null,signal:null});continue}let u=(s-a)/a*100;n.push({roc:u,signal:null})}if(o&&o>0)for(let i=r+o-1;i<n.length;i++){let s=0,a=0;for(let u=i-o+1;u<=i;u++)n[u].roc!==null&&(s+=n[u].roc,a++);a===o&&(n[i].signal=s/o)}return n}function Le(t,e={}){let{period:r=14,adxPeriod:o=r}=e,n=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let i=[],s=[],a=[];for(let f=0;f<t.length;f++){if(f===0){i.push(0),s.push(0),a.push(0),n.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],E=t[f-1];if(C.high===null||C.low===null||C.close===null||E.high===null||E.low===null||E.close===null){i.push(0),s.push(0),a.push(0),n.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let b=C.high-C.low,_=Math.abs(C.high-E.close),N=Math.abs(C.low-E.close);a.push(Math.max(b,_,N));let U=C.high-E.high,Y=E.low-C.low;U>Y&&U>0?i.push(U):i.push(0),Y>U&&Y>0?s.push(Y):s.push(0),n.push({pdi:null,mdi:null,adx:null,adxr:null})}let u=0,l=0,c=0,m=[];for(let f=1;f<t.length;f++){if(f<r){u+=a[f],l+=i[f],c+=s[f],m.push(0);continue}f===r?(u=u,l=l,c=c):(u=u-u/r+a[f],l=l-l/r+i[f],c=c-c/r+s[f]);let C=u>0?l/u*100:0,E=u>0?c/u*100:0;n[f].pdi=C,n[f].mdi=E;let b=C+E,_=b>0?Math.abs(C-E)/b*100:0;m.push(_)}let d=0,h=0,y=0;for(let f=r;f<t.length;f++){if(f<r*2-1){d+=m[f-r+1]||0,h++;continue}if(f===r*2-1)d+=m[f-r+1]||0,y=d/o,n[f].adx=y;else{let C=m[f-r+1]||0;y=(y*(o-1)+C)/o,n[f].adx=y}}for(let f=r*2-1+o;f<t.length;f++){let C=n[f].adx,E=n[f-o]?.adx;C!==null&&E!==null&&(n[f].adxr=(C+E)/2)}return n}function ve(t,e={}){let{afStart:r=.02,afIncrement:o=.02,afMax:n=.2}=e,i=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,a=r,u=t[0].high??0,l=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(s=-1,u=c.low??0,l=c.high??0),i.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let h=t[d],y=t[d-1];if(h.high===null||h.low===null||y.high===null||y.low===null){i.push({sar:null,trend:null,ep:null,af:null});continue}let f=l+a*(u-l);s===1?(f=Math.min(f,y.low,t[Math.max(0,d-2)]?.low??y.low),h.low<f?(s=-1,f=u,u=h.low,a=r):h.high>u&&(u=h.high,a=Math.min(a+o,n))):(f=Math.max(f,y.high,t[Math.max(0,d-2)]?.high??y.high),h.high>f?(s=1,f=u,u=h.high,a=r):h.low<u&&(u=h.low,a=Math.min(a+o,n))),l=f,i.push({sar:l,trend:s,ep:u,af:a})}return i}function Ke(t,e={}){let{emaPeriod:r=20,atrPeriod:o=10,multiplier:n=2}=e,i=[],s=t.map(l=>l.close),a=D(s,r),u=W(t,{period:o});for(let l=0;l<t.length;l++){let c=a[l],m=u[l]?.atr;if(c===null||m===null){i.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+n*m,h=c-n*m,y=c>0?(d-h)/c*100:null;i.push({mid:c,upper:d,lower:h,width:y})}return i}function nt(t,e=0){return t.length===0?e:Math.max(...t)}function ke(t){return{closes:t.map(e=>e.close),ohlcv:t.map(e=>({open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}}var V={ma:{key:"ma",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.periods??[5,10,20,30,60,120,250],o=e.type??"sma";return{bars:nt(r,20),emaBased:o==="ema"}},compute:(t,e)=>Re(t.closes,typeof e=="object"?e:{})},macd:{key:"macd",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.long??26,o=e.signal??9;return{bars:r*3+o,emaBased:!0}},compute:(t,e)=>Ee(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>Te(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>Ie(t.ohlcv,typeof e=="object"?e:{})},rsi:{key:"rsi",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,12,24];return{bars:nt(e,14)+1}},compute:(t,e)=>be(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:nt(e,10)}},compute:(t,e)=>_e(t.ohlcv,typeof e=="object"?e:{})},bias:{key:"bias",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,12,24];return{bars:nt(e,12)}},compute:(t,e)=>Pe(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>Ae(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>W(t.ohlcv,typeof e=="object"?e:{})},obv:{key:"obv",estimateLookback:t=>{let e=typeof t=="object"&&t.maPeriod?t.maPeriod:0;return{bars:Math.max(2,e)}},compute:(t,e)=>xe(t.ohlcv,typeof e=="object"?e:{})},roc:{key:"roc",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.period??12,o=e.signalPeriod??0;return{bars:r+o}},compute:(t,e)=>Me(t.ohlcv,typeof e=="object"?e:{})},dmi:{key:"dmi",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.period??14,o=e.adxPeriod??r;return{bars:r*2+o}},compute:(t,e)=>Le(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>ve(t.ohlcv,typeof e=="object"?e:{})},kc:{key:"kc",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.emaPeriod??20,o=e.atrPeriod??10;return{bars:Math.max(r*3,o),emaBased:!0}},compute:(t,e)=>Ke(t.ohlcv,typeof e=="object"?e:{})}};function J(t){return Object.keys(V).filter(e=>!!t[e])}function Ue(t){let e=0,r=!1;for(let n of J(t)){let s=V[n].estimateLookback(t[n]);e=Math.max(e,s.bars),r||(r=!!s.emaBased)}return{maxLookback:e,hasEmaBasedIndicator:r,requiredBars:Math.ceil(e*(r?1.5:1.2))}}function Fe(t,e={}){if(t.length===0)return[];let r=ke(t),o=new Map;for(let n of J(e)){let i=V[n];o.set(n,i.compute(r,e[n]))}return t.map((n,i)=>({...n,...Object.fromEntries(Array.from(o.entries()).map(([s,a])=>[s,a[i]]))}))}var De=class{constructor(e,r){this.klineService=e;this.quoteService=r}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}calcActualStartDate(e,r,o=1.5){let n=Math.ceil(r*o),i=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));i.setDate(i.getDate()-n);let s=i.getFullYear(),a=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0");return`${s}${a}${u}`}calcActualStartDateByCalendar(e,r,o){if(!o||o.length===0)return;let n=this.normalizeDate(e),i=o.findIndex(a=>a>=n);i===-1&&(i=o.length-1);let s=Math.max(0,i-r);return this.toCompactDate(o[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 r=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(r).getTime()}async getKlineWithIndicators(e,r={}){let{startDate:o,endDate:n,indicators:i={}}=r,s=r.market??this.detectMarket(e),{requiredBars:a}=Ue(i),u={A:1.5,HK:1.46,US:1.45},l;if(o)if(s==="A")try{let h=await this.quoteService.getTradingCalendar();l=this.calcActualStartDateByCalendar(o,a,h)??this.calcActualStartDate(o,a,u[s])}catch{l=this.calcActualStartDate(o,a,u[s])}else l=this.calcActualStartDate(o,a,u[s]);let c={period:r.period,adjust:r.adjust,startDate:l,endDate:r.endDate},m;switch(s){case"HK":m=await this.klineService.getHKHistoryKline(e,c);break;case"US":m=await this.klineService.getUSHistoryKline(e,c);break;default:m=await this.klineService.getHistoryKline(e,c)}if(o&&m.length<a)switch(s){case"HK":m=await this.klineService.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.klineService.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.klineService.getHistoryKline(e,{...c,startDate:void 0})}let d=Fe(m,i);if(o){let h=this.dateToTimestamp(o),y=n?this.dateToTimestamp(n):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=h&&C<=y})}return d}};var Ne=class{constructor(e={}){this.client=new pe(e),this.quoteService=new ge(this.client),this.boardService=new he(this.client),this.klineService=new ye(this.client),this.futuresService=new Se(this.client),this.optionsService=new Ce(this.client),this.indicatorService=new De(this.klineService,this.quoteService)}getFullQuotes(e){return this.quoteService.getFullQuotes(e)}getSimpleQuotes(e){return this.quoteService.getSimpleQuotes(e)}getHKQuotes(e){return this.quoteService.getHKQuotes(e)}getUSQuotes(e){return this.quoteService.getUSQuotes(e)}getFundQuotes(e){return this.quoteService.getFundQuotes(e)}getFundFlow(e){return this.quoteService.getFundFlow(e)}getPanelLargeOrder(e){return this.quoteService.getPanelLargeOrder(e)}getTodayTimeline(e){return this.quoteService.getTodayTimeline(e)}getIndustryList(){return this.boardService.getIndustryList()}getIndustrySpot(e){return this.boardService.getIndustrySpot(e)}getIndustryConstituents(e){return this.boardService.getIndustryConstituents(e)}getIndustryKline(e,r){return this.boardService.getIndustryKline(e,r)}getIndustryMinuteKline(e,r){return this.boardService.getIndustryMinuteKline(e,r)}getConceptList(){return this.boardService.getConceptList()}getConceptSpot(e){return this.boardService.getConceptSpot(e)}getConceptConstituents(e){return this.boardService.getConceptConstituents(e)}getConceptKline(e,r){return this.boardService.getConceptKline(e,r)}getConceptMinuteKline(e,r){return this.boardService.getConceptMinuteKline(e,r)}getHistoryKline(e,r){return this.klineService.getHistoryKline(e,r)}getMinuteKline(e,r){return this.klineService.getMinuteKline(e,r)}getHKHistoryKline(e,r){return this.klineService.getHKHistoryKline(e,r)}getUSHistoryKline(e,r){return this.klineService.getUSHistoryKline(e,r)}search(e){return this.quoteService.search(e)}getAShareCodeList(e){return this.quoteService.getAShareCodeList(e)}getUSCodeList(e){return this.quoteService.getUSCodeList(e)}getHKCodeList(){return this.quoteService.getHKCodeList()}getFundCodeList(){return this.quoteService.getFundCodeList()}getAllAShareQuotes(e={}){return this.quoteService.getAllAShareQuotes(e)}getAllHKShareQuotes(e={}){return this.quoteService.getAllHKShareQuotes(e)}getAllUSShareQuotes(e={}){return this.quoteService.getAllUSShareQuotes(e)}getAllQuotesByCodes(e,r={}){return this.quoteService.getAllQuotesByCodes(e,r)}batchRaw(e){return this.quoteService.batchRaw(e)}getTradingCalendar(){return this.quoteService.getTradingCalendar()}getDividendDetail(e){return this.quoteService.getDividendDetail(e)}getFuturesKline(e,r){return this.futuresService.getFuturesKline(e,r)}getGlobalFuturesSpot(e){return this.futuresService.getGlobalFuturesSpot(e)}getGlobalFuturesKline(e,r){return this.futuresService.getGlobalFuturesKline(e,r)}getFuturesInventorySymbols(){return this.futuresService.getFuturesInventorySymbols()}getFuturesInventory(e,r){return this.futuresService.getFuturesInventory(e,r)}getComexInventory(e,r){return this.futuresService.getComexInventory(e,r)}getIndexOptionSpot(e,r){return this.optionsService.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return this.optionsService.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return this.optionsService.getCFFEXOptionQuotes(e)}getETFOptionMonths(e){return this.optionsService.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return this.optionsService.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return this.optionsService.getETFOptionMinute(e)}getETFOptionDailyKline(e){return this.optionsService.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return this.optionsService.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return this.optionsService.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return this.optionsService.getCommodityOptionKline(e)}getOptionLHB(e,r){return this.optionsService.getOptionLHB(e,r)}getKlineWithIndicators(e,r={}){return this.indicatorService.getKlineWithIndicators(e,r)}},gn=Ne;0&&(module.exports={HttpError,INDICATOR_REGISTRY,SdkError,StockSDK,addIndicators,asyncPool,buildIndicatorContext,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,estimateIndicatorLookback,extractJsonFromJsonp,getEnabledIndicatorKeys,getSdkErrorCode,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});
|
|
1
|
+
"use strict";var yt=Object.defineProperty;var fo=Object.getOwnPropertyDescriptor;var ho=Object.getOwnPropertyNames;var To=Object.prototype.hasOwnProperty;var Ze=(t,e)=>{for(var r in e)yt(t,r,{get:e[r],enumerable:!0})},yo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ho(e))!To.call(t,o)&&o!==r&&yt(t,o,{get:()=>e[o],enumerable:!(n=fo(e,o))||n.enumerable});return t};var So=t=>yo(yt({},"__esModule",{value:!0}),t);var Ci={};Ze(Ci,{HttpError:()=>v,INDICATOR_REGISTRY:()=>ee,SdkError:()=>k,StockSDK:()=>Xe,addIndicators:()=>Qe,asyncPool:()=>W,buildIndicatorContext:()=>qe,calcATR:()=>J,calcBIAS:()=>xe,calcBOLL:()=>Me,calcCCI:()=>ve,calcDMI:()=>Be,calcEMA:()=>q,calcKC:()=>He,calcKDJ:()=>Ne,calcMA:()=>be,calcMACD:()=>Le,calcOBV:()=>Ue,calcROC:()=>we,calcRSI:()=>ke,calcSAR:()=>Ke,calcSMA:()=>z,calcWMA:()=>gt,calcWR:()=>Fe,chunkArray:()=>V,decodeGBK:()=>ie,default:()=>mo,estimateIndicatorLookback:()=>$e,extractJsonFromJsonp:()=>ut,getEnabledIndicatorKeys:()=>oe,getSdkErrorCode:()=>Q,jsonpRequest:()=>b,parseResponse:()=>se,safeNumber:()=>h,safeNumberOrNull:()=>E});module.exports=So(Ci);function ie(t){return new TextDecoder("gbk").decode(t)}function se(t){let e=t.split(";").map(n=>n.trim()).filter(Boolean),r=[];for(let n of e){let o=n.indexOf("=");if(o<0)continue;let i=n.slice(0,o).trim();i.startsWith("v_")&&(i=i.slice(2));let s=n.slice(o+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let u=s.split("~");r.push({key:i,fields:u})}return r}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function E(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function m(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function a(t){return t==null?null:m(String(t))}var St="https://qt.gtimg.cn",Rt="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Et="https://assets.linkdiary.cn/shares/zh_a_list.json",Ct="https://assets.linkdiary.cn/shares/us_list.json",Ot="https://assets.linkdiary.cn/shares/hk_list.json",_t="https://assets.linkdiary.cn/shares/fund_list",Rr="https://assets.linkdiary.cn/shares/trade-data-list.txt";var Je="https://push2his.eastmoney.com/api/qt/stock/kline/get",At="https://push2his.eastmoney.com/api/qt/stock/trends2/get",It="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Pt="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Dt="https://17.push2.eastmoney.com/api/qt/clist/get",bt="https://91.push2.eastmoney.com/api/qt/stock/get",Lt="https://29.push2.eastmoney.com/api/qt/clist/get",Mt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Nt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",kt="https://79.push2.eastmoney.com/api/qt/clist/get",Ft="https://91.push2.eastmoney.com/api/qt/stock/get",xt="https://29.push2.eastmoney.com/api/qt/clist/get",vt="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Ut="https://push2his.eastmoney.com/api/qt/stock/trends2/get",wt="https://datacenter-web.eastmoney.com/api/data/v1/get",ae="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",Bt="https://push2.eastmoney.com/api/qt/clist/get",Kt="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",ue="https://push2ex.eastmoney.com",M="7eea3edcaed734bea9cbfc24409ed989",x="b2884a393a59ad64002292a3e90d46a5",le="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ht="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",ce="58b2fa8f54638b60b87d69b31969089c",qt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},te={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"},et={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},pe="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",de="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",$t="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",tt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",Qt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",jt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",Gt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",zt="https://futsseapi.eastmoney.com/list/option/221",Yt="https://datacenter-web.eastmoney.com/api/data/get";var rt={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"}},Vt=3e4,me=500,ge=500,fe=7,Wt=3,Xt=1e3,Zt=3e4,Jt=2,er=[408,429,500,502,503,504];var nt=class{constructor(e={}){let r=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??r,this.tokens=this.maxTokens,this.refillRate=r/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),n=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+n),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(r=>setTimeout(r,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Er=["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"],tr=0;function Ro(){return typeof window<"u"&&typeof window.document<"u"}function Cr(){if(Ro())return;let t=Er[tr];return tr=(tr+1)%Er.length,t}var k=class extends Error{constructor(e){super(e.message),this.name="SdkError",this.code=e.code,this.provider=e.provider,this.url=e.url,this.status=e.status,this.details=e.details,e.cause!==void 0&&(this.cause=e.cause)}},v=class extends k{constructor(r,n,o,i){let s=n?` ${n}`:"",u=o?`, url: ${o}`:"",l=i?`, provider: ${i}`:"";super({code:r===429?"RATE_LIMITED":"HTTP_ERROR",message:`HTTP error! status: ${r}${s}${u}${l}`,status:r,url:o,provider:i,details:{statusText:n}});this.status=r;this.name="HttpError",this.statusText=n}};var Te=class extends k{constructor(e,r,n){super({code:"NOT_FOUND",message:e,provider:r,url:n}),this.name="NotFoundError"}};function he(t,e){let r=t;return!r.sdkCode&&e.sdkCode&&(r.sdkCode=e.sdkCode),!r.provider&&e.provider&&(r.provider=e.provider),!r.url&&e.url&&(r.url=e.url),r.status===void 0&&e.status!==void 0&&(r.status=e.status),!r.details&&e.details&&(r.details=e.details),r}function Eo(t,e){return he(t,{provider:e.provider,url:e.url})}function Q(t){if(t instanceof k||t instanceof v)return t.code;if(t instanceof DOMException&&t.name==="AbortError")return"TIMEOUT";if(t instanceof TypeError)return t.sdkCode??"NETWORK_ERROR";if(t instanceof Error)return t.sdkCode}function ot(t,e={}){return t instanceof k?Eo(t,e):t instanceof DOMException&&t.name==="AbortError"?he(t,{sdkCode:"TIMEOUT",provider:e.provider,url:e.url,details:e.timeout?{timeout:e.timeout}:void 0}):t instanceof TypeError?he(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):t instanceof Error?he(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):new k({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var re=class extends k{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},it=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 r=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(r,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 r=await e();return this.recordSuccess(),r}catch(r){throw this.recordFailure(),r}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var Co=3e4,Oo=1,Or=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],_r=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function _o(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Or:t.includes("push2.eastmoney.com")?_r:[t]}function Ao(t){return Array.from(new Set(t))}var st=class{constructor(e=Co,r=Oo){this.cooldownMs=e;this.failureThreshold=r;this.states=new Map}getCandidateUrls(e,r){let n;try{n=new URL(e)}catch{return[e]}let o=Date.now(),i=_o(n.hostname,r);if(i.length<=1)return[e];let s=i.filter(c=>{let p=this.states.get(c);return!p||p.cooldownUntil<=o}),u=i.filter(c=>{let p=this.states.get(c);return p&&p.cooldownUntil>o});return Ao([...s.includes(n.hostname)?[n.hostname]:[],...s.filter(c=>c!==n.hostname),...u.includes(n.hostname)?[n.hostname]:[],...u.filter(c=>c!==n.hostname)]).map(c=>{let p=new URL(e);return p.hostname=c,p.toString()})}recordSuccess(e){let r=this.safeGetHost(e);if(!r)return;let n=this.getState(r);n.failureCount=0,n.cooldownUntil=0,n.successCount++,n.lastErrorCode=void 0}recordFailure(e,r){let n=this.safeGetHost(e);if(!n)return;let o=this.getState(n);o.failureCount++,o.lastFailureAt=Date.now(),o.lastErrorCode=Q(r),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let r=Q(e);return r==="NETWORK_ERROR"||r==="TIMEOUT"?!0:e instanceof v?e.status===408||e.status===429||e.status>=500:!1}getStats(e){let r=Array.from(this.states.values()).map(o=>({...o}));if(!e)return r;if(e!=="eastmoney")return[];let n=new Set([...Or,..._r]);return r.filter(o=>n.has(o.host))}safeGetHost(e){try{return new URL(e).hostname}catch{return null}}getState(e){let r=this.states.get(e);if(r)return r;let n={host:e,failureCount:0,successCount:0,cooldownUntil:0,lastFailureAt:0};return this.states.set(e,n),n}};function Io(t){return{maxRetries:t?.maxRetries??Wt,baseDelay:t?.baseDelay??Xt,maxDelay:t?.maxDelay??Zt,backoffMultiplier:t?.backoffMultiplier??Jt,retryableStatusCodes:t?.retryableStatusCodes??er,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function Po(t,e){let r={...t??{}};return e&&(Object.keys(r).some(o=>o.toLowerCase()==="user-agent")||(r["User-Agent"]=e)),r}function Ar(t,e){return e?{timeout:e.timeout??t.timeout,retry:e.retry?{...t.retry??{},...e.retry}:t.retry?{...t.retry}:void 0,headers:{...t.headers??{},...e.headers??{}},userAgent:e.userAgent??t.userAgent,rateLimit:e.rateLimit?{...t.rateLimit??{},...e.rateLimit}:t.rateLimit?{...t.rateLimit}:void 0,rotateUserAgent:e.rotateUserAgent??t.rotateUserAgent,circuitBreaker:e.circuitBreaker?{...t.circuitBreaker??{},...e.circuitBreaker}:t.circuitBreaker?{...t.circuitBreaker}:void 0}:{...t,headers:{...t.headers??{}},retry:t.retry?{...t.retry}:void 0,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function rr(t={}){return{timeout:t.timeout??Vt,retry:Io(t.retry),headers:Po(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function Ir(t,e){if(e)return e;try{let r=new URL(t).hostname;if(r.includes("eastmoney.com"))return"eastmoney";if(r.includes("gtimg.cn"))return"tencent";if(r.includes("sina.com.cn"))return"sina";if(r.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}var ye=class{constructor(e={}){this.baseUrl=e.baseUrl??St;let r={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=rr(r),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new st;for(let[n,o]of Object.entries(e.providerPolicies??{})){let i=Ar(r,o);this.providerPolicies[n]=rr(i)}}getProviderState(e){let r=this.runtimeStates.get(e);if(r)return r;let n=this.providerPolicies[e]??this.defaultPolicy,o={policy:n,rateLimiter:n.rateLimit?new nt(n.rateLimit):null,circuitBreaker:n.circuitBreaker?new it(n.circuitBreaker):null};return this.runtimeStates.set(e,o),o}getTimeout(){return this.defaultPolicy.timeout}getHostHealth(e){return this.fallbackManager.getStats(e)}calculateDelay(e,r){return Math.min(r.baseDelay*Math.pow(r.backoffMultiplier,e),r.maxDelay)+Math.random()*100}sleep(e){return new Promise(r=>setTimeout(r,e))}shouldRetry(e,r,n){if(r>=n.maxRetries)return!1;let o=Q(e);return o==="TIMEOUT"?n.retryOnTimeout:o==="NETWORK_ERROR"?n.retryOnNetworkError:e instanceof v?n.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,r,n,o=0){try{return await e()}catch(i){let s=ot(i,n);if(this.shouldRetry(s,o,r)){let u=this.calculateDelay(o,r);return r.onRetry&&r.onRetry(o+1,s,u),await this.sleep(u),this.executeWithRetry(e,r,n,o+1)}throw s}}async performRequest(e,r,n,o="text"){r.rateLimiter&&await r.rateLimiter.acquire();let i=new AbortController,s=setTimeout(()=>i.abort(),r.policy.timeout),u={...r.policy.headers};if(r.policy.rotateUserAgent){let l=Cr();if(l){for(let c of Object.keys(u))c.toLowerCase()==="user-agent"&&delete u[c];u["User-Agent"]=l}}try{let l=await fetch(e,{signal:i.signal,headers:u});if(!l.ok)throw new v(l.status,l.statusText,e,n);switch(o){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}finally{clearTimeout(s)}}async get(e,r={}){let n=Ir(e,r.provider),o=this.getProviderState(n);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new re("Circuit breaker is OPEN, request rejected");let i=this.fallbackManager.getCandidateUrls(e,n),s;for(let u=0;u<i.length;u++){let l=i[u],c=u===0?o.policy.retry:{...o.policy.retry,maxRetries:0};try{let p=await this.executeWithRetry(()=>this.performRequest(l,o,n,r.responseType),c,{provider:n,url:l,timeout:o.policy.timeout});return o.circuitBreaker?.recordSuccess(),this.fallbackManager.recordSuccess(l),p}catch(p){let d=ot(p,{provider:n,url:l,timeout:o.policy.timeout});if(s=d,this.fallbackManager.recordFailure(l,d),u<i.length-1&&this.fallbackManager.shouldFallback(d))continue;throw o.circuitBreaker?.recordFailure(),d}}throw o.circuitBreaker?.recordFailure(),s??new re("Request failed without a concrete error")}async getTencentQuote(e){let r=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,n=await this.get(r,{responseType:"arraybuffer",provider:"tencent"}),o=ie(n);return se(o)}};var Do=new Set(["daily","weekly","monthly"]),bo=new Set(["1","5","15","30","60"]),Lo=new Set(["","qfq","hfq"]);function H(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function U(t){if(!Do.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function Se(t){if(!bo.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function j(t){if(!Lo.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function V(t,e){H(e,"chunkSize");let r=[];for(let n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}async function W(t,e,r=!1){if(H(e,"concurrency"),t.length===0)return[];let n=r?new Array(t.length):[],o=0,i=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let s=o++;if(s>=t.length)return;let u=await t[s]();r?n[s]=u:n.push(u)}});return await Promise.all(i),n}function ne(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function w(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function G(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var at=class{constructor(e={}){this.cache=new Map;this.inflight=new Map;this.defaultTTL=e.defaultTTL??0,this.maxSize=e.maxSize??1e3}get(e){let r=this.cache.get(e);if(r){if(r.expireAt>0&&Date.now()>r.expireAt){this.cache.delete(e);return}return r.lastAccess=Date.now(),r.value}}set(e,r,n){this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictLRU();let o=n??this.defaultTTL,i=Date.now();this.cache.set(e,{value:r,expireAt:o>0?i+o:0,lastAccess:i})}has(e){return this.get(e)!==void 0}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.inflight.clear()}get size(){return this.cache.size}cleanup(){let e=Date.now(),r=0;for(let[n,o]of this.cache)o.expireAt>0&&e>o.expireAt&&(this.cache.delete(n),r++);return r}evictLRU(){let e=null,r=1/0;for(let[n,o]of this.cache)o.lastAccess<r&&(r=o.lastAccess,e=n);e&&this.cache.delete(e)}async getOrFetch(e,r,n){let o=this.get(e);if(o!==void 0)return o;let i=this.inflight.get(e);if(i)return i;let s=r().then(u=>(this.set(e,u,n),u)).finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,s),s}},Pr=new Map;function X(t,e){let r=Pr.get(t);if(r)return r;let n=new at(e);return Pr.set(t,n),n}var Mo=typeof document<"u"&&typeof window<"u",No=0;function Dr(){return`__stock_sdk_jsonp_${Date.now()}_${No++}`}function ut(t){let e=t,r=e.indexOf("*/");r!==-1&&(e=e.slice(r+2).trim());let n=e.indexOf("(");if(n===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let o=e.lastIndexOf(")");if(o===-1||o<=n)throw new Error("Invalid JSONP response: no closing parenthesis found");let i=e.slice(n+1,o);return JSON.parse(i)}function ko(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let u=Dr(),l;if(o==="path")l=t.replace("{callback}",u);else{let S=t.includes("?")?"&":"?";l=`${t}${S}${n}=${u}`}let c=document.createElement("script"),p=!1,d=window,f=()=>{c.parentNode&&c.parentNode.removeChild(c),delete d[u]},y=setTimeout(()=>{p||(p=!0,f(),s(new Error(`JSONP request timed out after ${r}ms: ${t}`)))},r);d[u]=S=>{p||(p=!0,clearTimeout(y),f(),i(S))},c.onerror=()=>{p||(p=!0,clearTimeout(y),f(),s(new Error(`JSONP script load failed: ${t}`)))},c.src=l,document.head.appendChild(c)})}async function Fo(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e,i=Dr(),s;if(o==="path")s=t.replace("{callback}",i);else{let c=t.includes("?")?"&":"?";s=`${t}${c}${n}=${i}`}let u=new AbortController,l=setTimeout(()=>u.abort(),r);try{let c=await fetch(s,{signal:u.signal});if(!c.ok)throw new Error(`JSONP fetch failed with status ${c.status}: ${t}`);let p=await c.text();return ut(p)}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new Error(`JSONP request timed out after ${r}ms: ${t}`):c}finally{clearTimeout(l)}}function b(t,e={}){return Mo?ko(t,e):Fo(t,e)}var A={};Ze(A,{getAShareCodeList:()=>xr,getAllHKQuotesByCodes:()=>Br,getAllQuotesByCodes:()=>wr,getAllUSQuotesByCodes:()=>Kr,getFullQuotes:()=>lt,getFundCodeList:()=>Hr,getFundFlow:()=>Lr,getFundQuotes:()=>Nr,getHKCodeList:()=>Ur,getHKQuotes:()=>ct,getPanelLargeOrder:()=>Mr,getSimpleQuotes:()=>br,getTodayTimeline:()=>kr,getTradingCalendar:()=>qr,getUSCodeList:()=>vr,getUSQuotes:()=>pt,parseFullQuote:()=>nr,parseFundFlow:()=>ir,parseFundQuote:()=>lr,parseHKQuote:()=>ar,parsePanelLargeOrder:()=>sr,parseSimpleQuote:()=>or,parseUSQuote:()=>ur,search:()=>Qr});function nr(t){let e=[];for(let n=0;n<5;n++)e.push({price:h(t[9+n*2]),volume:h(t[10+n*2])});let r=[];for(let n=0;n<5;n++)r.push({price:h(t[19+n*2]),volume:h(t[20+n*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:r,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:E(t[38]),pe:E(t[39]),amplitude:E(t[43]),circulatingMarketCap:E(t[44]),totalMarketCap:E(t[45]),pb:E(t[46]),limitUp:E(t[47]),limitDown:E(t[48]),volumeRatio:E(t[49]),avgPrice:E(t[51]),peStatic:E(t[52]),peDynamic:E(t[53]),high52w:E(t[67]),low52w:E(t[68]),circulatingShares:E(t[72]),totalShares:E(t[73]),raw:t}}function or(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:E(t[9]),marketType:t[10]??"",raw:t}}function ir(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 sr(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function ar(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:E(t[40]),circulatingMarketCap:E(t[44]),totalMarketCap:E(t[45]),currency:t[t.length-3]??"",raw:t}}function ur(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:E(t[38]),pe:E(t[39]),amplitude:E(t[43]),totalMarketCap:E(t[45]),pb:E(t[47]),high52w:E(t[48]),low52w:E(t[49]),raw:t}}function lr(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 lt(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(n=>n.fields&&n.fields.length>0&&n.fields[0]!=="").map(n=>nr(n.fields))}async function br(t,e){if(!e||e.length===0)return[];let r=e.map(o=>`s_${o}`);return(await t.getTencentQuote(r.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>or(o.fields))}async function Lr(t,e){if(!e||e.length===0)return[];let r=e.map(o=>`ff_${o}`);return(await t.getTencentQuote(r.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>ir(o.fields))}async function Mr(t,e){if(!e||e.length===0)return[];let r=e.map(o=>`s_pk${o}`);return(await t.getTencentQuote(r.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>sr(o.fields))}async function ct(t,e){if(!e||e.length===0)return[];let r=e.map(o=>`hk${o}`);return(await t.getTencentQuote(r.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>ar(o.fields))}async function pt(t,e){if(!e||e.length===0)return[];let r=e.map(o=>`us${o}`);return(await t.getTencentQuote(r.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>ur(o.fields))}async function Nr(t,e){if(!e||e.length===0)return[];let r=e.map(o=>`jj${o}`);return(await t.getTencentQuote(r.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>lr(o.fields))}async function kr(t,e){let r=t.getTimeout(),n=new AbortController,o=setTimeout(()=>n.abort(),r);try{let i=await fetch(`${Rt}?code=${e}`,{signal:n.signal});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let s=await i.json();if(s.code!==0)throw new Error(s.msg||"API error");let u=s.data?.[e];if(!u)return{code:e,date:"",preClose:0,data:[]};let l=u.data?.data||[],c=u.data?.date||"",p=Array.isArray(u.qt?.[e])?u.qt[e]:[],d=parseFloat(p[4]??"")||0,f=!1;if(l.length>0){let S=l[0].split(" "),g=parseFloat(S[1])||0,R=parseInt(S[2],10)||0,C=parseFloat(S[3])||0;R>0&&g>0&&C/R>g*50&&(f=!0)}let y=l.map(S=>{let g=S.split(" "),R=g[0],C=`${R.slice(0,2)}:${R.slice(2,4)}`,I=parseInt(g[2],10)||0,P=parseFloat(g[3])||0,D=f?I*100:I,N=D>0?P/D:0;return{time:C,price:parseFloat(g[1])||0,volume:D,amount:P,avgPrice:Math.round(N*100)/100}});return{code:e,date:c,preClose:d,data:y}}finally{clearTimeout(o)}}var Fr=X("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function cr(t,e,r){return Fr.getOrFetch(e,async()=>(await t.get(r,{responseType:"json"}))?.list||[])}function xo(t,e){let r=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return r.startsWith("6");case"sz":return r.startsWith("0")||r.startsWith("3");case"bj":return r.startsWith("92");case"kc":return r.startsWith("688");case"cy":return r.startsWith("30");default:return!0}}async function xr(t,e){let r=!1,n;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,n=e.market);let i=await cr(t,"a-share:full",Et);return n&&(i=i.filter(s=>xo(s,n))),r?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var vo={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function vr(t,e){let r=!1,n;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,n=e.market);let i=(await cr(t,"us:full",Ct)).slice();if(n){let s=vo[n];i=i.filter(u=>u.startsWith(s))}return r?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function Ur(t){return(await cr(t,"hk:full",Ot)).slice()}async function wr(t,e,r={}){let{batchSize:n=me,concurrency:o=fe,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,ge),u=V(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await lt(t,f);return c++,i&&i(c,l),y});return(await W(p,o,!0)).flat()}async function Br(t,e,r={}){let{batchSize:n=me,concurrency:o=fe,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,ge),u=V(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await ct(t,f);return c++,i&&i(c,l),y});return(await W(p,o,!0)).flat()}async function Kr(t,e,r={}){let{batchSize:n=me,concurrency:o=fe,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,ge),u=V(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await pt(t,f);return c++,i&&i(c,l),y});return(await W(p,o,!0)).flat()}async function Hr(t){return(await Fr.getOrFetch("fund:full",async()=>(await t.get(_t,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var Uo=X("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function qr(t){return(await Uo.getOrFetch("a-share",async()=>{let r=await t.get(Rr);return!r||r.trim()===""?[]:r.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0)})).slice()}var $r="https://smartbox.gtimg.cn/s3/";function wo(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function Bo(t){let e=t.toUpperCase();return e.startsWith("QDII")||e.startsWith("ETF")||e.startsWith("LOF")||e.startsWith("KJ")||e.startsWith("JJ")||e.includes("FUND")?"fund":e.startsWith("GP")||e.includes("STOCK")?"stock":e==="ZS"||e.includes("INDEX")?"index":e.startsWith("ZQ")||e.includes("BOND")?"bond":e.startsWith("QH")||e.includes("FUTURE")?"futures":e.startsWith("QZ")||e.includes("OPTION")?"option":"other"}function Ko(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(r=>{let n=r.split("~"),o=n[0]||"",i=n[1]||"",s=wo(n[2]||""),u=n[4]||"";return{code:o+i,name:s,market:o,type:u,category:Bo(u)}})}function Ho(t){return new Promise((e,r)=>{let n=`${$r}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=n,o.charset="utf-8",o.onload=()=>{let i=window.v_hint||"";document.body.removeChild(o),e(i)},o.onerror=()=>{document.body.removeChild(o),r(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function qo(t,e){let r=`${$r}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(r)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function $o(){return typeof window<"u"&&typeof document<"u"}async function Qr(t,e){if(!e||!e.trim())return[];let r;return $o()?r=await Ho(e):r=await qo(t,e),Ko(r)}var T={};Ze(T,{extractVariety:()=>mr,fetchDatacenter:()=>dr,fetchDatacenterList:()=>O,getBlockTradeDailyStat:()=>Zn,getBlockTradeDetail:()=>Xn,getBlockTradeMarketStat:()=>Wn,getBoardChanges:()=>Hn,getCFFEXOptionQuotes:()=>Tn,getComexInventory:()=>Cn,getConceptConstituents:()=>ln,getConceptKline:()=>cn,getConceptList:()=>an,getConceptMinuteKline:()=>pn,getConceptSpot:()=>un,getDividendDetail:()=>dn,getDragonTigerBranchRank:()=>Gn,getDragonTigerDetail:()=>$n,getDragonTigerInstitution:()=>jn,getDragonTigerStockSeatDetail:()=>zn,getDragonTigerStockStats:()=>Qn,getFundFlowRank:()=>bn,getFuturesHistoryKline:()=>gn,getFuturesInventory:()=>En,getFuturesInventorySymbols:()=>Rn,getFuturesMarketCode:()=>gr,getGlobalFuturesKline:()=>hn,getGlobalFuturesSpot:()=>fn,getHKHistoryKline:()=>zr,getHistoryKline:()=>jr,getIndividualFundFlow:()=>Pn,getIndustryConstituents:()=>nn,getIndustryKline:()=>on,getIndustryList:()=>tn,getIndustryMinuteKline:()=>sn,getIndustrySpot:()=>rn,getMarginAccountInfo:()=>Jn,getMarginTargetList:()=>eo,getMarketFundFlow:()=>Dn,getMinuteKline:()=>Gr,getNorthboundFlowSummary:()=>xn,getNorthboundHistory:()=>Un,getNorthboundHoldingRank:()=>vn,getNorthboundIndividual:()=>wn,getNorthboundMinute:()=>Fn,getOptionLHB:()=>yn,getSectorFundFlowHistory:()=>Mn,getSectorFundFlowRank:()=>Ln,getStockChanges:()=>Kn,getUSHistoryKline:()=>Yr,getZTPool:()=>Bn});async function pr(t,e,r,n,o=100,i){let s=[],u=1,l=0;do{let c=new URLSearchParams({...r,pn:String(u),pz:String(o),fields:n}),p=`${e}?${c.toString()}`,f=(await t.get(p,{responseType:"json"}))?.data;if(!f||!Array.isArray(f.diff))break;u===1&&(l=f.total??0);let y=f.diff.map((S,g)=>i(S,s.length+g+1));s.push(...y),u++}while(s.length<l);return s}function B(t){let[e,r,n,o,i,s,u,l,c,p,d]=t.split(",");return{date:e,open:m(r),close:m(n),high:m(o),low:m(i),volume:m(s),amount:m(u),amplitude:m(l),changePercent:m(c),change:m(p),turnoverRate:m(d)}}async function K(t,e,r){let n=`${e}?${r.toString()}`,o=await t.get(n,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function jr(t,e,r={}){let{period:n="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=r;U(n),j(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${ne(e)}.${u}`,c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:M,klt:w(n),fqt:G(o),secid:l,beg:i,end:s}),p=Je,{klines:d}=await K(t,p,c);return d.length===0?[]:d.map(f=>({...B(f),code:u}))}async function Gr(t,e,r={}){let{period:n="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=r;Se(n),j(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${ne(e)}.${u}`;if(n==="1"){let c=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:M,ndays:"5",iscr:"0",secid:l}),p=`${At}?${c.toString()}`,f=(await t.get(p,{responseType:"json"}))?.data?.trends;if(!Array.isArray(f)||f.length===0)return[];let y=i.replace("T"," ").slice(0,16),S=s.replace("T"," ").slice(0,16);return f.map(g=>{let[R,C,I,P,D,N,Y,$]=g.split(",");return{time:R,open:m(C),close:m(I),high:m(P),low:m(D),volume:m(N),amount:m(Y),avgPrice:m($)}}).filter(g=>g.time>=y&&g.time<=S)}else{let c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:M,klt:n,fqt:G(o||""),secid:l,beg:"0",end:"20500000"}),p=Je,{klines:d}=await K(t,p,c);if(d.length===0)return[];let f=i.replace("T"," ").slice(0,16),y=s.replace("T"," ").slice(0,16);return d.map(S=>{let g=B(S);return{...g,time:g.date}}).filter(S=>S.time>=f&&S.time<=y)}}function dt(t){return async function(r,n,o={}){let{period:i="daily",adjust:s="qfq",startDate:u="19700101",endDate:l="20500101"}=o;U(i),j(s);let c=t.normalizeSymbol(n),p=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:M,klt:w(i),fqt:G(s),secid:c.secid,beg:u,end:l,lmt:"1000000"}),{klines:d,name:f,code:y}=await K(r,t.url,p);if(d.length===0)return[];let S=t.resolveResultMeta?t.resolveResultMeta(n,c,{code:y,name:f}):{code:y||c.fallbackCode,name:f||""};return d.map(g=>({...B(g),code:S.code,name:S.name}))}}var Qo=dt({url:It,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function zr(t,e,r={}){return Qo(t,e,r)}var jo=dt({url:Pt,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,r)=>({code:r.code||e.fallbackCode,name:r.name||""})});async function Yr(t,e,r={}){return jo(t,e,r)}function Vr(t){let e=X(`eastmoney:board-code-map:${t.type}`,{defaultTTL:36e5,maxSize:4});return{async getCode(r,n,o){if(n.startsWith("BK"))return n;let s=(await e.getOrFetch("name-code-map",async()=>{let u=await o(r);return Object.fromEntries(u.map(l=>[l.name,l.code]))}))[n];if(!s)throw new Te(`${t.errorPrefix}: ${n}`,"eastmoney");return s}}}async function Wr(t,e){let r={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},n=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 pr(t,e.listUrl,r,n,100,(i,s)=>({rank:s,name:String(i.f14??""),code:String(i.f12??""),price:a(i.f2),change:a(i.f4),changePercent:a(i.f3),totalMarketCap:a(i.f20),turnoverRate:a(i.f8),riseCount:a(i.f104),fallCount:a(i.f105),leadingStock:i.f128?String(i.f128):null,leadingStockChangePercent:a(i.f136)}));return o.sort((i,s)=>(s.changePercent??0)-(i.changePercent??0)),o.forEach((i,s)=>{i.rank=s+1}),o}async function Xr(t,e,r){let n=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${r}?${n.toString()}`,s=(await t.get(o,{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:c,divide:p})=>{let d=s[l],f=null;return typeof d=="number"&&!isNaN(d)&&(f=p?d/100:d),{item:c,value:f}}):[]}async function Zr(t,e,r){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return pr(t,r,n,"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,(i,s)=>({rank:s,code:String(i.f12??""),name:String(i.f14??""),price:a(i.f2),changePercent:a(i.f3),change:a(i.f4),volume:a(i.f5),amount:a(i.f6),amplitude:a(i.f7),high:a(i.f15),low:a(i.f16),open:a(i.f17),prevClose:a(i.f18),turnoverRate:a(i.f8),pe:a(i.f9),pb:a(i.f23)}))}async function Jr(t,e,r,n={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:u="20500101"}=n;U(o),j(i);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:w(o),fqt:G(i),beg:s,end:u,smplmt:"10000",lmt:"1000000"}),{klines:c}=await K(t,r,l);return c.length===0?[]:c.map(p=>B(p))}async function en(t,e,r,n,o={}){let{period:i="5"}=o;if(Se(i),i==="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}`}),u=`${n}?${s.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.trends;return!Array.isArray(c)||c.length===0?[]:c.map(p=>{let[d,f,y,S,g,R,C,I]=p.split(","),P=m(I);return{time:d,open:m(f),close:m(y),high:m(S),low:m(g),volume:m(R),amount:m(C),price:P,avgPrice:P}})}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:i,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),u=`${r}?${s.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(p=>{let[d,f,y,S,g,R,C,I,P,D,N]=p.split(",");return{time:d,open:m(f),close:m(y),high:m(S),low:m(g),changePercent:m(P),change:m(D),volume:m(R),amount:m(C),amplitude:m(I),turnoverRate:m(N)}})}}function mt(t){let e=Vr(t);async function r(o){return Wr(o,t)}async function n(o,i){return e.getCode(o,i,r)}return{async getList(o){return r(o)},async getSpot(o,i){let s=await n(o,i);return Xr(o,s,t.spotUrl)},async getConstituents(o,i){let s=await n(o,i);return Zr(o,s,t.consUrl)},async getKline(o,i,s={}){let u=await n(o,i);return Jr(o,u,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let u=await n(o,i);return en(o,u,t.klineUrl,t.trendsUrl,s)}}}var Go={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Dt,spotUrl:bt,consUrl:Lt,klineUrl:Mt,trendsUrl:Nt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},Re=mt(Go);async function tn(t){return Re.getList(t)}async function rn(t,e){return Re.getSpot(t,e)}async function nn(t,e){return Re.getConstituents(t,e)}async function on(t,e,r={}){return Re.getKline(t,e,r)}async function sn(t,e,r={}){return Re.getMinuteKline(t,e,r)}var zo={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:kt,spotUrl:Ft,consUrl:xt,klineUrl:vt,trendsUrl:Ut,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},Ee=mt(zo);async function an(t){return Ee.getList(t)}async function un(t,e){return Ee.getSpot(t,e)}async function ln(t,e){return Ee.getConstituents(t,e)}async function cn(t,e,r={}){return Ee.getKline(t,e,r)}async function pn(t,e,r={}){return Ee.getMinuteKline(t,e,r)}async function dr(t,e,r){let{reportName:n,columns:o="ALL",filter:i,sortColumns:s,sortTypes:u,pageSize:l=500,startPage:c=1,fetchAllPages:p=!0,maxPages:d=1e3,quoteColumns:f,quoteType:y,extraParams:S}=e,g=[],R=c,C=1,I=0,P=0;do{let D=new URLSearchParams({reportName:n,columns:o,pageSize:String(l),pageNumber:String(R),source:"WEB",client:"WEB"});if(i&&D.set("filter",i),s&&D.set("sortColumns",s),u&&D.set("sortTypes",u),f&&D.set("quoteColumns",f),y&&D.set("quoteType",y),S)for(let[ht,Tt]of Object.entries(S))D.set(ht,Tt);let N=`${wt}?${D.toString()}`,$=(await t.get(N,{responseType:"json"}))?.result;if(!$||!Array.isArray($.data))break;R===c&&(C=$.pages??1,I=$.count??$.data.length);let go=$.data.map((ht,Tt)=>r(ht,g.length+Tt));if(g.push(...go),R++,P++,!p)break}while(R<=C&&P<d);return p&&P>=d&&R<=C&&console.warn(`[stock-sdk] fetchDatacenter("${n}") truncated at maxPages=${d} (server reports ${C} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:g,total:I,pages:C}}async function O(t,e,r){return(await dr(t,e,r)).data}function L(t){if(t==null)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}function Z(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Yo(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:Z(t.REPORT_DATE),planNoticeDate:Z(t.PLAN_NOTICE_DATE),disclosureDate:Z(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:Z(t.EQUITY_RECORD_DATE),exDividendDate:Z(t.EX_DIVIDEND_DATE),payDate:Z(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:Z(t.NOTICE_DATE)}}async function dn(t,e){let r=e.replace(/^(sh|sz|bj)/,"");return O(t,{reportName:"RPT_SHAREBONUS_DET",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:500,filter:`(SECURITY_CODE="${r}")`},n=>Yo(n))}function mr(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 mn(t){return te[t]??te[t.toLowerCase()]??te[t.toUpperCase()]}function gr(t){let e=mn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=mn(t.slice(0,-1))),!e){let n=Object.keys(te).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${n}`)}let r=qt[e];if(r===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return r}function Vo(t){let e=B(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}async function gn(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;U(n);let s=mr(e),l=`${gr(s)}.${e}`,c=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:M,klt:w(n),fqt:"0",secid:l,beg:o,end:i}),{klines:p,name:d,code:f}=await K(t,le,c);return p.length===0?[]:p.map(y=>({...Vo(y),code:f||e,name:d||""}))}async function fn(t,e={}){let r=e.pageSize??20,n=[],o=0,i=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(r),pageIndex:String(o),token:ce,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),u=`${Ht}?${s.toString()}`,l=await t.get(u,{responseType:"json"});if(!l||!Array.isArray(l.list))break;o===0&&(i=l.total??0);let c=l.list.map(Wo);n.push(...c),o++}while(n.length<i);return n}function Wo(t){return{code:t.dm||"",name:t.name||"",price:m(String(t.p)),change:m(String(t.zde)),changePercent:m(String(t.zdf)),open:m(String(t.o)),high:m(String(t.h)),low:m(String(t.l)),prevSettle:m(String(t.zjsj)),volume:m(String(t.vol)),buyVolume:m(String(t.wp)),sellVolume:m(String(t.np)),openInterest:m(String(t.ccl))}}function Xo(t){let e=B(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}function Zo(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 hn(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;U(n);let s=r.marketCode;if(s===void 0){let f=Zo(e);if(s=et[f],s===void 0){let y=Object.keys(et).join(", ");throw new RangeError(`Unknown global futures variety: "${f}". Supported: ${y}. Or specify marketCode manually via options.`)}}let u=`${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:M,klt:w(n),fqt:"0",secid:u,beg:o,end:i}),{klines:c,name:p,code:d}=await K(t,le,l);return c.length===0?[]:c.map(f=>({...Xo(f),code:d||e,name:p||""}))}async function Tn(t,e={}){let{pageSize:r=2e4}=e,n=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(r),pageIndex:"0",token:ce,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${zt}?${n.toString()}`,s=(await t.get(o,{responseType:"json"}))?.list;return Array.isArray(s)?s.map(u=>({code:String(u.dm??""),name:String(u.name??""),price:a(u.p),change:a(u.zde),changePercent:a(u.zdf),volume:a(u.vol),amount:a(u.cje),openInterest:a(u.ccl),strikePrice:a(u.xqj),remainDays:a(u.syr),dailyChange:a(u.rz),prevSettle:a(u.zjsj),open:a(u.o)})):[]}function Jo(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function yn(t,e,r){let n=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:x,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${r}')`}),o=`${Yt}?${n.toString()}`,s=(await t.get(o,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function u(l){if(!l)return"";let c=String(l),p=c.match(/^(\d{4}-\d{2}-\d{2})/);return p?p[1]:c}return s.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:u(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:a(l.MEMBER_RANK)??0,sellVolume:a(l.SELL_VOLUME),sellVolumeChange:a(l.SELL_VOLUME_CHANGE),netSellVolume:a(l.NET_SELL_VOLUME),sellVolumeRatio:a(l.SELL_VOLUME_RATIO),buyVolume:a(l.BUY_VOLUME),buyVolumeChange:a(l.BUY_VOLUME_CHANGE),netBuyVolume:a(l.NET_BUY_VOLUME),buyVolumeRatio:a(l.BUY_VOLUME_RATIO),sellPosition:a(l.SELL_POSITION),sellPositionChange:a(l.SELL_POSITION_CHANGE),netSellPosition:a(l.NET_SELL_POSITION),sellPositionRatio:a(l.SELL_POSITION_RATIO),buyPosition:a(l.BUY_POSITION),buyPositionChange:a(l.BUY_POSITION_CHANGE),netBuyPosition:a(l.NET_BUY_POSITION),buyPositionRatio:a(l.BUY_POSITION_RATIO),tradeDate:u(l.TRADE_DATE),volume:a(l.BUY_VOLUME)??a(l.SELL_VOLUME)??a(l.NET_BUY_VOLUME)??a(l.NET_SELL_VOLUME),volumeChange:a(l.BUY_VOLUME_CHANGE)??a(l.SELL_VOLUME_CHANGE),amount:a(l.BUY_POSITION)??a(l.SELL_POSITION)??a(l.NET_BUY_POSITION)??a(l.NET_SELL_POSITION),amountChange:a(l.BUY_POSITION_CHANGE)??a(l.SELL_POSITION_CHANGE),openInterest:a(l.BUY_POSITION)??a(l.SELL_POSITION),openInterestChange:a(l.BUY_POSITION_CHANGE)??a(l.SELL_POSITION_CHANGE),side:Jo(String(l.TRADE_TYPE??""))}))}var ei={gold:"EMI00069026",silver:"EMI00069027"};function Sn(t){if(!t)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}async function Rn(t){return O(t,{reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageSize:500,fetchAllPages:!1},e=>({code:String(e.TRADE_CODE??""),name:String(e.TRADE_TYPE??""),marketCode:String(e.TRADE_MARKET_CODE??"")}))}async function En(t,e,r={}){let{startDate:n="2020-10-28",pageSize:o=500}=r,i=e.toUpperCase();return O(t,{reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${i}")(TRADE_DATE>='${n}')`,pageSize:o,sortColumns:"TRADE_DATE",sortTypes:"-1"},s=>({code:String(s.SECURITY_CODE??e),date:Sn(s.TRADE_DATE),inventory:a(s.ON_WARRANT_NUM),change:a(s.ADDCHANGE)}))}async function Cn(t,e,r={}){let n=ei[e];if(!n)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:o=500}=r,i={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};return O(t,{reportName:"RPT_FUTUOPT_GOLDSIL",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:o,filter:`(INDICATOR_ID1="${n}")(@STORAGE_TON<>"NULL")`},s=>({date:Sn(s.REPORT_DATE),name:i[e]??e,storageTon:a(s.STORAGE_TON),storageOunce:a(s.STORAGE_OUNCE),inventory:a(s.STORAGE_TON),change:null,market:e}))}var On={daily:"101",weekly:"102",monthly:"103"},fr="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function _n(t){let e=t.split(",");return{date:e[0]??"",mainNetInflow:m(e[1]),smallNetInflow:m(e[2]),mediumNetInflow:m(e[3]),largeNetInflow:m(e[4]),superLargeNetInflow:m(e[5]),mainNetInflowPercent:m(e[6]),smallNetInflowPercent:m(e[7]),mediumNetInflowPercent:m(e[8]),largeNetInflowPercent:m(e[9]),superLargeNetInflowPercent:m(e[10]),close:m(e[11]),changePercent:m(e[12])}}function ti(t){let e=t.split(",");return{date:e[0]??"",mainNetInflow:m(e[1]),smallNetInflow:m(e[2]),mediumNetInflow:m(e[3]),largeNetInflow:m(e[4]),superLargeNetInflow:m(e[5]),mainNetInflowPercent:m(e[6]),smallNetInflowPercent:m(e[7]),mediumNetInflowPercent:m(e[8]),largeNetInflowPercent:m(e[9]),superLargeNetInflowPercent:m(e[10]),shClose:m(e[11]),shChangePercent:m(e[12]),szClose:m(e[13]),szChangePercent:m(e[14])}}var An={today:{fid:"f62",fields:"f12,f14,f2,f3,f62,f184,f66,f69,f72,f75,f78,f81,f84,f87,f124",changePercentField:"f3",mainNet:"f62",mainPct:"f184",superLargeNet:"f66",superLargePct:"f69",largeNet:"f72",largePct:"f75",mediumNet:"f78",mediumPct:"f81",smallNet:"f84",smallPct:"f87"},"3day":{fid:"f267",fields:"f12,f14,f2,f127,f267,f268,f269,f270,f271,f272,f273,f274,f275,f276,f124",changePercentField:"f127",mainNet:"f267",mainPct:"f268",superLargeNet:"f269",superLargePct:"f270",largeNet:"f271",largePct:"f272",mediumNet:"f273",mediumPct:"f274",smallNet:"f275",smallPct:"f276"},"5day":{fid:"f164",fields:"f12,f14,f2,f109,f164,f165,f166,f167,f168,f169,f170,f171,f172,f173,f124",changePercentField:"f109",mainNet:"f164",mainPct:"f165",superLargeNet:"f166",superLargePct:"f167",largeNet:"f168",largePct:"f169",mediumNet:"f170",mediumPct:"f171",smallNet:"f172",smallPct:"f173"},"10day":{fid:"f174",fields:"f12,f14,f2,f160,f174,f175,f176,f177,f178,f179,f180,f181,f182,f183,f124",changePercentField:"f160",mainNet:"f174",mainPct:"f175",superLargeNet:"f176",superLargePct:"f177",largeNet:"f178",largePct:"f179",mediumNet:"f180",mediumPct:"f181",smallNet:"f182",smallPct:"f183"}},ri={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},ni="m:0+t:6+f:!2,m:0+t:13+f:!2,m:0+t:80+f:!2,m:1+t:2+f:!2,m:1+t:23+f:!2,m:0+t:7+f:!2,m:1+t:3+f:!2";async function In(t,e,r=100,n=1e3){let o=[],i=1,s=0;do{let u=new URLSearchParams({...e,pn:String(i),pz:String(r)}),l=`${Bt}?${u.toString()}`,p=(await t.get(l,{responseType:"json"}))?.data;if(!p||!Array.isArray(p.diff)||(i===1&&(s=p.total??0),o.push(...p.diff),o.length>=s||p.diff.length<r))break;i++}while(o.length<s&&i<=n);return i>n&&o.length<s&&console.warn(`[stock-sdk] fetchClistAllPages truncated at maxPages=${n} (server reports total=${s}, fetched=${o.length}). Pass a larger \`maxPages\` to fetch the full dataset.`),o}async function Pn(t,e,r={}){let{period:n="daily"}=r,o=On[n];if(!o)throw new RangeError(`Invalid period: ${n}. Must be daily/weekly/monthly.`);let i=e.replace(/^(sh|sz|bj)/i,""),s=`${ne(e)}.${i}`,u=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:fr,ut:x}),l=`${ae}?${u.toString()}`,p=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(p)||p.length===0?[]:p.map(_n)}async function Dn(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:fr,ut:x}),r=`${ae}?${e.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(ti)}async function bn(t,e={}){let{indicator:r="today"}=e,n=An[r];if(!n)throw new RangeError(`Invalid indicator: ${r}.`);let o={fid:n.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:x,fs:ni,fields:n.fields};return(await In(t,o,100)).map(s=>({code:String(s.f12??""),name:String(s.f14??""),price:a(s.f2),changePercent:a(s[n.changePercentField]),mainNetInflow:a(s[n.mainNet]),mainNetInflowPercent:a(s[n.mainPct]),superLargeNetInflow:a(s[n.superLargeNet]),superLargeNetInflowPercent:a(s[n.superLargePct]),largeNetInflow:a(s[n.largeNet]),largeNetInflowPercent:a(s[n.largePct]),mediumNetInflow:a(s[n.mediumNet]),mediumNetInflowPercent:a(s[n.mediumPct]),smallNetInflow:a(s[n.smallNet]),smallNetInflowPercent:a(s[n.smallPct])}))}async function Ln(t,e={}){let{indicator:r="today",sectorType:n="industry"}=e,o=An[r];if(!o)throw new RangeError(`Invalid indicator: ${r}.`);let i=ri[n];if(!i)throw new RangeError(`Invalid sectorType: ${n}.`);let s=`${o.fields},f204,f205`,u={fid:o.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:x,fs:i,fields:s};return(await In(t,u,100)).map(c=>({code:String(c.f12??""),name:String(c.f14??""),changePercent:a(c[o.changePercentField]),mainNetInflow:a(c[o.mainNet]),mainNetInflowPercent:a(c[o.mainPct]),superLargeNetInflow:a(c[o.superLargeNet]),largeNetInflow:a(c[o.largeNet]),mediumNetInflow:a(c[o.mediumNet]),smallNetInflow:a(c[o.smallNet]),topStockCode:c.f204?String(c.f204):void 0,topStockName:c.f205?String(c.f205):void 0}))}async function Mn(t,e,r={}){let{period:n="daily"}=r,o=On[n];if(!o)throw new RangeError(`Invalid period: ${n}. Must be daily/weekly/monthly.`);let i=e.includes(".")?e:`90.${e}`,s=new URLSearchParams({lmt:"0",klt:o,secid:i,fields1:"f1,f2,f3,f7",fields2:fr,ut:x}),u=`${ae}?${s.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(_n)}var oi={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},ii={shanghai:"001",shenzhen:"003"};function Nn(t,e){let r=t.split(",");return{date:e,time:r[0]??"",shanghaiNetInflow:m(r[1]),shenzhenNetInflow:m(r[3]),totalNetInflow:m(r[5])}}async function Fn(t,e="north"){let r=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:x}),n=`${Kt}?${r.toString()}`,i=(await t.get(n,{responseType:"json"}))?.data;if(!i)return[];if(e==="south"){let l=i.n2s??[],c=i.n2sDate??"";return l.map(p=>Nn(p,kn(c)))}let s=i.s2n??[],u=i.s2nDate??"";return s.map(l=>Nn(l,kn(u)))}function kn(t){return t?/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t:""}async function xn(t){return O(t,{reportName:"RPT_MUTUAL_QUOTA",columns:"TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,INDEX_CODE,INDEX_NAME,BOARD_CODE",quoteColumns:"status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE",quoteType:"0",sortColumns:"MUTUAL_TYPE",sortTypes:"1",pageSize:2e3,fetchAllPages:!1},e=>({date:L(e.TRADE_DATE),type:String(e.MUTUAL_TYPE??""),boardName:String(e.MUTUAL_TYPE_NAME??""),direction:String(e.FUNDS_DIRECTION??""),status:String(e.status??""),netBuyAmount:a(e.netBuyAmt),netInflow:a(e.dayNetAmtIn),remainAmount:a(e.dayAmtRemain),upCount:a(e.f104),flatCount:a(e.f106),downCount:a(e.f105),indexCode:String(e.INDEX_CODE??""),indexName:String(e.INDEX_NAME??""),indexChangePercent:a(e.INDEX_f3)}))}async function vn(t,e={}){let{market:r="all",period:n="5day",date:o}=e,i=oi[n];if(!i)throw new RangeError(`Invalid period: ${n}.`);let s=[`(INTERVAL_TYPE="${i}")`];return o&&s.push(`(TRADE_DATE='${o}')`),r!=="all"&&s.push(`(MUTUAL_TYPE="${ii[r]}")`),O(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:s.join("")},u=>({date:L(u.TRADE_DATE),code:String(u.SECURITY_CODE??""),name:String(u.SECURITY_NAME??u.SECURITY_NAME_ABBR??""),close:a(u.CLOSE_PRICE),changePercent:a(u.CHANGE_RATE),holdShares:a(u.HOLD_SHARES),holdMarketValue:a(u.HOLD_MARKET_CAP),holdRatioFloat:a(u.HOLD_RATIO),holdRatioTotal:a(u.A_SHARES_RATIO),addShares:a(u.ADD_SHARES),addMarketValue:a(u.ADD_MARKET_CAP),addMarketValuePercent:a(u.ADD_MARKET_CAP_PROPORTION),sector:String(u.BOARD_NAME??"")}))}async function Un(t,e="north",r={}){let{startDate:n,endDate:o}=r,i=[e==="north"?'(BOARD_TYPE="1")':'(BOARD_TYPE="0")'];return n&&i.push(`(TRADE_DATE>='${n}')`),o&&i.push(`(TRADE_DATE<='${o}')`),O(t,{reportName:"RPT_MUTUAL_DEAL_HISTORY",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:i.join("")},s=>({date:L(s.TRADE_DATE),netBuyAmount:a(s.NET_DEAL_AMT),buyAmount:a(s.BUY_AMT),sellAmount:a(s.SELL_AMT),accNetBuyAmount:a(s.ACCUM_DEAL_AMT),netInflow:a(s.FUND_INFLOW),remainAmount:a(s.QUOTA_BALANCE),topStockCode:s.LEAD_STOCKS_CODE?String(s.LEAD_STOCKS_CODE):null,topStockName:s.LEAD_STOCKS_NAME?String(s.LEAD_STOCKS_NAME):null,topStockChangePercent:a(s.LS_CHANGE_RATE)}))}async function wn(t,e,r={}){let n=e.replace(/^(sh|sz|bj)/i,""),{startDate:o,endDate:i}=r,s=[`(SECURITY_CODE="${n}")`];return o&&s.push(`(TRADE_DATE>='${o}')`),i&&s.push(`(TRADE_DATE<='${i}')`),O(t,{reportName:"RPT_MUTUAL_HOLDSTOCKNORTH_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:s.join("")},u=>({date:L(u.TRADE_DATE),holdShares:a(u.HOLD_SHARES),holdMarketValue:a(u.HOLD_MARKET_CAP),holdRatioFloat:a(u.HOLD_RATIO),holdRatioTotal:a(u.A_SHARES_RATIO),close:a(u.CLOSE_PRICE),changePercent:a(u.CHANGE_RATE)}))}var si={zt:{path:"/getTopicZTPool",sort:"fbt:asc"},yesterday:{path:"/getYesterdayZTPool",sort:"zs:desc"},strong:{path:"/getTopicQSPool",sort:"zdp:desc"},sub_new:{path:"/getTopicCXPool",sort:"ods:asc"},broken:{path:"/getTopicZBPool",sort:"fbt:asc"},dt:{path:"/getTopicDTPool",sort:"fund:asc"}},ai={rocket_launch:"8201",quick_rebound:"8202",large_buy:"8193",limit_up_seal:"4",limit_down_open:"32",big_buy_order:"64",auction_up:"8207",high_open_5d:"8209",gap_up:"8211",high_60d:"8213",surge_60d:"8215",accelerate_down:"8204",high_dive:"8203",large_sell:"8194",limit_down_seal:"8",limit_up_open:"16",big_sell_order:"128",auction_down:"8208",low_open_5d:"8210",gap_down:"8212",low_60d:"8214",drop_60d:"8216"},ui={8201:"\u706B\u7BAD\u53D1\u5C04",8202:"\u5FEB\u901F\u53CD\u5F39",8193:"\u5927\u7B14\u4E70\u5165",4:"\u5C01\u6DA8\u505C\u677F",32:"\u6253\u5F00\u8DCC\u505C\u677F",64:"\u6709\u5927\u4E70\u76D8",8207:"\u7ADE\u4EF7\u4E0A\u6DA8",8209:"\u9AD8\u5F005\u65E5\u7EBF",8211:"\u5411\u4E0A\u7F3A\u53E3",8213:"60\u65E5\u65B0\u9AD8",8215:"60\u65E5\u5927\u5E45\u4E0A\u6DA8",8204:"\u52A0\u901F\u4E0B\u8DCC",8203:"\u9AD8\u53F0\u8DF3\u6C34",8194:"\u5927\u7B14\u5356\u51FA",8:"\u5C01\u8DCC\u505C\u677F",16:"\u6253\u5F00\u6DA8\u505C\u677F",128:"\u6709\u5927\u5356\u76D8",8208:"\u7ADE\u4EF7\u4E0B\u8DCC",8210:"\u4F4E\u5F005\u65E5\u7EBF",8212:"\u5411\u4E0B\u7F3A\u53E3",8214:"60\u65E5\u65B0\u4F4E",8216:"60\u65E5\u5927\u5E45\u4E0B\u8DCC"};function hr(t){if(t==null)return"";let e=String(t).padStart(6,"0");return`${e.slice(0,2)}:${e.slice(2,4)}:${e.slice(4,6)}`}function li(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function ci(t){let e=a(t.p),r=a(t.tp);return{code:String(t.c??t.m??""),name:String(t.n??""),price:e!==null?e/1e3:null,changePercent:a(t.zdp),limitPrice:r!==null?r/1e3:null,amount:a(t.amount??t.zb),floatMarketValue:a(t.ltsz),totalMarketValue:a(t.tshare),turnoverRate:a(t.hs),continuousBoardCount:a(t.lbc),firstBoardTime:t.fbt!==void 0&&t.fbt!==null?hr(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?hr(t.lbt):null,boardAmount:a(t.fund),sealAmount:a(t.fund),failedCount:a(t.zbc),industry:String(t.hybk??""),ztStatistics:li(t.zttj),amplitude:a(t.zf),speed:a(t.zs)}}function pi(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function di(){let t=new Date(Date.now()+288e5),e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0");return`${e}${r}${n}`}async function Bn(t,e="zt",r){let n=si[e];if(!n)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=pi(r)??di(),i=new URLSearchParams({ut:M,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:n.sort,date:o}),s=`${ue}${n.path}?${i.toString()}`,l=(await t.get(s,{responseType:"json"}))?.data?.pool;return!Array.isArray(l)||l.length===0?[]:l.map(ci)}async function Kn(t,e="large_buy"){let r=ai[e];if(!r)throw new RangeError(`Invalid StockChangeType: ${e}.`);let n=new URLSearchParams({type:r,pageindex:"0",pagesize:"5000",ut:M,dpt:"wzchanges"}),o=`${ue}/getAllStockChanges?${n.toString()}`,s=(await t.get(o,{responseType:"json"}))?.data?.allstock;return!Array.isArray(s)||s.length===0?[]:s.map(u=>{let l=String(u.t??r);return{time:hr(u.tm),code:String(u.c??""),name:String(u.n??""),changeType:e,changeTypeLabel:ui[l]??"",info:String(u.i??"")}})}async function Hn(t){let e=new URLSearchParams({ut:M,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),r=`${ue}/getAllBKChanges?${e.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data?.allbk;return!Array.isArray(o)||o.length===0?[]:o.map(i=>{let s=i.ms??{},u=s.m===0?"\u5927\u7B14\u4E70\u5165":s.m===1?"\u5927\u7B14\u5356\u51FA":"",l={},c=i.bkdf??i.bkdfdis;if(c&&typeof c=="object")for(let[p,d]of Object.entries(c))l[p]=Number(d)||0;return{name:String(i.bkn??""),changePercent:a(i.bkz),mainNetInflow:a(i.bkj),totalChangeCount:a(i.bkc),topStockCode:String(s.c??""),topStockName:String(s.n??""),topStockDirection:u,changeTypeDistribution:l}})}var qn={"1month":"01","3month":"02","6month":"03","1year":"04"};function Ce(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}async function $n(t,e){let r=Ce(e.startDate),n=Ce(e.endDate);return O(t,{reportName:"RPT_DAILYBILLBOARD_DETAILSNEW",columns:"SECURITY_CODE,SECUCODE,SECURITY_NAME_ABBR,TRADE_DATE,EXPLAIN,CLOSE_PRICE,CHANGE_RATE,BILLBOARD_NET_AMT,BILLBOARD_BUY_AMT,BILLBOARD_SELL_AMT,BILLBOARD_DEAL_AMT,ACCUM_AMOUNT,DEAL_NET_RATIO,DEAL_AMOUNT_RATIO,TURNOVERRATE,FREE_MARKET_CAP,EXPLANATION,D1_CLOSE_ADJCHRATE,D2_CLOSE_ADJCHRATE,D5_CLOSE_ADJCHRATE,D10_CLOSE_ADJCHRATE",sortColumns:"SECURITY_CODE,TRADE_DATE",sortTypes:"1,-1",pageSize:5e3,filter:`(TRADE_DATE<='${n}')(TRADE_DATE>='${r}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:L(o.TRADE_DATE),close:a(o.CLOSE_PRICE),changePercent:a(o.CHANGE_RATE),netBuyAmount:a(o.BILLBOARD_NET_AMT),buyAmount:a(o.BILLBOARD_BUY_AMT),sellAmount:a(o.BILLBOARD_SELL_AMT),dealAmount:a(o.BILLBOARD_DEAL_AMT),totalAmount:a(o.ACCUM_AMOUNT),netBuyRatio:a(o.DEAL_NET_RATIO),dealAmountRatio:a(o.DEAL_AMOUNT_RATIO),turnoverRate:a(o.TURNOVERRATE),floatMarketValue:a(o.FREE_MARKET_CAP),reason:String(o.EXPLANATION??o.EXPLAIN??""),afterChange1d:a(o.D1_CLOSE_ADJCHRATE),afterChange2d:a(o.D2_CLOSE_ADJCHRATE),afterChange5d:a(o.D5_CLOSE_ADJCHRATE),afterChange10d:a(o.D10_CLOSE_ADJCHRATE)}))}async function Qn(t,e="1month"){let r=qn[e];if(!r)throw new RangeError(`Invalid period: ${e}.`);return O(t,{reportName:"RPT_BILLBOARD_TRADEALL",columns:"ALL",sortColumns:"BILLBOARD_TIMES,LATEST_TDATE,SECURITY_CODE",sortTypes:"-1,-1,1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${r}")`},n=>({code:String(n.SECURITY_CODE??""),name:String(n.SECURITY_NAME_ABBR??""),latestDate:L(n.LATEST_TDATE),close:a(n.CLOSE_PRICE),changePercent:a(n.CHANGE_RATE),count:a(n.BILLBOARD_TIMES),totalBuyAmount:a(n.BILLBOARD_BUY_AMT),totalSellAmount:a(n.BILLBOARD_SELL_AMT),totalNetAmount:a(n.BILLBOARD_NET_AMT),totalDealAmount:a(n.BILLBOARD_DEAL_AMT),buyOrgCount:a(n.ORG_BUY_TIMES),sellOrgCount:a(n.ORG_SELL_TIMES)}))}async function jn(t,e){let r=Ce(e.startDate),n=Ce(e.endDate);return O(t,{reportName:"RPT_ORGANIZATION_TRADE_DETAILS",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:`(TRADE_DATE<='${n}')(TRADE_DATE>='${r}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:L(o.TRADE_DATE),close:a(o.CLOSE_PRICE),changePercent:a(o.CHANGE_RATE),buyOrgCount:a(o.BUY_TIMES),sellOrgCount:a(o.SELL_TIMES),orgBuyAmount:a(o.BUY_AMT),orgSellAmount:a(o.SELL_AMT),orgNetAmount:a(o.NET_AMT)}))}async function Gn(t,e="1month"){let r=qn[e];if(!r)throw new RangeError(`Invalid period: ${e}.`);return O(t,{reportName:"RPT_BILLBOARD_TRADEDETAILS",columns:"ALL",sortColumns:"TOTAL_BUYER_SALESTIMES",sortTypes:"-1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${r}")`},n=>({code:String(n.OPERATEDEPT_CODE??""),name:String(n.OPERATEDEPT_NAME??""),totalBuyAmount:a(n.TOTAL_BUYAMT??n.BUY_AMT),totalSellAmount:a(n.TOTAL_SELLAMT??n.SELL_AMT),buyCount:a(n.TOTAL_BUYER_SALESTIMES??n.BUY_TIMES),sellCount:a(n.TOTAL_SELLER_SALESTIMES??n.SELL_TIMES),totalCount:a(n.TOTAL_TIMES)}))}async function zn(t,e,r){let n=e.replace(/^(sh|sz|bj)/i,""),o=Ce(r),i=`(SECURITY_CODE="${n}")(TRADE_DATE='${o}')`,[s,u]=await Promise.all([O(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSBUY",columns:"ALL",sortColumns:"BUY_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:a(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:a(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:a(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:a(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:a(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:a(l.NET_AMT),side:"buy"})),O(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSSELL",columns:"ALL",sortColumns:"SELL_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:a(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:a(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:a(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:a(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:a(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:a(l.NET_AMT),side:"sell"}))]);return[...s,...u]}function Yn(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function Vn(t){if(!t)return"";let e=Yn(t.startDate),r=Yn(t.endDate),n=[];return e&&n.push(`(TRADE_DATE>='${e}')`),r&&n.push(`(TRADE_DATE<='${r}')`),n.join("")}async function Wn(t){return O(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:L(e.TRADE_DATE),shClose:a(e.CLOSE_PRICE??e.SH_CLOSE_PRICE),shChangePercent:a(e.CHANGE_RATE??e.SH_CHANGE_RATE),totalAmount:a(e.TURNOVER??e.TOTAL_AMOUNT),premiumAmount:a(e.PREMIUM_TURNOVER??e.PREMIUM_AMOUNT),premiumRatio:a(e.PREMIUM_RATIO),discountAmount:a(e.DISCOUNT_TURNOVER??e.DISCOUNT_AMOUNT),discountRatio:a(e.DISCOUNT_RATIO)}))}async function Xn(t,e={}){let r=Vn(e);return O(t,{reportName:"RPT_BLOCK_TRADE_DETAIL",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:r||void 0},n=>({code:String(n.SECURITY_CODE??""),name:String(n.SECURITY_NAME_ABBR??""),date:L(n.TRADE_DATE),close:a(n.CLOSE_PRICE),changePercent:a(n.CHANGE_RATE),dealPrice:a(n.DEAL_PRICE??n.PRICE),dealVolume:a(n.DEAL_VOLUME??n.VOLUME),dealAmount:a(n.DEAL_AMT??n.TURNOVER),premiumRate:a(n.PREMIUM_RATIO??n.PREMIUM_RATE),buyBranch:String(n.BUYER_DEPT??n.BUYER_OPERATEDEPT_NAME??""),sellBranch:String(n.SELLER_DEPT??n.SELLER_OPERATEDEPT_NAME??"")}))}async function Zn(t,e={}){let r=Vn(e);return O(t,{reportName:"RPT_BLOCK_TRADE_STA",columns:"ALL",sortColumns:"TRADE_DATE,DEAL_AMT",sortTypes:"-1,-1",pageSize:5e3,filter:r||void 0},n=>({code:String(n.SECURITY_CODE??""),name:String(n.SECURITY_NAME_ABBR??""),date:L(n.TRADE_DATE),changePercent:a(n.CHANGE_RATE),close:a(n.CLOSE_PRICE),dealCount:a(n.DEAL_NUM??n.DEAL_COUNT),dealTotalAmount:a(n.DEAL_AMT??n.TOTAL_AMOUNT),dealTotalVolume:a(n.DEAL_VOLUME??n.TOTAL_VOLUME),premiumAmount:a(n.PREMIUM_AMT??n.PREMIUM_AMOUNT),discountAmount:a(n.DISCOUNT_AMT??n.DISCOUNT_AMOUNT)}))}async function Jn(t){return O(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:L(e.STATISTICS_DATE??e.TRADE_DATE),finBalance:a(e.FIN_BALANCE),loanBalance:a(e.LOAN_BALANCE),finBuyAmount:a(e.FIN_BUY_AMT),loanSellAmount:a(e.LOAN_SELL_AMT),investorCount:a(e.OPERATE_INVESTOR_NUM??e.INVESTOR_NUM),liabilityInvestorCount:a(e.MARGIN_INVESTOR_NUM),totalGuarantee:a(e.TOTAL_GUARANTEE),avgGuaranteeRatio:a(e.AVG_GUARANTEE_RATIO)}))}async function eo(t,e){let r=e?`(TRADE_DATE='${e}')`:void 0;return O(t,{reportName:"RPT_MARGIN_TRADE_DETAIL",columns:"ALL",sortColumns:"FIN_BALANCE",sortTypes:"-1",pageSize:5e3,filter:r},n=>({code:String(n.SECURITY_CODE??""),name:String(n.SECURITY_NAME_ABBR??""),date:L(n.TRADE_DATE),finBalance:a(n.FIN_BALANCE),finBuyAmount:a(n.FIN_BUY_AMT),finRepayAmount:a(n.FIN_REPAY_AMT),loanBalance:a(n.LOAN_BALANCE),loanSellVolume:a(n.LOAN_SELL_VOLUME),loanRepayVolume:a(n.LOAN_REPAY_VOLUME)}))}var F={};Ze(F,{getCommodityOptionKline:()=>co,getCommodityOptionSpot:()=>lo,getETFOption5DayMinute:()=>uo,getETFOptionDailyKline:()=>ao,getETFOptionExpireDay:()=>oo,getETFOptionMinute:()=>so,getETFOptionMonths:()=>no,getIndexOptionKline:()=>ro,getIndexOptionSpot:()=>to});function mi(t){return{buyVolume:a(t[0]),buyPrice:a(t[1]),price:a(t[2]),askPrice:a(t[3]),askVolume:a(t[4]),openInterest:a(t[5]),change:a(t[6]),strikePrice:a(t[7]),symbol:t[8]??""}}function gi(t){return{buyVolume:a(t[0]),buyPrice:a(t[1]),price:a(t[2]),askPrice:a(t[3]),askVolume:a(t[4]),openInterest:a(t[5]),change:a(t[6]),strikePrice:null,symbol:t[7]??""}}async function to(t,e){let r=`${pe}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,n=await b(r),o=n?.result?.data?.up??[],i=n?.result?.data?.down??[];return{calls:o.map(mi),puts:i.map(gi)}}async function ro(t){let e=`${de}?symbol=${t}`,r=await b(e,{callbackMode:"path"});return Array.isArray(r)?r.map(n=>({date:n.d,open:a(n.o),high:a(n.h),low:a(n.l),close:a(n.c),volume:a(n.v)})):[]}async function no(t){let e=`${$t}?exchange=null&cate=${encodeURIComponent(t)}`,n=(await b(e))?.result?.data,o=n?.contractMonth??[];return{months:o.length>1?o.slice(1):o,stockId:n?.stockId??"",cateId:n?.cateId??"",cateList:n?.cateList??[]}}async function oo(t,e){let r=`${tt}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,n=await b(r),o=n?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let s=`${tt}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;n=await b(s)}let i=n?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function io(t){let e="";return t.map(r=>(r.d&&(e=r.d),{time:r.i,date:e,price:a(r.p),volume:a(r.v),openInterest:a(r.t),avgPrice:a(r.a)}))}async function so(t){let e=`CON_OP_${t}`,r=`${Qt}?symbol=${e}`,o=(await b(r))?.result?.data;return Array.isArray(o)?io(o):[]}async function ao(t){let e=`CON_OP_${t}`,r=`${jt}?symbol=${e}`,n=await b(r,{callbackMode:"path"});return Array.isArray(n)?n.map(o=>({date:o.d,open:a(o.o),high:a(o.h),low:a(o.l),close:a(o.c),volume:a(o.v)})):[]}async function uo(t){let e=`CON_OP_${t}`,r=`${Gt}?symbol=${e}`,o=(await b(r))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...io(s));return i}function fi(t){return{buyVolume:a(t[0]),buyPrice:a(t[1]),price:a(t[2]),askPrice:a(t[3]),askVolume:a(t[4]),openInterest:a(t[5]),change:a(t[6]),strikePrice:a(t[7]),symbol:t[8]??""}}function hi(t){return{buyVolume:a(t[0]),buyPrice:a(t[1]),price:a(t[2]),askPrice:a(t[3]),askVolume:a(t[4]),openInterest:a(t[5]),change:a(t[6]),strikePrice:null,symbol:t[7]??""}}async function lo(t,e){let r=rt[t];if(!r)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(rt).join(", ")}`);let n=`${pe}?type=futures&product=${r.product}&exchange=${r.exchange}&pinzhong=${e}`,o=await b(n),i=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:i.map(fi),puts:s.map(hi)}}async function co(t){let e=`${de}?symbol=${t}`,r=await b(e,{callbackMode:"path"});return Array.isArray(r)?r.map(n=>({date:n.d,open:a(n.o),high:a(n.h),low:a(n.l),close:a(n.c),volume:a(n.v)})):[]}var _=class{constructor(e){this.client=e}};var Oe=class extends _{constructor(e){super(e)}getFullQuotes(e){return A.getFullQuotes(this.client,e)}getSimpleQuotes(e){return A.getSimpleQuotes(this.client,e)}getHKQuotes(e){return A.getHKQuotes(this.client,e)}getUSQuotes(e){return A.getUSQuotes(this.client,e)}getFundQuotes(e){return A.getFundQuotes(this.client,e)}getFundFlow(e){return A.getFundFlow(this.client,e)}getPanelLargeOrder(e){return A.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return A.getTodayTimeline(this.client,e)}search(e){return A.search(this.client,e)}getAShareCodeList(e){return A.getAShareCodeList(this.client,e)}getUSCodeList(e){return A.getUSCodeList(this.client,e)}getHKCodeList(){return A.getHKCodeList(this.client)}getFundCodeList(){return A.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:r,...n}=e,o=await this.getAShareCodeList({market:r});return A.getAllQuotesByCodes(this.client,o,n)}async getAllHKShareQuotes(e={}){let r=await this.getHKCodeList();return A.getAllHKQuotesByCodes(this.client,r,e)}async getAllUSShareQuotes(e={}){let{market:r,...n}=e,o=await this.getUSCodeList({simple:!0,market:r});return A.getAllUSQuotesByCodes(this.client,o,n)}getAllQuotesByCodes(e,r={}){return A.getAllQuotesByCodes(this.client,e,r)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return A.getTradingCalendar(this.client)}getDividendDetail(e){return T.getDividendDetail(this.client,e)}};var _e=class extends _{constructor(e){super(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,r){return T.getIndustryKline(this.client,e,r)}getIndustryMinuteKline(e,r){return T.getIndustryMinuteKline(this.client,e,r)}getConceptList(){return T.getConceptList(this.client)}getConceptSpot(e){return T.getConceptSpot(this.client,e)}getConceptConstituents(e){return T.getConceptConstituents(this.client,e)}getConceptKline(e,r){return T.getConceptKline(this.client,e,r)}getConceptMinuteKline(e,r){return T.getConceptMinuteKline(this.client,e,r)}};var Ae=class extends _{constructor(e){super(e)}getHistoryKline(e,r){return T.getHistoryKline(this.client,e,r)}getMinuteKline(e,r){return T.getMinuteKline(this.client,e,r)}getHKHistoryKline(e,r){return T.getHKHistoryKline(this.client,e,r)}getUSHistoryKline(e,r){return T.getUSHistoryKline(this.client,e,r)}};var Ie=class extends _{constructor(e){super(e)}getFuturesKline(e,r){return T.getFuturesHistoryKline(this.client,e,r)}getGlobalFuturesSpot(e){return T.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,r){return T.getGlobalFuturesKline(this.client,e,r)}getFuturesInventorySymbols(){return T.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,r){return T.getFuturesInventory(this.client,e,r)}getComexInventory(e,r){return T.getComexInventory(this.client,e,r)}};var Pe=class extends _{constructor(e){super(e)}getIndexOptionSpot(e,r){return F.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return F.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return T.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return F.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return F.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return F.getETFOptionMinute(e)}getETFOptionDailyKline(e){return F.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return F.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return F.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return F.getCommodityOptionKline(e)}getOptionLHB(e,r){return T.getOptionLHB(this.client,e,r)}};function De(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function z(t,e){let r=[];for(let n=0;n<t.length;n++){if(n<e-1){r.push(null);continue}let o=0,i=0;for(let s=n-e+1;s<=n;s++)t[s]!==null&&(o+=t[s],i++);r.push(i===e?De(o/e):null)}return r}function q(t,e){let r=[],n=2/(e+1),o=null,i=!1;for(let s=0;s<t.length;s++){if(s<e-1){r.push(null);continue}if(!i){let l=0,c=0;for(let p=s-e+1;p<=s;p++)t[p]!==null&&(l+=t[p],c++);c===e&&(o=l/e,i=!0),r.push(o!==null?De(o):null);continue}let u=t[s];u===null?r.push(o!==null?De(o):null):(o=n*u+(1-n)*o,r.push(De(o)))}return r}function gt(t,e){let r=[],n=Array.from({length:e},(i,s)=>s+1),o=n.reduce((i,s)=>i+s,0);for(let i=0;i<t.length;i++){if(i<e-1){r.push(null);continue}let s=0,u=!0;for(let l=0;l<e;l++){let c=t[i-e+1+l];if(c===null){u=!1;break}s+=c*n[l]}r.push(u?De(s/o):null)}return r}function be(t,e={}){let{periods:r=[5,10,20,30,60,120,250],type:n="sma"}=e,o=n==="ema"?q:n==="wma"?gt:z,i={};for(let s of r)i[`ma${s}`]=o(t,s);return t.map((s,u)=>{let l={};for(let c of r)l[`ma${c}`]=i[`ma${c}`][u];return l})}function po(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Le(t,e={}){let{short:r=12,long:n=26,signal:o=9}=e,i=q(t,r),s=q(t,n),u=t.map((c,p)=>i[p]===null||s[p]===null?null:i[p]-s[p]),l=q(u,o);return t.map((c,p)=>({dif:u[p]!==null?po(u[p]):null,dea:l[p],macd:u[p]!==null&&l[p]!==null?po((u[p]-l[p])*2):null}))}function Tr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ti(t,e,r){let n=[];for(let o=0;o<t.length;o++){if(o<e-1||r[o]===null){n.push(null);continue}let i=0,s=0;for(let u=o-e+1;u<=o;u++)t[u]!==null&&r[o]!==null&&(i+=Math.pow(t[u]-r[o],2),s++);n.push(s===e?Math.sqrt(i/e):null)}return n}function Me(t,e={}){let{period:r=20,stdDev:n=2}=e,o=z(t,r),i=Ti(t,r,o);return t.map((s,u)=>{if(o[u]===null||i[u]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=o[u]+n*i[u],c=o[u]-n*i[u],p=o[u]!==0?Tr((l-c)/o[u]*100):null;return{mid:o[u],upper:Tr(l),lower:Tr(c),bandwidth:p}})}function yr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ne(t,e={}){let{period:r=9,kPeriod:n=3,dPeriod:o=3}=e,i=[],s=50,u=50;for(let l=0;l<t.length;l++){if(l<r-1){i.push({k:null,d:null,j:null});continue}let c=-1/0,p=1/0,d=!0;for(let g=l-r+1;g<=l;g++){if(t[g].high===null||t[g].low===null){d=!1;break}c=Math.max(c,t[g].high),p=Math.min(p,t[g].low)}let f=t[l].close;if(!d||f===null||c===p){i.push({k:null,d:null,j:null});continue}let y=(f-p)/(c-p)*100;s=(n-1)/n*s+1/n*y,u=(o-1)/o*u+1/o*s;let S=3*s-2*u;i.push({k:yr(s),d:yr(u),j:yr(S)})}return i}function yi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function ke(t,e={}){let{periods:r=[6,12,24]}=e,n=[null];for(let i=1;i<t.length;i++)t[i]===null||t[i-1]===null?n.push(null):n.push(t[i]-t[i-1]);let o={};for(let i of r){let s=[],u=0,l=0;for(let c=0;c<t.length;c++){if(c<i){s.push(null),n[c]!==null&&(n[c]>0?u+=n[c]:l+=Math.abs(n[c]));continue}if(c===i)u=u/i,l=l/i;else{let p=n[c]??0,d=p>0?p:0,f=p<0?Math.abs(p):0;u=(u*(i-1)+d)/i,l=(l*(i-1)+f)/i}if(l===0)s.push(100);else if(u===0)s.push(0);else{let p=u/l;s.push(yi(100-100/(1+p)))}}o[`rsi${i}`]=s}return t.map((i,s)=>{let u={};for(let l of r)u[`rsi${l}`]=o[`rsi${l}`][s];return u})}function Si(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Fe(t,e={}){let{periods:r=[6,10]}=e,n={};for(let o of r){let i=[];for(let s=0;s<t.length;s++){if(s<o-1){i.push(null);continue}let u=-1/0,l=1/0,c=!0;for(let f=s-o+1;f<=s;f++){if(t[f].high===null||t[f].low===null){c=!1;break}u=Math.max(u,t[f].high),l=Math.min(l,t[f].low)}let p=t[s].close;if(!c||p===null||u===l){i.push(null);continue}let d=(u-p)/(u-l)*100;i.push(Si(d))}n[`wr${o}`]=i}return t.map((o,i)=>{let s={};for(let u of r)s[`wr${u}`]=n[`wr${u}`][i];return s})}function Ri(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function xe(t,e={}){let{periods:r=[6,12,24]}=e,n={};for(let o of r){let i=z(t,o),s=[];for(let u=0;u<t.length;u++)if(t[u]===null||i[u]===null||i[u]===0)s.push(null);else{let l=(t[u]-i[u])/i[u]*100;s.push(Ri(l))}n[`bias${o}`]=s}return t.map((o,i)=>{let s={};for(let u of r)s[`bias${u}`]=n[`bias${u}`][i];return s})}function Ei(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function ve(t,e={}){let{period:r=14}=e,n=[],o=t.map(i=>i.high===null||i.low===null||i.close===null?null:(i.high+i.low+i.close)/3);for(let i=0;i<t.length;i++){if(i<r-1){n.push({cci:null});continue}let s=0,u=0;for(let d=i-r+1;d<=i;d++)o[d]!==null&&(s+=o[d],u++);if(u!==r||o[i]===null){n.push({cci:null});continue}let l=s/r,c=0;for(let d=i-r+1;d<=i;d++)c+=Math.abs(o[d]-l);let p=c/r;if(p===0)n.push({cci:0});else{let d=(o[i]-l)/(.015*p);n.push({cci:Ei(d)})}}return n}function Sr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function J(t,e={}){let{period:r=14}=e,n=[],o=[];for(let s=0;s<t.length;s++){let{high:u,low:l,close:c}=t[s];if(u===null||l===null||c===null){o.push(null);continue}if(s===0)o.push(u-l);else{let p=t[s-1].close;if(p===null)o.push(u-l);else{let d=u-l,f=Math.abs(u-p),y=Math.abs(l-p);o.push(Math.max(d,f,y))}}}let i=null;for(let s=0;s<t.length;s++){if(s<r-1){n.push({tr:o[s]!==null?Sr(o[s]):null,atr:null});continue}if(s===r-1){let u=0,l=0;for(let c=0;c<r;c++)o[c]!==null&&(u+=o[c],l++);l===r&&(i=u/r)}else i!==null&&o[s]!==null&&(i=(i*(r-1)+o[s])/r);n.push({tr:o[s]!==null?Sr(o[s]):null,atr:i!==null?Sr(i):null})}return n}function Ue(t,e={}){let{maPeriod:r}=e,n=[];if(t.length===0)return n;let o=t[0].volume??0;n.push({obv:o,obvMa:null});for(let i=1;i<t.length;i++){let s=t[i],u=t[i-1];if(s.close===null||u.close===null||s.volume===null||s.volume===void 0){n.push({obv:null,obvMa:null});continue}s.close>u.close?o+=s.volume:s.close<u.close&&(o-=s.volume),n.push({obv:o,obvMa:null})}if(r&&r>0)for(let i=r-1;i<n.length;i++){let s=0,u=0;for(let l=i-r+1;l<=i;l++)n[l].obv!==null&&(s+=n[l].obv,u++);u===r&&(n[i].obvMa=s/r)}return n}function we(t,e={}){let{period:r=12,signalPeriod:n}=e,o=[];for(let i=0;i<t.length;i++){if(i<r){o.push({roc:null,signal:null});continue}let s=t[i].close,u=t[i-r].close;if(s===null||u===null||u===0){o.push({roc:null,signal:null});continue}let l=(s-u)/u*100;o.push({roc:l,signal:null})}if(n&&n>0)for(let i=r+n-1;i<o.length;i++){let s=0,u=0;for(let l=i-n+1;l<=i;l++)o[l].roc!==null&&(s+=o[l].roc,u++);u===n&&(o[i].signal=s/n)}return o}function Be(t,e={}){let{period:r=14,adxPeriod:n=r}=e,o=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let i=[],s=[],u=[];for(let g=0;g<t.length;g++){if(g===0){i.push(0),s.push(0),u.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let R=t[g],C=t[g-1];if(R.high===null||R.low===null||R.close===null||C.high===null||C.low===null||C.close===null){i.push(0),s.push(0),u.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let I=R.high-R.low,P=Math.abs(R.high-C.close),D=Math.abs(R.low-C.close);u.push(Math.max(I,P,D));let N=R.high-C.high,Y=C.low-R.low;N>Y&&N>0?i.push(N):i.push(0),Y>N&&Y>0?s.push(Y):s.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,c=0,p=0,d=[];for(let g=1;g<t.length;g++){if(g<r){l+=u[g],c+=i[g],p+=s[g],d.push(0);continue}g===r?(l=l,c=c,p=p):(l=l-l/r+u[g],c=c-c/r+i[g],p=p-p/r+s[g]);let R=l>0?c/l*100:0,C=l>0?p/l*100:0;o[g].pdi=R,o[g].mdi=C;let I=R+C,P=I>0?Math.abs(R-C)/I*100:0;d.push(P)}let f=0,y=0,S=0;for(let g=r;g<t.length;g++){if(g<r*2-1){f+=d[g-r+1]||0,y++;continue}if(g===r*2-1)f+=d[g-r+1]||0,S=f/n,o[g].adx=S;else{let R=d[g-r+1]||0;S=(S*(n-1)+R)/n,o[g].adx=S}}for(let g=r*2-1+n;g<t.length;g++){let R=o[g].adx,C=o[g-n]?.adx;R!==null&&C!==null&&(o[g].adxr=(R+C)/2)}return o}function Ke(t,e={}){let{afStart:r=.02,afIncrement:n=.02,afMax:o=.2}=e,i=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,u=r,l=t[0].high??0,c=t[0].low??0,p=t[0],d=t[1];p.close!==null&&d.close!==null&&d.close<p.close&&(s=-1,l=p.low??0,c=p.high??0),i.push({sar:null,trend:null,ep:null,af:null});for(let f=1;f<t.length;f++){let y=t[f],S=t[f-1];if(y.high===null||y.low===null||S.high===null||S.low===null){i.push({sar:null,trend:null,ep:null,af:null});continue}let g=c+u*(l-c);s===1?(g=Math.min(g,S.low,t[Math.max(0,f-2)]?.low??S.low),y.low<g?(s=-1,g=l,l=y.low,u=r):y.high>l&&(l=y.high,u=Math.min(u+n,o))):(g=Math.max(g,S.high,t[Math.max(0,f-2)]?.high??S.high),y.high>g?(s=1,g=l,l=y.high,u=r):y.low<l&&(l=y.low,u=Math.min(u+n,o))),c=g,i.push({sar:c,trend:s,ep:l,af:u})}return i}function He(t,e={}){let{emaPeriod:r=20,atrPeriod:n=10,multiplier:o=2}=e,i=[],s=t.map(c=>c.close),u=q(s,r),l=J(t,{period:n});for(let c=0;c<t.length;c++){let p=u[c],d=l[c]?.atr;if(p===null||d===null){i.push({mid:null,upper:null,lower:null,width:null});continue}let f=p+o*d,y=p-o*d,S=p>0?(f-y)/p*100:null;i.push({mid:p,upper:f,lower:y,width:S})}return i}function ft(t,e=0){return t.length===0?e:Math.max(...t)}function qe(t){return{closes:t.map(e=>e.close),ohlcv:t.map(e=>({open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}}var ee={ma:{key:"ma",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.periods??[5,10,20,30,60,120,250],n=e.type??"sma";return{bars:ft(r,20),emaBased:n==="ema"}},compute:(t,e)=>be(t.closes,typeof e=="object"?e:{})},macd:{key:"macd",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.long??26,n=e.signal??9;return{bars:r*3+n,emaBased:!0}},compute:(t,e)=>Le(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>Me(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>Ne(t.ohlcv,typeof e=="object"?e:{})},rsi:{key:"rsi",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,12,24];return{bars:ft(e,14)+1}},compute:(t,e)=>ke(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:ft(e,10)}},compute:(t,e)=>Fe(t.ohlcv,typeof e=="object"?e:{})},bias:{key:"bias",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,12,24];return{bars:ft(e,12)}},compute:(t,e)=>xe(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>ve(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>J(t.ohlcv,typeof e=="object"?e:{})},obv:{key:"obv",estimateLookback:t=>{let e=typeof t=="object"&&t.maPeriod?t.maPeriod:0;return{bars:Math.max(2,e)}},compute:(t,e)=>Ue(t.ohlcv,typeof e=="object"?e:{})},roc:{key:"roc",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.period??12,n=e.signalPeriod??0;return{bars:r+n}},compute:(t,e)=>we(t.ohlcv,typeof e=="object"?e:{})},dmi:{key:"dmi",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.period??14,n=e.adxPeriod??r;return{bars:r*2+n}},compute:(t,e)=>Be(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>Ke(t.ohlcv,typeof e=="object"?e:{})},kc:{key:"kc",estimateLookback:t=>{let e=typeof t=="object"?t:{},r=e.emaPeriod??20,n=e.atrPeriod??10;return{bars:Math.max(r*3,n),emaBased:!0}},compute:(t,e)=>He(t.ohlcv,typeof e=="object"?e:{})}};function oe(t){return Object.keys(ee).filter(e=>!!t[e])}function $e(t){let e=0,r=!1;for(let o of oe(t)){let s=ee[o].estimateLookback(t[o]);e=Math.max(e,s.bars),r||(r=!!s.emaBased)}return{maxLookback:e,hasEmaBasedIndicator:r,requiredBars:Math.ceil(e*(r?1.5:1.2))}}function Qe(t,e={}){if(t.length===0)return[];let r=qe(t),n=new Map;for(let o of oe(e)){let i=ee[o];n.set(o,i.compute(r,e[o]))}return t.map((o,i)=>({...o,...Object.fromEntries(Array.from(n.entries()).map(([s,u])=>[s,u[i]]))}))}var je=class{constructor(e,r){this.klineService=e;this.quoteService=r}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}calcActualStartDate(e,r,n=1.5){let o=Math.ceil(r*n),i=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));i.setDate(i.getDate()-o);let s=i.getFullYear(),u=String(i.getMonth()+1).padStart(2,"0"),l=String(i.getDate()).padStart(2,"0");return`${s}${u}${l}`}calcActualStartDateByCalendar(e,r,n){if(!n||n.length===0)return;let o=this.normalizeDate(e),i=n.findIndex(u=>u>=o);i===-1&&(i=n.length-1);let s=Math.max(0,i-r);return this.toCompactDate(n[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 r=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(r).getTime()}async getKlineWithIndicators(e,r={}){let{startDate:n,endDate:o,indicators:i={}}=r,s=r.market??this.detectMarket(e),{requiredBars:u}=$e(i),l={A:1.5,HK:1.46,US:1.45},c;if(n)if(s==="A")try{let y=await this.quoteService.getTradingCalendar();c=this.calcActualStartDateByCalendar(n,u,y)??this.calcActualStartDate(n,u,l[s])}catch{c=this.calcActualStartDate(n,u,l[s])}else c=this.calcActualStartDate(n,u,l[s]);let p={period:r.period,adjust:r.adjust,startDate:c,endDate:r.endDate},d;switch(s){case"HK":d=await this.klineService.getHKHistoryKline(e,p);break;case"US":d=await this.klineService.getUSHistoryKline(e,p);break;default:d=await this.klineService.getHistoryKline(e,p)}if(n&&d.length<u)switch(s){case"HK":d=await this.klineService.getHKHistoryKline(e,{...p,startDate:void 0});break;case"US":d=await this.klineService.getUSHistoryKline(e,{...p,startDate:void 0});break;default:d=await this.klineService.getHistoryKline(e,{...p,startDate:void 0})}let f=Qe(d,i);if(n){let y=this.dateToTimestamp(n),S=o?this.dateToTimestamp(o):1/0;return f.filter(g=>{let R=this.dateToTimestamp(g.date);return R>=y&&R<=S})}return f}};var Ge=class extends _{constructor(e){super(e)}getIndividualFundFlow(e,r){return T.getIndividualFundFlow(this.client,e,r)}getMarketFundFlow(){return T.getMarketFundFlow(this.client)}getFundFlowRank(e){return T.getFundFlowRank(this.client,e)}getSectorFundFlowRank(e){return T.getSectorFundFlowRank(this.client,e)}getSectorFundFlowHistory(e,r){return T.getSectorFundFlowHistory(this.client,e,r)}};var ze=class extends _{constructor(e){super(e)}getNorthboundMinute(e){return T.getNorthboundMinute(this.client,e)}getNorthboundFlowSummary(){return T.getNorthboundFlowSummary(this.client)}getNorthboundHoldingRank(e){return T.getNorthboundHoldingRank(this.client,e)}getNorthboundHistory(e,r){return T.getNorthboundHistory(this.client,e,r)}getNorthboundIndividual(e,r){return T.getNorthboundIndividual(this.client,e,r)}};var Ye=class extends _{constructor(e){super(e)}getZTPool(e,r){return T.getZTPool(this.client,e,r)}getStockChanges(e){return T.getStockChanges(this.client,e)}getBoardChanges(){return T.getBoardChanges(this.client)}};var Ve=class extends _{constructor(e){super(e)}getDragonTigerDetail(e){return T.getDragonTigerDetail(this.client,e)}getDragonTigerStockStats(e){return T.getDragonTigerStockStats(this.client,e)}getDragonTigerInstitution(e){return T.getDragonTigerInstitution(this.client,e)}getDragonTigerBranchRank(e){return T.getDragonTigerBranchRank(this.client,e)}getDragonTigerStockSeatDetail(e,r){return T.getDragonTigerStockSeatDetail(this.client,e,r)}};var We=class extends _{constructor(e){super(e)}getBlockTradeMarketStat(){return T.getBlockTradeMarketStat(this.client)}getBlockTradeDetail(e){return T.getBlockTradeDetail(this.client,e)}getBlockTradeDailyStat(e){return T.getBlockTradeDailyStat(this.client,e)}getMarginAccountInfo(){return T.getMarginAccountInfo(this.client)}getMarginTargetList(e){return T.getMarginTargetList(this.client,e)}};var Xe=class{constructor(e={}){this.client=new ye(e),this.quoteService=new Oe(this.client),this.boardService=new _e(this.client),this.klineService=new Ae(this.client),this.futuresService=new Ie(this.client),this.optionsService=new Pe(this.client),this.indicatorService=new je(this.klineService,this.quoteService),this.fundFlowService=new Ge(this.client),this.northboundService=new ze(this.client),this.marketEventService=new Ye(this.client),this.dragonTigerService=new Ve(this.client),this.dataService=new We(this.client)}getFullQuotes(e){return this.quoteService.getFullQuotes(e)}getSimpleQuotes(e){return this.quoteService.getSimpleQuotes(e)}getHKQuotes(e){return this.quoteService.getHKQuotes(e)}getUSQuotes(e){return this.quoteService.getUSQuotes(e)}getFundQuotes(e){return this.quoteService.getFundQuotes(e)}getFundFlow(e){return this.quoteService.getFundFlow(e)}getPanelLargeOrder(e){return this.quoteService.getPanelLargeOrder(e)}getTodayTimeline(e){return this.quoteService.getTodayTimeline(e)}getIndustryList(){return this.boardService.getIndustryList()}getIndustrySpot(e){return this.boardService.getIndustrySpot(e)}getIndustryConstituents(e){return this.boardService.getIndustryConstituents(e)}getIndustryKline(e,r){return this.boardService.getIndustryKline(e,r)}getIndustryMinuteKline(e,r){return this.boardService.getIndustryMinuteKline(e,r)}getConceptList(){return this.boardService.getConceptList()}getConceptSpot(e){return this.boardService.getConceptSpot(e)}getConceptConstituents(e){return this.boardService.getConceptConstituents(e)}getConceptKline(e,r){return this.boardService.getConceptKline(e,r)}getConceptMinuteKline(e,r){return this.boardService.getConceptMinuteKline(e,r)}getHistoryKline(e,r){return this.klineService.getHistoryKline(e,r)}getMinuteKline(e,r){return this.klineService.getMinuteKline(e,r)}getHKHistoryKline(e,r){return this.klineService.getHKHistoryKline(e,r)}getUSHistoryKline(e,r){return this.klineService.getUSHistoryKline(e,r)}search(e){return this.quoteService.search(e)}getAShareCodeList(e){return this.quoteService.getAShareCodeList(e)}getUSCodeList(e){return this.quoteService.getUSCodeList(e)}getHKCodeList(){return this.quoteService.getHKCodeList()}getFundCodeList(){return this.quoteService.getFundCodeList()}getAllAShareQuotes(e={}){return this.quoteService.getAllAShareQuotes(e)}getAllHKShareQuotes(e={}){return this.quoteService.getAllHKShareQuotes(e)}getAllUSShareQuotes(e={}){return this.quoteService.getAllUSShareQuotes(e)}getAllQuotesByCodes(e,r={}){return this.quoteService.getAllQuotesByCodes(e,r)}batchRaw(e){return this.quoteService.batchRaw(e)}getTradingCalendar(){return this.quoteService.getTradingCalendar()}getDividendDetail(e){return this.quoteService.getDividendDetail(e)}getFuturesKline(e,r){return this.futuresService.getFuturesKline(e,r)}getGlobalFuturesSpot(e){return this.futuresService.getGlobalFuturesSpot(e)}getGlobalFuturesKline(e,r){return this.futuresService.getGlobalFuturesKline(e,r)}getFuturesInventorySymbols(){return this.futuresService.getFuturesInventorySymbols()}getFuturesInventory(e,r){return this.futuresService.getFuturesInventory(e,r)}getComexInventory(e,r){return this.futuresService.getComexInventory(e,r)}getIndexOptionSpot(e,r){return this.optionsService.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return this.optionsService.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return this.optionsService.getCFFEXOptionQuotes(e)}getETFOptionMonths(e){return this.optionsService.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return this.optionsService.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return this.optionsService.getETFOptionMinute(e)}getETFOptionDailyKline(e){return this.optionsService.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return this.optionsService.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return this.optionsService.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return this.optionsService.getCommodityOptionKline(e)}getOptionLHB(e,r){return this.optionsService.getOptionLHB(e,r)}getKlineWithIndicators(e,r={}){return this.indicatorService.getKlineWithIndicators(e,r)}getIndividualFundFlow(e,r){return this.fundFlowService.getIndividualFundFlow(e,r)}getMarketFundFlow(){return this.fundFlowService.getMarketFundFlow()}getFundFlowRank(e){return this.fundFlowService.getFundFlowRank(e)}getSectorFundFlowRank(e){return this.fundFlowService.getSectorFundFlowRank(e)}getSectorFundFlowHistory(e,r){return this.fundFlowService.getSectorFundFlowHistory(e,r)}getNorthboundMinute(e){return this.northboundService.getNorthboundMinute(e)}getNorthboundFlowSummary(){return this.northboundService.getNorthboundFlowSummary()}getNorthboundHoldingRank(e){return this.northboundService.getNorthboundHoldingRank(e)}getNorthboundHistory(e,r){return this.northboundService.getNorthboundHistory(e,r)}getNorthboundIndividual(e,r){return this.northboundService.getNorthboundIndividual(e,r)}getZTPool(e,r){return this.marketEventService.getZTPool(e,r)}getStockChanges(e){return this.marketEventService.getStockChanges(e)}getBoardChanges(){return this.marketEventService.getBoardChanges()}getDragonTigerDetail(e){return this.dragonTigerService.getDragonTigerDetail(e)}getDragonTigerStockStats(e){return this.dragonTigerService.getDragonTigerStockStats(e)}getDragonTigerInstitution(e){return this.dragonTigerService.getDragonTigerInstitution(e)}getDragonTigerBranchRank(e){return this.dragonTigerService.getDragonTigerBranchRank(e)}getDragonTigerStockSeatDetail(e,r){return this.dragonTigerService.getDragonTigerStockSeatDetail(e,r)}getBlockTradeMarketStat(){return this.dataService.getBlockTradeMarketStat()}getBlockTradeDetail(e){return this.dataService.getBlockTradeDetail(e)}getBlockTradeDailyStat(e){return this.dataService.getBlockTradeDailyStat(e)}getMarginAccountInfo(){return this.dataService.getMarginAccountInfo()}getMarginTargetList(e){return this.dataService.getMarginTargetList(e)}},mo=Xe;0&&(module.exports={HttpError,INDICATOR_REGISTRY,SdkError,StockSDK,addIndicators,asyncPool,buildIndicatorContext,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,estimateIndicatorLookback,extractJsonFromJsonp,getEnabledIndicatorKeys,getSdkErrorCode,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});
|