stock-sdk 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -346,6 +346,8 @@ Stock SDK 配套 MCP Server([stock-sdk-mcp](https://www.npmjs.com/package/stoc
346
346
  |------|------|
347
347
  | `search` | 搜索股票代码/名称/拼音 |
348
348
 
349
+ 搜索结果可配合 `generateSearchExternalLinks(result)` 生成东方财富、雪球外链。
350
+
349
351
  ---
350
352
 
351
353
  ## 许可证
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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});
1
+ "use strict";var yt=Object.defineProperty;var ho=Object.getOwnPropertyDescriptor;var To=Object.getOwnPropertyNames;var yo=Object.prototype.hasOwnProperty;var Ze=(t,e)=>{for(var r in e)yt(t,r,{get:e[r],enumerable:!0})},So=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of To(e))!yo.call(t,o)&&o!==r&&yt(t,o,{get:()=>e[o],enumerable:!(n=ho(e,o))||n.enumerable});return t};var Ro=t=>So(yt({},"__esModule",{value:!0}),t);var Li={};Ze(Li,{HttpError:()=>v,INDICATOR_REGISTRY:()=>ee,SdkError:()=>N,StockSDK:()=>Xe,addIndicators:()=>Qe,asyncPool:()=>W,buildIndicatorContext:()=>qe,calcATR:()=>J,calcBIAS:()=>xe,calcBOLL:()=>Me,calcCCI:()=>ve,calcDMI:()=>Be,calcEMA:()=>q,calcKC:()=>He,calcKDJ:()=>ke,calcMA:()=>be,calcMACD:()=>Le,calcOBV:()=>Ue,calcROC:()=>we,calcRSI:()=>Ne,calcSAR:()=>Ke,calcSMA:()=>G,calcWMA:()=>gt,calcWR:()=>Fe,chunkArray:()=>V,decodeGBK:()=>ie,default:()=>mo,estimateIndicatorLookback:()=>$e,extractJsonFromJsonp:()=>ut,generateSearchExternalLinks:()=>go,getEnabledIndicatorKeys:()=>oe,getSdkErrorCode:()=>Q,jsonpRequest:()=>b,parseResponse:()=>se,safeNumber:()=>h,safeNumberOrNull:()=>E});module.exports=Ro(Li);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",kt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Nt="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",zt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",Gt="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 Eo(){return typeof window<"u"&&typeof window.document<"u"}function Cr(){if(Eo())return;let t=Er[tr];return tr=(tr+1)%Er.length,t}var N=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 N{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 N{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 Co(t,e){return he(t,{provider:e.provider,url:e.url})}function Q(t){if(t instanceof N||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 N?Co(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 N({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var re=class extends N{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 Oo=3e4,_o=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 Ao(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Or:t.includes("push2.eastmoney.com")?_r:[t]}function Io(t){return Array.from(new Set(t))}var st=class{constructor(e=Oo,r=_o){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=Ao(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 Io([...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 Po(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 Do(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:Po(t.retry),headers:Do(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 bo=new Set(["daily","weekly","monthly"]),Lo=new Set(["1","5","15","30","60"]),Mo=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(!bo.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function Se(t){if(!Lo.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function j(t){if(!Mo.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 z(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 ko=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 Fo(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 xo(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 ko?Fo(t,e):xo(t,e)}var A={};Ze(A,{getAShareCodeList:()=>xr,getAllHKQuotesByCodes:()=>Br,getAllQuotesByCodes:()=>wr,getAllUSQuotesByCodes:()=>Kr,getFullQuotes:()=>lt,getFundCodeList:()=>Hr,getFundFlow:()=>Lr,getFundQuotes:()=>kr,getHKCodeList:()=>Ur,getHKQuotes:()=>ct,getPanelLargeOrder:()=>Mr,getSimpleQuotes:()=>br,getTodayTimeline:()=>Nr,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 kr(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 Nr(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,k=D>0?P/D:0;return{time:C,price:parseFloat(g[1])||0,volume:D,amount:P,avgPrice:Math.round(k*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 vo(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=>vo(s,n))),r?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var Uo={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=Uo[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 wo=X("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function qr(t){return(await wo.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 Bo(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function Ko(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 Ho(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(r=>{let n=r.split("~"),o=n[0]||"",i=n[1]||"",s=Bo(n[2]||""),u=n[4]||"";return{code:o+i,name:s,market:o,type:u,category:Ko(u)}})}function qo(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 $o(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 Qo(){return typeof window<"u"&&typeof document<"u"}async function Qr(t,e){if(!e||!e.trim())return[];let r;return Qo()?r=await qo(e):r=await $o(t,e),Ho(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:()=>zn,getDragonTigerDetail:()=>$n,getDragonTigerInstitution:()=>jn,getDragonTigerStockSeatDetail:()=>Gn,getDragonTigerStockStats:()=>Qn,getFundFlowRank:()=>bn,getFuturesHistoryKline:()=>gn,getFuturesInventory:()=>En,getFuturesInventorySymbols:()=>Rn,getFuturesMarketCode:()=>gr,getGlobalFuturesKline:()=>hn,getGlobalFuturesSpot:()=>fn,getHKHistoryKline:()=>Gr,getHistoryKline:()=>jr,getIndividualFundFlow:()=>Pn,getIndustryConstituents:()=>nn,getIndustryKline:()=>on,getIndustryList:()=>tn,getIndustryMinuteKline:()=>sn,getIndustrySpot:()=>rn,getMarginAccountInfo:()=>Jn,getMarginTargetList:()=>eo,getMarketFundFlow:()=>Dn,getMinuteKline:()=>zr,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:z(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 zr(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,k,Y,$]=g.split(",");return{time:R,open:m(C),close:m(I),high:m(P),low:m(D),volume:m(k),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:z(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:z(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 jo=dt({url:It,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function Gr(t,e,r={}){return jo(t,e,r)}var zo=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 zo(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:z(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,k]=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(k)}})}}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:kt,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 Yo={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Nt,spotUrl:Ft,consUrl:xt,klineUrl:vt,trendsUrl:Ut,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},Ee=mt(Yo);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 k=`${wt}?${D.toString()}`,$=(await t.get(k,{responseType:"json"}))?.result;if(!$||!Array.isArray($.data))break;R===c&&(C=$.pages??1,I=$.count??$.data.length);let fo=$.data.map((ht,Tt)=>r(ht,g.length+Tt));if(g.push(...fo),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 Vo(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=>Vo(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 Wo(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=>({...Wo(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(Xo);n.push(...c),o++}while(n.length<i);return n}function Xo(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 Zo(t){let e=B(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}function Jo(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=Jo(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=>({...Zo(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=`${Gt}?${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 ei(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:ei(String(l.TRADE_TYPE??""))}))}var ti={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=ti[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 ri(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"}},ni={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},oi="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(ri)}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:oi,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=ni[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 ii={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},si={shanghai:"001",shenzhen:"003"};function kn(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=>kn(p,Nn(c)))}let s=i.s2n??[],u=i.s2nDate??"";return s.map(l=>kn(l,Nn(u)))}function Nn(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=ii[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="${si[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 ai={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"}},ui={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"},li={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 ci(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function pi(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:ci(t.zttj),amplitude:a(t.zf),speed:a(t.zs)}}function di(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function mi(){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=ai[e];if(!n)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=di(r)??mi(),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(pi)}async function Kn(t,e="large_buy"){let r=ui[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:li[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 zn(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 Gn(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 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:a(t[7]),symbol:t[8]??""}}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: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(gi),puts:i.map(fi)}}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=`${zt}?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 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:a(t[7]),symbol:t[8]??""}}function Ti(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(hi),puts:s.map(Ti)}}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 G(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:G,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 yi(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=G(t,r),i=yi(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 ke(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 Si(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ne(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(Si(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 Ri(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(Ri(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 Ei(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=G(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(Ei(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 Ci(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:Ci(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 k=R.high-C.high,Y=C.low-R.low;k>Y&&k>0?i.push(k):i.push(0),Y>k&&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)=>ke(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)=>Ne(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 ze=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 Ge=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 ze(this.client),this.northboundService=new Ge(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;var Oi={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},_i={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},Ai={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function Ii(t){let e=t.code.trim(),r=t.market.trim().toLowerCase(),n=Oi[t.market]??r;return n==="sh"||n==="sz"?{code:e.replace(/^(sh|sz)/i,""),market:n}:n==="hk"?{code:e.replace(/^hk/i,"").padStart(5,"0"),market:n}:n==="us"?{code:e.replace(/^us/i,"").replace(/^\d{3}\./,"").toUpperCase(),market:n}:n==="global"?{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:n}:/^sh\d{6}$/i.test(e)?{code:e.slice(2),market:"sh"}:/^sz\d{6}$/i.test(e)?{code:e.slice(2),market:"sz"}:/^hk\d{5}$/i.test(e)?{code:e.slice(2),market:"hk"}:/^us[A-Z.]+$/i.test(e)?{code:e.slice(2).toUpperCase(),market:"us"}:{code:e,market:"unknown"}}function Pi(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Di(t){let{code:e,market:r}=t;return(r==="sh"||r==="sz")&&Pi(e,r)?`https://quote.eastmoney.com/zs${e}.html`:r==="sh"||r==="sz"?`https://quote.eastmoney.com/${r}${e}.html`:r==="hk"?`https://quote.eastmoney.com/hk/${e}.html`:r==="us"?`https://quote.eastmoney.com/us/${e}.html`:r==="global"?`https://quote.eastmoney.com/gb/zs${Ai[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function bi(t){let{code:e,market:r}=t;return r==="sh"||r==="sz"?`https://xueqiu.com/S/${r.toUpperCase()}${e}`:r==="hk"?`https://xueqiu.com/S/${e}`:r==="us"?`https://xueqiu.com/S/${e}`:r==="global"?`https://xueqiu.com/S/${_i[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function go(t){let e=Ii(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Di(e)},{name:"\u96EA\u7403",url:bi(e)}]}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,generateSearchExternalLinks,getEnabledIndicatorKeys,getSdkErrorCode,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});
package/dist/index.d.cts CHANGED
@@ -989,6 +989,15 @@ interface SearchResult {
989
989
  */
990
990
  category?: SearchResultType;
991
991
  }
992
+ /**
993
+ * 外部财经站点链接
994
+ */
995
+ interface ExternalLink {
996
+ /** 站点名称 */
997
+ name: string;
998
+ /** 可直接打开的 URL */
999
+ url: string;
1000
+ }
992
1001
  /**
993
1002
  * 分红派送详情
994
1003
  */
@@ -3004,4 +3013,11 @@ declare class StockSDK {
3004
3013
  getMarginTargetList(date?: string): Promise<MarginTargetItem[]>;
3005
3014
  }
3006
3015
 
3007
- export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type BlockTradeDailyStatItem, type BlockTradeDateOptions, type BlockTradeDetailItem, type BlockTradeMarketStatItem, type BoardChangeItem, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DatacenterQuery, type DatacenterResult, type DividendDetail, type DragonTigerBranchItem, type DragonTigerDateOptions, type DragonTigerDetailItem, type DragonTigerInstitutionItem, type DragonTigerPeriod, type DragonTigerSeatItem, type DragonTigerStockStatItem, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type FullQuote, type FundFlow, type FundFlowOptions, type FundFlowRankItem, type FundFlowRankOptions, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, INDICATOR_REGISTRY, type IndexOptionProduct, type IndicatorKey, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarginAccountItem, type MarginTargetItem, type MarketFundFlow, type MarketType, type MinuteKline, type MinuteTimeline, type NorthboundDirection, type NorthboundFlowSummary, type NorthboundHistoryItem, type NorthboundHistoryOptions, type NorthboundHoldingRankItem, type NorthboundHoldingRankOptions, type NorthboundIndividualItem, type NorthboundMarket, type NorthboundMinuteItem, type NorthboundRankPeriod, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ProviderName, type ProviderRequestPolicy, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RequestError, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, SdkError, type SearchResult, type SearchResultType, type SectorFundFlowItem, type SimpleQuote, type StockChangeItem, type StockChangeType, type StockFundFlowDaily, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, type ZTPoolItem, type ZTPoolType, addIndicators, asyncPool, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, estimateIndicatorLookback, extractJsonFromJsonp, getEnabledIndicatorKeys, getSdkErrorCode, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
3016
+ /**
3017
+ * 根据搜索结果生成外部财经站点链接。
3018
+ * @param result 搜索结果
3019
+ * @returns 东方财富、雪球链接列表;未知市场退回站内搜索链接
3020
+ */
3021
+ declare function generateSearchExternalLinks(result: SearchResult): ExternalLink[];
3022
+
3023
+ export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type BlockTradeDailyStatItem, type BlockTradeDateOptions, type BlockTradeDetailItem, type BlockTradeMarketStatItem, type BoardChangeItem, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DatacenterQuery, type DatacenterResult, type DividendDetail, type DragonTigerBranchItem, type DragonTigerDateOptions, type DragonTigerDetailItem, type DragonTigerInstitutionItem, type DragonTigerPeriod, type DragonTigerSeatItem, type DragonTigerStockStatItem, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type ExternalLink, type FullQuote, type FundFlow, type FundFlowOptions, type FundFlowRankItem, type FundFlowRankOptions, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, INDICATOR_REGISTRY, type IndexOptionProduct, type IndicatorKey, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarginAccountItem, type MarginTargetItem, type MarketFundFlow, type MarketType, type MinuteKline, type MinuteTimeline, type NorthboundDirection, type NorthboundFlowSummary, type NorthboundHistoryItem, type NorthboundHistoryOptions, type NorthboundHoldingRankItem, type NorthboundHoldingRankOptions, type NorthboundIndividualItem, type NorthboundMarket, type NorthboundMinuteItem, type NorthboundRankPeriod, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ProviderName, type ProviderRequestPolicy, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RequestError, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, SdkError, type SearchResult, type SearchResultType, type SectorFundFlowItem, type SimpleQuote, type StockChangeItem, type StockChangeType, type StockFundFlowDaily, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, type ZTPoolItem, type ZTPoolType, addIndicators, asyncPool, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, estimateIndicatorLookback, extractJsonFromJsonp, generateSearchExternalLinks, getEnabledIndicatorKeys, getSdkErrorCode, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
package/dist/index.d.ts CHANGED
@@ -989,6 +989,15 @@ interface SearchResult {
989
989
  */
990
990
  category?: SearchResultType;
991
991
  }
992
+ /**
993
+ * 外部财经站点链接
994
+ */
995
+ interface ExternalLink {
996
+ /** 站点名称 */
997
+ name: string;
998
+ /** 可直接打开的 URL */
999
+ url: string;
1000
+ }
992
1001
  /**
993
1002
  * 分红派送详情
994
1003
  */
@@ -3004,4 +3013,11 @@ declare class StockSDK {
3004
3013
  getMarginTargetList(date?: string): Promise<MarginTargetItem[]>;
3005
3014
  }
3006
3015
 
3007
- export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type BlockTradeDailyStatItem, type BlockTradeDateOptions, type BlockTradeDetailItem, type BlockTradeMarketStatItem, type BoardChangeItem, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DatacenterQuery, type DatacenterResult, type DividendDetail, type DragonTigerBranchItem, type DragonTigerDateOptions, type DragonTigerDetailItem, type DragonTigerInstitutionItem, type DragonTigerPeriod, type DragonTigerSeatItem, type DragonTigerStockStatItem, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type FullQuote, type FundFlow, type FundFlowOptions, type FundFlowRankItem, type FundFlowRankOptions, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, INDICATOR_REGISTRY, type IndexOptionProduct, type IndicatorKey, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarginAccountItem, type MarginTargetItem, type MarketFundFlow, type MarketType, type MinuteKline, type MinuteTimeline, type NorthboundDirection, type NorthboundFlowSummary, type NorthboundHistoryItem, type NorthboundHistoryOptions, type NorthboundHoldingRankItem, type NorthboundHoldingRankOptions, type NorthboundIndividualItem, type NorthboundMarket, type NorthboundMinuteItem, type NorthboundRankPeriod, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ProviderName, type ProviderRequestPolicy, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RequestError, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, SdkError, type SearchResult, type SearchResultType, type SectorFundFlowItem, type SimpleQuote, type StockChangeItem, type StockChangeType, type StockFundFlowDaily, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, type ZTPoolItem, type ZTPoolType, addIndicators, asyncPool, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, estimateIndicatorLookback, extractJsonFromJsonp, getEnabledIndicatorKeys, getSdkErrorCode, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
3016
+ /**
3017
+ * 根据搜索结果生成外部财经站点链接。
3018
+ * @param result 搜索结果
3019
+ * @returns 东方财富、雪球链接列表;未知市场退回站内搜索链接
3020
+ */
3021
+ declare function generateSearchExternalLinks(result: SearchResult): ExternalLink[];
3022
+
3023
+ export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type BlockTradeDailyStatItem, type BlockTradeDateOptions, type BlockTradeDetailItem, type BlockTradeMarketStatItem, type BoardChangeItem, type CCIOptions, type CFFEXOptionQuote, type CFFEXOptionQuotesOptions, type ComexInventory, type ComexInventoryOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DatacenterQuery, type DatacenterResult, type DividendDetail, type DragonTigerBranchItem, type DragonTigerDateOptions, type DragonTigerDetailItem, type DragonTigerInstitutionItem, type DragonTigerPeriod, type DragonTigerSeatItem, type DragonTigerStockStatItem, type ETFOptionCate, type ETFOptionExpireDay, type ETFOptionMonth, type ExternalLink, type FullQuote, type FundFlow, type FundFlowOptions, type FundFlowRankItem, type FundFlowRankOptions, type FundQuote, type FuturesExchange, type FuturesInventory, type FuturesInventoryOptions, type FuturesInventorySymbol, type FuturesKline, type FuturesKlineOptions, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type GlobalFuturesKlineOptions, type GlobalFuturesQuote, type GlobalFuturesSpotOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, INDICATOR_REGISTRY, type IndexOptionProduct, type IndicatorKey, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type JsonpOptions, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarginAccountItem, type MarginTargetItem, type MarketFundFlow, type MarketType, type MinuteKline, type MinuteTimeline, type NorthboundDirection, type NorthboundFlowSummary, type NorthboundHistoryItem, type NorthboundHistoryOptions, type NorthboundHoldingRankItem, type NorthboundHoldingRankOptions, type NorthboundIndividualItem, type NorthboundMarket, type NorthboundMinuteItem, type NorthboundRankPeriod, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type OptionKline, type OptionLHBItem, type OptionMinute, type OptionTQuote, type OptionTQuoteResult, type PanelLargeOrder, type ProviderName, type ProviderRequestPolicy, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RequestError, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, SdkError, type SearchResult, type SearchResultType, type SectorFundFlowItem, type SimpleQuote, type StockChangeItem, type StockChangeType, type StockFundFlowDaily, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, type ZTPoolItem, type ZTPoolType, addIndicators, asyncPool, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, estimateIndicatorLookback, extractJsonFromJsonp, generateSearchExternalLinks, getEnabledIndicatorKeys, getSdkErrorCode, jsonpRequest, parseResponse, safeNumber, safeNumberOrNull };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var mo=Object.defineProperty;var ft=(t,e)=>{for(var r in e)mo(t,r,{get:e[r],enumerable:!0})};function ke(t){return new TextDecoder("gbk").decode(t)}function Fe(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 C(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 ht="https://qt.gtimg.cn",Tt="https://web.ifzq.gtimg.cn/appstock/app/minute/query",yt="https://assets.linkdiary.cn/shares/zh_a_list.json",St="https://assets.linkdiary.cn/shares/us_list.json",Rt="https://assets.linkdiary.cn/shares/hk_list.json",Et="https://assets.linkdiary.cn/shares/fund_list",Sr="https://assets.linkdiary.cn/shares/trade-data-list.txt";var xe="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ct="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ot="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",_t="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",At="https://17.push2.eastmoney.com/api/qt/clist/get",It="https://91.push2.eastmoney.com/api/qt/stock/get",Pt="https://29.push2.eastmoney.com/api/qt/clist/get",Dt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",bt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Lt="https://79.push2.eastmoney.com/api/qt/clist/get",Mt="https://91.push2.eastmoney.com/api/qt/stock/get",Nt="https://29.push2.eastmoney.com/api/qt/clist/get",kt="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Ft="https://push2his.eastmoney.com/api/qt/stock/trends2/get",xt="https://datacenter-web.eastmoney.com/api/data/v1/get",oe="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",vt="https://push2.eastmoney.com/api/qt/clist/get",Ut="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",ie="https://push2ex.eastmoney.com",L="7eea3edcaed734bea9cbfc24409ed989",F="b2884a393a59ad64002292a3e90d46a5",se="https://push2his.eastmoney.com/api/qt/stock/kline/get",wt="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",ae="58b2fa8f54638b60b87d69b31969089c",Bt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},X={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},ve={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},ue="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",le="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",Kt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",Ue="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",Ht="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",qt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",$t="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",Qt="https://futsseapi.eastmoney.com/list/option/221",jt="https://datacenter-web.eastmoney.com/api/data/get";var we={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"}},Gt=3e4,ce=500,pe=500,de=7,zt=3,Yt=1e3,Vt=3e4,Wt=2,Xt=[408,429,500,502,503,504];var Be=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 Rr=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Zt=0;function go(){return typeof window<"u"&&typeof window.document<"u"}function Er(){if(go())return;let t=Rr[Zt];return Zt=(Zt+1)%Rr.length,t}var x=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)}},K=class extends x{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 ge=class extends x{constructor(e,r,n){super({code:"NOT_FOUND",message:e,provider:r,url:n}),this.name="NotFoundError"}};function me(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 fo(t,e){return me(t,{provider:e.provider,url:e.url})}function z(t){if(t instanceof x||t instanceof K)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 Ke(t,e={}){return t instanceof x?fo(t,e):t instanceof DOMException&&t.name==="AbortError"?me(t,{sdkCode:"TIMEOUT",provider:e.provider,url:e.url,details:e.timeout?{timeout:e.timeout}:void 0}):t instanceof TypeError?me(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):t instanceof Error?me(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):new x({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var Z=class extends x{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},He=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let r=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(r,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new Z;try{let r=await e();return this.recordSuccess(),r}catch(r){throw this.recordFailure(),r}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var ho=3e4,To=1,Cr=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],Or=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function yo(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Cr:t.includes("push2.eastmoney.com")?Or:[t]}function So(t){return Array.from(new Set(t))}var qe=class{constructor(e=ho,r=To){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=yo(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 So([...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=z(r),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let r=z(e);return r==="NETWORK_ERROR"||r==="TIMEOUT"?!0:e instanceof K?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([...Cr,...Or]);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 Ro(t){return{maxRetries:t?.maxRetries??zt,baseDelay:t?.baseDelay??Yt,maxDelay:t?.maxDelay??Vt,backoffMultiplier:t?.backoffMultiplier??Wt,retryableStatusCodes:t?.retryableStatusCodes??Xt,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function Eo(t,e){let r={...t??{}};return e&&(Object.keys(r).some(o=>o.toLowerCase()==="user-agent")||(r["User-Agent"]=e)),r}function _r(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 Jt(t={}){return{timeout:t.timeout??Gt,retry:Ro(t.retry),headers:Eo(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function Ar(t,e){if(e)return e;try{let r=new URL(t).hostname;if(r.includes("eastmoney.com"))return"eastmoney";if(r.includes("gtimg.cn"))return"tencent";if(r.includes("sina.com.cn"))return"sina";if(r.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}var fe=class{constructor(e={}){this.baseUrl=e.baseUrl??ht;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=Jt(r),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new qe;for(let[n,o]of Object.entries(e.providerPolicies??{})){let i=_r(r,o);this.providerPolicies[n]=Jt(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 Be(n.rateLimit):null,circuitBreaker:n.circuitBreaker?new He(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=z(e);return o==="TIMEOUT"?n.retryOnTimeout:o==="NETWORK_ERROR"?n.retryOnNetworkError:e instanceof K?n.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,r,n,o=0){try{return await e()}catch(i){let s=Ke(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=Er();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 K(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=Ar(e,r.provider),o=this.getProviderState(n);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new Z("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=Ke(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 Z("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=ke(n);return Fe(o)}};var Co=new Set(["daily","weekly","monthly"]),Oo=new Set(["1","5","15","30","60"]),_o=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 v(t){if(!Co.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function he(t){if(!Oo.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function Q(t){if(!_o.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function J(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 ee(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 te(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function U(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function j(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var $e=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}},Ir=new Map;function Y(t,e){let r=Ir.get(t);if(r)return r;let n=new $e(e);return Ir.set(t,n),n}var Ao=typeof document<"u"&&typeof window<"u",Io=0;function Pr(){return`__stock_sdk_jsonp_${Date.now()}_${Io++}`}function er(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 Po(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let u=Pr(),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 Do(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e,i=Pr(),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 er(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 M(t,e={}){return Ao?Po(t,e):Do(t,e)}var A={};ft(A,{getAShareCodeList:()=>Fr,getAllHKQuotesByCodes:()=>wr,getAllQuotesByCodes:()=>Ur,getAllUSQuotesByCodes:()=>Br,getFullQuotes:()=>Qe,getFundCodeList:()=>Kr,getFundFlow:()=>br,getFundQuotes:()=>Mr,getHKCodeList:()=>vr,getHKQuotes:()=>je,getPanelLargeOrder:()=>Lr,getSimpleQuotes:()=>Dr,getTodayTimeline:()=>Nr,getTradingCalendar:()=>Hr,getUSCodeList:()=>xr,getUSQuotes:()=>Ge,parseFullQuote:()=>tr,parseFundFlow:()=>nr,parseFundQuote:()=>ar,parseHKQuote:()=>ir,parsePanelLargeOrder:()=>or,parseSimpleQuote:()=>rr,parseUSQuote:()=>sr,search:()=>$r});function tr(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:C(t[38]),pe:C(t[39]),amplitude:C(t[43]),circulatingMarketCap:C(t[44]),totalMarketCap:C(t[45]),pb:C(t[46]),limitUp:C(t[47]),limitDown:C(t[48]),volumeRatio:C(t[49]),avgPrice:C(t[51]),peStatic:C(t[52]),peDynamic:C(t[53]),high52w:C(t[67]),low52w:C(t[68]),circulatingShares:C(t[72]),totalShares:C(t[73]),raw:t}}function rr(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:C(t[9]),marketType:t[10]??"",raw:t}}function nr(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 or(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function ir(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:C(t[40]),circulatingMarketCap:C(t[44]),totalMarketCap:C(t[45]),currency:t[t.length-3]??"",raw:t}}function sr(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:C(t[38]),pe:C(t[39]),amplitude:C(t[43]),totalMarketCap:C(t[45]),pb:C(t[47]),high52w:C(t[48]),low52w:C(t[49]),raw:t}}function ar(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 Qe(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=>tr(n.fields))}async function Dr(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=>rr(o.fields))}async function br(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=>nr(o.fields))}async function Lr(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=>or(o.fields))}async function je(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=>ir(o.fields))}async function Ge(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=>sr(o.fields))}async function Mr(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=>ar(o.fields))}async function Nr(t,e){let r=t.getTimeout(),n=new AbortController,o=setTimeout(()=>n.abort(),r);try{let i=await fetch(`${Tt}?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,E=parseFloat(S[3])||0;R>0&&g>0&&E/R>g*50&&(f=!0)}let y=l.map(S=>{let g=S.split(" "),R=g[0],E=`${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:E,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 kr=Y("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function ur(t,e,r){return kr.getOrFetch(e,async()=>(await t.get(r,{responseType:"json"}))?.list||[])}function bo(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 Fr(t,e){let r=!1,n;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,n=e.market);let i=await ur(t,"a-share:full",yt);return n&&(i=i.filter(s=>bo(s,n))),r?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var Lo={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};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 ur(t,"us:full",St)).slice();if(n){let s=Lo[n];i=i.filter(u=>u.startsWith(s))}return r?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function vr(t){return(await ur(t,"hk:full",Rt)).slice()}async function Ur(t,e,r={}){let{batchSize:n=ce,concurrency:o=de,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,pe),u=J(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await Qe(t,f);return c++,i&&i(c,l),y});return(await ee(p,o,!0)).flat()}async function wr(t,e,r={}){let{batchSize:n=ce,concurrency:o=de,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,pe),u=J(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await je(t,f);return c++,i&&i(c,l),y});return(await ee(p,o,!0)).flat()}async function Br(t,e,r={}){let{batchSize:n=ce,concurrency:o=de,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,pe),u=J(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await Ge(t,f);return c++,i&&i(c,l),y});return(await ee(p,o,!0)).flat()}async function Kr(t){return(await kr.getOrFetch("fund:full",async()=>(await t.get(Et,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var Mo=Y("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function Hr(t){return(await Mo.getOrFetch("a-share",async()=>{let r=await t.get(Sr);return!r||r.trim()===""?[]:r.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0)})).slice()}var qr="https://smartbox.gtimg.cn/s3/";function No(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function ko(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 Fo(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(r=>{let n=r.split("~"),o=n[0]||"",i=n[1]||"",s=No(n[2]||""),u=n[4]||"";return{code:o+i,name:s,market:o,type:u,category:ko(u)}})}function xo(t){return new Promise((e,r)=>{let n=`${qr}?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 vo(t,e){let r=`${qr}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(r)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function Uo(){return typeof window<"u"&&typeof document<"u"}async function $r(t,e){if(!e||!e.trim())return[];let r;return Uo()?r=await xo(e):r=await vo(t,e),Fo(r)}var T={};ft(T,{extractVariety:()=>pr,fetchDatacenter:()=>cr,fetchDatacenterList:()=>O,getBlockTradeDailyStat:()=>Xn,getBlockTradeDetail:()=>Wn,getBlockTradeMarketStat:()=>Vn,getBoardChanges:()=>Kn,getCFFEXOptionQuotes:()=>hn,getComexInventory:()=>En,getConceptConstituents:()=>un,getConceptKline:()=>ln,getConceptList:()=>sn,getConceptMinuteKline:()=>cn,getConceptSpot:()=>an,getDividendDetail:()=>pn,getDragonTigerBranchRank:()=>jn,getDragonTigerDetail:()=>qn,getDragonTigerInstitution:()=>Qn,getDragonTigerStockSeatDetail:()=>Gn,getDragonTigerStockStats:()=>$n,getFundFlowRank:()=>Dn,getFuturesHistoryKline:()=>mn,getFuturesInventory:()=>Rn,getFuturesInventorySymbols:()=>Sn,getFuturesMarketCode:()=>dr,getGlobalFuturesKline:()=>fn,getGlobalFuturesSpot:()=>gn,getHKHistoryKline:()=>Gr,getHistoryKline:()=>Qr,getIndividualFundFlow:()=>In,getIndustryConstituents:()=>rn,getIndustryKline:()=>nn,getIndustryList:()=>en,getIndustryMinuteKline:()=>on,getIndustrySpot:()=>tn,getMarginAccountInfo:()=>Zn,getMarginTargetList:()=>Jn,getMarketFundFlow:()=>Pn,getMinuteKline:()=>jr,getNorthboundFlowSummary:()=>Fn,getNorthboundHistory:()=>vn,getNorthboundHoldingRank:()=>xn,getNorthboundIndividual:()=>Un,getNorthboundMinute:()=>kn,getOptionLHB:()=>Tn,getSectorFundFlowHistory:()=>Ln,getSectorFundFlowRank:()=>bn,getStockChanges:()=>Bn,getUSHistoryKline:()=>zr,getZTPool:()=>wn});async function lr(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 w(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 B(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 Qr(t,e,r={}){let{period:n="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=r;v(n),Q(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${te(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:L,klt:U(n),fqt:j(o),secid:l,beg:i,end:s}),p=xe,{klines:d}=await B(t,p,c);return d.length===0?[]:d.map(f=>({...w(f),code:u}))}async function jr(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;he(n),Q(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${te(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:L,ndays:"5",iscr:"0",secid:l}),p=`${Ct}?${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,E,I,P,D,N,G,$]=g.split(",");return{time:R,open:m(E),close:m(I),high:m(P),low:m(D),volume:m(N),amount:m(G),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:L,klt:n,fqt:j(o||""),secid:l,beg:"0",end:"20500000"}),p=xe,{klines:d}=await B(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=w(S);return{...g,time:g.date}}).filter(S=>S.time>=f&&S.time<=y)}}function ze(t){return async function(r,n,o={}){let{period:i="daily",adjust:s="qfq",startDate:u="19700101",endDate:l="20500101"}=o;v(i),Q(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:L,klt:U(i),fqt:j(s),secid:c.secid,beg:u,end:l,lmt:"1000000"}),{klines:d,name:f,code:y}=await B(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=>({...w(g),code:S.code,name:S.name}))}}var wo=ze({url:Ot,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function Gr(t,e,r={}){return wo(t,e,r)}var Bo=ze({url:_t,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,r)=>({code:r.code||e.fallbackCode,name:r.name||""})});async function zr(t,e,r={}){return Bo(t,e,r)}function Yr(t){let e=Y(`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 ge(`${t.errorPrefix}: ${n}`,"eastmoney");return s}}}async function Vr(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 lr(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 Wr(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 Xr(t,e,r){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return lr(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 Zr(t,e,r,n={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:u="20500101"}=n;v(o),Q(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:U(o),fqt:j(i),beg:s,end:u,smplmt:"10000",lmt:"1000000"}),{klines:c}=await B(t,r,l);return c.length===0?[]:c.map(p=>w(p))}async function Jr(t,e,r,n,o={}){let{period:i="5"}=o;if(he(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,E,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(E),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,E,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(E),amplitude:m(I),turnoverRate:m(N)}})}}function Ye(t){let e=Yr(t);async function r(o){return Vr(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 Wr(o,s,t.spotUrl)},async getConstituents(o,i){let s=await n(o,i);return Xr(o,s,t.consUrl)},async getKline(o,i,s={}){let u=await n(o,i);return Zr(o,u,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let u=await n(o,i);return Jr(o,u,t.klineUrl,t.trendsUrl,s)}}}var Ko={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:At,spotUrl:It,consUrl:Pt,klineUrl:Dt,trendsUrl:bt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},Te=Ye(Ko);async function en(t){return Te.getList(t)}async function tn(t,e){return Te.getSpot(t,e)}async function rn(t,e){return Te.getConstituents(t,e)}async function nn(t,e,r={}){return Te.getKline(t,e,r)}async function on(t,e,r={}){return Te.getMinuteKline(t,e,r)}var Ho={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Lt,spotUrl:Mt,consUrl:Nt,klineUrl:kt,trendsUrl:Ft,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ye=Ye(Ho);async function sn(t){return ye.getList(t)}async function an(t,e){return ye.getSpot(t,e)}async function un(t,e){return ye.getConstituents(t,e)}async function ln(t,e,r={}){return ye.getKline(t,e,r)}async function cn(t,e,r={}){return ye.getMinuteKline(t,e,r)}async function cr(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,E=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[mt,gt]of Object.entries(S))D.set(mt,gt);let N=`${xt}?${D.toString()}`,$=(await t.get(N,{responseType:"json"}))?.result;if(!$||!Array.isArray($.data))break;R===c&&(E=$.pages??1,I=$.count??$.data.length);let po=$.data.map((mt,gt)=>r(mt,g.length+gt));if(g.push(...po),R++,P++,!p)break}while(R<=E&&P<d);return p&&P>=d&&R<=E&&console.warn(`[stock-sdk] fetchDatacenter("${n}") truncated at maxPages=${d} (server reports ${E} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:g,total:I,pages:E}}async function O(t,e,r){return(await cr(t,e,r)).data}function b(t){if(t==null)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}function V(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function qo(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:V(t.REPORT_DATE),planNoticeDate:V(t.PLAN_NOTICE_DATE),disclosureDate:V(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:V(t.EQUITY_RECORD_DATE),exDividendDate:V(t.EX_DIVIDEND_DATE),payDate:V(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:V(t.NOTICE_DATE)}}async function pn(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=>qo(n))}function pr(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 dn(t){return X[t]??X[t.toLowerCase()]??X[t.toUpperCase()]}function dr(t){let e=dn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=dn(t.slice(0,-1))),!e){let n=Object.keys(X).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${n}`)}let r=Bt[e];if(r===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return r}function $o(t){let e=w(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}async function mn(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;v(n);let s=pr(e),l=`${dr(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:L,klt:U(n),fqt:"0",secid:l,beg:o,end:i}),{klines:p,name:d,code:f}=await B(t,se,c);return p.length===0?[]:p.map(y=>({...$o(y),code:f||e,name:d||""}))}async function gn(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:ae,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),u=`${wt}?${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(Qo);n.push(...c),o++}while(n.length<i);return n}function Qo(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 jo(t){let e=w(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}function Go(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 fn(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;v(n);let s=r.marketCode;if(s===void 0){let f=Go(e);if(s=ve[f],s===void 0){let y=Object.keys(ve).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:L,klt:U(n),fqt:"0",secid:u,beg:o,end:i}),{klines:c,name:p,code:d}=await B(t,se,l);return c.length===0?[]:c.map(f=>({...jo(f),code:d||e,name:p||""}))}async function hn(t,e={}){let{pageSize:r=2e4}=e,n=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(r),pageIndex:"0",token:ae,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${Qt}?${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 zo(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function Tn(t,e,r){let n=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:F,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${r}')`}),o=`${jt}?${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:zo(String(l.TRADE_TYPE??""))}))}var Yo={gold:"EMI00069026",silver:"EMI00069027"};function yn(t){if(!t)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}async function Sn(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 Rn(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:yn(s.TRADE_DATE),inventory:a(s.ON_WARRANT_NUM),change:a(s.ADDCHANGE)}))}async function En(t,e,r={}){let n=Yo[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:yn(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 Cn={daily:"101",weekly:"102",monthly:"103"},mr="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function On(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 Vo(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 _n={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"}},Wo={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},Xo="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 An(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=`${vt}?${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 In(t,e,r={}){let{period:n="daily"}=r,o=Cn[n];if(!o)throw new RangeError(`Invalid period: ${n}. Must be daily/weekly/monthly.`);let i=e.replace(/^(sh|sz|bj)/i,""),s=`${te(e)}.${i}`,u=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:mr,ut:F}),l=`${oe}?${u.toString()}`,p=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(p)||p.length===0?[]:p.map(On)}async function Pn(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:mr,ut:F}),r=`${oe}?${e.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(Vo)}async function Dn(t,e={}){let{indicator:r="today"}=e,n=_n[r];if(!n)throw new RangeError(`Invalid indicator: ${r}.`);let o={fid:n.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:F,fs:Xo,fields:n.fields};return(await An(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 bn(t,e={}){let{indicator:r="today",sectorType:n="industry"}=e,o=_n[r];if(!o)throw new RangeError(`Invalid indicator: ${r}.`);let i=Wo[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:F,fs:i,fields:s};return(await An(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 Ln(t,e,r={}){let{period:n="daily"}=r,o=Cn[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:mr,ut:F}),u=`${oe}?${s.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(On)}var Zo={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},Jo={shanghai:"001",shenzhen:"003"};function Mn(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 kn(t,e="north"){let r=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:F}),n=`${Ut}?${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=>Mn(p,Nn(c)))}let s=i.s2n??[],u=i.s2nDate??"";return s.map(l=>Mn(l,Nn(u)))}function Nn(t){return t?/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t:""}async function Fn(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:b(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 xn(t,e={}){let{market:r="all",period:n="5day",date:o}=e,i=Zo[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="${Jo[r]}")`),O(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:s.join("")},u=>({date:b(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 vn(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:b(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 Un(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:b(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 ei={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"}},ti={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"},ri={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 gr(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 ni(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function oi(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?gr(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?gr(t.lbt):null,boardAmount:a(t.fund),sealAmount:a(t.fund),failedCount:a(t.zbc),industry:String(t.hybk??""),ztStatistics:ni(t.zttj),amplitude:a(t.zf),speed:a(t.zs)}}function ii(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function si(){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 wn(t,e="zt",r){let n=ei[e];if(!n)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=ii(r)??si(),i=new URLSearchParams({ut:L,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:n.sort,date:o}),s=`${ie}${n.path}?${i.toString()}`,l=(await t.get(s,{responseType:"json"}))?.data?.pool;return!Array.isArray(l)||l.length===0?[]:l.map(oi)}async function Bn(t,e="large_buy"){let r=ti[e];if(!r)throw new RangeError(`Invalid StockChangeType: ${e}.`);let n=new URLSearchParams({type:r,pageindex:"0",pagesize:"5000",ut:L,dpt:"wzchanges"}),o=`${ie}/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:gr(u.tm),code:String(u.c??""),name:String(u.n??""),changeType:e,changeTypeLabel:ri[l]??"",info:String(u.i??"")}})}async function Kn(t){let e=new URLSearchParams({ut:L,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),r=`${ie}/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 Hn={"1month":"01","3month":"02","6month":"03","1year":"04"};function Se(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}async function qn(t,e){let r=Se(e.startDate),n=Se(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:b(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 $n(t,e="1month"){let r=Hn[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:b(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 Qn(t,e){let r=Se(e.startDate),n=Se(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:b(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 jn(t,e="1month"){let r=Hn[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 Gn(t,e,r){let n=e.replace(/^(sh|sz|bj)/i,""),o=Se(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 zn(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function Yn(t){if(!t)return"";let e=zn(t.startDate),r=zn(t.endDate),n=[];return e&&n.push(`(TRADE_DATE>='${e}')`),r&&n.push(`(TRADE_DATE<='${r}')`),n.join("")}async function Vn(t){return O(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:b(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 Wn(t,e={}){let r=Yn(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:b(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 Xn(t,e={}){let r=Yn(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:b(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 Zn(t){return O(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:b(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 Jn(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:b(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 k={};ft(k,{getCommodityOptionKline:()=>lo,getCommodityOptionSpot:()=>uo,getETFOption5DayMinute:()=>ao,getETFOptionDailyKline:()=>so,getETFOptionExpireDay:()=>no,getETFOptionMinute:()=>io,getETFOptionMonths:()=>ro,getIndexOptionKline:()=>to,getIndexOptionSpot:()=>eo});function ai(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 ui(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 eo(t,e){let r=`${ue}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,n=await M(r),o=n?.result?.data?.up??[],i=n?.result?.data?.down??[];return{calls:o.map(ai),puts:i.map(ui)}}async function to(t){let e=`${le}?symbol=${t}`,r=await M(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 ro(t){let e=`${Kt}?exchange=null&cate=${encodeURIComponent(t)}`,n=(await M(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 no(t,e){let r=`${Ue}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,n=await M(r),o=n?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let s=`${Ue}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;n=await M(s)}let i=n?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function oo(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 io(t){let e=`CON_OP_${t}`,r=`${Ht}?symbol=${e}`,o=(await M(r))?.result?.data;return Array.isArray(o)?oo(o):[]}async function so(t){let e=`CON_OP_${t}`,r=`${qt}?symbol=${e}`,n=await M(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 ao(t){let e=`CON_OP_${t}`,r=`${$t}?symbol=${e}`,o=(await M(r))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...oo(s));return i}function li(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 ci(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 uo(t,e){let r=we[t];if(!r)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(we).join(", ")}`);let n=`${ue}?type=futures&product=${r.product}&exchange=${r.exchange}&pinzhong=${e}`,o=await M(n),i=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:i.map(li),puts:s.map(ci)}}async function lo(t){let e=`${le}?symbol=${t}`,r=await M(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 Re=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 Ee=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 Ce=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 Oe=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 _e=class extends _{constructor(e){super(e)}getIndexOptionSpot(e,r){return k.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return k.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return T.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return k.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return k.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return k.getETFOptionMinute(e)}getETFOptionDailyKline(e){return k.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return k.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return k.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return k.getCommodityOptionKline(e)}getOptionLHB(e,r){return T.getOptionLHB(this.client,e,r)}};function Ae(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function W(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?Ae(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?Ae(o):null);continue}let u=t[s];u===null?r.push(o!==null?Ae(o):null):(o=n*u+(1-n)*o,r.push(Ae(o)))}return r}function fr(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?Ae(s/o):null)}return r}function Ve(t,e={}){let{periods:r=[5,10,20,30,60,120,250],type:n="sma"}=e,o=n==="ema"?q:n==="wma"?fr:W,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 co(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function We(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?co(u[p]):null,dea:l[p],macd:u[p]!==null&&l[p]!==null?co((u[p]-l[p])*2):null}))}function hr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function pi(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 Xe(t,e={}){let{period:r=20,stdDev:n=2}=e,o=W(t,r),i=pi(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?hr((l-c)/o[u]*100):null;return{mid:o[u],upper:hr(l),lower:hr(c),bandwidth:p}})}function Tr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ze(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:Tr(s),d:Tr(u),j:Tr(S)})}return i}function di(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Je(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(di(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 mi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function et(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(mi(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 gi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function tt(t,e={}){let{periods:r=[6,12,24]}=e,n={};for(let o of r){let i=W(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(gi(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 fi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function rt(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:fi(d)})}}return n}function yr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function re(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?yr(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?yr(o[s]):null,atr:i!==null?yr(i):null})}return n}function nt(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 ot(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 it(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],E=t[g-1];if(R.high===null||R.low===null||R.close===null||E.high===null||E.low===null||E.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-E.close),D=Math.abs(R.low-E.close);u.push(Math.max(I,P,D));let N=R.high-E.high,G=E.low-R.low;N>G&&N>0?i.push(N):i.push(0),G>N&&G>0?s.push(G):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,E=l>0?p/l*100:0;o[g].pdi=R,o[g].mdi=E;let I=R+E,P=I>0?Math.abs(R-E)/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,E=o[g-n]?.adx;R!==null&&E!==null&&(o[g].adxr=(R+E)/2)}return o}function st(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 at(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=re(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 ut(t,e=0){return t.length===0?e:Math.max(...t)}function lt(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 ne={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:ut(r,20),emaBased:n==="ema"}},compute:(t,e)=>Ve(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)=>We(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>Xe(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>Ze(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:ut(e,14)+1}},compute:(t,e)=>Je(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:ut(e,10)}},compute:(t,e)=>et(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:ut(e,12)}},compute:(t,e)=>tt(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>rt(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>re(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)=>nt(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)=>ot(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)=>it(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>st(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)=>at(t.ohlcv,typeof e=="object"?e:{})}};function Ie(t){return Object.keys(ne).filter(e=>!!t[e])}function ct(t){let e=0,r=!1;for(let o of Ie(t)){let s=ne[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 pt(t,e={}){if(t.length===0)return[];let r=lt(t),n=new Map;for(let o of Ie(e)){let i=ne[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 Pe=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}=ct(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=pt(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 De=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 be=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 Le=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 Me=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 Ne=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 dt=class{constructor(e={}){this.client=new fe(e),this.quoteService=new Re(this.client),this.boardService=new Ee(this.client),this.klineService=new Ce(this.client),this.futuresService=new Oe(this.client),this.optionsService=new _e(this.client),this.indicatorService=new Pe(this.klineService,this.quoteService),this.fundFlowService=new De(this.client),this.northboundService=new be(this.client),this.marketEventService=new Le(this.client),this.dragonTigerService=new Me(this.client),this.dataService=new Ne(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)}},hi=dt;export{K as HttpError,ne as INDICATOR_REGISTRY,x as SdkError,dt as StockSDK,pt as addIndicators,ee as asyncPool,lt as buildIndicatorContext,re as calcATR,tt as calcBIAS,Xe as calcBOLL,rt as calcCCI,it as calcDMI,q as calcEMA,at as calcKC,Ze as calcKDJ,Ve as calcMA,We as calcMACD,nt as calcOBV,ot as calcROC,Je as calcRSI,st as calcSAR,W as calcSMA,fr as calcWMA,et as calcWR,J as chunkArray,ke as decodeGBK,hi as default,ct as estimateIndicatorLookback,er as extractJsonFromJsonp,Ie as getEnabledIndicatorKeys,z as getSdkErrorCode,M as jsonpRequest,Fe as parseResponse,h as safeNumber,C as safeNumberOrNull};
1
+ var mo=Object.defineProperty;var ft=(t,e)=>{for(var r in e)mo(t,r,{get:e[r],enumerable:!0})};function Ne(t){return new TextDecoder("gbk").decode(t)}function Fe(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 C(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 ht="https://qt.gtimg.cn",Tt="https://web.ifzq.gtimg.cn/appstock/app/minute/query",yt="https://assets.linkdiary.cn/shares/zh_a_list.json",St="https://assets.linkdiary.cn/shares/us_list.json",Rt="https://assets.linkdiary.cn/shares/hk_list.json",Et="https://assets.linkdiary.cn/shares/fund_list",Sr="https://assets.linkdiary.cn/shares/trade-data-list.txt";var xe="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ct="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ot="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",_t="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",At="https://17.push2.eastmoney.com/api/qt/clist/get",It="https://91.push2.eastmoney.com/api/qt/stock/get",Pt="https://29.push2.eastmoney.com/api/qt/clist/get",Dt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",bt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Lt="https://79.push2.eastmoney.com/api/qt/clist/get",Mt="https://91.push2.eastmoney.com/api/qt/stock/get",kt="https://29.push2.eastmoney.com/api/qt/clist/get",Nt="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Ft="https://push2his.eastmoney.com/api/qt/stock/trends2/get",xt="https://datacenter-web.eastmoney.com/api/data/v1/get",oe="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",vt="https://push2.eastmoney.com/api/qt/clist/get",Ut="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",ie="https://push2ex.eastmoney.com",L="7eea3edcaed734bea9cbfc24409ed989",F="b2884a393a59ad64002292a3e90d46a5",se="https://push2his.eastmoney.com/api/qt/stock/kline/get",wt="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",ae="58b2fa8f54638b60b87d69b31969089c",Bt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},X={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},ve={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},ue="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",le="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",Kt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",Ue="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",Ht="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",qt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",$t="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",Qt="https://futsseapi.eastmoney.com/list/option/221",jt="https://datacenter-web.eastmoney.com/api/data/get";var we={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"}},zt=3e4,ce=500,pe=500,de=7,Gt=3,Yt=1e3,Vt=3e4,Wt=2,Xt=[408,429,500,502,503,504];var Be=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 Rr=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Zt=0;function go(){return typeof window<"u"&&typeof window.document<"u"}function Er(){if(go())return;let t=Rr[Zt];return Zt=(Zt+1)%Rr.length,t}var x=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)}},K=class extends x{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 ge=class extends x{constructor(e,r,n){super({code:"NOT_FOUND",message:e,provider:r,url:n}),this.name="NotFoundError"}};function me(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 fo(t,e){return me(t,{provider:e.provider,url:e.url})}function G(t){if(t instanceof x||t instanceof K)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 Ke(t,e={}){return t instanceof x?fo(t,e):t instanceof DOMException&&t.name==="AbortError"?me(t,{sdkCode:"TIMEOUT",provider:e.provider,url:e.url,details:e.timeout?{timeout:e.timeout}:void 0}):t instanceof TypeError?me(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):t instanceof Error?me(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):new x({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var Z=class extends x{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},He=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let r=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(r,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new Z;try{let r=await e();return this.recordSuccess(),r}catch(r){throw this.recordFailure(),r}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var ho=3e4,To=1,Cr=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],Or=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function yo(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Cr:t.includes("push2.eastmoney.com")?Or:[t]}function So(t){return Array.from(new Set(t))}var qe=class{constructor(e=ho,r=To){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=yo(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 So([...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=G(r),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let r=G(e);return r==="NETWORK_ERROR"||r==="TIMEOUT"?!0:e instanceof K?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([...Cr,...Or]);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 Ro(t){return{maxRetries:t?.maxRetries??Gt,baseDelay:t?.baseDelay??Yt,maxDelay:t?.maxDelay??Vt,backoffMultiplier:t?.backoffMultiplier??Wt,retryableStatusCodes:t?.retryableStatusCodes??Xt,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function Eo(t,e){let r={...t??{}};return e&&(Object.keys(r).some(o=>o.toLowerCase()==="user-agent")||(r["User-Agent"]=e)),r}function _r(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 Jt(t={}){return{timeout:t.timeout??zt,retry:Ro(t.retry),headers:Eo(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function Ar(t,e){if(e)return e;try{let r=new URL(t).hostname;if(r.includes("eastmoney.com"))return"eastmoney";if(r.includes("gtimg.cn"))return"tencent";if(r.includes("sina.com.cn"))return"sina";if(r.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}var fe=class{constructor(e={}){this.baseUrl=e.baseUrl??ht;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=Jt(r),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new qe;for(let[n,o]of Object.entries(e.providerPolicies??{})){let i=_r(r,o);this.providerPolicies[n]=Jt(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 Be(n.rateLimit):null,circuitBreaker:n.circuitBreaker?new He(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=G(e);return o==="TIMEOUT"?n.retryOnTimeout:o==="NETWORK_ERROR"?n.retryOnNetworkError:e instanceof K?n.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,r,n,o=0){try{return await e()}catch(i){let s=Ke(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=Er();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 K(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=Ar(e,r.provider),o=this.getProviderState(n);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new Z("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=Ke(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 Z("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=Ne(n);return Fe(o)}};var Co=new Set(["daily","weekly","monthly"]),Oo=new Set(["1","5","15","30","60"]),_o=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 v(t){if(!Co.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function he(t){if(!Oo.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function Q(t){if(!_o.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function J(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 ee(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 te(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function U(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function j(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var $e=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}},Ir=new Map;function Y(t,e){let r=Ir.get(t);if(r)return r;let n=new $e(e);return Ir.set(t,n),n}var Ao=typeof document<"u"&&typeof window<"u",Io=0;function Pr(){return`__stock_sdk_jsonp_${Date.now()}_${Io++}`}function er(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 Po(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let u=Pr(),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 Do(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e,i=Pr(),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 er(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 M(t,e={}){return Ao?Po(t,e):Do(t,e)}var A={};ft(A,{getAShareCodeList:()=>Fr,getAllHKQuotesByCodes:()=>wr,getAllQuotesByCodes:()=>Ur,getAllUSQuotesByCodes:()=>Br,getFullQuotes:()=>Qe,getFundCodeList:()=>Kr,getFundFlow:()=>br,getFundQuotes:()=>Mr,getHKCodeList:()=>vr,getHKQuotes:()=>je,getPanelLargeOrder:()=>Lr,getSimpleQuotes:()=>Dr,getTodayTimeline:()=>kr,getTradingCalendar:()=>Hr,getUSCodeList:()=>xr,getUSQuotes:()=>ze,parseFullQuote:()=>tr,parseFundFlow:()=>nr,parseFundQuote:()=>ar,parseHKQuote:()=>ir,parsePanelLargeOrder:()=>or,parseSimpleQuote:()=>rr,parseUSQuote:()=>sr,search:()=>$r});function tr(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:C(t[38]),pe:C(t[39]),amplitude:C(t[43]),circulatingMarketCap:C(t[44]),totalMarketCap:C(t[45]),pb:C(t[46]),limitUp:C(t[47]),limitDown:C(t[48]),volumeRatio:C(t[49]),avgPrice:C(t[51]),peStatic:C(t[52]),peDynamic:C(t[53]),high52w:C(t[67]),low52w:C(t[68]),circulatingShares:C(t[72]),totalShares:C(t[73]),raw:t}}function rr(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:C(t[9]),marketType:t[10]??"",raw:t}}function nr(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 or(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function ir(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:C(t[40]),circulatingMarketCap:C(t[44]),totalMarketCap:C(t[45]),currency:t[t.length-3]??"",raw:t}}function sr(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:C(t[38]),pe:C(t[39]),amplitude:C(t[43]),totalMarketCap:C(t[45]),pb:C(t[47]),high52w:C(t[48]),low52w:C(t[49]),raw:t}}function ar(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 Qe(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=>tr(n.fields))}async function Dr(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=>rr(o.fields))}async function br(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=>nr(o.fields))}async function Lr(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=>or(o.fields))}async function je(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=>ir(o.fields))}async function ze(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=>sr(o.fields))}async function Mr(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=>ar(o.fields))}async function kr(t,e){let r=t.getTimeout(),n=new AbortController,o=setTimeout(()=>n.abort(),r);try{let i=await fetch(`${Tt}?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,E=parseFloat(S[3])||0;R>0&&g>0&&E/R>g*50&&(f=!0)}let y=l.map(S=>{let g=S.split(" "),R=g[0],E=`${R.slice(0,2)}:${R.slice(2,4)}`,I=parseInt(g[2],10)||0,P=parseFloat(g[3])||0,D=f?I*100:I,k=D>0?P/D:0;return{time:E,price:parseFloat(g[1])||0,volume:D,amount:P,avgPrice:Math.round(k*100)/100}});return{code:e,date:c,preClose:d,data:y}}finally{clearTimeout(o)}}var Nr=Y("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function ur(t,e,r){return Nr.getOrFetch(e,async()=>(await t.get(r,{responseType:"json"}))?.list||[])}function bo(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 Fr(t,e){let r=!1,n;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,n=e.market);let i=await ur(t,"a-share:full",yt);return n&&(i=i.filter(s=>bo(s,n))),r?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var Lo={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};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 ur(t,"us:full",St)).slice();if(n){let s=Lo[n];i=i.filter(u=>u.startsWith(s))}return r?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function vr(t){return(await ur(t,"hk:full",Rt)).slice()}async function Ur(t,e,r={}){let{batchSize:n=ce,concurrency:o=de,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,pe),u=J(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await Qe(t,f);return c++,i&&i(c,l),y});return(await ee(p,o,!0)).flat()}async function wr(t,e,r={}){let{batchSize:n=ce,concurrency:o=de,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,pe),u=J(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await je(t,f);return c++,i&&i(c,l),y});return(await ee(p,o,!0)).flat()}async function Br(t,e,r={}){let{batchSize:n=ce,concurrency:o=de,onProgress:i}=r;H(n,"batchSize"),H(o,"concurrency");let s=Math.min(n,pe),u=J(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let y=await ze(t,f);return c++,i&&i(c,l),y});return(await ee(p,o,!0)).flat()}async function Kr(t){return(await Nr.getOrFetch("fund:full",async()=>(await t.get(Et,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var Mo=Y("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function Hr(t){return(await Mo.getOrFetch("a-share",async()=>{let r=await t.get(Sr);return!r||r.trim()===""?[]:r.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0)})).slice()}var qr="https://smartbox.gtimg.cn/s3/";function ko(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function No(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 Fo(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(r=>{let n=r.split("~"),o=n[0]||"",i=n[1]||"",s=ko(n[2]||""),u=n[4]||"";return{code:o+i,name:s,market:o,type:u,category:No(u)}})}function xo(t){return new Promise((e,r)=>{let n=`${qr}?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 vo(t,e){let r=`${qr}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(r)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function Uo(){return typeof window<"u"&&typeof document<"u"}async function $r(t,e){if(!e||!e.trim())return[];let r;return Uo()?r=await xo(e):r=await vo(t,e),Fo(r)}var T={};ft(T,{extractVariety:()=>pr,fetchDatacenter:()=>cr,fetchDatacenterList:()=>O,getBlockTradeDailyStat:()=>Xn,getBlockTradeDetail:()=>Wn,getBlockTradeMarketStat:()=>Vn,getBoardChanges:()=>Kn,getCFFEXOptionQuotes:()=>hn,getComexInventory:()=>En,getConceptConstituents:()=>un,getConceptKline:()=>ln,getConceptList:()=>sn,getConceptMinuteKline:()=>cn,getConceptSpot:()=>an,getDividendDetail:()=>pn,getDragonTigerBranchRank:()=>jn,getDragonTigerDetail:()=>qn,getDragonTigerInstitution:()=>Qn,getDragonTigerStockSeatDetail:()=>zn,getDragonTigerStockStats:()=>$n,getFundFlowRank:()=>Dn,getFuturesHistoryKline:()=>mn,getFuturesInventory:()=>Rn,getFuturesInventorySymbols:()=>Sn,getFuturesMarketCode:()=>dr,getGlobalFuturesKline:()=>fn,getGlobalFuturesSpot:()=>gn,getHKHistoryKline:()=>zr,getHistoryKline:()=>Qr,getIndividualFundFlow:()=>In,getIndustryConstituents:()=>rn,getIndustryKline:()=>nn,getIndustryList:()=>en,getIndustryMinuteKline:()=>on,getIndustrySpot:()=>tn,getMarginAccountInfo:()=>Zn,getMarginTargetList:()=>Jn,getMarketFundFlow:()=>Pn,getMinuteKline:()=>jr,getNorthboundFlowSummary:()=>Fn,getNorthboundHistory:()=>vn,getNorthboundHoldingRank:()=>xn,getNorthboundIndividual:()=>Un,getNorthboundMinute:()=>Nn,getOptionLHB:()=>Tn,getSectorFundFlowHistory:()=>Ln,getSectorFundFlowRank:()=>bn,getStockChanges:()=>Bn,getUSHistoryKline:()=>Gr,getZTPool:()=>wn});async function lr(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 w(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 B(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 Qr(t,e,r={}){let{period:n="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=r;v(n),Q(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${te(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:L,klt:U(n),fqt:j(o),secid:l,beg:i,end:s}),p=xe,{klines:d}=await B(t,p,c);return d.length===0?[]:d.map(f=>({...w(f),code:u}))}async function jr(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;he(n),Q(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${te(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:L,ndays:"5",iscr:"0",secid:l}),p=`${Ct}?${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,E,I,P,D,k,z,$]=g.split(",");return{time:R,open:m(E),close:m(I),high:m(P),low:m(D),volume:m(k),amount:m(z),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:L,klt:n,fqt:j(o||""),secid:l,beg:"0",end:"20500000"}),p=xe,{klines:d}=await B(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=w(S);return{...g,time:g.date}}).filter(S=>S.time>=f&&S.time<=y)}}function Ge(t){return async function(r,n,o={}){let{period:i="daily",adjust:s="qfq",startDate:u="19700101",endDate:l="20500101"}=o;v(i),Q(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:L,klt:U(i),fqt:j(s),secid:c.secid,beg:u,end:l,lmt:"1000000"}),{klines:d,name:f,code:y}=await B(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=>({...w(g),code:S.code,name:S.name}))}}var wo=Ge({url:Ot,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}}});async function zr(t,e,r={}){return wo(t,e,r)}var Bo=Ge({url:_t,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,r)=>({code:r.code||e.fallbackCode,name:r.name||""})});async function Gr(t,e,r={}){return Bo(t,e,r)}function Yr(t){let e=Y(`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 ge(`${t.errorPrefix}: ${n}`,"eastmoney");return s}}}async function Vr(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 lr(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 Wr(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 Xr(t,e,r){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return lr(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 Zr(t,e,r,n={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:u="20500101"}=n;v(o),Q(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:U(o),fqt:j(i),beg:s,end:u,smplmt:"10000",lmt:"1000000"}),{klines:c}=await B(t,r,l);return c.length===0?[]:c.map(p=>w(p))}async function Jr(t,e,r,n,o={}){let{period:i="5"}=o;if(he(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,E,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(E),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,E,I,P,D,k]=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(E),amplitude:m(I),turnoverRate:m(k)}})}}function Ye(t){let e=Yr(t);async function r(o){return Vr(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 Wr(o,s,t.spotUrl)},async getConstituents(o,i){let s=await n(o,i);return Xr(o,s,t.consUrl)},async getKline(o,i,s={}){let u=await n(o,i);return Zr(o,u,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let u=await n(o,i);return Jr(o,u,t.klineUrl,t.trendsUrl,s)}}}var Ko={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:At,spotUrl:It,consUrl:Pt,klineUrl:Dt,trendsUrl:bt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},Te=Ye(Ko);async function en(t){return Te.getList(t)}async function tn(t,e){return Te.getSpot(t,e)}async function rn(t,e){return Te.getConstituents(t,e)}async function nn(t,e,r={}){return Te.getKline(t,e,r)}async function on(t,e,r={}){return Te.getMinuteKline(t,e,r)}var Ho={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Lt,spotUrl:Mt,consUrl:kt,klineUrl:Nt,trendsUrl:Ft,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ye=Ye(Ho);async function sn(t){return ye.getList(t)}async function an(t,e){return ye.getSpot(t,e)}async function un(t,e){return ye.getConstituents(t,e)}async function ln(t,e,r={}){return ye.getKline(t,e,r)}async function cn(t,e,r={}){return ye.getMinuteKline(t,e,r)}async function cr(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,E=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[mt,gt]of Object.entries(S))D.set(mt,gt);let k=`${xt}?${D.toString()}`,$=(await t.get(k,{responseType:"json"}))?.result;if(!$||!Array.isArray($.data))break;R===c&&(E=$.pages??1,I=$.count??$.data.length);let po=$.data.map((mt,gt)=>r(mt,g.length+gt));if(g.push(...po),R++,P++,!p)break}while(R<=E&&P<d);return p&&P>=d&&R<=E&&console.warn(`[stock-sdk] fetchDatacenter("${n}") truncated at maxPages=${d} (server reports ${E} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:g,total:I,pages:E}}async function O(t,e,r){return(await cr(t,e,r)).data}function b(t){if(t==null)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}function V(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function qo(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:V(t.REPORT_DATE),planNoticeDate:V(t.PLAN_NOTICE_DATE),disclosureDate:V(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:V(t.EQUITY_RECORD_DATE),exDividendDate:V(t.EX_DIVIDEND_DATE),payDate:V(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:V(t.NOTICE_DATE)}}async function pn(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=>qo(n))}function pr(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 dn(t){return X[t]??X[t.toLowerCase()]??X[t.toUpperCase()]}function dr(t){let e=dn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=dn(t.slice(0,-1))),!e){let n=Object.keys(X).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${n}`)}let r=Bt[e];if(r===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return r}function $o(t){let e=w(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}async function mn(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;v(n);let s=pr(e),l=`${dr(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:L,klt:U(n),fqt:"0",secid:l,beg:o,end:i}),{klines:p,name:d,code:f}=await B(t,se,c);return p.length===0?[]:p.map(y=>({...$o(y),code:f||e,name:d||""}))}async function gn(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:ae,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),u=`${wt}?${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(Qo);n.push(...c),o++}while(n.length<i);return n}function Qo(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 jo(t){let e=w(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 fn(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;v(n);let s=r.marketCode;if(s===void 0){let f=zo(e);if(s=ve[f],s===void 0){let y=Object.keys(ve).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:L,klt:U(n),fqt:"0",secid:u,beg:o,end:i}),{klines:c,name:p,code:d}=await B(t,se,l);return c.length===0?[]:c.map(f=>({...jo(f),code:d||e,name:p||""}))}async function hn(t,e={}){let{pageSize:r=2e4}=e,n=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(r),pageIndex:"0",token:ae,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${Qt}?${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 Go(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function Tn(t,e,r){let n=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:F,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${r}')`}),o=`${jt}?${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:Go(String(l.TRADE_TYPE??""))}))}var Yo={gold:"EMI00069026",silver:"EMI00069027"};function yn(t){if(!t)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}async function Sn(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 Rn(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:yn(s.TRADE_DATE),inventory:a(s.ON_WARRANT_NUM),change:a(s.ADDCHANGE)}))}async function En(t,e,r={}){let n=Yo[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:yn(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 Cn={daily:"101",weekly:"102",monthly:"103"},mr="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function On(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 Vo(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 _n={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"}},Wo={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},Xo="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 An(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=`${vt}?${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 In(t,e,r={}){let{period:n="daily"}=r,o=Cn[n];if(!o)throw new RangeError(`Invalid period: ${n}. Must be daily/weekly/monthly.`);let i=e.replace(/^(sh|sz|bj)/i,""),s=`${te(e)}.${i}`,u=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:mr,ut:F}),l=`${oe}?${u.toString()}`,p=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(p)||p.length===0?[]:p.map(On)}async function Pn(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:mr,ut:F}),r=`${oe}?${e.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(Vo)}async function Dn(t,e={}){let{indicator:r="today"}=e,n=_n[r];if(!n)throw new RangeError(`Invalid indicator: ${r}.`);let o={fid:n.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:F,fs:Xo,fields:n.fields};return(await An(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 bn(t,e={}){let{indicator:r="today",sectorType:n="industry"}=e,o=_n[r];if(!o)throw new RangeError(`Invalid indicator: ${r}.`);let i=Wo[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:F,fs:i,fields:s};return(await An(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 Ln(t,e,r={}){let{period:n="daily"}=r,o=Cn[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:mr,ut:F}),u=`${oe}?${s.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(On)}var Zo={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},Jo={shanghai:"001",shenzhen:"003"};function Mn(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 Nn(t,e="north"){let r=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:F}),n=`${Ut}?${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=>Mn(p,kn(c)))}let s=i.s2n??[],u=i.s2nDate??"";return s.map(l=>Mn(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 Fn(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:b(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 xn(t,e={}){let{market:r="all",period:n="5day",date:o}=e,i=Zo[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="${Jo[r]}")`),O(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:s.join("")},u=>({date:b(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 vn(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:b(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 Un(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:b(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 ei={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"}},ti={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"},ri={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 gr(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 ni(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function oi(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?gr(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?gr(t.lbt):null,boardAmount:a(t.fund),sealAmount:a(t.fund),failedCount:a(t.zbc),industry:String(t.hybk??""),ztStatistics:ni(t.zttj),amplitude:a(t.zf),speed:a(t.zs)}}function ii(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function si(){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 wn(t,e="zt",r){let n=ei[e];if(!n)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=ii(r)??si(),i=new URLSearchParams({ut:L,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:n.sort,date:o}),s=`${ie}${n.path}?${i.toString()}`,l=(await t.get(s,{responseType:"json"}))?.data?.pool;return!Array.isArray(l)||l.length===0?[]:l.map(oi)}async function Bn(t,e="large_buy"){let r=ti[e];if(!r)throw new RangeError(`Invalid StockChangeType: ${e}.`);let n=new URLSearchParams({type:r,pageindex:"0",pagesize:"5000",ut:L,dpt:"wzchanges"}),o=`${ie}/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:gr(u.tm),code:String(u.c??""),name:String(u.n??""),changeType:e,changeTypeLabel:ri[l]??"",info:String(u.i??"")}})}async function Kn(t){let e=new URLSearchParams({ut:L,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),r=`${ie}/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 Hn={"1month":"01","3month":"02","6month":"03","1year":"04"};function Se(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}async function qn(t,e){let r=Se(e.startDate),n=Se(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:b(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 $n(t,e="1month"){let r=Hn[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:b(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 Qn(t,e){let r=Se(e.startDate),n=Se(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:b(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 jn(t,e="1month"){let r=Hn[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=Se(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 Gn(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function Yn(t){if(!t)return"";let e=Gn(t.startDate),r=Gn(t.endDate),n=[];return e&&n.push(`(TRADE_DATE>='${e}')`),r&&n.push(`(TRADE_DATE<='${r}')`),n.join("")}async function Vn(t){return O(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:b(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 Wn(t,e={}){let r=Yn(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:b(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 Xn(t,e={}){let r=Yn(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:b(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 Zn(t){return O(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:b(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 Jn(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:b(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 N={};ft(N,{getCommodityOptionKline:()=>lo,getCommodityOptionSpot:()=>uo,getETFOption5DayMinute:()=>ao,getETFOptionDailyKline:()=>so,getETFOptionExpireDay:()=>no,getETFOptionMinute:()=>io,getETFOptionMonths:()=>ro,getIndexOptionKline:()=>to,getIndexOptionSpot:()=>eo});function ai(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 ui(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 eo(t,e){let r=`${ue}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,n=await M(r),o=n?.result?.data?.up??[],i=n?.result?.data?.down??[];return{calls:o.map(ai),puts:i.map(ui)}}async function to(t){let e=`${le}?symbol=${t}`,r=await M(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 ro(t){let e=`${Kt}?exchange=null&cate=${encodeURIComponent(t)}`,n=(await M(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 no(t,e){let r=`${Ue}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,n=await M(r),o=n?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let s=`${Ue}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;n=await M(s)}let i=n?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function oo(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 io(t){let e=`CON_OP_${t}`,r=`${Ht}?symbol=${e}`,o=(await M(r))?.result?.data;return Array.isArray(o)?oo(o):[]}async function so(t){let e=`CON_OP_${t}`,r=`${qt}?symbol=${e}`,n=await M(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 ao(t){let e=`CON_OP_${t}`,r=`${$t}?symbol=${e}`,o=(await M(r))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...oo(s));return i}function li(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 ci(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 uo(t,e){let r=we[t];if(!r)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(we).join(", ")}`);let n=`${ue}?type=futures&product=${r.product}&exchange=${r.exchange}&pinzhong=${e}`,o=await M(n),i=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:i.map(li),puts:s.map(ci)}}async function lo(t){let e=`${le}?symbol=${t}`,r=await M(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 Re=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 Ee=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 Ce=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 Oe=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 _e=class extends _{constructor(e){super(e)}getIndexOptionSpot(e,r){return N.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return N.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return T.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return N.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return N.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return N.getETFOptionMinute(e)}getETFOptionDailyKline(e){return N.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return N.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return N.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return N.getCommodityOptionKline(e)}getOptionLHB(e,r){return T.getOptionLHB(this.client,e,r)}};function Ae(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function W(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?Ae(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?Ae(o):null);continue}let u=t[s];u===null?r.push(o!==null?Ae(o):null):(o=n*u+(1-n)*o,r.push(Ae(o)))}return r}function fr(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?Ae(s/o):null)}return r}function Ve(t,e={}){let{periods:r=[5,10,20,30,60,120,250],type:n="sma"}=e,o=n==="ema"?q:n==="wma"?fr:W,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 co(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function We(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?co(u[p]):null,dea:l[p],macd:u[p]!==null&&l[p]!==null?co((u[p]-l[p])*2):null}))}function hr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function pi(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 Xe(t,e={}){let{period:r=20,stdDev:n=2}=e,o=W(t,r),i=pi(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?hr((l-c)/o[u]*100):null;return{mid:o[u],upper:hr(l),lower:hr(c),bandwidth:p}})}function Tr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Ze(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:Tr(s),d:Tr(u),j:Tr(S)})}return i}function di(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Je(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(di(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 mi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function et(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(mi(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 gi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function tt(t,e={}){let{periods:r=[6,12,24]}=e,n={};for(let o of r){let i=W(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(gi(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 fi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function rt(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:fi(d)})}}return n}function yr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function re(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?yr(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?yr(o[s]):null,atr:i!==null?yr(i):null})}return n}function nt(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 ot(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 it(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],E=t[g-1];if(R.high===null||R.low===null||R.close===null||E.high===null||E.low===null||E.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-E.close),D=Math.abs(R.low-E.close);u.push(Math.max(I,P,D));let k=R.high-E.high,z=E.low-R.low;k>z&&k>0?i.push(k):i.push(0),z>k&&z>0?s.push(z):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,E=l>0?p/l*100:0;o[g].pdi=R,o[g].mdi=E;let I=R+E,P=I>0?Math.abs(R-E)/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,E=o[g-n]?.adx;R!==null&&E!==null&&(o[g].adxr=(R+E)/2)}return o}function st(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 at(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=re(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 ut(t,e=0){return t.length===0?e:Math.max(...t)}function lt(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 ne={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:ut(r,20),emaBased:n==="ema"}},compute:(t,e)=>Ve(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)=>We(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>Xe(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>Ze(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:ut(e,14)+1}},compute:(t,e)=>Je(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:ut(e,10)}},compute:(t,e)=>et(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:ut(e,12)}},compute:(t,e)=>tt(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>rt(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>re(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)=>nt(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)=>ot(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)=>it(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>st(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)=>at(t.ohlcv,typeof e=="object"?e:{})}};function Ie(t){return Object.keys(ne).filter(e=>!!t[e])}function ct(t){let e=0,r=!1;for(let o of Ie(t)){let s=ne[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 pt(t,e={}){if(t.length===0)return[];let r=lt(t),n=new Map;for(let o of Ie(e)){let i=ne[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 Pe=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}=ct(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=pt(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 De=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 be=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 Le=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 Me=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 ke=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 dt=class{constructor(e={}){this.client=new fe(e),this.quoteService=new Re(this.client),this.boardService=new Ee(this.client),this.klineService=new Ce(this.client),this.futuresService=new Oe(this.client),this.optionsService=new _e(this.client),this.indicatorService=new Pe(this.klineService,this.quoteService),this.fundFlowService=new De(this.client),this.northboundService=new be(this.client),this.marketEventService=new Le(this.client),this.dragonTigerService=new Me(this.client),this.dataService=new ke(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)}},hi=dt;var Ti={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},yi={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},Si={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function Ri(t){let e=t.code.trim(),r=t.market.trim().toLowerCase(),n=Ti[t.market]??r;return n==="sh"||n==="sz"?{code:e.replace(/^(sh|sz)/i,""),market:n}:n==="hk"?{code:e.replace(/^hk/i,"").padStart(5,"0"),market:n}:n==="us"?{code:e.replace(/^us/i,"").replace(/^\d{3}\./,"").toUpperCase(),market:n}:n==="global"?{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:n}:/^sh\d{6}$/i.test(e)?{code:e.slice(2),market:"sh"}:/^sz\d{6}$/i.test(e)?{code:e.slice(2),market:"sz"}:/^hk\d{5}$/i.test(e)?{code:e.slice(2),market:"hk"}:/^us[A-Z.]+$/i.test(e)?{code:e.slice(2).toUpperCase(),market:"us"}:{code:e,market:"unknown"}}function Ei(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Ci(t){let{code:e,market:r}=t;return(r==="sh"||r==="sz")&&Ei(e,r)?`https://quote.eastmoney.com/zs${e}.html`:r==="sh"||r==="sz"?`https://quote.eastmoney.com/${r}${e}.html`:r==="hk"?`https://quote.eastmoney.com/hk/${e}.html`:r==="us"?`https://quote.eastmoney.com/us/${e}.html`:r==="global"?`https://quote.eastmoney.com/gb/zs${Si[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function Oi(t){let{code:e,market:r}=t;return r==="sh"||r==="sz"?`https://xueqiu.com/S/${r.toUpperCase()}${e}`:r==="hk"?`https://xueqiu.com/S/${e}`:r==="us"?`https://xueqiu.com/S/${e}`:r==="global"?`https://xueqiu.com/S/${yi[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function _i(t){let e=Ri(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Ci(e)},{name:"\u96EA\u7403",url:Oi(e)}]}export{K as HttpError,ne as INDICATOR_REGISTRY,x as SdkError,dt as StockSDK,pt as addIndicators,ee as asyncPool,lt as buildIndicatorContext,re as calcATR,tt as calcBIAS,Xe as calcBOLL,rt as calcCCI,it as calcDMI,q as calcEMA,at as calcKC,Ze as calcKDJ,Ve as calcMA,We as calcMACD,nt as calcOBV,ot as calcROC,Je as calcRSI,st as calcSAR,W as calcSMA,fr as calcWMA,et as calcWR,J as chunkArray,Ne as decodeGBK,hi as default,ct as estimateIndicatorLookback,er as extractJsonFromJsonp,_i as generateSearchExternalLinks,Ie as getEnabledIndicatorKeys,G as getSdkErrorCode,M as jsonpRequest,Fe as parseResponse,h as safeNumber,C as safeNumberOrNull};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stock-sdk",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",