stock-sdk 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Le=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var rn=Object.prototype.hasOwnProperty;var Ie=(t,e)=>{for(var n in e)Le(t,n,{get:e[n],enumerable:!0})},sn=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of nn(e))!rn.call(t,s)&&s!==n&&Le(t,s,{get:()=>e[s],enumerable:!(i=tn(e,s))||i.enumerable});return t};var on=t=>sn(Le({},"__esModule",{value:!0}),t);var _n={};Ie(_n,{HttpError:()=>B,StockSDK:()=>ce,addIndicators:()=>ue,asyncPool:()=>v,calcATR:()=>F,calcBIAS:()=>le,calcBOLL:()=>re,calcCCI:()=>ae,calcDMI:()=>Rt,calcEMA:()=>_,calcKC:()=>bt,calcKDJ:()=>se,calcMA:()=>te,calcMACD:()=>ne,calcOBV:()=>yt,calcROC:()=>Ct,calcRSI:()=>ie,calcSAR:()=>St,calcSMA:()=>k,calcWMA:()=>_e,calcWR:()=>oe,chunkArray:()=>D,decodeGBK:()=>W,default:()=>Zt,parseResponse:()=>G,safeNumber:()=>h,safeNumberOrNull:()=>R});module.exports=on(_n);function W(t){return new TextDecoder("gbk").decode(t)}function G(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let s=i.indexOf("=");if(s<0)continue;let r=i.slice(0,s).trim();r.startsWith("v_")&&(r=r.slice(2));let o=i.slice(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));let l=o.split("~");n.push({key:r,fields:l})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function R(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function y(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function b(t){return t==null?null:y(String(t))}var Ke="https://qt.gtimg.cn",we="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Pe="https://assets.linkdiary.cn/shares/zh_a_list.json",Ue="https://assets.linkdiary.cn/shares/us_list.json",ke="https://assets.linkdiary.cn/shares/hk_list.json",Tt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var pe="https://push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://push2his.eastmoney.com/api/qt/stock/trends2/get",De="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",ve="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ne="https://17.push2.eastmoney.com/api/qt/clist/get",He="https://91.push2.eastmoney.com/api/qt/stock/get",qe="https://29.push2.eastmoney.com/api/qt/clist/get",Fe="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",je="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Qe="https://79.push2.eastmoney.com/api/qt/clist/get",$e="https://91.push2.eastmoney.com/api/qt/stock/get",We="https://29.push2.eastmoney.com/api/qt/clist/get",Ge="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Ve="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ze="https://datacenter-web.eastmoney.com/api/data/v1/get",Ye=3e4,V=500,z=500,Y=7,Xe=3,Je=1e3,Ze=3e4,et=2,tt=[408,429,500,502,503,504];var fe=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var At=["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"],nt=0;function ln(){return typeof window<"u"&&typeof window.document<"u"}function Ot(){if(ln())return;let t=At[nt];return nt=(nt+1)%At.length,t}var X=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},de=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 X;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 B=class extends Error{constructor(n,i,s,r){let o=i?` ${i}`:"",l=s?`, url: ${s}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${o}${l}${a}`);this.status=n;this.statusText=i;this.url=s;this.provider=r;this.name="HttpError"}},J=class{constructor(e={}){this.baseUrl=e.baseUrl??Ke,this.timeout=e.timeout??Ye,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new fe(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new de(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(i=>i.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Xe,baseDelay:e?.baseDelay??Je,maxDelay:e?.maxDelay??Ze,backoffMultiplier:e?.backoffMultiplier??et,retryableStatusCodes:e?.retryableStatusCodes??tt,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof B?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let i=await e();return this.circuitBreaker?.recordSuccess(),i}catch(i){if(this.shouldRetry(i,n)){let s=this.calculateDelay(n);return this.retryOptions.onRetry&&i instanceof Error&&this.retryOptions.onRetry(n+1,i,s),await this.sleep(s),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),i}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new X("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let i=new AbortController,s=setTimeout(()=>i.abort(),this.timeout),r=this.inferProvider(e),o={...this.headers};if(this.rotateUserAgent){let l=Ot();l&&(o["User-Agent"]=l)}try{let l=await fetch(e,{signal:i.signal,headers:o});if(!l.ok)throw new B(l.status,l.statusText,e,r);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=r),l}finally{clearTimeout(s)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer"}),s=W(i);return G(s)}};var an=new Set(["daily","weekly","monthly"]),un=new Set(["1","5","15","30","60"]),cn=new Set(["","qfq","hfq"]);function M(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function I(t){if(!an.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function Z(t){if(!un.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function E(t){if(!cn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function D(t,e){M(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function v(t,e){M(e,"concurrency");let n=[],i=[];for(let s of t){let r=Promise.resolve().then(()=>s()).then(o=>{n.push(o)});if(i.push(r),i.length>=e){await Promise.race(i);for(let o=i.length-1;o>=0;o--)await Promise.race([i[o].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&i.splice(o,1)}}return await Promise.all(i),n}function me(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function K(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function x(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var T={};Ie(T,{getAShareCodeList:()=>It,getAllHKQuotesByCodes:()=>Ut,getAllQuotesByCodes:()=>Pt,getAllUSQuotesByCodes:()=>kt,getFullQuotes:()=>he,getFundFlow:()=>Et,getFundQuotes:()=>_t,getHKCodeList:()=>wt,getHKQuotes:()=>ge,getPanelLargeOrder:()=>xt,getSimpleQuotes:()=>Mt,getTodayTimeline:()=>Lt,getTradingCalendar:()=>Bt,getUSCodeList:()=>Kt,getUSQuotes:()=>ye,parseFullQuote:()=>rt,parseFundFlow:()=>it,parseFundQuote:()=>ut,parseHKQuote:()=>lt,parsePanelLargeOrder:()=>ot,parseSimpleQuote:()=>st,parseUSQuote:()=>at,search:()=>vt});function rt(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),pb:R(t[46]),limitUp:R(t[47]),limitDown:R(t[48]),volumeRatio:R(t[49]),avgPrice:R(t[51]),peStatic:R(t[52]),peDynamic:R(t[53]),high52w:R(t[67]),low52w:R(t[68]),circulatingShares:R(t[72]),totalShares:R(t[73]),raw:t}}function st(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:R(t[9]),marketType:t[10]??"",raw:t}}function it(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function ot(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function lt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:R(t[40]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),currency:t[t.length-3]??"",raw:t}}function at(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),totalMarketCap:R(t[45]),pb:R(t[47]),high52w:R(t[48]),low52w:R(t[49]),raw:t}}function ut(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function he(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>rt(i.fields))}async function Mt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`s_${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>st(s.fields))}async function Et(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`ff_${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>it(s.fields))}async function xt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`s_pk${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>ot(s.fields))}async function ge(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`hk${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>lt(s.fields))}async function ye(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`us${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>at(s.fields))}async function _t(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`jj${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>ut(s.fields))}async function Lt(t,e){let n=t.getTimeout(),i=new AbortController,s=setTimeout(()=>i.abort(),n);try{let r=await fetch(`${we}?code=${e}`,{signal:i.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let o=await r.json();if(o.code!==0)throw new Error(o.msg||"API error");let l=o.data?.[e];if(!l)return{code:e,date:"",data:[]};let a=l.data?.data||[],u=l.data?.date||"",c=!1;if(a.length>0){let d=a[0].split(" "),m=parseFloat(d[1])||0,g=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;g>0&&m>0&&f/g>m*50&&(c=!0)}let p=a.map(d=>{let m=d.split(" "),g=m[0],f=`${g.slice(0,2)}:${g.slice(2,4)}`,C=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?C*100:C,L=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(L*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(s)}}var ct=null,pn=null,Ce=null,fn=null,Re=null;function dn(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 It(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!ct){let o=(await t.get(Pe,{responseType:"json"}))?.list||[];ct=o,pn=o.map(l=>l.replace(/^(sh|sz|bj)/,""))}let s=ct;return i&&(s=s.filter(r=>dn(r,i))),n?s.map(r=>r.replace(/^(sh|sz|bj)/,"")):s.slice()}var mn={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Kt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),Ce||(Ce=(await t.get(Ue,{responseType:"json"}))?.list||[],fn=Ce.map(o=>o.replace(/^\d{3}\./,"")));let s=Ce.slice();if(i){let r=mn[i];s=s.filter(o=>o.startsWith(r))}return n?s.map(r=>r.replace(/^\d{3}\./,"")):s}async function wt(t){return Re||(Re=(await t.get(ke,{responseType:"json"}))?.list||[]),Re.slice()}async function Pt(t,e,n={}){let{batchSize:i=V,concurrency:s=Y,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,z),l=D(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await he(t,d);return u++,r&&r(u,a),m});return(await v(c,s)).flat()}async function Ut(t,e,n={}){let{batchSize:i=V,concurrency:s=Y,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,z),l=D(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ge(t,d);return u++,r&&r(u,a),m});return(await v(c,s)).flat()}async function kt(t,e,n={}){let{batchSize:i=V,concurrency:s=Y,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,z),l=D(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ye(t,d);return u++,r&&r(u,a),m});return(await v(c,s)).flat()}var Q=null;async function Bt(t){if(Q)return Q.slice();let e=await t.get(Tt);return!e||e.trim()===""?(Q=[],Q.slice()):(Q=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),Q.slice())}var Dt="https://smartbox.gtimg.cn/s3/";function hn(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function gn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),s=i[0]||"",r=i[1]||"",o=hn(i[2]||""),l=i[4]||"";return{code:s+r,name:o,market:s,type:l}})}function yn(t){return new Promise((e,n)=>{let i=`${Dt}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let s=document.createElement("script");s.src=i,s.charset="utf-8",s.onload=()=>{let r=window.v_hint||"";document.body.removeChild(s),e(r)},s.onerror=()=>{document.body.removeChild(s),n(new Error("Network error calling Smartbox"))},document.body.appendChild(s)})}async function Cn(t,e){let n=`${Dt}?v=2&t=all&q=${encodeURIComponent(e)}`,s=(await t.get(n)).match(/v_hint="([^"]*)"/);return s?s[1]:""}function Rn(){return typeof window<"u"&&typeof document<"u"}async function vt(t,e){if(!e||!e.trim())return[];let n;return Rn()?n=await yn(e):n=await Cn(t,e),gn(n)}var A={};Ie(A,{getConceptConstituents:()=>Vt,getConceptKline:()=>zt,getConceptList:()=>dt,getConceptMinuteKline:()=>Yt,getConceptSpot:()=>Gt,getDividendDetail:()=>Xt,getHKHistoryKline:()=>qt,getHistoryKline:()=>Nt,getIndustryConstituents:()=>Qt,getIndustryKline:()=>$t,getIndustryList:()=>ft,getIndustryMinuteKline:()=>Wt,getIndustrySpot:()=>jt,getMinuteKline:()=>Ht,getUSHistoryKline:()=>Ft});async function pt(t,e,n,i,s=100,r){let o=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(s),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;l===1&&(a=d.total??0);let m=d.diff.map((g,f)=>r(g,o.length+f+1));o.push(...m),l++}while(o.length<a);return o}function w(t){let[e,n,i,s,r,o,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(i),high:y(s),low:y(r),volume:y(o),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function P(t,e,n){let i=`${e}?${n.toString()}`,s=await t.get(i,{responseType:"json"});return{klines:s?.data?.klines||[],name:s?.data?.name,code:s?.data?.code}}async function Nt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;I(i),E(s);let l=e.replace(/^(sh|sz|bj)/,""),a=`${me(e)}.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(s),secid:a,beg:r,end:o}),c=pe,{klines:p}=await P(t,c,u);return p.length===0?[]:p.map(d=>({...w(d),code:l}))}async function Ht(t,e,n={}){let{period:i="1",adjust:s="qfq",startDate:r="1979-09-01 09:32:00",endDate:o="2222-01-01 09:32:00"}=n;Z(i),E(s);let l=e.replace(/^(sh|sz|bj)/,""),a=`${me(e)}.${l}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:a}),c=`${Be}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=r.replace("T"," ").slice(0,16),g=o.replace("T"," ").slice(0,16);return d.map(f=>{let[C,S,O,L,$,U,j,en]=f.split(",");return{time:C,open:y(S),close:y(O),high:y(L),low:y($),volume:y(U),amount:y(j),avgPrice:y(en)}}).filter(f=>f.time>=m&&f.time<=g)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:x(s||""),secid:a,beg:"0",end:"20500000"}),c=pe,{klines:p}=await P(t,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=o.replace("T"," ").slice(0,16);return p.map(g=>{let f=w(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function qt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;I(i),E(s);let l=e.replace(/^hk/i,"").padStart(5,"0"),a=`116.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(s),secid:a,beg:r,end:o,lmt:"1000000"}),c=De,{klines:p,name:d}=await P(t,c,u);return p.length===0?[]:p.map(m=>({...w(m),code:l,name:d||""}))}async function Ft(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;I(i),E(s);let l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(s),secid:e,beg:r,end:o,lmt:"1000000"}),a=ve,{klines:u,name:c,code:p}=await P(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...w(g),code:d,name:m}))}function Se(t){let e=null;return{async getCode(n,i,s){if(i.startsWith("BK"))return i;if(!e){let o=await s(n);e=new Map(o.map(l=>[l.name,l.code]))}let r=e.get(i);if(!r)throw new Error(`${t.errorPrefix}: ${i}`);return r}}}async function be(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",s=await pt(t,e.listUrl,n,i,100,(r,o)=>({rank:o,name:String(r.f14??""),code:String(r.f12??""),price:b(r.f2),change:b(r.f4),changePercent:b(r.f3),totalMarketCap:b(r.f20),turnoverRate:b(r.f8),riseCount:b(r.f104),fallCount:b(r.f105),leadingStock:r.f128?String(r.f128):null,leadingStockChangePercent:b(r.f136)}));return s.sort((r,o)=>(o.changePercent??0)-(r.changePercent??0)),s.forEach((r,o)=>{r.rank=o+1}),s}async function Te(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),s=`${n}?${i.toString()}`,o=(await t.get(s,{responseType:"json"}))?.data;return o?[{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:a,name:u,divide:c})=>{let p=o[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function Ae(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return pt(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(r,o)=>({rank:o,code:String(r.f12??""),name:String(r.f14??""),price:b(r.f2),changePercent:b(r.f3),change:b(r.f4),volume:b(r.f5),amount:b(r.f6),amplitude:b(r.f7),high:b(r.f15),low:b(r.f16),open:b(r.f17),prevClose:b(r.f18),turnoverRate:b(r.f8),pe:b(r.f9),pb:b(r.f23)}))}async function Oe(t,e,n,i={}){let{period:s="daily",adjust:r="",startDate:o="19700101",endDate:l="20500101"}=i;I(s),E(r);let a=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:K(s),fqt:x(r),beg:o,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await P(t,n,a);return u.length===0?[]:u.map(c=>w(c))}async function Me(t,e,n,i,s={}){let{period:r="5"}=s;if(Z(r),r==="1"){let o=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}`}),l=`${i}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(S),price:y(O)}})}else{let o=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:r,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),l=`${n}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O,L,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(L),change:y($),volume:y(C),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var N={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ne,spotUrl:He,consUrl:qe,klineUrl:Fe,trendsUrl:je,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},Sn=Se(N);async function Ee(t,e){return Sn.getCode(t,e,ft)}async function ft(t){return be(t,N)}async function jt(t,e){let n=await Ee(t,e);return Te(t,n,N.spotUrl)}async function Qt(t,e){let n=await Ee(t,e);return Ae(t,n,N.consUrl)}async function $t(t,e,n={}){let i=await Ee(t,e);return Oe(t,i,N.klineUrl,n)}async function Wt(t,e,n={}){let i=await Ee(t,e);return Me(t,i,N.klineUrl,N.trendsUrl,n)}var H={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Qe,spotUrl:$e,consUrl:We,klineUrl:Ge,trendsUrl:Ve,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},bn=Se(H);async function xe(t,e){return bn.getCode(t,e,dt)}async function dt(t){return be(t,H)}async function Gt(t,e){let n=await xe(t,e);return Te(t,n,H.spotUrl)}async function Vt(t,e){let n=await xe(t,e);return Ae(t,n,H.consUrl)}async function zt(t,e,n={}){let i=await xe(t,e);return Oe(t,i,H.klineUrl,n)}async function Yt(t,e,n={}){let i=await xe(t,e);return Me(t,i,H.klineUrl,H.trendsUrl,n)}function q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Tn(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:q(t.REPORT_DATE),planNoticeDate:q(t.PLAN_NOTICE_DATE),disclosureDate:q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:q(t.EQUITY_RECORD_DATE),exDividendDate:q(t.EX_DIVIDEND_DATE),payDate:q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:q(t.NOTICE_DATE)}}async function Xt(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],s=1,r=1;do{let o=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(s),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${ze}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;s===1&&(r=u.pages??1);let c=u.data.map(Tn);i.push(...c),s++}while(s<=r);return i}function ee(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function k(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let s=0,r=0;for(let o=i-e+1;o<=i;o++)t[o]!==null&&(s+=t[o],r++);n.push(r===e?ee(s/e):null)}return n}function _(t,e){let n=[],i=2/(e+1),s=null,r=!1;for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=o-e+1;c<=o;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(s=a/e,r=!0),n.push(s!==null?ee(s):null);continue}let l=t[o];l===null?n.push(s!==null?ee(s):null):(s=i*l+(1-i)*s,n.push(ee(s)))}return n}function _e(t,e){let n=[],i=Array.from({length:e},(r,o)=>o+1),s=i.reduce((r,o)=>r+o,0);for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let o=0,l=!0;for(let a=0;a<e;a++){let u=t[r-e+1+a];if(u===null){l=!1;break}o+=u*i[a]}n.push(l?ee(o/s):null)}return n}function te(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,s=i==="ema"?_:i==="wma"?_e:k,r={};for(let o of n)r[`ma${o}`]=s(t,o);return t.map((o,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function Jt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ne(t,e={}){let{short:n=12,long:i=26,signal:s=9}=e,r=_(t,n),o=_(t,i),l=t.map((u,c)=>r[c]===null||o[c]===null?null:r[c]-o[c]),a=_(l,s);return t.map((u,c)=>({dif:l[c]!==null?Jt(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?Jt((l[c]-a[c])*2):null}))}function mt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function An(t,e,n){let i=[];for(let s=0;s<t.length;s++){if(s<e-1||n[s]===null){i.push(null);continue}let r=0,o=0;for(let l=s-e+1;l<=s;l++)t[l]!==null&&n[s]!==null&&(r+=Math.pow(t[l]-n[s],2),o++);i.push(o===e?Math.sqrt(r/e):null)}return i}function re(t,e={}){let{period:n=20,stdDev:i=2}=e,s=k(t,n),r=An(t,n,s);return t.map((o,l)=>{if(s[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=s[l]+i*r[l],u=s[l]-i*r[l],c=s[l]!==0?mt((a-u)/s[l]*100):null;return{mid:s[l],upper:mt(a),lower:mt(u),bandwidth:c}})}function ht(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function se(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:s=3}=e,r=[],o=50,l=50;for(let a=0;a<t.length;a++){if(a<n-1){r.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,p=!0;for(let f=a-n+1;f<=a;f++){if(t[f].high===null||t[f].low===null){p=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[a].close;if(!p||d===null||u===c){r.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;o=(i-1)/i*o+1/i*m,l=(s-1)/s*l+1/s*o;let g=3*o-2*l;r.push({k:ht(o),d:ht(l),j:ht(g)})}return r}function On(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ie(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let r=1;r<t.length;r++)t[r]===null||t[r-1]===null?i.push(null):i.push(t[r]-t[r-1]);let s={};for(let r of n){let o=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<r){o.push(null),i[u]!==null&&(i[u]>0?l+=i[u]:a+=Math.abs(i[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=i[u]??0,p=c>0?c:0,d=c<0?Math.abs(c):0;l=(l*(r-1)+p)/r,a=(a*(r-1)+d)/r}if(a===0)o.push(100);else if(l===0)o.push(0);else{let c=l/a;o.push(On(100-100/(1+c)))}}s[`rsi${r}`]=o}return t.map((r,o)=>{let l={};for(let a of n)l[`rsi${a}`]=s[`rsi${a}`][o];return l})}function Mn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function oe(t,e={}){let{periods:n=[6,10]}=e,i={};for(let s of n){let r=[];for(let o=0;o<t.length;o++){if(o<s-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=o-s+1;d<=o;d++){if(t[d].high===null||t[d].low===null){u=!1;break}l=Math.max(l,t[d].high),a=Math.min(a,t[d].low)}let c=t[o].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(Mn(p))}i[`wr${s}`]=r}return t.map((s,r)=>{let o={};for(let l of n)o[`wr${l}`]=i[`wr${l}`][r];return o})}function En(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function le(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let s of n){let r=k(t,s),o=[];for(let l=0;l<t.length;l++)if(t[l]===null||r[l]===null||r[l]===0)o.push(null);else{let a=(t[l]-r[l])/r[l]*100;o.push(En(a))}i[`bias${s}`]=o}return t.map((s,r)=>{let o={};for(let l of n)o[`bias${l}`]=i[`bias${l}`][r];return o})}function xn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ae(t,e={}){let{period:n=14}=e,i=[],s=t.map(r=>r.high===null||r.low===null||r.close===null?null:(r.high+r.low+r.close)/3);for(let r=0;r<t.length;r++){if(r<n-1){i.push({cci:null});continue}let o=0,l=0;for(let p=r-n+1;p<=r;p++)s[p]!==null&&(o+=s[p],l++);if(l!==n||s[r]===null){i.push({cci:null});continue}let a=o/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(s[p]-a);let c=u/n;if(c===0)i.push({cci:0});else{let p=(s[r]-a)/(.015*c);i.push({cci:xn(p)})}}return i}function gt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function F(t,e={}){let{period:n=14}=e,i=[],s=[];for(let o=0;o<t.length;o++){let{high:l,low:a,close:u}=t[o];if(l===null||a===null||u===null){s.push(null);continue}if(o===0)s.push(l-a);else{let c=t[o-1].close;if(c===null)s.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);s.push(Math.max(p,d,m))}}}let r=null;for(let o=0;o<t.length;o++){if(o<n-1){i.push({tr:s[o]!==null?gt(s[o]):null,atr:null});continue}if(o===n-1){let l=0,a=0;for(let u=0;u<n;u++)s[u]!==null&&(l+=s[u],a++);a===n&&(r=l/n)}else r!==null&&s[o]!==null&&(r=(r*(n-1)+s[o])/n);i.push({tr:s[o]!==null?gt(s[o]):null,atr:r!==null?gt(r):null})}return i}function yt(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let s=t[0].volume??0;i.push({obv:s,obvMa:null});for(let r=1;r<t.length;r++){let o=t[r],l=t[r-1];if(o.close===null||l.close===null||o.volume===null||o.volume===void 0){i.push({obv:null,obvMa:null});continue}o.close>l.close?s+=o.volume:o.close<l.close&&(s-=o.volume),i.push({obv:s,obvMa:null})}if(n&&n>0)for(let r=n-1;r<i.length;r++){let o=0,l=0;for(let a=r-n+1;a<=r;a++)i[a].obv!==null&&(o+=i[a].obv,l++);l===n&&(i[r].obvMa=o/n)}return i}function Ct(t,e={}){let{period:n=12,signalPeriod:i}=e,s=[];for(let r=0;r<t.length;r++){if(r<n){s.push({roc:null,signal:null});continue}let o=t[r].close,l=t[r-n].close;if(o===null||l===null||l===0){s.push({roc:null,signal:null});continue}let a=(o-l)/l*100;s.push({roc:a,signal:null})}if(i&&i>0)for(let r=n+i-1;r<s.length;r++){let o=0,l=0;for(let a=r-i+1;a<=r;a++)s[a].roc!==null&&(o+=s[a].roc,l++);l===i&&(s[r].signal=o/i)}return s}function Rt(t,e={}){let{period:n=14,adxPeriod:i=n}=e,s=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],o=[],l=[];for(let f=0;f<t.length;f++){if(f===0){r.push(0),o.push(0),l.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],S=t[f-1];if(C.high===null||C.low===null||C.close===null||S.high===null||S.low===null||S.close===null){r.push(0),o.push(0),l.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=C.high-C.low,L=Math.abs(C.high-S.close),$=Math.abs(C.low-S.close);l.push(Math.max(O,L,$));let U=C.high-S.high,j=S.low-C.low;U>j&&U>0?r.push(U):r.push(0),j>U&&j>0?o.push(j):o.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<t.length;f++){if(f<n){a+=l[f],u+=r[f],c+=o[f],p.push(0);continue}f===n?(a=a,u=u,c=c):(a=a-a/n+l[f],u=u-u/n+r[f],c=c-c/n+o[f]);let C=a>0?u/a*100:0,S=a>0?c/a*100:0;s[f].pdi=C,s[f].mdi=S;let O=C+S,L=O>0?Math.abs(C-S)/O*100:0;p.push(L)}let d=0,m=0,g=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=p[f-n+1]||0,m++;continue}if(f===n*2-1)d+=p[f-n+1]||0,g=d/i,s[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(i-1)+C)/i,s[f].adx=g}}for(let f=n*2-1+i;f<t.length;f++){let C=s[f].adx,S=s[f-i]?.adx;C!==null&&S!==null&&(s[f].adxr=(C+S)/2)}return s}function St(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:s=.2}=e,r=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,l=n,a=t[0].high??0,u=t[0].low??0,c=t[0],p=t[1];c.close!==null&&p.close!==null&&p.close<c.close&&(o=-1,a=c.low??0,u=c.high??0),r.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let m=t[d],g=t[d-1];if(m.high===null||m.low===null||g.high===null||g.low===null){r.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+l*(a-u);o===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(o=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+i,s))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(o=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+i,s))),u=f,r.push({sar:u,trend:o,ep:a,af:l})}return r}function bt(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:s=2}=e,r=[],o=t.map(u=>u.close),l=_(o,n),a=F(t,{period:i});for(let u=0;u<t.length;u++){let c=l[u],p=a[u]?.atr;if(c===null||p===null){r.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+s*p,m=c-s*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function ue(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),i=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),s=e.ma?te(n,typeof e.ma=="object"?e.ma:{}):null,r=e.macd?ne(n,typeof e.macd=="object"?e.macd:{}):null,o=e.boll?re(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?se(i,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?ie(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?oe(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?le(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?ae(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?F(i,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...s&&{ma:s[g]},...r&&{macd:r[g]},...o&&{boll:o[g]},...l&&{kdj:l[g]},...a&&{rsi:a[g]},...u&&{wr:u[g]},...c&&{bias:c[g]},...p&&{cci:p[g]},...d&&{atr:d[g]}}))}var ce=class{constructor(e={}){this.client=new J(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return A.getIndustryList(this.client)}getIndustrySpot(e){return A.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return A.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return A.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return A.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return A.getConceptList(this.client)}getConceptSpot(e){return A.getConceptSpot(this.client,e)}getConceptConstituents(e){return A.getConceptConstituents(this.client,e)}getConceptKline(e,n){return A.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return A.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return A.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return A.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return A.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return A.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,s=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(s,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,s=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,s,i)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return A.getDividendDetail(this.client,e)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let r=typeof e.ma=="object"?e.ma:{},o=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(o,20)),l==="ema"&&(i=!0)}if(e.macd){let r=typeof e.macd=="object"?e.macd:{},o=r.long??26,l=r.signal??9;n=Math.max(n,o*3+l),i=!0}if(e.boll){let r=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,r)}if(e.kdj){let r=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,r)}if(e.rsi){let r=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(r,14)+1)}if(e.wr){let r=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(r,10))}if(e.bias){let r=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(r,12))}if(e.cci){let r=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,r)}if(e.atr){let r=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,r)}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let s=Math.ceil(n*i),r=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));r.setDate(r.getDate()-s);let o=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${o}${l}${a}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let s=this.normalizeDate(e),r=i.findIndex(l=>l>=s);r===-1&&(r=i.length-1);let o=Math.max(0,r-n);return this.toCompactDate(i[o])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:s,indicators:r={}}=n,o=n.market??this.detectMarket(e),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(i)if(o==="A")try{let m=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,l,m)??this.calcActualStartDate(i,l,a[o])}catch{u=this.calcActualStartDate(i,l,a[o])}else u=this.calcActualStartDate(i,l,a[o]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(o){case"HK":p=await this.getHKHistoryKline(e,c);break;case"US":p=await this.getUSHistoryKline(e,c);break;default:p=await this.getHistoryKline(e,c)}if(i&&p.length<l)switch(o){case"HK":p=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=ue(p,r);if(i){let m=this.dateToTimestamp(i),g=s?this.dateToTimestamp(s):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},Zt=ce;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,parseResponse,safeNumber,safeNumberOrNull});
|
|
1
|
+
"use strict";var Le=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var ln=Object.prototype.hasOwnProperty;var Ie=(t,e)=>{for(var n in e)Le(t,n,{get:e[n],enumerable:!0})},an=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of on(e))!ln.call(t,r)&&r!==n&&Le(t,r,{get:()=>e[r],enumerable:!(i=sn(e,r))||i.enumerable});return t};var un=t=>an(Le({},"__esModule",{value:!0}),t);var Kn={};Ie(Kn,{HttpError:()=>D,StockSDK:()=>ce,addIndicators:()=>ue,asyncPool:()=>v,calcATR:()=>F,calcBIAS:()=>le,calcBOLL:()=>re,calcCCI:()=>ae,calcDMI:()=>bt,calcEMA:()=>E,calcKC:()=>At,calcKDJ:()=>se,calcMA:()=>te,calcMACD:()=>ne,calcOBV:()=>Rt,calcROC:()=>St,calcRSI:()=>ie,calcSAR:()=>Tt,calcSMA:()=>k,calcWMA:()=>Ee,calcWR:()=>oe,chunkArray:()=>B,decodeGBK:()=>W,default:()=>nn,parseResponse:()=>G,safeNumber:()=>h,safeNumberOrNull:()=>R});module.exports=un(Kn);function W(t){return new TextDecoder("gbk").decode(t)}function G(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let r=i.indexOf("=");if(r<0)continue;let s=i.slice(0,r).trim();s.startsWith("v_")&&(s=s.slice(2));let o=i.slice(r+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));let l=o.split("~");n.push({key:s,fields:l})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function R(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function y(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function b(t){return t==null?null:y(String(t))}var Ke="https://qt.gtimg.cn",we="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Pe="https://assets.linkdiary.cn/shares/zh_a_list.json",Ue="https://assets.linkdiary.cn/shares/us_list.json",ke="https://assets.linkdiary.cn/shares/hk_list.json",De="https://assets.linkdiary.cn/shares/fund_list",Ot="https://assets.linkdiary.cn/shares/trade-data-list.txt";var pe="https://push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ve="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Ne="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",He="https://17.push2.eastmoney.com/api/qt/clist/get",qe="https://91.push2.eastmoney.com/api/qt/stock/get",Fe="https://29.push2.eastmoney.com/api/qt/clist/get",je="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Qe="https://push2his.eastmoney.com/api/qt/stock/trends2/get",$e="https://79.push2.eastmoney.com/api/qt/clist/get",We="https://91.push2.eastmoney.com/api/qt/stock/get",Ge="https://29.push2.eastmoney.com/api/qt/clist/get",Ve="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",ze="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ye="https://datacenter-web.eastmoney.com/api/data/v1/get",Xe=3e4,V=500,z=500,Y=7,Je=3,Ze=1e3,et=3e4,tt=2,nt=[408,429,500,502,503,504];var fe=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Mt=["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"],rt=0;function cn(){return typeof window<"u"&&typeof window.document<"u"}function _t(){if(cn())return;let t=Mt[rt];return rt=(rt+1)%Mt.length,t}var X=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},de=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 X;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 D=class extends Error{constructor(n,i,r,s){let o=i?` ${i}`:"",l=r?`, url: ${r}`:"",a=s?`, provider: ${s}`:"";super(`HTTP error! status: ${n}${o}${l}${a}`);this.status=n;this.statusText=i;this.url=r;this.provider=s;this.name="HttpError"}},J=class{constructor(e={}){this.baseUrl=e.baseUrl??Ke,this.timeout=e.timeout??Xe,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new fe(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new de(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(i=>i.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Je,baseDelay:e?.baseDelay??Ze,maxDelay:e?.maxDelay??et,backoffMultiplier:e?.backoffMultiplier??tt,retryableStatusCodes:e?.retryableStatusCodes??nt,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof D?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let i=await e();return this.circuitBreaker?.recordSuccess(),i}catch(i){if(this.shouldRetry(i,n)){let r=this.calculateDelay(n);return this.retryOptions.onRetry&&i instanceof Error&&this.retryOptions.onRetry(n+1,i,r),await this.sleep(r),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),i}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new X("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let i=new AbortController,r=setTimeout(()=>i.abort(),this.timeout),s=this.inferProvider(e),o={...this.headers};if(this.rotateUserAgent){let l=_t();l&&(o["User-Agent"]=l)}try{let l=await fetch(e,{signal:i.signal,headers:o});if(!l.ok)throw new D(l.status,l.statusText,e,s);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=s),l}finally{clearTimeout(r)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer"}),r=W(i);return G(r)}};var pn=new Set(["daily","weekly","monthly"]),fn=new Set(["1","5","15","30","60"]),dn=new Set(["","qfq","hfq"]);function M(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function I(t){if(!pn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function Z(t){if(!fn.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function _(t){if(!dn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function B(t,e){M(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function v(t,e){M(e,"concurrency");let n=[],i=[];for(let r of t){let s=Promise.resolve().then(()=>r()).then(o=>{n.push(o)});if(i.push(s),i.length>=e){await Promise.race(i);for(let o=i.length-1;o>=0;o--)await Promise.race([i[o].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&i.splice(o,1)}}return await Promise.all(i),n}function me(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function K(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function x(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var T={};Ie(T,{getAShareCodeList:()=>wt,getAllHKQuotesByCodes:()=>Dt,getAllQuotesByCodes:()=>kt,getAllUSQuotesByCodes:()=>Bt,getFullQuotes:()=>he,getFundCodeList:()=>vt,getFundFlow:()=>Et,getFundQuotes:()=>It,getHKCodeList:()=>Ut,getHKQuotes:()=>ge,getPanelLargeOrder:()=>Lt,getSimpleQuotes:()=>xt,getTodayTimeline:()=>Kt,getTradingCalendar:()=>Nt,getUSCodeList:()=>Pt,getUSQuotes:()=>ye,parseFullQuote:()=>st,parseFundFlow:()=>ot,parseFundQuote:()=>ct,parseHKQuote:()=>at,parsePanelLargeOrder:()=>lt,parseSimpleQuote:()=>it,parseUSQuote:()=>ut,search:()=>qt});function st(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),pb:R(t[46]),limitUp:R(t[47]),limitDown:R(t[48]),volumeRatio:R(t[49]),avgPrice:R(t[51]),peStatic:R(t[52]),peDynamic:R(t[53]),high52w:R(t[67]),low52w:R(t[68]),circulatingShares:R(t[72]),totalShares:R(t[73]),raw:t}}function it(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:R(t[9]),marketType:t[10]??"",raw:t}}function ot(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function lt(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function at(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:R(t[40]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),currency:t[t.length-3]??"",raw:t}}function ut(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),totalMarketCap:R(t[45]),pb:R(t[47]),high52w:R(t[48]),low52w:R(t[49]),raw:t}}function ct(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function he(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>st(i.fields))}async function xt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>it(r.fields))}async function Et(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ot(r.fields))}async function Lt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>lt(r.fields))}async function ge(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>at(r.fields))}async function ye(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ut(r.fields))}async function It(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ct(r.fields))}async function Kt(t,e){let n=t.getTimeout(),i=new AbortController,r=setTimeout(()=>i.abort(),n);try{let s=await fetch(`${we}?code=${e}`,{signal:i.signal});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);let o=await s.json();if(o.code!==0)throw new Error(o.msg||"API error");let l=o.data?.[e];if(!l)return{code:e,date:"",data:[]};let a=l.data?.data||[],u=l.data?.date||"",c=!1;if(a.length>0){let d=a[0].split(" "),m=parseFloat(d[1])||0,g=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;g>0&&m>0&&f/g>m*50&&(c=!0)}let p=a.map(d=>{let m=d.split(" "),g=m[0],f=`${g.slice(0,2)}:${g.slice(2,4)}`,C=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?C*100:C,L=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(L*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(r)}}var pt=null,mn=null,Ce=null,hn=null,Re=null,ft=null;function gn(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 wt(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!pt){let o=(await t.get(Pe,{responseType:"json"}))?.list||[];pt=o,mn=o.map(l=>l.replace(/^(sh|sz|bj)/,""))}let r=pt;return i&&(r=r.filter(s=>gn(s,i))),n?r.map(s=>s.replace(/^(sh|sz|bj)/,"")):r.slice()}var yn={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Pt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),Ce||(Ce=(await t.get(Ue,{responseType:"json"}))?.list||[],hn=Ce.map(o=>o.replace(/^\d{3}\./,"")));let r=Ce.slice();if(i){let s=yn[i];r=r.filter(o=>o.startsWith(s))}return n?r.map(s=>s.replace(/^\d{3}\./,"")):r}async function Ut(t){return Re||(Re=(await t.get(ke,{responseType:"json"}))?.list||[]),Re.slice()}async function kt(t,e,n={}){let{batchSize:i=V,concurrency:r=Y,onProgress:s}=n;M(i,"batchSize"),M(r,"concurrency");let o=Math.min(i,z),l=B(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await he(t,d);return u++,s&&s(u,a),m});return(await v(c,r)).flat()}async function Dt(t,e,n={}){let{batchSize:i=V,concurrency:r=Y,onProgress:s}=n;M(i,"batchSize"),M(r,"concurrency");let o=Math.min(i,z),l=B(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ge(t,d);return u++,s&&s(u,a),m});return(await v(c,r)).flat()}async function Bt(t,e,n={}){let{batchSize:i=V,concurrency:r=Y,onProgress:s}=n;M(i,"batchSize"),M(r,"concurrency");let o=Math.min(i,z),l=B(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ye(t,d);return u++,s&&s(u,a),m});return(await v(c,r)).flat()}async function vt(t){if(ft)return ft.slice();let i=(await t.get(De,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return ft=i,i.slice()}var Q=null;async function Nt(t){if(Q)return Q.slice();let e=await t.get(Ot);return!e||e.trim()===""?(Q=[],Q.slice()):(Q=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),Q.slice())}var Ht="https://smartbox.gtimg.cn/s3/";function Cn(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function Rn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),r=i[0]||"",s=i[1]||"",o=Cn(i[2]||""),l=i[4]||"";return{code:r+s,name:o,market:r,type:l}})}function Sn(t){return new Promise((e,n)=>{let i=`${Ht}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=i,r.charset="utf-8",r.onload=()=>{let s=window.v_hint||"";document.body.removeChild(r),e(s)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function bn(t,e){let n=`${Ht}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function Tn(){return typeof window<"u"&&typeof document<"u"}async function qt(t,e){if(!e||!e.trim())return[];let n;return Tn()?n=await Sn(e):n=await bn(t,e),Rn(n)}var A={};Ie(A,{getConceptConstituents:()=>Xt,getConceptKline:()=>Jt,getConceptList:()=>ht,getConceptMinuteKline:()=>Zt,getConceptSpot:()=>Yt,getDividendDetail:()=>en,getHKHistoryKline:()=>Qt,getHistoryKline:()=>Ft,getIndustryConstituents:()=>Gt,getIndustryKline:()=>Vt,getIndustryList:()=>mt,getIndustryMinuteKline:()=>zt,getIndustrySpot:()=>Wt,getMinuteKline:()=>jt,getUSHistoryKline:()=>$t});async function dt(t,e,n,i,r=100,s){let o=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(r),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;l===1&&(a=d.total??0);let m=d.diff.map((g,f)=>s(g,o.length+f+1));o.push(...m),l++}while(o.length<a);return o}function w(t){let[e,n,i,r,s,o,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(i),high:y(r),low:y(s),volume:y(o),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function P(t,e,n){let i=`${e}?${n.toString()}`,r=await t.get(i,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function Ft(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:s="19700101",endDate:o="20500101"}=n;I(i),_(r);let l=e.replace(/^(sh|sz|bj)/,""),a=`${me(e)}.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(r),secid:a,beg:s,end:o}),c=pe,{klines:p}=await P(t,c,u);return p.length===0?[]:p.map(d=>({...w(d),code:l}))}async function jt(t,e,n={}){let{period:i="1",adjust:r="qfq",startDate:s="1979-09-01 09:32:00",endDate:o="2222-01-01 09:32:00"}=n;Z(i),_(r);let l=e.replace(/^(sh|sz|bj)/,""),a=`${me(e)}.${l}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:a}),c=`${Be}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=s.replace("T"," ").slice(0,16),g=o.replace("T"," ").slice(0,16);return d.map(f=>{let[C,S,O,L,$,U,j,rn]=f.split(",");return{time:C,open:y(S),close:y(O),high:y(L),low:y($),volume:y(U),amount:y(j),avgPrice:y(rn)}}).filter(f=>f.time>=m&&f.time<=g)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:x(r||""),secid:a,beg:"0",end:"20500000"}),c=pe,{klines:p}=await P(t,c,u);if(p.length===0)return[];let d=s.replace("T"," ").slice(0,16),m=o.replace("T"," ").slice(0,16);return p.map(g=>{let f=w(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function Qt(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:s="19700101",endDate:o="20500101"}=n;I(i),_(r);let l=e.replace(/^hk/i,"").padStart(5,"0"),a=`116.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(r),secid:a,beg:s,end:o,lmt:"1000000"}),c=ve,{klines:p,name:d}=await P(t,c,u);return p.length===0?[]:p.map(m=>({...w(m),code:l,name:d||""}))}async function $t(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:s="19700101",endDate:o="20500101"}=n;I(i),_(r);let l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(r),secid:e,beg:s,end:o,lmt:"1000000"}),a=Ne,{klines:u,name:c,code:p}=await P(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...w(g),code:d,name:m}))}function Se(t){let e=null;return{async getCode(n,i,r){if(i.startsWith("BK"))return i;if(!e){let o=await r(n);e=new Map(o.map(l=>[l.name,l.code]))}let s=e.get(i);if(!s)throw new Error(`${t.errorPrefix}: ${i}`);return s}}}async function be(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await dt(t,e.listUrl,n,i,100,(s,o)=>({rank:o,name:String(s.f14??""),code:String(s.f12??""),price:b(s.f2),change:b(s.f4),changePercent:b(s.f3),totalMarketCap:b(s.f20),turnoverRate:b(s.f8),riseCount:b(s.f104),fallCount:b(s.f105),leadingStock:s.f128?String(s.f128):null,leadingStockChangePercent:b(s.f136)}));return r.sort((s,o)=>(o.changePercent??0)-(s.changePercent??0)),r.forEach((s,o)=>{s.rank=o+1}),r}async function Te(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${i.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data;return o?[{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:a,name:u,divide:c})=>{let p=o[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function Ae(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return dt(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(s,o)=>({rank:o,code:String(s.f12??""),name:String(s.f14??""),price:b(s.f2),changePercent:b(s.f3),change:b(s.f4),volume:b(s.f5),amount:b(s.f6),amplitude:b(s.f7),high:b(s.f15),low:b(s.f16),open:b(s.f17),prevClose:b(s.f18),turnoverRate:b(s.f8),pe:b(s.f9),pb:b(s.f23)}))}async function Oe(t,e,n,i={}){let{period:r="daily",adjust:s="",startDate:o="19700101",endDate:l="20500101"}=i;I(r),_(s);let a=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:K(r),fqt:x(s),beg:o,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await P(t,n,a);return u.length===0?[]:u.map(c=>w(c))}async function Me(t,e,n,i,r={}){let{period:s="5"}=r;if(Z(s),s==="1"){let o=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}`}),l=`${i}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(S),price:y(O)}})}else{let o=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:s,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),l=`${n}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O,L,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(L),change:y($),volume:y(C),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var N={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:He,spotUrl:qe,consUrl:Fe,klineUrl:je,trendsUrl:Qe,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},An=Se(N);async function _e(t,e){return An.getCode(t,e,mt)}async function mt(t){return be(t,N)}async function Wt(t,e){let n=await _e(t,e);return Te(t,n,N.spotUrl)}async function Gt(t,e){let n=await _e(t,e);return Ae(t,n,N.consUrl)}async function Vt(t,e,n={}){let i=await _e(t,e);return Oe(t,i,N.klineUrl,n)}async function zt(t,e,n={}){let i=await _e(t,e);return Me(t,i,N.klineUrl,N.trendsUrl,n)}var H={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:$e,spotUrl:We,consUrl:Ge,klineUrl:Ve,trendsUrl:ze,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},On=Se(H);async function xe(t,e){return On.getCode(t,e,ht)}async function ht(t){return be(t,H)}async function Yt(t,e){let n=await xe(t,e);return Te(t,n,H.spotUrl)}async function Xt(t,e){let n=await xe(t,e);return Ae(t,n,H.consUrl)}async function Jt(t,e,n={}){let i=await xe(t,e);return Oe(t,i,H.klineUrl,n)}async function Zt(t,e,n={}){let i=await xe(t,e);return Me(t,i,H.klineUrl,H.trendsUrl,n)}function q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Mn(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:q(t.REPORT_DATE),planNoticeDate:q(t.PLAN_NOTICE_DATE),disclosureDate:q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:q(t.EQUITY_RECORD_DATE),exDividendDate:q(t.EX_DIVIDEND_DATE),payDate:q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:q(t.NOTICE_DATE)}}async function en(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],r=1,s=1;do{let o=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${Ye}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(s=u.pages??1);let c=u.data.map(Mn);i.push(...c),r++}while(r<=s);return i}function ee(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function k(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let r=0,s=0;for(let o=i-e+1;o<=i;o++)t[o]!==null&&(r+=t[o],s++);n.push(s===e?ee(r/e):null)}return n}function E(t,e){let n=[],i=2/(e+1),r=null,s=!1;for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}if(!s){let a=0,u=0;for(let c=o-e+1;c<=o;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(r=a/e,s=!0),n.push(r!==null?ee(r):null);continue}let l=t[o];l===null?n.push(r!==null?ee(r):null):(r=i*l+(1-i)*r,n.push(ee(r)))}return n}function Ee(t,e){let n=[],i=Array.from({length:e},(s,o)=>o+1),r=i.reduce((s,o)=>s+o,0);for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let o=0,l=!0;for(let a=0;a<e;a++){let u=t[s-e+1+a];if(u===null){l=!1;break}o+=u*i[a]}n.push(l?ee(o/r):null)}return n}function te(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,r=i==="ema"?E:i==="wma"?Ee:k,s={};for(let o of n)s[`ma${o}`]=r(t,o);return t.map((o,l)=>{let a={};for(let u of n)a[`ma${u}`]=s[`ma${u}`][l];return a})}function tn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ne(t,e={}){let{short:n=12,long:i=26,signal:r=9}=e,s=E(t,n),o=E(t,i),l=t.map((u,c)=>s[c]===null||o[c]===null?null:s[c]-o[c]),a=E(l,r);return t.map((u,c)=>({dif:l[c]!==null?tn(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?tn((l[c]-a[c])*2):null}))}function gt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function _n(t,e,n){let i=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){i.push(null);continue}let s=0,o=0;for(let l=r-e+1;l<=r;l++)t[l]!==null&&n[r]!==null&&(s+=Math.pow(t[l]-n[r],2),o++);i.push(o===e?Math.sqrt(s/e):null)}return i}function re(t,e={}){let{period:n=20,stdDev:i=2}=e,r=k(t,n),s=_n(t,n,r);return t.map((o,l)=>{if(r[l]===null||s[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=r[l]+i*s[l],u=r[l]-i*s[l],c=r[l]!==0?gt((a-u)/r[l]*100):null;return{mid:r[l],upper:gt(a),lower:gt(u),bandwidth:c}})}function yt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function se(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:r=3}=e,s=[],o=50,l=50;for(let a=0;a<t.length;a++){if(a<n-1){s.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,p=!0;for(let f=a-n+1;f<=a;f++){if(t[f].high===null||t[f].low===null){p=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[a].close;if(!p||d===null||u===c){s.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;o=(i-1)/i*o+1/i*m,l=(r-1)/r*l+1/r*o;let g=3*o-2*l;s.push({k:yt(o),d:yt(l),j:yt(g)})}return s}function xn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ie(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let s=1;s<t.length;s++)t[s]===null||t[s-1]===null?i.push(null):i.push(t[s]-t[s-1]);let r={};for(let s of n){let o=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<s){o.push(null),i[u]!==null&&(i[u]>0?l+=i[u]:a+=Math.abs(i[u]));continue}if(u===s)l=l/s,a=a/s;else{let c=i[u]??0,p=c>0?c:0,d=c<0?Math.abs(c):0;l=(l*(s-1)+p)/s,a=(a*(s-1)+d)/s}if(a===0)o.push(100);else if(l===0)o.push(0);else{let c=l/a;o.push(xn(100-100/(1+c)))}}r[`rsi${s}`]=o}return t.map((s,o)=>{let l={};for(let a of n)l[`rsi${a}`]=r[`rsi${a}`][o];return l})}function En(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function oe(t,e={}){let{periods:n=[6,10]}=e,i={};for(let r of n){let s=[];for(let o=0;o<t.length;o++){if(o<r-1){s.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=o-r+1;d<=o;d++){if(t[d].high===null||t[d].low===null){u=!1;break}l=Math.max(l,t[d].high),a=Math.min(a,t[d].low)}let c=t[o].close;if(!u||c===null||l===a){s.push(null);continue}let p=(l-c)/(l-a)*100;s.push(En(p))}i[`wr${r}`]=s}return t.map((r,s)=>{let o={};for(let l of n)o[`wr${l}`]=i[`wr${l}`][s];return o})}function Ln(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function le(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let r of n){let s=k(t,r),o=[];for(let l=0;l<t.length;l++)if(t[l]===null||s[l]===null||s[l]===0)o.push(null);else{let a=(t[l]-s[l])/s[l]*100;o.push(Ln(a))}i[`bias${r}`]=o}return t.map((r,s)=>{let o={};for(let l of n)o[`bias${l}`]=i[`bias${l}`][s];return o})}function In(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ae(t,e={}){let{period:n=14}=e,i=[],r=t.map(s=>s.high===null||s.low===null||s.close===null?null:(s.high+s.low+s.close)/3);for(let s=0;s<t.length;s++){if(s<n-1){i.push({cci:null});continue}let o=0,l=0;for(let p=s-n+1;p<=s;p++)r[p]!==null&&(o+=r[p],l++);if(l!==n||r[s]===null){i.push({cci:null});continue}let a=o/n,u=0;for(let p=s-n+1;p<=s;p++)u+=Math.abs(r[p]-a);let c=u/n;if(c===0)i.push({cci:0});else{let p=(r[s]-a)/(.015*c);i.push({cci:In(p)})}}return i}function Ct(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function F(t,e={}){let{period:n=14}=e,i=[],r=[];for(let o=0;o<t.length;o++){let{high:l,low:a,close:u}=t[o];if(l===null||a===null||u===null){r.push(null);continue}if(o===0)r.push(l-a);else{let c=t[o-1].close;if(c===null)r.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);r.push(Math.max(p,d,m))}}}let s=null;for(let o=0;o<t.length;o++){if(o<n-1){i.push({tr:r[o]!==null?Ct(r[o]):null,atr:null});continue}if(o===n-1){let l=0,a=0;for(let u=0;u<n;u++)r[u]!==null&&(l+=r[u],a++);a===n&&(s=l/n)}else s!==null&&r[o]!==null&&(s=(s*(n-1)+r[o])/n);i.push({tr:r[o]!==null?Ct(r[o]):null,atr:s!==null?Ct(s):null})}return i}function Rt(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let r=t[0].volume??0;i.push({obv:r,obvMa:null});for(let s=1;s<t.length;s++){let o=t[s],l=t[s-1];if(o.close===null||l.close===null||o.volume===null||o.volume===void 0){i.push({obv:null,obvMa:null});continue}o.close>l.close?r+=o.volume:o.close<l.close&&(r-=o.volume),i.push({obv:r,obvMa:null})}if(n&&n>0)for(let s=n-1;s<i.length;s++){let o=0,l=0;for(let a=s-n+1;a<=s;a++)i[a].obv!==null&&(o+=i[a].obv,l++);l===n&&(i[s].obvMa=o/n)}return i}function St(t,e={}){let{period:n=12,signalPeriod:i}=e,r=[];for(let s=0;s<t.length;s++){if(s<n){r.push({roc:null,signal:null});continue}let o=t[s].close,l=t[s-n].close;if(o===null||l===null||l===0){r.push({roc:null,signal:null});continue}let a=(o-l)/l*100;r.push({roc:a,signal:null})}if(i&&i>0)for(let s=n+i-1;s<r.length;s++){let o=0,l=0;for(let a=s-i+1;a<=s;a++)r[a].roc!==null&&(o+=r[a].roc,l++);l===i&&(r[s].signal=o/i)}return r}function bt(t,e={}){let{period:n=14,adxPeriod:i=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let s=[],o=[],l=[];for(let f=0;f<t.length;f++){if(f===0){s.push(0),o.push(0),l.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],S=t[f-1];if(C.high===null||C.low===null||C.close===null||S.high===null||S.low===null||S.close===null){s.push(0),o.push(0),l.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=C.high-C.low,L=Math.abs(C.high-S.close),$=Math.abs(C.low-S.close);l.push(Math.max(O,L,$));let U=C.high-S.high,j=S.low-C.low;U>j&&U>0?s.push(U):s.push(0),j>U&&j>0?o.push(j):o.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<t.length;f++){if(f<n){a+=l[f],u+=s[f],c+=o[f],p.push(0);continue}f===n?(a=a,u=u,c=c):(a=a-a/n+l[f],u=u-u/n+s[f],c=c-c/n+o[f]);let C=a>0?u/a*100:0,S=a>0?c/a*100:0;r[f].pdi=C,r[f].mdi=S;let O=C+S,L=O>0?Math.abs(C-S)/O*100:0;p.push(L)}let d=0,m=0,g=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=p[f-n+1]||0,m++;continue}if(f===n*2-1)d+=p[f-n+1]||0,g=d/i,r[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(i-1)+C)/i,r[f].adx=g}}for(let f=n*2-1+i;f<t.length;f++){let C=r[f].adx,S=r[f-i]?.adx;C!==null&&S!==null&&(r[f].adxr=(C+S)/2)}return r}function Tt(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:r=.2}=e,s=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,l=n,a=t[0].high??0,u=t[0].low??0,c=t[0],p=t[1];c.close!==null&&p.close!==null&&p.close<c.close&&(o=-1,a=c.low??0,u=c.high??0),s.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let m=t[d],g=t[d-1];if(m.high===null||m.low===null||g.high===null||g.low===null){s.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+l*(a-u);o===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(o=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+i,r))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(o=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+i,r))),u=f,s.push({sar:u,trend:o,ep:a,af:l})}return s}function At(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:r=2}=e,s=[],o=t.map(u=>u.close),l=E(o,n),a=F(t,{period:i});for(let u=0;u<t.length;u++){let c=l[u],p=a[u]?.atr;if(c===null||p===null){s.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*p,m=c-r*p,g=c>0?(d-m)/c*100:null;s.push({mid:c,upper:d,lower:m,width:g})}return s}function ue(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),i=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),r=e.ma?te(n,typeof e.ma=="object"?e.ma:{}):null,s=e.macd?ne(n,typeof e.macd=="object"?e.macd:{}):null,o=e.boll?re(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?se(i,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?ie(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?oe(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?le(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?ae(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?F(i,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...r&&{ma:r[g]},...s&&{macd:s[g]},...o&&{boll:o[g]},...l&&{kdj:l[g]},...a&&{rsi:a[g]},...u&&{wr:u[g]},...c&&{bias:c[g]},...p&&{cci:p[g]},...d&&{atr:d[g]}}))}var ce=class{constructor(e={}){this.client=new J(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return A.getIndustryList(this.client)}getIndustrySpot(e){return A.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return A.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return A.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return A.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return A.getConceptList(this.client)}getConceptSpot(e){return A.getConceptSpot(this.client,e)}getConceptConstituents(e){return A.getConceptConstituents(this.client,e)}getConceptKline(e,n){return A.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return A.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return A.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return A.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return A.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return A.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}getFundCodeList(){return T.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,r=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,r,i)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return A.getDividendDetail(this.client,e)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let s=typeof e.ma=="object"?e.ma:{},o=s.periods??[5,10,20,30,60,120,250],l=s.type??"sma";n=Math.max(n,this.safeMax(o,20)),l==="ema"&&(i=!0)}if(e.macd){let s=typeof e.macd=="object"?e.macd:{},o=s.long??26,l=s.signal??9;n=Math.max(n,o*3+l),i=!0}if(e.boll){let s=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,s)}if(e.kdj){let s=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,s)}if(e.rsi){let s=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(s,14)+1)}if(e.wr){let s=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(s,10))}if(e.bias){let s=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(s,12))}if(e.cci){let s=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,s)}if(e.atr){let s=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,s)}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let r=Math.ceil(n*i),s=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));s.setDate(s.getDate()-r);let o=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");return`${o}${l}${a}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let r=this.normalizeDate(e),s=i.findIndex(l=>l>=r);s===-1&&(s=i.length-1);let o=Math.max(0,s-n);return this.toCompactDate(i[o])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:r,indicators:s={}}=n,o=n.market??this.detectMarket(e),l=this.calcRequiredLookback(s),a={A:1.5,HK:1.46,US:1.45},u;if(i)if(o==="A")try{let m=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,l,m)??this.calcActualStartDate(i,l,a[o])}catch{u=this.calcActualStartDate(i,l,a[o])}else u=this.calcActualStartDate(i,l,a[o]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(o){case"HK":p=await this.getHKHistoryKline(e,c);break;case"US":p=await this.getUSHistoryKline(e,c);break;default:p=await this.getHistoryKline(e,c)}if(i&&p.length<l)switch(o){case"HK":p=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=ue(p,s);if(i){let m=this.dateToTimestamp(i),g=r?this.dateToTimestamp(r):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},nn=ce;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,parseResponse,safeNumber,safeNumberOrNull});
|
package/dist/index.d.cts
CHANGED
|
@@ -1618,6 +1618,15 @@ declare class StockSDK {
|
|
|
1618
1618
|
* 从远程获取港股代码列表
|
|
1619
1619
|
*/
|
|
1620
1620
|
getHKCodeList(): Promise<string[]>;
|
|
1621
|
+
/**
|
|
1622
|
+
* 从远程获取基金代码列表
|
|
1623
|
+
* @returns 基金代码数组(6 位代码)
|
|
1624
|
+
*
|
|
1625
|
+
* @example
|
|
1626
|
+
* const codes = await sdk.getFundCodeList();
|
|
1627
|
+
* console.log(codes.length); // 26068
|
|
1628
|
+
*/
|
|
1629
|
+
getFundCodeList(): Promise<string[]>;
|
|
1621
1630
|
/**
|
|
1622
1631
|
* 获取全部 A 股实时行情
|
|
1623
1632
|
* @param options 配置选项
|
package/dist/index.d.ts
CHANGED
|
@@ -1618,6 +1618,15 @@ declare class StockSDK {
|
|
|
1618
1618
|
* 从远程获取港股代码列表
|
|
1619
1619
|
*/
|
|
1620
1620
|
getHKCodeList(): Promise<string[]>;
|
|
1621
|
+
/**
|
|
1622
|
+
* 从远程获取基金代码列表
|
|
1623
|
+
* @returns 基金代码数组(6 位代码)
|
|
1624
|
+
*
|
|
1625
|
+
* @example
|
|
1626
|
+
* const codes = await sdk.getFundCodeList();
|
|
1627
|
+
* console.log(codes.length); // 26068
|
|
1628
|
+
*/
|
|
1629
|
+
getFundCodeList(): Promise<string[]>;
|
|
1621
1630
|
/**
|
|
1622
1631
|
* 获取全部 A 股实时行情
|
|
1623
1632
|
* @param options 配置选项
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Zt=Object.defineProperty;var ht=(t,e)=>{for(var n in e)Zt(t,n,{get:e[n],enumerable:!0})};function Z(t){return new TextDecoder("gbk").decode(t)}function ee(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let s=i.indexOf("=");if(s<0)continue;let r=i.slice(0,s).trim();r.startsWith("v_")&&(r=r.slice(2));let o=i.slice(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));let l=o.split("~");n.push({key:r,fields:l})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function R(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function y(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function b(t){return t==null?null:y(String(t))}var _e="https://qt.gtimg.cn",Le="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Ie="https://assets.linkdiary.cn/shares/zh_a_list.json",Ke="https://assets.linkdiary.cn/shares/us_list.json",we="https://assets.linkdiary.cn/shares/hk_list.json",gt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var te="https://push2his.eastmoney.com/api/qt/stock/kline/get",Pe="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ue="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",ke="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://17.push2.eastmoney.com/api/qt/clist/get",De="https://91.push2.eastmoney.com/api/qt/stock/get",ve="https://29.push2.eastmoney.com/api/qt/clist/get",Ne="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",He="https://push2his.eastmoney.com/api/qt/stock/trends2/get",qe="https://79.push2.eastmoney.com/api/qt/clist/get",Fe="https://91.push2.eastmoney.com/api/qt/stock/get",je="https://29.push2.eastmoney.com/api/qt/clist/get",Qe="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",$e="https://push2his.eastmoney.com/api/qt/stock/trends2/get",We="https://datacenter-web.eastmoney.com/api/data/v1/get",Ge=3e4,W=500,G=500,V=7,Ve=3,ze=1e3,Ye=3e4,Xe=2,Je=[408,429,500,502,503,504];var ne=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var yt=["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"],Ze=0;function en(){return typeof window<"u"&&typeof window.document<"u"}function Ct(){if(en())return;let t=yt[Ze];return Ze=(Ze+1)%yt.length,t}var z=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},re=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 z;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 H=class extends Error{constructor(n,i,s,r){let o=i?` ${i}`:"",l=s?`, url: ${s}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${o}${l}${a}`);this.status=n;this.statusText=i;this.url=s;this.provider=r;this.name="HttpError"}},Y=class{constructor(e={}){this.baseUrl=e.baseUrl??_e,this.timeout=e.timeout??Ge,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new ne(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new re(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(i=>i.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Ve,baseDelay:e?.baseDelay??ze,maxDelay:e?.maxDelay??Ye,backoffMultiplier:e?.backoffMultiplier??Xe,retryableStatusCodes:e?.retryableStatusCodes??Je,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof H?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let i=await e();return this.circuitBreaker?.recordSuccess(),i}catch(i){if(this.shouldRetry(i,n)){let s=this.calculateDelay(n);return this.retryOptions.onRetry&&i instanceof Error&&this.retryOptions.onRetry(n+1,i,s),await this.sleep(s),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),i}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new z("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let i=new AbortController,s=setTimeout(()=>i.abort(),this.timeout),r=this.inferProvider(e),o={...this.headers};if(this.rotateUserAgent){let l=Ct();l&&(o["User-Agent"]=l)}try{let l=await fetch(e,{signal:i.signal,headers:o});if(!l.ok)throw new H(l.status,l.statusText,e,r);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=r),l}finally{clearTimeout(s)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer"}),s=Z(i);return ee(s)}};var tn=new Set(["daily","weekly","monthly"]),nn=new Set(["1","5","15","30","60"]),rn=new Set(["","qfq","hfq"]);function M(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function L(t){if(!tn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function X(t){if(!nn.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function E(t){if(!rn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function q(t,e){M(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function F(t,e){M(e,"concurrency");let n=[],i=[];for(let s of t){let r=Promise.resolve().then(()=>s()).then(o=>{n.push(o)});if(i.push(r),i.length>=e){await Promise.race(i);for(let o=i.length-1;o>=0;o--)await Promise.race([i[o].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&i.splice(o,1)}}return await Promise.all(i),n}function se(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function I(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function x(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var T={};ht(T,{getAShareCodeList:()=>Ot,getAllHKQuotesByCodes:()=>_t,getAllQuotesByCodes:()=>xt,getAllUSQuotesByCodes:()=>Lt,getFullQuotes:()=>ie,getFundFlow:()=>St,getFundQuotes:()=>Tt,getHKCodeList:()=>Et,getHKQuotes:()=>oe,getPanelLargeOrder:()=>bt,getSimpleQuotes:()=>Rt,getTodayTimeline:()=>At,getTradingCalendar:()=>It,getUSCodeList:()=>Mt,getUSQuotes:()=>le,parseFullQuote:()=>et,parseFundFlow:()=>nt,parseFundQuote:()=>ot,parseHKQuote:()=>st,parsePanelLargeOrder:()=>rt,parseSimpleQuote:()=>tt,parseUSQuote:()=>it,search:()=>wt});function et(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),pb:R(t[46]),limitUp:R(t[47]),limitDown:R(t[48]),volumeRatio:R(t[49]),avgPrice:R(t[51]),peStatic:R(t[52]),peDynamic:R(t[53]),high52w:R(t[67]),low52w:R(t[68]),circulatingShares:R(t[72]),totalShares:R(t[73]),raw:t}}function tt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:R(t[9]),marketType:t[10]??"",raw:t}}function nt(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function rt(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function st(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:R(t[40]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),currency:t[t.length-3]??"",raw:t}}function it(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),totalMarketCap:R(t[45]),pb:R(t[47]),high52w:R(t[48]),low52w:R(t[49]),raw:t}}function ot(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function ie(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>et(i.fields))}async function Rt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`s_${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>tt(s.fields))}async function St(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`ff_${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>nt(s.fields))}async function bt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`s_pk${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>rt(s.fields))}async function oe(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`hk${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>st(s.fields))}async function le(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`us${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>it(s.fields))}async function Tt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`jj${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>ot(s.fields))}async function At(t,e){let n=t.getTimeout(),i=new AbortController,s=setTimeout(()=>i.abort(),n);try{let r=await fetch(`${Le}?code=${e}`,{signal:i.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let o=await r.json();if(o.code!==0)throw new Error(o.msg||"API error");let l=o.data?.[e];if(!l)return{code:e,date:"",data:[]};let a=l.data?.data||[],u=l.data?.date||"",c=!1;if(a.length>0){let d=a[0].split(" "),m=parseFloat(d[1])||0,g=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;g>0&&m>0&&f/g>m*50&&(c=!0)}let p=a.map(d=>{let m=d.split(" "),g=m[0],f=`${g.slice(0,2)}:${g.slice(2,4)}`,C=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?C*100:C,_=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(_*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(s)}}var lt=null,sn=null,ae=null,on=null,ue=null;function ln(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 Ot(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!lt){let o=(await t.get(Ie,{responseType:"json"}))?.list||[];lt=o,sn=o.map(l=>l.replace(/^(sh|sz|bj)/,""))}let s=lt;return i&&(s=s.filter(r=>ln(r,i))),n?s.map(r=>r.replace(/^(sh|sz|bj)/,"")):s.slice()}var an={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Mt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),ae||(ae=(await t.get(Ke,{responseType:"json"}))?.list||[],on=ae.map(o=>o.replace(/^\d{3}\./,"")));let s=ae.slice();if(i){let r=an[i];s=s.filter(o=>o.startsWith(r))}return n?s.map(r=>r.replace(/^\d{3}\./,"")):s}async function Et(t){return ue||(ue=(await t.get(we,{responseType:"json"}))?.list||[]),ue.slice()}async function xt(t,e,n={}){let{batchSize:i=W,concurrency:s=V,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,G),l=q(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ie(t,d);return u++,r&&r(u,a),m});return(await F(c,s)).flat()}async function _t(t,e,n={}){let{batchSize:i=W,concurrency:s=V,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,G),l=q(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await oe(t,d);return u++,r&&r(u,a),m});return(await F(c,s)).flat()}async function Lt(t,e,n={}){let{batchSize:i=W,concurrency:s=V,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,G),l=q(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await le(t,d);return u++,r&&r(u,a),m});return(await F(c,s)).flat()}var j=null;async function It(t){if(j)return j.slice();let e=await t.get(gt);return!e||e.trim()===""?(j=[],j.slice()):(j=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),j.slice())}var Kt="https://smartbox.gtimg.cn/s3/";function un(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function cn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),s=i[0]||"",r=i[1]||"",o=un(i[2]||""),l=i[4]||"";return{code:s+r,name:o,market:s,type:l}})}function pn(t){return new Promise((e,n)=>{let i=`${Kt}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let s=document.createElement("script");s.src=i,s.charset="utf-8",s.onload=()=>{let r=window.v_hint||"";document.body.removeChild(s),e(r)},s.onerror=()=>{document.body.removeChild(s),n(new Error("Network error calling Smartbox"))},document.body.appendChild(s)})}async function fn(t,e){let n=`${Kt}?v=2&t=all&q=${encodeURIComponent(e)}`,s=(await t.get(n)).match(/v_hint="([^"]*)"/);return s?s[1]:""}function dn(){return typeof window<"u"&&typeof document<"u"}async function wt(t,e){if(!e||!e.trim())return[];let n;return dn()?n=await pn(e):n=await fn(t,e),cn(n)}var A={};ht(A,{getConceptConstituents:()=>Ft,getConceptKline:()=>jt,getConceptList:()=>ct,getConceptMinuteKline:()=>Qt,getConceptSpot:()=>qt,getDividendDetail:()=>$t,getHKHistoryKline:()=>kt,getHistoryKline:()=>Pt,getIndustryConstituents:()=>vt,getIndustryKline:()=>Nt,getIndustryList:()=>ut,getIndustryMinuteKline:()=>Ht,getIndustrySpot:()=>Dt,getMinuteKline:()=>Ut,getUSHistoryKline:()=>Bt});async function at(t,e,n,i,s=100,r){let o=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(s),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;l===1&&(a=d.total??0);let m=d.diff.map((g,f)=>r(g,o.length+f+1));o.push(...m),l++}while(o.length<a);return o}function K(t){let[e,n,i,s,r,o,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(i),high:y(s),low:y(r),volume:y(o),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function w(t,e,n){let i=`${e}?${n.toString()}`,s=await t.get(i,{responseType:"json"});return{klines:s?.data?.klines||[],name:s?.data?.name,code:s?.data?.code}}async function Pt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;L(i),E(s);let l=e.replace(/^(sh|sz|bj)/,""),a=`${se(e)}.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(i),fqt:x(s),secid:a,beg:r,end:o}),c=te,{klines:p}=await w(t,c,u);return p.length===0?[]:p.map(d=>({...K(d),code:l}))}async function Ut(t,e,n={}){let{period:i="1",adjust:s="qfq",startDate:r="1979-09-01 09:32:00",endDate:o="2222-01-01 09:32:00"}=n;X(i),E(s);let l=e.replace(/^(sh|sz|bj)/,""),a=`${se(e)}.${l}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:a}),c=`${Pe}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=r.replace("T"," ").slice(0,16),g=o.replace("T"," ").slice(0,16);return d.map(f=>{let[C,S,O,_,$,U,N,Jt]=f.split(",");return{time:C,open:y(S),close:y(O),high:y(_),low:y($),volume:y(U),amount:y(N),avgPrice:y(Jt)}}).filter(f=>f.time>=m&&f.time<=g)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:x(s||""),secid:a,beg:"0",end:"20500000"}),c=te,{klines:p}=await w(t,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=o.replace("T"," ").slice(0,16);return p.map(g=>{let f=K(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function kt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;L(i),E(s);let l=e.replace(/^hk/i,"").padStart(5,"0"),a=`116.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(i),fqt:x(s),secid:a,beg:r,end:o,lmt:"1000000"}),c=Ue,{klines:p,name:d}=await w(t,c,u);return p.length===0?[]:p.map(m=>({...K(m),code:l,name:d||""}))}async function Bt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;L(i),E(s);let l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(i),fqt:x(s),secid:e,beg:r,end:o,lmt:"1000000"}),a=ke,{klines:u,name:c,code:p}=await w(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...K(g),code:d,name:m}))}function ce(t){let e=null;return{async getCode(n,i,s){if(i.startsWith("BK"))return i;if(!e){let o=await s(n);e=new Map(o.map(l=>[l.name,l.code]))}let r=e.get(i);if(!r)throw new Error(`${t.errorPrefix}: ${i}`);return r}}}async function pe(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",s=await at(t,e.listUrl,n,i,100,(r,o)=>({rank:o,name:String(r.f14??""),code:String(r.f12??""),price:b(r.f2),change:b(r.f4),changePercent:b(r.f3),totalMarketCap:b(r.f20),turnoverRate:b(r.f8),riseCount:b(r.f104),fallCount:b(r.f105),leadingStock:r.f128?String(r.f128):null,leadingStockChangePercent:b(r.f136)}));return s.sort((r,o)=>(o.changePercent??0)-(r.changePercent??0)),s.forEach((r,o)=>{r.rank=o+1}),s}async function fe(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),s=`${n}?${i.toString()}`,o=(await t.get(s,{responseType:"json"}))?.data;return o?[{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:a,name:u,divide:c})=>{let p=o[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function de(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return at(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(r,o)=>({rank:o,code:String(r.f12??""),name:String(r.f14??""),price:b(r.f2),changePercent:b(r.f3),change:b(r.f4),volume:b(r.f5),amount:b(r.f6),amplitude:b(r.f7),high:b(r.f15),low:b(r.f16),open:b(r.f17),prevClose:b(r.f18),turnoverRate:b(r.f8),pe:b(r.f9),pb:b(r.f23)}))}async function me(t,e,n,i={}){let{period:s="daily",adjust:r="",startDate:o="19700101",endDate:l="20500101"}=i;L(s),E(r);let a=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(s),fqt:x(r),beg:o,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await w(t,n,a);return u.length===0?[]:u.map(c=>K(c))}async function he(t,e,n,i,s={}){let{period:r="5"}=s;if(X(r),r==="1"){let o=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}`}),l=`${i}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(S),price:y(O)}})}else{let o=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:r,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),l=`${n}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O,_,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(_),change:y($),volume:y(C),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var k={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Be,spotUrl:De,consUrl:ve,klineUrl:Ne,trendsUrl:He,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},mn=ce(k);async function ge(t,e){return mn.getCode(t,e,ut)}async function ut(t){return pe(t,k)}async function Dt(t,e){let n=await ge(t,e);return fe(t,n,k.spotUrl)}async function vt(t,e){let n=await ge(t,e);return de(t,n,k.consUrl)}async function Nt(t,e,n={}){let i=await ge(t,e);return me(t,i,k.klineUrl,n)}async function Ht(t,e,n={}){let i=await ge(t,e);return he(t,i,k.klineUrl,k.trendsUrl,n)}var B={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:qe,spotUrl:Fe,consUrl:je,klineUrl:Qe,trendsUrl:$e,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},hn=ce(B);async function ye(t,e){return hn.getCode(t,e,ct)}async function ct(t){return pe(t,B)}async function qt(t,e){let n=await ye(t,e);return fe(t,n,B.spotUrl)}async function Ft(t,e){let n=await ye(t,e);return de(t,n,B.consUrl)}async function jt(t,e,n={}){let i=await ye(t,e);return me(t,i,B.klineUrl,n)}async function Qt(t,e,n={}){let i=await ye(t,e);return he(t,i,B.klineUrl,B.trendsUrl,n)}function D(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function gn(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:D(t.REPORT_DATE),planNoticeDate:D(t.PLAN_NOTICE_DATE),disclosureDate:D(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:D(t.EQUITY_RECORD_DATE),exDividendDate:D(t.EX_DIVIDEND_DATE),payDate:D(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:D(t.NOTICE_DATE)}}async function $t(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],s=1,r=1;do{let o=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(s),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${We}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;s===1&&(r=u.pages??1);let c=u.data.map(gn);i.push(...c),s++}while(s<=r);return i}function J(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function v(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let s=0,r=0;for(let o=i-e+1;o<=i;o++)t[o]!==null&&(s+=t[o],r++);n.push(r===e?J(s/e):null)}return n}function P(t,e){let n=[],i=2/(e+1),s=null,r=!1;for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=o-e+1;c<=o;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(s=a/e,r=!0),n.push(s!==null?J(s):null);continue}let l=t[o];l===null?n.push(s!==null?J(s):null):(s=i*l+(1-i)*s,n.push(J(s)))}return n}function pt(t,e){let n=[],i=Array.from({length:e},(r,o)=>o+1),s=i.reduce((r,o)=>r+o,0);for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let o=0,l=!0;for(let a=0;a<e;a++){let u=t[r-e+1+a];if(u===null){l=!1;break}o+=u*i[a]}n.push(l?J(o/s):null)}return n}function Ce(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,s=i==="ema"?P:i==="wma"?pt:v,r={};for(let o of n)r[`ma${o}`]=s(t,o);return t.map((o,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function Wt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Re(t,e={}){let{short:n=12,long:i=26,signal:s=9}=e,r=P(t,n),o=P(t,i),l=t.map((u,c)=>r[c]===null||o[c]===null?null:r[c]-o[c]),a=P(l,s);return t.map((u,c)=>({dif:l[c]!==null?Wt(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?Wt((l[c]-a[c])*2):null}))}function ft(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function yn(t,e,n){let i=[];for(let s=0;s<t.length;s++){if(s<e-1||n[s]===null){i.push(null);continue}let r=0,o=0;for(let l=s-e+1;l<=s;l++)t[l]!==null&&n[s]!==null&&(r+=Math.pow(t[l]-n[s],2),o++);i.push(o===e?Math.sqrt(r/e):null)}return i}function Se(t,e={}){let{period:n=20,stdDev:i=2}=e,s=v(t,n),r=yn(t,n,s);return t.map((o,l)=>{if(s[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=s[l]+i*r[l],u=s[l]-i*r[l],c=s[l]!==0?ft((a-u)/s[l]*100):null;return{mid:s[l],upper:ft(a),lower:ft(u),bandwidth:c}})}function dt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function be(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:s=3}=e,r=[],o=50,l=50;for(let a=0;a<t.length;a++){if(a<n-1){r.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,p=!0;for(let f=a-n+1;f<=a;f++){if(t[f].high===null||t[f].low===null){p=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[a].close;if(!p||d===null||u===c){r.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;o=(i-1)/i*o+1/i*m,l=(s-1)/s*l+1/s*o;let g=3*o-2*l;r.push({k:dt(o),d:dt(l),j:dt(g)})}return r}function Cn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Te(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let r=1;r<t.length;r++)t[r]===null||t[r-1]===null?i.push(null):i.push(t[r]-t[r-1]);let s={};for(let r of n){let o=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<r){o.push(null),i[u]!==null&&(i[u]>0?l+=i[u]:a+=Math.abs(i[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=i[u]??0,p=c>0?c:0,d=c<0?Math.abs(c):0;l=(l*(r-1)+p)/r,a=(a*(r-1)+d)/r}if(a===0)o.push(100);else if(l===0)o.push(0);else{let c=l/a;o.push(Cn(100-100/(1+c)))}}s[`rsi${r}`]=o}return t.map((r,o)=>{let l={};for(let a of n)l[`rsi${a}`]=s[`rsi${a}`][o];return l})}function Rn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ae(t,e={}){let{periods:n=[6,10]}=e,i={};for(let s of n){let r=[];for(let o=0;o<t.length;o++){if(o<s-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=o-s+1;d<=o;d++){if(t[d].high===null||t[d].low===null){u=!1;break}l=Math.max(l,t[d].high),a=Math.min(a,t[d].low)}let c=t[o].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(Rn(p))}i[`wr${s}`]=r}return t.map((s,r)=>{let o={};for(let l of n)o[`wr${l}`]=i[`wr${l}`][r];return o})}function Sn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Oe(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let s of n){let r=v(t,s),o=[];for(let l=0;l<t.length;l++)if(t[l]===null||r[l]===null||r[l]===0)o.push(null);else{let a=(t[l]-r[l])/r[l]*100;o.push(Sn(a))}i[`bias${s}`]=o}return t.map((s,r)=>{let o={};for(let l of n)o[`bias${l}`]=i[`bias${l}`][r];return o})}function bn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Me(t,e={}){let{period:n=14}=e,i=[],s=t.map(r=>r.high===null||r.low===null||r.close===null?null:(r.high+r.low+r.close)/3);for(let r=0;r<t.length;r++){if(r<n-1){i.push({cci:null});continue}let o=0,l=0;for(let p=r-n+1;p<=r;p++)s[p]!==null&&(o+=s[p],l++);if(l!==n||s[r]===null){i.push({cci:null});continue}let a=o/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(s[p]-a);let c=u/n;if(c===0)i.push({cci:0});else{let p=(s[r]-a)/(.015*c);i.push({cci:bn(p)})}}return i}function mt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Q(t,e={}){let{period:n=14}=e,i=[],s=[];for(let o=0;o<t.length;o++){let{high:l,low:a,close:u}=t[o];if(l===null||a===null||u===null){s.push(null);continue}if(o===0)s.push(l-a);else{let c=t[o-1].close;if(c===null)s.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);s.push(Math.max(p,d,m))}}}let r=null;for(let o=0;o<t.length;o++){if(o<n-1){i.push({tr:s[o]!==null?mt(s[o]):null,atr:null});continue}if(o===n-1){let l=0,a=0;for(let u=0;u<n;u++)s[u]!==null&&(l+=s[u],a++);a===n&&(r=l/n)}else r!==null&&s[o]!==null&&(r=(r*(n-1)+s[o])/n);i.push({tr:s[o]!==null?mt(s[o]):null,atr:r!==null?mt(r):null})}return i}function Gt(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let s=t[0].volume??0;i.push({obv:s,obvMa:null});for(let r=1;r<t.length;r++){let o=t[r],l=t[r-1];if(o.close===null||l.close===null||o.volume===null||o.volume===void 0){i.push({obv:null,obvMa:null});continue}o.close>l.close?s+=o.volume:o.close<l.close&&(s-=o.volume),i.push({obv:s,obvMa:null})}if(n&&n>0)for(let r=n-1;r<i.length;r++){let o=0,l=0;for(let a=r-n+1;a<=r;a++)i[a].obv!==null&&(o+=i[a].obv,l++);l===n&&(i[r].obvMa=o/n)}return i}function Vt(t,e={}){let{period:n=12,signalPeriod:i}=e,s=[];for(let r=0;r<t.length;r++){if(r<n){s.push({roc:null,signal:null});continue}let o=t[r].close,l=t[r-n].close;if(o===null||l===null||l===0){s.push({roc:null,signal:null});continue}let a=(o-l)/l*100;s.push({roc:a,signal:null})}if(i&&i>0)for(let r=n+i-1;r<s.length;r++){let o=0,l=0;for(let a=r-i+1;a<=r;a++)s[a].roc!==null&&(o+=s[a].roc,l++);l===i&&(s[r].signal=o/i)}return s}function zt(t,e={}){let{period:n=14,adxPeriod:i=n}=e,s=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],o=[],l=[];for(let f=0;f<t.length;f++){if(f===0){r.push(0),o.push(0),l.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],S=t[f-1];if(C.high===null||C.low===null||C.close===null||S.high===null||S.low===null||S.close===null){r.push(0),o.push(0),l.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=C.high-C.low,_=Math.abs(C.high-S.close),$=Math.abs(C.low-S.close);l.push(Math.max(O,_,$));let U=C.high-S.high,N=S.low-C.low;U>N&&U>0?r.push(U):r.push(0),N>U&&N>0?o.push(N):o.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<t.length;f++){if(f<n){a+=l[f],u+=r[f],c+=o[f],p.push(0);continue}f===n?(a=a,u=u,c=c):(a=a-a/n+l[f],u=u-u/n+r[f],c=c-c/n+o[f]);let C=a>0?u/a*100:0,S=a>0?c/a*100:0;s[f].pdi=C,s[f].mdi=S;let O=C+S,_=O>0?Math.abs(C-S)/O*100:0;p.push(_)}let d=0,m=0,g=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=p[f-n+1]||0,m++;continue}if(f===n*2-1)d+=p[f-n+1]||0,g=d/i,s[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(i-1)+C)/i,s[f].adx=g}}for(let f=n*2-1+i;f<t.length;f++){let C=s[f].adx,S=s[f-i]?.adx;C!==null&&S!==null&&(s[f].adxr=(C+S)/2)}return s}function Yt(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:s=.2}=e,r=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,l=n,a=t[0].high??0,u=t[0].low??0,c=t[0],p=t[1];c.close!==null&&p.close!==null&&p.close<c.close&&(o=-1,a=c.low??0,u=c.high??0),r.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let m=t[d],g=t[d-1];if(m.high===null||m.low===null||g.high===null||g.low===null){r.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+l*(a-u);o===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(o=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+i,s))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(o=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+i,s))),u=f,r.push({sar:u,trend:o,ep:a,af:l})}return r}function Xt(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:s=2}=e,r=[],o=t.map(u=>u.close),l=P(o,n),a=Q(t,{period:i});for(let u=0;u<t.length;u++){let c=l[u],p=a[u]?.atr;if(c===null||p===null){r.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+s*p,m=c-s*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function Ee(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),i=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),s=e.ma?Ce(n,typeof e.ma=="object"?e.ma:{}):null,r=e.macd?Re(n,typeof e.macd=="object"?e.macd:{}):null,o=e.boll?Se(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?be(i,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?Te(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?Ae(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?Oe(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?Me(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?Q(i,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...s&&{ma:s[g]},...r&&{macd:r[g]},...o&&{boll:o[g]},...l&&{kdj:l[g]},...a&&{rsi:a[g]},...u&&{wr:u[g]},...c&&{bias:c[g]},...p&&{cci:p[g]},...d&&{atr:d[g]}}))}var xe=class{constructor(e={}){this.client=new Y(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return A.getIndustryList(this.client)}getIndustrySpot(e){return A.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return A.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return A.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return A.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return A.getConceptList(this.client)}getConceptSpot(e){return A.getConceptSpot(this.client,e)}getConceptConstituents(e){return A.getConceptConstituents(this.client,e)}getConceptKline(e,n){return A.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return A.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return A.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return A.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return A.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return A.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,s=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(s,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,s=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,s,i)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return A.getDividendDetail(this.client,e)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let r=typeof e.ma=="object"?e.ma:{},o=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(o,20)),l==="ema"&&(i=!0)}if(e.macd){let r=typeof e.macd=="object"?e.macd:{},o=r.long??26,l=r.signal??9;n=Math.max(n,o*3+l),i=!0}if(e.boll){let r=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,r)}if(e.kdj){let r=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,r)}if(e.rsi){let r=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(r,14)+1)}if(e.wr){let r=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(r,10))}if(e.bias){let r=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(r,12))}if(e.cci){let r=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,r)}if(e.atr){let r=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,r)}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let s=Math.ceil(n*i),r=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));r.setDate(r.getDate()-s);let o=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${o}${l}${a}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let s=this.normalizeDate(e),r=i.findIndex(l=>l>=s);r===-1&&(r=i.length-1);let o=Math.max(0,r-n);return this.toCompactDate(i[o])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:s,indicators:r={}}=n,o=n.market??this.detectMarket(e),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(i)if(o==="A")try{let m=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,l,m)??this.calcActualStartDate(i,l,a[o])}catch{u=this.calcActualStartDate(i,l,a[o])}else u=this.calcActualStartDate(i,l,a[o]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(o){case"HK":p=await this.getHKHistoryKline(e,c);break;case"US":p=await this.getUSHistoryKline(e,c);break;default:p=await this.getHistoryKline(e,c)}if(i&&p.length<l)switch(o){case"HK":p=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=Ee(p,r);if(i){let m=this.dateToTimestamp(i),g=s?this.dateToTimestamp(s):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},Tn=xe;export{H as HttpError,xe as StockSDK,Ee as addIndicators,F as asyncPool,Q as calcATR,Oe as calcBIAS,Se as calcBOLL,Me as calcCCI,zt as calcDMI,P as calcEMA,Xt as calcKC,be as calcKDJ,Ce as calcMA,Re as calcMACD,Gt as calcOBV,Vt as calcROC,Te as calcRSI,Yt as calcSAR,v as calcSMA,pt as calcWMA,Ae as calcWR,q as chunkArray,Z as decodeGBK,Tn as default,ee as parseResponse,h as safeNumber,R as safeNumberOrNull};
|
|
1
|
+
var nn=Object.defineProperty;var yt=(t,e)=>{for(var n in e)nn(t,n,{get:e[n],enumerable:!0})};function Z(t){return new TextDecoder("gbk").decode(t)}function ee(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let s=i.indexOf("=");if(s<0)continue;let r=i.slice(0,s).trim();r.startsWith("v_")&&(r=r.slice(2));let o=i.slice(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));let l=o.split("~");n.push({key:r,fields:l})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function R(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function y(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function b(t){return t==null?null:y(String(t))}var Ee="https://qt.gtimg.cn",Le="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Ie="https://assets.linkdiary.cn/shares/zh_a_list.json",Ke="https://assets.linkdiary.cn/shares/us_list.json",we="https://assets.linkdiary.cn/shares/hk_list.json",Pe="https://assets.linkdiary.cn/shares/fund_list",Ct="https://assets.linkdiary.cn/shares/trade-data-list.txt";var te="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ue="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ke="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",De="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://17.push2.eastmoney.com/api/qt/clist/get",ve="https://91.push2.eastmoney.com/api/qt/stock/get",Ne="https://29.push2.eastmoney.com/api/qt/clist/get",He="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",qe="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Fe="https://79.push2.eastmoney.com/api/qt/clist/get",je="https://91.push2.eastmoney.com/api/qt/stock/get",Qe="https://29.push2.eastmoney.com/api/qt/clist/get",$e="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",We="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ge="https://datacenter-web.eastmoney.com/api/data/v1/get",Ve=3e4,W=500,G=500,V=7,ze=3,Ye=1e3,Xe=3e4,Je=2,Ze=[408,429,500,502,503,504];var ne=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Rt=["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"],et=0;function rn(){return typeof window<"u"&&typeof window.document<"u"}function St(){if(rn())return;let t=Rt[et];return et=(et+1)%Rt.length,t}var z=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},re=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 z;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 H=class extends Error{constructor(n,i,s,r){let o=i?` ${i}`:"",l=s?`, url: ${s}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${o}${l}${a}`);this.status=n;this.statusText=i;this.url=s;this.provider=r;this.name="HttpError"}},Y=class{constructor(e={}){this.baseUrl=e.baseUrl??Ee,this.timeout=e.timeout??Ve,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new ne(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new re(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(i=>i.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??ze,baseDelay:e?.baseDelay??Ye,maxDelay:e?.maxDelay??Xe,backoffMultiplier:e?.backoffMultiplier??Je,retryableStatusCodes:e?.retryableStatusCodes??Ze,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof H?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let i=await e();return this.circuitBreaker?.recordSuccess(),i}catch(i){if(this.shouldRetry(i,n)){let s=this.calculateDelay(n);return this.retryOptions.onRetry&&i instanceof Error&&this.retryOptions.onRetry(n+1,i,s),await this.sleep(s),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),i}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new z("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let i=new AbortController,s=setTimeout(()=>i.abort(),this.timeout),r=this.inferProvider(e),o={...this.headers};if(this.rotateUserAgent){let l=St();l&&(o["User-Agent"]=l)}try{let l=await fetch(e,{signal:i.signal,headers:o});if(!l.ok)throw new H(l.status,l.statusText,e,r);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=r),l}finally{clearTimeout(s)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer"}),s=Z(i);return ee(s)}};var sn=new Set(["daily","weekly","monthly"]),on=new Set(["1","5","15","30","60"]),ln=new Set(["","qfq","hfq"]);function M(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function L(t){if(!sn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function X(t){if(!on.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function _(t){if(!ln.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function q(t,e){M(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function F(t,e){M(e,"concurrency");let n=[],i=[];for(let s of t){let r=Promise.resolve().then(()=>s()).then(o=>{n.push(o)});if(i.push(r),i.length>=e){await Promise.race(i);for(let o=i.length-1;o>=0;o--)await Promise.race([i[o].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&i.splice(o,1)}}return await Promise.all(i),n}function se(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function I(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function x(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var T={};yt(T,{getAShareCodeList:()=>_t,getAllHKQuotesByCodes:()=>It,getAllQuotesByCodes:()=>Lt,getAllUSQuotesByCodes:()=>Kt,getFullQuotes:()=>ie,getFundCodeList:()=>wt,getFundFlow:()=>Tt,getFundQuotes:()=>Ot,getHKCodeList:()=>Et,getHKQuotes:()=>oe,getPanelLargeOrder:()=>At,getSimpleQuotes:()=>bt,getTodayTimeline:()=>Mt,getTradingCalendar:()=>Pt,getUSCodeList:()=>xt,getUSQuotes:()=>le,parseFullQuote:()=>tt,parseFundFlow:()=>rt,parseFundQuote:()=>lt,parseHKQuote:()=>it,parsePanelLargeOrder:()=>st,parseSimpleQuote:()=>nt,parseUSQuote:()=>ot,search:()=>kt});function tt(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),pb:R(t[46]),limitUp:R(t[47]),limitDown:R(t[48]),volumeRatio:R(t[49]),avgPrice:R(t[51]),peStatic:R(t[52]),peDynamic:R(t[53]),high52w:R(t[67]),low52w:R(t[68]),circulatingShares:R(t[72]),totalShares:R(t[73]),raw:t}}function nt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:R(t[9]),marketType:t[10]??"",raw:t}}function rt(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function st(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function it(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:R(t[40]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),currency:t[t.length-3]??"",raw:t}}function ot(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),totalMarketCap:R(t[45]),pb:R(t[47]),high52w:R(t[48]),low52w:R(t[49]),raw:t}}function lt(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function ie(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>tt(i.fields))}async function bt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`s_${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>nt(s.fields))}async function Tt(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`ff_${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>rt(s.fields))}async function At(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`s_pk${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>st(s.fields))}async function oe(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`hk${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>it(s.fields))}async function le(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`us${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>ot(s.fields))}async function Ot(t,e){if(!e||e.length===0)return[];let n=e.map(s=>`jj${s}`);return(await t.getTencentQuote(n.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>lt(s.fields))}async function Mt(t,e){let n=t.getTimeout(),i=new AbortController,s=setTimeout(()=>i.abort(),n);try{let r=await fetch(`${Le}?code=${e}`,{signal:i.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let o=await r.json();if(o.code!==0)throw new Error(o.msg||"API error");let l=o.data?.[e];if(!l)return{code:e,date:"",data:[]};let a=l.data?.data||[],u=l.data?.date||"",c=!1;if(a.length>0){let d=a[0].split(" "),m=parseFloat(d[1])||0,g=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;g>0&&m>0&&f/g>m*50&&(c=!0)}let p=a.map(d=>{let m=d.split(" "),g=m[0],f=`${g.slice(0,2)}:${g.slice(2,4)}`,C=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?C*100:C,E=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(E*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(s)}}var at=null,an=null,ae=null,un=null,ue=null,ut=null;function cn(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 _t(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!at){let o=(await t.get(Ie,{responseType:"json"}))?.list||[];at=o,an=o.map(l=>l.replace(/^(sh|sz|bj)/,""))}let s=at;return i&&(s=s.filter(r=>cn(r,i))),n?s.map(r=>r.replace(/^(sh|sz|bj)/,"")):s.slice()}var pn={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function xt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),ae||(ae=(await t.get(Ke,{responseType:"json"}))?.list||[],un=ae.map(o=>o.replace(/^\d{3}\./,"")));let s=ae.slice();if(i){let r=pn[i];s=s.filter(o=>o.startsWith(r))}return n?s.map(r=>r.replace(/^\d{3}\./,"")):s}async function Et(t){return ue||(ue=(await t.get(we,{responseType:"json"}))?.list||[]),ue.slice()}async function Lt(t,e,n={}){let{batchSize:i=W,concurrency:s=V,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,G),l=q(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ie(t,d);return u++,r&&r(u,a),m});return(await F(c,s)).flat()}async function It(t,e,n={}){let{batchSize:i=W,concurrency:s=V,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,G),l=q(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await oe(t,d);return u++,r&&r(u,a),m});return(await F(c,s)).flat()}async function Kt(t,e,n={}){let{batchSize:i=W,concurrency:s=V,onProgress:r}=n;M(i,"batchSize"),M(s,"concurrency");let o=Math.min(i,G),l=q(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await le(t,d);return u++,r&&r(u,a),m});return(await F(c,s)).flat()}async function wt(t){if(ut)return ut.slice();let i=(await t.get(Pe,{responseType:"text"})).split(",").slice(1).filter(s=>s.trim());return ut=i,i.slice()}var j=null;async function Pt(t){if(j)return j.slice();let e=await t.get(Ct);return!e||e.trim()===""?(j=[],j.slice()):(j=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),j.slice())}var Ut="https://smartbox.gtimg.cn/s3/";function fn(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function dn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),s=i[0]||"",r=i[1]||"",o=fn(i[2]||""),l=i[4]||"";return{code:s+r,name:o,market:s,type:l}})}function mn(t){return new Promise((e,n)=>{let i=`${Ut}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let s=document.createElement("script");s.src=i,s.charset="utf-8",s.onload=()=>{let r=window.v_hint||"";document.body.removeChild(s),e(r)},s.onerror=()=>{document.body.removeChild(s),n(new Error("Network error calling Smartbox"))},document.body.appendChild(s)})}async function hn(t,e){let n=`${Ut}?v=2&t=all&q=${encodeURIComponent(e)}`,s=(await t.get(n)).match(/v_hint="([^"]*)"/);return s?s[1]:""}function gn(){return typeof window<"u"&&typeof document<"u"}async function kt(t,e){if(!e||!e.trim())return[];let n;return gn()?n=await mn(e):n=await hn(t,e),dn(n)}var A={};yt(A,{getConceptConstituents:()=>$t,getConceptKline:()=>Wt,getConceptList:()=>ft,getConceptMinuteKline:()=>Gt,getConceptSpot:()=>Qt,getDividendDetail:()=>Vt,getHKHistoryKline:()=>vt,getHistoryKline:()=>Dt,getIndustryConstituents:()=>qt,getIndustryKline:()=>Ft,getIndustryList:()=>pt,getIndustryMinuteKline:()=>jt,getIndustrySpot:()=>Ht,getMinuteKline:()=>Bt,getUSHistoryKline:()=>Nt});async function ct(t,e,n,i,s=100,r){let o=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(s),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;l===1&&(a=d.total??0);let m=d.diff.map((g,f)=>r(g,o.length+f+1));o.push(...m),l++}while(o.length<a);return o}function K(t){let[e,n,i,s,r,o,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(i),high:y(s),low:y(r),volume:y(o),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function w(t,e,n){let i=`${e}?${n.toString()}`,s=await t.get(i,{responseType:"json"});return{klines:s?.data?.klines||[],name:s?.data?.name,code:s?.data?.code}}async function Dt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;L(i),_(s);let l=e.replace(/^(sh|sz|bj)/,""),a=`${se(e)}.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(i),fqt:x(s),secid:a,beg:r,end:o}),c=te,{klines:p}=await w(t,c,u);return p.length===0?[]:p.map(d=>({...K(d),code:l}))}async function Bt(t,e,n={}){let{period:i="1",adjust:s="qfq",startDate:r="1979-09-01 09:32:00",endDate:o="2222-01-01 09:32:00"}=n;X(i),_(s);let l=e.replace(/^(sh|sz|bj)/,""),a=`${se(e)}.${l}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:a}),c=`${Ue}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=r.replace("T"," ").slice(0,16),g=o.replace("T"," ").slice(0,16);return d.map(f=>{let[C,S,O,E,$,U,N,tn]=f.split(",");return{time:C,open:y(S),close:y(O),high:y(E),low:y($),volume:y(U),amount:y(N),avgPrice:y(tn)}}).filter(f=>f.time>=m&&f.time<=g)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:x(s||""),secid:a,beg:"0",end:"20500000"}),c=te,{klines:p}=await w(t,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=o.replace("T"," ").slice(0,16);return p.map(g=>{let f=K(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function vt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;L(i),_(s);let l=e.replace(/^hk/i,"").padStart(5,"0"),a=`116.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(i),fqt:x(s),secid:a,beg:r,end:o,lmt:"1000000"}),c=ke,{klines:p,name:d}=await w(t,c,u);return p.length===0?[]:p.map(m=>({...K(m),code:l,name:d||""}))}async function Nt(t,e,n={}){let{period:i="daily",adjust:s="qfq",startDate:r="19700101",endDate:o="20500101"}=n;L(i),_(s);let l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(i),fqt:x(s),secid:e,beg:r,end:o,lmt:"1000000"}),a=De,{klines:u,name:c,code:p}=await w(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...K(g),code:d,name:m}))}function ce(t){let e=null;return{async getCode(n,i,s){if(i.startsWith("BK"))return i;if(!e){let o=await s(n);e=new Map(o.map(l=>[l.name,l.code]))}let r=e.get(i);if(!r)throw new Error(`${t.errorPrefix}: ${i}`);return r}}}async function pe(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",s=await ct(t,e.listUrl,n,i,100,(r,o)=>({rank:o,name:String(r.f14??""),code:String(r.f12??""),price:b(r.f2),change:b(r.f4),changePercent:b(r.f3),totalMarketCap:b(r.f20),turnoverRate:b(r.f8),riseCount:b(r.f104),fallCount:b(r.f105),leadingStock:r.f128?String(r.f128):null,leadingStockChangePercent:b(r.f136)}));return s.sort((r,o)=>(o.changePercent??0)-(r.changePercent??0)),s.forEach((r,o)=>{r.rank=o+1}),s}async function fe(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),s=`${n}?${i.toString()}`,o=(await t.get(s,{responseType:"json"}))?.data;return o?[{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:a,name:u,divide:c})=>{let p=o[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function de(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return ct(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(r,o)=>({rank:o,code:String(r.f12??""),name:String(r.f14??""),price:b(r.f2),changePercent:b(r.f3),change:b(r.f4),volume:b(r.f5),amount:b(r.f6),amplitude:b(r.f7),high:b(r.f15),low:b(r.f16),open:b(r.f17),prevClose:b(r.f18),turnoverRate:b(r.f8),pe:b(r.f9),pb:b(r.f23)}))}async function me(t,e,n,i={}){let{period:s="daily",adjust:r="",startDate:o="19700101",endDate:l="20500101"}=i;L(s),_(r);let a=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(s),fqt:x(r),beg:o,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await w(t,n,a);return u.length===0?[]:u.map(c=>K(c))}async function he(t,e,n,i,s={}){let{period:r="5"}=s;if(X(r),r==="1"){let o=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}`}),l=`${i}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(S),price:y(O)}})}else{let o=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:r,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),l=`${n}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O,E,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(E),change:y($),volume:y(C),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var k={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Be,spotUrl:ve,consUrl:Ne,klineUrl:He,trendsUrl:qe,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},yn=ce(k);async function ge(t,e){return yn.getCode(t,e,pt)}async function pt(t){return pe(t,k)}async function Ht(t,e){let n=await ge(t,e);return fe(t,n,k.spotUrl)}async function qt(t,e){let n=await ge(t,e);return de(t,n,k.consUrl)}async function Ft(t,e,n={}){let i=await ge(t,e);return me(t,i,k.klineUrl,n)}async function jt(t,e,n={}){let i=await ge(t,e);return he(t,i,k.klineUrl,k.trendsUrl,n)}var D={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Fe,spotUrl:je,consUrl:Qe,klineUrl:$e,trendsUrl:We,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},Cn=ce(D);async function ye(t,e){return Cn.getCode(t,e,ft)}async function ft(t){return pe(t,D)}async function Qt(t,e){let n=await ye(t,e);return fe(t,n,D.spotUrl)}async function $t(t,e){let n=await ye(t,e);return de(t,n,D.consUrl)}async function Wt(t,e,n={}){let i=await ye(t,e);return me(t,i,D.klineUrl,n)}async function Gt(t,e,n={}){let i=await ye(t,e);return he(t,i,D.klineUrl,D.trendsUrl,n)}function B(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Rn(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:B(t.REPORT_DATE),planNoticeDate:B(t.PLAN_NOTICE_DATE),disclosureDate:B(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:B(t.EQUITY_RECORD_DATE),exDividendDate:B(t.EX_DIVIDEND_DATE),payDate:B(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:B(t.NOTICE_DATE)}}async function Vt(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],s=1,r=1;do{let o=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(s),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${Ge}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;s===1&&(r=u.pages??1);let c=u.data.map(Rn);i.push(...c),s++}while(s<=r);return i}function J(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function v(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let s=0,r=0;for(let o=i-e+1;o<=i;o++)t[o]!==null&&(s+=t[o],r++);n.push(r===e?J(s/e):null)}return n}function P(t,e){let n=[],i=2/(e+1),s=null,r=!1;for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=o-e+1;c<=o;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(s=a/e,r=!0),n.push(s!==null?J(s):null);continue}let l=t[o];l===null?n.push(s!==null?J(s):null):(s=i*l+(1-i)*s,n.push(J(s)))}return n}function dt(t,e){let n=[],i=Array.from({length:e},(r,o)=>o+1),s=i.reduce((r,o)=>r+o,0);for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let o=0,l=!0;for(let a=0;a<e;a++){let u=t[r-e+1+a];if(u===null){l=!1;break}o+=u*i[a]}n.push(l?J(o/s):null)}return n}function Ce(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,s=i==="ema"?P:i==="wma"?dt:v,r={};for(let o of n)r[`ma${o}`]=s(t,o);return t.map((o,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function zt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Re(t,e={}){let{short:n=12,long:i=26,signal:s=9}=e,r=P(t,n),o=P(t,i),l=t.map((u,c)=>r[c]===null||o[c]===null?null:r[c]-o[c]),a=P(l,s);return t.map((u,c)=>({dif:l[c]!==null?zt(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?zt((l[c]-a[c])*2):null}))}function mt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Sn(t,e,n){let i=[];for(let s=0;s<t.length;s++){if(s<e-1||n[s]===null){i.push(null);continue}let r=0,o=0;for(let l=s-e+1;l<=s;l++)t[l]!==null&&n[s]!==null&&(r+=Math.pow(t[l]-n[s],2),o++);i.push(o===e?Math.sqrt(r/e):null)}return i}function Se(t,e={}){let{period:n=20,stdDev:i=2}=e,s=v(t,n),r=Sn(t,n,s);return t.map((o,l)=>{if(s[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=s[l]+i*r[l],u=s[l]-i*r[l],c=s[l]!==0?mt((a-u)/s[l]*100):null;return{mid:s[l],upper:mt(a),lower:mt(u),bandwidth:c}})}function ht(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function be(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:s=3}=e,r=[],o=50,l=50;for(let a=0;a<t.length;a++){if(a<n-1){r.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,p=!0;for(let f=a-n+1;f<=a;f++){if(t[f].high===null||t[f].low===null){p=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[a].close;if(!p||d===null||u===c){r.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;o=(i-1)/i*o+1/i*m,l=(s-1)/s*l+1/s*o;let g=3*o-2*l;r.push({k:ht(o),d:ht(l),j:ht(g)})}return r}function bn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Te(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let r=1;r<t.length;r++)t[r]===null||t[r-1]===null?i.push(null):i.push(t[r]-t[r-1]);let s={};for(let r of n){let o=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<r){o.push(null),i[u]!==null&&(i[u]>0?l+=i[u]:a+=Math.abs(i[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=i[u]??0,p=c>0?c:0,d=c<0?Math.abs(c):0;l=(l*(r-1)+p)/r,a=(a*(r-1)+d)/r}if(a===0)o.push(100);else if(l===0)o.push(0);else{let c=l/a;o.push(bn(100-100/(1+c)))}}s[`rsi${r}`]=o}return t.map((r,o)=>{let l={};for(let a of n)l[`rsi${a}`]=s[`rsi${a}`][o];return l})}function Tn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ae(t,e={}){let{periods:n=[6,10]}=e,i={};for(let s of n){let r=[];for(let o=0;o<t.length;o++){if(o<s-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=o-s+1;d<=o;d++){if(t[d].high===null||t[d].low===null){u=!1;break}l=Math.max(l,t[d].high),a=Math.min(a,t[d].low)}let c=t[o].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(Tn(p))}i[`wr${s}`]=r}return t.map((s,r)=>{let o={};for(let l of n)o[`wr${l}`]=i[`wr${l}`][r];return o})}function An(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Oe(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let s of n){let r=v(t,s),o=[];for(let l=0;l<t.length;l++)if(t[l]===null||r[l]===null||r[l]===0)o.push(null);else{let a=(t[l]-r[l])/r[l]*100;o.push(An(a))}i[`bias${s}`]=o}return t.map((s,r)=>{let o={};for(let l of n)o[`bias${l}`]=i[`bias${l}`][r];return o})}function On(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Me(t,e={}){let{period:n=14}=e,i=[],s=t.map(r=>r.high===null||r.low===null||r.close===null?null:(r.high+r.low+r.close)/3);for(let r=0;r<t.length;r++){if(r<n-1){i.push({cci:null});continue}let o=0,l=0;for(let p=r-n+1;p<=r;p++)s[p]!==null&&(o+=s[p],l++);if(l!==n||s[r]===null){i.push({cci:null});continue}let a=o/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(s[p]-a);let c=u/n;if(c===0)i.push({cci:0});else{let p=(s[r]-a)/(.015*c);i.push({cci:On(p)})}}return i}function gt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Q(t,e={}){let{period:n=14}=e,i=[],s=[];for(let o=0;o<t.length;o++){let{high:l,low:a,close:u}=t[o];if(l===null||a===null||u===null){s.push(null);continue}if(o===0)s.push(l-a);else{let c=t[o-1].close;if(c===null)s.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);s.push(Math.max(p,d,m))}}}let r=null;for(let o=0;o<t.length;o++){if(o<n-1){i.push({tr:s[o]!==null?gt(s[o]):null,atr:null});continue}if(o===n-1){let l=0,a=0;for(let u=0;u<n;u++)s[u]!==null&&(l+=s[u],a++);a===n&&(r=l/n)}else r!==null&&s[o]!==null&&(r=(r*(n-1)+s[o])/n);i.push({tr:s[o]!==null?gt(s[o]):null,atr:r!==null?gt(r):null})}return i}function Yt(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let s=t[0].volume??0;i.push({obv:s,obvMa:null});for(let r=1;r<t.length;r++){let o=t[r],l=t[r-1];if(o.close===null||l.close===null||o.volume===null||o.volume===void 0){i.push({obv:null,obvMa:null});continue}o.close>l.close?s+=o.volume:o.close<l.close&&(s-=o.volume),i.push({obv:s,obvMa:null})}if(n&&n>0)for(let r=n-1;r<i.length;r++){let o=0,l=0;for(let a=r-n+1;a<=r;a++)i[a].obv!==null&&(o+=i[a].obv,l++);l===n&&(i[r].obvMa=o/n)}return i}function Xt(t,e={}){let{period:n=12,signalPeriod:i}=e,s=[];for(let r=0;r<t.length;r++){if(r<n){s.push({roc:null,signal:null});continue}let o=t[r].close,l=t[r-n].close;if(o===null||l===null||l===0){s.push({roc:null,signal:null});continue}let a=(o-l)/l*100;s.push({roc:a,signal:null})}if(i&&i>0)for(let r=n+i-1;r<s.length;r++){let o=0,l=0;for(let a=r-i+1;a<=r;a++)s[a].roc!==null&&(o+=s[a].roc,l++);l===i&&(s[r].signal=o/i)}return s}function Jt(t,e={}){let{period:n=14,adxPeriod:i=n}=e,s=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],o=[],l=[];for(let f=0;f<t.length;f++){if(f===0){r.push(0),o.push(0),l.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],S=t[f-1];if(C.high===null||C.low===null||C.close===null||S.high===null||S.low===null||S.close===null){r.push(0),o.push(0),l.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=C.high-C.low,E=Math.abs(C.high-S.close),$=Math.abs(C.low-S.close);l.push(Math.max(O,E,$));let U=C.high-S.high,N=S.low-C.low;U>N&&U>0?r.push(U):r.push(0),N>U&&N>0?o.push(N):o.push(0),s.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<t.length;f++){if(f<n){a+=l[f],u+=r[f],c+=o[f],p.push(0);continue}f===n?(a=a,u=u,c=c):(a=a-a/n+l[f],u=u-u/n+r[f],c=c-c/n+o[f]);let C=a>0?u/a*100:0,S=a>0?c/a*100:0;s[f].pdi=C,s[f].mdi=S;let O=C+S,E=O>0?Math.abs(C-S)/O*100:0;p.push(E)}let d=0,m=0,g=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=p[f-n+1]||0,m++;continue}if(f===n*2-1)d+=p[f-n+1]||0,g=d/i,s[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(i-1)+C)/i,s[f].adx=g}}for(let f=n*2-1+i;f<t.length;f++){let C=s[f].adx,S=s[f-i]?.adx;C!==null&&S!==null&&(s[f].adxr=(C+S)/2)}return s}function Zt(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:s=.2}=e,r=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,l=n,a=t[0].high??0,u=t[0].low??0,c=t[0],p=t[1];c.close!==null&&p.close!==null&&p.close<c.close&&(o=-1,a=c.low??0,u=c.high??0),r.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let m=t[d],g=t[d-1];if(m.high===null||m.low===null||g.high===null||g.low===null){r.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+l*(a-u);o===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(o=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+i,s))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(o=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+i,s))),u=f,r.push({sar:u,trend:o,ep:a,af:l})}return r}function en(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:s=2}=e,r=[],o=t.map(u=>u.close),l=P(o,n),a=Q(t,{period:i});for(let u=0;u<t.length;u++){let c=l[u],p=a[u]?.atr;if(c===null||p===null){r.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+s*p,m=c-s*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function _e(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),i=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),s=e.ma?Ce(n,typeof e.ma=="object"?e.ma:{}):null,r=e.macd?Re(n,typeof e.macd=="object"?e.macd:{}):null,o=e.boll?Se(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?be(i,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?Te(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?Ae(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?Oe(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?Me(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?Q(i,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...s&&{ma:s[g]},...r&&{macd:r[g]},...o&&{boll:o[g]},...l&&{kdj:l[g]},...a&&{rsi:a[g]},...u&&{wr:u[g]},...c&&{bias:c[g]},...p&&{cci:p[g]},...d&&{atr:d[g]}}))}var xe=class{constructor(e={}){this.client=new Y(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return A.getIndustryList(this.client)}getIndustrySpot(e){return A.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return A.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return A.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return A.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return A.getConceptList(this.client)}getConceptSpot(e){return A.getConceptSpot(this.client,e)}getConceptConstituents(e){return A.getConceptConstituents(this.client,e)}getConceptKline(e,n){return A.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return A.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return A.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return A.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return A.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return A.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}getFundCodeList(){return T.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,s=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(s,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,s=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,s,i)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return A.getDividendDetail(this.client,e)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let r=typeof e.ma=="object"?e.ma:{},o=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(o,20)),l==="ema"&&(i=!0)}if(e.macd){let r=typeof e.macd=="object"?e.macd:{},o=r.long??26,l=r.signal??9;n=Math.max(n,o*3+l),i=!0}if(e.boll){let r=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,r)}if(e.kdj){let r=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,r)}if(e.rsi){let r=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(r,14)+1)}if(e.wr){let r=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(r,10))}if(e.bias){let r=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(r,12))}if(e.cci){let r=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,r)}if(e.atr){let r=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,r)}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let s=Math.ceil(n*i),r=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));r.setDate(r.getDate()-s);let o=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${o}${l}${a}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let s=this.normalizeDate(e),r=i.findIndex(l=>l>=s);r===-1&&(r=i.length-1);let o=Math.max(0,r-n);return this.toCompactDate(i[o])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:s,indicators:r={}}=n,o=n.market??this.detectMarket(e),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(i)if(o==="A")try{let m=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,l,m)??this.calcActualStartDate(i,l,a[o])}catch{u=this.calcActualStartDate(i,l,a[o])}else u=this.calcActualStartDate(i,l,a[o]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(o){case"HK":p=await this.getHKHistoryKline(e,c);break;case"US":p=await this.getUSHistoryKline(e,c);break;default:p=await this.getHistoryKline(e,c)}if(i&&p.length<l)switch(o){case"HK":p=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=_e(p,r);if(i){let m=this.dateToTimestamp(i),g=s?this.dateToTimestamp(s):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},Mn=xe;export{H as HttpError,xe as StockSDK,_e as addIndicators,F as asyncPool,Q as calcATR,Oe as calcBIAS,Se as calcBOLL,Me as calcCCI,Jt as calcDMI,P as calcEMA,en as calcKC,be as calcKDJ,Ce as calcMA,Re as calcMACD,Yt as calcOBV,Xt as calcROC,Te as calcRSI,Zt as calcSAR,v as calcSMA,dt as calcWMA,Ae as calcWR,q as chunkArray,Z as decodeGBK,Mn as default,ee as parseResponse,h as safeNumber,R as safeNumberOrNull};
|