stock-sdk 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var wt=Object.defineProperty;var Zo=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var ei=Object.prototype.hasOwnProperty;var mt=(t,e)=>{for(var n in e)wt(t,n,{get:e[n],enumerable:!0})},ti=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Jo(e))!ei.call(t,o)&&o!==n&&wt(t,o,{get:()=>e[o],enumerable:!(r=Zo(e,o))||r.enumerable});return t};var ni=t=>ti(wt({},"__esModule",{value:!0}),t);var xs={};mt(xs,{BROWSER_JSVARS_MUTEX_KEY:()=>_n,FundService:()=>me,HttpError:()=>j,INDICATOR_REGISTRY:()=>de,MARKET_TZ:()=>C,SdkError:()=>K,StockSDK:()=>pt,TradingCalendarService:()=>pe,addIndicators:()=>it,asyncPool:()=>oe,buildIndicatorContext:()=>rt,buildTimeMeta:()=>L,buildTimeMetaFromDateAndTime:()=>Fe,calcATR:()=>ce,calcBIAS:()=>We,calcBOLL:()=>Qe,calcCCI:()=>Xe,calcDMI:()=>et,calcEMA:()=>V,calcKC:()=>nt,calcKDJ:()=>Ge,calcMA:()=>ze,calcMACD:()=>je,calcOBV:()=>Ze,calcROC:()=>Je,calcRSI:()=>Ye,calcSAR:()=>tt,calcSMA:()=>ee,calcWMA:()=>bt,calcWR:()=>Ve,chunkArray:()=>re,decodeGBK:()=>Se,default:()=>Wo,estimateIndicatorLookback:()=>ot,extractJsonFromJsonp:()=>Te,fetchJsVars:()=>ae,formatInTz:()=>ue,generateSearchExternalLinks:()=>Xo,getEnabledIndicatorKeys:()=>ye,getSdkErrorCode:()=>Z,jsonpRequest:()=>N,parseJsVars:()=>Ne,parseMarketTime:()=>J,parseResponse:()=>Re,safeNumber:()=>S,safeNumberOrNull:()=>O,withScriptMutex:()=>se});module.exports=ni(xs);function Se(t){return new TextDecoder("gbk").decode(t)}function Re(t){let e=t.split(";").map(r=>r.trim()).filter(Boolean),n=[];for(let r of e){let o=r.indexOf("=");if(o<0)continue;let i=r.slice(0,o).trim();i.startsWith("v_")&&(i=i.slice(2));let s=r.slice(o+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");n.push({key:i,fields:a})}return n}function S(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function O(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function u(t){return t==null?null:p(String(t))}var Ut="https://qt.gtimg.cn",Kt="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Bt="https://assets.linkdiary.cn/shares/zh_a_list.json",Ht="https://assets.linkdiary.cn/shares/us_list.json",qt="https://assets.linkdiary.cn/shares/hk_list.json",$t="https://assets.linkdiary.cn/shares/fund_list",Gn="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ft="https://push2his.eastmoney.com/api/qt/stock/kline/get",zt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",gt="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",ht="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",jt="https://33.push2his.eastmoney.com/api/qt/stock/trends2/get",Qt="https://63.push2his.eastmoney.com/api/qt/stock/trends2/get",Gt="https://17.push2.eastmoney.com/api/qt/clist/get",Yt="https://91.push2.eastmoney.com/api/qt/stock/get",Vt="https://29.push2.eastmoney.com/api/qt/clist/get",Wt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Xt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Zt="https://79.push2.eastmoney.com/api/qt/clist/get",Jt="https://91.push2.eastmoney.com/api/qt/stock/get",en="https://29.push2.eastmoney.com/api/qt/clist/get",tn="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",nn="https://push2his.eastmoney.com/api/qt/stock/trends2/get",rn="https://datacenter-web.eastmoney.com/api/data/v1/get",Ee="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",on="https://push2.eastmoney.com/api/qt/clist/get",sn="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",Ce="https://push2ex.eastmoney.com",P="7eea3edcaed734bea9cbfc24409ed989",z="b2884a393a59ad64002292a3e90d46a5",_e="https://push2his.eastmoney.com/api/qt/stock/kline/get",an="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",Oe="58b2fa8f54638b60b87d69b31969089c",un={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},fe={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"},Tt={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},Ae="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",Ie="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",ln="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",yt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",cn="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",dn="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",pn="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",mn="https://futsseapi.eastmoney.com/list/option/221",fn="https://datacenter-web.eastmoney.com/api/data/get";var St={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"}},gn=3e4,Pe=500,De=500,Me=7,hn=3,Tn=1e3,yn=3e4,Sn=2,Rn=[408,429,500,502,503,504];var Rt=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),r=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+r),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Yn=["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"],En=0;function ri(){return typeof window<"u"&&typeof window.document<"u"}function Vn(){if(ri())return;let t=Yn[En];return En=(En+1)%Yn.length,t}var K=class extends Error{constructor(e){super(e.message),this.name="SdkError",this.code=e.code,this.provider=e.provider,this.url=e.url,this.status=e.status,this.details=e.details,e.cause!==void 0&&(this.cause=e.cause)}},j=class extends K{constructor(n,r,o,i){let s=r?` ${r}`:"",a=o?`, url: ${o}`:"",l=i?`, provider: ${i}`:"";super({code:n===429?"RATE_LIMITED":"HTTP_ERROR",message:`HTTP error! status: ${n}${s}${a}${l}`,status:n,url:o,provider:i,details:{statusText:r}});this.status=n;this.name="HttpError",this.statusText=r}};var ke=class extends K{constructor(e,n,r){super({code:"NOT_FOUND",message:e,provider:n,url:r}),this.name="NotFoundError"}};function be(t,e){let n=t;return!n.sdkCode&&e.sdkCode&&(n.sdkCode=e.sdkCode),!n.provider&&e.provider&&(n.provider=e.provider),!n.url&&e.url&&(n.url=e.url),n.status===void 0&&e.status!==void 0&&(n.status=e.status),!n.details&&e.details&&(n.details=e.details),n}function oi(t,e){return be(t,{provider:e.provider,url:e.url})}function Z(t){if(t instanceof K||t instanceof j)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 Et(t,e={}){return t instanceof K?oi(t,e):t instanceof DOMException&&t.name==="AbortError"?be(t,{sdkCode:"TIMEOUT",provider:e.provider,url:e.url,details:e.timeout?{timeout:e.timeout}:void 0}):t instanceof TypeError?be(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):t instanceof Error?be(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):new K({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var ge=class extends K{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},Ct=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new ge;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var ii=3e4,si=1,Wn=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],Xn=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function ai(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Wn:t.includes("push2.eastmoney.com")?Xn:[t]}function ui(t){return Array.from(new Set(t))}var _t=class{constructor(e=ii,n=si){this.cooldownMs=e;this.failureThreshold=n;this.states=new Map}getCandidateUrls(e,n){let r;try{r=new URL(e)}catch{return[e]}let o=Date.now(),i=ai(r.hostname,n);if(i.length<=1)return[e];let s=i.filter(c=>{let d=this.states.get(c);return!d||d.cooldownUntil<=o}),a=i.filter(c=>{let d=this.states.get(c);return d&&d.cooldownUntil>o});return ui([...s.includes(r.hostname)?[r.hostname]:[],...s.filter(c=>c!==r.hostname),...a.includes(r.hostname)?[r.hostname]:[],...a.filter(c=>c!==r.hostname)]).map(c=>{let d=new URL(e);return d.hostname=c,d.toString()})}recordSuccess(e){let n=this.safeGetHost(e);if(!n)return;let r=this.getState(n);r.failureCount=0,r.cooldownUntil=0,r.successCount++,r.lastErrorCode=void 0}recordFailure(e,n){let r=this.safeGetHost(e);if(!r)return;let o=this.getState(r);o.failureCount++,o.lastFailureAt=Date.now(),o.lastErrorCode=Z(n),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let n=Z(e);return n==="NETWORK_ERROR"||n==="TIMEOUT"?!0:e instanceof j?e.status===408||e.status===429||e.status>=500:!1}getStats(e){let n=Array.from(this.states.values()).map(o=>({...o}));if(!e)return n;if(e!=="eastmoney")return[];let r=new Set([...Wn,...Xn]);return n.filter(o=>r.has(o.host))}safeGetHost(e){try{return new URL(e).hostname}catch{return null}}getState(e){let n=this.states.get(e);if(n)return n;let r={host:e,failureCount:0,successCount:0,cooldownUntil:0,lastFailureAt:0};return this.states.set(e,r),r}};function li(t){return{maxRetries:t?.maxRetries??hn,baseDelay:t?.baseDelay??Tn,maxDelay:t?.maxDelay??yn,backoffMultiplier:t?.backoffMultiplier??Sn,retryableStatusCodes:t?.retryableStatusCodes??Rn,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function ci(t,e){let n={...t??{}};return e&&(Object.keys(n).some(o=>o.toLowerCase()==="user-agent")||(n["User-Agent"]=e)),n}function Zn(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 Cn(t={}){return{timeout:t.timeout??gn,retry:li(t.retry),headers:ci(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function Jn(t,e){if(e)return e;try{let n=new URL(t).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("sina.com.cn"))return"sina";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}var Le=class{constructor(e={}){this.baseUrl=e.baseUrl??Ut;let n={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=Cn(n),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new _t;for(let[r,o]of Object.entries(e.providerPolicies??{})){let i=Zn(n,o);this.providerPolicies[r]=Cn(i)}}getProviderState(e){let n=this.runtimeStates.get(e);if(n)return n;let r=this.providerPolicies[e]??this.defaultPolicy,o={policy:r,rateLimiter:r.rateLimit?new Rt(r.rateLimit):null,circuitBreaker:r.circuitBreaker?new Ct(r.circuitBreaker):null};return this.runtimeStates.set(e,o),o}getTimeout(){return this.defaultPolicy.timeout}getHostHealth(e){return this.fallbackManager.getStats(e)}calculateDelay(e,n){return Math.min(n.baseDelay*Math.pow(n.backoffMultiplier,e),n.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n,r){if(n>=r.maxRetries)return!1;let o=Z(e);return o==="TIMEOUT"?r.retryOnTimeout:o==="NETWORK_ERROR"?r.retryOnNetworkError:e instanceof j?r.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n,r,o=0){try{return await e()}catch(i){let s=Et(i,r);if(this.shouldRetry(s,o,n)){let a=this.calculateDelay(o,n);return n.onRetry&&n.onRetry(o+1,s,a),await this.sleep(a),this.executeWithRetry(e,n,r,o+1)}throw s}}async performRequest(e,n,r,o="text"){n.rateLimiter&&await n.rateLimiter.acquire();let i=new AbortController,s=setTimeout(()=>i.abort(),n.policy.timeout),a={...n.policy.headers};if(n.policy.rotateUserAgent){let l=Vn();if(l){for(let c of Object.keys(a))c.toLowerCase()==="user-agent"&&delete a[c];a["User-Agent"]=l}}try{let l=await fetch(e,{signal:i.signal,headers:a});if(!l.ok)throw new j(l.status,l.statusText,e,r);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,n={}){let r=Jn(e,n.provider),o=this.getProviderState(r);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new ge("Circuit breaker is OPEN, request rejected");let i=this.fallbackManager.getCandidateUrls(e,r),s;for(let a=0;a<i.length;a++){let l=i[a],c=a===0?o.policy.retry:{...o.policy.retry,maxRetries:0};try{let d=await this.executeWithRetry(()=>this.performRequest(l,o,r,n.responseType),c,{provider:r,url:l,timeout:o.policy.timeout});return o.circuitBreaker?.recordSuccess(),this.fallbackManager.recordSuccess(l),d}catch(d){let f=Et(d,{provider:r,url:l,timeout:o.policy.timeout});if(s=f,this.fallbackManager.recordFailure(l,f),a<i.length-1&&this.fallbackManager.shouldFallback(f))continue;throw o.circuitBreaker?.recordFailure(),f}}throw o.circuitBreaker?.recordFailure(),s??new ge("Request failed without a concrete error")}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,r=await this.get(n,{responseType:"arraybuffer",provider:"tencent"}),o=Se(r);return Re(o)}};var di=new Set(["daily","weekly","monthly"]),pi=new Set(["1","5","15","30","60"]),mi=new Set(["","qfq","hfq"]);function Y(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function Q(t){if(!di.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function W(t){if(!pi.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function B(t){if(!mi.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function re(t,e){Y(e,"chunkSize");let n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}async function oe(t,e,n=!1){if(Y(e,"concurrency"),t.length===0)return[];let r=n?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 a=await t[s]();n?r[s]=a:r.push(a)}});return await Promise.all(i),r}function he(t){if(t.startsWith("sh"))return"1";if(t.startsWith("sz")||t.startsWith("bj"))return"0";let e=t[0];return e==="6"||e==="5"||e==="9"?"1":"0"}function G(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function H(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var Ot=class{constructor(e={}){this.cache=new Map;this.inflight=new Map;this.defaultTTL=e.defaultTTL??0,this.maxSize=e.maxSize??1e3}get(e){let n=this.cache.get(e);if(n){if(n.expireAt>0&&Date.now()>n.expireAt){this.cache.delete(e);return}return n.lastAccess=Date.now(),n.value}}set(e,n,r){this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictLRU();let o=r??this.defaultTTL,i=Date.now();this.cache.set(e,{value:n,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(),n=0;for(let[r,o]of this.cache)o.expireAt>0&&e>o.expireAt&&(this.cache.delete(r),n++);return n}evictLRU(){let e=null,n=1/0;for(let[r,o]of this.cache)o.lastAccess<n&&(n=o.lastAccess,e=r);e&&this.cache.delete(e)}async getOrFetch(e,n,r){let o=this.get(e);if(o!==void 0)return o;let i=this.inflight.get(e);if(i)return i;let s=n().then(a=>(this.set(e,a,r),a)).finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,s),s}},er=new Map;function ie(t,e){let n=er.get(t);if(n)return n;let r=new Ot(e);return er.set(t,r),r}var fi=typeof document<"u"&&typeof window<"u",gi=0;function tr(){return`__stock_sdk_jsonp_${Date.now()}_${gi++}`}function Te(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let r=e.indexOf("(");if(r===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let o=e.lastIndexOf(")");if(o===-1||o<=r)throw new Error("Invalid JSONP response: no closing parenthesis found");let i=e.slice(r+1,o);return JSON.parse(i)}function hi(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let a=tr(),l;if(o==="path")l=t.replace("{callback}",a);else{let R=t.includes("?")?"&":"?";l=`${t}${R}${r}=${a}`}let c=document.createElement("script"),d=!1,f=window,g=()=>{c.parentNode&&c.parentNode.removeChild(c),delete f[a]},T=setTimeout(()=>{d||(d=!0,g(),s(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);f[a]=R=>{d||(d=!0,clearTimeout(T),g(),i(R))},c.onerror=()=>{d||(d=!0,clearTimeout(T),g(),s(new Error(`JSONP script load failed: ${t}`)))},c.src=l,document.head.appendChild(c)})}async function Ti(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e,i=tr(),s;if(o==="path")s=t.replace("{callback}",i);else{let c=t.includes("?")?"&":"?";s=`${t}${c}${r}=${i}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let c=await fetch(s,{signal:a.signal});if(!c.ok)throw new Error(`JSONP fetch failed with status ${c.status}: ${t}`);let d=await c.text();return Te(d)}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):c}finally{clearTimeout(l)}}function N(t,e={}){return fi?hi(t,e):Ti(t,e)}var nr=new Map;async function se(t,e){let r=(nr.get(t)??Promise.resolve()).then(e,e);return nr.set(t,r.then(()=>{},()=>{})),r}function yi(){return typeof document<"u"&&typeof window<"u"}var Si=15e3,_n="jsVars";async function ae(t,e,n={}){let r=n.timeout??Si;return yi()?se(_n,()=>Ri(t,e,r)):Ei(t,e,r,n.headers,n.client)}function Ne(t,e){let n={};for(let r of e){let o=Ci(t,r);o!==void 0&&(n[r]=o)}return n}function Ri(t,e,n){return new Promise((r,o)=>{let i=document.createElement("script"),s=!1,a=()=>{i.parentNode&&i.parentNode.removeChild(i)},l=setTimeout(()=>{s||(s=!0,a(),o(new Error(`fetchJsVars timed out after ${n}ms: ${t}`)))},n);i.onload=()=>{if(s)return;s=!0,clearTimeout(l);let c=window,d={};for(let f of e)if(f in c){d[f]=c[f];try{delete c[f]}catch{}}a(),r(d)},i.onerror=()=>{s||(s=!0,clearTimeout(l),a(),o(new Error(`fetchJsVars script load failed: ${t}`)))},i.src=t,document.head.appendChild(i)})}async function Ei(t,e,n,r,o){if(o){let a=await o.get(t,{responseType:"text"});return Ne(a,e)}let i=new AbortController,s=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{signal:i.signal,headers:r});if(!a.ok)throw new Error(`fetchJsVars fetch failed with status ${a.status}: ${t}`);let l=await a.text();return Ne(l,e)}catch(a){throw a instanceof DOMException&&a.name==="AbortError"?new Error(`fetchJsVars timed out after ${n}ms: ${t}`):a}finally{clearTimeout(s)}}function Ci(t,e){let r=new RegExp(`(?:^|[^\\w$])(?:var|let|const)\\s+${_i(e)}\\s*=\\s*`,"m").exec(t);if(!r)return;let o=r.index+r[0].length,i=Oi(t,o),s=t.slice(o,i).trim();try{return JSON.parse(s)}catch{return}}function _i(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oi(t,e){let n=0,r=null;for(let o=e;o<t.length;o++){let i=t[o];if(r){if(i==="\\"){o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"){r=i;continue}if(i==="["||i==="{"||i==="("){n++;continue}if(i==="]"||i==="}"||i===")"){n--;continue}if(i===";"&&n===0)return o}return t.length}var C={CN:"Asia/Shanghai",HK:"Asia/Hong_Kong",US:"America/New_York"};function Ai(t){if(!t)return null;let e=t.trim();if(!e)return null;let n=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/.exec(e);if(n)return{year:+n[1],month:+n[2],day:+n[3],hour:+n[4],minute:+n[5],second:n[6]?+n[6]:0};let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return r?{year:+r[1],month:+r[2],day:+r[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 rr(t,e){let n=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(n)),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 a=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=n-a;return n+l}function Ii(t,e){let n=(t||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n)??/^(\d{4})(\d{2})(\d{2})$/.exec(n);if(!r)return null;let o=/^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec((e||"").trim());return o?{year:+r[1],month:+r[2],day:+r[3],hour:+o[1],minute:+o[2],second:o[3]?+o[3]:0}:null}function J(t,e){let n=Ai(t);return n?rr(n,e):NaN}function L(t,e){return{timestamp:J(t,e),tz:e}}function Fe(t,e,n){let r=Ii(t,e);return r?{timestamp:rr(r,n),tz:n}:{timestamp:NaN,tz:n}}function ue(t,e){if(!Number.isFinite(t))return"";let n=new Intl.DateTimeFormat("sv-SE",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t)),r=n.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/);if(!r)return n;let o=r[2]==="24"?"00":r[2];return`${r[1]} ${o}:${r[3]}`}var D={};mt(D,{getAShareCodeList:()=>cr,getAllHKQuotesByCodes:()=>fr,getAllQuotesByCodes:()=>mr,getAllUSQuotesByCodes:()=>gr,getFullQuotes:()=>At,getFundCodeList:()=>hr,getFundFlow:()=>ir,getFundQuotes:()=>ar,getHKCodeList:()=>pr,getHKQuotes:()=>It,getPanelLargeOrder:()=>sr,getSimpleQuotes:()=>or,getTodayTimeline:()=>ur,getTradingCalendar:()=>Tr,getUSCodeList:()=>dr,getUSQuotes:()=>Pt,parseFullQuote:()=>On,parseFundFlow:()=>In,parseFundQuote:()=>bn,parseHKQuote:()=>Dn,parsePanelLargeOrder:()=>Pn,parseSimpleQuote:()=>An,parseUSQuote:()=>Mn,search:()=>Sr});function On(t){let e=[];for(let i=0;i<5;i++)e.push({price:S(t[9+i*2]),volume:S(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:S(t[19+i*2]),volume:S(t[20+i*2])});let r=t[30]??"",o=L(r,C.CN);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:S(t[3]),prevClose:S(t[4]),open:S(t[5]),volume:S(t[6]),outerVolume:S(t[7]),innerVolume:S(t[8]),bid:e,ask:n,time:r,timestamp:o.timestamp,tz:o.tz,change:S(t[31]),changePercent:S(t[32]),high:S(t[33]),low:S(t[34]),volume2:S(t[36]),amount:S(t[37]),turnoverRate:O(t[38]),pe:O(t[39]),amplitude:O(t[43]),circulatingMarketCap:O(t[44]),totalMarketCap:O(t[45]),pb:O(t[46]),limitUp:O(t[47]),limitDown:O(t[48]),volumeRatio:O(t[49]),avgPrice:O(t[51]),peStatic:O(t[52]),peDynamic:O(t[53]),high52w:O(t[67]),low52w:O(t[68]),circulatingShares:O(t[72]),totalShares:O(t[73]),raw:t}}function An(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:S(t[3]),change:S(t[4]),changePercent:S(t[5]),volume:S(t[6]),amount:S(t[7]),marketCap:O(t[9]),marketType:t[10]??"",raw:t}}function In(t){let e=t[13]??"",n=L(e,C.CN);return{code:t[0]??"",mainInflow:S(t[1]),mainOutflow:S(t[2]),mainNet:S(t[3]),mainNetRatio:S(t[4]),retailInflow:S(t[5]),retailOutflow:S(t[6]),retailNet:S(t[7]),retailNetRatio:S(t[8]),totalFlow:S(t[9]),name:t[12]??"",date:e,timestamp:n.timestamp,tz:n.tz,raw:t}}function Pn(t){return{buyLargeRatio:S(t[0]),buySmallRatio:S(t[1]),sellLargeRatio:S(t[2]),sellSmallRatio:S(t[3]),raw:t}}function Dn(t){let e=t[30]??"",n=L(e,C.HK);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:S(t[3]),prevClose:S(t[4]),open:S(t[5]),volume:S(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:S(t[31]),changePercent:S(t[32]),high:S(t[33]),low:S(t[34]),amount:S(t[37]),lotSize:O(t[40]),circulatingMarketCap:O(t[44]),totalMarketCap:O(t[45]),currency:t[t.length-3]??"",raw:t}}function Mn(t){let e=t[30]??"",n=L(e,C.US);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:S(t[3]),prevClose:S(t[4]),open:S(t[5]),volume:S(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:S(t[31]),changePercent:S(t[32]),high:S(t[33]),low:S(t[34]),amount:S(t[37]),turnoverRate:O(t[38]),pe:O(t[39]),amplitude:O(t[43]),totalMarketCap:O(t[45]),pb:O(t[47]),high52w:O(t[48]),low52w:O(t[49]),raw:t}}function bn(t){let e=t[8]??"",n=L(e,C.CN);return{code:t[0]??"",name:t[1]??"",nav:S(t[5]),accNav:S(t[6]),change:S(t[7]),navDate:e,timestamp:n.timestamp,tz:n.tz,raw:t}}async function At(t,e){if(!e||e.length===0)return[];let n=await t.getTencentQuote(e.join(",")),r=new Set(e);return n.filter(o=>r.has(o.key)&&o.fields&&o.fields.length>5&&o.fields[0]!=="").map(o=>On(o.fields))}async function or(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`s_${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>An(i.fields))}async function ir(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`ff_${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=14&&i.fields[0]!=="").map(i=>In(i.fields))}async function sr(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`s_pk${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=4&&i.fields[0]!=="").map(i=>Pn(i.fields))}async function It(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`hk${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>Dn(i.fields))}async function Pt(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`us${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>Mn(i.fields))}async function ar(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`jj${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=9&&i.fields[0]!=="").map(i=>bn(i.fields))}async function ur(t,e){let n=`${Kt}?code=${encodeURIComponent(e)}`,r=await t.get(n,{responseType:"json",provider:"tencent"});if(r.code!==0)throw new Error(r.msg||"API error");let o=r.data?.[e];if(!o){let g=L("",C.CN);return{code:e,date:"",timestamp:g.timestamp,tz:g.tz,preClose:0,data:[]}}let i=o.data?.data??[],s=o.data?.date??"",a=o.qt?.[e]??[],l=parseFloat(a[4]??"")||0,c=!1;if(i.length>0){let g=i[0].split(" "),T=parseFloat(g[1])||0,R=parseInt(g[2],10)||0,m=parseFloat(g[3])||0;R>0&&T>0&&m/R>T*50&&(c=!0)}let d=i.map(g=>{let T=g.split(" "),R=T[0],m=`${R.slice(0,2)}:${R.slice(2,4)}`,h=parseInt(T[2],10)||0,E=parseFloat(T[3])||0,_=c?h*100:h,M=_>0?E/_:0,b=Fe(s,m,C.CN);return{time:m,timestamp:b.timestamp,tz:b.tz,price:parseFloat(T[1])||0,volume:_,amount:E,avgPrice:Math.round(M*100)/100}}),f=L(s,C.CN);return{code:e,date:s,timestamp:f.timestamp,tz:f.tz,preClose:l,data:d}}var lr=ie("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function kn(t,e,n){return lr.getOrFetch(e,async()=>(await t.get(n,{responseType:"json"}))?.list||[])}function Pi(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function cr(t,e){let n=!1,r;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,r=e.market);let i=await kn(t,"a-share:full",Bt);return r&&(i=i.filter(s=>Pi(s,r))),n?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var Di={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function dr(t,e){let n=!1,r;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,r=e.market);let i=(await kn(t,"us:full",Ht)).slice();if(r){let s=Di[r];i=i.filter(a=>a.startsWith(s))}return n?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function pr(t){return(await kn(t,"hk:full",qt)).slice()}async function mr(t,e,n={}){let{batchSize:r=Pe,concurrency:o=Me,onProgress:i}=n;Y(r,"batchSize"),Y(o,"concurrency");let s=Math.min(r,De),a=re(e,s),l=a.length,c=0,d=a.map(g=>async()=>{let T=await At(t,g);return c++,i&&i(c,l),T});return(await oe(d,o,!0)).flat()}async function fr(t,e,n={}){let{batchSize:r=Pe,concurrency:o=Me,onProgress:i}=n;Y(r,"batchSize"),Y(o,"concurrency");let s=Math.min(r,De),a=re(e,s),l=a.length,c=0,d=a.map(g=>async()=>{let T=await It(t,g);return c++,i&&i(c,l),T});return(await oe(d,o,!0)).flat()}async function gr(t,e,n={}){let{batchSize:r=Pe,concurrency:o=Me,onProgress:i}=n;Y(r,"batchSize"),Y(o,"concurrency");let s=Math.min(r,De),a=re(e,s),l=a.length,c=0,d=a.map(g=>async()=>{let T=await Pt(t,g);return c++,i&&i(c,l),T});return(await oe(d,o,!0)).flat()}async function hr(t){return(await lr.getOrFetch("fund:full",async()=>(await t.get($t,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var Mi=ie("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function Tr(t){return(await Mi.getOrFetch("a-share",async()=>{let n=await t.get(Gn);return!n||n.trim()===""?[]:n.trim().split(",").map(r=>r.trim()).filter(r=>r.length>0)})).slice()}var yr="https://smartbox.gtimg.cn/s3/";function bi(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function ki(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 Li(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let r=n.split("~"),o=r[0]||"",i=r[1]||"",s=bi(r[2]||""),a=r[4]||"";return{code:o+i,name:s,market:o,type:a,category:ki(a)}})}function Ni(t){return new Promise((e,n)=>{let r=`${yr}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=r,o.charset="utf-8",o.onload=()=>{let i=window.v_hint||"";document.body.removeChild(o),e(i)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function Fi(t,e){let n=`${yr}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function xi(){return typeof window<"u"&&typeof document<"u"}async function Sr(t,e){if(!e||!e.trim())return[];let n;return xi()?n=await Ni(e):n=await Fi(t,e),Li(n)}var y={};mt(y,{extractVariety:()=>wn,fetchDatacenter:()=>Nn,fetchDatacenterList:()=>A,getBlockTradeDailyStat:()=>vo,getBlockTradeDetail:()=>xo,getBlockTradeMarketStat:()=>Fo,getBoardChanges:()=>Ao,getCFFEXOptionQuotes:()=>eo,getComexInventory:()=>io,getConceptConstituents:()=>Kr,getConceptKline:()=>Br,getConceptList:()=>wr,getConceptMinuteKline:()=>Hr,getConceptSpot:()=>Ur,getDividendDetail:()=>qr,getDragonTigerBranchRank:()=>bo,getDragonTigerDetail:()=>Po,getDragonTigerInstitution:()=>Mo,getDragonTigerStockSeatDetail:()=>ko,getDragonTigerStockStats:()=>Do,getFundDividendList:()=>jr,getFundEstimate:()=>Yr,getFundFlowRank:()=>mo,getFundNavHistory:()=>Gr,getFundRankHistory:()=>Vr,getFuturesHistoryKline:()=>Xr,getFuturesInventory:()=>oo,getFuturesInventorySymbols:()=>ro,getFuturesMarketCode:()=>Un,getGlobalFuturesKline:()=>Jr,getGlobalFuturesSpot:()=>Zr,getHKHistoryKline:()=>Cr,getHKMinuteKline:()=>_r,getHistoryKline:()=>Rr,getIndividualFundFlow:()=>co,getIndustryConstituents:()=>Fr,getIndustryKline:()=>xr,getIndustryList:()=>Lr,getIndustryMinuteKline:()=>vr,getIndustrySpot:()=>Nr,getMarginAccountInfo:()=>wo,getMarginTargetList:()=>Uo,getMarketFundFlow:()=>po,getMinuteKline:()=>Er,getNorthboundFlowSummary:()=>So,getNorthboundHistory:()=>Eo,getNorthboundHoldingRank:()=>Ro,getNorthboundIndividual:()=>Co,getNorthboundMinute:()=>yo,getOptionLHB:()=>to,getSectorFundFlowHistory:()=>go,getSectorFundFlowRank:()=>fo,getStockChanges:()=>Oo,getUSHistoryKline:()=>Or,getUSMinuteKline:()=>Ar,getZTPool:()=>_o});async function Ln(t,e,n,r,o=100,i){let s=[],a=1,l=0;do{let c=new URLSearchParams({...n,pn:String(a),pz:String(o),fields:r}),d=`${e}?${c.toString()}`,g=(await t.get(d,{responseType:"json"}))?.data;if(!g||!Array.isArray(g.diff))break;a===1&&(l=g.total??0);let T=g.diff.map((R,m)=>i(R,s.length+m+1));s.push(...T),a++}while(s.length<l);return s}function x(t){let[e,n,r,o,i,s,a,l,c,d,f]=t.split(",");return{date:e,open:p(n),close:p(r),high:p(o),low:p(i),volume:p(s),amount:p(a),amplitude:p(l),changePercent:p(c),change:p(d),turnoverRate:p(f)}}async function v(t,e,n){let r=`${e}?${n.toString()}`,o=await t.get(r,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function Rr(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=n;Q(r),B(o);let a=e.replace(/^(sh|sz|bj)/,""),l=`${he(e)}.${a}`,c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:P,klt:G(r),fqt:H(o),secid:l,beg:i,end:s}),d=ft,{klines:f}=await v(t,d,c);return f.length===0?[]:f.map(g=>{let T=x(g),R=L(T.date,C.CN);return{...T,timestamp:R.timestamp,tz:R.tz,code:a}})}async function Er(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=n;W(r),B(o);let a=e.replace(/^(sh|sz|bj)/,""),l=`${he(e)}.${a}`;if(r==="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:P,ndays:"5",iscr:"0",secid:l}),d=`${zt}?${c.toString()}`,g=(await t.get(d,{responseType:"json"}))?.data?.trends;if(!Array.isArray(g)||g.length===0)return[];let T=i.replace("T"," ").slice(0,16),R=s.replace("T"," ").slice(0,16);return g.map(m=>{let[h,E,_,M,b,k,$,U]=m.split(","),X=L(h,C.CN);return{time:h,timestamp:X.timestamp,tz:X.tz,open:p(E),close:p(_),high:p(M),low:p(b),volume:p(k),amount:p($),avgPrice:p(U)}}).filter(m=>m.time>=T&&m.time<=R)}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:P,klt:r,fqt:H(o||""),secid:l,beg:"0",end:"20500000"}),d=ft,{klines:f}=await v(t,d,c);if(f.length===0)return[];let g=i.replace("T"," ").slice(0,16),T=s.replace("T"," ").slice(0,16);return f.map(R=>{let m=x(R),h=L(m.date,C.CN);return{...m,time:m.date,timestamp:h.timestamp,tz:h.tz}}).filter(R=>R.time>=g&&R.time<=T)}}function Dt(t){return async function(n,r,o={}){let{period:i="daily",adjust:s="qfq",startDate:a="19700101",endDate:l="20500101"}=o;Q(i),B(s);let c=t.normalizeSymbol(r),d=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:P,klt:G(i),fqt:H(s),secid:c.secid,beg:a,end:l,lmt:"1000000"}),{klines:f,name:g,code:T}=await v(n,t.url,d);if(f.length===0)return[];let R=t.resolveResultMeta?t.resolveResultMeta(r,c,{code:T,name:g}):{code:T||c.fallbackCode,name:g||""};return f.map(m=>{let h=x(m),E=L(h.date,t.tz),_={...h,timestamp:E.timestamp,tz:E.tz,code:R.code,name:R.name};return t.enrichItem(_)})}}var vi=Dt({url:gt,tz:C.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 Cr(t,e,n={}){return vi(t,e,n)}async function _r(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00",ndays:a=1}=n;W(r),B(o);let l=e.replace(/^hk/i,"").padStart(5,"0"),c=`116.${l}`,d=m=>{let h=J(m,C.CN);return{time:ue(h,C.HK)||m,timestamp:h}};if(r==="1"){let m=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:P,ndays:String(a),iscr:"0",secid:c}),h=`${jt}?${m.toString()}`,_=(await t.get(h,{responseType:"json"}))?.data?.trends;if(!Array.isArray(_)||_.length===0)return[];let M=i.replace("T"," ").slice(0,16),b=s.replace("T"," ").slice(0,16);return _.map(k=>{let[$,U,X,te,ne,Lt,Nt,Ft]=k.split(","),{time:xt,timestamp:vt}=d($);return{time:xt,timestamp:vt,tz:C.HK,open:p(U),close:p(X),high:p(te),low:p(ne),volume:p(Lt),amount:p(Nt),avgPrice:p(Ft),currency:"HKD",code:l}}).filter(k=>k.time>=M&&k.time<=b)}let f=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:P,klt:r,fqt:H(o),secid:c,beg:"0",end:"20500000"}),{klines:g}=await v(t,gt,f);if(g.length===0)return[];let T=i.replace("T"," ").slice(0,16),R=s.replace("T"," ").slice(0,16);return g.map(m=>{let h=x(m),{time:E,timestamp:_}=d(h.date);return{time:E,timestamp:_,tz:C.HK,open:h.open,close:h.close,high:h.high,low:h.low,volume:h.volume,amount:h.amount,amplitude:h.amplitude,changePercent:h.changePercent,change:h.change,turnoverRate:h.turnoverRate,currency:"HKD",code:l}}).filter(m=>m.time>=T&&m.time<=R)}var wi=Dt({url:ht,tz:C.US,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:n.code||e.fallbackCode,name:n.name||""}),enrichItem:t=>({...t,currency:"USD"})});async function Or(t,e,n={}){return wi(t,e,n)}async function Ar(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00",ndays:a=1}=n;W(r),B(o);let l=e,c=e.split(".")[1]||e,d=m=>{let h=J(m,C.CN);return{time:ue(h,C.US)||m,timestamp:h}};if(r==="1"){let m=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:P,ndays:String(a),iscr:"0",secid:l}),h=`${Qt}?${m.toString()}`,_=(await t.get(h,{responseType:"json"}))?.data?.trends;if(!Array.isArray(_)||_.length===0)return[];let M=i.replace("T"," ").slice(0,16),b=s.replace("T"," ").slice(0,16);return _.map(k=>{let[$,U,X,te,ne,Lt,Nt,Ft]=k.split(","),{time:xt,timestamp:vt}=d($);return{time:xt,timestamp:vt,tz:C.US,open:p(U),close:p(X),high:p(te),low:p(ne),volume:p(Lt),amount:p(Nt),avgPrice:p(Ft),currency:"USD",code:c}}).filter(k=>k.time>=M&&k.time<=b)}let f=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:P,klt:r,fqt:H(o),secid:l,beg:"0",end:"20500000"}),{klines:g}=await v(t,ht,f);if(g.length===0)return[];let T=i.replace("T"," ").slice(0,16),R=s.replace("T"," ").slice(0,16);return g.map(m=>{let h=x(m),{time:E,timestamp:_}=d(h.date);return{time:E,timestamp:_,tz:C.US,open:h.open,close:h.close,high:h.high,low:h.low,volume:h.volume,amount:h.amount,amplitude:h.amplitude,changePercent:h.changePercent,change:h.change,turnoverRate:h.turnoverRate,currency:"USD",code:c}}).filter(m=>m.time>=T&&m.time<=R)}function Ir(t){let e=ie(`eastmoney:board-code-map:${t.type}`,{defaultTTL:36e5,maxSize:4});return{async getCode(n,r,o){if(r.startsWith("BK"))return r;let s=(await e.getOrFetch("name-code-map",async()=>{let a=await o(n);return Object.fromEntries(a.map(l=>[l.name,l.code]))}))[r];if(!s)throw new ke(`${t.errorPrefix}: ${r}`,"eastmoney");return s}}}async function Pr(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},r=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await Ln(t,e.listUrl,n,r,100,(i,s)=>({rank:s,name:String(i.f14??""),code:String(i.f12??""),price:u(i.f2),change:u(i.f4),changePercent:u(i.f3),totalMarketCap:u(i.f20),turnoverRate:u(i.f8),riseCount:u(i.f104),fallCount:u(i.f105),leadingStock:i.f128?String(i.f128):null,leadingStockChangePercent:u(i.f136)}));return o.sort((i,s)=>(s.changePercent??0)-(i.changePercent??0)),o.forEach((i,s)=>{i.rank=s+1}),o}async function Dr(t,e,n){let r=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${r.toString()}`,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:d})=>{let f=s[l],g=null;return typeof f=="number"&&!isNaN(f)&&(g=d?f/100:f),{item:c,value:g}}):[]}async function Mr(t,e,n){let r={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Ln(t,n,r,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(i,s)=>({rank:s,code:String(i.f12??""),name:String(i.f14??""),price:u(i.f2),changePercent:u(i.f3),change:u(i.f4),volume:u(i.f5),amount:u(i.f6),amplitude:u(i.f7),high:u(i.f15),low:u(i.f16),open:u(i.f17),prevClose:u(i.f18),turnoverRate:u(i.f8),pe:u(i.f9),pb:u(i.f23)}))}async function br(t,e,n,r={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:a="20500101"}=r;Q(o),B(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:G(o),fqt:H(i),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:c}=await v(t,n,l);return c.length===0?[]:c.map(d=>x(d))}async function kr(t,e,n,r,o={}){let{period:i="5"}=o;if(W(i),i==="1"){let s=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${r}?${s.toString()}`,c=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(c)||c.length===0?[]:c.map(d=>{let[f,g,T,R,m,h,E,_]=d.split(","),M=p(_);return{time:f,open:p(g),close:p(T),high:p(R),low:p(m),volume:p(h),amount:p(E),price:M,avgPrice:M}})}else{let s=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:i,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${s.toString()}`,c=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(d=>{let[f,g,T,R,m,h,E,_,M,b,k]=d.split(",");return{time:f,open:p(g),close:p(T),high:p(R),low:p(m),changePercent:p(M),change:p(b),volume:p(h),amount:p(E),amplitude:p(_),turnoverRate:p(k)}})}}function Mt(t){let e=Ir(t);async function n(o){return Pr(o,t)}async function r(o,i){return e.getCode(o,i,n)}return{async getList(o){return n(o)},async getSpot(o,i){let s=await r(o,i);return Dr(o,s,t.spotUrl)},async getConstituents(o,i){let s=await r(o,i);return Mr(o,s,t.consUrl)},async getKline(o,i,s={}){let a=await r(o,i);return br(o,a,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let a=await r(o,i);return kr(o,a,t.klineUrl,t.trendsUrl,s)}}}var Ui={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Gt,spotUrl:Yt,consUrl:Vt,klineUrl:Wt,trendsUrl:Xt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},xe=Mt(Ui);async function Lr(t){return xe.getList(t)}async function Nr(t,e){return xe.getSpot(t,e)}async function Fr(t,e){return xe.getConstituents(t,e)}async function xr(t,e,n={}){return xe.getKline(t,e,n)}async function vr(t,e,n={}){return xe.getMinuteKline(t,e,n)}var Ki={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Zt,spotUrl:Jt,consUrl:en,klineUrl:tn,trendsUrl:nn,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ve=Mt(Ki);async function wr(t){return ve.getList(t)}async function Ur(t,e){return ve.getSpot(t,e)}async function Kr(t,e){return ve.getConstituents(t,e)}async function Br(t,e,n={}){return ve.getKline(t,e,n)}async function Hr(t,e,n={}){return ve.getMinuteKline(t,e,n)}async function Nn(t,e,n){let{reportName:r,columns:o="ALL",filter:i,sortColumns:s,sortTypes:a,pageSize:l=500,startPage:c=1,fetchAllPages:d=!0,maxPages:f=1e3,quoteColumns:g,quoteType:T,extraParams:R}=e,m=[],h=c,E=1,_=0,M=0;do{let b=new URLSearchParams({reportName:r,columns:o,pageSize:String(l),pageNumber:String(h),source:"WEB",client:"WEB"});if(i&&b.set("filter",i),s&&b.set("sortColumns",s),a&&b.set("sortTypes",a),g&&b.set("quoteColumns",g),T&&b.set("quoteType",T),R)for(let[te,ne]of Object.entries(R))b.set(te,ne);let k=`${rn}?${b.toString()}`,U=(await t.get(k,{responseType:"json"}))?.result;if(!U||!Array.isArray(U.data))break;h===c&&(E=U.pages??1,_=U.count??U.data.length);let X=U.data.map((te,ne)=>n(te,m.length+ne));if(m.push(...X),h++,M++,!d)break}while(h<=E&&M<f);return d&&M>=f&&h<=E&&console.warn(`[stock-sdk] fetchDatacenter("${r}") truncated at maxPages=${f} (server reports ${E} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:m,total:_,pages:E}}async function A(t,e,n){return(await Nn(t,e,n)).data}function F(t){if(t==null)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}function le(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Bi(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:le(t.REPORT_DATE),planNoticeDate:le(t.PLAN_NOTICE_DATE),disclosureDate:le(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:le(t.EQUITY_RECORD_DATE),exDividendDate:le(t.EX_DIVIDEND_DATE),payDate:le(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:le(t.NOTICE_DATE)}}async function qr(t,e){let n=e.replace(/^(sh|sz|bj)/,"");return A(t,{reportName:"RPT_SHAREBONUS_DET",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:500,filter:`(SECURITY_CODE="${n}")`},r=>Bi(r))}var Hi="https://fund.eastmoney.com/Data/funddataIndex_Interface.aspx",zr="https://fund.eastmoney.com/pingzhongdata",qi="https://fundgz.1234567.com.cn/js";function $i(){return typeof document<"u"&&typeof window<"u"}var zi=1e4;function ji(){return new Date().getFullYear()}function Qi(t,e){let n=new URLSearchParams({dt:"8",page:String(e),rank:t.rank??"FSRQ",sort:t.sort??"desc",gs:"",ftype:t.fundType??"",year:String(t.year??ji())});return`${Hi}?${n.toString()}`}function Fn(t){if(!t)return null;let e=t.trim().match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Gi(t){if(t===void 0||t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Yi(t){return{code:t[0]??"",name:t[1]??"",equityRecordDate:Fn(t[2]),exDividendDate:Fn(t[3]),dividendPerShare:Gi(t[4]),payDate:Fn(t[5]),raw:t}}async function xn(t,e,n){let r=Qi(e,n),o=await ae(r,["pageinfo","jjfh_data"],{client:t}),i=o.pageinfo??[0,0,n],[s=0,a=0,l=n]=i;return{items:(o.jjfh_data??[]).map(Yi),totalPages:s,pageSize:a,currentPage:l}}async function jr(t,e={}){if(e.page==="all"){let o=await xn(t,e,1),i=o.items;for(let s=2;s<=o.totalPages;s++){let a=await xn(t,e,s);i=i.concat(a.items)}return e.code&&(i=i.filter(s=>s.code===e.code)),{items:i,totalPages:o.totalPages,pageSize:o.pageSize,currentPage:-1}}let n=e.page??1,r=await xn(t,e,n);return e.code?{...r,items:r.items.filter(o=>o.code===e.code)}:r}function Vi(t){if(t===void 0||t===""||t===null)return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}function Qr(t){return new Date(t).toISOString().slice(0,10)}async function Gr(t,e){let n=`${zr}/${encodeURIComponent(e)}.js`,r=await ae(n,["fS_code","fS_name","Data_netWorthTrend","Data_ACWorthTrend"],{client:t}),o=r.Data_netWorthTrend??[],i=new Map;for(let a of r.Data_ACWorthTrend??[])Array.isArray(a)&&a.length>=2&&i.set(a[0],a[1]);let s=o.map(a=>({date:Qr(a.x),timestamp:a.x,nav:a.y,accNav:i.has(a.x)?i.get(a.x):null,dailyReturn:Vi(a.equityReturn),unitMoney:a.unitMoney??""}));return{code:r.fS_code??e,name:r.fS_name??null,items:s}}function Wi(t,e,n=zi){let r=`${qi}/${encodeURIComponent(e)}.js?rt=${Date.now()}`;return $i()?se("fundgz:jsonpgz",()=>Xi(r,n)):Zi(t,r)}function Xi(t,e){return new Promise((n,r)=>{let o=document.createElement("script"),i=window,s=i.jsonpgz,a=!1,l=()=>{if(o.parentNode&&o.parentNode.removeChild(o),s===void 0)try{delete i.jsonpgz}catch{}else i.jsonpgz=s},c=setTimeout(()=>{a||(a=!0,l(),r(new Error(`fundgz JSONP timed out after ${e}ms: ${t}`)))},e);i.jsonpgz=d=>{a||(a=!0,clearTimeout(c),l(),n(d??{}))},o.onerror=()=>{a||(a=!0,clearTimeout(c),l(),r(new Error(`fundgz JSONP script load failed: ${t}`)))},o.src=t,document.head.appendChild(o)})}async function Zi(t,e){let r=(await t.get(e,{responseType:"text",provider:"eastmoney"})).trim();if(!r)return{};try{return Te(r)}catch{return{}}}function vn(t){if(t===void 0||t===""||t==="--")return null;let e=Number(t);return Number.isFinite(e)?e:null}async function Yr(t,e){let n=await Wi(t,e);return{code:n.fundcode??e,name:n.name??null,navDate:n.jzrq?.trim()?n.jzrq.trim():null,nav:vn(n.dwjz),estimatedNav:vn(n.gsz),estimatedChangePercent:vn(n.gszzl),estimateTime:n.gztime?.trim()?n.gztime.trim():null}}function $r(t){if(t===void 0||t===""||t===null)return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}async function Vr(t,e){let n=`${zr}/${encodeURIComponent(e)}.js`,r=await ae(n,["fS_code","fS_name","Data_rateInSimilarType","Data_rateInSimilarPersent"],{client:t}),o=r.Data_rateInSimilarType??[],i=new Map;for(let a of r.Data_rateInSimilarPersent??[])Array.isArray(a)&&a.length>=2&&i.set(a[0],a[1]);let s=o.map(a=>({date:Qr(a.x),timestamp:a.x,rank:$r(a.y),total:$r(a.sc),percentile:i.has(a.x)?i.get(a.x):null}));return{code:r.fS_code??e,name:r.fS_name??null,items:s}}function wn(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 Wr(t){return fe[t]??fe[t.toLowerCase()]??fe[t.toUpperCase()]}function Un(t){let e=Wr(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=Wr(t.slice(0,-1))),!e){let r=Object.keys(fe).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${r}`)}let n=un[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function Ji(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?p(n[12]):null}}async function Xr(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;Q(r);let s=wn(e),l=`${Un(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:P,klt:G(r),fqt:"0",secid:l,beg:o,end:i}),{klines:d,name:f,code:g}=await v(t,_e,c);return d.length===0?[]:d.map(T=>({...Ji(T),code:g||e,name:f||""}))}async function Zr(t,e={}){let n=e.pageSize??20,r=[],o=0,i=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(o),token:Oe,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${an}?${s.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;o===0&&(i=l.total??0);let c=l.list.map(es);r.push(...c),o++}while(r.length<i);return r}function es(t){return{code:t.dm||"",name:t.name||"",price:p(String(t.p)),change:p(String(t.zde)),changePercent:p(String(t.zdf)),open:p(String(t.o)),high:p(String(t.h)),low:p(String(t.l)),prevSettle:p(String(t.zjsj)),volume:p(String(t.vol)),buyVolume:p(String(t.wp)),sellVolume:p(String(t.np)),openInterest:p(String(t.ccl))}}function ts(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?p(n[12]):null}}function ns(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 Jr(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;Q(r);let s=n.marketCode;if(s===void 0){let g=ns(e);if(s=Tt[g],s===void 0){let T=Object.keys(Tt).join(", ");throw new RangeError(`Unknown global futures variety: "${g}". Supported: ${T}. Or specify marketCode manually via options.`)}}let a=`${s}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:P,klt:G(r),fqt:"0",secid:a,beg:o,end:i}),{klines:c,name:d,code:f}=await v(t,_e,l);return c.length===0?[]:c.map(g=>({...ts(g),code:f||e,name:d||""}))}async function eo(t,e={}){let{pageSize:n=2e4}=e,r=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:Oe,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${mn}?${r.toString()}`,s=(await t.get(o,{responseType:"json"}))?.list;return Array.isArray(s)?s.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:u(a.p),change:u(a.zde),changePercent:u(a.zdf),volume:u(a.vol),amount:u(a.cje),openInterest:u(a.ccl),strikePrice:u(a.xqj),remainDays:u(a.syr),dailyChange:u(a.rz),prevSettle:u(a.zjsj),open:u(a.o)})):[]}function rs(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function to(t,e,n){let r=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:z,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),o=`${fn}?${r.toString()}`,s=(await t.get(o,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function a(l){if(!l)return"";let c=String(l),d=c.match(/^(\d{4}-\d{2}-\d{2})/);return d?d[1]:c}return s.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:u(l.MEMBER_RANK)??0,sellVolume:u(l.SELL_VOLUME),sellVolumeChange:u(l.SELL_VOLUME_CHANGE),netSellVolume:u(l.NET_SELL_VOLUME),sellVolumeRatio:u(l.SELL_VOLUME_RATIO),buyVolume:u(l.BUY_VOLUME),buyVolumeChange:u(l.BUY_VOLUME_CHANGE),netBuyVolume:u(l.NET_BUY_VOLUME),buyVolumeRatio:u(l.BUY_VOLUME_RATIO),sellPosition:u(l.SELL_POSITION),sellPositionChange:u(l.SELL_POSITION_CHANGE),netSellPosition:u(l.NET_SELL_POSITION),sellPositionRatio:u(l.SELL_POSITION_RATIO),buyPosition:u(l.BUY_POSITION),buyPositionChange:u(l.BUY_POSITION_CHANGE),netBuyPosition:u(l.NET_BUY_POSITION),buyPositionRatio:u(l.BUY_POSITION_RATIO),tradeDate:a(l.TRADE_DATE),volume:u(l.BUY_VOLUME)??u(l.SELL_VOLUME)??u(l.NET_BUY_VOLUME)??u(l.NET_SELL_VOLUME),volumeChange:u(l.BUY_VOLUME_CHANGE)??u(l.SELL_VOLUME_CHANGE),amount:u(l.BUY_POSITION)??u(l.SELL_POSITION)??u(l.NET_BUY_POSITION)??u(l.NET_SELL_POSITION),amountChange:u(l.BUY_POSITION_CHANGE)??u(l.SELL_POSITION_CHANGE),openInterest:u(l.BUY_POSITION)??u(l.SELL_POSITION),openInterestChange:u(l.BUY_POSITION_CHANGE)??u(l.SELL_POSITION_CHANGE),side:rs(String(l.TRADE_TYPE??""))}))}var os={gold:"EMI00069026",silver:"EMI00069027"};function no(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function ro(t){return A(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 oo(t,e,n={}){let{startDate:r="2020-10-28",pageSize:o=500}=n,i=e.toUpperCase();return A(t,{reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${i}")(TRADE_DATE>='${r}')`,pageSize:o,sortColumns:"TRADE_DATE",sortTypes:"-1"},s=>({code:String(s.SECURITY_CODE??e),date:no(s.TRADE_DATE),inventory:u(s.ON_WARRANT_NUM),change:u(s.ADDCHANGE)}))}async function io(t,e,n={}){let r=os[e];if(!r)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:o=500}=n,i={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};return A(t,{reportName:"RPT_FUTUOPT_GOLDSIL",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:o,filter:`(INDICATOR_ID1="${r}")(@STORAGE_TON<>"NULL")`},s=>({date:no(s.REPORT_DATE),name:i[e]??e,storageTon:u(s.STORAGE_TON),storageOunce:u(s.STORAGE_OUNCE),inventory:u(s.STORAGE_TON),change:null,market:e}))}var so={daily:"101",weekly:"102",monthly:"103"},Kn="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function ao(t){let e=t.split(",");return{date:e[0]??"",mainNetInflow:p(e[1]),smallNetInflow:p(e[2]),mediumNetInflow:p(e[3]),largeNetInflow:p(e[4]),superLargeNetInflow:p(e[5]),mainNetInflowPercent:p(e[6]),smallNetInflowPercent:p(e[7]),mediumNetInflowPercent:p(e[8]),largeNetInflowPercent:p(e[9]),superLargeNetInflowPercent:p(e[10]),close:p(e[11]),changePercent:p(e[12])}}function is(t){let e=t.split(",");return{date:e[0]??"",mainNetInflow:p(e[1]),smallNetInflow:p(e[2]),mediumNetInflow:p(e[3]),largeNetInflow:p(e[4]),superLargeNetInflow:p(e[5]),mainNetInflowPercent:p(e[6]),smallNetInflowPercent:p(e[7]),mediumNetInflowPercent:p(e[8]),largeNetInflowPercent:p(e[9]),superLargeNetInflowPercent:p(e[10]),shClose:p(e[11]),shChangePercent:p(e[12]),szClose:p(e[13]),szChangePercent:p(e[14])}}var uo={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"}},ss={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},as="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 lo(t,e,n=100,r=1e3){let o=[],i=1,s=0;do{let a=new URLSearchParams({...e,pn:String(i),pz:String(n)}),l=`${on}?${a.toString()}`,d=(await t.get(l,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff)||(i===1&&(s=d.total??0),o.push(...d.diff),o.length>=s||d.diff.length<n))break;i++}while(o.length<s&&i<=r);return i>r&&o.length<s&&console.warn(`[stock-sdk] fetchClistAllPages truncated at maxPages=${r} (server reports total=${s}, fetched=${o.length}). Pass a larger \`maxPages\` to fetch the full dataset.`),o}async function co(t,e,n={}){let{period:r="daily"}=n,o=so[r];if(!o)throw new RangeError(`Invalid period: ${r}. Must be daily/weekly/monthly.`);let i=e.replace(/^(sh|sz|bj)/i,""),s=`${he(e)}.${i}`,a=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:Kn,ut:z}),l=`${Ee}?${a.toString()}`,d=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(d)||d.length===0?[]:d.map(ao)}async function po(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:Kn,ut:z}),n=`${Ee}?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(is)}async function mo(t,e={}){let{indicator:n="today"}=e,r=uo[n];if(!r)throw new RangeError(`Invalid indicator: ${n}.`);let o={fid:r.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:z,fs:as,fields:r.fields};return(await lo(t,o,100)).map(s=>({code:String(s.f12??""),name:String(s.f14??""),price:u(s.f2),changePercent:u(s[r.changePercentField]),mainNetInflow:u(s[r.mainNet]),mainNetInflowPercent:u(s[r.mainPct]),superLargeNetInflow:u(s[r.superLargeNet]),superLargeNetInflowPercent:u(s[r.superLargePct]),largeNetInflow:u(s[r.largeNet]),largeNetInflowPercent:u(s[r.largePct]),mediumNetInflow:u(s[r.mediumNet]),mediumNetInflowPercent:u(s[r.mediumPct]),smallNetInflow:u(s[r.smallNet]),smallNetInflowPercent:u(s[r.smallPct])}))}async function fo(t,e={}){let{indicator:n="today",sectorType:r="industry"}=e,o=uo[n];if(!o)throw new RangeError(`Invalid indicator: ${n}.`);let i=ss[r];if(!i)throw new RangeError(`Invalid sectorType: ${r}.`);let s=`${o.fields},f204,f205`,a={fid:o.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:z,fs:i,fields:s};return(await lo(t,a,100)).map(c=>({code:String(c.f12??""),name:String(c.f14??""),changePercent:u(c[o.changePercentField]),mainNetInflow:u(c[o.mainNet]),mainNetInflowPercent:u(c[o.mainPct]),superLargeNetInflow:u(c[o.superLargeNet]),largeNetInflow:u(c[o.largeNet]),mediumNetInflow:u(c[o.mediumNet]),smallNetInflow:u(c[o.smallNet]),topStockCode:c.f204?String(c.f204):void 0,topStockName:c.f205?String(c.f205):void 0}))}async function go(t,e,n={}){let{period:r="daily"}=n,o=so[r];if(!o)throw new RangeError(`Invalid period: ${r}. 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:Kn,ut:z}),a=`${Ee}?${s.toString()}`,c=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(ao)}var us={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},ls={shanghai:"001",shenzhen:"003"};function ho(t,e){let n=t.split(",");return{date:e,time:n[0]??"",shanghaiNetInflow:p(n[1]),shenzhenNetInflow:p(n[3]),totalNetInflow:p(n[5])}}async function yo(t,e="north"){let n=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:z}),r=`${sn}?${n.toString()}`,i=(await t.get(r,{responseType:"json"}))?.data;if(!i)return[];if(e==="south"){let l=i.n2s??[],c=i.n2sDate??"";return l.map(d=>ho(d,To(c)))}let s=i.s2n??[],a=i.s2nDate??"";return s.map(l=>ho(l,To(a)))}function To(t){return t?/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t:""}async function So(t){return A(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:F(e.TRADE_DATE),type:String(e.MUTUAL_TYPE??""),boardName:String(e.MUTUAL_TYPE_NAME??""),direction:String(e.FUNDS_DIRECTION??""),status:String(e.status??""),netBuyAmount:u(e.netBuyAmt),netInflow:u(e.dayNetAmtIn),remainAmount:u(e.dayAmtRemain),upCount:u(e.f104),flatCount:u(e.f106),downCount:u(e.f105),indexCode:String(e.INDEX_CODE??""),indexName:String(e.INDEX_NAME??""),indexChangePercent:u(e.INDEX_f3)}))}async function Ro(t,e={}){let{market:n="all",period:r="5day",date:o}=e,i=us[r];if(!i)throw new RangeError(`Invalid period: ${r}.`);let s=[`(INTERVAL_TYPE="${i}")`];return o&&s.push(`(TRADE_DATE='${o}')`),n!=="all"&&s.push(`(MUTUAL_TYPE="${ls[n]}")`),A(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:s.join("")},a=>({date:F(a.TRADE_DATE),code:String(a.SECURITY_CODE??""),name:String(a.SECURITY_NAME??a.SECURITY_NAME_ABBR??""),close:u(a.CLOSE_PRICE),changePercent:u(a.CHANGE_RATE),holdShares:u(a.HOLD_SHARES),holdMarketValue:u(a.HOLD_MARKET_CAP),holdRatioFloat:u(a.HOLD_RATIO),holdRatioTotal:u(a.A_SHARES_RATIO),addShares:u(a.ADD_SHARES),addMarketValue:u(a.ADD_MARKET_CAP),addMarketValuePercent:u(a.ADD_MARKET_CAP_PROPORTION),sector:String(a.BOARD_NAME??"")}))}async function Eo(t,e="north",n={}){let{startDate:r,endDate:o}=n,i=[e==="north"?'(BOARD_TYPE="1")':'(BOARD_TYPE="0")'];return r&&i.push(`(TRADE_DATE>='${r}')`),o&&i.push(`(TRADE_DATE<='${o}')`),A(t,{reportName:"RPT_MUTUAL_DEAL_HISTORY",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:i.join("")},s=>({date:F(s.TRADE_DATE),netBuyAmount:u(s.NET_DEAL_AMT),buyAmount:u(s.BUY_AMT),sellAmount:u(s.SELL_AMT),accNetBuyAmount:u(s.ACCUM_DEAL_AMT),netInflow:u(s.FUND_INFLOW),remainAmount:u(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:u(s.LS_CHANGE_RATE)}))}async function Co(t,e,n={}){let r=e.replace(/^(sh|sz|bj)/i,""),{startDate:o,endDate:i}=n,s=[`(SECURITY_CODE="${r}")`];return o&&s.push(`(TRADE_DATE>='${o}')`),i&&s.push(`(TRADE_DATE<='${i}')`),A(t,{reportName:"RPT_MUTUAL_HOLDSTOCKNORTH_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:s.join("")},a=>({date:F(a.TRADE_DATE),holdShares:u(a.HOLD_SHARES),holdMarketValue:u(a.HOLD_MARKET_CAP),holdRatioFloat:u(a.HOLD_RATIO),holdRatioTotal:u(a.A_SHARES_RATIO),close:u(a.CLOSE_PRICE),changePercent:u(a.CHANGE_RATE)}))}var cs={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"}},ds={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"},ps={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 Bn(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 ms(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function fs(t){let e=u(t.p),n=u(t.tp);return{code:String(t.c??t.m??""),name:String(t.n??""),price:e!==null?e/1e3:null,changePercent:u(t.zdp),limitPrice:n!==null?n/1e3:null,amount:u(t.amount??t.zb),floatMarketValue:u(t.ltsz),totalMarketValue:u(t.tshare),turnoverRate:u(t.hs),continuousBoardCount:u(t.lbc),firstBoardTime:t.fbt!==void 0&&t.fbt!==null?Bn(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?Bn(t.lbt):null,boardAmount:u(t.fund),sealAmount:u(t.fund),failedCount:u(t.zbc),industry:String(t.hybk??""),ztStatistics:ms(t.zttj),amplitude:u(t.zf),speed:u(t.zs)}}function gs(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function hs(){let t=new Date(Date.now()+288e5),e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),r=String(t.getUTCDate()).padStart(2,"0");return`${e}${n}${r}`}async function _o(t,e="zt",n){let r=cs[e];if(!r)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=gs(n)??hs(),i=new URLSearchParams({ut:P,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:r.sort,date:o}),s=`${Ce}${r.path}?${i.toString()}`,l=(await t.get(s,{responseType:"json"}))?.data?.pool;return!Array.isArray(l)||l.length===0?[]:l.map(fs)}async function Oo(t,e="large_buy"){let n=ds[e];if(!n)throw new RangeError(`Invalid StockChangeType: ${e}.`);let r=new URLSearchParams({type:n,pageindex:"0",pagesize:"5000",ut:P,dpt:"wzchanges"}),o=`${Ce}/getAllStockChanges?${r.toString()}`,s=(await t.get(o,{responseType:"json"}))?.data?.allstock;return!Array.isArray(s)||s.length===0?[]:s.map(a=>{let l=String(a.t??n);return{time:Bn(a.tm),code:String(a.c??""),name:String(a.n??""),changeType:e,changeTypeLabel:ps[l]??"",info:String(a.i??"")}})}async function Ao(t){let e=new URLSearchParams({ut:P,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),n=`${Ce}/getAllBKChanges?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.data?.allbk;return!Array.isArray(o)||o.length===0?[]:o.map(i=>{let s=i.ms??{},a=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[d,f]of Object.entries(c))l[d]=Number(f)||0;return{name:String(i.bkn??""),changePercent:u(i.bkz),mainNetInflow:u(i.bkj),totalChangeCount:u(i.bkc),topStockCode:String(s.c??""),topStockName:String(s.n??""),topStockDirection:a,changeTypeDistribution:l}})}var Io={"1month":"01","3month":"02","6month":"03","1year":"04"};function we(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}async function Po(t,e){let n=we(e.startDate),r=we(e.endDate);return A(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<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:F(o.TRADE_DATE),close:u(o.CLOSE_PRICE),changePercent:u(o.CHANGE_RATE),netBuyAmount:u(o.BILLBOARD_NET_AMT),buyAmount:u(o.BILLBOARD_BUY_AMT),sellAmount:u(o.BILLBOARD_SELL_AMT),dealAmount:u(o.BILLBOARD_DEAL_AMT),totalAmount:u(o.ACCUM_AMOUNT),netBuyRatio:u(o.DEAL_NET_RATIO),dealAmountRatio:u(o.DEAL_AMOUNT_RATIO),turnoverRate:u(o.TURNOVERRATE),floatMarketValue:u(o.FREE_MARKET_CAP),reason:String(o.EXPLANATION??o.EXPLAIN??""),afterChange1d:u(o.D1_CLOSE_ADJCHRATE),afterChange2d:u(o.D2_CLOSE_ADJCHRATE),afterChange5d:u(o.D5_CLOSE_ADJCHRATE),afterChange10d:u(o.D10_CLOSE_ADJCHRATE)}))}async function Do(t,e="1month"){let n=Io[e];if(!n)throw new RangeError(`Invalid period: ${e}.`);return A(t,{reportName:"RPT_BILLBOARD_TRADEALL",columns:"ALL",sortColumns:"BILLBOARD_TIMES,LATEST_TDATE,SECURITY_CODE",sortTypes:"-1,-1,1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),latestDate:F(r.LATEST_TDATE),close:u(r.CLOSE_PRICE),changePercent:u(r.CHANGE_RATE),count:u(r.BILLBOARD_TIMES),totalBuyAmount:u(r.BILLBOARD_BUY_AMT),totalSellAmount:u(r.BILLBOARD_SELL_AMT),totalNetAmount:u(r.BILLBOARD_NET_AMT),totalDealAmount:u(r.BILLBOARD_DEAL_AMT),buyOrgCount:u(r.ORG_BUY_TIMES),sellOrgCount:u(r.ORG_SELL_TIMES)}))}async function Mo(t,e){let n=we(e.startDate),r=we(e.endDate);return A(t,{reportName:"RPT_ORGANIZATION_TRADE_DETAILS",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:`(TRADE_DATE<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:F(o.TRADE_DATE),close:u(o.CLOSE_PRICE),changePercent:u(o.CHANGE_RATE),buyOrgCount:u(o.BUY_TIMES),sellOrgCount:u(o.SELL_TIMES),orgBuyAmount:u(o.BUY_AMT),orgSellAmount:u(o.SELL_AMT),orgNetAmount:u(o.NET_AMT)}))}async function bo(t,e="1month"){let n=Io[e];if(!n)throw new RangeError(`Invalid period: ${e}.`);return A(t,{reportName:"RPT_BILLBOARD_TRADEDETAILS",columns:"ALL",sortColumns:"TOTAL_BUYER_SALESTIMES",sortTypes:"-1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(r.OPERATEDEPT_CODE??""),name:String(r.OPERATEDEPT_NAME??""),totalBuyAmount:u(r.TOTAL_BUYAMT??r.BUY_AMT),totalSellAmount:u(r.TOTAL_SELLAMT??r.SELL_AMT),buyCount:u(r.TOTAL_BUYER_SALESTIMES??r.BUY_TIMES),sellCount:u(r.TOTAL_SELLER_SALESTIMES??r.SELL_TIMES),totalCount:u(r.TOTAL_TIMES)}))}async function ko(t,e,n){let r=e.replace(/^(sh|sz|bj)/i,""),o=we(n),i=`(SECURITY_CODE="${r}")(TRADE_DATE='${o}')`,[s,a]=await Promise.all([A(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSBUY",columns:"ALL",sortColumns:"BUY_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:u(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:u(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:u(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:u(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:u(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:u(l.NET_AMT),side:"buy"})),A(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSSELL",columns:"ALL",sortColumns:"SELL_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:u(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:u(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:u(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:u(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:u(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:u(l.NET_AMT),side:"sell"}))]);return[...s,...a]}function Lo(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function No(t){if(!t)return"";let e=Lo(t.startDate),n=Lo(t.endDate),r=[];return e&&r.push(`(TRADE_DATE>='${e}')`),n&&r.push(`(TRADE_DATE<='${n}')`),r.join("")}async function Fo(t){return A(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:F(e.TRADE_DATE),shClose:u(e.CLOSE_PRICE??e.SH_CLOSE_PRICE),shChangePercent:u(e.CHANGE_RATE??e.SH_CHANGE_RATE),totalAmount:u(e.TURNOVER??e.TOTAL_AMOUNT),premiumAmount:u(e.PREMIUM_TURNOVER??e.PREMIUM_AMOUNT),premiumRatio:u(e.PREMIUM_RATIO),discountAmount:u(e.DISCOUNT_TURNOVER??e.DISCOUNT_AMOUNT),discountRatio:u(e.DISCOUNT_RATIO)}))}async function xo(t,e={}){let n=No(e);return A(t,{reportName:"RPT_BLOCK_TRADE_DETAIL",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:n||void 0},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:F(r.TRADE_DATE),close:u(r.CLOSE_PRICE),changePercent:u(r.CHANGE_RATE),dealPrice:u(r.DEAL_PRICE??r.PRICE),dealVolume:u(r.DEAL_VOLUME??r.VOLUME),dealAmount:u(r.DEAL_AMT??r.TURNOVER),premiumRate:u(r.PREMIUM_RATIO??r.PREMIUM_RATE),buyBranch:String(r.BUYER_DEPT??r.BUYER_OPERATEDEPT_NAME??""),sellBranch:String(r.SELLER_DEPT??r.SELLER_OPERATEDEPT_NAME??"")}))}async function vo(t,e={}){let n=No(e);return A(t,{reportName:"RPT_BLOCK_TRADE_STA",columns:"ALL",sortColumns:"TRADE_DATE,DEAL_AMT",sortTypes:"-1,-1",pageSize:5e3,filter:n||void 0},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:F(r.TRADE_DATE),changePercent:u(r.CHANGE_RATE),close:u(r.CLOSE_PRICE),dealCount:u(r.DEAL_NUM??r.DEAL_COUNT),dealTotalAmount:u(r.DEAL_AMT??r.TOTAL_AMOUNT),dealTotalVolume:u(r.DEAL_VOLUME??r.TOTAL_VOLUME),premiumAmount:u(r.PREMIUM_AMT??r.PREMIUM_AMOUNT),discountAmount:u(r.DISCOUNT_AMT??r.DISCOUNT_AMOUNT)}))}async function wo(t){return A(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:F(e.STATISTICS_DATE??e.TRADE_DATE),finBalance:u(e.FIN_BALANCE),loanBalance:u(e.LOAN_BALANCE),finBuyAmount:u(e.FIN_BUY_AMT),loanSellAmount:u(e.LOAN_SELL_AMT),investorCount:u(e.OPERATE_INVESTOR_NUM??e.INVESTOR_NUM),liabilityInvestorCount:u(e.MARGIN_INVESTOR_NUM),totalGuarantee:u(e.TOTAL_GUARANTEE),avgGuaranteeRatio:u(e.AVG_GUARANTEE_RATIO)}))}async function Uo(t,e){let n=e?`(TRADE_DATE='${e}')`:void 0;return A(t,{reportName:"RPT_MARGIN_TRADE_DETAIL",columns:"ALL",sortColumns:"FIN_BALANCE",sortTypes:"-1",pageSize:5e3,filter:n},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:F(r.TRADE_DATE),finBalance:u(r.FIN_BALANCE),finBuyAmount:u(r.FIN_BUY_AMT),finRepayAmount:u(r.FIN_REPAY_AMT),loanBalance:u(r.LOAN_BALANCE),loanSellVolume:u(r.LOAN_SELL_VOLUME),loanRepayVolume:u(r.LOAN_REPAY_VOLUME)}))}var q={};mt(q,{getCommodityOptionKline:()=>Yo,getCommodityOptionSpot:()=>Go,getETFOption5DayMinute:()=>Qo,getETFOptionDailyKline:()=>jo,getETFOptionExpireDay:()=>qo,getETFOptionMinute:()=>zo,getETFOptionMonths:()=>Ho,getIndexOptionKline:()=>Bo,getIndexOptionSpot:()=>Ko});function Ts(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:u(t[7]),symbol:t[8]??""}}function ys(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:null,symbol:t[7]??""}}async function Ko(t,e){let n=`${Ae}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,r=await N(n),o=r?.result?.data?.up??[],i=r?.result?.data?.down??[];return{calls:o.map(Ts),puts:i.map(ys)}}async function Bo(t){let e=`${Ie}?symbol=${t}`,n=await N(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:u(r.o),high:u(r.h),low:u(r.l),close:u(r.c),volume:u(r.v)})):[]}async function Ho(t){let e=`${ln}?exchange=null&cate=${encodeURIComponent(t)}`,r=(await N(e))?.result?.data,o=r?.contractMonth??[];return{months:o.length>1?o.slice(1):o,stockId:r?.stockId??"",cateId:r?.cateId??"",cateList:r?.cateList??[]}}async function qo(t,e){let n=`${yt}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,r=await N(n),o=r?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let s=`${yt}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;r=await N(s)}let i=r?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function $o(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:u(n.p),volume:u(n.v),openInterest:u(n.t),avgPrice:u(n.a)}))}async function zo(t){let e=`CON_OP_${t}`,n=`${cn}?symbol=${e}`,o=(await N(n))?.result?.data;return Array.isArray(o)?$o(o):[]}async function jo(t){let e=`CON_OP_${t}`,n=`${dn}?symbol=${e}`,r=await N(n,{callbackMode:"path"});return Array.isArray(r)?r.map(o=>({date:o.d,open:u(o.o),high:u(o.h),low:u(o.l),close:u(o.c),volume:u(o.v)})):[]}async function Qo(t){let e=`CON_OP_${t}`,n=`${pn}?symbol=${e}`,o=(await N(n))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...$o(s));return i}function Ss(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:u(t[7]),symbol:t[8]??""}}function Rs(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:null,symbol:t[7]??""}}async function Go(t,e){let n=St[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(St).join(", ")}`);let r=`${Ae}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,o=await N(r),i=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:i.map(Ss),puts:s.map(Rs)}}async function Yo(t){let e=`${Ie}?symbol=${t}`,n=await N(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:u(r.o),high:u(r.h),low:u(r.l),close:u(r.c),volume:u(r.v)})):[]}var I=class{constructor(e){this.client=e}};var Ue=class extends I{constructor(e){super(e)}getFullQuotes(e){return D.getFullQuotes(this.client,e)}getSimpleQuotes(e){return D.getSimpleQuotes(this.client,e)}getHKQuotes(e){return D.getHKQuotes(this.client,e)}getUSQuotes(e){return D.getUSQuotes(this.client,e)}getFundQuotes(e){return D.getFundQuotes(this.client,e)}getFundFlow(e){return D.getFundFlow(this.client,e)}getPanelLargeOrder(e){return D.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return D.getTodayTimeline(this.client,e)}search(e){return D.search(this.client,e)}getAShareCodeList(e){return D.getAShareCodeList(this.client,e)}getUSCodeList(e){return D.getUSCodeList(this.client,e)}getHKCodeList(){return D.getHKCodeList(this.client)}getFundCodeList(){return D.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...r}=e,o=await this.getAShareCodeList({market:n});return D.getAllQuotesByCodes(this.client,o,r)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return D.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...r}=e,o=await this.getUSCodeList({simple:!0,market:n});return D.getAllUSQuotesByCodes(this.client,o,r)}getAllQuotesByCodes(e,n={}){return D.getAllQuotesByCodes(this.client,e,n)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return D.getTradingCalendar(this.client)}getDividendDetail(e){return y.getDividendDetail(this.client,e)}};var Ke=class extends I{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,n){return y.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return y.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return y.getConceptList(this.client)}getConceptSpot(e){return y.getConceptSpot(this.client,e)}getConceptConstituents(e){return y.getConceptConstituents(this.client,e)}getConceptKline(e,n){return y.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return y.getConceptMinuteKline(this.client,e,n)}};var Be=class extends I{constructor(e){super(e)}getHistoryKline(e,n){return y.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return y.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return y.getHKHistoryKline(this.client,e,n)}getHKMinuteKline(e,n){return y.getHKMinuteKline(this.client,e,n)}getUSHistoryKline(e,n){return y.getUSHistoryKline(this.client,e,n)}getUSMinuteKline(e,n){return y.getUSMinuteKline(this.client,e,n)}};var He=class extends I{constructor(e){super(e)}getFuturesKline(e,n){return y.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return y.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return y.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return y.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return y.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return y.getComexInventory(this.client,e,n)}};var qe=class extends I{constructor(e){super(e)}getIndexOptionSpot(e,n){return q.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return q.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return y.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return q.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return q.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return q.getETFOptionMinute(e)}getETFOptionDailyKline(e){return q.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return q.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return q.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return q.getCommodityOptionKline(e)}getOptionLHB(e,n){return y.getOptionLHB(this.client,e,n)}};function $e(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ee(t,e){let n=[];for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let o=0,i=0;for(let s=r-e+1;s<=r;s++)t[s]!==null&&(o+=t[s],i++);n.push(i===e?$e(o/e):null)}return n}function V(t,e){let n=[],r=2/(e+1),o=null,i=!1;for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}if(!i){let l=0,c=0;for(let d=s-e+1;d<=s;d++)t[d]!==null&&(l+=t[d],c++);c===e&&(o=l/e,i=!0),n.push(o!==null?$e(o):null);continue}let a=t[s];a===null?n.push(o!==null?$e(o):null):(o=r*a+(1-r)*o,n.push($e(o)))}return n}function bt(t,e){let n=[],r=Array.from({length:e},(i,s)=>s+1),o=r.reduce((i,s)=>i+s,0);for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let s=0,a=!0;for(let l=0;l<e;l++){let c=t[i-e+1+l];if(c===null){a=!1;break}s+=c*r[l]}n.push(a?$e(s/o):null)}return n}function ze(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:r="sma"}=e,o=r==="ema"?V:r==="wma"?bt:ee,i={};for(let s of n)i[`ma${s}`]=o(t,s);return t.map((s,a)=>{let l={};for(let c of n)l[`ma${c}`]=i[`ma${c}`][a];return l})}function Vo(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function je(t,e={}){let{short:n=12,long:r=26,signal:o=9}=e,i=V(t,n),s=V(t,r),a=t.map((c,d)=>i[d]===null||s[d]===null?null:i[d]-s[d]),l=V(a,o);return t.map((c,d)=>({dif:a[d]!==null?Vo(a[d]):null,dea:l[d],macd:a[d]!==null&&l[d]!==null?Vo((a[d]-l[d])*2):null}))}function Hn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Es(t,e,n){let r=[];for(let o=0;o<t.length;o++){if(o<e-1||n[o]===null){r.push(null);continue}let i=0,s=0;for(let a=o-e+1;a<=o;a++)t[a]!==null&&n[o]!==null&&(i+=Math.pow(t[a]-n[o],2),s++);r.push(s===e?Math.sqrt(i/e):null)}return r}function Qe(t,e={}){let{period:n=20,stdDev:r=2}=e,o=ee(t,n),i=Es(t,n,o);return t.map((s,a)=>{if(o[a]===null||i[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=o[a]+r*i[a],c=o[a]-r*i[a],d=o[a]!==0?Hn((l-c)/o[a]*100):null;return{mid:o[a],upper:Hn(l),lower:Hn(c),bandwidth:d}})}function qn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ge(t,e={}){let{period:n=9,kPeriod:r=3,dPeriod:o=3}=e,i=[],s=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){i.push({k:null,d:null,j:null});continue}let c=-1/0,d=1/0,f=!0;for(let m=l-n+1;m<=l;m++){if(t[m].high===null||t[m].low===null){f=!1;break}c=Math.max(c,t[m].high),d=Math.min(d,t[m].low)}let g=t[l].close;if(!f||g===null||c===d){i.push({k:null,d:null,j:null});continue}let T=(g-d)/(c-d)*100;s=(r-1)/r*s+1/r*T,a=(o-1)/o*a+1/o*s;let R=3*s-2*a;i.push({k:qn(s),d:qn(a),j:qn(R)})}return i}function Cs(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ye(t,e={}){let{periods:n=[6,12,24]}=e,r=[null];for(let i=1;i<t.length;i++)t[i]===null||t[i-1]===null?r.push(null):r.push(t[i]-t[i-1]);let o={};for(let i of n){let s=[],a=0,l=0;for(let c=0;c<t.length;c++){if(c<i){s.push(null),r[c]!==null&&(r[c]>0?a+=r[c]:l+=Math.abs(r[c]));continue}if(c===i)a=a/i,l=l/i;else{let d=r[c]??0,f=d>0?d:0,g=d<0?Math.abs(d):0;a=(a*(i-1)+f)/i,l=(l*(i-1)+g)/i}if(l===0)s.push(100);else if(a===0)s.push(0);else{let d=a/l;s.push(Cs(100-100/(1+d)))}}o[`rsi${i}`]=s}return t.map((i,s)=>{let a={};for(let l of n)a[`rsi${l}`]=o[`rsi${l}`][s];return a})}function _s(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ve(t,e={}){let{periods:n=[6,10]}=e,r={};for(let o of n){let i=[];for(let s=0;s<t.length;s++){if(s<o-1){i.push(null);continue}let a=-1/0,l=1/0,c=!0;for(let g=s-o+1;g<=s;g++){if(t[g].high===null||t[g].low===null){c=!1;break}a=Math.max(a,t[g].high),l=Math.min(l,t[g].low)}let d=t[s].close;if(!c||d===null||a===l){i.push(null);continue}let f=(a-d)/(a-l)*100;i.push(_s(f))}r[`wr${o}`]=i}return t.map((o,i)=>{let s={};for(let a of n)s[`wr${a}`]=r[`wr${a}`][i];return s})}function Os(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function We(t,e={}){let{periods:n=[6,12,24]}=e,r={};for(let o of n){let i=ee(t,o),s=[];for(let a=0;a<t.length;a++)if(t[a]===null||i[a]===null||i[a]===0)s.push(null);else{let l=(t[a]-i[a])/i[a]*100;s.push(Os(l))}r[`bias${o}`]=s}return t.map((o,i)=>{let s={};for(let a of n)s[`bias${a}`]=r[`bias${a}`][i];return s})}function As(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Xe(t,e={}){let{period:n=14}=e,r=[],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<n-1){r.push({cci:null});continue}let s=0,a=0;for(let f=i-n+1;f<=i;f++)o[f]!==null&&(s+=o[f],a++);if(a!==n||o[i]===null){r.push({cci:null});continue}let l=s/n,c=0;for(let f=i-n+1;f<=i;f++)c+=Math.abs(o[f]-l);let d=c/n;if(d===0)r.push({cci:0});else{let f=(o[i]-l)/(.015*d);r.push({cci:As(f)})}}return r}function $n(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ce(t,e={}){let{period:n=14}=e,r=[],o=[];for(let s=0;s<t.length;s++){let{high:a,low:l,close:c}=t[s];if(a===null||l===null||c===null){o.push(null);continue}if(s===0)o.push(a-l);else{let d=t[s-1].close;if(d===null)o.push(a-l);else{let f=a-l,g=Math.abs(a-d),T=Math.abs(l-d);o.push(Math.max(f,g,T))}}}let i=null;for(let s=0;s<t.length;s++){if(s<n-1){r.push({tr:o[s]!==null?$n(o[s]):null,atr:null});continue}if(s===n-1){let a=0,l=0;for(let c=0;c<n;c++)o[c]!==null&&(a+=o[c],l++);l===n&&(i=a/n)}else i!==null&&o[s]!==null&&(i=(i*(n-1)+o[s])/n);r.push({tr:o[s]!==null?$n(o[s]):null,atr:i!==null?$n(i):null})}return r}function Ze(t,e={}){let{maPeriod:n}=e,r=[];if(t.length===0)return r;let o=t[0].volume??0;r.push({obv:o,obvMa:null});for(let i=1;i<t.length;i++){let s=t[i],a=t[i-1];if(s.close===null||a.close===null||s.volume===null||s.volume===void 0){r.push({obv:null,obvMa:null});continue}s.close>a.close?o+=s.volume:s.close<a.close&&(o-=s.volume),r.push({obv:o,obvMa:null})}if(n&&n>0)for(let i=n-1;i<r.length;i++){let s=0,a=0;for(let l=i-n+1;l<=i;l++)r[l].obv!==null&&(s+=r[l].obv,a++);a===n&&(r[i].obvMa=s/n)}return r}function Je(t,e={}){let{period:n=12,signalPeriod:r}=e,o=[];for(let i=0;i<t.length;i++){if(i<n){o.push({roc:null,signal:null});continue}let s=t[i].close,a=t[i-n].close;if(s===null||a===null||a===0){o.push({roc:null,signal:null});continue}let l=(s-a)/a*100;o.push({roc:l,signal:null})}if(r&&r>0)for(let i=n+r-1;i<o.length;i++){let s=0,a=0;for(let l=i-r+1;l<=i;l++)o[l].roc!==null&&(s+=o[l].roc,a++);a===r&&(o[i].signal=s/r)}return o}function et(t,e={}){let{period:n=14,adxPeriod:r=n}=e,o=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let i=[],s=[],a=[];for(let m=0;m<t.length;m++){if(m===0){i.push(0),s.push(0),a.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let h=t[m],E=t[m-1];if(h.high===null||h.low===null||h.close===null||E.high===null||E.low===null||E.close===null){i.push(0),s.push(0),a.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let _=h.high-h.low,M=Math.abs(h.high-E.close),b=Math.abs(h.low-E.close);a.push(Math.max(_,M,b));let k=h.high-E.high,$=E.low-h.low;k>$&&k>0?i.push(k):i.push(0),$>k&&$>0?s.push($):s.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,c=0,d=0,f=[];for(let m=1;m<t.length;m++){if(m<n){l+=a[m],c+=i[m],d+=s[m],f.push(0);continue}m===n?(l=l,c=c,d=d):(l=l-l/n+a[m],c=c-c/n+i[m],d=d-d/n+s[m]);let h=l>0?c/l*100:0,E=l>0?d/l*100:0;o[m].pdi=h,o[m].mdi=E;let _=h+E,M=_>0?Math.abs(h-E)/_*100:0;f.push(M)}let g=0,T=0,R=0;for(let m=n;m<t.length;m++){if(m<n*2-1){g+=f[m-n+1]||0,T++;continue}if(m===n*2-1)g+=f[m-n+1]||0,R=g/r,o[m].adx=R;else{let h=f[m-n+1]||0;R=(R*(r-1)+h)/r,o[m].adx=R}}for(let m=n*2-1+r;m<t.length;m++){let h=o[m].adx,E=o[m-r]?.adx;h!==null&&E!==null&&(o[m].adxr=(h+E)/2)}return o}function tt(t,e={}){let{afStart:n=.02,afIncrement:r=.02,afMax:o=.2}=e,i=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,a=n,l=t[0].high??0,c=t[0].low??0,d=t[0],f=t[1];d.close!==null&&f.close!==null&&f.close<d.close&&(s=-1,l=d.low??0,c=d.high??0),i.push({sar:null,trend:null,ep:null,af:null});for(let g=1;g<t.length;g++){let T=t[g],R=t[g-1];if(T.high===null||T.low===null||R.high===null||R.low===null){i.push({sar:null,trend:null,ep:null,af:null});continue}let m=c+a*(l-c);s===1?(m=Math.min(m,R.low,t[Math.max(0,g-2)]?.low??R.low),T.low<m?(s=-1,m=l,l=T.low,a=n):T.high>l&&(l=T.high,a=Math.min(a+r,o))):(m=Math.max(m,R.high,t[Math.max(0,g-2)]?.high??R.high),T.high>m?(s=1,m=l,l=T.high,a=n):T.low<l&&(l=T.low,a=Math.min(a+r,o))),c=m,i.push({sar:c,trend:s,ep:l,af:a})}return i}function nt(t,e={}){let{emaPeriod:n=20,atrPeriod:r=10,multiplier:o=2}=e,i=[],s=t.map(c=>c.close),a=V(s,n),l=ce(t,{period:r});for(let c=0;c<t.length;c++){let d=a[c],f=l[c]?.atr;if(d===null||f===null){i.push({mid:null,upper:null,lower:null,width:null});continue}let g=d+o*f,T=d-o*f,R=d>0?(g-T)/d*100:null;i.push({mid:d,upper:g,lower:T,width:R})}return i}function kt(t,e=0){return t.length===0?e:Math.max(...t)}function rt(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 de={ma:{key:"ma",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.periods??[5,10,20,30,60,120,250],r=e.type??"sma";return{bars:kt(n,20),emaBased:r==="ema"}},compute:(t,e)=>ze(t.closes,typeof e=="object"?e:{})},macd:{key:"macd",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.long??26,r=e.signal??9;return{bars:n*3+r,emaBased:!0}},compute:(t,e)=>je(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>Qe(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>Ge(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:kt(e,14)+1}},compute:(t,e)=>Ye(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:kt(e,10)}},compute:(t,e)=>Ve(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:kt(e,12)}},compute:(t,e)=>We(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>Xe(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>ce(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)=>Ze(t.ohlcv,typeof e=="object"?e:{})},roc:{key:"roc",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.period??12,r=e.signalPeriod??0;return{bars:n+r}},compute:(t,e)=>Je(t.ohlcv,typeof e=="object"?e:{})},dmi:{key:"dmi",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.period??14,r=e.adxPeriod??n;return{bars:n*2+r}},compute:(t,e)=>et(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>tt(t.ohlcv,typeof e=="object"?e:{})},kc:{key:"kc",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.emaPeriod??20,r=e.atrPeriod??10;return{bars:Math.max(n*3,r),emaBased:!0}},compute:(t,e)=>nt(t.ohlcv,typeof e=="object"?e:{})}};function ye(t){return Object.keys(de).filter(e=>!!t[e])}function ot(t){let e=0,n=!1;for(let o of ye(t)){let s=de[o].estimateLookback(t[o]);e=Math.max(e,s.bars),n||(n=!!s.emaBased)}return{maxLookback:e,hasEmaBasedIndicator:n,requiredBars:Math.ceil(e*(n?1.5:1.2))}}function it(t,e={}){if(t.length===0)return[];let n=rt(t),r=new Map;for(let o of ye(e)){let i=de[o];r.set(o,i.compute(n,e[o]))}return t.map((o,i)=>({...o,...Object.fromEntries(Array.from(r.entries()).map(([s,a])=>[s,a[i]]))}))}var st=class{constructor(e,n){this.klineService=e;this.quoteService=n}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}calcActualStartDate(e,n,r=1.5){let o=this.toCompactDate(e),i=Math.ceil(n*r),s=new Date(parseInt(o.slice(0,4)),parseInt(o.slice(4,6))-1,parseInt(o.slice(6,8)));s.setDate(s.getDate()-i);let a=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),c=String(s.getDate()).padStart(2,"0");return`${a}${l}${c}`}calcActualStartDateByCalendar(e,n,r){if(!r||r.length===0)return;let o=this.normalizeDate(e),i=r.findIndex(a=>a>=o);i===-1&&(i=r.length-1);let s=Math.max(0,i-n);return this.toCompactDate(r[s])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:r,endDate:o,indicators:i={}}=n,s=n.market??this.detectMarket(e),{requiredBars:a}=ot(i),l={A:1.5,HK:1.46,US:1.45},c;if(r)if(s==="A")try{let T=await this.quoteService.getTradingCalendar();c=this.calcActualStartDateByCalendar(r,a,T)??this.calcActualStartDate(r,a,l[s])}catch{c=this.calcActualStartDate(r,a,l[s])}else c=this.calcActualStartDate(r,a,l[s]);let d={period:n.period,adjust:n.adjust,startDate:c,endDate:n.endDate?this.toCompactDate(n.endDate):void 0},f;switch(s){case"HK":f=await this.klineService.getHKHistoryKline(e,d);break;case"US":f=await this.klineService.getUSHistoryKline(e,d);break;default:f=await this.klineService.getHistoryKline(e,d)}if(r&&f.length<a)switch(s){case"HK":f=await this.klineService.getHKHistoryKline(e,{...d,startDate:void 0});break;case"US":f=await this.klineService.getUSHistoryKline(e,{...d,startDate:void 0});break;default:f=await this.klineService.getHistoryKline(e,{...d,startDate:void 0})}let g=it(f,i);if(r){let T=this.dateToTimestamp(r),R=o?this.dateToTimestamp(o):1/0;return g.filter(m=>{let h=this.dateToTimestamp(m.date);return h>=T&&h<=R})}return g}};var at=class extends I{constructor(e){super(e)}getIndividualFundFlow(e,n){return y.getIndividualFundFlow(this.client,e,n)}getMarketFundFlow(){return y.getMarketFundFlow(this.client)}getFundFlowRank(e){return y.getFundFlowRank(this.client,e)}getSectorFundFlowRank(e){return y.getSectorFundFlowRank(this.client,e)}getSectorFundFlowHistory(e,n){return y.getSectorFundFlowHistory(this.client,e,n)}};var ut=class extends I{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,n){return y.getNorthboundHistory(this.client,e,n)}getNorthboundIndividual(e,n){return y.getNorthboundIndividual(this.client,e,n)}};var lt=class extends I{constructor(e){super(e)}getZTPool(e,n){return y.getZTPool(this.client,e,n)}getStockChanges(e){return y.getStockChanges(this.client,e)}getBoardChanges(){return y.getBoardChanges(this.client)}};var ct=class extends I{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,n){return y.getDragonTigerStockSeatDetail(this.client,e,n)}};var dt=class extends I{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 w=(t,e)=>t*60+e,Is={A:{tz:C.CN,open:[[w(9,30),w(11,30)],[w(13,0),w(15,0)]],lunchBreak:[w(11,30),w(13,0)],tradingWeekdays:[1,2,3,4,5]},HK:{tz:C.HK,open:[[w(9,30),w(12,0)],[w(13,0),w(16,0)]],lunchBreak:[w(12,0),w(13,0)],tradingWeekdays:[1,2,3,4,5]},US:{tz:C.US,open:[[w(9,30),w(16,0)]],tradingWeekdays:[1,2,3,4,5]}};function zn(t,e){if(t==null)return jn(new Date,e);if(t instanceof Date)return jn(t,e);let n=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(n))return n;if(/^\d{8}$/.test(n))return`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`;let r=new Date(n);if(!Number.isNaN(r.getTime()))return jn(r,e);throw new RangeError(`Unsupported date input: ${JSON.stringify(t)}. Expected 'YYYY-MM-DD', 'YYYYMMDD', or Date.`)}function jn(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(t)}function Ps(t,e){let n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,weekday:"short",hour:"2-digit",minute:"2-digit"}),r={};for(let l of n.formatToParts(t))l.type!=="literal"&&(r[l.type]=l.value);let o=parseInt(r.hour??"0",10);o===24&&(o=0);let i=parseInt(r.minute??"0",10),a={Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6,Sun:7}[r.weekday??""]??0;return{minutes:o*60+i,weekday:a}}function Qn(t,e){let n=0,r=t.length;for(;n<r;){let o=n+r>>>1;t[o]<e?n=o+1:r=o}return n}var pe=class{constructor(e){this.quoteService=e}async isTradingDay(e){let n=zn(e,C.CN),r=await this.quoteService.getTradingCalendar(),o=Qn(r,n);return o<r.length&&r[o]===n}async nextTradingDay(e){let n=zn(e,C.CN),r=await this.quoteService.getTradingCalendar(),o=Qn(r,n);if(o<r.length&&r[o]===n&&(o+=1),o>=r.length)throw new RangeError(`nextTradingDay: ${n} \u4E4B\u540E\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5927\u65E5\u671F ${r[r.length-1]??"N/A"})`);return r[o]}async prevTradingDay(e){let n=zn(e,C.CN),r=await this.quoteService.getTradingCalendar(),i=Qn(r,n)-1;if(i<0)throw new RangeError(`prevTradingDay: ${n} \u4E4B\u524D\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5C0F\u65E5\u671F ${r[0]??"N/A"})`);return r[i]}getMarketStatus(e="A",n=new Date){let r=Is[e],{minutes:o,weekday:i}=Ps(n,r.tz);if(!r.tradingWeekdays.includes(i))return"closed";let s=r.open[0][0],a=r.open[r.open.length-1][1];if(o<s)return"pre_market";if(o>=a)return"after_hours";for(let[l,c]of r.open)if(o>=l&&o<c)return"open";return r.lunchBreak&&o>=r.lunchBreak[0]&&o<r.lunchBreak[1]?"lunch_break":"closed"}};var me=class extends I{constructor(e){super(e)}getFundDividendList(e){return y.getFundDividendList(this.client,e)}getFundNavHistory(e){return y.getFundNavHistory(this.client,e)}getFundEstimate(e){return y.getFundEstimate(this.client,e)}getFundRankHistory(e){return y.getFundRankHistory(this.client,e)}};var pt=class{constructor(e={}){this.client=new Le(e),this.quoteService=new Ue(this.client),this.boardService=new Ke(this.client),this.klineService=new Be(this.client),this.futuresService=new He(this.client),this.optionsService=new qe(this.client),this.indicatorService=new st(this.klineService,this.quoteService),this.fundFlowService=new at(this.client),this.northboundService=new ut(this.client),this.marketEventService=new lt(this.client),this.dragonTigerService=new ct(this.client),this.dataService=new dt(this.client),this.tradingCalendarService=new pe(this.quoteService),this.fundService=new me(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,n){return this.boardService.getIndustryKline(e,n)}getIndustryMinuteKline(e,n){return this.boardService.getIndustryMinuteKline(e,n)}getConceptList(){return this.boardService.getConceptList()}getConceptSpot(e){return this.boardService.getConceptSpot(e)}getConceptConstituents(e){return this.boardService.getConceptConstituents(e)}getConceptKline(e,n){return this.boardService.getConceptKline(e,n)}getConceptMinuteKline(e,n){return this.boardService.getConceptMinuteKline(e,n)}getHistoryKline(e,n){return this.klineService.getHistoryKline(e,n)}getMinuteKline(e,n){return this.klineService.getMinuteKline(e,n)}getHKHistoryKline(e,n){return this.klineService.getHKHistoryKline(e,n)}getHKMinuteKline(e,n){return this.klineService.getHKMinuteKline(e,n)}getUSHistoryKline(e,n){return this.klineService.getUSHistoryKline(e,n)}getUSMinuteKline(e,n){return this.klineService.getUSMinuteKline(e,n)}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,n={}){return this.quoteService.getAllQuotesByCodes(e,n)}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,n){return this.futuresService.getFuturesKline(e,n)}getGlobalFuturesSpot(e){return this.futuresService.getGlobalFuturesSpot(e)}getGlobalFuturesKline(e,n){return this.futuresService.getGlobalFuturesKline(e,n)}getFuturesInventorySymbols(){return this.futuresService.getFuturesInventorySymbols()}getFuturesInventory(e,n){return this.futuresService.getFuturesInventory(e,n)}getComexInventory(e,n){return this.futuresService.getComexInventory(e,n)}getIndexOptionSpot(e,n){return this.optionsService.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return this.optionsService.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return this.optionsService.getCFFEXOptionQuotes(e)}getETFOptionMonths(e){return this.optionsService.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return this.optionsService.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return this.optionsService.getETFOptionMinute(e)}getETFOptionDailyKline(e){return this.optionsService.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return this.optionsService.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return this.optionsService.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return this.optionsService.getCommodityOptionKline(e)}getOptionLHB(e,n){return this.optionsService.getOptionLHB(e,n)}getKlineWithIndicators(e,n={}){return this.indicatorService.getKlineWithIndicators(e,n)}getIndividualFundFlow(e,n){return this.fundFlowService.getIndividualFundFlow(e,n)}getMarketFundFlow(){return this.fundFlowService.getMarketFundFlow()}getFundFlowRank(e){return this.fundFlowService.getFundFlowRank(e)}getSectorFundFlowRank(e){return this.fundFlowService.getSectorFundFlowRank(e)}getSectorFundFlowHistory(e,n){return this.fundFlowService.getSectorFundFlowHistory(e,n)}getNorthboundMinute(e){return this.northboundService.getNorthboundMinute(e)}getNorthboundFlowSummary(){return this.northboundService.getNorthboundFlowSummary()}getNorthboundHoldingRank(e){return this.northboundService.getNorthboundHoldingRank(e)}getNorthboundHistory(e,n){return this.northboundService.getNorthboundHistory(e,n)}getNorthboundIndividual(e,n){return this.northboundService.getNorthboundIndividual(e,n)}getZTPool(e,n){return this.marketEventService.getZTPool(e,n)}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,n){return this.dragonTigerService.getDragonTigerStockSeatDetail(e,n)}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)}getFundDividendList(e){return this.fundService.getFundDividendList(e)}getFundNavHistory(e){return this.fundService.getFundNavHistory(e)}getFundEstimate(e){return this.fundService.getFundEstimate(e)}getFundRankHistory(e){return this.fundService.getFundRankHistory(e)}},Wo=pt;var Ds={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},Ms={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},bs={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function ks(t){let e=t.code.trim(),n=t.market.trim().toLowerCase(),r=Ds[t.market]??n;return r==="sh"||r==="sz"?{code:e.replace(/^(sh|sz)/i,""),market:r}:r==="hk"?{code:e.replace(/^hk/i,"").padStart(5,"0"),market:r}:r==="us"?{code:e.replace(/^us/i,"").replace(/^\d{3}\./,"").toUpperCase(),market:r}:r==="global"?{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:r}:/^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 Ls(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Ns(t){let{code:e,market:n}=t;return(n==="sh"||n==="sz")&&Ls(e,n)?`https://quote.eastmoney.com/zs${e}.html`:n==="sh"||n==="sz"?`https://quote.eastmoney.com/${n}${e}.html`:n==="hk"?`https://quote.eastmoney.com/hk/${e}.html`:n==="us"?`https://quote.eastmoney.com/us/${e}.html`:n==="global"?`https://quote.eastmoney.com/gb/zs${bs[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function Fs(t){let{code:e,market:n}=t;return n==="sh"||n==="sz"?`https://xueqiu.com/S/${n.toUpperCase()}${e}`:n==="hk"?`https://xueqiu.com/S/${e}`:n==="us"?`https://xueqiu.com/S/${e}`:n==="global"?`https://xueqiu.com/S/${Ms[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function Xo(t){let e=ks(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Ns(e)},{name:"\u96EA\u7403",url:Fs(e)}]}0&&(module.exports={BROWSER_JSVARS_MUTEX_KEY,FundService,HttpError,INDICATOR_REGISTRY,MARKET_TZ,SdkError,StockSDK,TradingCalendarService,addIndicators,asyncPool,buildIndicatorContext,buildTimeMeta,buildTimeMetaFromDateAndTime,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,estimateIndicatorLookback,extractJsonFromJsonp,fetchJsVars,formatInTz,generateSearchExternalLinks,getEnabledIndicatorKeys,getSdkErrorCode,jsonpRequest,parseJsVars,parseMarketTime,parseResponse,safeNumber,safeNumberOrNull,withScriptMutex});
|
|
1
|
+
"use strict";var wt=Object.defineProperty;var Zo=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var ei=Object.prototype.hasOwnProperty;var mt=(t,e)=>{for(var n in e)wt(t,n,{get:e[n],enumerable:!0})},ti=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Jo(e))!ei.call(t,o)&&o!==n&&wt(t,o,{get:()=>e[o],enumerable:!(r=Zo(e,o))||r.enumerable});return t};var ni=t=>ti(wt({},"__esModule",{value:!0}),t);var xs={};mt(xs,{BROWSER_JSVARS_MUTEX_KEY:()=>On,FundService:()=>me,HttpError:()=>j,INDICATOR_REGISTRY:()=>de,MARKET_TZ:()=>C,SdkError:()=>w,StockSDK:()=>pt,TradingCalendarService:()=>pe,addIndicators:()=>it,asyncPool:()=>oe,buildIndicatorContext:()=>rt,buildTimeMeta:()=>L,buildTimeMetaFromDateAndTime:()=>Fe,calcATR:()=>ce,calcBIAS:()=>We,calcBOLL:()=>Qe,calcCCI:()=>Xe,calcDMI:()=>et,calcEMA:()=>V,calcKC:()=>nt,calcKDJ:()=>Ge,calcMA:()=>ze,calcMACD:()=>je,calcOBV:()=>Ze,calcROC:()=>Je,calcRSI:()=>Ye,calcSAR:()=>tt,calcSMA:()=>ee,calcWMA:()=>bt,calcWR:()=>Ve,chunkArray:()=>re,decodeGBK:()=>Se,default:()=>Wo,estimateIndicatorLookback:()=>ot,extractJsonFromJsonp:()=>Te,fetchJsVars:()=>ae,formatInTz:()=>ue,generateSearchExternalLinks:()=>Xo,getEnabledIndicatorKeys:()=>ye,getSdkErrorCode:()=>Z,jsonpRequest:()=>N,parseJsVars:()=>Ne,parseMarketTime:()=>J,parseResponse:()=>Re,safeNumber:()=>R,safeNumberOrNull:()=>_,withScriptMutex:()=>se});module.exports=ni(xs);function Se(t){return new TextDecoder("gbk").decode(t)}function Re(t){let e=t.split(";").map(r=>r.trim()).filter(Boolean),n=[];for(let r of e){let o=r.indexOf("=");if(o<0)continue;let i=r.slice(0,o).trim();i.startsWith("v_")&&(i=i.slice(2));let s=r.slice(o+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");n.push({key:i,fields:a})}return n}function R(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function _(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 u(t){return t==null?null:m(String(t))}var Ut="https://qt.gtimg.cn",Kt="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Bt="https://assets.linkdiary.cn/shares/zh_a_list.json",Ht="https://assets.linkdiary.cn/shares/us_list.json",qt="https://assets.linkdiary.cn/shares/hk_list.json",$t="https://assets.linkdiary.cn/shares/fund_list",Gn="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ft="https://push2his.eastmoney.com/api/qt/stock/kline/get",zt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",gt="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",ht="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",jt="https://33.push2his.eastmoney.com/api/qt/stock/trends2/get",Qt="https://63.push2his.eastmoney.com/api/qt/stock/trends2/get",Gt="https://17.push2.eastmoney.com/api/qt/clist/get",Yt="https://91.push2.eastmoney.com/api/qt/stock/get",Vt="https://29.push2.eastmoney.com/api/qt/clist/get",Wt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Xt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Zt="https://79.push2.eastmoney.com/api/qt/clist/get",Jt="https://91.push2.eastmoney.com/api/qt/stock/get",en="https://29.push2.eastmoney.com/api/qt/clist/get",tn="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",nn="https://push2his.eastmoney.com/api/qt/stock/trends2/get",rn="https://datacenter-web.eastmoney.com/api/data/v1/get",Ee="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",on="https://push2.eastmoney.com/api/qt/clist/get",sn="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",Ce="https://push2ex.eastmoney.com",D="7eea3edcaed734bea9cbfc24409ed989",z="b2884a393a59ad64002292a3e90d46a5",Oe="https://push2his.eastmoney.com/api/qt/stock/kline/get",an="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",_e="58b2fa8f54638b60b87d69b31969089c",un={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},fe={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"},Tt={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},Ae="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",Ie="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",ln="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",yt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",cn="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",dn="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",pn="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",mn="https://futsseapi.eastmoney.com/list/option/221",fn="https://datacenter-web.eastmoney.com/api/data/get";var St={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"}},gn=3e4,Pe=500,De=500,Me=7,hn=3,Tn=1e3,yn=3e4,Sn=2,Rn=[408,429,500,502,503,504];var Rt=class{constructor(e={}){this.acquireChain=Promise.resolve();let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),r=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+r),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.acquireChain,n;this.acquireChain=new Promise(r=>{n=r});try{await e;let r=this.getWaitTime();r>0&&await this.sleep(r),this.refill(),this.tokens-=1}finally{n()}}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Yn=["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"],En=0;function ri(){return typeof window<"u"&&typeof window.document<"u"}function Vn(){if(ri())return;let t=Yn[En];return En=(En+1)%Yn.length,t}var w=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)}},j=class extends w{constructor(n,r,o,i){let s=r?` ${r}`:"",a=o?`, url: ${o}`:"",l=i?`, provider: ${i}`:"";super({code:n===429?"RATE_LIMITED":"HTTP_ERROR",message:`HTTP error! status: ${n}${s}${a}${l}`,status:n,url:o,provider:i,details:{statusText:r}});this.status=n;this.name="HttpError",this.statusText=r}};var ke=class extends w{constructor(e,n,r){super({code:"NOT_FOUND",message:e,provider:n,url:r}),this.name="NotFoundError"}};function be(t,e){let n=t;return!n.sdkCode&&e.sdkCode&&(n.sdkCode=e.sdkCode),!n.provider&&e.provider&&(n.provider=e.provider),!n.url&&e.url&&(n.url=e.url),n.status===void 0&&e.status!==void 0&&(n.status=e.status),!n.details&&e.details&&(n.details=e.details),n}function oi(t,e){return be(t,{provider:e.provider,url:e.url})}function Z(t){if(t instanceof w||t instanceof j)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 Et(t,e={}){return t instanceof w?oi(t,e):t instanceof DOMException&&t.name==="AbortError"?be(t,{sdkCode:"TIMEOUT",provider:e.provider,url:e.url,details:e.timeout?{timeout:e.timeout}:void 0}):t instanceof TypeError?be(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):t instanceof Error?be(t,{sdkCode:"NETWORK_ERROR",provider:e.provider,url:e.url}):new w({code:"NETWORK_ERROR",message:"Unknown request error",provider:e.provider,url:e.url,cause:t})}var ge=class extends w{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},Ct=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new ge;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var ii=3e4,si=1,Wn=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],Xn=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function ai(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?Wn:t.includes("push2.eastmoney.com")?Xn:[t]}function ui(t){return Array.from(new Set(t))}var Ot=class{constructor(e=ii,n=si){this.cooldownMs=e;this.failureThreshold=n;this.states=new Map}getCandidateUrls(e,n){let r;try{r=new URL(e)}catch{return[e]}let o=Date.now(),i=ai(r.hostname,n);if(i.length<=1)return[e];let s=i.filter(c=>{let d=this.states.get(c);return!d||d.cooldownUntil<=o}),a=i.filter(c=>{let d=this.states.get(c);return d&&d.cooldownUntil>o});return ui([...s.includes(r.hostname)?[r.hostname]:[],...s.filter(c=>c!==r.hostname),...a.includes(r.hostname)?[r.hostname]:[],...a.filter(c=>c!==r.hostname)]).map(c=>{let d=new URL(e);return d.hostname=c,d.toString()})}recordSuccess(e){let n=this.safeGetHost(e);if(!n)return;let r=this.getState(n);r.failureCount=0,r.cooldownUntil=0,r.successCount++,r.lastErrorCode=void 0}recordFailure(e,n){let r=this.safeGetHost(e);if(!r)return;let o=this.getState(r);o.failureCount++,o.lastFailureAt=Date.now(),o.lastErrorCode=Z(n),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let n=Z(e);return n==="NETWORK_ERROR"||n==="TIMEOUT"||n==="PARSE_ERROR"?!0:e instanceof j?e.status===408||e.status===429||e.status>=500:!1}getStats(e){let n=Array.from(this.states.values()).map(o=>({...o}));if(!e)return n;if(e!=="eastmoney")return[];let r=new Set([...Wn,...Xn]);return n.filter(o=>r.has(o.host))}safeGetHost(e){try{return new URL(e).hostname}catch{return null}}getState(e){let n=this.states.get(e);if(n)return n;let r={host:e,failureCount:0,successCount:0,cooldownUntil:0,lastFailureAt:0};return this.states.set(e,r),r}};function li(t){return{maxRetries:t?.maxRetries??hn,baseDelay:t?.baseDelay??Tn,maxDelay:t?.maxDelay??yn,backoffMultiplier:t?.backoffMultiplier??Sn,retryableStatusCodes:t?.retryableStatusCodes??Rn,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}function ci(t,e){let n={...t??{}};return e&&(Object.keys(n).some(o=>o.toLowerCase()==="user-agent")||(n["User-Agent"]=e)),n}function Zn(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 Cn(t={}){return{timeout:t.timeout??gn,retry:li(t.retry),headers:ci(t.headers,t.userAgent),rotateUserAgent:t.rotateUserAgent??!1,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function Jn(t,e){if(e)return e;try{let n=new URL(t).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("sina.com.cn"))return"sina";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return"unknown"}return"unknown"}var Le=class{constructor(e={}){this.baseUrl=e.baseUrl??Ut;let n={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=Cn(n),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new Ot;for(let[r,o]of Object.entries(e.providerPolicies??{})){let i=Zn(n,o);this.providerPolicies[r]=Cn(i)}}getProviderState(e){let n=this.runtimeStates.get(e);if(n)return n;let r=this.providerPolicies[e]??this.defaultPolicy,o={policy:r,rateLimiter:r.rateLimit?new Rt(r.rateLimit):null,circuitBreaker:r.circuitBreaker?new Ct(r.circuitBreaker):null};return this.runtimeStates.set(e,o),o}getTimeout(){return this.defaultPolicy.timeout}getHostHealth(e){return this.fallbackManager.getStats(e)}calculateDelay(e,n){return Math.min(n.baseDelay*Math.pow(n.backoffMultiplier,e),n.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n,r){if(n>=r.maxRetries)return!1;let o=Z(e);return o==="TIMEOUT"?r.retryOnTimeout:o==="NETWORK_ERROR"?r.retryOnNetworkError:e instanceof j?r.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n,r,o=0){try{return await e()}catch(i){let s=Et(i,r);if(this.shouldRetry(s,o,n)){let a=this.calculateDelay(o,n);return n.onRetry&&n.onRetry(o+1,s,a),await this.sleep(a),this.executeWithRetry(e,n,r,o+1)}throw s}}async performRequest(e,n,r,o="text"){n.rateLimiter&&await n.rateLimiter.acquire();let i=new AbortController,s=setTimeout(()=>i.abort(),n.policy.timeout),a={...n.policy.headers};if(n.policy.rotateUserAgent){let l=Vn();if(l){for(let c of Object.keys(a))c.toLowerCase()==="user-agent"&&delete a[c];a["User-Agent"]=l}}try{let l=await fetch(e,{signal:i.signal,headers:a});if(!l.ok)throw new j(l.status,l.statusText,e,r);switch(o){case"json":try{return await l.json()}catch(c){throw new w({code:"PARSE_ERROR",message:`Failed to parse JSON response from ${e}`,provider:r,url:e,cause:c})}case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}finally{clearTimeout(s)}}async get(e,n={}){let r=Jn(e,n.provider),o=this.getProviderState(r);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new ge("Circuit breaker is OPEN, request rejected");let i=this.fallbackManager.getCandidateUrls(e,r),s;for(let a=0;a<i.length;a++){let l=i[a],c=a===0?o.policy.retry:{...o.policy.retry,maxRetries:0};try{let d=await this.executeWithRetry(()=>this.performRequest(l,o,r,n.responseType),c,{provider:r,url:l,timeout:o.policy.timeout});return o.circuitBreaker?.recordSuccess(),this.fallbackManager.recordSuccess(l),d}catch(d){let f=Et(d,{provider:r,url:l,timeout:o.policy.timeout});if(s=f,this.fallbackManager.recordFailure(l,f),a<i.length-1&&this.fallbackManager.shouldFallback(f))continue;throw o.circuitBreaker?.recordFailure(),f}}throw o.circuitBreaker?.recordFailure(),s??new ge("Request failed without a concrete error")}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,r=await this.get(n,{responseType:"arraybuffer",provider:"tencent"}),o=Se(r);return Re(o)}};var di=new Set(["daily","weekly","monthly"]),pi=new Set(["1","5","15","30","60"]),mi=new Set(["","qfq","hfq"]);function Y(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function Q(t){if(!di.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function W(t){if(!pi.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function B(t){if(!mi.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function re(t,e){Y(e,"chunkSize");let n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}async function oe(t,e,n=!1){if(Y(e,"concurrency"),t.length===0)return[];let r=n?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 a=await t[s]();n?r[s]=a:r.push(a)}});return await Promise.all(i),r}function he(t){if(t.startsWith("sh"))return"1";if(t.startsWith("sz")||t.startsWith("bj")||t.startsWith("92"))return"0";let e=t[0];return e==="6"||e==="5"||e==="9"?"1":"0"}function G(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function H(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var _t=class{constructor(e={}){this.cache=new Map;this.inflight=new Map;this.defaultTTL=e.defaultTTL??0,this.maxSize=e.maxSize??1e3}get(e){let n=this.cache.get(e);if(n){if(n.expireAt>0&&Date.now()>n.expireAt){this.cache.delete(e);return}return n.lastAccess=Date.now(),n.value}}set(e,n,r){this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictLRU();let o=r??this.defaultTTL,i=Date.now();this.cache.set(e,{value:n,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(),n=0;for(let[r,o]of this.cache)o.expireAt>0&&e>o.expireAt&&(this.cache.delete(r),n++);return n}evictLRU(){let e=null,n=1/0;for(let[r,o]of this.cache)o.lastAccess<n&&(n=o.lastAccess,e=r);e&&this.cache.delete(e)}async getOrFetch(e,n,r){let o=this.get(e);if(o!==void 0)return o;let i=this.inflight.get(e);if(i)return i;let s=n().then(a=>(this.set(e,a,r),a)).finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,s),s}},er=new Map;function ie(t,e){let n=er.get(t);if(n)return n;let r=new _t(e);return er.set(t,r),r}var fi=typeof document<"u"&&typeof window<"u",gi=0;function tr(){return`__stock_sdk_jsonp_${Date.now()}_${gi++}`}function Te(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let r=e.indexOf("(");if(r===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let o=e.lastIndexOf(")");if(o===-1||o<=r)throw new Error("Invalid JSONP response: no closing parenthesis found");let i=e.slice(r+1,o);return JSON.parse(i)}function hi(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let a=tr(),l;if(o==="path")l=t.replace("{callback}",a);else{let S=t.includes("?")?"&":"?";l=`${t}${S}${r}=${a}`}let c=document.createElement("script"),d=!1,f=window,g=()=>{c.parentNode&&c.parentNode.removeChild(c),delete f[a]},T=setTimeout(()=>{d||(d=!0,g(),s(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);f[a]=S=>{d||(d=!0,clearTimeout(T),g(),i(S))},c.onerror=()=>{d||(d=!0,clearTimeout(T),g(),s(new Error(`JSONP script load failed: ${t}`)))},c.src=l,document.head.appendChild(c)})}async function Ti(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e,i=tr(),s;if(o==="path")s=t.replace("{callback}",i);else{let c=t.includes("?")?"&":"?";s=`${t}${c}${r}=${i}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let c=await fetch(s,{signal:a.signal});if(!c.ok)throw new Error(`JSONP fetch failed with status ${c.status}: ${t}`);let d=await c.text();return Te(d)}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):c}finally{clearTimeout(l)}}function N(t,e={}){return fi?hi(t,e):Ti(t,e)}var nr=new Map;async function se(t,e){let r=(nr.get(t)??Promise.resolve()).then(e,e);return nr.set(t,r.then(()=>{},()=>{})),r}function yi(){return typeof document<"u"&&typeof window<"u"}var Si=15e3,On="jsVars";async function ae(t,e,n={}){let r=n.timeout??Si;return yi()?se(On,()=>Ri(t,e,r)):Ei(t,e,r,n.headers,n.client)}function Ne(t,e){let n={};for(let r of e){let o=Ci(t,r);o!==void 0&&(n[r]=o)}return n}function Ri(t,e,n){return new Promise((r,o)=>{let i=document.createElement("script"),s=!1,a=()=>{i.parentNode&&i.parentNode.removeChild(i)},l=setTimeout(()=>{s||(s=!0,a(),o(new Error(`fetchJsVars timed out after ${n}ms: ${t}`)))},n);i.onload=()=>{if(s)return;s=!0,clearTimeout(l);let c=window,d={};for(let f of e)if(f in c){d[f]=c[f];try{delete c[f]}catch{}}a(),r(d)},i.onerror=()=>{s||(s=!0,clearTimeout(l),a(),o(new Error(`fetchJsVars script load failed: ${t}`)))},i.src=t,document.head.appendChild(i)})}async function Ei(t,e,n,r,o){if(o){let a=await o.get(t,{responseType:"text"});return Ne(a,e)}let i=new AbortController,s=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{signal:i.signal,headers:r});if(!a.ok)throw new Error(`fetchJsVars fetch failed with status ${a.status}: ${t}`);let l=await a.text();return Ne(l,e)}catch(a){throw a instanceof DOMException&&a.name==="AbortError"?new Error(`fetchJsVars timed out after ${n}ms: ${t}`):a}finally{clearTimeout(s)}}function Ci(t,e){let r=new RegExp(`(?:^|[^\\w$])(?:var|let|const)\\s+${Oi(e)}\\s*=\\s*`,"m").exec(t);if(!r)return;let o=r.index+r[0].length,i=_i(t,o),s=t.slice(o,i).trim();try{return JSON.parse(s)}catch{return}}function Oi(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _i(t,e){let n=0,r=null;for(let o=e;o<t.length;o++){let i=t[o];if(r){if(i==="\\"){o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"){r=i;continue}if(i==="["||i==="{"||i==="("){n++;continue}if(i==="]"||i==="}"||i===")"){n--;continue}if(i===";"&&n===0)return o}return t.length}var C={CN:"Asia/Shanghai",HK:"Asia/Hong_Kong",US:"America/New_York"};function Ai(t){if(!t)return null;let e=t.trim();if(!e)return null;let n=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/.exec(e);if(n)return{year:+n[1],month:+n[2],day:+n[3],hour:+n[4],minute:+n[5],second:n[6]?+n[6]:0};let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return r?{year:+r[1],month:+r[2],day:+r[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 rr(t,e){let n=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(n)),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 a=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=n-a;return n+l}function Ii(t,e){let n=(t||"").trim(),r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n)??/^(\d{4})(\d{2})(\d{2})$/.exec(n);if(!r)return null;let o=/^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec((e||"").trim());return o?{year:+r[1],month:+r[2],day:+r[3],hour:+o[1],minute:+o[2],second:o[3]?+o[3]:0}:null}function J(t,e){let n=Ai(t);return n?rr(n,e):NaN}function L(t,e){return{timestamp:J(t,e),tz:e}}function Fe(t,e,n){let r=Ii(t,e);return r?{timestamp:rr(r,n),tz:n}:{timestamp:NaN,tz:n}}function ue(t,e){if(!Number.isFinite(t))return"";let n=new Intl.DateTimeFormat("sv-SE",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t)),r=n.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/);if(!r)return n;let o=r[2]==="24"?"00":r[2];return`${r[1]} ${o}:${r[3]}`}var M={};mt(M,{getAShareCodeList:()=>cr,getAllHKQuotesByCodes:()=>fr,getAllQuotesByCodes:()=>mr,getAllUSQuotesByCodes:()=>gr,getFullQuotes:()=>At,getFundCodeList:()=>hr,getFundFlow:()=>ir,getFundQuotes:()=>ar,getHKCodeList:()=>pr,getHKQuotes:()=>It,getPanelLargeOrder:()=>sr,getSimpleQuotes:()=>or,getTodayTimeline:()=>ur,getTradingCalendar:()=>Tr,getUSCodeList:()=>dr,getUSQuotes:()=>Pt,parseFullQuote:()=>_n,parseFundFlow:()=>In,parseFundQuote:()=>bn,parseHKQuote:()=>Dn,parsePanelLargeOrder:()=>Pn,parseSimpleQuote:()=>An,parseUSQuote:()=>Mn,search:()=>Sr});function _n(t){let e=[];for(let i=0;i<5;i++)e.push({price:R(t[9+i*2]),volume:R(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:R(t[19+i*2]),volume:R(t[20+i*2])});let r=t[30]??"",o=L(r,C.CN);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:R(t[3]),prevClose:R(t[4]),open:R(t[5]),volume:R(t[6]),outerVolume:R(t[7]),innerVolume:R(t[8]),bid:e,ask:n,time:r,timestamp:o.timestamp,tz:o.tz,change:R(t[31]),changePercent:R(t[32]),high:R(t[33]),low:R(t[34]),volume2:R(t[36]),amount:R(t[37]),turnoverRate:_(t[38]),pe:_(t[39]),amplitude:_(t[43]),circulatingMarketCap:_(t[44]),totalMarketCap:_(t[45]),pb:_(t[46]),limitUp:_(t[47]),limitDown:_(t[48]),volumeRatio:_(t[49]),avgPrice:_(t[51]),peStatic:_(t[52]),peDynamic:_(t[53]),high52w:_(t[67]),low52w:_(t[68]),circulatingShares:_(t[72]),totalShares:_(t[73]),raw:t}}function An(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:R(t[3]),change:R(t[4]),changePercent:R(t[5]),volume:R(t[6]),amount:R(t[7]),marketCap:_(t[9]),marketType:t[10]??"",raw:t}}function In(t){let e=t[13]??"",n=L(e,C.CN);return{code:t[0]??"",mainInflow:R(t[1]),mainOutflow:R(t[2]),mainNet:R(t[3]),mainNetRatio:R(t[4]),retailInflow:R(t[5]),retailOutflow:R(t[6]),retailNet:R(t[7]),retailNetRatio:R(t[8]),totalFlow:R(t[9]),name:t[12]??"",date:e,timestamp:n.timestamp,tz:n.tz,raw:t}}function Pn(t){return{buyLargeRatio:R(t[0]),buySmallRatio:R(t[1]),sellLargeRatio:R(t[2]),sellSmallRatio:R(t[3]),raw:t}}function Dn(t){let e=t[30]??"",n=L(e,C.HK);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:R(t[3]),prevClose:R(t[4]),open:R(t[5]),volume:R(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:R(t[31]),changePercent:R(t[32]),high:R(t[33]),low:R(t[34]),amount:R(t[37]),lotSize:_(t[40]),circulatingMarketCap:_(t[44]),totalMarketCap:_(t[45]),currency:t[t.length-3]??"",raw:t}}function Mn(t){let e=t[30]??"",n=L(e,C.US);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:R(t[3]),prevClose:R(t[4]),open:R(t[5]),volume:R(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:R(t[31]),changePercent:R(t[32]),high:R(t[33]),low:R(t[34]),amount:R(t[37]),turnoverRate:_(t[38]),pe:_(t[39]),amplitude:_(t[43]),totalMarketCap:_(t[45]),pb:_(t[47]),high52w:_(t[48]),low52w:_(t[49]),raw:t}}function bn(t){let e=t[8]??"",n=L(e,C.CN);return{code:t[0]??"",name:t[1]??"",nav:R(t[5]),accNav:R(t[6]),change:R(t[7]),navDate:e,timestamp:n.timestamp,tz:n.tz,raw:t}}async function At(t,e){if(!e||e.length===0)return[];let n=await t.getTencentQuote(e.join(",")),r=new Set(e);return n.filter(o=>r.has(o.key)&&o.fields&&o.fields.length>5&&o.fields[0]!=="").map(o=>_n(o.fields))}async function or(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`s_${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>An(i.fields))}async function ir(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`ff_${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=14&&i.fields[0]!=="").map(i=>In(i.fields))}async function sr(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`s_pk${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=4&&i.fields[0]!=="").map(i=>Pn(i.fields))}async function It(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`hk${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>Dn(i.fields))}async function Pt(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`us${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>Mn(i.fields))}async function ar(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`jj${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=9&&i.fields[0]!=="").map(i=>bn(i.fields))}async function ur(t,e){let n=`${Kt}?code=${encodeURIComponent(e)}`,r=await t.get(n,{responseType:"json",provider:"tencent"});if(r.code!==0)throw new Error(r.msg||"API error");let o=r.data?.[e];if(!o){let g=L("",C.CN);return{code:e,date:"",timestamp:g.timestamp,tz:g.tz,preClose:0,data:[]}}let i=o.data?.data??[],s=o.data?.date??"",a=o.qt?.[e]??[],l=parseFloat(a[4]??"")||0,c=!1;for(let g of i){let T=g.split(" "),S=parseFloat(T[1])||0,p=parseInt(T[2],10)||0,h=parseFloat(T[3])||0;if(p>0&&S>0){h/p>S*50&&(c=!0);break}}let d=i.map(g=>{let T=g.split(" "),S=T[0],p=`${S.slice(0,2)}:${S.slice(2,4)}`,h=parseInt(T[2],10)||0,E=parseFloat(T[3])||0,O=c?h*100:h,b=O>0?E/O:0,I=Fe(s,p,C.CN);return{time:p,timestamp:I.timestamp,tz:I.tz,price:parseFloat(T[1])||0,volume:O,amount:E,avgPrice:Math.round(b*100)/100}}),f=L(s,C.CN);return{code:e,date:s,timestamp:f.timestamp,tz:f.tz,preClose:l,data:d}}var lr=ie("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function kn(t,e,n){return lr.getOrFetch(e,async()=>(await t.get(n,{responseType:"json"}))?.list||[])}function Pi(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("4")||n.startsWith("8")||n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function cr(t,e){let n=!1,r;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,r=e.market);let i=await kn(t,"a-share:full",Bt);return r&&(i=i.filter(s=>Pi(s,r))),n?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}var Di={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function dr(t,e){let n=!1,r;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,r=e.market);let i=(await kn(t,"us:full",Ht)).slice();if(r){let s=Di[r];i=i.filter(a=>a.startsWith(s))}return n?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function pr(t){return(await kn(t,"hk:full",qt)).slice()}async function mr(t,e,n={}){let{batchSize:r=Pe,concurrency:o=Me,onProgress:i}=n;Y(r,"batchSize"),Y(o,"concurrency");let s=Math.min(r,De),a=re(e,s),l=a.length,c=0,d=a.map(g=>async()=>{let T=await At(t,g);return c++,i&&i(c,l),T});return(await oe(d,o,!0)).flat()}async function fr(t,e,n={}){let{batchSize:r=Pe,concurrency:o=Me,onProgress:i}=n;Y(r,"batchSize"),Y(o,"concurrency");let s=Math.min(r,De),a=re(e,s),l=a.length,c=0,d=a.map(g=>async()=>{let T=await It(t,g);return c++,i&&i(c,l),T});return(await oe(d,o,!0)).flat()}async function gr(t,e,n={}){let{batchSize:r=Pe,concurrency:o=Me,onProgress:i}=n;Y(r,"batchSize"),Y(o,"concurrency");let s=Math.min(r,De),a=re(e,s),l=a.length,c=0,d=a.map(g=>async()=>{let T=await Pt(t,g);return c++,i&&i(c,l),T});return(await oe(d,o,!0)).flat()}async function hr(t){return(await lr.getOrFetch("fund:full",async()=>(await t.get($t,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var Mi=ie("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function Tr(t){return(await Mi.getOrFetch("a-share",async()=>{let n=await t.get(Gn);return!n||n.trim()===""?[]:n.trim().split(",").map(r=>r.trim()).filter(r=>r.length>0)})).slice()}var yr="https://smartbox.gtimg.cn/s3/";function bi(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function ki(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 Li(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let r=n.split("~"),o=r[0]||"",i=r[1]||"",s=bi(r[2]||""),a=r[4]||"";return{code:o+i,name:s,market:o,type:a,category:ki(a)}})}function Ni(t){return new Promise((e,n)=>{let r=`${yr}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=r,o.charset="utf-8",o.onload=()=>{let i=window.v_hint||"";document.body.removeChild(o),e(i)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function Fi(t,e){let n=`${yr}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function xi(){return typeof window<"u"&&typeof document<"u"}async function Sr(t,e){if(!e||!e.trim())return[];let n;return xi()?n=await Ni(e):n=await Fi(t,e),Li(n)}var y={};mt(y,{extractVariety:()=>wn,fetchDatacenter:()=>Nn,fetchDatacenterList:()=>A,getBlockTradeDailyStat:()=>vo,getBlockTradeDetail:()=>xo,getBlockTradeMarketStat:()=>Fo,getBoardChanges:()=>Ao,getCFFEXOptionQuotes:()=>eo,getComexInventory:()=>io,getConceptConstituents:()=>Kr,getConceptKline:()=>Br,getConceptList:()=>wr,getConceptMinuteKline:()=>Hr,getConceptSpot:()=>Ur,getDividendDetail:()=>qr,getDragonTigerBranchRank:()=>bo,getDragonTigerDetail:()=>Po,getDragonTigerInstitution:()=>Mo,getDragonTigerStockSeatDetail:()=>ko,getDragonTigerStockStats:()=>Do,getFundDividendList:()=>jr,getFundEstimate:()=>Yr,getFundFlowRank:()=>mo,getFundNavHistory:()=>Gr,getFundRankHistory:()=>Vr,getFuturesHistoryKline:()=>Xr,getFuturesInventory:()=>oo,getFuturesInventorySymbols:()=>ro,getFuturesMarketCode:()=>Un,getGlobalFuturesKline:()=>Jr,getGlobalFuturesSpot:()=>Zr,getHKHistoryKline:()=>Cr,getHKMinuteKline:()=>Or,getHistoryKline:()=>Rr,getIndividualFundFlow:()=>co,getIndustryConstituents:()=>Fr,getIndustryKline:()=>xr,getIndustryList:()=>Lr,getIndustryMinuteKline:()=>vr,getIndustrySpot:()=>Nr,getMarginAccountInfo:()=>wo,getMarginTargetList:()=>Uo,getMarketFundFlow:()=>po,getMinuteKline:()=>Er,getNorthboundFlowSummary:()=>So,getNorthboundHistory:()=>Eo,getNorthboundHoldingRank:()=>Ro,getNorthboundIndividual:()=>Co,getNorthboundMinute:()=>yo,getOptionLHB:()=>to,getSectorFundFlowHistory:()=>go,getSectorFundFlowRank:()=>fo,getStockChanges:()=>_o,getUSHistoryKline:()=>_r,getUSMinuteKline:()=>Ar,getZTPool:()=>Oo});async function Ln(t,e,n,r,o=100,i){let s=[],a=1,l=0;do{let c=new URLSearchParams({...n,pn:String(a),pz:String(o),fields:r}),d=`${e}?${c.toString()}`,g=(await t.get(d,{responseType:"json"}))?.data;if(!g||!Array.isArray(g.diff))break;a===1&&(l=g.total??0);let T=g.diff.map((S,p)=>i(S,s.length+p+1));if(s.push(...T),T.length===0)break;a++}while(s.length<l);return s}function x(t){let[e,n,r,o,i,s,a,l,c,d,f]=t.split(",");return{date:e,open:m(n),close:m(r),high:m(o),low:m(i),volume:m(s),amount:m(a),amplitude:m(l),changePercent:m(c),change:m(d),turnoverRate:m(f)}}async function v(t,e,n){let r=`${e}?${n.toString()}`,o=await t.get(r,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function Rr(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=n;Q(r),B(o);let a=e.replace(/^(sh|sz|bj)/,""),l=`${he(e)}.${a}`,c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:D,klt:G(r),fqt:H(o),secid:l,beg:i,end:s}),d=ft,{klines:f}=await v(t,d,c);return f.length===0?[]:f.map(g=>{let T=x(g),S=L(T.date,C.CN);return{...T,timestamp:S.timestamp,tz:S.tz,code:a}})}async function Er(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00"}=n;W(r),B(o);let a=e.replace(/^(sh|sz|bj)/,""),l=`${he(e)}.${a}`;if(r==="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:D,ndays:"5",iscr:"0",secid:l}),d=`${zt}?${c.toString()}`,g=(await t.get(d,{responseType:"json"}))?.data?.trends;if(!Array.isArray(g)||g.length===0)return[];let T=i.replace("T"," ").slice(0,16),S=s.replace("T"," ").slice(0,16);return S.length===10&&(S+=" 23:59"),g.map(p=>{let[h,E,O,b,I,k,$,K]=p.split(","),X=L(h,C.CN);return{time:h,timestamp:X.timestamp,tz:X.tz,open:m(E),close:m(O),high:m(b),low:m(I),volume:m(k),amount:m($),avgPrice:m(K)}}).filter(p=>p.time>=T&&p.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:D,klt:r,fqt:H(o||""),secid:l,beg:"0",end:"20500000"}),d=ft,{klines:f}=await v(t,d,c);if(f.length===0)return[];let g=i.replace("T"," ").slice(0,16),T=s.replace("T"," ").slice(0,16);return T.length===10&&(T+=" 23:59"),f.map(S=>{let p=x(S),h=L(p.date,C.CN);return{...p,time:p.date,timestamp:h.timestamp,tz:h.tz}}).filter(S=>S.time>=g&&S.time<=T)}}function Dt(t){return async function(n,r,o={}){let{period:i="daily",adjust:s="qfq",startDate:a="19700101",endDate:l="20500101"}=o;Q(i),B(s);let c=t.normalizeSymbol(r),d=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:D,klt:G(i),fqt:H(s),secid:c.secid,beg:a,end:l,lmt:"1000000"}),{klines:f,name:g,code:T}=await v(n,t.url,d);if(f.length===0)return[];let S=t.resolveResultMeta?t.resolveResultMeta(r,c,{code:T,name:g}):{code:T||c.fallbackCode,name:g||""};return f.map(p=>{let h=x(p),E=L(h.date,t.tz),O={...h,timestamp:E.timestamp,tz:E.tz,code:S.code,name:S.name};return t.enrichItem(O)})}}var vi=Dt({url:gt,tz:C.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 Cr(t,e,n={}){return vi(t,e,n)}async function Or(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00",ndays:a=1}=n;W(r),B(o);let l=e.replace(/^hk/i,"").padStart(5,"0"),c=`116.${l}`,d=p=>{let h=J(p,C.CN);return{time:ue(h,C.HK)||p,timestamp:h}};if(r==="1"){let p=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:D,ndays:String(a),iscr:"0",secid:c}),h=`${jt}?${p.toString()}`,O=(await t.get(h,{responseType:"json"}))?.data?.trends;if(!Array.isArray(O)||O.length===0)return[];let b=i.replace("T"," ").slice(0,16),I=s.replace("T"," ").slice(0,16);return I.length===10&&(I+=" 23:59"),O.map(k=>{let[$,K,X,te,ne,Lt,Nt,Ft]=k.split(","),{time:xt,timestamp:vt}=d($);return{time:xt,timestamp:vt,tz:C.HK,open:m(K),close:m(X),high:m(te),low:m(ne),volume:m(Lt),amount:m(Nt),avgPrice:m(Ft),currency:"HKD",code:l}}).filter(k=>k.time>=b&&k.time<=I)}let f=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:D,klt:r,fqt:H(o),secid:c,beg:"0",end:"20500000"}),{klines:g}=await v(t,gt,f);if(g.length===0)return[];let T=i.replace("T"," ").slice(0,16),S=s.replace("T"," ").slice(0,16);return S.length===10&&(S+=" 23:59"),g.map(p=>{let h=x(p),{time:E,timestamp:O}=d(h.date);return{time:E,timestamp:O,tz:C.HK,open:h.open,close:h.close,high:h.high,low:h.low,volume:h.volume,amount:h.amount,amplitude:h.amplitude,changePercent:h.changePercent,change:h.change,turnoverRate:h.turnoverRate,currency:"HKD",code:l}}).filter(p=>p.time>=T&&p.time<=S)}var wi=Dt({url:ht,tz:C.US,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:n.code||e.fallbackCode,name:n.name||""}),enrichItem:t=>({...t,currency:"USD"})});async function _r(t,e,n={}){return wi(t,e,n)}async function Ar(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:s="2222-01-01 09:32:00",ndays:a=1}=n;W(r),B(o);let l=e,c=e.split(".")[1]||e,d=p=>{let h=J(p,C.CN);return{time:ue(h,C.US)||p,timestamp:h}};if(r==="1"){let p=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:D,ndays:String(a),iscr:"0",secid:l}),h=`${Qt}?${p.toString()}`,O=(await t.get(h,{responseType:"json"}))?.data?.trends;if(!Array.isArray(O)||O.length===0)return[];let b=i.replace("T"," ").slice(0,16),I=s.replace("T"," ").slice(0,16);return I.length===10&&(I+=" 23:59"),O.map(k=>{let[$,K,X,te,ne,Lt,Nt,Ft]=k.split(","),{time:xt,timestamp:vt}=d($);return{time:xt,timestamp:vt,tz:C.US,open:m(K),close:m(X),high:m(te),low:m(ne),volume:m(Lt),amount:m(Nt),avgPrice:m(Ft),currency:"USD",code:c}}).filter(k=>k.time>=b&&k.time<=I)}let f=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:D,klt:r,fqt:H(o),secid:l,beg:"0",end:"20500000"}),{klines:g}=await v(t,ht,f);if(g.length===0)return[];let T=i.replace("T"," ").slice(0,16),S=s.replace("T"," ").slice(0,16);return S.length===10&&(S+=" 23:59"),g.map(p=>{let h=x(p),{time:E,timestamp:O}=d(h.date);return{time:E,timestamp:O,tz:C.US,open:h.open,close:h.close,high:h.high,low:h.low,volume:h.volume,amount:h.amount,amplitude:h.amplitude,changePercent:h.changePercent,change:h.change,turnoverRate:h.turnoverRate,currency:"USD",code:c}}).filter(p=>p.time>=T&&p.time<=S)}function Ir(t){let e=ie(`eastmoney:board-code-map:${t.type}`,{defaultTTL:36e5,maxSize:4});return{async getCode(n,r,o){if(r.startsWith("BK"))return r;let s=(await e.getOrFetch("name-code-map",async()=>{let a=await o(n);return Object.fromEntries(a.map(l=>[l.name,l.code]))}))[r];if(!s)throw new ke(`${t.errorPrefix}: ${r}`,"eastmoney");return s}}}async function Pr(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},r=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await Ln(t,e.listUrl,n,r,100,(i,s)=>({rank:s,name:String(i.f14??""),code:String(i.f12??""),price:u(i.f2),change:u(i.f4),changePercent:u(i.f3),totalMarketCap:u(i.f20),turnoverRate:u(i.f8),riseCount:u(i.f104),fallCount:u(i.f105),leadingStock:i.f128?String(i.f128):null,leadingStockChangePercent:u(i.f136)}));return o.sort((i,s)=>(s.changePercent??0)-(i.changePercent??0)),o.forEach((i,s)=>{i.rank=s+1}),o}async function Dr(t,e,n){let r=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${r.toString()}`,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:d})=>{let f=s[l],g=null;return typeof f=="number"&&!isNaN(f)&&(g=d?f/100:f),{item:c,value:g}}):[]}async function Mr(t,e,n){let r={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Ln(t,n,r,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(i,s)=>({rank:s,code:String(i.f12??""),name:String(i.f14??""),price:u(i.f2),changePercent:u(i.f3),change:u(i.f4),volume:u(i.f5),amount:u(i.f6),amplitude:u(i.f7),high:u(i.f15),low:u(i.f16),open:u(i.f17),prevClose:u(i.f18),turnoverRate:u(i.f8),pe:u(i.f9),pb:u(i.f23)}))}async function br(t,e,n,r={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:a="20500101"}=r;Q(o),B(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:G(o),fqt:H(i),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:c}=await v(t,n,l);return c.length===0?[]:c.map(d=>x(d))}async function kr(t,e,n,r,o={}){let{period:i="5"}=o;if(W(i),i==="1"){let s=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),a=`${r}?${s.toString()}`,c=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(c)||c.length===0?[]:c.map(d=>{let[f,g,T,S,p,h,E,O]=d.split(","),b=m(O);return{time:f,open:m(g),close:m(T),high:m(S),low:m(p),volume:m(h),amount:m(E),price:b,avgPrice:b}})}else{let s=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:i,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${s.toString()}`,c=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(d=>{let[f,g,T,S,p,h,E,O,b,I,k]=d.split(",");return{time:f,open:m(g),close:m(T),high:m(S),low:m(p),changePercent:m(b),change:m(I),volume:m(h),amount:m(E),amplitude:m(O),turnoverRate:m(k)}})}}function Mt(t){let e=Ir(t);async function n(o){return Pr(o,t)}async function r(o,i){return e.getCode(o,i,n)}return{async getList(o){return n(o)},async getSpot(o,i){let s=await r(o,i);return Dr(o,s,t.spotUrl)},async getConstituents(o,i){let s=await r(o,i);return Mr(o,s,t.consUrl)},async getKline(o,i,s={}){let a=await r(o,i);return br(o,a,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let a=await r(o,i);return kr(o,a,t.klineUrl,t.trendsUrl,s)}}}var Ui={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Gt,spotUrl:Yt,consUrl:Vt,klineUrl:Wt,trendsUrl:Xt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},xe=Mt(Ui);async function Lr(t){return xe.getList(t)}async function Nr(t,e){return xe.getSpot(t,e)}async function Fr(t,e){return xe.getConstituents(t,e)}async function xr(t,e,n={}){return xe.getKline(t,e,n)}async function vr(t,e,n={}){return xe.getMinuteKline(t,e,n)}var Ki={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Zt,spotUrl:Jt,consUrl:en,klineUrl:tn,trendsUrl:nn,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},ve=Mt(Ki);async function wr(t){return ve.getList(t)}async function Ur(t,e){return ve.getSpot(t,e)}async function Kr(t,e){return ve.getConstituents(t,e)}async function Br(t,e,n={}){return ve.getKline(t,e,n)}async function Hr(t,e,n={}){return ve.getMinuteKline(t,e,n)}async function Nn(t,e,n){let{reportName:r,columns:o="ALL",filter:i,sortColumns:s,sortTypes:a,pageSize:l=500,startPage:c=1,fetchAllPages:d=!0,maxPages:f=1e3,quoteColumns:g,quoteType:T,extraParams:S}=e,p=[],h=c,E=1,O=0,b=0;do{let I=new URLSearchParams({reportName:r,columns:o,pageSize:String(l),pageNumber:String(h),source:"WEB",client:"WEB"});if(i&&I.set("filter",i),s&&I.set("sortColumns",s),a&&I.set("sortTypes",a),g&&I.set("quoteColumns",g),T&&I.set("quoteType",T),S)for(let[te,ne]of Object.entries(S))I.set(te,ne);let k=`${rn}?${I.toString()}`,K=(await t.get(k,{responseType:"json"}))?.result;if(!K||!Array.isArray(K.data))break;h===c&&(E=K.pages??1,O=K.count??K.data.length);let X=K.data.map((te,ne)=>n(te,p.length+ne));if(p.push(...X),h++,b++,!d)break}while(h<=E&&b<f);return d&&b>=f&&h<=E&&console.warn(`[stock-sdk] fetchDatacenter("${r}") truncated at maxPages=${f} (server reports ${E} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:p,total:O,pages:E}}async function A(t,e,n){return(await Nn(t,e,n)).data}function F(t){if(t==null)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}function le(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Bi(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:le(t.REPORT_DATE),planNoticeDate:le(t.PLAN_NOTICE_DATE),disclosureDate:le(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:le(t.EQUITY_RECORD_DATE),exDividendDate:le(t.EX_DIVIDEND_DATE),payDate:le(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:le(t.NOTICE_DATE)}}async function qr(t,e){let n=e.replace(/^(sh|sz|bj)/,"");return A(t,{reportName:"RPT_SHAREBONUS_DET",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:500,filter:`(SECURITY_CODE="${n}")`},r=>Bi(r))}var Hi="https://fund.eastmoney.com/Data/funddataIndex_Interface.aspx",zr="https://fund.eastmoney.com/pingzhongdata",qi="https://fundgz.1234567.com.cn/js";function $i(){return typeof document<"u"&&typeof window<"u"}var zi=1e4;function ji(){return new Date().getFullYear()}function Qi(t,e){let n=new URLSearchParams({dt:"8",page:String(e),rank:t.rank??"FSRQ",sort:t.sort??"desc",gs:"",ftype:t.fundType??"",year:String(t.year??ji())});return`${Hi}?${n.toString()}`}function Fn(t){if(!t)return null;let e=t.trim().match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Gi(t){if(t===void 0||t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Yi(t){return{code:t[0]??"",name:t[1]??"",equityRecordDate:Fn(t[2]),exDividendDate:Fn(t[3]),dividendPerShare:Gi(t[4]),payDate:Fn(t[5]),raw:t}}async function xn(t,e,n){let r=Qi(e,n),o=await ae(r,["pageinfo","jjfh_data"],{client:t}),i=o.pageinfo??[0,0,n],[s=0,a=0,l=n]=i;return{items:(o.jjfh_data??[]).map(Yi),totalPages:s,pageSize:a,currentPage:l}}async function jr(t,e={}){if(e.page==="all"){let o=await xn(t,e,1),i=o.items;for(let s=2;s<=o.totalPages;s++){let a=await xn(t,e,s);i=i.concat(a.items)}return e.code&&(i=i.filter(s=>s.code===e.code)),{items:i,totalPages:o.totalPages,pageSize:o.pageSize,currentPage:-1}}let n=e.page??1,r=await xn(t,e,n);return e.code?{...r,items:r.items.filter(o=>o.code===e.code)}:r}function Vi(t){if(t===void 0||t===""||t===null)return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}function Qr(t){return new Date(t).toISOString().slice(0,10)}async function Gr(t,e){let n=`${zr}/${encodeURIComponent(e)}.js`,r=await ae(n,["fS_code","fS_name","Data_netWorthTrend","Data_ACWorthTrend"],{client:t}),o=r.Data_netWorthTrend??[],i=new Map;for(let a of r.Data_ACWorthTrend??[])Array.isArray(a)&&a.length>=2&&i.set(a[0],a[1]);let s=o.map(a=>({date:Qr(a.x),timestamp:a.x,nav:a.y,accNav:i.has(a.x)?i.get(a.x):null,dailyReturn:Vi(a.equityReturn),unitMoney:a.unitMoney??""}));return{code:r.fS_code??e,name:r.fS_name??null,items:s}}function Wi(t,e,n=zi){let r=`${qi}/${encodeURIComponent(e)}.js?rt=${Date.now()}`;return $i()?se("fundgz:jsonpgz",()=>Xi(r,n)):Zi(t,r)}function Xi(t,e){return new Promise((n,r)=>{let o=document.createElement("script"),i=window,s=i.jsonpgz,a=!1,l=()=>{if(o.parentNode&&o.parentNode.removeChild(o),s===void 0)try{delete i.jsonpgz}catch{}else i.jsonpgz=s},c=setTimeout(()=>{a||(a=!0,l(),r(new Error(`fundgz JSONP timed out after ${e}ms: ${t}`)))},e);i.jsonpgz=d=>{a||(a=!0,clearTimeout(c),l(),n(d??{}))},o.onerror=()=>{a||(a=!0,clearTimeout(c),l(),r(new Error(`fundgz JSONP script load failed: ${t}`)))},o.src=t,document.head.appendChild(o)})}async function Zi(t,e){let r=(await t.get(e,{responseType:"text",provider:"eastmoney"})).trim();if(!r)return{};try{return Te(r)}catch{return{}}}function vn(t){if(t===void 0||t===""||t==="--")return null;let e=Number(t);return Number.isFinite(e)?e:null}async function Yr(t,e){let n=await Wi(t,e);return{code:n.fundcode??e,name:n.name??null,navDate:n.jzrq?.trim()?n.jzrq.trim():null,nav:vn(n.dwjz),estimatedNav:vn(n.gsz),estimatedChangePercent:vn(n.gszzl),estimateTime:n.gztime?.trim()?n.gztime.trim():null}}function $r(t){if(t===void 0||t===""||t===null)return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}async function Vr(t,e){let n=`${zr}/${encodeURIComponent(e)}.js`,r=await ae(n,["fS_code","fS_name","Data_rateInSimilarType","Data_rateInSimilarPersent"],{client:t}),o=r.Data_rateInSimilarType??[],i=new Map;for(let a of r.Data_rateInSimilarPersent??[])Array.isArray(a)&&a.length>=2&&i.set(a[0],a[1]);let s=o.map(a=>({date:Qr(a.x),timestamp:a.x,rank:$r(a.y),total:$r(a.sc),percentile:i.has(a.x)?i.get(a.x):null}));return{code:r.fS_code??e,name:r.fS_name??null,items:s}}function wn(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 Wr(t){return fe[t]??fe[t.toLowerCase()]??fe[t.toUpperCase()]}function Un(t){let e=Wr(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=Wr(t.slice(0,-1))),!e){let r=Object.keys(fe).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${r}`)}let n=un[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function Ji(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?m(n[12]):null}}async function Xr(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;Q(r);let s=wn(e),l=`${Un(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:D,klt:G(r),fqt:"0",secid:l,beg:o,end:i}),{klines:d,name:f,code:g}=await v(t,Oe,c);return d.length===0?[]:d.map(T=>({...Ji(T),code:g||e,name:f||""}))}async function Zr(t,e={}){let n=e.pageSize??20,r=[],o=0,i=0;do{let s=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(o),token:_e,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${an}?${s.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;o===0&&(i=l.total??0);let c=l.list.map(es);r.push(...c),o++}while(r.length<i);return r}function es(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 ts(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?m(n[12]):null}}function ns(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 Jr(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;Q(r);let s=n.marketCode;if(s===void 0){let g=ns(e);if(s=Tt[g],s===void 0){let T=Object.keys(Tt).join(", ");throw new RangeError(`Unknown global futures variety: "${g}". Supported: ${T}. Or specify marketCode manually via options.`)}}let a=`${s}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:D,klt:G(r),fqt:"0",secid:a,beg:o,end:i}),{klines:c,name:d,code:f}=await v(t,Oe,l);return c.length===0?[]:c.map(g=>({...ts(g),code:f||e,name:d||""}))}async function eo(t,e={}){let{pageSize:n=2e4}=e,r=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:_e,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${mn}?${r.toString()}`,s=(await t.get(o,{responseType:"json"}))?.list;return Array.isArray(s)?s.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:u(a.p),change:u(a.zde),changePercent:u(a.zdf),volume:u(a.vol),amount:u(a.cje),openInterest:u(a.ccl),strikePrice:u(a.xqj),remainDays:u(a.syr),dailyChange:u(a.rz),prevSettle:u(a.zjsj),open:u(a.o)})):[]}function rs(t){return t.includes("\u51C0")?"net":t.includes("\u4E70")?"buy":t.includes("\u5356")?"sell":null}async function to(t,e,n){let r=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:z,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),o=`${fn}?${r.toString()}`,s=(await t.get(o,{responseType:"json"}))?.result?.data;if(!Array.isArray(s))return[];function a(l){if(!l)return"";let c=String(l),d=c.match(/^(\d{4}-\d{2}-\d{2})/);return d?d[1]:c}return s.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:u(l.MEMBER_RANK)??0,sellVolume:u(l.SELL_VOLUME),sellVolumeChange:u(l.SELL_VOLUME_CHANGE),netSellVolume:u(l.NET_SELL_VOLUME),sellVolumeRatio:u(l.SELL_VOLUME_RATIO),buyVolume:u(l.BUY_VOLUME),buyVolumeChange:u(l.BUY_VOLUME_CHANGE),netBuyVolume:u(l.NET_BUY_VOLUME),buyVolumeRatio:u(l.BUY_VOLUME_RATIO),sellPosition:u(l.SELL_POSITION),sellPositionChange:u(l.SELL_POSITION_CHANGE),netSellPosition:u(l.NET_SELL_POSITION),sellPositionRatio:u(l.SELL_POSITION_RATIO),buyPosition:u(l.BUY_POSITION),buyPositionChange:u(l.BUY_POSITION_CHANGE),netBuyPosition:u(l.NET_BUY_POSITION),buyPositionRatio:u(l.BUY_POSITION_RATIO),tradeDate:a(l.TRADE_DATE),volume:u(l.BUY_VOLUME)??u(l.SELL_VOLUME)??u(l.NET_BUY_VOLUME)??u(l.NET_SELL_VOLUME),volumeChange:u(l.BUY_VOLUME_CHANGE)??u(l.SELL_VOLUME_CHANGE),amount:u(l.BUY_POSITION)??u(l.SELL_POSITION)??u(l.NET_BUY_POSITION)??u(l.NET_SELL_POSITION),amountChange:u(l.BUY_POSITION_CHANGE)??u(l.SELL_POSITION_CHANGE),openInterest:u(l.BUY_POSITION)??u(l.SELL_POSITION),openInterestChange:u(l.BUY_POSITION_CHANGE)??u(l.SELL_POSITION_CHANGE),side:rs(String(l.TRADE_TYPE??""))}))}var os={gold:"EMI00069026",silver:"EMI00069027"};function no(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function ro(t){return A(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 oo(t,e,n={}){let{startDate:r="2020-10-28",pageSize:o=500}=n,i=e.toUpperCase();return A(t,{reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${i}")(TRADE_DATE>='${r}')`,pageSize:o,sortColumns:"TRADE_DATE",sortTypes:"-1"},s=>({code:String(s.SECURITY_CODE??e),date:no(s.TRADE_DATE),inventory:u(s.ON_WARRANT_NUM),change:u(s.ADDCHANGE)}))}async function io(t,e,n={}){let r=os[e];if(!r)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:o=500}=n,i={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};return A(t,{reportName:"RPT_FUTUOPT_GOLDSIL",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:o,filter:`(INDICATOR_ID1="${r}")(@STORAGE_TON<>"NULL")`},s=>({date:no(s.REPORT_DATE),name:i[e]??e,storageTon:u(s.STORAGE_TON),storageOunce:u(s.STORAGE_OUNCE),inventory:u(s.STORAGE_TON),change:null,market:e}))}var so={daily:"101",weekly:"102",monthly:"103"},Kn="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function ao(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 is(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 uo={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"}},ss={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},as="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 lo(t,e,n=100,r=1e3){let o=[],i=1,s=0;do{let a=new URLSearchParams({...e,pn:String(i),pz:String(n)}),l=`${on}?${a.toString()}`,d=(await t.get(l,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff)||(i===1&&(s=d.total??0),o.push(...d.diff),o.length>=s||d.diff.length<n))break;i++}while(o.length<s&&i<=r);return i>r&&o.length<s&&console.warn(`[stock-sdk] fetchClistAllPages truncated at maxPages=${r} (server reports total=${s}, fetched=${o.length}). Pass a larger \`maxPages\` to fetch the full dataset.`),o}async function co(t,e,n={}){let{period:r="daily"}=n,o=so[r];if(!o)throw new RangeError(`Invalid period: ${r}. Must be daily/weekly/monthly.`);let i=e.replace(/^(sh|sz|bj)/i,""),s=`${he(e)}.${i}`,a=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:Kn,ut:z}),l=`${Ee}?${a.toString()}`,d=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(d)||d.length===0?[]:d.map(ao)}async function po(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:Kn,ut:z}),n=`${Ee}?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(is)}async function mo(t,e={}){let{indicator:n="today"}=e,r=uo[n];if(!r)throw new RangeError(`Invalid indicator: ${n}.`);let o={fid:r.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:z,fs:as,fields:r.fields};return(await lo(t,o,100)).map(s=>({code:String(s.f12??""),name:String(s.f14??""),price:u(s.f2),changePercent:u(s[r.changePercentField]),mainNetInflow:u(s[r.mainNet]),mainNetInflowPercent:u(s[r.mainPct]),superLargeNetInflow:u(s[r.superLargeNet]),superLargeNetInflowPercent:u(s[r.superLargePct]),largeNetInflow:u(s[r.largeNet]),largeNetInflowPercent:u(s[r.largePct]),mediumNetInflow:u(s[r.mediumNet]),mediumNetInflowPercent:u(s[r.mediumPct]),smallNetInflow:u(s[r.smallNet]),smallNetInflowPercent:u(s[r.smallPct])}))}async function fo(t,e={}){let{indicator:n="today",sectorType:r="industry"}=e,o=uo[n];if(!o)throw new RangeError(`Invalid indicator: ${n}.`);let i=ss[r];if(!i)throw new RangeError(`Invalid sectorType: ${r}.`);let s=`${o.fields},f204,f205`,a={fid:o.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:z,fs:i,fields:s};return(await lo(t,a,100)).map(c=>({code:String(c.f12??""),name:String(c.f14??""),changePercent:u(c[o.changePercentField]),mainNetInflow:u(c[o.mainNet]),mainNetInflowPercent:u(c[o.mainPct]),superLargeNetInflow:u(c[o.superLargeNet]),largeNetInflow:u(c[o.largeNet]),mediumNetInflow:u(c[o.mediumNet]),smallNetInflow:u(c[o.smallNet]),topStockCode:c.f204?String(c.f204):void 0,topStockName:c.f205?String(c.f205):void 0}))}async function go(t,e,n={}){let{period:r="daily"}=n,o=so[r];if(!o)throw new RangeError(`Invalid period: ${r}. 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:Kn,ut:z}),a=`${Ee}?${s.toString()}`,c=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(ao)}var us={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},ls={shanghai:"001",shenzhen:"003"};function ho(t,e){let n=t.split(",");return{date:e,time:n[0]??"",shanghaiNetInflow:m(n[1]),shenzhenNetInflow:m(n[3]),totalNetInflow:m(n[5])}}async function yo(t,e="north"){let n=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:z}),r=`${sn}?${n.toString()}`,i=(await t.get(r,{responseType:"json"}))?.data;if(!i)return[];if(e==="south"){let l=i.n2s??[],c=i.n2sDate??"";return l.map(d=>ho(d,To(c)))}let s=i.s2n??[],a=i.s2nDate??"";return s.map(l=>ho(l,To(a)))}function To(t){return t?/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t:""}async function So(t){return A(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:F(e.TRADE_DATE),type:String(e.MUTUAL_TYPE??""),boardName:String(e.MUTUAL_TYPE_NAME??""),direction:String(e.FUNDS_DIRECTION??""),status:String(e.status??""),netBuyAmount:u(e.netBuyAmt),netInflow:u(e.dayNetAmtIn),remainAmount:u(e.dayAmtRemain),upCount:u(e.f104),flatCount:u(e.f106),downCount:u(e.f105),indexCode:String(e.INDEX_CODE??""),indexName:String(e.INDEX_NAME??""),indexChangePercent:u(e.INDEX_f3)}))}async function Ro(t,e={}){let{market:n="all",period:r="5day",date:o}=e,i=us[r];if(!i)throw new RangeError(`Invalid period: ${r}.`);let s=[`(INTERVAL_TYPE="${i}")`];return o&&s.push(`(TRADE_DATE='${o}')`),n!=="all"&&s.push(`(MUTUAL_TYPE="${ls[n]}")`),A(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:s.join("")},a=>({date:F(a.TRADE_DATE),code:String(a.SECURITY_CODE??""),name:String(a.SECURITY_NAME??a.SECURITY_NAME_ABBR??""),close:u(a.CLOSE_PRICE),changePercent:u(a.CHANGE_RATE),holdShares:u(a.HOLD_SHARES),holdMarketValue:u(a.HOLD_MARKET_CAP),holdRatioFloat:u(a.HOLD_RATIO),holdRatioTotal:u(a.A_SHARES_RATIO),addShares:u(a.ADD_SHARES),addMarketValue:u(a.ADD_MARKET_CAP),addMarketValuePercent:u(a.ADD_MARKET_CAP_PROPORTION),sector:String(a.BOARD_NAME??"")}))}async function Eo(t,e="north",n={}){let{startDate:r,endDate:o}=n,i=[e==="north"?'(BOARD_TYPE="1")':'(BOARD_TYPE="0")'];return r&&i.push(`(TRADE_DATE>='${r}')`),o&&i.push(`(TRADE_DATE<='${o}')`),A(t,{reportName:"RPT_MUTUAL_DEAL_HISTORY",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:i.join("")},s=>({date:F(s.TRADE_DATE),netBuyAmount:u(s.NET_DEAL_AMT),buyAmount:u(s.BUY_AMT),sellAmount:u(s.SELL_AMT),accNetBuyAmount:u(s.ACCUM_DEAL_AMT),netInflow:u(s.FUND_INFLOW),remainAmount:u(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:u(s.LS_CHANGE_RATE)}))}async function Co(t,e,n={}){let r=e.replace(/^(sh|sz|bj)/i,""),{startDate:o,endDate:i}=n,s=[`(SECURITY_CODE="${r}")`];return o&&s.push(`(TRADE_DATE>='${o}')`),i&&s.push(`(TRADE_DATE<='${i}')`),A(t,{reportName:"RPT_MUTUAL_HOLDSTOCKNORTH_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:s.join("")},a=>({date:F(a.TRADE_DATE),holdShares:u(a.HOLD_SHARES),holdMarketValue:u(a.HOLD_MARKET_CAP),holdRatioFloat:u(a.HOLD_RATIO),holdRatioTotal:u(a.A_SHARES_RATIO),close:u(a.CLOSE_PRICE),changePercent:u(a.CHANGE_RATE)}))}var cs={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"}},ds={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"},ps={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 Bn(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 ms(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function fs(t){let e=u(t.p),n=u(t.tp);return{code:String(t.c??t.m??""),name:String(t.n??""),price:e!==null?e/1e3:null,changePercent:u(t.zdp),limitPrice:n!==null?n/1e3:null,amount:u(t.amount??t.zb),floatMarketValue:u(t.ltsz),totalMarketValue:u(t.tshare),turnoverRate:u(t.hs),continuousBoardCount:u(t.lbc),firstBoardTime:t.fbt!==void 0&&t.fbt!==null?Bn(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?Bn(t.lbt):null,boardAmount:u(t.fund),sealAmount:u(t.fund),failedCount:u(t.zbc),industry:String(t.hybk??""),ztStatistics:ms(t.zttj),amplitude:u(t.zf),speed:u(t.zs)}}function gs(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function hs(){let t=new Date(Date.now()+288e5),e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),r=String(t.getUTCDate()).padStart(2,"0");return`${e}${n}${r}`}async function Oo(t,e="zt",n){let r=cs[e];if(!r)throw new RangeError(`Invalid ZTPool type: ${e}.`);let o=gs(n)??hs(),i=new URLSearchParams({ut:D,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:r.sort,date:o}),s=`${Ce}${r.path}?${i.toString()}`,l=(await t.get(s,{responseType:"json"}))?.data?.pool;return!Array.isArray(l)||l.length===0?[]:l.map(fs)}async function _o(t,e="large_buy"){let n=ds[e];if(!n)throw new RangeError(`Invalid StockChangeType: ${e}.`);let r=new URLSearchParams({type:n,pageindex:"0",pagesize:"5000",ut:D,dpt:"wzchanges"}),o=`${Ce}/getAllStockChanges?${r.toString()}`,s=(await t.get(o,{responseType:"json"}))?.data?.allstock;return!Array.isArray(s)||s.length===0?[]:s.map(a=>{let l=String(a.t??n);return{time:Bn(a.tm),code:String(a.c??""),name:String(a.n??""),changeType:e,changeTypeLabel:ps[l]??"",info:String(a.i??"")}})}async function Ao(t){let e=new URLSearchParams({ut:D,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),n=`${Ce}/getAllBKChanges?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.data?.allbk;return!Array.isArray(o)||o.length===0?[]:o.map(i=>{let s=i.ms??{},a=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[d,f]of Object.entries(c))l[d]=Number(f)||0;return{name:String(i.bkn??""),changePercent:u(i.bkz),mainNetInflow:u(i.bkj),totalChangeCount:u(i.bkc),topStockCode:String(s.c??""),topStockName:String(s.n??""),topStockDirection:a,changeTypeDistribution:l}})}var Io={"1month":"01","3month":"02","6month":"03","1year":"04"};function we(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}async function Po(t,e){let n=we(e.startDate),r=we(e.endDate);return A(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<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:F(o.TRADE_DATE),close:u(o.CLOSE_PRICE),changePercent:u(o.CHANGE_RATE),netBuyAmount:u(o.BILLBOARD_NET_AMT),buyAmount:u(o.BILLBOARD_BUY_AMT),sellAmount:u(o.BILLBOARD_SELL_AMT),dealAmount:u(o.BILLBOARD_DEAL_AMT),totalAmount:u(o.ACCUM_AMOUNT),netBuyRatio:u(o.DEAL_NET_RATIO),dealAmountRatio:u(o.DEAL_AMOUNT_RATIO),turnoverRate:u(o.TURNOVERRATE),floatMarketValue:u(o.FREE_MARKET_CAP),reason:String(o.EXPLANATION??o.EXPLAIN??""),afterChange1d:u(o.D1_CLOSE_ADJCHRATE),afterChange2d:u(o.D2_CLOSE_ADJCHRATE),afterChange5d:u(o.D5_CLOSE_ADJCHRATE),afterChange10d:u(o.D10_CLOSE_ADJCHRATE)}))}async function Do(t,e="1month"){let n=Io[e];if(!n)throw new RangeError(`Invalid period: ${e}.`);return A(t,{reportName:"RPT_BILLBOARD_TRADEALL",columns:"ALL",sortColumns:"BILLBOARD_TIMES,LATEST_TDATE,SECURITY_CODE",sortTypes:"-1,-1,1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),latestDate:F(r.LATEST_TDATE),close:u(r.CLOSE_PRICE),changePercent:u(r.CHANGE_RATE),count:u(r.BILLBOARD_TIMES),totalBuyAmount:u(r.BILLBOARD_BUY_AMT),totalSellAmount:u(r.BILLBOARD_SELL_AMT),totalNetAmount:u(r.BILLBOARD_NET_AMT),totalDealAmount:u(r.BILLBOARD_DEAL_AMT),buyOrgCount:u(r.ORG_BUY_TIMES),sellOrgCount:u(r.ORG_SELL_TIMES)}))}async function Mo(t,e){let n=we(e.startDate),r=we(e.endDate);return A(t,{reportName:"RPT_ORGANIZATION_TRADE_DETAILS",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:`(TRADE_DATE<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:F(o.TRADE_DATE),close:u(o.CLOSE_PRICE),changePercent:u(o.CHANGE_RATE),buyOrgCount:u(o.BUY_TIMES),sellOrgCount:u(o.SELL_TIMES),orgBuyAmount:u(o.BUY_AMT),orgSellAmount:u(o.SELL_AMT),orgNetAmount:u(o.NET_AMT)}))}async function bo(t,e="1month"){let n=Io[e];if(!n)throw new RangeError(`Invalid period: ${e}.`);return A(t,{reportName:"RPT_BILLBOARD_TRADEDETAILS",columns:"ALL",sortColumns:"TOTAL_BUYER_SALESTIMES",sortTypes:"-1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(r.OPERATEDEPT_CODE??""),name:String(r.OPERATEDEPT_NAME??""),totalBuyAmount:u(r.TOTAL_BUYAMT??r.BUY_AMT),totalSellAmount:u(r.TOTAL_SELLAMT??r.SELL_AMT),buyCount:u(r.TOTAL_BUYER_SALESTIMES??r.BUY_TIMES),sellCount:u(r.TOTAL_SELLER_SALESTIMES??r.SELL_TIMES),totalCount:u(r.TOTAL_TIMES)}))}async function ko(t,e,n){let r=e.replace(/^(sh|sz|bj)/i,""),o=we(n),i=`(SECURITY_CODE="${r}")(TRADE_DATE='${o}')`,[s,a]=await Promise.all([A(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSBUY",columns:"ALL",sortColumns:"BUY_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:u(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:u(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:u(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:u(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:u(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:u(l.NET_AMT),side:"buy"})),A(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSSELL",columns:"ALL",sortColumns:"SELL_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:u(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:u(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:u(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:u(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:u(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:u(l.NET_AMT),side:"sell"}))]);return[...s,...a]}function Lo(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function No(t){if(!t)return"";let e=Lo(t.startDate),n=Lo(t.endDate),r=[];return e&&r.push(`(TRADE_DATE>='${e}')`),n&&r.push(`(TRADE_DATE<='${n}')`),r.join("")}async function Fo(t){return A(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:F(e.TRADE_DATE),shClose:u(e.CLOSE_PRICE??e.SH_CLOSE_PRICE),shChangePercent:u(e.CHANGE_RATE??e.SH_CHANGE_RATE),totalAmount:u(e.TURNOVER??e.TOTAL_AMOUNT),premiumAmount:u(e.PREMIUM_TURNOVER??e.PREMIUM_AMOUNT),premiumRatio:u(e.PREMIUM_RATIO),discountAmount:u(e.DISCOUNT_TURNOVER??e.DISCOUNT_AMOUNT),discountRatio:u(e.DISCOUNT_RATIO)}))}async function xo(t,e={}){let n=No(e);return A(t,{reportName:"RPT_BLOCK_TRADE_DETAIL",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:n||void 0},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:F(r.TRADE_DATE),close:u(r.CLOSE_PRICE),changePercent:u(r.CHANGE_RATE),dealPrice:u(r.DEAL_PRICE??r.PRICE),dealVolume:u(r.DEAL_VOLUME??r.VOLUME),dealAmount:u(r.DEAL_AMT??r.TURNOVER),premiumRate:u(r.PREMIUM_RATIO??r.PREMIUM_RATE),buyBranch:String(r.BUYER_DEPT??r.BUYER_OPERATEDEPT_NAME??""),sellBranch:String(r.SELLER_DEPT??r.SELLER_OPERATEDEPT_NAME??"")}))}async function vo(t,e={}){let n=No(e);return A(t,{reportName:"RPT_BLOCK_TRADE_STA",columns:"ALL",sortColumns:"TRADE_DATE,DEAL_AMT",sortTypes:"-1,-1",pageSize:5e3,filter:n||void 0},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:F(r.TRADE_DATE),changePercent:u(r.CHANGE_RATE),close:u(r.CLOSE_PRICE),dealCount:u(r.DEAL_NUM??r.DEAL_COUNT),dealTotalAmount:u(r.DEAL_AMT??r.TOTAL_AMOUNT),dealTotalVolume:u(r.DEAL_VOLUME??r.TOTAL_VOLUME),premiumAmount:u(r.PREMIUM_AMT??r.PREMIUM_AMOUNT),discountAmount:u(r.DISCOUNT_AMT??r.DISCOUNT_AMOUNT)}))}async function wo(t){return A(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:F(e.STATISTICS_DATE??e.TRADE_DATE),finBalance:u(e.FIN_BALANCE),loanBalance:u(e.LOAN_BALANCE),finBuyAmount:u(e.FIN_BUY_AMT),loanSellAmount:u(e.LOAN_SELL_AMT),investorCount:u(e.OPERATE_INVESTOR_NUM??e.INVESTOR_NUM),liabilityInvestorCount:u(e.MARGIN_INVESTOR_NUM),totalGuarantee:u(e.TOTAL_GUARANTEE),avgGuaranteeRatio:u(e.AVG_GUARANTEE_RATIO)}))}async function Uo(t,e){let n=e?`(TRADE_DATE='${e}')`:void 0;return A(t,{reportName:"RPT_MARGIN_TRADE_DETAIL",columns:"ALL",sortColumns:"FIN_BALANCE",sortTypes:"-1",pageSize:5e3,filter:n},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:F(r.TRADE_DATE),finBalance:u(r.FIN_BALANCE),finBuyAmount:u(r.FIN_BUY_AMT),finRepayAmount:u(r.FIN_REPAY_AMT),loanBalance:u(r.LOAN_BALANCE),loanSellVolume:u(r.LOAN_SELL_VOLUME),loanRepayVolume:u(r.LOAN_REPAY_VOLUME)}))}var q={};mt(q,{getCommodityOptionKline:()=>Yo,getCommodityOptionSpot:()=>Go,getETFOption5DayMinute:()=>Qo,getETFOptionDailyKline:()=>jo,getETFOptionExpireDay:()=>qo,getETFOptionMinute:()=>zo,getETFOptionMonths:()=>Ho,getIndexOptionKline:()=>Bo,getIndexOptionSpot:()=>Ko});function Ts(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:u(t[7]),symbol:t[8]??""}}function ys(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:null,symbol:t[7]??""}}async function Ko(t,e){let n=`${Ae}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,r=await N(n),o=r?.result?.data?.up??[],i=r?.result?.data?.down??[];return{calls:o.map(Ts),puts:i.map(ys)}}async function Bo(t){let e=`${Ie}?symbol=${t}`,n=await N(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:u(r.o),high:u(r.h),low:u(r.l),close:u(r.c),volume:u(r.v)})):[]}async function Ho(t){let e=`${ln}?exchange=null&cate=${encodeURIComponent(t)}`,r=(await N(e))?.result?.data,o=r?.contractMonth??[];return{months:o.length>1?o.slice(1):o,stockId:r?.stockId??"",cateId:r?.cateId??"",cateList:r?.cateList??[]}}async function qo(t,e){let n=`${yt}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,r=await N(n),o=r?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let s=`${yt}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;r=await N(s)}let i=r?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function $o(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:u(n.p),volume:u(n.v),openInterest:u(n.t),avgPrice:u(n.a)}))}async function zo(t){let e=`CON_OP_${t}`,n=`${cn}?symbol=${e}`,o=(await N(n))?.result?.data;return Array.isArray(o)?$o(o):[]}async function jo(t){let e=`CON_OP_${t}`,n=`${dn}?symbol=${e}`,r=await N(n,{callbackMode:"path"});return Array.isArray(r)?r.map(o=>({date:o.d,open:u(o.o),high:u(o.h),low:u(o.l),close:u(o.c),volume:u(o.v)})):[]}async function Qo(t){let e=`CON_OP_${t}`,n=`${pn}?symbol=${e}`,o=(await N(n))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...$o(s));return i}function Ss(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:u(t[7]),symbol:t[8]??""}}function Rs(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:null,symbol:t[7]??""}}async function Go(t,e){let n=St[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(St).join(", ")}`);let r=`${Ae}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,o=await N(r),i=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:i.map(Ss),puts:s.map(Rs)}}async function Yo(t){let e=`${Ie}?symbol=${t}`,n=await N(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:u(r.o),high:u(r.h),low:u(r.l),close:u(r.c),volume:u(r.v)})):[]}var P=class{constructor(e){this.client=e}};var Ue=class extends P{constructor(e){super(e)}getFullQuotes(e){return M.getFullQuotes(this.client,e)}getSimpleQuotes(e){return M.getSimpleQuotes(this.client,e)}getHKQuotes(e){return M.getHKQuotes(this.client,e)}getUSQuotes(e){return M.getUSQuotes(this.client,e)}getFundQuotes(e){return M.getFundQuotes(this.client,e)}getFundFlow(e){return M.getFundFlow(this.client,e)}getPanelLargeOrder(e){return M.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return M.getTodayTimeline(this.client,e)}search(e){return M.search(this.client,e)}getAShareCodeList(e){return M.getAShareCodeList(this.client,e)}getUSCodeList(e){return M.getUSCodeList(this.client,e)}getHKCodeList(){return M.getHKCodeList(this.client)}getFundCodeList(){return M.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...r}=e,o=await this.getAShareCodeList({market:n});return M.getAllQuotesByCodes(this.client,o,r)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return M.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...r}=e,o=await this.getUSCodeList({simple:!0,market:n});return M.getAllUSQuotesByCodes(this.client,o,r)}getAllQuotesByCodes(e,n={}){return M.getAllQuotesByCodes(this.client,e,n)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return M.getTradingCalendar(this.client)}getDividendDetail(e){return y.getDividendDetail(this.client,e)}};var Ke=class extends P{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,n){return y.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return y.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return y.getConceptList(this.client)}getConceptSpot(e){return y.getConceptSpot(this.client,e)}getConceptConstituents(e){return y.getConceptConstituents(this.client,e)}getConceptKline(e,n){return y.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return y.getConceptMinuteKline(this.client,e,n)}};var Be=class extends P{constructor(e){super(e)}getHistoryKline(e,n){return y.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return y.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return y.getHKHistoryKline(this.client,e,n)}getHKMinuteKline(e,n){return y.getHKMinuteKline(this.client,e,n)}getUSHistoryKline(e,n){return y.getUSHistoryKline(this.client,e,n)}getUSMinuteKline(e,n){return y.getUSMinuteKline(this.client,e,n)}};var He=class extends P{constructor(e){super(e)}getFuturesKline(e,n){return y.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return y.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return y.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return y.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return y.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return y.getComexInventory(this.client,e,n)}};var qe=class extends P{constructor(e){super(e)}getIndexOptionSpot(e,n){return q.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return q.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return y.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return q.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return q.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return q.getETFOptionMinute(e)}getETFOptionDailyKline(e){return q.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return q.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return q.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return q.getCommodityOptionKline(e)}getOptionLHB(e,n){return y.getOptionLHB(this.client,e,n)}};function $e(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ee(t,e){let n=[];for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let o=0,i=0;for(let s=r-e+1;s<=r;s++)t[s]!==null&&(o+=t[s],i++);n.push(i===e?$e(o/e):null)}return n}function V(t,e){let n=[],r=2/(e+1),o=null,i=!1;for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}if(!i){let l=0,c=0;for(let d=s-e+1;d<=s;d++)t[d]!==null&&(l+=t[d],c++);c===e&&(o=l/e,i=!0),n.push(o!==null?$e(o):null);continue}let a=t[s];a===null?n.push(o!==null?$e(o):null):(o=r*a+(1-r)*o,n.push($e(o)))}return n}function bt(t,e){let n=[],r=Array.from({length:e},(i,s)=>s+1),o=r.reduce((i,s)=>i+s,0);for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let s=0,a=!0;for(let l=0;l<e;l++){let c=t[i-e+1+l];if(c===null){a=!1;break}s+=c*r[l]}n.push(a?$e(s/o):null)}return n}function ze(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:r="sma"}=e,o=r==="ema"?V:r==="wma"?bt:ee,i={};for(let s of n)i[`ma${s}`]=o(t,s);return t.map((s,a)=>{let l={};for(let c of n)l[`ma${c}`]=i[`ma${c}`][a];return l})}function Vo(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function je(t,e={}){let{short:n=12,long:r=26,signal:o=9}=e,i=V(t,n),s=V(t,r),a=t.map((c,d)=>i[d]===null||s[d]===null?null:i[d]-s[d]),l=V(a,o);return t.map((c,d)=>({dif:a[d]!==null?Vo(a[d]):null,dea:l[d],macd:a[d]!==null&&l[d]!==null?Vo((a[d]-l[d])*2):null}))}function Hn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Es(t,e,n){let r=[];for(let o=0;o<t.length;o++){if(o<e-1||n[o]===null){r.push(null);continue}let i=0,s=0;for(let a=o-e+1;a<=o;a++)t[a]!==null&&n[o]!==null&&(i+=Math.pow(t[a]-n[o],2),s++);r.push(s===e?Math.sqrt(i/e):null)}return r}function Qe(t,e={}){let{period:n=20,stdDev:r=2}=e,o=ee(t,n),i=Es(t,n,o);return t.map((s,a)=>{if(o[a]===null||i[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=o[a]+r*i[a],c=o[a]-r*i[a],d=o[a]!==0?Hn((l-c)/o[a]*100):null;return{mid:o[a],upper:Hn(l),lower:Hn(c),bandwidth:d}})}function qn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ge(t,e={}){let{period:n=9,kPeriod:r=3,dPeriod:o=3}=e,i=[],s=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){i.push({k:null,d:null,j:null});continue}let c=-1/0,d=1/0,f=!0;for(let p=l-n+1;p<=l;p++){if(t[p].high===null||t[p].low===null){f=!1;break}c=Math.max(c,t[p].high),d=Math.min(d,t[p].low)}let g=t[l].close;if(!f||g===null||c===d){i.push({k:null,d:null,j:null});continue}let T=(g-d)/(c-d)*100;s=(r-1)/r*s+1/r*T,a=(o-1)/o*a+1/o*s;let S=3*s-2*a;i.push({k:qn(s),d:qn(a),j:qn(S)})}return i}function Cs(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ye(t,e={}){let{periods:n=[6,12,24]}=e,r=[null];for(let i=1;i<t.length;i++)t[i]===null||t[i-1]===null?r.push(null):r.push(t[i]-t[i-1]);let o={};for(let i of n){let s=[],a=0,l=0;for(let c=0;c<t.length;c++){if(c<i){s.push(null),r[c]!==null&&(r[c]>0?a+=r[c]:l+=Math.abs(r[c]));continue}if(c===i)r[c]!==null&&(r[c]>0?a+=r[c]:l+=Math.abs(r[c])),a=a/i,l=l/i;else{let d=r[c]??0,f=d>0?d:0,g=d<0?Math.abs(d):0;a=(a*(i-1)+f)/i,l=(l*(i-1)+g)/i}if(l===0)s.push(100);else if(a===0)s.push(0);else{let d=a/l;s.push(Cs(100-100/(1+d)))}}o[`rsi${i}`]=s}return t.map((i,s)=>{let a={};for(let l of n)a[`rsi${l}`]=o[`rsi${l}`][s];return a})}function Os(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ve(t,e={}){let{periods:n=[6,10]}=e,r={};for(let o of n){let i=[];for(let s=0;s<t.length;s++){if(s<o-1){i.push(null);continue}let a=-1/0,l=1/0,c=!0;for(let g=s-o+1;g<=s;g++){if(t[g].high===null||t[g].low===null){c=!1;break}a=Math.max(a,t[g].high),l=Math.min(l,t[g].low)}let d=t[s].close;if(!c||d===null||a===l){i.push(null);continue}let f=(a-d)/(a-l)*100;i.push(Os(f))}r[`wr${o}`]=i}return t.map((o,i)=>{let s={};for(let a of n)s[`wr${a}`]=r[`wr${a}`][i];return s})}function _s(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function We(t,e={}){let{periods:n=[6,12,24]}=e,r={};for(let o of n){let i=ee(t,o),s=[];for(let a=0;a<t.length;a++)if(t[a]===null||i[a]===null||i[a]===0)s.push(null);else{let l=(t[a]-i[a])/i[a]*100;s.push(_s(l))}r[`bias${o}`]=s}return t.map((o,i)=>{let s={};for(let a of n)s[`bias${a}`]=r[`bias${a}`][i];return s})}function As(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Xe(t,e={}){let{period:n=14}=e,r=[],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<n-1){r.push({cci:null});continue}let s=0,a=0;for(let f=i-n+1;f<=i;f++)o[f]!==null&&(s+=o[f],a++);if(a!==n||o[i]===null){r.push({cci:null});continue}let l=s/n,c=0;for(let f=i-n+1;f<=i;f++)c+=Math.abs(o[f]-l);let d=c/n;if(d===0)r.push({cci:0});else{let f=(o[i]-l)/(.015*d);r.push({cci:As(f)})}}return r}function $n(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ce(t,e={}){let{period:n=14}=e,r=[],o=[];for(let s=0;s<t.length;s++){let{high:a,low:l,close:c}=t[s];if(a===null||l===null||c===null){o.push(null);continue}if(s===0)o.push(a-l);else{let d=t[s-1].close;if(d===null)o.push(a-l);else{let f=a-l,g=Math.abs(a-d),T=Math.abs(l-d);o.push(Math.max(f,g,T))}}}let i=null;for(let s=0;s<t.length;s++){if(s<n-1){r.push({tr:o[s]!==null?$n(o[s]):null,atr:null});continue}if(s===n-1){let a=0,l=0;for(let c=0;c<n;c++)o[c]!==null&&(a+=o[c],l++);l===n&&(i=a/n)}else i!==null&&o[s]!==null&&(i=(i*(n-1)+o[s])/n);r.push({tr:o[s]!==null?$n(o[s]):null,atr:i!==null?$n(i):null})}return r}function Ze(t,e={}){let{maPeriod:n}=e,r=[];if(t.length===0)return r;let o=t[0].volume??0;r.push({obv:o,obvMa:null});for(let i=1;i<t.length;i++){let s=t[i],a=t[i-1];if(s.close===null||a.close===null||s.volume===null||s.volume===void 0){r.push({obv:null,obvMa:null});continue}s.close>a.close?o+=s.volume:s.close<a.close&&(o-=s.volume),r.push({obv:o,obvMa:null})}if(n&&n>0)for(let i=n-1;i<r.length;i++){let s=0,a=0;for(let l=i-n+1;l<=i;l++)r[l].obv!==null&&(s+=r[l].obv,a++);a===n&&(r[i].obvMa=s/n)}return r}function Je(t,e={}){let{period:n=12,signalPeriod:r}=e,o=[];for(let i=0;i<t.length;i++){if(i<n){o.push({roc:null,signal:null});continue}let s=t[i].close,a=t[i-n].close;if(s===null||a===null||a===0){o.push({roc:null,signal:null});continue}let l=(s-a)/a*100;o.push({roc:l,signal:null})}if(r&&r>0)for(let i=n+r-1;i<o.length;i++){let s=0,a=0;for(let l=i-r+1;l<=i;l++)o[l].roc!==null&&(s+=o[l].roc,a++);a===r&&(o[i].signal=s/r)}return o}function et(t,e={}){let{period:n=14,adxPeriod:r=n}=e,o=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let i=[],s=[],a=[];for(let p=0;p<t.length;p++){if(p===0){i.push(0),s.push(0),a.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let h=t[p],E=t[p-1];if(h.high===null||h.low===null||h.close===null||E.high===null||E.low===null||E.close===null){i.push(0),s.push(0),a.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=h.high-h.low,b=Math.abs(h.high-E.close),I=Math.abs(h.low-E.close);a.push(Math.max(O,b,I));let k=h.high-E.high,$=E.low-h.low;k>$&&k>0?i.push(k):i.push(0),$>k&&$>0?s.push($):s.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,c=0,d=0,f=[];for(let p=1;p<t.length;p++){if(p<n){l+=a[p],c+=i[p],d+=s[p],f.push(0);continue}p===n?(l+=a[p],c+=i[p],d+=s[p]):(l=l-l/n+a[p],c=c-c/n+i[p],d=d-d/n+s[p]);let h=l>0?c/l*100:0,E=l>0?d/l*100:0;o[p].pdi=h,o[p].mdi=E;let O=h+E,b=O>0?Math.abs(h-E)/O*100:0;f.push(b)}let g=0,T=0,S=0;for(let p=n;p<t.length;p++){if(p<n*2-1){g+=f[p-1]||0,T++;continue}if(p===n*2-1)g+=f[p-1]||0,S=g/r,o[p].adx=S;else{let h=f[p-1]||0;S=(S*(r-1)+h)/r,o[p].adx=S}}for(let p=n*2-1+r;p<t.length;p++){let h=o[p].adx,E=o[p-r]?.adx;h!==null&&E!==null&&(o[p].adxr=(h+E)/2)}return o}function tt(t,e={}){let{afStart:n=.02,afIncrement:r=.02,afMax:o=.2}=e,i=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let s=1,a=n,l=t[0].high??0,c=t[0].low??0,d=t[0],f=t[1];d.close!==null&&f.close!==null&&f.close<d.close&&(s=-1,l=d.low??0,c=d.high??0),i.push({sar:null,trend:null,ep:null,af:null});for(let g=1;g<t.length;g++){let T=t[g],S=t[g-1];if(T.high===null||T.low===null||S.high===null||S.low===null){i.push({sar:null,trend:null,ep:null,af:null});continue}let p=c+a*(l-c);s===1?(p=Math.min(p,S.low,t[Math.max(0,g-2)]?.low??S.low),T.low<p?(s=-1,p=l,l=T.low,a=n):T.high>l&&(l=T.high,a=Math.min(a+r,o))):(p=Math.max(p,S.high,t[Math.max(0,g-2)]?.high??S.high),T.high>p?(s=1,p=l,l=T.high,a=n):T.low<l&&(l=T.low,a=Math.min(a+r,o))),c=p,i.push({sar:c,trend:s,ep:l,af:a})}return i}function nt(t,e={}){let{emaPeriod:n=20,atrPeriod:r=10,multiplier:o=2}=e,i=[],s=t.map(c=>c.close),a=V(s,n),l=ce(t,{period:r});for(let c=0;c<t.length;c++){let d=a[c],f=l[c]?.atr;if(d===null||f===null){i.push({mid:null,upper:null,lower:null,width:null});continue}let g=d+o*f,T=d-o*f,S=d>0?(g-T)/d*100:null;i.push({mid:d,upper:g,lower:T,width:S})}return i}function kt(t,e=0){return t.length===0?e:Math.max(...t)}function rt(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 de={ma:{key:"ma",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.periods??[5,10,20,30,60,120,250],r=e.type??"sma";return{bars:kt(n,20),emaBased:r==="ema"}},compute:(t,e)=>ze(t.closes,typeof e=="object"?e:{})},macd:{key:"macd",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.long??26,r=e.signal??9;return{bars:n*3+r,emaBased:!0}},compute:(t,e)=>je(t.closes,typeof e=="object"?e:{})},boll:{key:"boll",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:20}),compute:(t,e)=>Qe(t.closes,typeof e=="object"?e:{})},kdj:{key:"kdj",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:9}),compute:(t,e)=>Ge(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:kt(e,14)+1}},compute:(t,e)=>Ye(t.closes,typeof e=="object"?e:{})},wr:{key:"wr",estimateLookback:t=>{let e=typeof t=="object"&&t.periods?t.periods:[6,10];return{bars:kt(e,10)}},compute:(t,e)=>Ve(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:kt(e,12)}},compute:(t,e)=>We(t.closes,typeof e=="object"?e:{})},cci:{key:"cci",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>Xe(t.ohlcv,typeof e=="object"?e:{})},atr:{key:"atr",estimateLookback:t=>({bars:typeof t=="object"&&t.period?t.period:14}),compute:(t,e)=>ce(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)=>Ze(t.ohlcv,typeof e=="object"?e:{})},roc:{key:"roc",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.period??12,r=e.signalPeriod??0;return{bars:n+r}},compute:(t,e)=>Je(t.ohlcv,typeof e=="object"?e:{})},dmi:{key:"dmi",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.period??14,r=e.adxPeriod??n;return{bars:n*2+r}},compute:(t,e)=>et(t.ohlcv,typeof e=="object"?e:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(t,e)=>tt(t.ohlcv,typeof e=="object"?e:{})},kc:{key:"kc",estimateLookback:t=>{let e=typeof t=="object"?t:{},n=e.emaPeriod??20,r=e.atrPeriod??10;return{bars:Math.max(n*3,r),emaBased:!0}},compute:(t,e)=>nt(t.ohlcv,typeof e=="object"?e:{})}};function ye(t){return Object.keys(de).filter(e=>!!t[e])}function ot(t){let e=0,n=!1;for(let o of ye(t)){let s=de[o].estimateLookback(t[o]);e=Math.max(e,s.bars),n||(n=!!s.emaBased)}return{maxLookback:e,hasEmaBasedIndicator:n,requiredBars:Math.ceil(e*(n?1.5:1.2))}}function it(t,e={}){if(t.length===0)return[];let n=rt(t),r=new Map;for(let o of ye(e)){let i=de[o];r.set(o,i.compute(n,e[o]))}return t.map((o,i)=>({...o,...Object.fromEntries(Array.from(r.entries()).map(([s,a])=>[s,a[i]]))}))}var st=class{constructor(e,n){this.klineService=e;this.quoteService=n}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}calcActualStartDate(e,n,r=1.5){let o=this.toCompactDate(e),i=Math.ceil(n*r),s=new Date(parseInt(o.slice(0,4)),parseInt(o.slice(4,6))-1,parseInt(o.slice(6,8)));s.setDate(s.getDate()-i);let a=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),c=String(s.getDate()).padStart(2,"0");return`${a}${l}${c}`}calcActualStartDateByCalendar(e,n,r){if(!r||r.length===0)return;let o=this.normalizeDate(e),i=r.findIndex(a=>a>=o);i===-1&&(i=r.length-1);let s=Math.max(0,i-n);return this.toCompactDate(r[s])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:r,endDate:o,indicators:i={}}=n,s=n.market??this.detectMarket(e),{requiredBars:a}=ot(i),l={A:1.5,HK:1.46,US:1.45},c;if(r)if(s==="A")try{let T=await this.quoteService.getTradingCalendar();c=this.calcActualStartDateByCalendar(r,a,T)??this.calcActualStartDate(r,a,l[s])}catch{c=this.calcActualStartDate(r,a,l[s])}else c=this.calcActualStartDate(r,a,l[s]);let d={period:n.period,adjust:n.adjust,startDate:c,endDate:n.endDate?this.toCompactDate(n.endDate):void 0},f;switch(s){case"HK":f=await this.klineService.getHKHistoryKline(e,d);break;case"US":f=await this.klineService.getUSHistoryKline(e,d);break;default:f=await this.klineService.getHistoryKline(e,d)}if(r&&f.length<a)switch(s){case"HK":f=await this.klineService.getHKHistoryKline(e,{...d,startDate:void 0});break;case"US":f=await this.klineService.getUSHistoryKline(e,{...d,startDate:void 0});break;default:f=await this.klineService.getHistoryKline(e,{...d,startDate:void 0})}let g=it(f,i);if(r){let T=this.dateToTimestamp(r),S=o?this.dateToTimestamp(o):1/0;return g.filter(p=>{let h=this.dateToTimestamp(p.date);return h>=T&&h<=S})}return g}};var at=class extends P{constructor(e){super(e)}getIndividualFundFlow(e,n){return y.getIndividualFundFlow(this.client,e,n)}getMarketFundFlow(){return y.getMarketFundFlow(this.client)}getFundFlowRank(e){return y.getFundFlowRank(this.client,e)}getSectorFundFlowRank(e){return y.getSectorFundFlowRank(this.client,e)}getSectorFundFlowHistory(e,n){return y.getSectorFundFlowHistory(this.client,e,n)}};var ut=class extends P{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,n){return y.getNorthboundHistory(this.client,e,n)}getNorthboundIndividual(e,n){return y.getNorthboundIndividual(this.client,e,n)}};var lt=class extends P{constructor(e){super(e)}getZTPool(e,n){return y.getZTPool(this.client,e,n)}getStockChanges(e){return y.getStockChanges(this.client,e)}getBoardChanges(){return y.getBoardChanges(this.client)}};var ct=class extends P{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,n){return y.getDragonTigerStockSeatDetail(this.client,e,n)}};var dt=class extends P{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 U=(t,e)=>t*60+e,Is={A:{tz:C.CN,open:[[U(9,30),U(11,30)],[U(13,0),U(15,0)]],lunchBreak:[U(11,30),U(13,0)],tradingWeekdays:[1,2,3,4,5]},HK:{tz:C.HK,open:[[U(9,30),U(12,0)],[U(13,0),U(16,0)]],lunchBreak:[U(12,0),U(13,0)],tradingWeekdays:[1,2,3,4,5]},US:{tz:C.US,open:[[U(9,30),U(16,0)]],tradingWeekdays:[1,2,3,4,5]}};function zn(t,e){if(t==null)return jn(new Date,e);if(t instanceof Date)return jn(t,e);let n=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(n))return n;if(/^\d{8}$/.test(n))return`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`;let r=new Date(n);if(!Number.isNaN(r.getTime()))return jn(r,e);throw new RangeError(`Unsupported date input: ${JSON.stringify(t)}. Expected 'YYYY-MM-DD', 'YYYYMMDD', or Date.`)}function jn(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(t)}function Ps(t,e){let n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,weekday:"short",hour:"2-digit",minute:"2-digit"}),r={};for(let l of n.formatToParts(t))l.type!=="literal"&&(r[l.type]=l.value);let o=parseInt(r.hour??"0",10);o===24&&(o=0);let i=parseInt(r.minute??"0",10),a={Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6,Sun:7}[r.weekday??""]??0;return{minutes:o*60+i,weekday:a}}function Qn(t,e){let n=0,r=t.length;for(;n<r;){let o=n+r>>>1;t[o]<e?n=o+1:r=o}return n}var pe=class{constructor(e){this.quoteService=e}async isTradingDay(e){let n=zn(e,C.CN),r=await this.quoteService.getTradingCalendar(),o=Qn(r,n);return o<r.length&&r[o]===n}async nextTradingDay(e){let n=zn(e,C.CN),r=await this.quoteService.getTradingCalendar(),o=Qn(r,n);if(o<r.length&&r[o]===n&&(o+=1),o>=r.length)throw new RangeError(`nextTradingDay: ${n} \u4E4B\u540E\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5927\u65E5\u671F ${r[r.length-1]??"N/A"})`);return r[o]}async prevTradingDay(e){let n=zn(e,C.CN),r=await this.quoteService.getTradingCalendar(),i=Qn(r,n)-1;if(i<0)throw new RangeError(`prevTradingDay: ${n} \u4E4B\u524D\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5C0F\u65E5\u671F ${r[0]??"N/A"})`);return r[i]}getMarketStatus(e="A",n=new Date){let r=Is[e],{minutes:o,weekday:i}=Ps(n,r.tz);if(!r.tradingWeekdays.includes(i))return"closed";let s=r.open[0][0],a=r.open[r.open.length-1][1];if(o<s)return"pre_market";if(o>=a)return"after_hours";for(let[l,c]of r.open)if(o>=l&&o<c)return"open";return r.lunchBreak&&o>=r.lunchBreak[0]&&o<r.lunchBreak[1]?"lunch_break":"closed"}};var me=class extends P{constructor(e){super(e)}getFundDividendList(e){return y.getFundDividendList(this.client,e)}getFundNavHistory(e){return y.getFundNavHistory(this.client,e)}getFundEstimate(e){return y.getFundEstimate(this.client,e)}getFundRankHistory(e){return y.getFundRankHistory(this.client,e)}};var pt=class{constructor(e={}){this.client=new Le(e),this.quoteService=new Ue(this.client),this.boardService=new Ke(this.client),this.klineService=new Be(this.client),this.futuresService=new He(this.client),this.optionsService=new qe(this.client),this.indicatorService=new st(this.klineService,this.quoteService),this.fundFlowService=new at(this.client),this.northboundService=new ut(this.client),this.marketEventService=new lt(this.client),this.dragonTigerService=new ct(this.client),this.dataService=new dt(this.client),this.tradingCalendarService=new pe(this.quoteService),this.fundService=new me(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,n){return this.boardService.getIndustryKline(e,n)}getIndustryMinuteKline(e,n){return this.boardService.getIndustryMinuteKline(e,n)}getConceptList(){return this.boardService.getConceptList()}getConceptSpot(e){return this.boardService.getConceptSpot(e)}getConceptConstituents(e){return this.boardService.getConceptConstituents(e)}getConceptKline(e,n){return this.boardService.getConceptKline(e,n)}getConceptMinuteKline(e,n){return this.boardService.getConceptMinuteKline(e,n)}getHistoryKline(e,n){return this.klineService.getHistoryKline(e,n)}getMinuteKline(e,n){return this.klineService.getMinuteKline(e,n)}getHKHistoryKline(e,n){return this.klineService.getHKHistoryKline(e,n)}getHKMinuteKline(e,n){return this.klineService.getHKMinuteKline(e,n)}getUSHistoryKline(e,n){return this.klineService.getUSHistoryKline(e,n)}getUSMinuteKline(e,n){return this.klineService.getUSMinuteKline(e,n)}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,n={}){return this.quoteService.getAllQuotesByCodes(e,n)}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,n){return this.futuresService.getFuturesKline(e,n)}getGlobalFuturesSpot(e){return this.futuresService.getGlobalFuturesSpot(e)}getGlobalFuturesKline(e,n){return this.futuresService.getGlobalFuturesKline(e,n)}getFuturesInventorySymbols(){return this.futuresService.getFuturesInventorySymbols()}getFuturesInventory(e,n){return this.futuresService.getFuturesInventory(e,n)}getComexInventory(e,n){return this.futuresService.getComexInventory(e,n)}getIndexOptionSpot(e,n){return this.optionsService.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return this.optionsService.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return this.optionsService.getCFFEXOptionQuotes(e)}getETFOptionMonths(e){return this.optionsService.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return this.optionsService.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return this.optionsService.getETFOptionMinute(e)}getETFOptionDailyKline(e){return this.optionsService.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return this.optionsService.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return this.optionsService.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return this.optionsService.getCommodityOptionKline(e)}getOptionLHB(e,n){return this.optionsService.getOptionLHB(e,n)}getKlineWithIndicators(e,n={}){return this.indicatorService.getKlineWithIndicators(e,n)}getIndividualFundFlow(e,n){return this.fundFlowService.getIndividualFundFlow(e,n)}getMarketFundFlow(){return this.fundFlowService.getMarketFundFlow()}getFundFlowRank(e){return this.fundFlowService.getFundFlowRank(e)}getSectorFundFlowRank(e){return this.fundFlowService.getSectorFundFlowRank(e)}getSectorFundFlowHistory(e,n){return this.fundFlowService.getSectorFundFlowHistory(e,n)}getNorthboundMinute(e){return this.northboundService.getNorthboundMinute(e)}getNorthboundFlowSummary(){return this.northboundService.getNorthboundFlowSummary()}getNorthboundHoldingRank(e){return this.northboundService.getNorthboundHoldingRank(e)}getNorthboundHistory(e,n){return this.northboundService.getNorthboundHistory(e,n)}getNorthboundIndividual(e,n){return this.northboundService.getNorthboundIndividual(e,n)}getZTPool(e,n){return this.marketEventService.getZTPool(e,n)}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,n){return this.dragonTigerService.getDragonTigerStockSeatDetail(e,n)}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)}getFundDividendList(e){return this.fundService.getFundDividendList(e)}getFundNavHistory(e){return this.fundService.getFundNavHistory(e)}getFundEstimate(e){return this.fundService.getFundEstimate(e)}getFundRankHistory(e){return this.fundService.getFundRankHistory(e)}},Wo=pt;var Ds={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},Ms={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},bs={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function ks(t){let e=t.code.trim(),n=t.market.trim().toLowerCase(),r=Ds[t.market]??n;return r==="sh"||r==="sz"?{code:e.replace(/^(sh|sz)/i,""),market:r}:r==="hk"?{code:e.replace(/^hk/i,"").padStart(5,"0"),market:r}:r==="us"?{code:e.replace(/^us/i,"").replace(/^\d{3}\./,"").toUpperCase(),market:r}:r==="global"?{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:r}:/^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 Ls(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Ns(t){let{code:e,market:n}=t;return(n==="sh"||n==="sz")&&Ls(e,n)?`https://quote.eastmoney.com/zs${e}.html`:n==="sh"||n==="sz"?`https://quote.eastmoney.com/${n}${e}.html`:n==="hk"?`https://quote.eastmoney.com/hk/${e}.html`:n==="us"?`https://quote.eastmoney.com/us/${e}.html`:n==="global"?`https://quote.eastmoney.com/gb/zs${bs[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function Fs(t){let{code:e,market:n}=t;return n==="sh"||n==="sz"?`https://xueqiu.com/S/${n.toUpperCase()}${e}`:n==="hk"?`https://xueqiu.com/S/${e}`:n==="us"?`https://xueqiu.com/S/${e}`:n==="global"?`https://xueqiu.com/S/${Ms[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function Xo(t){let e=ks(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Ns(e)},{name:"\u96EA\u7403",url:Fs(e)}]}0&&(module.exports={BROWSER_JSVARS_MUTEX_KEY,FundService,HttpError,INDICATOR_REGISTRY,MARKET_TZ,SdkError,StockSDK,TradingCalendarService,addIndicators,asyncPool,buildIndicatorContext,buildTimeMeta,buildTimeMetaFromDateAndTime,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,estimateIndicatorLookback,extractJsonFromJsonp,fetchJsVars,formatInTz,generateSearchExternalLinks,getEnabledIndicatorKeys,getSdkErrorCode,jsonpRequest,parseJsVars,parseMarketTime,parseResponse,safeNumber,safeNumberOrNull,withScriptMutex});
|