stock-sdk 1.8.2 → 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 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 工具
@@ -107,6 +110,45 @@ const allQuotes = await sdk.getAllAShareQuotes({
107
110
  console.log(`共获取 ${allQuotes.length} 只股票`);
108
111
  ```
109
112
 
113
+ ## 请求治理与错误码
114
+
115
+ ```ts
116
+ import { StockSDK, HttpError, getSdkErrorCode } from 'stock-sdk';
117
+
118
+ const sdk = new StockSDK({
119
+ retry: { maxRetries: 2, baseDelay: 500 },
120
+ providerPolicies: {
121
+ eastmoney: {
122
+ timeout: 12000,
123
+ rateLimit: { requestsPerSecond: 3, maxBurst: 3 },
124
+ },
125
+ },
126
+ });
127
+
128
+ try {
129
+ await sdk.getSimpleQuotes(['sh600519']);
130
+ } catch (error) {
131
+ if (error instanceof HttpError) {
132
+ console.log(error.status, error.statusText);
133
+ }
134
+
135
+ console.log(getSdkErrorCode(error)); // HTTP_ERROR / NETWORK_ERROR / TIMEOUT ...
136
+ }
137
+ ```
138
+
139
+ `getSdkErrorCode` 只做标准化识别,不会改变原始错误实例类型。网络错误仍然保持 `TypeError`,超时仍然保持 `AbortError` / `DOMException` 的兼容行为。
140
+
141
+ ## 开发校验命令
142
+
143
+ ```bash
144
+ yarn typecheck
145
+ yarn build
146
+ yarn test
147
+ yarn test:integration:smoke
148
+ # 全量集成回归
149
+ yarn test:integration:full
150
+ ```
151
+
110
152
  ## 🤖 AI / MCP 集成
111
153
 
112
154
  Stock SDK 配套 MCP Server([stock-sdk-mcp](https://www.npmjs.com/package/stock-sdk-mcp)),可一键接入主流 AI 工具:
@@ -233,9 +275,58 @@ Stock SDK 配套 MCP Server([stock-sdk-mcp](https://www.npmjs.com/package/stoc
233
275
 
234
276
  | 方法 | 说明 |
235
277
  |------|------|
236
- | `getFundFlow` | 资金流向 |
278
+ | `getFundFlow` | 资金流向(按代码批量查询) |
237
279
  | `getPanelLargeOrder` | 盘口大单占比 |
238
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` | 融资融券标的明细 |
239
330
 
240
331
  ### 批量查询
241
332
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var He=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Xn=Object.prototype.hasOwnProperty;var _e=(t,e)=>{for(var n in e)He(t,n,{get:e[n],enumerable:!0})},Yn=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wn(e))!Xn.call(t,r)&&r!==n&&He(t,r,{get:()=>e[r],enumerable:!(i=Vn(e,r))||i.enumerable});return t};var Zn=t=>Yn(He({},"__esModule",{value:!0}),t);var kr={};_e(kr,{HttpError:()=>v,StockSDK:()=>Ee,addIndicators:()=>Te,asyncPool:()=>H,calcATR:()=>j,calcBIAS:()=>ge,calcBOLL:()=>pe,calcCCI:()=>he,calcDMI:()=>Ce,calcEMA:()=>U,calcKC:()=>Oe,calcKDJ:()=>de,calcMA:()=>ue,calcMACD:()=>ce,calcOBV:()=>ye,calcROC:()=>Re,calcRSI:()=>me,calcSAR:()=>Se,calcSMA:()=>B,calcWMA:()=>we,calcWR:()=>fe,chunkArray:()=>w,decodeGBK:()=>V,default:()=>Gn,extractJsonFromJsonp:()=>Ke,jsonpRequest:()=>P,parseResponse:()=>W,safeNumber:()=>h,safeNumberOrNull:()=>S});module.exports=Zn(kr);function V(t){return new TextDecoder("gbk").decode(t)}function W(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let r=i.indexOf("=");if(r<0)continue;let o=i.slice(0,r).trim();o.startsWith("v_")&&(o=o.slice(2));let s=i.slice(r+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");n.push({key:o,fields:a})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function S(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function R(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:R(String(t))}var qe="https://qt.gtimg.cn",je="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Qe="https://assets.linkdiary.cn/shares/zh_a_list.json",$e="https://assets.linkdiary.cn/shares/us_list.json",Ge="https://assets.linkdiary.cn/shares/hk_list.json",ze="https://assets.linkdiary.cn/shares/fund_list",Ft="https://assets.linkdiary.cn/shares/trade-data-list.txt";var be="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ve="https://push2his.eastmoney.com/api/qt/stock/trends2/get",We="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Xe="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ye="https://17.push2.eastmoney.com/api/qt/clist/get",Ze="https://91.push2.eastmoney.com/api/qt/stock/get",Je="https://29.push2.eastmoney.com/api/qt/clist/get",et="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",tt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",nt="https://79.push2.eastmoney.com/api/qt/clist/get",rt="https://91.push2.eastmoney.com/api/qt/stock/get",ot="https://29.push2.eastmoney.com/api/qt/clist/get",it="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",st="https://push2his.eastmoney.com/api/qt/stock/trends2/get",F="https://datacenter-web.eastmoney.com/api/data/v1/get",X="https://push2his.eastmoney.com/api/qt/stock/kline/get",at="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",Y="58b2fa8f54638b60b87d69b31969089c",lt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},$={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},Pe={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},Z="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",J="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",ut="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",Ae="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",ct="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",pt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",dt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",mt="https://futsseapi.eastmoney.com/list/option/221",ft="https://datacenter-web.eastmoney.com/api/data/get",gt="b2884a393a59ad64002292a3e90d46a5";var Ie={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},ht=3e4,ee=500,te=500,ne=7,yt=3,Rt=1e3,Ct=3e4,St=2,Ot=[408,429,500,502,503,504];var Me=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var vt=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Tt=0;function Jn(){return typeof window<"u"&&typeof window.document<"u"}function wt(){if(Jn())return;let t=vt[Tt];return Tt=(Tt+1)%vt.length,t}var re=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},xe=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new re;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var v=class extends Error{constructor(n,i,r,o){let s=i?` ${i}`:"",a=r?`, url: ${r}`:"",l=o?`, provider: ${o}`:"";super(`HTTP error! status: ${n}${s}${a}${l}`);this.status=n;this.statusText=i;this.url=r;this.provider=o;this.name="HttpError"}},oe=class{constructor(e={}){this.baseUrl=e.baseUrl??qe;let n={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=this.resolveProviderPolicy(n),this.providerPolicies={},this.runtimeStates=new Map;for(let[i,r]of Object.entries(e.providerPolicies??{})){let o=this.mergeProviderPolicy(n,r);this.providerPolicies[i]=this.resolveProviderPolicy(o)}}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??yt,baseDelay:e?.baseDelay??Rt,maxDelay:e?.maxDelay??Ct,backoffMultiplier:e?.backoffMultiplier??St,retryableStatusCodes:e?.retryableStatusCodes??Ot,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}normalizeHeaders(e,n){let i={...e??{}};return n&&(Object.keys(i).some(o=>o.toLowerCase()==="user-agent")||(i["User-Agent"]=n)),i}mergeProviderPolicy(e,n){return n?{timeout:n.timeout??e.timeout,retry:n.retry?{...e.retry??{},...n.retry}:e.retry?{...e.retry}:void 0,headers:{...e.headers??{},...n.headers??{}},userAgent:n.userAgent??e.userAgent,rateLimit:n.rateLimit?{...e.rateLimit??{},...n.rateLimit}:e.rateLimit?{...e.rateLimit}:void 0,rotateUserAgent:n.rotateUserAgent??e.rotateUserAgent,circuitBreaker:n.circuitBreaker?{...e.circuitBreaker??{},...n.circuitBreaker}:e.circuitBreaker?{...e.circuitBreaker}:void 0}:{...e,headers:{...e.headers??{}},retry:e.retry?{...e.retry}:void 0,rateLimit:e.rateLimit?{...e.rateLimit}:void 0,circuitBreaker:e.circuitBreaker?{...e.circuitBreaker}:void 0}}resolveProviderPolicy(e={}){return{timeout:e.timeout??ht,retry:this.resolveRetryOptions(e.retry),headers:this.normalizeHeaders(e.headers,e.userAgent),rotateUserAgent:e.rotateUserAgent??!1,rateLimit:e.rateLimit?{...e.rateLimit}:void 0,circuitBreaker:e.circuitBreaker?{...e.circuitBreaker}:void 0}}getProviderState(e){let n=this.runtimeStates.get(e);if(n)return n;let i=this.providerPolicies[e]??this.defaultPolicy,r={policy:i,rateLimiter:i.rateLimit?new Me(i.rateLimit):null,circuitBreaker:i.circuitBreaker?new xe(i.circuitBreaker):null};return this.runtimeStates.set(e,r),r}inferProvider(e,n){if(n)return n;try{let i=new URL(e).hostname;if(i.includes("eastmoney.com"))return"eastmoney";if(i.includes("gtimg.cn"))return"tencent";if(i.includes("sina.com.cn"))return"sina";if(i.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}getTimeout(){return this.defaultPolicy.timeout}calculateDelay(e,n){return Math.min(n.baseDelay*Math.pow(n.backoffMultiplier,e),n.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n,i){return n>=i.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?i.retryOnTimeout:e instanceof TypeError?i.retryOnNetworkError:e instanceof v?i.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n,i,r=0){try{let o=await e();return n.circuitBreaker?.recordSuccess(),o}catch(o){if(this.shouldRetry(o,r,n.policy.retry)){let s=this.calculateDelay(r,n.policy.retry);return n.policy.retry.onRetry&&o instanceof Error&&n.policy.retry.onRetry(r+1,o,s),await this.sleep(s),this.executeWithRetry(e,n,i,r+1)}throw n.circuitBreaker?.recordFailure(),o instanceof Error&&(o.provider=i),o}}async get(e,n={}){let i=this.inferProvider(e,n.provider),r=this.getProviderState(i);if(r.circuitBreaker&&!r.circuitBreaker.canRequest())throw new re("Circuit breaker is OPEN, request rejected");return r.rateLimiter&&await r.rateLimiter.acquire(),this.executeWithRetry(async()=>{let o=new AbortController,s=setTimeout(()=>o.abort(),r.policy.timeout),a={...r.policy.headers};if(r.policy.rotateUserAgent){let l=wt();l&&(a["User-Agent"]=l)}try{let l=await fetch(e,{signal:o.signal,headers:a});if(!l.ok)throw new v(l.status,l.statusText,e,i);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=i),l}finally{clearTimeout(s)}},r,i)}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer",provider:"tencent"}),r=V(i);return W(r)}};var er=new Set(["daily","weekly","monthly"]),tr=new Set(["1","5","15","30","60"]),nr=new Set(["","qfq","hfq"]);function K(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function I(t){if(!er.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function ie(t){if(!tr.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function k(t){if(!nr.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function w(t,e){K(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function H(t,e,n=!1){if(K(e,"concurrency"),t.length===0)return[];let i=n?new Array(t.length):[],r=0,o=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let s=r++;if(s>=t.length)return;let a=await t[s]();n?i[s]=a:i.push(a)}});return await Promise.all(o),i}function Le(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function M(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function N(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var rr=typeof document<"u"&&typeof window<"u",or=0;function Ht(){return`__stock_sdk_jsonp_${Date.now()}_${or++}`}function Ke(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let i=e.indexOf("(");if(i===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let r=e.lastIndexOf(")");if(r===-1||r<=i)throw new Error("Invalid JSONP response: no closing parenthesis found");let o=e.slice(i+1,r);return JSON.parse(o)}function ir(t,e){let{timeout:n=15e3,callbackParam:i="callback",callbackMode:r="query"}=e;return new Promise((o,s)=>{let a=Ht(),l;if(r==="path")l=t.replace("{callback}",a);else{let y=t.includes("?")?"&":"?";l=`${t}${y}${i}=${a}`}let u=document.createElement("script"),c=!1,m=window,d=()=>{u.parentNode&&u.parentNode.removeChild(u),delete m[a]},g=setTimeout(()=>{c||(c=!0,d(),s(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);m[a]=y=>{c||(c=!0,clearTimeout(g),d(),o(y))},u.onerror=()=>{c||(c=!0,clearTimeout(g),d(),s(new Error(`JSONP script load failed: ${t}`)))},u.src=l,document.head.appendChild(u)})}async function sr(t,e){let{timeout:n=15e3,callbackParam:i="callback",callbackMode:r="query"}=e,o=Ht(),s;if(r==="path")s=t.replace("{callback}",o);else{let u=t.includes("?")?"&":"?";s=`${t}${u}${i}=${o}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let u=await fetch(s,{signal:a.signal});if(!u.ok)throw new Error(`JSONP fetch failed with status ${u.status}: ${t}`);let c=await u.text();return Ke(c)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):u}finally{clearTimeout(l)}}function P(t,e={}){return rr?ir(t,e):sr(t,e)}var b={};_e(b,{getAShareCodeList:()=>zt,getAllHKQuotesByCodes:()=>Yt,getAllQuotesByCodes:()=>Xt,getAllUSQuotesByCodes:()=>Zt,getFullQuotes:()=>Ue,getFundCodeList:()=>Jt,getFundFlow:()=>jt,getFundQuotes:()=>$t,getHKCodeList:()=>Wt,getHKQuotes:()=>De,getPanelLargeOrder:()=>Qt,getSimpleQuotes:()=>qt,getTodayTimeline:()=>Gt,getTradingCalendar:()=>en,getUSCodeList:()=>Vt,getUSQuotes:()=>ke,parseFullQuote:()=>Et,parseFundFlow:()=>bt,parseFundQuote:()=>Mt,parseHKQuote:()=>At,parsePanelLargeOrder:()=>Pt,parseSimpleQuote:()=>_t,parseUSQuote:()=>It,search:()=>nn});function Et(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),pb:S(t[46]),limitUp:S(t[47]),limitDown:S(t[48]),volumeRatio:S(t[49]),avgPrice:S(t[51]),peStatic:S(t[52]),peDynamic:S(t[53]),high52w:S(t[67]),low52w:S(t[68]),circulatingShares:S(t[72]),totalShares:S(t[73]),raw:t}}function _t(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:S(t[9]),marketType:t[10]??"",raw:t}}function bt(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function Pt(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function At(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:S(t[40]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),currency:t[t.length-3]??"",raw:t}}function It(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),totalMarketCap:S(t[45]),pb:S(t[47]),high52w:S(t[48]),low52w:S(t[49]),raw:t}}function Mt(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function Ue(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>Et(i.fields))}async function qt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>_t(r.fields))}async function jt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>bt(r.fields))}async function Qt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Pt(r.fields))}async function De(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>At(r.fields))}async function ke(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>It(r.fields))}async function $t(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>Mt(r.fields))}async function Gt(t,e){let n=t.getTimeout(),i=new AbortController,r=setTimeout(()=>i.abort(),n);try{let o=await fetch(`${je}?code=${e}`,{signal:i.signal});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(s.code!==0)throw new Error(s.msg||"API error");let a=s.data?.[e];if(!a)return{code:e,date:"",data:[]};let l=a.data?.data||[],u=a.data?.date||"",c=!1;if(l.length>0){let d=l[0].split(" "),g=parseFloat(d[1])||0,y=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;y>0&&g>0&&f/y>g*50&&(c=!0)}let m=l.map(d=>{let g=d.split(" "),y=g[0],f=`${y.slice(0,2)}:${y.slice(2,4)}`,C=parseInt(g[2],10)||0,O=parseFloat(g[3])||0,E=c?C*100:C,_=E>0?O/E:0;return{time:f,price:parseFloat(g[1])||0,volume:E,amount:O,avgPrice:Math.round(_*100)/100}});return{code:e,date:u,data:m}}finally{clearTimeout(r)}}var xt=null,ar=null,Ne=null,lr=null,Be=null,Lt=null;function ur(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function zt(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!xt){let s=(await t.get(Qe,{responseType:"json"}))?.list||[];xt=s,ar=s.map(a=>a.replace(/^(sh|sz|bj)/,""))}let r=xt;return i&&(r=r.filter(o=>ur(o,i))),n?r.map(o=>o.replace(/^(sh|sz|bj)/,"")):r.slice()}var cr={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Vt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),Ne||(Ne=(await t.get($e,{responseType:"json"}))?.list||[],lr=Ne.map(s=>s.replace(/^\d{3}\./,"")));let r=Ne.slice();if(i){let o=cr[i];r=r.filter(s=>s.startsWith(o))}return n?r.map(o=>o.replace(/^\d{3}\./,"")):r}async function Wt(t){return Be||(Be=(await t.get(Ge,{responseType:"json"}))?.list||[]),Be.slice()}async function Xt(t,e,n={}){let{batchSize:i=ee,concurrency:r=ne,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,te),a=w(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await Ue(t,d);return u++,o&&o(u,l),g});return(await H(c,r,!0)).flat()}async function Yt(t,e,n={}){let{batchSize:i=ee,concurrency:r=ne,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,te),a=w(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await De(t,d);return u++,o&&o(u,l),g});return(await H(c,r,!0)).flat()}async function Zt(t,e,n={}){let{batchSize:i=ee,concurrency:r=ne,onProgress:o}=n;K(i,"batchSize"),K(r,"concurrency");let s=Math.min(i,te),a=w(e,s),l=a.length,u=0,c=a.map(d=>async()=>{let g=await ke(t,d);return u++,o&&o(u,l),g});return(await H(c,r,!0)).flat()}async function Jt(t){if(Lt)return Lt.slice();let i=(await t.get(ze,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return Lt=i,i.slice()}var G=null;async function en(t){if(G)return G.slice();let e=await t.get(Ft);return!e||e.trim()===""?(G=[],G.slice()):(G=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),G.slice())}var tn="https://smartbox.gtimg.cn/s3/";function pr(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function dr(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),r=i[0]||"",o=i[1]||"",s=pr(i[2]||""),a=i[4]||"";return{code:r+o,name:s,market:r,type:a}})}function mr(t){return new Promise((e,n)=>{let i=`${tn}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=i,r.charset="utf-8",r.onload=()=>{let o=window.v_hint||"";document.body.removeChild(r),e(o)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function fr(t,e){let n=`${tn}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function gr(){return typeof window<"u"&&typeof document<"u"}async function nn(t,e){if(!e||!e.trim())return[];let n;return gr()?n=await mr(e):n=await fr(t,e),dr(n)}var T={};_e(T,{extractVariety:()=>Ut,getCFFEXOptionQuotes:()=>Mn,getComexInventory:()=>Dn,getConceptConstituents:()=>On,getConceptKline:()=>Tn,getConceptList:()=>Cn,getConceptMinuteKline:()=>En,getConceptSpot:()=>Sn,getDividendDetail:()=>_n,getFuturesHistoryKline:()=>Pn,getFuturesInventory:()=>Un,getFuturesInventorySymbols:()=>Ln,getFuturesMarketCode:()=>Dt,getGlobalFuturesKline:()=>In,getGlobalFuturesSpot:()=>An,getHKHistoryKline:()=>sn,getHistoryKline:()=>rn,getIndustryConstituents:()=>hn,getIndustryKline:()=>yn,getIndustryList:()=>fn,getIndustryMinuteKline:()=>Rn,getIndustrySpot:()=>gn,getMinuteKline:()=>on,getOptionLHB:()=>xn,getUSHistoryKline:()=>an});async function Kt(t,e,n,i,r=100,o){let s=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(r),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(l=d.total??0);let g=d.diff.map((y,f)=>o(y,s.length+f+1));s.push(...g),a++}while(s.length<l);return s}function x(t){let[e,n,i,r,o,s,a,l,u,c,m]=t.split(",");return{date:e,open:R(n),close:R(i),high:R(r),low:R(o),volume:R(s),amount:R(a),amplitude:R(l),changePercent:R(u),change:R(c),turnoverRate:R(m)}}async function L(t,e,n){let i=`${e}?${n.toString()}`,r=await t.get(i,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function rn(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:o="19700101",endDate:s="20500101"}=n;I(i),k(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Le(e)}.${a}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:N(r),secid:l,beg:o,end:s}),c=be,{klines:m}=await L(t,c,u);return m.length===0?[]:m.map(d=>({...x(d),code:a}))}async function on(t,e,n={}){let{period:i="1",adjust:r="qfq",startDate:o="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=n;ie(i),k(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Le(e)}.${a}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:l}),c=`${Ve}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let g=o.replace("T"," ").slice(0,16),y=s.replace("T"," ").slice(0,16);return d.map(f=>{let[C,O,E,_,z,D,Q,zn]=f.split(",");return{time:C,open:R(O),close:R(E),high:R(_),low:R(z),volume:R(D),amount:R(Q),avgPrice:R(zn)}}).filter(f=>f.time>=g&&f.time<=y)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:N(r||""),secid:l,beg:"0",end:"20500000"}),c=be,{klines:m}=await L(t,c,u);if(m.length===0)return[];let d=o.replace("T"," ").slice(0,16),g=s.replace("T"," ").slice(0,16);return m.map(y=>{let f=x(y);return{...f,time:f.date}}).filter(y=>y.time>=d&&y.time<=g)}}function Fe(t){return async function(n,i,r={}){let{period:o="daily",adjust:s="qfq",startDate:a="19700101",endDate:l="20500101"}=r;I(o),k(s);let u=t.normalizeSymbol(i),c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(o),fqt:N(s),secid:u.secid,beg:a,end:l,lmt:"1000000"}),{klines:m,name:d,code:g}=await L(n,t.url,c);if(m.length===0)return[];let y=t.resolveResultMeta?t.resolveResultMeta(i,u,{code:g,name:d}):{code:g||u.fallbackCode,name:d||""};return m.map(f=>({...x(f),code:y.code,name:y.name}))}}var hr=Fe({url:We,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function sn(t,e,n={}){return hr(t,e,n)}var yr=Fe({url:Xe,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:n.code||e.fallbackCode,name:n.name||""})});async function an(t,e,n={}){return yr(t,e,n)}function ln(t){let e=null;return{async getCode(n,i,r){if(i.startsWith("BK"))return i;if(!e){let s=await r(n);e=new Map(s.map(a=>[a.name,a.code]))}let o=e.get(i);if(!o)throw new Error(`${t.errorPrefix}: ${i}`);return o}}}async function un(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await Kt(t,e.listUrl,n,i,100,(o,s)=>({rank:s,name:String(o.f14??""),code:String(o.f12??""),price:p(o.f2),change:p(o.f4),changePercent:p(o.f3),totalMarketCap:p(o.f20),turnoverRate:p(o.f8),riseCount:p(o.f104),fallCount:p(o.f105),leadingStock:o.f128?String(o.f128):null,leadingStockChangePercent:p(o.f136)}));return r.sort((o,s)=>(s.changePercent??0)-(o.changePercent??0)),r.forEach((o,s)=>{o.rank=s+1}),r}async function cn(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.data;return s?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:u,divide:c})=>{let m=s[l],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:u,value:d}}):[]}async function pn(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Kt(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(o,s)=>({rank:s,code:String(o.f12??""),name:String(o.f14??""),price:p(o.f2),changePercent:p(o.f3),change:p(o.f4),volume:p(o.f5),amount:p(o.f6),amplitude:p(o.f7),high:p(o.f15),low:p(o.f16),open:p(o.f17),prevClose:p(o.f18),turnoverRate:p(o.f8),pe:p(o.f9),pb:p(o.f23)}))}async function dn(t,e,n,i={}){let{period:r="daily",adjust:o="",startDate:s="19700101",endDate:a="20500101"}=i;I(r),k(o);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:M(r),fqt:N(o),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await L(t,n,l);return u.length===0?[]:u.map(c=>x(c))}async function mn(t,e,n,i,r={}){let{period:o="5"}=r;if(ie(o),o==="1"){let s=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${i}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,g,y,f,C,O,E]=c.split(",");return{time:m,open:R(d),close:R(g),high:R(y),low:R(f),volume:R(C),amount:R(O),price:R(E)}})}else{let s=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:o,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,g,y,f,C,O,E,_,z,D]=c.split(",");return{time:m,open:R(d),close:R(g),high:R(y),low:R(f),changePercent:R(_),change:R(z),volume:R(C),amount:R(O),amplitude:R(E),turnoverRate:R(D)}})}}function ve(t){let e=ln(t);async function n(r){return un(r,t)}async function i(r,o){return e.getCode(r,o,n)}return{async getList(r){return n(r)},async getSpot(r,o){let s=await i(r,o);return cn(r,s,t.spotUrl)},async getConstituents(r,o){let s=await i(r,o);return pn(r,s,t.consUrl)},async getKline(r,o,s={}){let a=await i(r,o);return dn(r,a,t.klineUrl,s)},async getMinuteKline(r,o,s={}){let a=await i(r,o);return mn(r,a,t.klineUrl,t.trendsUrl,s)}}}var Rr={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ye,spotUrl:Ze,consUrl:Je,klineUrl:et,trendsUrl:tt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},se=ve(Rr);async function fn(t){return se.getList(t)}async function gn(t,e){return se.getSpot(t,e)}async function hn(t,e){return se.getConstituents(t,e)}async function yn(t,e,n={}){return se.getKline(t,e,n)}async function Rn(t,e,n={}){return se.getMinuteKline(t,e,n)}var Cr={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:nt,spotUrl:rt,consUrl:ot,klineUrl:it,trendsUrl:st,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ae=ve(Cr);async function Cn(t){return ae.getList(t)}async function Sn(t,e){return ae.getSpot(t,e)}async function On(t,e){return ae.getConstituents(t,e)}async function Tn(t,e,n={}){return ae.getKline(t,e,n)}async function En(t,e,n={}){return ae.getMinuteKline(t,e,n)}function q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Sr(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:q(t.REPORT_DATE),planNoticeDate:q(t.PLAN_NOTICE_DATE),disclosureDate:q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:q(t.EQUITY_RECORD_DATE),exDividendDate:q(t.EX_DIVIDEND_DATE),payDate:q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:q(t.NOTICE_DATE)}}async function _n(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],r=1,o=1;do{let s=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),a=`${F}?${s.toString()}`,u=(await t.get(a,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(o=u.pages??1);let c=u.data.map(Sr);i.push(...c),r++}while(r<=o);return i}function Ut(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function bn(t){return $[t]??$[t.toLowerCase()]??$[t.toUpperCase()]}function Dt(t){let e=bn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=bn(t.slice(0,-1))),!e){let i=Object.keys($).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${i}`)}let n=lt[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function Or(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?R(n[12]):null}}async function Pn(t,e,n={}){let{period:i="daily",startDate:r="19700101",endDate:o="20500101"}=n;I(i);let s=Ut(e),l=`${Dt(s)}.${e}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:"0",secid:l,beg:r,end:o}),{klines:c,name:m,code:d}=await L(t,X,u);return c.length===0?[]:c.map(g=>({...Or(g),code:d||e,name:m||""}))}async function An(t,e={}){let n=e.pageSize??20,i=[],r=0,o=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(r),token:Y,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${at}?${s.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;r===0&&(o=l.total??0);let u=l.list.map(Tr);i.push(...u),r++}while(i.length<o);return i}function Tr(t){return{code:t.dm||"",name:t.name||"",price:R(String(t.p)),change:R(String(t.zde)),changePercent:R(String(t.zdf)),open:R(String(t.o)),high:R(String(t.h)),low:R(String(t.l)),prevSettle:R(String(t.zjsj)),volume:R(String(t.vol)),buyVolume:R(String(t.wp)),sellVolume:R(String(t.np)),openInterest:R(String(t.ccl))}}function Er(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?R(n[12]):null}}function _r(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function In(t,e,n={}){let{period:i="daily",startDate:r="19700101",endDate:o="20500101"}=n;I(i);let s=n.marketCode;if(s===void 0){let d=_r(e);if(s=Pe[d],s===void 0){let g=Object.keys(Pe).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${g}. Or specify marketCode manually via options.`)}}let a=`${s}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:M(i),fqt:"0",secid:a,beg:r,end:o}),{klines:u,name:c,code:m}=await L(t,X,l);return u.length===0?[]:u.map(d=>({...Er(d),code:m||e,name:c||""}))}async function Mn(t,e={}){let{pageSize:n=2e4}=e,i=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:Y,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),r=`${mt}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.list;return Array.isArray(s)?s.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:p(a.p),change:p(a.zde),changePercent:p(a.zdf),volume:p(a.vol),amount:p(a.cje),openInterest:p(a.ccl),strikePrice:p(a.xqj),remainDays:p(a.syr),dailyChange:p(a.rz),prevSettle:p(a.zjsj),open:p(a.o)})):[]}async function xn(t,e,n){let i=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:gt,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),r=`${ft}?${i.toString()}`,s=(await t.get(r,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function a(l){if(!l)return"";let u=String(l),c=u.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:u}return s.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:p(l.MEMBER_RANK)??0,sellVolume:p(l.SELL_VOLUME),sellVolumeChange:p(l.SELL_VOLUME_CHANGE),netSellVolume:p(l.NET_SELL_VOLUME),sellVolumeRatio:p(l.SELL_VOLUME_RATIO),buyVolume:p(l.BUY_VOLUME),buyVolumeChange:p(l.BUY_VOLUME_CHANGE),netBuyVolume:p(l.NET_BUY_VOLUME),buyVolumeRatio:p(l.BUY_VOLUME_RATIO),sellPosition:p(l.SELL_POSITION),sellPositionChange:p(l.SELL_POSITION_CHANGE),netSellPosition:p(l.NET_SELL_POSITION),sellPositionRatio:p(l.SELL_POSITION_RATIO),buyPosition:p(l.BUY_POSITION),buyPositionChange:p(l.BUY_POSITION_CHANGE),netBuyPosition:p(l.NET_BUY_POSITION),buyPositionRatio:p(l.BUY_POSITION_RATIO)}))}var br={gold:"EMI00069026",silver:"EMI00069027"};async function Ln(t){let e=new URLSearchParams({reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageNumber:"1",pageSize:"500",source:"WEB",client:"WEB"}),n=`${F}?${e.toString()}`,r=(await t.get(n,{responseType:"json"}))?.result?.data;return Array.isArray(r)?r.map(o=>({code:String(o.TRADE_CODE??""),name:String(o.TRADE_TYPE??""),marketCode:String(o.TRADE_MARKET_CODE??"")})):[]}function Kn(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function Un(t,e,n={}){let{startDate:i="2020-10-28",pageSize:r=500}=n,o=e.toUpperCase(),s=[],a=1,l=1;do{let u=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${o}")(TRADE_DATE>='${i}')`,pageNumber:String(a),pageSize:String(r),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${F}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(l=d.pages??1);let g=d.data.map(y=>({code:String(y.SECURITY_CODE??e),date:Kn(y.TRADE_DATE),inventory:p(y.ON_WARRANT_NUM),change:p(y.ADDCHANGE)}));s.push(...g),a++}while(a<=l);return s}async function Dn(t,e,n={}){let i=br[e];if(!i)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:r=500}=n,o=[],s=1,a=1,l={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let u=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(r),pageNumber:String(s),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${i}")(@STORAGE_TON<>"NULL")`}),c=`${F}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;s===1&&(a=d.pages??1);let g=d.data.map(y=>({date:Kn(y.REPORT_DATE),name:l[e]??e,storageTon:p(y.STORAGE_TON),storageOunce:p(y.STORAGE_OUNCE)}));o.push(...g),s++}while(s<=a);return o}var A={};_e(A,{getCommodityOptionKline:()=>Qn,getCommodityOptionSpot:()=>jn,getETFOption5DayMinute:()=>qn,getETFOptionDailyKline:()=>Hn,getETFOptionExpireDay:()=>Fn,getETFOptionMinute:()=>wn,getETFOptionMonths:()=>Bn,getIndexOptionKline:()=>Nn,getIndexOptionSpot:()=>kn});function Pr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Ar(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function kn(t,e){let n=`${Z}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,i=await P(n),r=i?.result?.data?.up??[],o=i?.result?.data?.down??[];return{calls:r.map(Pr),puts:o.map(Ar)}}async function Nn(t){let e=`${J}?symbol=${t}`,n=await P(e,{callbackMode:"path"});return Array.isArray(n)?n.map(i=>({date:i.d,open:p(i.o),high:p(i.h),low:p(i.l),close:p(i.c),volume:p(i.v)})):[]}async function Bn(t){let e=`${ut}?exchange=null&cate=${encodeURIComponent(t)}`,i=(await P(e))?.result?.data,r=i?.contractMonth??[];return{months:r.length>1?r.slice(1):r,stockId:i?.stockId??"",cateId:i?.cateId??"",cateList:i?.cateList??[]}}async function Fn(t,e){let n=`${Ae}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,i=await P(n),r=i?.result?.data?.remainderDays;if(typeof r=="number"&&r<0){let s=`${Ae}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;i=await P(s)}let o=i?.result?.data;return{expireDay:o?.expireDay??"",remainderDays:o?.remainderDays??0,stockId:o?.stockId??"",name:o?.other?.name??""}}function vn(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:p(n.p),volume:p(n.v),openInterest:p(n.t),avgPrice:p(n.a)}))}async function wn(t){let e=`CON_OP_${t}`,n=`${ct}?symbol=${e}`,r=(await P(n))?.result?.data;return Array.isArray(r)?vn(r):[]}async function Hn(t){let e=`CON_OP_${t}`,n=`${pt}?symbol=${e}`,i=await P(n,{callbackMode:"path"});return Array.isArray(i)?i.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}async function qn(t){let e=`CON_OP_${t}`,n=`${dt}?symbol=${e}`,r=(await P(n))?.result?.data;if(!Array.isArray(r))return[];let o=[];for(let s of r)Array.isArray(s)&&o.push(...vn(s));return o}function Ir(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Mr(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function jn(t,e){let n=Ie[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(Ie).join(", ")}`);let i=`${Z}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,r=await P(i),o=r?.result?.data?.up??[],s=r?.result?.data?.down??[];return{calls:o.map(Ir),puts:s.map(Mr)}}async function Qn(t){let e=`${J}?symbol=${t}`,n=await P(e,{callbackMode:"path"});return Array.isArray(n)?n.map(i=>({date:i.d,open:p(i.o),high:p(i.h),low:p(i.l),close:p(i.c),volume:p(i.v)})):[]}function le(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function B(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let r=0,o=0;for(let s=i-e+1;s<=i;s++)t[s]!==null&&(r+=t[s],o++);n.push(o===e?le(r/e):null)}return n}function U(t,e){let n=[],i=2/(e+1),r=null,o=!1;for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}if(!o){let l=0,u=0;for(let c=s-e+1;c<=s;c++)t[c]!==null&&(l+=t[c],u++);u===e&&(r=l/e,o=!0),n.push(r!==null?le(r):null);continue}let a=t[s];a===null?n.push(r!==null?le(r):null):(r=i*a+(1-i)*r,n.push(le(r)))}return n}function we(t,e){let n=[],i=Array.from({length:e},(o,s)=>s+1),r=i.reduce((o,s)=>o+s,0);for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}let s=0,a=!0;for(let l=0;l<e;l++){let u=t[o-e+1+l];if(u===null){a=!1;break}s+=u*i[l]}n.push(a?le(s/r):null)}return n}function ue(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,r=i==="ema"?U:i==="wma"?we:B,o={};for(let s of n)o[`ma${s}`]=r(t,s);return t.map((s,a)=>{let l={};for(let u of n)l[`ma${u}`]=o[`ma${u}`][a];return l})}function $n(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ce(t,e={}){let{short:n=12,long:i=26,signal:r=9}=e,o=U(t,n),s=U(t,i),a=t.map((u,c)=>o[c]===null||s[c]===null?null:o[c]-s[c]),l=U(a,r);return t.map((u,c)=>({dif:a[c]!==null?$n(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?$n((a[c]-l[c])*2):null}))}function kt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function xr(t,e,n){let i=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){i.push(null);continue}let o=0,s=0;for(let a=r-e+1;a<=r;a++)t[a]!==null&&n[r]!==null&&(o+=Math.pow(t[a]-n[r],2),s++);i.push(s===e?Math.sqrt(o/e):null)}return i}function pe(t,e={}){let{period:n=20,stdDev:i=2}=e,r=B(t,n),o=xr(t,n,r);return t.map((s,a)=>{if(r[a]===null||o[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=r[a]+i*o[a],u=r[a]-i*o[a],c=r[a]!==0?kt((l-u)/r[a]*100):null;return{mid:r[a],upper:kt(l),lower:kt(u),bandwidth:c}})}function Nt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function de(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:r=3}=e,o=[],s=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){o.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,m=!0;for(let f=l-n+1;f<=l;f++){if(t[f].high===null||t[f].low===null){m=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[l].close;if(!m||d===null||u===c){o.push({k:null,d:null,j:null});continue}let g=(d-c)/(u-c)*100;s=(i-1)/i*s+1/i*g,a=(r-1)/r*a+1/r*s;let y=3*s-2*a;o.push({k:Nt(s),d:Nt(a),j:Nt(y)})}return o}function Lr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function me(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let o=1;o<t.length;o++)t[o]===null||t[o-1]===null?i.push(null):i.push(t[o]-t[o-1]);let r={};for(let o of n){let s=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<o){s.push(null),i[u]!==null&&(i[u]>0?a+=i[u]:l+=Math.abs(i[u]));continue}if(u===o)a=a/o,l=l/o;else{let c=i[u]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(o-1)+m)/o,l=(l*(o-1)+d)/o}if(l===0)s.push(100);else if(a===0)s.push(0);else{let c=a/l;s.push(Lr(100-100/(1+c)))}}r[`rsi${o}`]=s}return t.map((o,s)=>{let a={};for(let l of n)a[`rsi${l}`]=r[`rsi${l}`][s];return a})}function Kr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function fe(t,e={}){let{periods:n=[6,10]}=e,i={};for(let r of n){let o=[];for(let s=0;s<t.length;s++){if(s<r-1){o.push(null);continue}let a=-1/0,l=1/0,u=!0;for(let d=s-r+1;d<=s;d++){if(t[d].high===null||t[d].low===null){u=!1;break}a=Math.max(a,t[d].high),l=Math.min(l,t[d].low)}let c=t[s].close;if(!u||c===null||a===l){o.push(null);continue}let m=(a-c)/(a-l)*100;o.push(Kr(m))}i[`wr${r}`]=o}return t.map((r,o)=>{let s={};for(let a of n)s[`wr${a}`]=i[`wr${a}`][o];return s})}function Ur(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ge(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let r of n){let o=B(t,r),s=[];for(let a=0;a<t.length;a++)if(t[a]===null||o[a]===null||o[a]===0)s.push(null);else{let l=(t[a]-o[a])/o[a]*100;s.push(Ur(l))}i[`bias${r}`]=s}return t.map((r,o)=>{let s={};for(let a of n)s[`bias${a}`]=i[`bias${a}`][o];return s})}function Dr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function he(t,e={}){let{period:n=14}=e,i=[],r=t.map(o=>o.high===null||o.low===null||o.close===null?null:(o.high+o.low+o.close)/3);for(let o=0;o<t.length;o++){if(o<n-1){i.push({cci:null});continue}let s=0,a=0;for(let m=o-n+1;m<=o;m++)r[m]!==null&&(s+=r[m],a++);if(a!==n||r[o]===null){i.push({cci:null});continue}let l=s/n,u=0;for(let m=o-n+1;m<=o;m++)u+=Math.abs(r[m]-l);let c=u/n;if(c===0)i.push({cci:0});else{let m=(r[o]-l)/(.015*c);i.push({cci:Dr(m)})}}return i}function Bt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function j(t,e={}){let{period:n=14}=e,i=[],r=[];for(let s=0;s<t.length;s++){let{high:a,low:l,close:u}=t[s];if(a===null||l===null||u===null){r.push(null);continue}if(s===0)r.push(a-l);else{let c=t[s-1].close;if(c===null)r.push(a-l);else{let m=a-l,d=Math.abs(a-c),g=Math.abs(l-c);r.push(Math.max(m,d,g))}}}let o=null;for(let s=0;s<t.length;s++){if(s<n-1){i.push({tr:r[s]!==null?Bt(r[s]):null,atr:null});continue}if(s===n-1){let a=0,l=0;for(let u=0;u<n;u++)r[u]!==null&&(a+=r[u],l++);l===n&&(o=a/n)}else o!==null&&r[s]!==null&&(o=(o*(n-1)+r[s])/n);i.push({tr:r[s]!==null?Bt(r[s]):null,atr:o!==null?Bt(o):null})}return i}function ye(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let r=t[0].volume??0;i.push({obv:r,obvMa:null});for(let o=1;o<t.length;o++){let s=t[o],a=t[o-1];if(s.close===null||a.close===null||s.volume===null||s.volume===void 0){i.push({obv:null,obvMa:null});continue}s.close>a.close?r+=s.volume:s.close<a.close&&(r-=s.volume),i.push({obv:r,obvMa:null})}if(n&&n>0)for(let o=n-1;o<i.length;o++){let s=0,a=0;for(let l=o-n+1;l<=o;l++)i[l].obv!==null&&(s+=i[l].obv,a++);a===n&&(i[o].obvMa=s/n)}return i}function Re(t,e={}){let{period:n=12,signalPeriod:i}=e,r=[];for(let o=0;o<t.length;o++){if(o<n){r.push({roc:null,signal:null});continue}let s=t[o].close,a=t[o-n].close;if(s===null||a===null||a===0){r.push({roc:null,signal:null});continue}let l=(s-a)/a*100;r.push({roc:l,signal:null})}if(i&&i>0)for(let o=n+i-1;o<r.length;o++){let s=0,a=0;for(let l=o-i+1;l<=o;l++)r[l].roc!==null&&(s+=r[l].roc,a++);a===i&&(r[o].signal=s/i)}return r}function Ce(t,e={}){let{period:n=14,adxPeriod:i=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let o=[],s=[],a=[];for(let f=0;f<t.length;f++){if(f===0){o.push(0),s.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],O=t[f-1];if(C.high===null||C.low===null||C.close===null||O.high===null||O.low===null||O.close===null){o.push(0),s.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let E=C.high-C.low,_=Math.abs(C.high-O.close),z=Math.abs(C.low-O.close);a.push(Math.max(E,_,z));let D=C.high-O.high,Q=O.low-C.low;D>Q&&D>0?o.push(D):o.push(0),Q>D&&Q>0?s.push(Q):s.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,u=0,c=0,m=[];for(let f=1;f<t.length;f++){if(f<n){l+=a[f],u+=o[f],c+=s[f],m.push(0);continue}f===n?(l=l,u=u,c=c):(l=l-l/n+a[f],u=u-u/n+o[f],c=c-c/n+s[f]);let C=l>0?u/l*100:0,O=l>0?c/l*100:0;r[f].pdi=C,r[f].mdi=O;let E=C+O,_=E>0?Math.abs(C-O)/E*100:0;m.push(_)}let d=0,g=0,y=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=m[f-n+1]||0,g++;continue}if(f===n*2-1)d+=m[f-n+1]||0,y=d/i,r[f].adx=y;else{let C=m[f-n+1]||0;y=(y*(i-1)+C)/i,r[f].adx=y}}for(let f=n*2-1+i;f<t.length;f++){let C=r[f].adx,O=r[f-i]?.adx;C!==null&&O!==null&&(r[f].adxr=(C+O)/2)}return r}function Se(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:r=.2}=e,o=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,a=n,l=t[0].high??0,u=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(s=-1,l=c.low??0,u=c.high??0),o.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let g=t[d],y=t[d-1];if(g.high===null||g.low===null||y.high===null||y.low===null){o.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+a*(l-u);s===1?(f=Math.min(f,y.low,t[Math.max(0,d-2)]?.low??y.low),g.low<f?(s=-1,f=l,l=g.low,a=n):g.high>l&&(l=g.high,a=Math.min(a+i,r))):(f=Math.max(f,y.high,t[Math.max(0,d-2)]?.high??y.high),g.high>f?(s=1,f=l,l=g.high,a=n):g.low<l&&(l=g.low,a=Math.min(a+i,r))),u=f,o.push({sar:u,trend:s,ep:l,af:a})}return o}function Oe(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:r=2}=e,o=[],s=t.map(u=>u.close),a=U(s,n),l=j(t,{period:i});for(let u=0;u<t.length;u++){let c=a[u],m=l[u]?.atr;if(c===null||m===null){o.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*m,g=c-r*m,y=c>0?(d-g)/c*100:null;o.push({mid:c,upper:d,lower:g,width:y})}return o}function Te(t,e={}){if(t.length===0)return[];let n=t.map(E=>E.close),i=t.map(E=>({open:E.open,high:E.high,low:E.low,close:E.close,volume:E.volume})),r=e.ma?ue(n,typeof e.ma=="object"?e.ma:{}):null,o=e.macd?ce(n,typeof e.macd=="object"?e.macd:{}):null,s=e.boll?pe(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?de(i,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?me(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?fe(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?ge(n,typeof e.bias=="object"?e.bias:{}):null,m=e.cci?he(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?j(i,typeof e.atr=="object"?e.atr:{}):null,g=e.obv?ye(i,typeof e.obv=="object"?e.obv:{}):null,y=e.roc?Re(i,typeof e.roc=="object"?e.roc:{}):null,f=e.dmi?Ce(i,typeof e.dmi=="object"?e.dmi:{}):null,C=e.sar?Se(i,typeof e.sar=="object"?e.sar:{}):null,O=e.kc?Oe(i,typeof e.kc=="object"?e.kc:{}):null;return t.map((E,_)=>({...E,...r&&{ma:r[_]},...o&&{macd:o[_]},...s&&{boll:s[_]},...a&&{kdj:a[_]},...l&&{rsi:l[_]},...u&&{wr:u[_]},...c&&{bias:c[_]},...m&&{cci:m[_]},...d&&{atr:d[_]},...g&&{obv:g[_]},...y&&{roc:y[_]},...f&&{dmi:f[_]},...C&&{sar:C[_]},...O&&{kc:O[_]}}))}var Ee=class{constructor(e={}){this.client=new oe(e)}getFullQuotes(e){return b.getFullQuotes(this.client,e)}getSimpleQuotes(e){return b.getSimpleQuotes(this.client,e)}getHKQuotes(e){return b.getHKQuotes(this.client,e)}getUSQuotes(e){return b.getUSQuotes(this.client,e)}getFundQuotes(e){return b.getFundQuotes(this.client,e)}getFundFlow(e){return b.getFundFlow(this.client,e)}getPanelLargeOrder(e){return b.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return b.getTodayTimeline(this.client,e)}getIndustryList(){return T.getIndustryList(this.client)}getIndustrySpot(e){return T.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return T.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return T.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return T.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return T.getConceptList(this.client)}getConceptSpot(e){return T.getConceptSpot(this.client,e)}getConceptConstituents(e){return T.getConceptConstituents(this.client,e)}getConceptKline(e,n){return T.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return T.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return T.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return T.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return T.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return T.getUSHistoryKline(this.client,e,n)}search(e){return b.search(this.client,e)}getAShareCodeList(e){return b.getAShareCodeList(this.client,e)}getUSCodeList(e){return b.getUSCodeList(this.client,e)}getHKCodeList(){return b.getHKCodeList(this.client)}getFundCodeList(){return b.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return b.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,r=await this.getUSCodeList({simple:!0,market:n});return b.getAllUSQuotesByCodes(this.client,r,i)}getAllQuotesByCodes(e,n={}){return b.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return b.getTradingCalendar(this.client)}getDividendDetail(e){return T.getDividendDetail(this.client,e)}getFuturesKline(e,n){return T.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return T.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return T.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return T.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return T.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return T.getComexInventory(this.client,e,n)}getIndexOptionSpot(e,n){return A.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return A.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return T.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return A.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return A.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return A.getETFOptionMinute(e)}getETFOptionDailyKline(e){return A.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return A.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return A.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return A.getCommodityOptionKline(e)}getOptionLHB(e,n){return T.getOptionLHB(this.client,e,n)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let o=typeof e.ma=="object"?e.ma:{},s=o.periods??[5,10,20,30,60,120,250],a=o.type??"sma";n=Math.max(n,this.safeMax(s,20)),a==="ema"&&(i=!0)}if(e.macd){let o=typeof e.macd=="object"?e.macd:{},s=o.long??26,a=o.signal??9;n=Math.max(n,s*3+a),i=!0}if(e.boll){let o=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,o)}if(e.kdj){let o=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,o)}if(e.rsi){let o=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(o,14)+1)}if(e.wr){let o=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(o,10))}if(e.bias){let o=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(o,12))}if(e.cci){let o=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,o)}if(e.atr){let o=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,o)}if(e.obv){let o=typeof e.obv=="object"&&e.obv.maPeriod?e.obv.maPeriod:0;n=Math.max(n,Math.max(2,o))}if(e.roc){let o=typeof e.roc=="object"?e.roc:{},s=o.period??12,a=o.signalPeriod??0;n=Math.max(n,s+a)}if(e.dmi){let o=typeof e.dmi=="object"?e.dmi:{},s=o.period??14,a=o.adxPeriod??s;n=Math.max(n,s*2+a)}if(e.sar&&(n=Math.max(n,5)),e.kc){let o=typeof e.kc=="object"?e.kc:{},s=o.emaPeriod??20,a=o.atrPeriod??10;n=Math.max(n,Math.max(s*3,a)),i=!0}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let r=Math.ceil(n*i),o=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));o.setDate(o.getDate()-r);let s=o.getFullYear(),a=String(o.getMonth()+1).padStart(2,"0"),l=String(o.getDate()).padStart(2,"0");return`${s}${a}${l}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let r=this.normalizeDate(e),o=i.findIndex(a=>a>=r);o===-1&&(o=i.length-1);let s=Math.max(0,o-n);return this.toCompactDate(i[s])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:r,indicators:o={}}=n,s=n.market??this.detectMarket(e),a=this.calcRequiredLookback(o),l={A:1.5,HK:1.46,US:1.45},u;if(i)if(s==="A")try{let g=await b.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,a,g)??this.calcActualStartDate(i,a,l[s])}catch{u=this.calcActualStartDate(i,a,l[s])}else u=this.calcActualStartDate(i,a,l[s]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},m;switch(s){case"HK":m=await this.getHKHistoryKline(e,c);break;case"US":m=await this.getUSHistoryKline(e,c);break;default:m=await this.getHistoryKline(e,c)}if(i&&m.length<a)switch(s){case"HK":m=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=Te(m,o);if(i){let g=this.dateToTimestamp(i),y=r?this.dateToTimestamp(r):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=g&&C<=y})}return d}},Gn=Ee;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,extractJsonFromJsonp,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});
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});