stock-sdk 1.9.1 → 1.9.2

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/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 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};
1
+ var Oo=Object.defineProperty;var Rt=(t,e)=>{for(var r in e)Oo(t,r,{get:e[r],enumerable:!0})};function Ue(t){return new TextDecoder("gbk").decode(t)}function Be(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 T(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 Et="https://qt.gtimg.cn",Ct="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Ot="https://assets.linkdiary.cn/shares/zh_a_list.json",At="https://assets.linkdiary.cn/shares/us_list.json",_t="https://assets.linkdiary.cn/shares/hk_list.json",It="https://assets.linkdiary.cn/shares/fund_list",Dr="https://assets.linkdiary.cn/shares/trade-data-list.txt";var Ke="https://push2his.eastmoney.com/api/qt/stock/kline/get",Pt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Dt="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",bt="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Mt="https://17.push2.eastmoney.com/api/qt/clist/get",Lt="https://91.push2.eastmoney.com/api/qt/stock/get",kt="https://29.push2.eastmoney.com/api/qt/clist/get",Nt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",xt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ft="https://79.push2.eastmoney.com/api/qt/clist/get",vt="https://91.push2.eastmoney.com/api/qt/stock/get",wt="https://29.push2.eastmoney.com/api/qt/clist/get",Ut="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Bt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Kt="https://datacenter-web.eastmoney.com/api/data/v1/get",ae="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",Ht="https://push2.eastmoney.com/api/qt/clist/get",qt="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",ue="https://push2ex.eastmoney.com",k="7eea3edcaed734bea9cbfc24409ed989",U="b2884a393a59ad64002292a3e90d46a5",le="https://push2his.eastmoney.com/api/qt/stock/kline/get",$t="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",ce="58b2fa8f54638b60b87d69b31969089c",zt={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},ee={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},He={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},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",Qt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",qe="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",jt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",Gt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",Yt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",Vt="https://futsseapi.eastmoney.com/list/option/221",Wt="https://datacenter-web.eastmoney.com/api/data/get";var $e={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"}},Xt=3e4,me=500,ge=500,fe=7,Zt=3,Jt=1e3,er=3e4,tr=2,rr=[408,429,500,502,503,504];var ze=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 br=["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"],nr=0;function Ao(){return typeof window<"u"&&typeof window.document<"u"}function Mr(){if(Ao())return;let t=br[nr];return nr=(nr+1)%br.length,t}var B=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)}},z=class extends B{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 B{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 _o(t,e){return he(t,{provider:e.provider,url:e.url})}function W(t){if(t instanceof B||t instanceof z)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 Qe(t,e={}){return t instanceof B?_o(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 B({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var te=class extends B{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},je=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 te;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 Io=3e4,Po=1,Lr=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],kr=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function Do(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Lr:t.includes("push2.eastmoney.com")?kr:[t]}function bo(t){return Array.from(new Set(t))}var Ge=class{constructor(e=Io,r=Po){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=Do(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 bo([...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=W(r),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let r=W(e);return r==="NETWORK_ERROR"||r==="TIMEOUT"?!0:e instanceof z?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([...Lr,...kr]);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 Mo(t){return{maxRetries:t?.maxRetries??Zt,baseDelay:t?.baseDelay??Jt,maxDelay:t?.maxDelay??er,backoffMultiplier:t?.backoffMultiplier??tr,retryableStatusCodes:t?.retryableStatusCodes??rr,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function Lo(t,e){let r={...t??{}};return e&&(Object.keys(r).some(o=>o.toLowerCase()==="user-agent")||(r["User-Agent"]=e)),r}function Nr(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 or(t={}){return{timeout:t.timeout??Xt,retry:Mo(t.retry),headers:Lo(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function xr(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??Et;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=or(r),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new Ge;for(let[n,o]of Object.entries(e.providerPolicies??{})){let i=Nr(r,o);this.providerPolicies[n]=or(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 ze(n.rateLimit):null,circuitBreaker:n.circuitBreaker?new je(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=W(e);return o==="TIMEOUT"?n.retryOnTimeout:o==="NETWORK_ERROR"?n.retryOnNetworkError:e instanceof z?n.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,r,n,o=0){try{return await e()}catch(i){let s=Qe(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=Mr();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 z(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=xr(e,r.provider),o=this.getProviderState(n);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new te("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=Qe(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 te("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=Ue(n);return Be(o)}};var ko=new Set(["daily","weekly","monthly"]),No=new Set(["1","5","15","30","60"]),xo=new Set(["","qfq","hfq"]);function Q(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function K(t){if(!ko.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function Se(t){if(!No.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function Y(t){if(!xo.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function re(t,e){Q(e,"chunkSize");let r=[];for(let n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}async function ne(t,e,r=!1){if(Q(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 oe(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function H(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function V(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var Ye=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}},Fr=new Map;function X(t,e){let r=Fr.get(t);if(r)return r;let n=new Ye(e);return Fr.set(t,n),n}var Fo=typeof document<"u"&&typeof window<"u",vo=0;function vr(){return`__stock_sdk_jsonp_${Date.now()}_${vo++}`}function ir(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 wo(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let u=vr(),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]},h=setTimeout(()=>{p||(p=!0,f(),s(new Error(`JSONP request timed out after ${r}ms: ${t}`)))},r);d[u]=S=>{p||(p=!0,clearTimeout(h),f(),i(S))},c.onerror=()=>{p||(p=!0,clearTimeout(h),f(),s(new Error(`JSONP script load failed: ${t}`)))},c.src=l,document.head.appendChild(c)})}async function Uo(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e,i=vr(),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 ir(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 N(t,e={}){return Fo?wo(t,e):Uo(t,e)}var A={CN:"Asia/Shanghai",HK:"Asia/Hong_Kong",US:"America/New_York"};function Bo(t){if(!t)return null;let e=t.trim();if(!e)return null;let r=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/.exec(e);if(r)return{year:+r[1],month:+r[2],day:+r[3],hour:+r[4],minute:+r[5],second:r[6]?+r[6]:0};let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return n?{year:+n[1],month:+n[2],day:+n[3],hour:0,minute:0,second:0}:/^\d{14}$/.test(e)?{year:+e.slice(0,4),month:+e.slice(4,6),day:+e.slice(6,8),hour:+e.slice(8,10),minute:+e.slice(10,12),second:+e.slice(12,14)}:/^\d{8}$/.test(e)?{year:+e.slice(0,4),month:+e.slice(4,6),day:+e.slice(6,8),hour:0,minute:0,second:0}:null}function wr(t,e){let r=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second),o=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(r)),i={};for(let c of o)c.type!=="literal"&&(i[c.type]=c.value);let s=parseInt(i.hour??"0",10);s===24&&(s=0);let u=Date.UTC(parseInt(i.year??"0",10),parseInt(i.month??"1",10)-1,parseInt(i.day??"1",10),s,parseInt(i.minute??"0",10),parseInt(i.second??"0",10)),l=r-u;return r+l}function Ko(t,e){let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec((t||"").trim());if(!r)return null;let n=/^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec((e||"").trim());return n?{year:+r[1],month:+r[2],day:+r[3],hour:+n[1],minute:+n[2],second:n[3]?+n[3]:0}:null}function Ur(t,e){let r=Bo(t);return r?wr(r,e):NaN}function M(t,e){return{timestamp:Ur(t,e),tz:e}}function sr(t,e,r){let n=Ko(t,e);return n?{timestamp:wr(n,r),tz:r}:{timestamp:NaN,tz:r}}var I={};Rt(I,{getAShareCodeList:()=>Qr,getAllHKQuotesByCodes:()=>Vr,getAllQuotesByCodes:()=>Yr,getAllUSQuotesByCodes:()=>Wr,getFullQuotes:()=>Ve,getFundCodeList:()=>Xr,getFundFlow:()=>Kr,getFundQuotes:()=>qr,getHKCodeList:()=>Gr,getHKQuotes:()=>We,getPanelLargeOrder:()=>Hr,getSimpleQuotes:()=>Br,getTodayTimeline:()=>$r,getTradingCalendar:()=>Zr,getUSCodeList:()=>jr,getUSQuotes:()=>Xe,parseFullQuote:()=>ar,parseFundFlow:()=>lr,parseFundQuote:()=>mr,parseHKQuote:()=>pr,parsePanelLargeOrder:()=>cr,parseSimpleQuote:()=>ur,parseUSQuote:()=>dr,search:()=>en});function ar(t){let e=[];for(let i=0;i<5;i++)e.push({price:T(t[9+i*2]),volume:T(t[10+i*2])});let r=[];for(let i=0;i<5;i++)r.push({price:T(t[19+i*2]),volume:T(t[20+i*2])});let n=t[30]??"",o=M(n,A.CN);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:T(t[3]),prevClose:T(t[4]),open:T(t[5]),volume:T(t[6]),outerVolume:T(t[7]),innerVolume:T(t[8]),bid:e,ask:r,time:n,timestamp:o.timestamp,tz:o.tz,change:T(t[31]),changePercent:T(t[32]),high:T(t[33]),low:T(t[34]),volume2:T(t[36]),amount:T(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 ur(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:T(t[3]),change:T(t[4]),changePercent:T(t[5]),volume:T(t[6]),amount:T(t[7]),marketCap:C(t[9]),marketType:t[10]??"",raw:t}}function lr(t){let e=t[13]??"",r=M(e,A.CN);return{code:t[0]??"",mainInflow:T(t[1]),mainOutflow:T(t[2]),mainNet:T(t[3]),mainNetRatio:T(t[4]),retailInflow:T(t[5]),retailOutflow:T(t[6]),retailNet:T(t[7]),retailNetRatio:T(t[8]),totalFlow:T(t[9]),name:t[12]??"",date:e,timestamp:r.timestamp,tz:r.tz,raw:t}}function cr(t){return{buyLargeRatio:T(t[0]),buySmallRatio:T(t[1]),sellLargeRatio:T(t[2]),sellSmallRatio:T(t[3]),raw:t}}function pr(t){let e=t[30]??"",r=M(e,A.HK);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:T(t[3]),prevClose:T(t[4]),open:T(t[5]),volume:T(t[6]),time:e,timestamp:r.timestamp,tz:r.tz,change:T(t[31]),changePercent:T(t[32]),high:T(t[33]),low:T(t[34]),amount:T(t[37]),lotSize:C(t[40]),circulatingMarketCap:C(t[44]),totalMarketCap:C(t[45]),currency:t[t.length-3]??"",raw:t}}function dr(t){let e=t[30]??"",r=M(e,A.US);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:T(t[3]),prevClose:T(t[4]),open:T(t[5]),volume:T(t[6]),time:e,timestamp:r.timestamp,tz:r.tz,change:T(t[31]),changePercent:T(t[32]),high:T(t[33]),low:T(t[34]),amount:T(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 mr(t){let e=t[8]??"",r=M(e,A.CN);return{code:t[0]??"",name:t[1]??"",nav:T(t[5]),accNav:T(t[6]),change:T(t[7]),navDate:e,timestamp:r.timestamp,tz:r.tz,raw:t}}async function Ve(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=>ar(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=>ur(o.fields))}async function Kr(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=>lr(o.fields))}async function Hr(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=>cr(o.fields))}async function We(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=>pr(o.fields))}async function Xe(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=>dr(o.fields))}async function qr(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=>mr(o.fields))}async function $r(t,e){let r=t.getTimeout(),n=new AbortController,o=setTimeout(()=>n.abort(),r);try{let i=await fetch(`${Ct}?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){let g=M("",A.CN);return{code:e,date:"",timestamp:g.timestamp,tz:g.tz,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 g=l[0].split(" "),R=parseFloat(g[1])||0,E=parseInt(g[2],10)||0,P=parseFloat(g[3])||0;E>0&&R>0&&P/E>R*50&&(f=!0)}let h=l.map(g=>{let R=g.split(" "),E=R[0],P=`${E.slice(0,2)}:${E.slice(2,4)}`,D=parseInt(R[2],10)||0,b=parseFloat(R[3])||0,x=f?D*100:D,j=x>0?b/x:0,w=sr(c,P,A.CN);return{time:P,timestamp:w.timestamp,tz:w.tz,price:parseFloat(R[1])||0,volume:x,amount:b,avgPrice:Math.round(j*100)/100}}),S=M(c,A.CN);return{code:e,date:c,timestamp:S.timestamp,tz:S.tz,preClose:d,data:h}}finally{clearTimeout(o)}}var zr=X("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function gr(t,e,r){return zr.getOrFetch(e,async()=>(await t.get(r,{responseType:"json"}))?.list||[])}function Ho(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 Qr(t,e){let r=!1,n;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,n=e.market);let i=await gr(t,"a-share:full",Ot);return n&&(i=i.filter(s=>Ho(s,n))),r?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var qo={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function jr(t,e){let r=!1,n;typeof e=="boolean"?r=!e:e&&(r=e.simple??!1,n=e.market);let i=(await gr(t,"us:full",At)).slice();if(n){let s=qo[n];i=i.filter(u=>u.startsWith(s))}return r?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function Gr(t){return(await gr(t,"hk:full",_t)).slice()}async function Yr(t,e,r={}){let{batchSize:n=me,concurrency:o=fe,onProgress:i}=r;Q(n,"batchSize"),Q(o,"concurrency");let s=Math.min(n,ge),u=re(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let h=await Ve(t,f);return c++,i&&i(c,l),h});return(await ne(p,o,!0)).flat()}async function Vr(t,e,r={}){let{batchSize:n=me,concurrency:o=fe,onProgress:i}=r;Q(n,"batchSize"),Q(o,"concurrency");let s=Math.min(n,ge),u=re(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let h=await We(t,f);return c++,i&&i(c,l),h});return(await ne(p,o,!0)).flat()}async function Wr(t,e,r={}){let{batchSize:n=me,concurrency:o=fe,onProgress:i}=r;Q(n,"batchSize"),Q(o,"concurrency");let s=Math.min(n,ge),u=re(e,s),l=u.length,c=0,p=u.map(f=>async()=>{let h=await Xe(t,f);return c++,i&&i(c,l),h});return(await ne(p,o,!0)).flat()}async function Xr(t){return(await zr.getOrFetch("fund:full",async()=>(await t.get(It,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var $o=X("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function Zr(t){return(await $o.getOrFetch("a-share",async()=>{let r=await t.get(Dr);return!r||r.trim()===""?[]:r.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0)})).slice()}var Jr="https://smartbox.gtimg.cn/s3/";function zo(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function Qo(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 jo(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(r=>{let n=r.split("~"),o=n[0]||"",i=n[1]||"",s=zo(n[2]||""),u=n[4]||"";return{code:o+i,name:s,market:o,type:u,category:Qo(u)}})}function Go(t){return new Promise((e,r)=>{let n=`${Jr}?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 Yo(t,e){let r=`${Jr}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(r)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function Vo(){return typeof window<"u"&&typeof document<"u"}async function en(t,e){if(!e||!e.trim())return[];let r;return Vo()?r=await Go(e):r=await Yo(t,e),jo(r)}var y={};Rt(y,{extractVariety:()=>Tr,fetchDatacenter:()=>hr,fetchDatacenterList:()=>O,getBlockTradeDailyStat:()=>uo,getBlockTradeDetail:()=>ao,getBlockTradeMarketStat:()=>so,getBoardChanges:()=>Xn,getCFFEXOptionQuotes:()=>Pn,getComexInventory:()=>kn,getConceptConstituents:()=>Sn,getConceptKline:()=>Rn,getConceptList:()=>Tn,getConceptMinuteKline:()=>En,getConceptSpot:()=>yn,getDividendDetail:()=>Cn,getDragonTigerBranchRank:()=>ro,getDragonTigerDetail:()=>Jn,getDragonTigerInstitution:()=>to,getDragonTigerStockSeatDetail:()=>no,getDragonTigerStockStats:()=>eo,getFundFlowRank:()=>Bn,getFuturesHistoryKline:()=>An,getFuturesInventory:()=>Ln,getFuturesInventorySymbols:()=>Mn,getFuturesMarketCode:()=>yr,getGlobalFuturesKline:()=>In,getGlobalFuturesSpot:()=>_n,getHKHistoryKline:()=>nn,getHistoryKline:()=>tn,getIndividualFundFlow:()=>wn,getIndustryConstituents:()=>gn,getIndustryKline:()=>fn,getIndustryList:()=>dn,getIndustryMinuteKline:()=>hn,getIndustrySpot:()=>mn,getMarginAccountInfo:()=>lo,getMarginTargetList:()=>co,getMarketFundFlow:()=>Un,getMinuteKline:()=>rn,getNorthboundFlowSummary:()=>Qn,getNorthboundHistory:()=>Gn,getNorthboundHoldingRank:()=>jn,getNorthboundIndividual:()=>Yn,getNorthboundMinute:()=>zn,getOptionLHB:()=>Dn,getSectorFundFlowHistory:()=>Hn,getSectorFundFlowRank:()=>Kn,getStockChanges:()=>Wn,getUSHistoryKline:()=>on,getZTPool:()=>Vn});async function fr(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 h=f.diff.map((S,g)=>i(S,s.length+g+1));s.push(...h),u++}while(s.length<l);return s}function q(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 $(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 tn(t,e,r={}){let{period:n="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=r;K(n),Y(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${oe(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:k,klt:H(n),fqt:V(o),secid:l,beg:i,end:s}),p=Ke,{klines:d}=await $(t,p,c);return d.length===0?[]:d.map(f=>{let h=q(f),S=M(h.date,A.CN);return{...h,timestamp:S.timestamp,tz:S.tz,code:u}})}async function rn(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),Y(o);let u=e.replace(/^(sh|sz|bj)/,""),l=`${oe(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:k,ndays:"5",iscr:"0",secid:l}),p=`${Pt}?${c.toString()}`,f=(await t.get(p,{responseType:"json"}))?.data?.trends;if(!Array.isArray(f)||f.length===0)return[];let h=i.replace("T"," ").slice(0,16),S=s.replace("T"," ").slice(0,16);return f.map(g=>{let[R,E,P,D,b,x,j,w]=g.split(","),we=M(R,A.CN);return{time:R,timestamp:we.timestamp,tz:we.tz,open:m(E),close:m(P),high:m(D),low:m(b),volume:m(x),amount:m(j),avgPrice:m(w)}}).filter(g=>g.time>=h&&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:k,klt:n,fqt:V(o||""),secid:l,beg:"0",end:"20500000"}),p=Ke,{klines:d}=await $(t,p,c);if(d.length===0)return[];let f=i.replace("T"," ").slice(0,16),h=s.replace("T"," ").slice(0,16);return d.map(S=>{let g=q(S),R=M(g.date,A.CN);return{...g,time:g.date,timestamp:R.timestamp,tz:R.tz}}).filter(S=>S.time>=f&&S.time<=h)}}function Ze(t){return async function(r,n,o={}){let{period:i="daily",adjust:s="qfq",startDate:u="19700101",endDate:l="20500101"}=o;K(i),Y(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:k,klt:H(i),fqt:V(s),secid:c.secid,beg:u,end:l,lmt:"1000000"}),{klines:d,name:f,code:h}=await $(r,t.url,p);if(d.length===0)return[];let S=t.resolveResultMeta?t.resolveResultMeta(n,c,{code:h,name:f}):{code:h||c.fallbackCode,name:f||""};return d.map(g=>{let R=q(g),E=M(R.date,t.tz),P={...R,timestamp:E.timestamp,tz:E.tz,code:S.code,name:S.name};return t.enrichItem(P)})}}var Wo=Ze({url:Dt,tz:A.HK,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}},enrichItem:t=>({...t,currency:"HKD",lotSize:null})});async function nn(t,e,r={}){return Wo(t,e,r)}var Xo=Ze({url:bt,tz:A.US,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,r)=>({code:r.code||e.fallbackCode,name:r.name||""}),enrichItem:t=>({...t,currency:"USD"})});async function on(t,e,r={}){return Xo(t,e,r)}function sn(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 an(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 fr(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 un(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 ln(t,e,r){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return fr(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 cn(t,e,r,n={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:u="20500101"}=n;K(o),Y(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:H(o),fqt:V(i),beg:s,end:u,smplmt:"10000",lmt:"1000000"}),{klines:c}=await $(t,r,l);return c.length===0?[]:c.map(p=>q(p))}async function pn(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,h,S,g,R,E,P]=p.split(","),D=m(P);return{time:d,open:m(f),close:m(h),high:m(S),low:m(g),volume:m(R),amount:m(E),price:D,avgPrice:D}})}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,h,S,g,R,E,P,D,b,x]=p.split(",");return{time:d,open:m(f),close:m(h),high:m(S),low:m(g),changePercent:m(D),change:m(b),volume:m(R),amount:m(E),amplitude:m(P),turnoverRate:m(x)}})}}function Je(t){let e=sn(t);async function r(o){return an(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 un(o,s,t.spotUrl)},async getConstituents(o,i){let s=await n(o,i);return ln(o,s,t.consUrl)},async getKline(o,i,s={}){let u=await n(o,i);return cn(o,u,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let u=await n(o,i);return pn(o,u,t.klineUrl,t.trendsUrl,s)}}}var Zo={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Mt,spotUrl:Lt,consUrl:kt,klineUrl:Nt,trendsUrl:xt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},Re=Je(Zo);async function dn(t){return Re.getList(t)}async function mn(t,e){return Re.getSpot(t,e)}async function gn(t,e){return Re.getConstituents(t,e)}async function fn(t,e,r={}){return Re.getKline(t,e,r)}async function hn(t,e,r={}){return Re.getMinuteKline(t,e,r)}var Jo={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Ft,spotUrl:vt,consUrl:wt,klineUrl:Ut,trendsUrl:Bt,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},Ee=Je(Jo);async function Tn(t){return Ee.getList(t)}async function yn(t,e){return Ee.getSpot(t,e)}async function Sn(t,e){return Ee.getConstituents(t,e)}async function Rn(t,e,r={}){return Ee.getKline(t,e,r)}async function En(t,e,r={}){return Ee.getMinuteKline(t,e,r)}async function hr(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:h,extraParams:S}=e,g=[],R=c,E=1,P=0,D=0;do{let b=new URLSearchParams({reportName:n,columns:o,pageSize:String(l),pageNumber:String(R),source:"WEB",client:"WEB"});if(i&&b.set("filter",i),s&&b.set("sortColumns",s),u&&b.set("sortTypes",u),f&&b.set("quoteColumns",f),h&&b.set("quoteType",h),S)for(let[yt,St]of Object.entries(S))b.set(yt,St);let x=`${Kt}?${b.toString()}`,w=(await t.get(x,{responseType:"json"}))?.result;if(!w||!Array.isArray(w.data))break;R===c&&(E=w.pages??1,P=w.count??w.data.length);let we=w.data.map((yt,St)=>r(yt,g.length+St));if(g.push(...we),R++,D++,!p)break}while(R<=E&&D<d);return p&&D>=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:P,pages:E}}async function O(t,e,r){return(await hr(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 ei(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 Cn(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=>ei(n))}function Tr(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function On(t){return ee[t]??ee[t.toLowerCase()]??ee[t.toUpperCase()]}function yr(t){let e=On(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=On(t.slice(0,-1))),!e){let n=Object.keys(ee).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${n}`)}let r=zt[e];if(r===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return r}function ti(t){let e=q(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}async function An(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;K(n);let s=Tr(e),l=`${yr(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:k,klt:H(n),fqt:"0",secid:l,beg:o,end:i}),{klines:p,name:d,code:f}=await $(t,le,c);return p.length===0?[]:p.map(h=>({...ti(h),code:f||e,name:d||""}))}async function _n(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=`${$t}?${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(ri);n.push(...c),o++}while(n.length<i);return n}function ri(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 ni(t){let e=q(t),r=t.split(",");return{...e,openInterest:r.length>12?m(r[12]):null}}function oi(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function In(t,e,r={}){let{period:n="daily",startDate:o="19700101",endDate:i="20500101"}=r;K(n);let s=r.marketCode;if(s===void 0){let f=oi(e);if(s=He[f],s===void 0){let h=Object.keys(He).join(", ");throw new RangeError(`Unknown global futures variety: "${f}". Supported: ${h}. 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:k,klt:H(n),fqt:"0",secid:u,beg:o,end:i}),{klines:c,name:p,code:d}=await $(t,le,l);return c.length===0?[]:c.map(f=>({...ni(f),code:d||e,name:p||""}))}async function Pn(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=`${Vt}?${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 ii(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function Dn(t,e,r){let n=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:U,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${r}')`}),o=`${Wt}?${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:ii(String(l.TRADE_TYPE??""))}))}var si={gold:"EMI00069026",silver:"EMI00069027"};function bn(t){if(!t)return"";let e=String(t),r=e.match(/^(\d{4}-\d{2}-\d{2})/);return r?r[1]:e}async function Mn(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 Ln(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:bn(s.TRADE_DATE),inventory:a(s.ON_WARRANT_NUM),change:a(s.ADDCHANGE)}))}async function kn(t,e,r={}){let n=si[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:bn(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 Nn={daily:"101",weekly:"102",monthly:"103"},Sr="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function xn(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 ai(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 Fn={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"}},ui={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},li="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 vn(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=`${Ht}?${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 wn(t,e,r={}){let{period:n="daily"}=r,o=Nn[n];if(!o)throw new RangeError(`Invalid period: ${n}. Must be daily/weekly/monthly.`);let i=e.replace(/^(sh|sz|bj)/i,""),s=`${oe(e)}.${i}`,u=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:Sr,ut:U}),l=`${ae}?${u.toString()}`,p=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(p)||p.length===0?[]:p.map(xn)}async function Un(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:Sr,ut:U}),r=`${ae}?${e.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(ai)}async function Bn(t,e={}){let{indicator:r="today"}=e,n=Fn[r];if(!n)throw new RangeError(`Invalid indicator: ${r}.`);let o={fid:n.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:U,fs:li,fields:n.fields};return(await vn(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 Kn(t,e={}){let{indicator:r="today",sectorType:n="industry"}=e,o=Fn[r];if(!o)throw new RangeError(`Invalid indicator: ${r}.`);let i=ui[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:U,fs:i,fields:s};return(await vn(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 Hn(t,e,r={}){let{period:n="daily"}=r,o=Nn[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:Sr,ut:U}),u=`${ae}?${s.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(xn)}var ci={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},pi={shanghai:"001",shenzhen:"003"};function qn(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 zn(t,e="north"){let r=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:U}),n=`${qt}?${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=>qn(p,$n(c)))}let s=i.s2n??[],u=i.s2nDate??"";return s.map(l=>qn(l,$n(u)))}function $n(t){return t?/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t:""}async function Qn(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 jn(t,e={}){let{market:r="all",period:n="5day",date:o}=e,i=ci[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="${pi[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 Gn(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 Yn(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 di={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"}},mi={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"},gi={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 Rr(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 fi(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function hi(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?Rr(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?Rr(t.lbt):null,boardAmount:a(t.fund),sealAmount:a(t.fund),failedCount:a(t.zbc),industry:String(t.hybk??""),ztStatistics:fi(t.zttj),amplitude:a(t.zf),speed:a(t.zs)}}function Ti(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function yi(){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 Vn(t,e="zt",r){let n=di[e];if(!n)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=Ti(r)??yi(),i=new URLSearchParams({ut:k,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(hi)}async function Wn(t,e="large_buy"){let r=mi[e];if(!r)throw new RangeError(`Invalid StockChangeType: ${e}.`);let n=new URLSearchParams({type:r,pageindex:"0",pagesize:"5000",ut:k,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:Rr(u.tm),code:String(u.c??""),name:String(u.n??""),changeType:e,changeTypeLabel:gi[l]??"",info:String(u.i??"")}})}async function Xn(t){let e=new URLSearchParams({ut:k,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 Zn={"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 Jn(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 eo(t,e="1month"){let r=Zn[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 to(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 ro(t,e="1month"){let r=Zn[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 no(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 oo(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function io(t){if(!t)return"";let e=oo(t.startDate),r=oo(t.endDate),n=[];return e&&n.push(`(TRADE_DATE>='${e}')`),r&&n.push(`(TRADE_DATE<='${r}')`),n.join("")}async function so(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 ao(t,e={}){let r=io(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 uo(t,e={}){let r=io(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 lo(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 co(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 v={};Rt(v,{getCommodityOptionKline:()=>Eo,getCommodityOptionSpot:()=>Ro,getETFOption5DayMinute:()=>So,getETFOptionDailyKline:()=>yo,getETFOptionExpireDay:()=>fo,getETFOptionMinute:()=>To,getETFOptionMonths:()=>go,getIndexOptionKline:()=>mo,getIndexOptionSpot:()=>po});function Si(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 Ri(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 po(t,e){let r=`${pe}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,n=await N(r),o=n?.result?.data?.up??[],i=n?.result?.data?.down??[];return{calls:o.map(Si),puts:i.map(Ri)}}async function mo(t){let e=`${de}?symbol=${t}`,r=await N(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 go(t){let e=`${Qt}?exchange=null&cate=${encodeURIComponent(t)}`,n=(await N(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 fo(t,e){let r=`${qe}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,n=await N(r),o=n?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let s=`${qe}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;n=await N(s)}let i=n?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function ho(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 To(t){let e=`CON_OP_${t}`,r=`${jt}?symbol=${e}`,o=(await N(r))?.result?.data;return Array.isArray(o)?ho(o):[]}async function yo(t){let e=`CON_OP_${t}`,r=`${Gt}?symbol=${e}`,n=await N(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 So(t){let e=`CON_OP_${t}`,r=`${Yt}?symbol=${e}`,o=(await N(r))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...ho(s));return i}function Ei(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 Ro(t,e){let r=$e[t];if(!r)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys($e).join(", ")}`);let n=`${pe}?type=futures&product=${r.product}&exchange=${r.exchange}&pinzhong=${e}`,o=await N(n),i=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:i.map(Ei),puts:s.map(Ci)}}async function Eo(t){let e=`${de}?symbol=${t}`,r=await N(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 I.getFullQuotes(this.client,e)}getSimpleQuotes(e){return I.getSimpleQuotes(this.client,e)}getHKQuotes(e){return I.getHKQuotes(this.client,e)}getUSQuotes(e){return I.getUSQuotes(this.client,e)}getFundQuotes(e){return I.getFundQuotes(this.client,e)}getFundFlow(e){return I.getFundFlow(this.client,e)}getPanelLargeOrder(e){return I.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return I.getTodayTimeline(this.client,e)}search(e){return I.search(this.client,e)}getAShareCodeList(e){return I.getAShareCodeList(this.client,e)}getUSCodeList(e){return I.getUSCodeList(this.client,e)}getHKCodeList(){return I.getHKCodeList(this.client)}getFundCodeList(){return I.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:r,...n}=e,o=await this.getAShareCodeList({market:r});return I.getAllQuotesByCodes(this.client,o,n)}async getAllHKShareQuotes(e={}){let r=await this.getHKCodeList();return I.getAllHKQuotesByCodes(this.client,r,e)}async getAllUSShareQuotes(e={}){let{market:r,...n}=e,o=await this.getUSCodeList({simple:!0,market:r});return I.getAllUSQuotesByCodes(this.client,o,n)}getAllQuotesByCodes(e,r={}){return I.getAllQuotesByCodes(this.client,e,r)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return I.getTradingCalendar(this.client)}getDividendDetail(e){return y.getDividendDetail(this.client,e)}};var Ae=class extends _{constructor(e){super(e)}getIndustryList(){return y.getIndustryList(this.client)}getIndustrySpot(e){return y.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return y.getIndustryConstituents(this.client,e)}getIndustryKline(e,r){return y.getIndustryKline(this.client,e,r)}getIndustryMinuteKline(e,r){return y.getIndustryMinuteKline(this.client,e,r)}getConceptList(){return y.getConceptList(this.client)}getConceptSpot(e){return y.getConceptSpot(this.client,e)}getConceptConstituents(e){return y.getConceptConstituents(this.client,e)}getConceptKline(e,r){return y.getConceptKline(this.client,e,r)}getConceptMinuteKline(e,r){return y.getConceptMinuteKline(this.client,e,r)}};var _e=class extends _{constructor(e){super(e)}getHistoryKline(e,r){return y.getHistoryKline(this.client,e,r)}getMinuteKline(e,r){return y.getMinuteKline(this.client,e,r)}getHKHistoryKline(e,r){return y.getHKHistoryKline(this.client,e,r)}getUSHistoryKline(e,r){return y.getUSHistoryKline(this.client,e,r)}};var Ie=class extends _{constructor(e){super(e)}getFuturesKline(e,r){return y.getFuturesHistoryKline(this.client,e,r)}getGlobalFuturesSpot(e){return y.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,r){return y.getGlobalFuturesKline(this.client,e,r)}getFuturesInventorySymbols(){return y.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,r){return y.getFuturesInventory(this.client,e,r)}getComexInventory(e,r){return y.getComexInventory(this.client,e,r)}};var Pe=class extends _{constructor(e){super(e)}getIndexOptionSpot(e,r){return v.getIndexOptionSpot(e,r)}getIndexOptionKline(e){return v.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return y.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return v.getETFOptionMonths(e)}getETFOptionExpireDay(e,r){return v.getETFOptionExpireDay(e,r)}getETFOptionMinute(e){return v.getETFOptionMinute(e)}getETFOptionDailyKline(e){return v.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return v.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,r){return v.getCommodityOptionSpot(e,r)}getCommodityOptionKline(e){return v.getCommodityOptionKline(e)}getOptionLHB(e,r){return y.getOptionLHB(this.client,e,r)}};function De(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function J(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 G(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 Er(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 et(t,e={}){let{periods:r=[5,10,20,30,60,120,250],type:n="sma"}=e,o=n==="ema"?G:n==="wma"?Er:J,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 tt(t,e={}){let{short:r=12,long:n=26,signal:o=9}=e,i=G(t,r),s=G(t,n),u=t.map((c,p)=>i[p]===null||s[p]===null?null:i[p]-s[p]),l=G(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 Cr(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function Oi(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 rt(t,e={}){let{period:r=20,stdDev:n=2}=e,o=J(t,r),i=Oi(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?Cr((l-c)/o[u]*100):null;return{mid:o[u],upper:Cr(l),lower:Cr(c),bandwidth:p}})}function Or(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function nt(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 h=(f-p)/(c-p)*100;s=(n-1)/n*s+1/n*h,u=(o-1)/o*u+1/o*s;let S=3*s-2*u;i.push({k:Or(s),d:Or(u),j:Or(S)})}return i}function Ai(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function ot(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(Ai(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 _i(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function it(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(_i(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 Ii(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function st(t,e={}){let{periods:r=[6,12,24]}=e,n={};for(let o of r){let i=J(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(Ii(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 Pi(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function at(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:Pi(d)})}}return n}function Ar(t,e=2){let r=Math.pow(10,e);return Math.round(t*r)/r}function ie(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),h=Math.abs(l-p);o.push(Math.max(d,f,h))}}}let i=null;for(let s=0;s<t.length;s++){if(s<r-1){n.push({tr:o[s]!==null?Ar(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?Ar(o[s]):null,atr:i!==null?Ar(i):null})}return n}function ut(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 lt(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 ct(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 P=R.high-R.low,D=Math.abs(R.high-E.close),b=Math.abs(R.low-E.close);u.push(Math.max(P,D,b));let x=R.high-E.high,j=E.low-R.low;x>j&&x>0?i.push(x):i.push(0),j>x&&j>0?s.push(j):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 P=R+E,D=P>0?Math.abs(R-E)/P*100:0;d.push(D)}let f=0,h=0,S=0;for(let g=r;g<t.length;g++){if(g<r*2-1){f+=d[g-r+1]||0,h++;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 pt(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 h=t[f],S=t[f-1];if(h.high===null||h.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),h.low<g?(s=-1,g=l,l=h.low,u=r):h.high>l&&(l=h.high,u=Math.min(u+n,o))):(g=Math.max(g,S.high,t[Math.max(0,f-2)]?.high??S.high),h.high>g?(s=1,g=l,l=h.high,u=r):h.low<l&&(l=h.low,u=Math.min(u+n,o))),c=g,i.push({sar:c,trend:s,ep:l,af:u})}return i}function dt(t,e={}){let{emaPeriod:r=20,atrPeriod:n=10,multiplier:o=2}=e,i=[],s=t.map(c=>c.close),u=G(s,r),l=ie(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,h=p-o*d,S=p>0?(f-h)/p*100:null;i.push({mid:p,upper:f,lower:h,width:S})}return i}function mt(t,e=0){return t.length===0?e:Math.max(...t)}function gt(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 se={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:mt(r,20),emaBased:n==="ema"}},compute:(t,e)=>et(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)=>tt(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>rt(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>nt(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:mt(e,14)+1}},compute:(t,e)=>ot(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:mt(e,10)}},compute:(t,e)=>it(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:mt(e,12)}},compute:(t,e)=>st(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>at(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>ie(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)=>ut(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)=>lt(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)=>ct(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>pt(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)=>dt(t.ohlcv,typeof e=="object"?e:{})}};function be(t){return Object.keys(se).filter(e=>!!t[e])}function ft(t){let e=0,r=!1;for(let o of be(t)){let s=se[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 ht(t,e={}){if(t.length===0)return[];let r=gt(t),n=new Map;for(let o of be(e)){let i=se[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 Me=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}=ft(i),l={A:1.5,HK:1.46,US:1.45},c;if(n)if(s==="A")try{let h=await this.quoteService.getTradingCalendar();c=this.calcActualStartDateByCalendar(n,u,h)??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=ht(d,i);if(n){let h=this.dateToTimestamp(n),S=o?this.dateToTimestamp(o):1/0;return f.filter(g=>{let R=this.dateToTimestamp(g.date);return R>=h&&R<=S})}return f}};var Le=class extends _{constructor(e){super(e)}getIndividualFundFlow(e,r){return y.getIndividualFundFlow(this.client,e,r)}getMarketFundFlow(){return y.getMarketFundFlow(this.client)}getFundFlowRank(e){return y.getFundFlowRank(this.client,e)}getSectorFundFlowRank(e){return y.getSectorFundFlowRank(this.client,e)}getSectorFundFlowHistory(e,r){return y.getSectorFundFlowHistory(this.client,e,r)}};var ke=class extends _{constructor(e){super(e)}getNorthboundMinute(e){return y.getNorthboundMinute(this.client,e)}getNorthboundFlowSummary(){return y.getNorthboundFlowSummary(this.client)}getNorthboundHoldingRank(e){return y.getNorthboundHoldingRank(this.client,e)}getNorthboundHistory(e,r){return y.getNorthboundHistory(this.client,e,r)}getNorthboundIndividual(e,r){return y.getNorthboundIndividual(this.client,e,r)}};var Ne=class extends _{constructor(e){super(e)}getZTPool(e,r){return y.getZTPool(this.client,e,r)}getStockChanges(e){return y.getStockChanges(this.client,e)}getBoardChanges(){return y.getBoardChanges(this.client)}};var xe=class extends _{constructor(e){super(e)}getDragonTigerDetail(e){return y.getDragonTigerDetail(this.client,e)}getDragonTigerStockStats(e){return y.getDragonTigerStockStats(this.client,e)}getDragonTigerInstitution(e){return y.getDragonTigerInstitution(this.client,e)}getDragonTigerBranchRank(e){return y.getDragonTigerBranchRank(this.client,e)}getDragonTigerStockSeatDetail(e,r){return y.getDragonTigerStockSeatDetail(this.client,e,r)}};var Fe=class extends _{constructor(e){super(e)}getBlockTradeMarketStat(){return y.getBlockTradeMarketStat(this.client)}getBlockTradeDetail(e){return y.getBlockTradeDetail(this.client,e)}getBlockTradeDailyStat(e){return y.getBlockTradeDailyStat(this.client,e)}getMarginAccountInfo(){return y.getMarginAccountInfo(this.client)}getMarginTargetList(e){return y.getMarginTargetList(this.client,e)}};var F=(t,e)=>t*60+e,Di={A:{tz:A.CN,open:[[F(9,30),F(11,30)],[F(13,0),F(15,0)]],lunchBreak:[F(11,30),F(13,0)],tradingWeekdays:[1,2,3,4,5]},HK:{tz:A.HK,open:[[F(9,30),F(12,0)],[F(13,0),F(16,0)]],lunchBreak:[F(12,0),F(13,0)],tradingWeekdays:[1,2,3,4,5]},US:{tz:A.US,open:[[F(9,30),F(16,0)]],tradingWeekdays:[1,2,3,4,5]}};function _r(t,e){if(t==null)return Ir(new Date,e);if(t instanceof Date)return Ir(t,e);let r=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(r))return r;if(/^\d{8}$/.test(r))return`${r.slice(0,4)}-${r.slice(4,6)}-${r.slice(6,8)}`;let n=new Date(r);if(!Number.isNaN(n.getTime()))return Ir(n,e);throw new RangeError(`Unsupported date input: ${JSON.stringify(t)}. Expected 'YYYY-MM-DD', 'YYYYMMDD', or Date.`)}function Ir(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(t)}function bi(t,e){let r=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,weekday:"short",hour:"2-digit",minute:"2-digit"}),n={};for(let l of r.formatToParts(t))l.type!=="literal"&&(n[l.type]=l.value);let o=parseInt(n.hour??"0",10);o===24&&(o=0);let i=parseInt(n.minute??"0",10),u={Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6,Sun:7}[n.weekday??""]??0;return{minutes:o*60+i,weekday:u}}function Pr(t,e){let r=0,n=t.length;for(;r<n;){let o=r+n>>>1;t[o]<e?r=o+1:n=o}return r}var ve=class{constructor(e){this.quoteService=e}async isTradingDay(e){let r=_r(e,A.CN),n=await this.quoteService.getTradingCalendar(),o=Pr(n,r);return o<n.length&&n[o]===r}async nextTradingDay(e){let r=_r(e,A.CN),n=await this.quoteService.getTradingCalendar(),o=Pr(n,r);if(o<n.length&&n[o]===r&&(o+=1),o>=n.length)throw new RangeError(`nextTradingDay: ${r} \u4E4B\u540E\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5927\u65E5\u671F ${n[n.length-1]??"N/A"})`);return n[o]}async prevTradingDay(e){let r=_r(e,A.CN),n=await this.quoteService.getTradingCalendar(),i=Pr(n,r)-1;if(i<0)throw new RangeError(`prevTradingDay: ${r} \u4E4B\u524D\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5C0F\u65E5\u671F ${n[0]??"N/A"})`);return n[i]}getMarketStatus(e="A",r=new Date){let n=Di[e],{minutes:o,weekday:i}=bi(r,n.tz);if(!n.tradingWeekdays.includes(i))return"closed";let s=n.open[0][0],u=n.open[n.open.length-1][1];if(o<s)return"pre_market";if(o>=u)return"after_hours";for(let[l,c]of n.open)if(o>=l&&o<c)return"open";return n.lunchBreak&&o>=n.lunchBreak[0]&&o<n.lunchBreak[1]?"lunch_break":"closed"}};var Tt=class{constructor(e={}){this.client=new ye(e),this.quoteService=new Oe(this.client),this.boardService=new Ae(this.client),this.klineService=new _e(this.client),this.futuresService=new Ie(this.client),this.optionsService=new Pe(this.client),this.indicatorService=new Me(this.klineService,this.quoteService),this.fundFlowService=new Le(this.client),this.northboundService=new ke(this.client),this.marketEventService=new Ne(this.client),this.dragonTigerService=new xe(this.client),this.dataService=new Fe(this.client),this.tradingCalendarService=new ve(this.quoteService)}getFullQuotes(e){return this.quoteService.getFullQuotes(e)}getSimpleQuotes(e){return this.quoteService.getSimpleQuotes(e)}getHKQuotes(e){return this.quoteService.getHKQuotes(e)}getUSQuotes(e){return this.quoteService.getUSQuotes(e)}getFundQuotes(e){return this.quoteService.getFundQuotes(e)}getFundFlow(e){return this.quoteService.getFundFlow(e)}getPanelLargeOrder(e){return this.quoteService.getPanelLargeOrder(e)}getTodayTimeline(e){return this.quoteService.getTodayTimeline(e)}getIndustryList(){return this.boardService.getIndustryList()}getIndustrySpot(e){return this.boardService.getIndustrySpot(e)}getIndustryConstituents(e){return this.boardService.getIndustryConstituents(e)}getIndustryKline(e,r){return this.boardService.getIndustryKline(e,r)}getIndustryMinuteKline(e,r){return this.boardService.getIndustryMinuteKline(e,r)}getConceptList(){return this.boardService.getConceptList()}getConceptSpot(e){return this.boardService.getConceptSpot(e)}getConceptConstituents(e){return this.boardService.getConceptConstituents(e)}getConceptKline(e,r){return this.boardService.getConceptKline(e,r)}getConceptMinuteKline(e,r){return this.boardService.getConceptMinuteKline(e,r)}getHistoryKline(e,r){return this.klineService.getHistoryKline(e,r)}getMinuteKline(e,r){return this.klineService.getMinuteKline(e,r)}getHKHistoryKline(e,r){return this.klineService.getHKHistoryKline(e,r)}getUSHistoryKline(e,r){return this.klineService.getUSHistoryKline(e,r)}search(e){return this.quoteService.search(e)}getAShareCodeList(e){return this.quoteService.getAShareCodeList(e)}getUSCodeList(e){return this.quoteService.getUSCodeList(e)}getHKCodeList(){return this.quoteService.getHKCodeList()}getFundCodeList(){return this.quoteService.getFundCodeList()}getAllAShareQuotes(e={}){return this.quoteService.getAllAShareQuotes(e)}getAllHKShareQuotes(e={}){return this.quoteService.getAllHKShareQuotes(e)}getAllUSShareQuotes(e={}){return this.quoteService.getAllUSShareQuotes(e)}getAllQuotesByCodes(e,r={}){return this.quoteService.getAllQuotesByCodes(e,r)}batchRaw(e){return this.quoteService.batchRaw(e)}getTradingCalendar(){return this.quoteService.getTradingCalendar()}isTradingDay(e){return this.tradingCalendarService.isTradingDay(e)}nextTradingDay(e){return this.tradingCalendarService.nextTradingDay(e)}prevTradingDay(e){return this.tradingCalendarService.prevTradingDay(e)}getMarketStatus(e="A"){return this.tradingCalendarService.getMarketStatus(e)}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)}},Mi=Tt;var Li={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},ki={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},Ni={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function xi(t){let e=t.code.trim(),r=t.market.trim().toLowerCase(),n=Li[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 Fi(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function vi(t){let{code:e,market:r}=t;return(r==="sh"||r==="sz")&&Fi(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${Ni[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function wi(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/${ki[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function Ui(t){let e=xi(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:vi(e)},{name:"\u96EA\u7403",url:wi(e)}]}export{z as HttpError,se as INDICATOR_REGISTRY,B as SdkError,Tt as StockSDK,ht as addIndicators,ne as asyncPool,gt as buildIndicatorContext,ie as calcATR,st as calcBIAS,rt as calcBOLL,at as calcCCI,ct as calcDMI,G as calcEMA,dt as calcKC,nt as calcKDJ,et as calcMA,tt as calcMACD,ut as calcOBV,lt as calcROC,ot as calcRSI,pt as calcSAR,J as calcSMA,Er as calcWMA,it as calcWR,re as chunkArray,Ue as decodeGBK,Mi as default,ft as estimateIndicatorLookback,ir as extractJsonFromJsonp,Ui as generateSearchExternalLinks,be as getEnabledIndicatorKeys,W as getSdkErrorCode,N as jsonpRequest,Be as parseResponse,T as safeNumber,C as safeNumberOrNull};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stock-sdk",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",