stock-sdk 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Ae=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Gt=Object.prototype.hasOwnProperty;var Te=(t,e)=>{for(var n in e)Ae(t,n,{get:e[n],enumerable:!0})},zt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Wt(e))!Gt.call(t,o)&&o!==n&&Ae(t,o,{get:()=>e[o],enumerable:!(s=Vt(e,o))||s.enumerable});return t};var Yt=t=>zt(Ae({},"__esModule",{value:!0}),t);var yn={};Te(yn,{HttpError:()=>k,StockSDK:()=>ae,addIndicators:()=>le,asyncPool:()=>v,calcATR:()=>N,calcBIAS:()=>se,calcBOLL:()=>te,calcCCI:()=>ie,calcDMI:()=>dt,calcEMA:()=>w,calcKC:()=>ht,calcKDJ:()=>ne,calcMA:()=>Z,calcMACD:()=>ee,calcOBV:()=>pt,calcROC:()=>ft,calcRSI:()=>re,calcSAR:()=>mt,calcSMA:()=>P,calcWMA:()=>xe,calcWR:()=>oe,chunkArray:()=>D,decodeGBK:()=>$,default:()=>Ft,parseResponse:()=>V,safeNumber:()=>h,safeNumberOrNull:()=>R});module.exports=Yt(yn);function $(t){return new TextDecoder("gbk").decode(t)}function V(t){let e=t.split(";").map(s=>s.trim()).filter(Boolean),n=[];for(let s of e){let o=s.indexOf("=");if(o<0)continue;let r=s.slice(0,o).trim();r.startsWith("v_")&&(r=r.slice(2));let i=s.slice(o+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let l=i.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 S(t){return t==null?null:y(String(t))}var Ke="https://qt.gtimg.cn",we="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Le="https://assets.linkdiary.cn/shares/zh_a_list.json",_e="https://assets.linkdiary.cn/shares/us_list.json",Ie="https://assets.linkdiary.cn/shares/hk_list.json",gt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ue="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ue="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ee="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Pe="https://17.push2.eastmoney.com/api/qt/clist/get",ke="https://91.push2.eastmoney.com/api/qt/stock/get",De="https://29.push2.eastmoney.com/api/qt/clist/get",ve="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",Ne="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",Fe="https://push2his.eastmoney.com/api/qt/stock/trends2/get",$e=3e4,W=500,G=500,z=7,Ve=3,We=1e3,Ge=3e4,ze=2,Ye=[408,429,500,502,503,504];var k=class extends Error{constructor(n,s,o,r){let i=s?` ${s}`:"",l=o?`, url: ${o}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${i}${l}${a}`);this.status=n;this.statusText=s;this.url=o;this.provider=r;this.name="HttpError"}},Y=class{constructor(e={}){this.baseUrl=e.baseUrl??Ke,this.timeout=e.timeout??$e,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},e.userAgent&&(Object.keys(this.headers).some(s=>s.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Ve,baseDelay:e?.baseDelay??We,maxDelay:e?.maxDelay??Ge,backoffMultiplier:e?.backoffMultiplier??ze,retryableStatusCodes:e?.retryableStatusCodes??Ye,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 k?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{return await e()}catch(s){if(this.shouldRetry(s,n)){let o=this.calculateDelay(n);return this.retryOptions.onRetry&&s instanceof Error&&this.retryOptions.onRetry(n+1,s,o),await this.sleep(o),this.executeWithRetry(e,n+1)}throw s}}async get(e,n={}){return this.executeWithRetry(async()=>{let s=new AbortController,o=setTimeout(()=>s.abort(),this.timeout),r=this.inferProvider(e);try{let i=await fetch(e,{signal:s.signal,headers:{...this.headers}});if(!i.ok)throw new k(i.status,i.statusText,e,r);switch(n.responseType){case"json":return await i.json();case"arraybuffer":return await i.arrayBuffer();default:return await i.text()}}catch(i){throw i instanceof Error&&(i.url=e,i.provider=r),i}finally{clearTimeout(o)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,s=await this.get(n,{responseType:"arraybuffer"}),o=$(s);return V(o)}};var Jt=new Set(["daily","weekly","monthly"]),Xt=new Set(["1","5","15","30","60"]),Zt=new Set(["","qfq","hfq"]);function A(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function _(t){if(!Jt.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function J(t){if(!Xt.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function T(t){if(!Zt.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function D(t,e){A(e,"chunkSize");let n=[];for(let s=0;s<t.length;s+=e)n.push(t.slice(s,s+e));return n}async function v(t,e){A(e,"concurrency");let n=[],s=[];for(let o of t){let r=Promise.resolve().then(()=>o()).then(i=>{n.push(i)});if(s.push(r),s.length>=e){await Promise.race(s);for(let i=s.length-1;i>=0;i--)await Promise.race([s[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&s.splice(i,1)}}return await Promise.all(s),n}function ce(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 K(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var M={};Te(M,{getAShareCodeList:()=>Mt,getAllHKQuotesByCodes:()=>Tt,getAllQuotesByCodes:()=>At,getAllUSQuotesByCodes:()=>Kt,getFullQuotes:()=>pe,getFundFlow:()=>Ct,getFundQuotes:()=>bt,getHKCodeList:()=>xt,getHKQuotes:()=>fe,getPanelLargeOrder:()=>Rt,getSimpleQuotes:()=>yt,getTodayTimeline:()=>St,getTradingCalendar:()=>wt,getUSCodeList:()=>Ot,getUSQuotes:()=>de,parseFullQuote:()=>Je,parseFundFlow:()=>Ze,parseFundQuote:()=>rt,parseHKQuote:()=>tt,parsePanelLargeOrder:()=>et,parseSimpleQuote:()=>Xe,parseUSQuote:()=>nt,search:()=>_t});function Je(t){let e=[];for(let s=0;s<5;s++)e.push({price:h(t[9+s*2]),volume:h(t[10+s*2])});let n=[];for(let s=0;s<5;s++)n.push({price:h(t[19+s*2]),volume:h(t[20+s*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 Xe(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 Ze(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 et(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function tt(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 nt(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 rt(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 pe(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>Je(s.fields))}async function yt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`s_${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Xe(o.fields))}async function Ct(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`ff_${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Ze(o.fields))}async function Rt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`s_pk${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>et(o.fields))}async function fe(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`hk${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>tt(o.fields))}async function de(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`us${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>nt(o.fields))}async function bt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`jj${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>rt(o.fields))}async function St(t,e){let n=t.getTimeout(),s=new AbortController,o=setTimeout(()=>s.abort(),n);try{let r=await fetch(`${we}?code=${e}`,{signal:s.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let i=await r.json();if(i.code!==0)throw new Error(i.msg||"API error");let l=i.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,b=parseFloat(m[3])||0,x=c?C*100:C,L=x>0?b/x:0;return{time:f,price:parseFloat(m[1])||0,volume:x,amount:b,avgPrice:Math.round(L*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(o)}}var ot=null,en=null,me=null,tn=null,he=null;function nn(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 Mt(t,e){let n=!1,s;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,s=e.market),!ot){let i=(await t.get(Le,{responseType:"json"}))?.list||[];ot=i,en=i.map(l=>l.replace(/^(sh|sz|bj)/,""))}let o=ot;return s&&(o=o.filter(r=>nn(r,s))),n?o.map(r=>r.replace(/^(sh|sz|bj)/,"")):o.slice()}var rn={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Ot(t,e){let n=!1,s;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,s=e.market),me||(me=(await t.get(_e,{responseType:"json"}))?.list||[],tn=me.map(i=>i.replace(/^\d{3}\./,"")));let o=me.slice();if(s){let r=rn[s];o=o.filter(i=>i.startsWith(r))}return n?o.map(r=>r.replace(/^\d{3}\./,"")):o}async function xt(t){return he||(he=(await t.get(Ie,{responseType:"json"}))?.list||[]),he.slice()}async function At(t,e,n={}){let{batchSize:s=W,concurrency:o=z,onProgress:r}=n;A(s,"batchSize"),A(o,"concurrency");let i=Math.min(s,G),l=D(e,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await pe(t,d);return u++,r&&r(u,a),m});return(await v(c,o)).flat()}async function Tt(t,e,n={}){let{batchSize:s=W,concurrency:o=z,onProgress:r}=n;A(s,"batchSize"),A(o,"concurrency");let i=Math.min(s,G),l=D(e,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await fe(t,d);return u++,r&&r(u,a),m});return(await v(c,o)).flat()}async function Kt(t,e,n={}){let{batchSize:s=W,concurrency:o=z,onProgress:r}=n;A(s,"batchSize"),A(o,"concurrency");let i=Math.min(s,G),l=D(e,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await de(t,d);return u++,r&&r(u,a),m});return(await v(c,o)).flat()}var Q=null;async function wt(t){if(Q)return Q.slice();let e=await t.get(gt);return!e||e.trim()===""?(Q=[],Q.slice()):(Q=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),Q.slice())}var Lt="https://smartbox.gtimg.cn/s3/";function on(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function sn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let s=n.split("~"),o=s[0]||"",r=s[1]||"",i=on(s[2]||""),l=s[4]||"";return{code:o+r,name:i,market:o,type:l}})}function ln(t){return new Promise((e,n)=>{let s=`${Lt}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=s,o.charset="utf-8",o.onload=()=>{let r=window.v_hint||"";document.body.removeChild(o),e(r)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function an(t,e){let n=`${Lt}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function un(){return typeof window<"u"&&typeof document<"u"}async function _t(t,e){if(!e||!e.trim())return[];let n;return un()?n=await ln(e):n=await an(t,e),sn(n)}var O={};Te(O,{getConceptConstituents:()=>qt,getConceptKline:()=>Nt,getConceptList:()=>lt,getConceptMinuteKline:()=>jt,getConceptSpot:()=>Ht,getHKHistoryKline:()=>Et,getHistoryKline:()=>It,getIndustryConstituents:()=>kt,getIndustryKline:()=>Dt,getIndustryList:()=>it,getIndustryMinuteKline:()=>vt,getIndustrySpot:()=>Pt,getMinuteKline:()=>Ut,getUSHistoryKline:()=>Bt});async function st(t,e,n,s,o=100,r){let i=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(o),fields:s}),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,i.length+f+1));i.push(...m),l++}while(i.length<a);return i}function U(t){let[e,n,s,o,r,i,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(s),high:y(o),low:y(r),volume:y(i),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function E(t,e,n){let s=`${e}?${n.toString()}`,o=await t.get(s,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function It(t,e,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;_(s),T(o);let l=e.replace(/^(sh|sz|bj)/,""),a=`${ce(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(s),fqt:K(o),secid:a,beg:r,end:i}),c=ue,{klines:p}=await E(t,c,u);return p.length===0?[]:p.map(d=>({...U(d),code:l}))}async function Ut(t,e,n={}){let{period:s="1",adjust:o="qfq",startDate:r="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;J(s),T(o);let l=e.replace(/^(sh|sz|bj)/,""),a=`${ce(e)}.${l}`;if(s==="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=i.replace("T"," ").slice(0,16);return d.map(f=>{let[C,b,x,L,F,B,j,$t]=f.split(",");return{time:C,open:y(b),close:y(x),high:y(L),low:y(F),volume:y(B),amount:y(j),avgPrice:y($t)}}).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:s,fqt:K(o||""),secid:a,beg:"0",end:"20500000"}),c=ue,{klines:p}=await E(t,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=i.replace("T"," ").slice(0,16);return p.map(g=>{let f=U(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function Et(t,e,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;_(s),T(o);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(s),fqt:K(o),secid:a,beg:r,end:i,lmt:"1000000"}),c=Ee,{klines:p,name:d}=await E(t,c,u);return p.length===0?[]:p.map(m=>({...U(m),code:l,name:d||""}))}async function Bt(t,e,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;_(s),T(o);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(s),fqt:K(o),secid:e,beg:r,end:i,lmt:"1000000"}),a=Be,{klines:u,name:c,code:p}=await E(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...U(g),code:d,name:m}))}function ge(t){let e=null;return{async getCode(n,s,o){if(s.startsWith("BK"))return s;if(!e){let i=await o(n);e=new Map(i.map(l=>[l.name,l.code]))}let r=e.get(s);if(!r)throw new Error(`${t.errorPrefix}: ${s}`);return r}}}async function ye(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},s=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await st(t,e.listUrl,n,s,100,(r,i)=>({rank:i,name:String(r.f14??""),code:String(r.f12??""),price:S(r.f2),change:S(r.f4),changePercent:S(r.f3),totalMarketCap:S(r.f20),turnoverRate:S(r.f8),riseCount:S(r.f104),fallCount:S(r.f105),leadingStock:r.f128?String(r.f128):null,leadingStockChangePercent:S(r.f136)}));return o.sort((r,i)=>(i.changePercent??0)-(r.changePercent??0)),o.forEach((r,i)=>{r.rank=i+1}),o}async function Ce(t,e,n){let s=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${s.toString()}`,i=(await t.get(o,{responseType:"json"}))?.data;return i?[{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=i[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function Re(t,e,n){let s={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return st(t,n,s,"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,i)=>({rank:i,code:String(r.f12??""),name:String(r.f14??""),price:S(r.f2),changePercent:S(r.f3),change:S(r.f4),volume:S(r.f5),amount:S(r.f6),amplitude:S(r.f7),high:S(r.f15),low:S(r.f16),open:S(r.f17),prevClose:S(r.f18),turnoverRate:S(r.f8),pe:S(r.f9),pb:S(r.f23)}))}async function be(t,e,n,s={}){let{period:o="daily",adjust:r="",startDate:i="19700101",endDate:l="20500101"}=s;_(o),T(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(o),fqt:K(r),beg:i,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await E(t,n,a);return u.length===0?[]:u.map(c=>U(c))}async function Se(t,e,n,s,o={}){let{period:r="5"}=o;if(J(r),r==="1"){let i=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=`${s}?${i.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,b,x]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(b),price:y(x)}})}else{let i=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}?${i.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,b,x,L,F,B]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(L),change:y(F),volume:y(C),amount:y(b),amplitude:y(x),turnoverRate:y(B)}})}}var H={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Pe,spotUrl:ke,consUrl:De,klineUrl:ve,trendsUrl:He,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},cn=ge(H);async function Me(t,e){return cn.getCode(t,e,it)}async function it(t){return ye(t,H)}async function Pt(t,e){let n=await Me(t,e);return Ce(t,n,H.spotUrl)}async function kt(t,e){let n=await Me(t,e);return Re(t,n,H.consUrl)}async function Dt(t,e,n={}){let s=await Me(t,e);return be(t,s,H.klineUrl,n)}async function vt(t,e,n={}){let s=await Me(t,e);return Se(t,s,H.klineUrl,H.trendsUrl,n)}var q={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:qe,spotUrl:Ne,consUrl:je,klineUrl:Qe,trendsUrl:Fe,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},pn=ge(q);async function Oe(t,e){return pn.getCode(t,e,lt)}async function lt(t){return ye(t,q)}async function Ht(t,e){let n=await Oe(t,e);return Ce(t,n,q.spotUrl)}async function qt(t,e){let n=await Oe(t,e);return Re(t,n,q.consUrl)}async function Nt(t,e,n={}){let s=await Oe(t,e);return be(t,s,q.klineUrl,n)}async function jt(t,e,n={}){let s=await Oe(t,e);return Se(t,s,q.klineUrl,q.trendsUrl,n)}function X(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function P(t,e){let n=[];for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let o=0,r=0;for(let i=s-e+1;i<=s;i++)t[i]!==null&&(o+=t[i],r++);n.push(r===e?X(o/e):null)}return n}function w(t,e){let n=[],s=2/(e+1),o=null,r=!1;for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=i-e+1;c<=i;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(o=a/e,r=!0),n.push(o!==null?X(o):null);continue}let l=t[i];l===null?n.push(o!==null?X(o):null):(o=s*l+(1-s)*o,n.push(X(o)))}return n}function xe(t,e){let n=[],s=Array.from({length:e},(r,i)=>i+1),o=s.reduce((r,i)=>r+i,0);for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let i=0,l=!0;for(let a=0;a<e;a++){let u=t[r-e+1+a];if(u===null){l=!1;break}i+=u*s[a]}n.push(l?X(i/o):null)}return n}function Z(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:s="sma"}=e,o=s==="ema"?w:s==="wma"?xe:P,r={};for(let i of n)r[`ma${i}`]=o(t,i);return t.map((i,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function Qt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ee(t,e={}){let{short:n=12,long:s=26,signal:o=9}=e,r=w(t,n),i=w(t,s),l=t.map((u,c)=>r[c]===null||i[c]===null?null:r[c]-i[c]),a=w(l,o);return t.map((u,c)=>({dif:l[c]!==null?Qt(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?Qt((l[c]-a[c])*2):null}))}function at(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function fn(t,e,n){let s=[];for(let o=0;o<t.length;o++){if(o<e-1||n[o]===null){s.push(null);continue}let r=0,i=0;for(let l=o-e+1;l<=o;l++)t[l]!==null&&n[o]!==null&&(r+=Math.pow(t[l]-n[o],2),i++);s.push(i===e?Math.sqrt(r/e):null)}return s}function te(t,e={}){let{period:n=20,stdDev:s=2}=e,o=P(t,n),r=fn(t,n,o);return t.map((i,l)=>{if(o[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=o[l]+s*r[l],u=o[l]-s*r[l],c=o[l]!==0?at((a-u)/o[l]*100):null;return{mid:o[l],upper:at(a),lower:at(u),bandwidth:c}})}function ut(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ne(t,e={}){let{period:n=9,kPeriod:s=3,dPeriod:o=3}=e,r=[],i=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;i=(s-1)/s*i+1/s*m,l=(o-1)/o*l+1/o*i;let g=3*i-2*l;r.push({k:ut(i),d:ut(l),j:ut(g)})}return r}function dn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function re(t,e={}){let{periods:n=[6,12,24]}=e,s=[null];for(let r=1;r<t.length;r++)t[r]===null||t[r-1]===null?s.push(null):s.push(t[r]-t[r-1]);let o={};for(let r of n){let i=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<r){i.push(null),s[u]!==null&&(s[u]>0?l+=s[u]:a+=Math.abs(s[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=s[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)i.push(100);else if(l===0)i.push(0);else{let c=l/a;i.push(dn(100-100/(1+c)))}}o[`rsi${r}`]=i}return t.map((r,i)=>{let l={};for(let a of n)l[`rsi${a}`]=o[`rsi${a}`][i];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,s={};for(let o of n){let r=[];for(let i=0;i<t.length;i++){if(i<o-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=i-o+1;d<=i;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[i].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(mn(p))}s[`wr${o}`]=r}return t.map((o,r)=>{let i={};for(let l of n)i[`wr${l}`]=s[`wr${l}`][r];return i})}function hn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function se(t,e={}){let{periods:n=[6,12,24]}=e,s={};for(let o of n){let r=P(t,o),i=[];for(let l=0;l<t.length;l++)if(t[l]===null||r[l]===null||r[l]===0)i.push(null);else{let a=(t[l]-r[l])/r[l]*100;i.push(hn(a))}s[`bias${o}`]=i}return t.map((o,r)=>{let i={};for(let l of n)i[`bias${l}`]=s[`bias${l}`][r];return i})}function gn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ie(t,e={}){let{period:n=14}=e,s=[],o=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){s.push({cci:null});continue}let i=0,l=0;for(let p=r-n+1;p<=r;p++)o[p]!==null&&(i+=o[p],l++);if(l!==n||o[r]===null){s.push({cci:null});continue}let a=i/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(o[p]-a);let c=u/n;if(c===0)s.push({cci:0});else{let p=(o[r]-a)/(.015*c);s.push({cci:gn(p)})}}return s}function ct(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function N(t,e={}){let{period:n=14}=e,s=[],o=[];for(let i=0;i<t.length;i++){let{high:l,low:a,close:u}=t[i];if(l===null||a===null||u===null){o.push(null);continue}if(i===0)o.push(l-a);else{let c=t[i-1].close;if(c===null)o.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);o.push(Math.max(p,d,m))}}}let r=null;for(let i=0;i<t.length;i++){if(i<n-1){s.push({tr:o[i]!==null?ct(o[i]):null,atr:null});continue}if(i===n-1){let l=0,a=0;for(let u=0;u<n;u++)o[u]!==null&&(l+=o[u],a++);a===n&&(r=l/n)}else r!==null&&o[i]!==null&&(r=(r*(n-1)+o[i])/n);s.push({tr:o[i]!==null?ct(o[i]):null,atr:r!==null?ct(r):null})}return s}function pt(t,e={}){let{maPeriod:n}=e,s=[];if(t.length===0)return s;let o=t[0].volume??0;s.push({obv:o,obvMa:null});for(let r=1;r<t.length;r++){let i=t[r],l=t[r-1];if(i.close===null||l.close===null||i.volume===null||i.volume===void 0){s.push({obv:null,obvMa:null});continue}i.close>l.close?o+=i.volume:i.close<l.close&&(o-=i.volume),s.push({obv:o,obvMa:null})}if(n&&n>0)for(let r=n-1;r<s.length;r++){let i=0,l=0;for(let a=r-n+1;a<=r;a++)s[a].obv!==null&&(i+=s[a].obv,l++);l===n&&(s[r].obvMa=i/n)}return s}function ft(t,e={}){let{period:n=12,signalPeriod:s}=e,o=[];for(let r=0;r<t.length;r++){if(r<n){o.push({roc:null,signal:null});continue}let i=t[r].close,l=t[r-n].close;if(i===null||l===null||l===0){o.push({roc:null,signal:null});continue}let a=(i-l)/l*100;o.push({roc:a,signal:null})}if(s&&s>0)for(let r=n+s-1;r<o.length;r++){let i=0,l=0;for(let a=r-s+1;a<=r;a++)o[a].roc!==null&&(i+=o[a].roc,l++);l===s&&(o[r].signal=i/s)}return o}function dt(t,e={}){let{period:n=14,adxPeriod:s=n}=e,o=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],i=[],l=[];for(let f=0;f<t.length;f++){if(f===0){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],b=t[f-1];if(C.high===null||C.low===null||C.close===null||b.high===null||b.low===null||b.close===null){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let x=C.high-C.low,L=Math.abs(C.high-b.close),F=Math.abs(C.low-b.close);l.push(Math.max(x,L,F));let B=C.high-b.high,j=b.low-C.low;B>j&&B>0?r.push(B):r.push(0),j>B&&j>0?i.push(j):i.push(0),o.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+=i[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+i[f]);let C=a>0?u/a*100:0,b=a>0?c/a*100:0;o[f].pdi=C,o[f].mdi=b;let x=C+b,L=x>0?Math.abs(C-b)/x*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/s,o[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(s-1)+C)/s,o[f].adx=g}}for(let f=n*2-1+s;f<t.length;f++){let C=o[f].adx,b=o[f-s]?.adx;C!==null&&b!==null&&(o[f].adxr=(C+b)/2)}return o}function mt(t,e={}){let{afStart:n=.02,afIncrement:s=.02,afMax:o=.2}=e,r=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=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&&(i=-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);i===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(i=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+s,o))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(i=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+s,o))),u=f,r.push({sar:u,trend:i,ep:a,af:l})}return r}function ht(t,e={}){let{emaPeriod:n=20,atrPeriod:s=10,multiplier:o=2}=e,r=[],i=t.map(u=>u.close),l=w(i,n),a=N(t,{period:s});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+o*p,m=c-o*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function le(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),s=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),o=e.ma?Z(n,typeof e.ma=="object"?e.ma:{}):null,r=e.macd?ee(n,typeof e.macd=="object"?e.macd:{}):null,i=e.boll?te(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?ne(s,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?re(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?oe(s,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?se(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?ie(s,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?N(s,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...o&&{ma:o[g]},...r&&{macd:r[g]},...i&&{boll:i[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 ae=class{constructor(e={}){this.client=new Y(e)}getFullQuotes(e){return M.getFullQuotes(this.client,e)}getSimpleQuotes(e){return M.getSimpleQuotes(this.client,e)}getHKQuotes(e){return M.getHKQuotes(this.client,e)}getUSQuotes(e){return M.getUSQuotes(this.client,e)}getFundQuotes(e){return M.getFundQuotes(this.client,e)}getFundFlow(e){return M.getFundFlow(this.client,e)}getPanelLargeOrder(e){return M.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return M.getTodayTimeline(this.client,e)}getIndustryList(){return O.getIndustryList(this.client)}getIndustrySpot(e){return O.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return O.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return O.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return O.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return O.getConceptList(this.client)}getConceptSpot(e){return O.getConceptSpot(this.client,e)}getConceptConstituents(e){return O.getConceptConstituents(this.client,e)}getConceptKline(e,n){return O.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return O.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return O.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return O.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return O.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return O.getUSHistoryKline(this.client,e,n)}search(e){return M.search(this.client,e)}getAShareCodeList(e){return M.getAShareCodeList(this.client,e)}getUSCodeList(e){return M.getUSCodeList(this.client,e)}getHKCodeList(){return M.getHKCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...s}=e,o=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(o,s)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return M.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...s}=e,o=await this.getUSCodeList({simple:!0,market:n});return M.getAllUSQuotesByCodes(this.client,o,s)}getAllQuotesByCodes(e,n={}){return M.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return M.getTradingCalendar(this.client)}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,s=!1;if(e.ma){let r=typeof e.ma=="object"?e.ma:{},i=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(i,20)),l==="ema"&&(s=!0)}if(e.macd){let r=typeof e.macd=="object"?e.macd:{},i=r.long??26,l=r.signal??9;n=Math.max(n,i*3+l),s=!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*(s?1.5:1.2))}calcActualStartDate(e,n,s=1.5){let o=Math.ceil(n*s),r=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));r.setDate(r.getDate()-o);let i=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${i}${l}${a}`}calcActualStartDateByCalendar(e,n,s){if(!s||s.length===0)return;let o=this.normalizeDate(e),r=s.findIndex(l=>l>=o);r===-1&&(r=s.length-1);let i=Math.max(0,r-n);return this.toCompactDate(s[i])}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:s,endDate:o,indicators:r={}}=n,i=n.market??this.detectMarket(e),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(s)if(i==="A")try{let m=await M.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(s,l,m)??this.calcActualStartDate(s,l,a[i])}catch{u=this.calcActualStartDate(s,l,a[i])}else u=this.calcActualStartDate(s,l,a[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(i){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(s&&p.length<l)switch(i){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=le(p,r);if(s){let m=this.dateToTimestamp(s),g=o?this.dateToTimestamp(o):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},Ft=ae;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 _e=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var n in t)_e(e,n,{get:t[n],enumerable:!0})},Jt=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yt(t))!Xt.call(e,o)&&o!==n&&_e(e,o,{get:()=>t[o],enumerable:!(s=zt(t,o))||s.enumerable});return e};var Zt=e=>Jt(_e({},"__esModule",{value:!0}),e);var bn={};Ee(bn,{HttpError:()=>B,StockSDK:()=>ue,addIndicators:()=>ae,asyncPool:()=>v,calcATR:()=>j,calcBIAS:()=>ie,calcBOLL:()=>ne,calcCCI:()=>le,calcDMI:()=>ht,calcEMA:()=>x,calcKC:()=>yt,calcKDJ:()=>re,calcMA:()=>ee,calcMACD:()=>te,calcOBV:()=>dt,calcROC:()=>mt,calcRSI:()=>oe,calcSAR:()=>gt,calcSMA:()=>D,calcWMA:()=>Me,calcWR:()=>se,chunkArray:()=>k,decodeGBK:()=>V,default:()=>Wt,parseResponse:()=>W,safeNumber:()=>h,safeNumberOrNull:()=>C});module.exports=Zt(bn);function V(e){return new TextDecoder("gbk").decode(e)}function W(e){let t=e.split(";").map(s=>s.trim()).filter(Boolean),n=[];for(let s of t){let o=s.indexOf("=");if(o<0)continue;let r=s.slice(0,o).trim();r.startsWith("v_")&&(r=r.slice(2));let i=s.slice(o+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let l=i.split("~");n.push({key:r,fields:l})}return n}function h(e){if(!e||e==="")return 0;let t=parseFloat(e);return Number.isNaN(t)?0:t}function C(e){if(!e||e==="")return null;let t=parseFloat(e);return Number.isNaN(t)?null:t}function y(e){if(!e||e===""||e==="-")return null;let t=parseFloat(e);return Number.isNaN(t)?null:t}function b(e){return e==null?null:y(String(e))}var xe="https://qt.gtimg.cn",Ie="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Ke="https://assets.linkdiary.cn/shares/zh_a_list.json",Le="https://assets.linkdiary.cn/shares/us_list.json",Pe="https://assets.linkdiary.cn/shares/hk_list.json",Rt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ce="https://push2his.eastmoney.com/api/qt/stock/kline/get",we="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ue="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",ke="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",je="https://91.push2.eastmoney.com/api/qt/stock/get",Qe="https://29.push2.eastmoney.com/api/qt/clist/get",Fe="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",$e="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ve="https://datacenter-web.eastmoney.com/api/data/v1/get",We=3e4,G=500,z=500,Y=7,Ge=3,ze=1e3,Ye=3e4,Xe=2,Je=[408,429,500,502,503,504];var B=class extends Error{constructor(n,s,o,r){let i=s?` ${s}`:"",l=o?`, url: ${o}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${i}${l}${a}`);this.status=n;this.statusText=s;this.url=o;this.provider=r;this.name="HttpError"}},X=class{constructor(t={}){this.baseUrl=t.baseUrl??xe,this.timeout=t.timeout??We,this.retryOptions=this.resolveRetryOptions(t.retry),this.headers={...t.headers??{}},t.userAgent&&(Object.keys(this.headers).some(s=>s.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=t.userAgent))}resolveRetryOptions(t){return{maxRetries:t?.maxRetries??Ge,baseDelay:t?.baseDelay??ze,maxDelay:t?.maxDelay??Ye,backoffMultiplier:t?.backoffMultiplier??Xe,retryableStatusCodes:t?.retryableStatusCodes??Je,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}inferProvider(t){try{let n=new URL(t).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(t){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,t),this.retryOptions.maxDelay)+Math.random()*100}sleep(t){return new Promise(n=>setTimeout(n,t))}shouldRetry(t,n){return n>=this.retryOptions.maxRetries?!1:t instanceof DOMException&&t.name==="AbortError"?this.retryOptions.retryOnTimeout:t instanceof TypeError?this.retryOptions.retryOnNetworkError:t instanceof B?this.retryOptions.retryableStatusCodes.includes(t.status):!1}async executeWithRetry(t,n=0){try{return await t()}catch(s){if(this.shouldRetry(s,n)){let o=this.calculateDelay(n);return this.retryOptions.onRetry&&s instanceof Error&&this.retryOptions.onRetry(n+1,s,o),await this.sleep(o),this.executeWithRetry(t,n+1)}throw s}}async get(t,n={}){return this.executeWithRetry(async()=>{let s=new AbortController,o=setTimeout(()=>s.abort(),this.timeout),r=this.inferProvider(t);try{let i=await fetch(t,{signal:s.signal,headers:{...this.headers}});if(!i.ok)throw new B(i.status,i.statusText,t,r);switch(n.responseType){case"json":return await i.json();case"arraybuffer":return await i.arrayBuffer();default:return await i.text()}}catch(i){throw i instanceof Error&&(i.url=t,i.provider=r),i}finally{clearTimeout(o)}})}async getTencentQuote(t){let n=`${this.baseUrl}/?q=${encodeURIComponent(t)}`,s=await this.get(n,{responseType:"arraybuffer"}),o=V(s);return W(o)}};var en=new Set(["daily","weekly","monthly"]),tn=new Set(["1","5","15","30","60"]),nn=new Set(["","qfq","hfq"]);function M(e,t){if(!Number.isFinite(e)||!Number.isInteger(e)||e<=0)throw new RangeError(`${t} must be a positive integer`)}function K(e){if(!en.has(e))throw new RangeError("period must be one of: daily, weekly, monthly")}function J(e){if(!tn.has(e))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function _(e){if(!nn.has(e))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function k(e,t){M(t,"chunkSize");let n=[];for(let s=0;s<e.length;s+=t)n.push(e.slice(s,s+t));return n}async function v(e,t){M(t,"concurrency");let n=[],s=[];for(let o of e){let r=Promise.resolve().then(()=>o()).then(i=>{n.push(i)});if(s.push(r),s.length>=t){await Promise.race(s);for(let i=s.length-1;i>=0;i--)await Promise.race([s[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&s.splice(i,1)}}return await Promise.all(s),n}function pe(e){return e.startsWith("sh")?"1":e.startsWith("sz")||e.startsWith("bj")?"0":e.startsWith("6")?"1":"0"}function L(e){return{daily:"101",weekly:"102",monthly:"103"}[e]}function E(e){return{"":"0",qfq:"1",hfq:"2"}[e]}var A={};Ee(A,{getAShareCodeList:()=>Ot,getAllHKQuotesByCodes:()=>xt,getAllQuotesByCodes:()=>Et,getAllUSQuotesByCodes:()=>It,getFullQuotes:()=>fe,getFundFlow:()=>St,getFundQuotes:()=>At,getHKCodeList:()=>_t,getHKQuotes:()=>de,getPanelLargeOrder:()=>bt,getSimpleQuotes:()=>Ct,getTodayTimeline:()=>Tt,getTradingCalendar:()=>Kt,getUSCodeList:()=>Mt,getUSQuotes:()=>me,parseFullQuote:()=>Ze,parseFundFlow:()=>tt,parseFundQuote:()=>st,parseHKQuote:()=>rt,parsePanelLargeOrder:()=>nt,parseSimpleQuote:()=>et,parseUSQuote:()=>ot,search:()=>Pt});function Ze(e){let t=[];for(let s=0;s<5;s++)t.push({price:h(e[9+s*2]),volume:h(e[10+s*2])});let n=[];for(let s=0;s<5;s++)n.push({price:h(e[19+s*2]),volume:h(e[20+s*2])});return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),prevClose:h(e[4]),open:h(e[5]),volume:h(e[6]),outerVolume:h(e[7]),innerVolume:h(e[8]),bid:t,ask:n,time:e[30]??"",change:h(e[31]),changePercent:h(e[32]),high:h(e[33]),low:h(e[34]),volume2:h(e[36]),amount:h(e[37]),turnoverRate:C(e[38]),pe:C(e[39]),amplitude:C(e[43]),circulatingMarketCap:C(e[44]),totalMarketCap:C(e[45]),pb:C(e[46]),limitUp:C(e[47]),limitDown:C(e[48]),volumeRatio:C(e[49]),avgPrice:C(e[51]),peStatic:C(e[52]),peDynamic:C(e[53]),high52w:C(e[67]),low52w:C(e[68]),circulatingShares:C(e[72]),totalShares:C(e[73]),raw:e}}function et(e){return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),change:h(e[4]),changePercent:h(e[5]),volume:h(e[6]),amount:h(e[7]),marketCap:C(e[9]),marketType:e[10]??"",raw:e}}function tt(e){return{code:e[0]??"",mainInflow:h(e[1]),mainOutflow:h(e[2]),mainNet:h(e[3]),mainNetRatio:h(e[4]),retailInflow:h(e[5]),retailOutflow:h(e[6]),retailNet:h(e[7]),retailNetRatio:h(e[8]),totalFlow:h(e[9]),name:e[12]??"",date:e[13]??"",raw:e}}function nt(e){return{buyLargeRatio:h(e[0]),buySmallRatio:h(e[1]),sellLargeRatio:h(e[2]),sellSmallRatio:h(e[3]),raw:e}}function rt(e){return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),prevClose:h(e[4]),open:h(e[5]),volume:h(e[6]),time:e[30]??"",change:h(e[31]),changePercent:h(e[32]),high:h(e[33]),low:h(e[34]),amount:h(e[37]),lotSize:C(e[40]),circulatingMarketCap:C(e[44]),totalMarketCap:C(e[45]),currency:e[e.length-3]??"",raw:e}}function ot(e){return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),prevClose:h(e[4]),open:h(e[5]),volume:h(e[6]),time:e[30]??"",change:h(e[31]),changePercent:h(e[32]),high:h(e[33]),low:h(e[34]),amount:h(e[37]),turnoverRate:C(e[38]),pe:C(e[39]),amplitude:C(e[43]),totalMarketCap:C(e[45]),pb:C(e[47]),high52w:C(e[48]),low52w:C(e[49]),raw:e}}function st(e){return{code:e[0]??"",name:e[1]??"",nav:h(e[5]),accNav:h(e[6]),change:h(e[7]),navDate:e[8]??"",raw:e}}async function fe(e,t){return!t||t.length===0?[]:(await e.getTencentQuote(t.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>Ze(s.fields))}async function Ct(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`s_${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>et(o.fields))}async function St(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`ff_${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>tt(o.fields))}async function bt(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`s_pk${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>nt(o.fields))}async function de(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`hk${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>rt(o.fields))}async function me(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`us${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>ot(o.fields))}async function At(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`jj${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>st(o.fields))}async function Tt(e,t){let n=e.getTimeout(),s=new AbortController,o=setTimeout(()=>s.abort(),n);try{let r=await fetch(`${Ie}?code=${t}`,{signal:s.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let i=await r.json();if(i.code!==0)throw new Error(i.msg||"API error");let l=i.data?.[t];if(!l)return{code:t,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)}`,R=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?R*100:R,I=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(I*100)/100}});return{code:t,date:u,data:p}}finally{clearTimeout(o)}}var it=null,rn=null,he=null,on=null,ge=null;function sn(e,t){let n=e.replace(/^(sh|sz|bj)/,"");switch(t){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(e,t){let n=!1,s;if(typeof t=="boolean"?n=!t:t&&(n=t.simple??!1,s=t.market),!it){let i=(await e.get(Ke,{responseType:"json"}))?.list||[];it=i,rn=i.map(l=>l.replace(/^(sh|sz|bj)/,""))}let o=it;return s&&(o=o.filter(r=>sn(r,s))),n?o.map(r=>r.replace(/^(sh|sz|bj)/,"")):o.slice()}var ln={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Mt(e,t){let n=!1,s;typeof t=="boolean"?n=!t:t&&(n=t.simple??!1,s=t.market),he||(he=(await e.get(Le,{responseType:"json"}))?.list||[],on=he.map(i=>i.replace(/^\d{3}\./,"")));let o=he.slice();if(s){let r=ln[s];o=o.filter(i=>i.startsWith(r))}return n?o.map(r=>r.replace(/^\d{3}\./,"")):o}async function _t(e){return ge||(ge=(await e.get(Pe,{responseType:"json"}))?.list||[]),ge.slice()}async function Et(e,t,n={}){let{batchSize:s=G,concurrency:o=Y,onProgress:r}=n;M(s,"batchSize"),M(o,"concurrency");let i=Math.min(s,z),l=k(t,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await fe(e,d);return u++,r&&r(u,a),m});return(await v(c,o)).flat()}async function xt(e,t,n={}){let{batchSize:s=G,concurrency:o=Y,onProgress:r}=n;M(s,"batchSize"),M(o,"concurrency");let i=Math.min(s,z),l=k(t,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await de(e,d);return u++,r&&r(u,a),m});return(await v(c,o)).flat()}async function It(e,t,n={}){let{batchSize:s=G,concurrency:o=Y,onProgress:r}=n;M(s,"batchSize"),M(o,"concurrency");let i=Math.min(s,z),l=k(t,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await me(e,d);return u++,r&&r(u,a),m});return(await v(c,o)).flat()}var F=null;async function Kt(e){if(F)return F.slice();let t=await e.get(Rt);return!t||t.trim()===""?(F=[],F.slice()):(F=t.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),F.slice())}var Lt="https://smartbox.gtimg.cn/s3/";function an(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,n)=>String.fromCharCode(parseInt(n,16)))}function un(e){return!e||e==="N"?[]:e.split("^").filter(Boolean).map(n=>{let s=n.split("~"),o=s[0]||"",r=s[1]||"",i=an(s[2]||""),l=s[4]||"";return{code:o+r,name:i,market:o,type:l}})}function cn(e){return new Promise((t,n)=>{let s=`${Lt}?v=2&t=all&q=${encodeURIComponent(e)}`;window.v_hint="";let o=document.createElement("script");o.src=s,o.charset="utf-8",o.onload=()=>{let r=window.v_hint||"";document.body.removeChild(o),t(r)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function pn(e,t){let n=`${Lt}?v=2&t=all&q=${encodeURIComponent(t)}`,o=(await e.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function fn(){return typeof window<"u"&&typeof document<"u"}async function Pt(e,t){if(!t||!t.trim())return[];let n;return fn()?n=await cn(t):n=await pn(e,t),un(n)}var T={};Ee(T,{getConceptConstituents:()=>jt,getConceptKline:()=>Qt,getConceptList:()=>ut,getConceptMinuteKline:()=>Ft,getConceptSpot:()=>qt,getDividendDetail:()=>$t,getHKHistoryKline:()=>Dt,getHistoryKline:()=>wt,getIndustryConstituents:()=>vt,getIndustryKline:()=>Nt,getIndustryList:()=>at,getIndustryMinuteKline:()=>Ht,getIndustrySpot:()=>kt,getMinuteKline:()=>Ut,getUSHistoryKline:()=>Bt});async function lt(e,t,n,s,o=100,r){let i=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(o),fields:s}),c=`${t}?${u.toString()}`,d=(await e.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,i.length+f+1));i.push(...m),l++}while(i.length<a);return i}function P(e){let[t,n,s,o,r,i,l,a,u,c,p]=e.split(",");return{date:t,open:y(n),close:y(s),high:y(o),low:y(r),volume:y(i),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function w(e,t,n){let s=`${t}?${n.toString()}`,o=await e.get(s,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function wt(e,t,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;K(s),_(o);let l=t.replace(/^(sh|sz|bj)/,""),a=`${pe(t)}.${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:L(s),fqt:E(o),secid:a,beg:r,end:i}),c=ce,{klines:p}=await w(e,c,u);return p.length===0?[]:p.map(d=>({...P(d),code:l}))}async function Ut(e,t,n={}){let{period:s="1",adjust:o="qfq",startDate:r="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;J(s),_(o);let l=t.replace(/^(sh|sz|bj)/,""),a=`${pe(t)}.${l}`;if(s==="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=`${we}?${u.toString()}`,d=(await e.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=r.replace("T"," ").slice(0,16),g=i.replace("T"," ").slice(0,16);return d.map(f=>{let[R,S,O,I,$,U,Q,Gt]=f.split(",");return{time:R,open:y(S),close:y(O),high:y(I),low:y($),volume:y(U),amount:y(Q),avgPrice:y(Gt)}}).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:s,fqt:E(o||""),secid:a,beg:"0",end:"20500000"}),c=ce,{klines:p}=await w(e,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=i.replace("T"," ").slice(0,16);return p.map(g=>{let f=P(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function Dt(e,t,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;K(s),_(o);let l=t.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:L(s),fqt:E(o),secid:a,beg:r,end:i,lmt:"1000000"}),c=Ue,{klines:p,name:d}=await w(e,c,u);return p.length===0?[]:p.map(m=>({...P(m),code:l,name:d||""}))}async function Bt(e,t,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;K(s),_(o);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:L(s),fqt:E(o),secid:t,beg:r,end:i,lmt:"1000000"}),a=De,{klines:u,name:c,code:p}=await w(e,a,l),d=p||t.split(".")[1]||t,m=c||"";return u.length===0?[]:u.map(g=>({...P(g),code:d,name:m}))}function ye(e){let t=null;return{async getCode(n,s,o){if(s.startsWith("BK"))return s;if(!t){let i=await o(n);t=new Map(i.map(l=>[l.name,l.code]))}let r=t.get(s);if(!r)throw new Error(`${e.errorPrefix}: ${s}`);return r}}}async function Re(e,t){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:t.type==="concept"?"f12":"f3",fs:t.fsFilter},s=t.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await lt(e,t.listUrl,n,s,100,(r,i)=>({rank:i,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 o.sort((r,i)=>(i.changePercent??0)-(r.changePercent??0)),o.forEach((r,i)=>{r.rank=i+1}),o}async function Ce(e,t,n){let s=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${t}`}),o=`${n}?${s.toString()}`,i=(await e.get(o,{responseType:"json"}))?.data;return i?[{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=i[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function Se(e,t,n){let s={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${t} f:!50`};return lt(e,n,s,"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,i)=>({rank:i,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 be(e,t,n,s={}){let{period:o="daily",adjust:r="",startDate:i="19700101",endDate:l="20500101"}=s;K(o),_(r);let a=new URLSearchParams({secid:`90.${t}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:L(o),fqt:E(r),beg:i,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await w(e,n,a);return u.length===0?[]:u.map(c=>P(c))}async function Ae(e,t,n,s,o={}){let{period:r="5"}=o;if(J(r),r==="1"){let i=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.${t}`}),l=`${s}?${i.toString()}`,u=(await e.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,R,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(R),amount:y(S),price:y(O)}})}else{let i=new URLSearchParams({secid:`90.${t}`,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}?${i.toString()}`,u=(await e.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,R,S,O,I,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(I),change:y($),volume:y(R),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var N={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Be,spotUrl:ke,consUrl:ve,klineUrl:Ne,trendsUrl:He,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},dn=ye(N);async function Te(e,t){return dn.getCode(e,t,at)}async function at(e){return Re(e,N)}async function kt(e,t){let n=await Te(e,t);return Ce(e,n,N.spotUrl)}async function vt(e,t){let n=await Te(e,t);return Se(e,n,N.consUrl)}async function Nt(e,t,n={}){let s=await Te(e,t);return be(e,s,N.klineUrl,n)}async function Ht(e,t,n={}){let s=await Te(e,t);return Ae(e,s,N.klineUrl,N.trendsUrl,n)}var H={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:qe,spotUrl:je,consUrl:Qe,klineUrl:Fe,trendsUrl:$e,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},mn=ye(H);async function Oe(e,t){return mn.getCode(e,t,ut)}async function ut(e){return Re(e,H)}async function qt(e,t){let n=await Oe(e,t);return Ce(e,n,H.spotUrl)}async function jt(e,t){let n=await Oe(e,t);return Se(e,n,H.consUrl)}async function Qt(e,t,n={}){let s=await Oe(e,t);return be(e,s,H.klineUrl,n)}async function Ft(e,t,n={}){let s=await Oe(e,t);return Ae(e,s,H.klineUrl,H.trendsUrl,n)}function q(e){if(!e)return null;let t=e.match(/^(\d{4}-\d{2}-\d{2})/);return t?t[1]:null}function hn(e){return{code:e.SECURITY_CODE??"",name:e.SECURITY_NAME_ABBR??"",reportDate:q(e.REPORT_DATE),planNoticeDate:q(e.PLAN_NOTICE_DATE),disclosureDate:q(e.PUBLISH_DATE??e.PLAN_NOTICE_DATE),assignTransferRatio:e.BONUS_IT_RATIO??null,bonusRatio:e.BONUS_RATIO??null,transferRatio:e.IT_RATIO??null,dividendPretax:e.PRETAX_BONUS_RMB??null,dividendDesc:e.IMPL_PLAN_PROFILE??null,dividendYield:e.DIVIDENT_RATIO??null,eps:e.BASIC_EPS??null,bps:e.BVPS??null,capitalReserve:e.PER_CAPITAL_RESERVE??null,unassignedProfit:e.PER_UNASSIGN_PROFIT??null,netProfitYoy:e.PNP_YOY_RATIO??null,totalShares:e.TOTAL_SHARES??null,equityRecordDate:q(e.EQUITY_RECORD_DATE),exDividendDate:q(e.EX_DIVIDEND_DATE),payDate:q(e.PAY_DATE),assignProgress:e.ASSIGN_PROGRESS??null,noticeDate:q(e.NOTICE_DATE)}}async function $t(e,t){let n=t.replace(/^(sh|sz|bj)/,""),s=[],o=1,r=1;do{let i=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(o),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${Ve}?${i.toString()}`,u=(await e.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;o===1&&(r=u.pages??1);let c=u.data.map(hn);s.push(...c),o++}while(o<=r);return s}function Z(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function D(e,t){let n=[];for(let s=0;s<e.length;s++){if(s<t-1){n.push(null);continue}let o=0,r=0;for(let i=s-t+1;i<=s;i++)e[i]!==null&&(o+=e[i],r++);n.push(r===t?Z(o/t):null)}return n}function x(e,t){let n=[],s=2/(t+1),o=null,r=!1;for(let i=0;i<e.length;i++){if(i<t-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=i-t+1;c<=i;c++)e[c]!==null&&(a+=e[c],u++);u===t&&(o=a/t,r=!0),n.push(o!==null?Z(o):null);continue}let l=e[i];l===null?n.push(o!==null?Z(o):null):(o=s*l+(1-s)*o,n.push(Z(o)))}return n}function Me(e,t){let n=[],s=Array.from({length:t},(r,i)=>i+1),o=s.reduce((r,i)=>r+i,0);for(let r=0;r<e.length;r++){if(r<t-1){n.push(null);continue}let i=0,l=!0;for(let a=0;a<t;a++){let u=e[r-t+1+a];if(u===null){l=!1;break}i+=u*s[a]}n.push(l?Z(i/o):null)}return n}function ee(e,t={}){let{periods:n=[5,10,20,30,60,120,250],type:s="sma"}=t,o=s==="ema"?x:s==="wma"?Me:D,r={};for(let i of n)r[`ma${i}`]=o(e,i);return e.map((i,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function Vt(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function te(e,t={}){let{short:n=12,long:s=26,signal:o=9}=t,r=x(e,n),i=x(e,s),l=e.map((u,c)=>r[c]===null||i[c]===null?null:r[c]-i[c]),a=x(l,o);return e.map((u,c)=>({dif:l[c]!==null?Vt(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?Vt((l[c]-a[c])*2):null}))}function ct(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function gn(e,t,n){let s=[];for(let o=0;o<e.length;o++){if(o<t-1||n[o]===null){s.push(null);continue}let r=0,i=0;for(let l=o-t+1;l<=o;l++)e[l]!==null&&n[o]!==null&&(r+=Math.pow(e[l]-n[o],2),i++);s.push(i===t?Math.sqrt(r/t):null)}return s}function ne(e,t={}){let{period:n=20,stdDev:s=2}=t,o=D(e,n),r=gn(e,n,o);return e.map((i,l)=>{if(o[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=o[l]+s*r[l],u=o[l]-s*r[l],c=o[l]!==0?ct((a-u)/o[l]*100):null;return{mid:o[l],upper:ct(a),lower:ct(u),bandwidth:c}})}function pt(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function re(e,t={}){let{period:n=9,kPeriod:s=3,dPeriod:o=3}=t,r=[],i=50,l=50;for(let a=0;a<e.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(e[f].high===null||e[f].low===null){p=!1;break}u=Math.max(u,e[f].high),c=Math.min(c,e[f].low)}let d=e[a].close;if(!p||d===null||u===c){r.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;i=(s-1)/s*i+1/s*m,l=(o-1)/o*l+1/o*i;let g=3*i-2*l;r.push({k:pt(i),d:pt(l),j:pt(g)})}return r}function yn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function oe(e,t={}){let{periods:n=[6,12,24]}=t,s=[null];for(let r=1;r<e.length;r++)e[r]===null||e[r-1]===null?s.push(null):s.push(e[r]-e[r-1]);let o={};for(let r of n){let i=[],l=0,a=0;for(let u=0;u<e.length;u++){if(u<r){i.push(null),s[u]!==null&&(s[u]>0?l+=s[u]:a+=Math.abs(s[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=s[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)i.push(100);else if(l===0)i.push(0);else{let c=l/a;i.push(yn(100-100/(1+c)))}}o[`rsi${r}`]=i}return e.map((r,i)=>{let l={};for(let a of n)l[`rsi${a}`]=o[`rsi${a}`][i];return l})}function Rn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function se(e,t={}){let{periods:n=[6,10]}=t,s={};for(let o of n){let r=[];for(let i=0;i<e.length;i++){if(i<o-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=i-o+1;d<=i;d++){if(e[d].high===null||e[d].low===null){u=!1;break}l=Math.max(l,e[d].high),a=Math.min(a,e[d].low)}let c=e[i].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(Rn(p))}s[`wr${o}`]=r}return e.map((o,r)=>{let i={};for(let l of n)i[`wr${l}`]=s[`wr${l}`][r];return i})}function Cn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function ie(e,t={}){let{periods:n=[6,12,24]}=t,s={};for(let o of n){let r=D(e,o),i=[];for(let l=0;l<e.length;l++)if(e[l]===null||r[l]===null||r[l]===0)i.push(null);else{let a=(e[l]-r[l])/r[l]*100;i.push(Cn(a))}s[`bias${o}`]=i}return e.map((o,r)=>{let i={};for(let l of n)i[`bias${l}`]=s[`bias${l}`][r];return i})}function Sn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function le(e,t={}){let{period:n=14}=t,s=[],o=e.map(r=>r.high===null||r.low===null||r.close===null?null:(r.high+r.low+r.close)/3);for(let r=0;r<e.length;r++){if(r<n-1){s.push({cci:null});continue}let i=0,l=0;for(let p=r-n+1;p<=r;p++)o[p]!==null&&(i+=o[p],l++);if(l!==n||o[r]===null){s.push({cci:null});continue}let a=i/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(o[p]-a);let c=u/n;if(c===0)s.push({cci:0});else{let p=(o[r]-a)/(.015*c);s.push({cci:Sn(p)})}}return s}function ft(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function j(e,t={}){let{period:n=14}=t,s=[],o=[];for(let i=0;i<e.length;i++){let{high:l,low:a,close:u}=e[i];if(l===null||a===null||u===null){o.push(null);continue}if(i===0)o.push(l-a);else{let c=e[i-1].close;if(c===null)o.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);o.push(Math.max(p,d,m))}}}let r=null;for(let i=0;i<e.length;i++){if(i<n-1){s.push({tr:o[i]!==null?ft(o[i]):null,atr:null});continue}if(i===n-1){let l=0,a=0;for(let u=0;u<n;u++)o[u]!==null&&(l+=o[u],a++);a===n&&(r=l/n)}else r!==null&&o[i]!==null&&(r=(r*(n-1)+o[i])/n);s.push({tr:o[i]!==null?ft(o[i]):null,atr:r!==null?ft(r):null})}return s}function dt(e,t={}){let{maPeriod:n}=t,s=[];if(e.length===0)return s;let o=e[0].volume??0;s.push({obv:o,obvMa:null});for(let r=1;r<e.length;r++){let i=e[r],l=e[r-1];if(i.close===null||l.close===null||i.volume===null||i.volume===void 0){s.push({obv:null,obvMa:null});continue}i.close>l.close?o+=i.volume:i.close<l.close&&(o-=i.volume),s.push({obv:o,obvMa:null})}if(n&&n>0)for(let r=n-1;r<s.length;r++){let i=0,l=0;for(let a=r-n+1;a<=r;a++)s[a].obv!==null&&(i+=s[a].obv,l++);l===n&&(s[r].obvMa=i/n)}return s}function mt(e,t={}){let{period:n=12,signalPeriod:s}=t,o=[];for(let r=0;r<e.length;r++){if(r<n){o.push({roc:null,signal:null});continue}let i=e[r].close,l=e[r-n].close;if(i===null||l===null||l===0){o.push({roc:null,signal:null});continue}let a=(i-l)/l*100;o.push({roc:a,signal:null})}if(s&&s>0)for(let r=n+s-1;r<o.length;r++){let i=0,l=0;for(let a=r-s+1;a<=r;a++)o[a].roc!==null&&(i+=o[a].roc,l++);l===s&&(o[r].signal=i/s)}return o}function ht(e,t={}){let{period:n=14,adxPeriod:s=n}=t,o=[];if(e.length<2)return e.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],i=[],l=[];for(let f=0;f<e.length;f++){if(f===0){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let R=e[f],S=e[f-1];if(R.high===null||R.low===null||R.close===null||S.high===null||S.low===null||S.close===null){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=R.high-R.low,I=Math.abs(R.high-S.close),$=Math.abs(R.low-S.close);l.push(Math.max(O,I,$));let U=R.high-S.high,Q=S.low-R.low;U>Q&&U>0?r.push(U):r.push(0),Q>U&&Q>0?i.push(Q):i.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<e.length;f++){if(f<n){a+=l[f],u+=r[f],c+=i[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+i[f]);let R=a>0?u/a*100:0,S=a>0?c/a*100:0;o[f].pdi=R,o[f].mdi=S;let O=R+S,I=O>0?Math.abs(R-S)/O*100:0;p.push(I)}let d=0,m=0,g=0;for(let f=n;f<e.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/s,o[f].adx=g;else{let R=p[f-n+1]||0;g=(g*(s-1)+R)/s,o[f].adx=g}}for(let f=n*2-1+s;f<e.length;f++){let R=o[f].adx,S=o[f-s]?.adx;R!==null&&S!==null&&(o[f].adxr=(R+S)/2)}return o}function gt(e,t={}){let{afStart:n=.02,afIncrement:s=.02,afMax:o=.2}=t,r=[];if(e.length<2)return e.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=1,l=n,a=e[0].high??0,u=e[0].low??0,c=e[0],p=e[1];c.close!==null&&p.close!==null&&p.close<c.close&&(i=-1,a=c.low??0,u=c.high??0),r.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<e.length;d++){let m=e[d],g=e[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);i===1?(f=Math.min(f,g.low,e[Math.max(0,d-2)]?.low??g.low),m.low<f?(i=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+s,o))):(f=Math.max(f,g.high,e[Math.max(0,d-2)]?.high??g.high),m.high>f?(i=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+s,o))),u=f,r.push({sar:u,trend:i,ep:a,af:l})}return r}function yt(e,t={}){let{emaPeriod:n=20,atrPeriod:s=10,multiplier:o=2}=t,r=[],i=e.map(u=>u.close),l=x(i,n),a=j(e,{period:s});for(let u=0;u<e.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+o*p,m=c-o*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function ae(e,t={}){if(e.length===0)return[];let n=e.map(m=>m.close),s=e.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),o=t.ma?ee(n,typeof t.ma=="object"?t.ma:{}):null,r=t.macd?te(n,typeof t.macd=="object"?t.macd:{}):null,i=t.boll?ne(n,typeof t.boll=="object"?t.boll:{}):null,l=t.kdj?re(s,typeof t.kdj=="object"?t.kdj:{}):null,a=t.rsi?oe(n,typeof t.rsi=="object"?t.rsi:{}):null,u=t.wr?se(s,typeof t.wr=="object"?t.wr:{}):null,c=t.bias?ie(n,typeof t.bias=="object"?t.bias:{}):null,p=t.cci?le(s,typeof t.cci=="object"?t.cci:{}):null,d=t.atr?j(s,typeof t.atr=="object"?t.atr:{}):null;return e.map((m,g)=>({...m,...o&&{ma:o[g]},...r&&{macd:r[g]},...i&&{boll:i[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 ue=class{constructor(t={}){this.client=new X(t)}getFullQuotes(t){return A.getFullQuotes(this.client,t)}getSimpleQuotes(t){return A.getSimpleQuotes(this.client,t)}getHKQuotes(t){return A.getHKQuotes(this.client,t)}getUSQuotes(t){return A.getUSQuotes(this.client,t)}getFundQuotes(t){return A.getFundQuotes(this.client,t)}getFundFlow(t){return A.getFundFlow(this.client,t)}getPanelLargeOrder(t){return A.getPanelLargeOrder(this.client,t)}getTodayTimeline(t){return A.getTodayTimeline(this.client,t)}getIndustryList(){return T.getIndustryList(this.client)}getIndustrySpot(t){return T.getIndustrySpot(this.client,t)}getIndustryConstituents(t){return T.getIndustryConstituents(this.client,t)}getIndustryKline(t,n){return T.getIndustryKline(this.client,t,n)}getIndustryMinuteKline(t,n){return T.getIndustryMinuteKline(this.client,t,n)}getConceptList(){return T.getConceptList(this.client)}getConceptSpot(t){return T.getConceptSpot(this.client,t)}getConceptConstituents(t){return T.getConceptConstituents(this.client,t)}getConceptKline(t,n){return T.getConceptKline(this.client,t,n)}getConceptMinuteKline(t,n){return T.getConceptMinuteKline(this.client,t,n)}getHistoryKline(t,n){return T.getHistoryKline(this.client,t,n)}getMinuteKline(t,n){return T.getMinuteKline(this.client,t,n)}getHKHistoryKline(t,n){return T.getHKHistoryKline(this.client,t,n)}getUSHistoryKline(t,n){return T.getUSHistoryKline(this.client,t,n)}search(t){return A.search(this.client,t)}getAShareCodeList(t){return A.getAShareCodeList(this.client,t)}getUSCodeList(t){return A.getUSCodeList(this.client,t)}getHKCodeList(){return A.getHKCodeList(this.client)}async getAllAShareQuotes(t={}){let{market:n,...s}=t,o=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(o,s)}async getAllHKShareQuotes(t={}){let n=await this.getHKCodeList();return A.getAllHKQuotesByCodes(this.client,n,t)}async getAllUSShareQuotes(t={}){let{market:n,...s}=t,o=await this.getUSCodeList({simple:!0,market:n});return A.getAllUSQuotesByCodes(this.client,o,s)}getAllQuotesByCodes(t,n={}){return A.getAllQuotesByCodes(this.client,t,n)}async batchRaw(t){return this.client.getTencentQuote(t)}getTradingCalendar(){return A.getTradingCalendar(this.client)}getDividendDetail(t){return T.getDividendDetail(this.client,t)}detectMarket(t){return/^\d{3}\.[A-Z]+$/i.test(t)?"US":/^\d{5}$/.test(t)?"HK":"A"}safeMax(t,n=0){return!t||t.length===0?n:Math.max(...t)}calcRequiredLookback(t){let n=0,s=!1;if(t.ma){let r=typeof t.ma=="object"?t.ma:{},i=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(i,20)),l==="ema"&&(s=!0)}if(t.macd){let r=typeof t.macd=="object"?t.macd:{},i=r.long??26,l=r.signal??9;n=Math.max(n,i*3+l),s=!0}if(t.boll){let r=typeof t.boll=="object"&&t.boll.period?t.boll.period:20;n=Math.max(n,r)}if(t.kdj){let r=typeof t.kdj=="object"&&t.kdj.period?t.kdj.period:9;n=Math.max(n,r)}if(t.rsi){let r=typeof t.rsi=="object"&&t.rsi.periods?t.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(r,14)+1)}if(t.wr){let r=typeof t.wr=="object"&&t.wr.periods?t.wr.periods:[6,10];n=Math.max(n,this.safeMax(r,10))}if(t.bias){let r=typeof t.bias=="object"&&t.bias.periods?t.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(r,12))}if(t.cci){let r=typeof t.cci=="object"&&t.cci.period?t.cci.period:14;n=Math.max(n,r)}if(t.atr){let r=typeof t.atr=="object"&&t.atr.period?t.atr.period:14;n=Math.max(n,r)}return Math.ceil(n*(s?1.5:1.2))}calcActualStartDate(t,n,s=1.5){let o=Math.ceil(n*s),r=new Date(parseInt(t.slice(0,4)),parseInt(t.slice(4,6))-1,parseInt(t.slice(6,8)));r.setDate(r.getDate()-o);let i=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${i}${l}${a}`}calcActualStartDateByCalendar(t,n,s){if(!s||s.length===0)return;let o=this.normalizeDate(t),r=s.findIndex(l=>l>=o);r===-1&&(r=s.length-1);let i=Math.max(0,r-n);return this.toCompactDate(s[i])}normalizeDate(t){return t.includes("-")?t:t.length===8?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}toCompactDate(t){return t.replace(/-/g,"")}dateToTimestamp(t){let n=t.includes("-")?t:`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(t,n={}){let{startDate:s,endDate:o,indicators:r={}}=n,i=n.market??this.detectMarket(t),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(s)if(i==="A")try{let m=await A.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(s,l,m)??this.calcActualStartDate(s,l,a[i])}catch{u=this.calcActualStartDate(s,l,a[i])}else u=this.calcActualStartDate(s,l,a[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(i){case"HK":p=await this.getHKHistoryKline(t,c);break;case"US":p=await this.getUSHistoryKline(t,c);break;default:p=await this.getHistoryKline(t,c)}if(s&&p.length<l)switch(i){case"HK":p=await this.getHKHistoryKline(t,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(t,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(t,{...c,startDate:void 0})}let d=ae(p,r);if(s){let m=this.dateToTimestamp(s),g=o?this.dateToTimestamp(o):1/0;return d.filter(f=>{let R=this.dateToTimestamp(f.date);return R>=m&&R<=g})}return d}},Wt=ue;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
@@ -625,6 +625,55 @@ interface SearchResult {
625
625
  /** 资产类别 (GP-A/GP/KJ 等) */
626
626
  type: string;
627
627
  }
628
+ /**
629
+ * 分红派送详情
630
+ */
631
+ interface DividendDetail {
632
+ /** 股票代码 */
633
+ code: string;
634
+ /** 股票名称 */
635
+ name: string;
636
+ /** 报告期 YYYY-MM-DD */
637
+ reportDate: string | null;
638
+ /** 预案公告日 YYYY-MM-DD */
639
+ planNoticeDate: string | null;
640
+ /** 业绩披露日期 YYYY-MM-DD */
641
+ disclosureDate: string | null;
642
+ /** 送转总比例(每10股送转X股) */
643
+ assignTransferRatio: number | null;
644
+ /** 送股比例(每10股送X股) */
645
+ bonusRatio: number | null;
646
+ /** 转股比例(每10股转X股) */
647
+ transferRatio: number | null;
648
+ /** 每10股派息(税前),单位:元 */
649
+ dividendPretax: number | null;
650
+ /** 分红描述(如:10派2.36元(含税,扣税后2.124元)) */
651
+ dividendDesc: string | null;
652
+ /** 股息率 */
653
+ dividendYield: number | null;
654
+ /** 每股收益(元) */
655
+ eps: number | null;
656
+ /** 每股净资产(元) */
657
+ bps: number | null;
658
+ /** 每股公积金(元) */
659
+ capitalReserve: number | null;
660
+ /** 每股未分配利润(元) */
661
+ unassignedProfit: number | null;
662
+ /** 净利润同比增长(%) */
663
+ netProfitYoy: number | null;
664
+ /** 总股本(股) */
665
+ totalShares: number | null;
666
+ /** 股权登记日 YYYY-MM-DD */
667
+ equityRecordDate: string | null;
668
+ /** 除权除息日 YYYY-MM-DD */
669
+ exDividendDate: string | null;
670
+ /** 现金分红发放日 YYYY-MM-DD */
671
+ payDate: string | null;
672
+ /** 方案进度(如:实施分配、股东大会预案等) */
673
+ assignProgress: string | null;
674
+ /** 最新公告日期 YYYY-MM-DD */
675
+ noticeDate: string | null;
676
+ }
628
677
 
629
678
  /**
630
679
  * 腾讯财经 - 批量操作
@@ -1581,6 +1630,17 @@ declare class StockSDK {
1581
1630
  * @returns 交易日期字符串数组,格式如 ['1990-12-19', '1990-12-20', ...]
1582
1631
  */
1583
1632
  getTradingCalendar(): Promise<string[]>;
1633
+ /**
1634
+ * 获取股票分红派送详情
1635
+ * @param symbol - 股票代码(纯数字或带交易所前缀),如 '600519' 或 'sh600519'
1636
+ * @returns 分红派送详情列表,按报告日期降序排列
1637
+ *
1638
+ * @example
1639
+ * // 获取贵州茅台的分红历史
1640
+ * const dividends = await sdk.getDividendDetail('600519');
1641
+ * console.log(dividends[0].dividendPretax); // 每10股派息(税前)
1642
+ */
1643
+ getDividendDetail(symbol: string): Promise<DividendDetail[]>;
1584
1644
  /**
1585
1645
  * 市场类型识别
1586
1646
  */
@@ -1632,4 +1692,4 @@ declare class StockSDK {
1632
1692
  }): Promise<KlineWithIndicators<HistoryKline | HKUSHistoryKline>[]>;
1633
1693
  }
1634
1694
 
1635
- export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type FullQuote, type FundFlow, type FundQuote, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type PanelLargeOrder, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, parseResponse, safeNumber, safeNumberOrNull };
1695
+ export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DividendDetail, type FullQuote, type FundFlow, type FundQuote, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type PanelLargeOrder, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, parseResponse, safeNumber, safeNumberOrNull };
package/dist/index.d.ts CHANGED
@@ -625,6 +625,55 @@ interface SearchResult {
625
625
  /** 资产类别 (GP-A/GP/KJ 等) */
626
626
  type: string;
627
627
  }
628
+ /**
629
+ * 分红派送详情
630
+ */
631
+ interface DividendDetail {
632
+ /** 股票代码 */
633
+ code: string;
634
+ /** 股票名称 */
635
+ name: string;
636
+ /** 报告期 YYYY-MM-DD */
637
+ reportDate: string | null;
638
+ /** 预案公告日 YYYY-MM-DD */
639
+ planNoticeDate: string | null;
640
+ /** 业绩披露日期 YYYY-MM-DD */
641
+ disclosureDate: string | null;
642
+ /** 送转总比例(每10股送转X股) */
643
+ assignTransferRatio: number | null;
644
+ /** 送股比例(每10股送X股) */
645
+ bonusRatio: number | null;
646
+ /** 转股比例(每10股转X股) */
647
+ transferRatio: number | null;
648
+ /** 每10股派息(税前),单位:元 */
649
+ dividendPretax: number | null;
650
+ /** 分红描述(如:10派2.36元(含税,扣税后2.124元)) */
651
+ dividendDesc: string | null;
652
+ /** 股息率 */
653
+ dividendYield: number | null;
654
+ /** 每股收益(元) */
655
+ eps: number | null;
656
+ /** 每股净资产(元) */
657
+ bps: number | null;
658
+ /** 每股公积金(元) */
659
+ capitalReserve: number | null;
660
+ /** 每股未分配利润(元) */
661
+ unassignedProfit: number | null;
662
+ /** 净利润同比增长(%) */
663
+ netProfitYoy: number | null;
664
+ /** 总股本(股) */
665
+ totalShares: number | null;
666
+ /** 股权登记日 YYYY-MM-DD */
667
+ equityRecordDate: string | null;
668
+ /** 除权除息日 YYYY-MM-DD */
669
+ exDividendDate: string | null;
670
+ /** 现金分红发放日 YYYY-MM-DD */
671
+ payDate: string | null;
672
+ /** 方案进度(如:实施分配、股东大会预案等) */
673
+ assignProgress: string | null;
674
+ /** 最新公告日期 YYYY-MM-DD */
675
+ noticeDate: string | null;
676
+ }
628
677
 
629
678
  /**
630
679
  * 腾讯财经 - 批量操作
@@ -1581,6 +1630,17 @@ declare class StockSDK {
1581
1630
  * @returns 交易日期字符串数组,格式如 ['1990-12-19', '1990-12-20', ...]
1582
1631
  */
1583
1632
  getTradingCalendar(): Promise<string[]>;
1633
+ /**
1634
+ * 获取股票分红派送详情
1635
+ * @param symbol - 股票代码(纯数字或带交易所前缀),如 '600519' 或 'sh600519'
1636
+ * @returns 分红派送详情列表,按报告日期降序排列
1637
+ *
1638
+ * @example
1639
+ * // 获取贵州茅台的分红历史
1640
+ * const dividends = await sdk.getDividendDetail('600519');
1641
+ * console.log(dividends[0].dividendPretax); // 每10股派息(税前)
1642
+ */
1643
+ getDividendDetail(symbol: string): Promise<DividendDetail[]>;
1584
1644
  /**
1585
1645
  * 市场类型识别
1586
1646
  */
@@ -1632,4 +1692,4 @@ declare class StockSDK {
1632
1692
  }): Promise<KlineWithIndicators<HistoryKline | HKUSHistoryKline>[]>;
1633
1693
  }
1634
1694
 
1635
- export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type FullQuote, type FundFlow, type FundQuote, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type PanelLargeOrder, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, parseResponse, safeNumber, safeNumberOrNull };
1695
+ export { type AShareMarket, type ATROptions, type BIASOptions, type BOLLOptions, type CCIOptions, type ConceptBoard, type ConceptBoardConstituent, type ConceptBoardKline, type ConceptBoardKlineOptions, type ConceptBoardMinuteKline, type ConceptBoardMinuteKlineOptions, type ConceptBoardMinuteTimeline, type ConceptBoardSpot, type DMIOptions$1 as DMIOptions, type DMIResult$1 as DMIResult, type DividendDetail, type FullQuote, type FundFlow, type FundQuote, type GetAShareCodeListOptions, type GetAllAShareQuotesOptions, type HKQuote, type HKUSHistoryKline, type HistoryKline, HttpError, type IndicatorOptions, type IndustryBoard, type IndustryBoardConstituent, type IndustryBoardKline, type IndustryBoardKlineOptions, type IndustryBoardMinuteKline, type IndustryBoardMinuteKlineOptions, type IndustryBoardMinuteTimeline, type IndustryBoardSpot, type KCOptions$1 as KCOptions, type KCResult$1 as KCResult, type KDJOptions, type KlineWithIndicators, type MACDOptions, type MAOptions, type MarketType, type MinuteKline, type MinuteTimeline, type OBVOptions$1 as OBVOptions, type OBVResult$1 as OBVResult, type PanelLargeOrder, type ROCOptions$1 as ROCOptions, type ROCResult$1 as ROCResult, type RSIOptions, type RequestClientOptions, type RetryOptions, type SAROptions$1 as SAROptions, type SARResult$1 as SARResult, type SearchResult, type SimpleQuote, StockSDK, type TodayTimeline, type TodayTimelineResponse, type USQuote, type WROptions, addIndicators, asyncPool, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, chunkArray, decodeGBK, StockSDK as default, parseResponse, safeNumber, safeNumberOrNull };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var Ft=Object.defineProperty;var ut=(t,e)=>{for(var n in e)Ft(t,n,{get:e[n],enumerable:!0})};function J(t){return new TextDecoder("gbk").decode(t)}function X(t){let e=t.split(";").map(s=>s.trim()).filter(Boolean),n=[];for(let s of e){let o=s.indexOf("=");if(o<0)continue;let r=s.slice(0,o).trim();r.startsWith("v_")&&(r=r.slice(2));let i=s.slice(o+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let l=i.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 S(t){return t==null?null:y(String(t))}var xe="https://qt.gtimg.cn",Ae="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Te="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",ct="https://assets.linkdiary.cn/shares/trade-data-list.txt";var Z="https://push2his.eastmoney.com/api/qt/stock/kline/get",Le="https://push2his.eastmoney.com/api/qt/stock/trends2/get",_e="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Ie="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ue="https://17.push2.eastmoney.com/api/qt/clist/get",Ee="https://91.push2.eastmoney.com/api/qt/stock/get",Be="https://29.push2.eastmoney.com/api/qt/clist/get",Pe="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",ke="https://push2his.eastmoney.com/api/qt/stock/trends2/get",De="https://79.push2.eastmoney.com/api/qt/clist/get",ve="https://91.push2.eastmoney.com/api/qt/stock/get",He="https://29.push2.eastmoney.com/api/qt/clist/get",qe="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",Ne="https://push2his.eastmoney.com/api/qt/stock/trends2/get",je=3e4,$=500,V=500,W=7,Qe=3,Fe=1e3,$e=3e4,Ve=2,We=[408,429,500,502,503,504];var H=class extends Error{constructor(n,s,o,r){let i=s?` ${s}`:"",l=o?`, url: ${o}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${i}${l}${a}`);this.status=n;this.statusText=s;this.url=o;this.provider=r;this.name="HttpError"}},G=class{constructor(e={}){this.baseUrl=e.baseUrl??xe,this.timeout=e.timeout??je,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},e.userAgent&&(Object.keys(this.headers).some(s=>s.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Qe,baseDelay:e?.baseDelay??Fe,maxDelay:e?.maxDelay??$e,backoffMultiplier:e?.backoffMultiplier??Ve,retryableStatusCodes:e?.retryableStatusCodes??We,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{return await e()}catch(s){if(this.shouldRetry(s,n)){let o=this.calculateDelay(n);return this.retryOptions.onRetry&&s instanceof Error&&this.retryOptions.onRetry(n+1,s,o),await this.sleep(o),this.executeWithRetry(e,n+1)}throw s}}async get(e,n={}){return this.executeWithRetry(async()=>{let s=new AbortController,o=setTimeout(()=>s.abort(),this.timeout),r=this.inferProvider(e);try{let i=await fetch(e,{signal:s.signal,headers:{...this.headers}});if(!i.ok)throw new H(i.status,i.statusText,e,r);switch(n.responseType){case"json":return await i.json();case"arraybuffer":return await i.arrayBuffer();default:return await i.text()}}catch(i){throw i instanceof Error&&(i.url=e,i.provider=r),i}finally{clearTimeout(o)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,s=await this.get(n,{responseType:"arraybuffer"}),o=J(s);return X(o)}};var $t=new Set(["daily","weekly","monthly"]),Vt=new Set(["1","5","15","30","60"]),Wt=new Set(["","qfq","hfq"]);function A(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function L(t){if(!$t.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function z(t){if(!Vt.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function T(t){if(!Wt.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function q(t,e){A(e,"chunkSize");let n=[];for(let s=0;s<t.length;s+=e)n.push(t.slice(s,s+e));return n}async function N(t,e){A(e,"concurrency");let n=[],s=[];for(let o of t){let r=Promise.resolve().then(()=>o()).then(i=>{n.push(i)});if(s.push(r),s.length>=e){await Promise.race(s);for(let i=s.length-1;i>=0;i--)await Promise.race([s[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&s.splice(i,1)}}return await Promise.all(s),n}function ee(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function _(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function K(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var M={};ut(M,{getAShareCodeList:()=>gt,getAllHKQuotesByCodes:()=>bt,getAllQuotesByCodes:()=>Rt,getAllUSQuotesByCodes:()=>St,getFullQuotes:()=>te,getFundFlow:()=>ft,getFundQuotes:()=>mt,getHKCodeList:()=>Ct,getHKQuotes:()=>ne,getPanelLargeOrder:()=>dt,getSimpleQuotes:()=>pt,getTodayTimeline:()=>ht,getTradingCalendar:()=>Mt,getUSCodeList:()=>yt,getUSQuotes:()=>re,parseFullQuote:()=>Ge,parseFundFlow:()=>Ye,parseFundQuote:()=>et,parseHKQuote:()=>Xe,parsePanelLargeOrder:()=>Je,parseSimpleQuote:()=>ze,parseUSQuote:()=>Ze,search:()=>xt});function Ge(t){let e=[];for(let s=0;s<5;s++)e.push({price:h(t[9+s*2]),volume:h(t[10+s*2])});let n=[];for(let s=0;s<5;s++)n.push({price:h(t[19+s*2]),volume:h(t[20+s*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 ze(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 Ye(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 Je(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function Xe(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 Ze(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 et(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 te(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>Ge(s.fields))}async function pt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`s_${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>ze(o.fields))}async function ft(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`ff_${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Ye(o.fields))}async function dt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`s_pk${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Je(o.fields))}async function ne(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`hk${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Xe(o.fields))}async function re(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`us${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Ze(o.fields))}async function mt(t,e){if(!e||e.length===0)return[];let n=e.map(o=>`jj${o}`);return(await t.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>et(o.fields))}async function ht(t,e){let n=t.getTimeout(),s=new AbortController,o=setTimeout(()=>s.abort(),n);try{let r=await fetch(`${Ae}?code=${e}`,{signal:s.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let i=await r.json();if(i.code!==0)throw new Error(i.msg||"API error");let l=i.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,b=parseFloat(m[3])||0,x=c?C*100:C,w=x>0?b/x:0;return{time:f,price:parseFloat(m[1])||0,volume:x,amount:b,avgPrice:Math.round(w*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(o)}}var tt=null,Gt=null,oe=null,zt=null,se=null;function Yt(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 gt(t,e){let n=!1,s;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,s=e.market),!tt){let i=(await t.get(Te,{responseType:"json"}))?.list||[];tt=i,Gt=i.map(l=>l.replace(/^(sh|sz|bj)/,""))}let o=tt;return s&&(o=o.filter(r=>Yt(r,s))),n?o.map(r=>r.replace(/^(sh|sz|bj)/,"")):o.slice()}var Jt={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function yt(t,e){let n=!1,s;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,s=e.market),oe||(oe=(await t.get(Ke,{responseType:"json"}))?.list||[],zt=oe.map(i=>i.replace(/^\d{3}\./,"")));let o=oe.slice();if(s){let r=Jt[s];o=o.filter(i=>i.startsWith(r))}return n?o.map(r=>r.replace(/^\d{3}\./,"")):o}async function Ct(t){return se||(se=(await t.get(we,{responseType:"json"}))?.list||[]),se.slice()}async function Rt(t,e,n={}){let{batchSize:s=$,concurrency:o=W,onProgress:r}=n;A(s,"batchSize"),A(o,"concurrency");let i=Math.min(s,V),l=q(e,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await te(t,d);return u++,r&&r(u,a),m});return(await N(c,o)).flat()}async function bt(t,e,n={}){let{batchSize:s=$,concurrency:o=W,onProgress:r}=n;A(s,"batchSize"),A(o,"concurrency");let i=Math.min(s,V),l=q(e,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ne(t,d);return u++,r&&r(u,a),m});return(await N(c,o)).flat()}async function St(t,e,n={}){let{batchSize:s=$,concurrency:o=W,onProgress:r}=n;A(s,"batchSize"),A(o,"concurrency");let i=Math.min(s,V),l=q(e,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await re(t,d);return u++,r&&r(u,a),m});return(await N(c,o)).flat()}var j=null;async function Mt(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 Ot="https://smartbox.gtimg.cn/s3/";function Xt(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function Zt(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let s=n.split("~"),o=s[0]||"",r=s[1]||"",i=Xt(s[2]||""),l=s[4]||"";return{code:o+r,name:i,market:o,type:l}})}function en(t){return new Promise((e,n)=>{let s=`${Ot}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=s,o.charset="utf-8",o.onload=()=>{let r=window.v_hint||"";document.body.removeChild(o),e(r)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function tn(t,e){let n=`${Ot}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function nn(){return typeof window<"u"&&typeof document<"u"}async function xt(t,e){if(!e||!e.trim())return[];let n;return nn()?n=await en(e):n=await tn(t,e),Zt(n)}var O={};ut(O,{getConceptConstituents:()=>Bt,getConceptKline:()=>Pt,getConceptList:()=>ot,getConceptMinuteKline:()=>kt,getConceptSpot:()=>Et,getHKHistoryKline:()=>Kt,getHistoryKline:()=>At,getIndustryConstituents:()=>_t,getIndustryKline:()=>It,getIndustryList:()=>rt,getIndustryMinuteKline:()=>Ut,getIndustrySpot:()=>Lt,getMinuteKline:()=>Tt,getUSHistoryKline:()=>wt});async function nt(t,e,n,s,o=100,r){let i=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(o),fields:s}),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,i.length+f+1));i.push(...m),l++}while(i.length<a);return i}function I(t){let[e,n,s,o,r,i,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(s),high:y(o),low:y(r),volume:y(i),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function U(t,e,n){let s=`${e}?${n.toString()}`,o=await t.get(s,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function At(t,e,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;L(s),T(o);let l=e.replace(/^(sh|sz|bj)/,""),a=`${ee(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:_(s),fqt:K(o),secid:a,beg:r,end:i}),c=Z,{klines:p}=await U(t,c,u);return p.length===0?[]:p.map(d=>({...I(d),code:l}))}async function Tt(t,e,n={}){let{period:s="1",adjust:o="qfq",startDate:r="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;z(s),T(o);let l=e.replace(/^(sh|sz|bj)/,""),a=`${ee(e)}.${l}`;if(s==="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=`${Le}?${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=i.replace("T"," ").slice(0,16);return d.map(f=>{let[C,b,x,w,F,B,v,Qt]=f.split(",");return{time:C,open:y(b),close:y(x),high:y(w),low:y(F),volume:y(B),amount:y(v),avgPrice:y(Qt)}}).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:s,fqt:K(o||""),secid:a,beg:"0",end:"20500000"}),c=Z,{klines:p}=await U(t,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=i.replace("T"," ").slice(0,16);return p.map(g=>{let f=I(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function Kt(t,e,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;L(s),T(o);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:_(s),fqt:K(o),secid:a,beg:r,end:i,lmt:"1000000"}),c=_e,{klines:p,name:d}=await U(t,c,u);return p.length===0?[]:p.map(m=>({...I(m),code:l,name:d||""}))}async function wt(t,e,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;L(s),T(o);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:_(s),fqt:K(o),secid:e,beg:r,end:i,lmt:"1000000"}),a=Ie,{klines:u,name:c,code:p}=await U(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...I(g),code:d,name:m}))}function ie(t){let e=null;return{async getCode(n,s,o){if(s.startsWith("BK"))return s;if(!e){let i=await o(n);e=new Map(i.map(l=>[l.name,l.code]))}let r=e.get(s);if(!r)throw new Error(`${t.errorPrefix}: ${s}`);return r}}}async function le(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},s=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await nt(t,e.listUrl,n,s,100,(r,i)=>({rank:i,name:String(r.f14??""),code:String(r.f12??""),price:S(r.f2),change:S(r.f4),changePercent:S(r.f3),totalMarketCap:S(r.f20),turnoverRate:S(r.f8),riseCount:S(r.f104),fallCount:S(r.f105),leadingStock:r.f128?String(r.f128):null,leadingStockChangePercent:S(r.f136)}));return o.sort((r,i)=>(i.changePercent??0)-(r.changePercent??0)),o.forEach((r,i)=>{r.rank=i+1}),o}async function ae(t,e,n){let s=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${s.toString()}`,i=(await t.get(o,{responseType:"json"}))?.data;return i?[{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=i[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function ue(t,e,n){let s={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return nt(t,n,s,"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,i)=>({rank:i,code:String(r.f12??""),name:String(r.f14??""),price:S(r.f2),changePercent:S(r.f3),change:S(r.f4),volume:S(r.f5),amount:S(r.f6),amplitude:S(r.f7),high:S(r.f15),low:S(r.f16),open:S(r.f17),prevClose:S(r.f18),turnoverRate:S(r.f8),pe:S(r.f9),pb:S(r.f23)}))}async function ce(t,e,n,s={}){let{period:o="daily",adjust:r="",startDate:i="19700101",endDate:l="20500101"}=s;L(o),T(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:_(o),fqt:K(r),beg:i,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await U(t,n,a);return u.length===0?[]:u.map(c=>I(c))}async function pe(t,e,n,s,o={}){let{period:r="5"}=o;if(z(r),r==="1"){let i=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=`${s}?${i.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,b,x]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(b),price:y(x)}})}else{let i=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}?${i.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,b,x,w,F,B]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(w),change:y(F),volume:y(C),amount:y(b),amplitude:y(x),turnoverRate:y(B)}})}}var P={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ue,spotUrl:Ee,consUrl:Be,klineUrl:Pe,trendsUrl:ke,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},rn=ie(P);async function fe(t,e){return rn.getCode(t,e,rt)}async function rt(t){return le(t,P)}async function Lt(t,e){let n=await fe(t,e);return ae(t,n,P.spotUrl)}async function _t(t,e){let n=await fe(t,e);return ue(t,n,P.consUrl)}async function It(t,e,n={}){let s=await fe(t,e);return ce(t,s,P.klineUrl,n)}async function Ut(t,e,n={}){let s=await fe(t,e);return pe(t,s,P.klineUrl,P.trendsUrl,n)}var k={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:De,spotUrl:ve,consUrl:He,klineUrl:qe,trendsUrl:Ne,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},on=ie(k);async function de(t,e){return on.getCode(t,e,ot)}async function ot(t){return le(t,k)}async function Et(t,e){let n=await de(t,e);return ae(t,n,k.spotUrl)}async function Bt(t,e){let n=await de(t,e);return ue(t,n,k.consUrl)}async function Pt(t,e,n={}){let s=await de(t,e);return ce(t,s,k.klineUrl,n)}async function kt(t,e,n={}){let s=await de(t,e);return pe(t,s,k.klineUrl,k.trendsUrl,n)}function Y(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function D(t,e){let n=[];for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let o=0,r=0;for(let i=s-e+1;i<=s;i++)t[i]!==null&&(o+=t[i],r++);n.push(r===e?Y(o/e):null)}return n}function E(t,e){let n=[],s=2/(e+1),o=null,r=!1;for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=i-e+1;c<=i;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(o=a/e,r=!0),n.push(o!==null?Y(o):null);continue}let l=t[i];l===null?n.push(o!==null?Y(o):null):(o=s*l+(1-s)*o,n.push(Y(o)))}return n}function st(t,e){let n=[],s=Array.from({length:e},(r,i)=>i+1),o=s.reduce((r,i)=>r+i,0);for(let r=0;r<t.length;r++){if(r<e-1){n.push(null);continue}let i=0,l=!0;for(let a=0;a<e;a++){let u=t[r-e+1+a];if(u===null){l=!1;break}i+=u*s[a]}n.push(l?Y(i/o):null)}return n}function me(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:s="sma"}=e,o=s==="ema"?E:s==="wma"?st:D,r={};for(let i of n)r[`ma${i}`]=o(t,i);return t.map((i,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function Dt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function he(t,e={}){let{short:n=12,long:s=26,signal:o=9}=e,r=E(t,n),i=E(t,s),l=t.map((u,c)=>r[c]===null||i[c]===null?null:r[c]-i[c]),a=E(l,o);return t.map((u,c)=>({dif:l[c]!==null?Dt(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?Dt((l[c]-a[c])*2):null}))}function it(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function sn(t,e,n){let s=[];for(let o=0;o<t.length;o++){if(o<e-1||n[o]===null){s.push(null);continue}let r=0,i=0;for(let l=o-e+1;l<=o;l++)t[l]!==null&&n[o]!==null&&(r+=Math.pow(t[l]-n[o],2),i++);s.push(i===e?Math.sqrt(r/e):null)}return s}function ge(t,e={}){let{period:n=20,stdDev:s=2}=e,o=D(t,n),r=sn(t,n,o);return t.map((i,l)=>{if(o[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=o[l]+s*r[l],u=o[l]-s*r[l],c=o[l]!==0?it((a-u)/o[l]*100):null;return{mid:o[l],upper:it(a),lower:it(u),bandwidth:c}})}function lt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ye(t,e={}){let{period:n=9,kPeriod:s=3,dPeriod:o=3}=e,r=[],i=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;i=(s-1)/s*i+1/s*m,l=(o-1)/o*l+1/o*i;let g=3*i-2*l;r.push({k:lt(i),d:lt(l),j:lt(g)})}return r}function ln(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Ce(t,e={}){let{periods:n=[6,12,24]}=e,s=[null];for(let r=1;r<t.length;r++)t[r]===null||t[r-1]===null?s.push(null):s.push(t[r]-t[r-1]);let o={};for(let r of n){let i=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<r){i.push(null),s[u]!==null&&(s[u]>0?l+=s[u]:a+=Math.abs(s[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=s[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)i.push(100);else if(l===0)i.push(0);else{let c=l/a;i.push(ln(100-100/(1+c)))}}o[`rsi${r}`]=i}return t.map((r,i)=>{let l={};for(let a of n)l[`rsi${a}`]=o[`rsi${a}`][i];return l})}function an(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Re(t,e={}){let{periods:n=[6,10]}=e,s={};for(let o of n){let r=[];for(let i=0;i<t.length;i++){if(i<o-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=i-o+1;d<=i;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[i].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(an(p))}s[`wr${o}`]=r}return t.map((o,r)=>{let i={};for(let l of n)i[`wr${l}`]=s[`wr${l}`][r];return i})}function un(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function be(t,e={}){let{periods:n=[6,12,24]}=e,s={};for(let o of n){let r=D(t,o),i=[];for(let l=0;l<t.length;l++)if(t[l]===null||r[l]===null||r[l]===0)i.push(null);else{let a=(t[l]-r[l])/r[l]*100;i.push(un(a))}s[`bias${o}`]=i}return t.map((o,r)=>{let i={};for(let l of n)i[`bias${l}`]=s[`bias${l}`][r];return i})}function cn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Se(t,e={}){let{period:n=14}=e,s=[],o=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){s.push({cci:null});continue}let i=0,l=0;for(let p=r-n+1;p<=r;p++)o[p]!==null&&(i+=o[p],l++);if(l!==n||o[r]===null){s.push({cci:null});continue}let a=i/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(o[p]-a);let c=u/n;if(c===0)s.push({cci:0});else{let p=(o[r]-a)/(.015*c);s.push({cci:cn(p)})}}return s}function at(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function Q(t,e={}){let{period:n=14}=e,s=[],o=[];for(let i=0;i<t.length;i++){let{high:l,low:a,close:u}=t[i];if(l===null||a===null||u===null){o.push(null);continue}if(i===0)o.push(l-a);else{let c=t[i-1].close;if(c===null)o.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);o.push(Math.max(p,d,m))}}}let r=null;for(let i=0;i<t.length;i++){if(i<n-1){s.push({tr:o[i]!==null?at(o[i]):null,atr:null});continue}if(i===n-1){let l=0,a=0;for(let u=0;u<n;u++)o[u]!==null&&(l+=o[u],a++);a===n&&(r=l/n)}else r!==null&&o[i]!==null&&(r=(r*(n-1)+o[i])/n);s.push({tr:o[i]!==null?at(o[i]):null,atr:r!==null?at(r):null})}return s}function vt(t,e={}){let{maPeriod:n}=e,s=[];if(t.length===0)return s;let o=t[0].volume??0;s.push({obv:o,obvMa:null});for(let r=1;r<t.length;r++){let i=t[r],l=t[r-1];if(i.close===null||l.close===null||i.volume===null||i.volume===void 0){s.push({obv:null,obvMa:null});continue}i.close>l.close?o+=i.volume:i.close<l.close&&(o-=i.volume),s.push({obv:o,obvMa:null})}if(n&&n>0)for(let r=n-1;r<s.length;r++){let i=0,l=0;for(let a=r-n+1;a<=r;a++)s[a].obv!==null&&(i+=s[a].obv,l++);l===n&&(s[r].obvMa=i/n)}return s}function Ht(t,e={}){let{period:n=12,signalPeriod:s}=e,o=[];for(let r=0;r<t.length;r++){if(r<n){o.push({roc:null,signal:null});continue}let i=t[r].close,l=t[r-n].close;if(i===null||l===null||l===0){o.push({roc:null,signal:null});continue}let a=(i-l)/l*100;o.push({roc:a,signal:null})}if(s&&s>0)for(let r=n+s-1;r<o.length;r++){let i=0,l=0;for(let a=r-s+1;a<=r;a++)o[a].roc!==null&&(i+=o[a].roc,l++);l===s&&(o[r].signal=i/s)}return o}function qt(t,e={}){let{period:n=14,adxPeriod:s=n}=e,o=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],i=[],l=[];for(let f=0;f<t.length;f++){if(f===0){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],b=t[f-1];if(C.high===null||C.low===null||C.close===null||b.high===null||b.low===null||b.close===null){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let x=C.high-C.low,w=Math.abs(C.high-b.close),F=Math.abs(C.low-b.close);l.push(Math.max(x,w,F));let B=C.high-b.high,v=b.low-C.low;B>v&&B>0?r.push(B):r.push(0),v>B&&v>0?i.push(v):i.push(0),o.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+=i[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+i[f]);let C=a>0?u/a*100:0,b=a>0?c/a*100:0;o[f].pdi=C,o[f].mdi=b;let x=C+b,w=x>0?Math.abs(C-b)/x*100:0;p.push(w)}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/s,o[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(s-1)+C)/s,o[f].adx=g}}for(let f=n*2-1+s;f<t.length;f++){let C=o[f].adx,b=o[f-s]?.adx;C!==null&&b!==null&&(o[f].adxr=(C+b)/2)}return o}function Nt(t,e={}){let{afStart:n=.02,afIncrement:s=.02,afMax:o=.2}=e,r=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=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&&(i=-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);i===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(i=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+s,o))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(i=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+s,o))),u=f,r.push({sar:u,trend:i,ep:a,af:l})}return r}function jt(t,e={}){let{emaPeriod:n=20,atrPeriod:s=10,multiplier:o=2}=e,r=[],i=t.map(u=>u.close),l=E(i,n),a=Q(t,{period:s});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+o*p,m=c-o*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function Me(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),s=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),o=e.ma?me(n,typeof e.ma=="object"?e.ma:{}):null,r=e.macd?he(n,typeof e.macd=="object"?e.macd:{}):null,i=e.boll?ge(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?ye(s,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?Ce(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?Re(s,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?be(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?Se(s,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?Q(s,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...o&&{ma:o[g]},...r&&{macd:r[g]},...i&&{boll:i[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 Oe=class{constructor(e={}){this.client=new G(e)}getFullQuotes(e){return M.getFullQuotes(this.client,e)}getSimpleQuotes(e){return M.getSimpleQuotes(this.client,e)}getHKQuotes(e){return M.getHKQuotes(this.client,e)}getUSQuotes(e){return M.getUSQuotes(this.client,e)}getFundQuotes(e){return M.getFundQuotes(this.client,e)}getFundFlow(e){return M.getFundFlow(this.client,e)}getPanelLargeOrder(e){return M.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return M.getTodayTimeline(this.client,e)}getIndustryList(){return O.getIndustryList(this.client)}getIndustrySpot(e){return O.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return O.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return O.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return O.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return O.getConceptList(this.client)}getConceptSpot(e){return O.getConceptSpot(this.client,e)}getConceptConstituents(e){return O.getConceptConstituents(this.client,e)}getConceptKline(e,n){return O.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return O.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return O.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return O.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return O.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return O.getUSHistoryKline(this.client,e,n)}search(e){return M.search(this.client,e)}getAShareCodeList(e){return M.getAShareCodeList(this.client,e)}getUSCodeList(e){return M.getUSCodeList(this.client,e)}getHKCodeList(){return M.getHKCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...s}=e,o=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(o,s)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return M.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...s}=e,o=await this.getUSCodeList({simple:!0,market:n});return M.getAllUSQuotesByCodes(this.client,o,s)}getAllQuotesByCodes(e,n={}){return M.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return M.getTradingCalendar(this.client)}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,s=!1;if(e.ma){let r=typeof e.ma=="object"?e.ma:{},i=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(i,20)),l==="ema"&&(s=!0)}if(e.macd){let r=typeof e.macd=="object"?e.macd:{},i=r.long??26,l=r.signal??9;n=Math.max(n,i*3+l),s=!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*(s?1.5:1.2))}calcActualStartDate(e,n,s=1.5){let o=Math.ceil(n*s),r=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));r.setDate(r.getDate()-o);let i=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${i}${l}${a}`}calcActualStartDateByCalendar(e,n,s){if(!s||s.length===0)return;let o=this.normalizeDate(e),r=s.findIndex(l=>l>=o);r===-1&&(r=s.length-1);let i=Math.max(0,r-n);return this.toCompactDate(s[i])}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:s,endDate:o,indicators:r={}}=n,i=n.market??this.detectMarket(e),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(s)if(i==="A")try{let m=await M.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(s,l,m)??this.calcActualStartDate(s,l,a[i])}catch{u=this.calcActualStartDate(s,l,a[i])}else u=this.calcActualStartDate(s,l,a[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(i){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(s&&p.length<l)switch(i){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=Me(p,r);if(s){let m=this.dateToTimestamp(s),g=o?this.dateToTimestamp(o):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},pn=Oe;export{H as HttpError,Oe as StockSDK,Me as addIndicators,N as asyncPool,Q as calcATR,be as calcBIAS,ge as calcBOLL,Se as calcCCI,qt as calcDMI,E as calcEMA,jt as calcKC,ye as calcKDJ,me as calcMA,he as calcMACD,vt as calcOBV,Ht as calcROC,Ce as calcRSI,Nt as calcSAR,D as calcSMA,st as calcWMA,Re as calcWR,q as chunkArray,J as decodeGBK,pn as default,X as parseResponse,h as safeNumber,R as safeNumberOrNull};
1
+ var Wt=Object.defineProperty;var pt=(e,t)=>{for(var n in t)Wt(e,n,{get:t[n],enumerable:!0})};function J(e){return new TextDecoder("gbk").decode(e)}function Z(e){let t=e.split(";").map(s=>s.trim()).filter(Boolean),n=[];for(let s of t){let o=s.indexOf("=");if(o<0)continue;let r=s.slice(0,o).trim();r.startsWith("v_")&&(r=r.slice(2));let i=s.slice(o+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let l=i.split("~");n.push({key:r,fields:l})}return n}function h(e){if(!e||e==="")return 0;let t=parseFloat(e);return Number.isNaN(t)?0:t}function C(e){if(!e||e==="")return null;let t=parseFloat(e);return Number.isNaN(t)?null:t}function y(e){if(!e||e===""||e==="-")return null;let t=parseFloat(e);return Number.isNaN(t)?null:t}function b(e){return e==null?null:y(String(e))}var Me="https://qt.gtimg.cn",_e="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Ee="https://assets.linkdiary.cn/shares/zh_a_list.json",xe="https://assets.linkdiary.cn/shares/us_list.json",Ie="https://assets.linkdiary.cn/shares/hk_list.json",ft="https://assets.linkdiary.cn/shares/trade-data-list.txt";var ee="https://push2his.eastmoney.com/api/qt/stock/kline/get",Ke="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Le="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Pe="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",we="https://17.push2.eastmoney.com/api/qt/clist/get",Ue="https://91.push2.eastmoney.com/api/qt/stock/get",De="https://29.push2.eastmoney.com/api/qt/clist/get",Be="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",ke="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ve="https://79.push2.eastmoney.com/api/qt/clist/get",Ne="https://91.push2.eastmoney.com/api/qt/stock/get",He="https://29.push2.eastmoney.com/api/qt/clist/get",qe="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",je="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Qe="https://datacenter-web.eastmoney.com/api/data/v1/get",Fe=3e4,V=500,W=500,G=7,$e=3,Ve=1e3,We=3e4,Ge=2,ze=[408,429,500,502,503,504];var H=class extends Error{constructor(n,s,o,r){let i=s?` ${s}`:"",l=o?`, url: ${o}`:"",a=r?`, provider: ${r}`:"";super(`HTTP error! status: ${n}${i}${l}${a}`);this.status=n;this.statusText=s;this.url=o;this.provider=r;this.name="HttpError"}},z=class{constructor(t={}){this.baseUrl=t.baseUrl??Me,this.timeout=t.timeout??Fe,this.retryOptions=this.resolveRetryOptions(t.retry),this.headers={...t.headers??{}},t.userAgent&&(Object.keys(this.headers).some(s=>s.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=t.userAgent))}resolveRetryOptions(t){return{maxRetries:t?.maxRetries??$e,baseDelay:t?.baseDelay??Ve,maxDelay:t?.maxDelay??We,backoffMultiplier:t?.backoffMultiplier??Ge,retryableStatusCodes:t?.retryableStatusCodes??ze,retryOnNetworkError:t?.retryOnNetworkError??!0,retryOnTimeout:t?.retryOnTimeout??!0,onRetry:t?.onRetry}}inferProvider(t){try{let n=new URL(t).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(t){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,t),this.retryOptions.maxDelay)+Math.random()*100}sleep(t){return new Promise(n=>setTimeout(n,t))}shouldRetry(t,n){return n>=this.retryOptions.maxRetries?!1:t instanceof DOMException&&t.name==="AbortError"?this.retryOptions.retryOnTimeout:t instanceof TypeError?this.retryOptions.retryOnNetworkError:t instanceof H?this.retryOptions.retryableStatusCodes.includes(t.status):!1}async executeWithRetry(t,n=0){try{return await t()}catch(s){if(this.shouldRetry(s,n)){let o=this.calculateDelay(n);return this.retryOptions.onRetry&&s instanceof Error&&this.retryOptions.onRetry(n+1,s,o),await this.sleep(o),this.executeWithRetry(t,n+1)}throw s}}async get(t,n={}){return this.executeWithRetry(async()=>{let s=new AbortController,o=setTimeout(()=>s.abort(),this.timeout),r=this.inferProvider(t);try{let i=await fetch(t,{signal:s.signal,headers:{...this.headers}});if(!i.ok)throw new H(i.status,i.statusText,t,r);switch(n.responseType){case"json":return await i.json();case"arraybuffer":return await i.arrayBuffer();default:return await i.text()}}catch(i){throw i instanceof Error&&(i.url=t,i.provider=r),i}finally{clearTimeout(o)}})}async getTencentQuote(t){let n=`${this.baseUrl}/?q=${encodeURIComponent(t)}`,s=await this.get(n,{responseType:"arraybuffer"}),o=J(s);return Z(o)}};var Gt=new Set(["daily","weekly","monthly"]),zt=new Set(["1","5","15","30","60"]),Yt=new Set(["","qfq","hfq"]);function M(e,t){if(!Number.isFinite(e)||!Number.isInteger(e)||e<=0)throw new RangeError(`${t} must be a positive integer`)}function I(e){if(!Gt.has(e))throw new RangeError("period must be one of: daily, weekly, monthly")}function Y(e){if(!zt.has(e))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function _(e){if(!Yt.has(e))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function q(e,t){M(t,"chunkSize");let n=[];for(let s=0;s<e.length;s+=t)n.push(e.slice(s,s+t));return n}async function j(e,t){M(t,"concurrency");let n=[],s=[];for(let o of e){let r=Promise.resolve().then(()=>o()).then(i=>{n.push(i)});if(s.push(r),s.length>=t){await Promise.race(s);for(let i=s.length-1;i>=0;i--)await Promise.race([s[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&s.splice(i,1)}}return await Promise.all(s),n}function te(e){return e.startsWith("sh")?"1":e.startsWith("sz")||e.startsWith("bj")?"0":e.startsWith("6")?"1":"0"}function K(e){return{daily:"101",weekly:"102",monthly:"103"}[e]}function E(e){return{"":"0",qfq:"1",hfq:"2"}[e]}var A={};pt(A,{getAShareCodeList:()=>Rt,getAllHKQuotesByCodes:()=>At,getAllQuotesByCodes:()=>bt,getAllUSQuotesByCodes:()=>Tt,getFullQuotes:()=>ne,getFundFlow:()=>mt,getFundQuotes:()=>gt,getHKCodeList:()=>St,getHKQuotes:()=>re,getPanelLargeOrder:()=>ht,getSimpleQuotes:()=>dt,getTodayTimeline:()=>yt,getTradingCalendar:()=>Ot,getUSCodeList:()=>Ct,getUSQuotes:()=>oe,parseFullQuote:()=>Ye,parseFundFlow:()=>Je,parseFundQuote:()=>nt,parseHKQuote:()=>et,parsePanelLargeOrder:()=>Ze,parseSimpleQuote:()=>Xe,parseUSQuote:()=>tt,search:()=>_t});function Ye(e){let t=[];for(let s=0;s<5;s++)t.push({price:h(e[9+s*2]),volume:h(e[10+s*2])});let n=[];for(let s=0;s<5;s++)n.push({price:h(e[19+s*2]),volume:h(e[20+s*2])});return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),prevClose:h(e[4]),open:h(e[5]),volume:h(e[6]),outerVolume:h(e[7]),innerVolume:h(e[8]),bid:t,ask:n,time:e[30]??"",change:h(e[31]),changePercent:h(e[32]),high:h(e[33]),low:h(e[34]),volume2:h(e[36]),amount:h(e[37]),turnoverRate:C(e[38]),pe:C(e[39]),amplitude:C(e[43]),circulatingMarketCap:C(e[44]),totalMarketCap:C(e[45]),pb:C(e[46]),limitUp:C(e[47]),limitDown:C(e[48]),volumeRatio:C(e[49]),avgPrice:C(e[51]),peStatic:C(e[52]),peDynamic:C(e[53]),high52w:C(e[67]),low52w:C(e[68]),circulatingShares:C(e[72]),totalShares:C(e[73]),raw:e}}function Xe(e){return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),change:h(e[4]),changePercent:h(e[5]),volume:h(e[6]),amount:h(e[7]),marketCap:C(e[9]),marketType:e[10]??"",raw:e}}function Je(e){return{code:e[0]??"",mainInflow:h(e[1]),mainOutflow:h(e[2]),mainNet:h(e[3]),mainNetRatio:h(e[4]),retailInflow:h(e[5]),retailOutflow:h(e[6]),retailNet:h(e[7]),retailNetRatio:h(e[8]),totalFlow:h(e[9]),name:e[12]??"",date:e[13]??"",raw:e}}function Ze(e){return{buyLargeRatio:h(e[0]),buySmallRatio:h(e[1]),sellLargeRatio:h(e[2]),sellSmallRatio:h(e[3]),raw:e}}function et(e){return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),prevClose:h(e[4]),open:h(e[5]),volume:h(e[6]),time:e[30]??"",change:h(e[31]),changePercent:h(e[32]),high:h(e[33]),low:h(e[34]),amount:h(e[37]),lotSize:C(e[40]),circulatingMarketCap:C(e[44]),totalMarketCap:C(e[45]),currency:e[e.length-3]??"",raw:e}}function tt(e){return{marketId:e[0]??"",name:e[1]??"",code:e[2]??"",price:h(e[3]),prevClose:h(e[4]),open:h(e[5]),volume:h(e[6]),time:e[30]??"",change:h(e[31]),changePercent:h(e[32]),high:h(e[33]),low:h(e[34]),amount:h(e[37]),turnoverRate:C(e[38]),pe:C(e[39]),amplitude:C(e[43]),totalMarketCap:C(e[45]),pb:C(e[47]),high52w:C(e[48]),low52w:C(e[49]),raw:e}}function nt(e){return{code:e[0]??"",name:e[1]??"",nav:h(e[5]),accNav:h(e[6]),change:h(e[7]),navDate:e[8]??"",raw:e}}async function ne(e,t){return!t||t.length===0?[]:(await e.getTencentQuote(t.join(","))).filter(s=>s.fields&&s.fields.length>0&&s.fields[0]!=="").map(s=>Ye(s.fields))}async function dt(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`s_${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Xe(o.fields))}async function mt(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`ff_${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Je(o.fields))}async function ht(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`s_pk${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>Ze(o.fields))}async function re(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`hk${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>et(o.fields))}async function oe(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`us${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>tt(o.fields))}async function gt(e,t){if(!t||t.length===0)return[];let n=t.map(o=>`jj${o}`);return(await e.getTencentQuote(n.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>nt(o.fields))}async function yt(e,t){let n=e.getTimeout(),s=new AbortController,o=setTimeout(()=>s.abort(),n);try{let r=await fetch(`${_e}?code=${t}`,{signal:s.signal});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let i=await r.json();if(i.code!==0)throw new Error(i.msg||"API error");let l=i.data?.[t];if(!l)return{code:t,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)}`,R=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?R*100:R,x=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(x*100)/100}});return{code:t,date:u,data:p}}finally{clearTimeout(o)}}var rt=null,Xt=null,se=null,Jt=null,ie=null;function Zt(e,t){let n=e.replace(/^(sh|sz|bj)/,"");switch(t){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 Rt(e,t){let n=!1,s;if(typeof t=="boolean"?n=!t:t&&(n=t.simple??!1,s=t.market),!rt){let i=(await e.get(Ee,{responseType:"json"}))?.list||[];rt=i,Xt=i.map(l=>l.replace(/^(sh|sz|bj)/,""))}let o=rt;return s&&(o=o.filter(r=>Zt(r,s))),n?o.map(r=>r.replace(/^(sh|sz|bj)/,"")):o.slice()}var en={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Ct(e,t){let n=!1,s;typeof t=="boolean"?n=!t:t&&(n=t.simple??!1,s=t.market),se||(se=(await e.get(xe,{responseType:"json"}))?.list||[],Jt=se.map(i=>i.replace(/^\d{3}\./,"")));let o=se.slice();if(s){let r=en[s];o=o.filter(i=>i.startsWith(r))}return n?o.map(r=>r.replace(/^\d{3}\./,"")):o}async function St(e){return ie||(ie=(await e.get(Ie,{responseType:"json"}))?.list||[]),ie.slice()}async function bt(e,t,n={}){let{batchSize:s=V,concurrency:o=G,onProgress:r}=n;M(s,"batchSize"),M(o,"concurrency");let i=Math.min(s,W),l=q(t,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ne(e,d);return u++,r&&r(u,a),m});return(await j(c,o)).flat()}async function At(e,t,n={}){let{batchSize:s=V,concurrency:o=G,onProgress:r}=n;M(s,"batchSize"),M(o,"concurrency");let i=Math.min(s,W),l=q(t,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await re(e,d);return u++,r&&r(u,a),m});return(await j(c,o)).flat()}async function Tt(e,t,n={}){let{batchSize:s=V,concurrency:o=G,onProgress:r}=n;M(s,"batchSize"),M(o,"concurrency");let i=Math.min(s,W),l=q(t,i),a=l.length,u=0,c=l.map(d=>async()=>{let m=await oe(e,d);return u++,r&&r(u,a),m});return(await j(c,o)).flat()}var Q=null;async function Ot(e){if(Q)return Q.slice();let t=await e.get(ft);return!t||t.trim()===""?(Q=[],Q.slice()):(Q=t.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),Q.slice())}var Mt="https://smartbox.gtimg.cn/s3/";function tn(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,n)=>String.fromCharCode(parseInt(n,16)))}function nn(e){return!e||e==="N"?[]:e.split("^").filter(Boolean).map(n=>{let s=n.split("~"),o=s[0]||"",r=s[1]||"",i=tn(s[2]||""),l=s[4]||"";return{code:o+r,name:i,market:o,type:l}})}function rn(e){return new Promise((t,n)=>{let s=`${Mt}?v=2&t=all&q=${encodeURIComponent(e)}`;window.v_hint="";let o=document.createElement("script");o.src=s,o.charset="utf-8",o.onload=()=>{let r=window.v_hint||"";document.body.removeChild(o),t(r)},o.onerror=()=>{document.body.removeChild(o),n(new Error("Network error calling Smartbox"))},document.body.appendChild(o)})}async function on(e,t){let n=`${Mt}?v=2&t=all&q=${encodeURIComponent(t)}`,o=(await e.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function sn(){return typeof window<"u"&&typeof document<"u"}async function _t(e,t){if(!t||!t.trim())return[];let n;return sn()?n=await rn(t):n=await on(e,t),nn(n)}var T={};pt(T,{getConceptConstituents:()=>Bt,getConceptKline:()=>kt,getConceptList:()=>it,getConceptMinuteKline:()=>vt,getConceptSpot:()=>Dt,getDividendDetail:()=>Nt,getHKHistoryKline:()=>It,getHistoryKline:()=>Et,getIndustryConstituents:()=>Pt,getIndustryKline:()=>wt,getIndustryList:()=>st,getIndustryMinuteKline:()=>Ut,getIndustrySpot:()=>Lt,getMinuteKline:()=>xt,getUSHistoryKline:()=>Kt});async function ot(e,t,n,s,o=100,r){let i=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(o),fields:s}),c=`${t}?${u.toString()}`,d=(await e.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,i.length+f+1));i.push(...m),l++}while(i.length<a);return i}function L(e){let[t,n,s,o,r,i,l,a,u,c,p]=e.split(",");return{date:t,open:y(n),close:y(s),high:y(o),low:y(r),volume:y(i),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function P(e,t,n){let s=`${t}?${n.toString()}`,o=await e.get(s,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function Et(e,t,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;I(s),_(o);let l=t.replace(/^(sh|sz|bj)/,""),a=`${te(t)}.${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(s),fqt:E(o),secid:a,beg:r,end:i}),c=ee,{klines:p}=await P(e,c,u);return p.length===0?[]:p.map(d=>({...L(d),code:l}))}async function xt(e,t,n={}){let{period:s="1",adjust:o="qfq",startDate:r="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;Y(s),_(o);let l=t.replace(/^(sh|sz|bj)/,""),a=`${te(t)}.${l}`;if(s==="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=`${Ke}?${u.toString()}`,d=(await e.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=r.replace("T"," ").slice(0,16),g=i.replace("T"," ").slice(0,16);return d.map(f=>{let[R,S,O,x,$,U,N,Vt]=f.split(",");return{time:R,open:y(S),close:y(O),high:y(x),low:y($),volume:y(U),amount:y(N),avgPrice:y(Vt)}}).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:s,fqt:E(o||""),secid:a,beg:"0",end:"20500000"}),c=ee,{klines:p}=await P(e,c,u);if(p.length===0)return[];let d=r.replace("T"," ").slice(0,16),m=i.replace("T"," ").slice(0,16);return p.map(g=>{let f=L(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function It(e,t,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;I(s),_(o);let l=t.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(s),fqt:E(o),secid:a,beg:r,end:i,lmt:"1000000"}),c=Le,{klines:p,name:d}=await P(e,c,u);return p.length===0?[]:p.map(m=>({...L(m),code:l,name:d||""}))}async function Kt(e,t,n={}){let{period:s="daily",adjust:o="qfq",startDate:r="19700101",endDate:i="20500101"}=n;I(s),_(o);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(s),fqt:E(o),secid:t,beg:r,end:i,lmt:"1000000"}),a=Pe,{klines:u,name:c,code:p}=await P(e,a,l),d=p||t.split(".")[1]||t,m=c||"";return u.length===0?[]:u.map(g=>({...L(g),code:d,name:m}))}function le(e){let t=null;return{async getCode(n,s,o){if(s.startsWith("BK"))return s;if(!t){let i=await o(n);t=new Map(i.map(l=>[l.name,l.code]))}let r=t.get(s);if(!r)throw new Error(`${e.errorPrefix}: ${s}`);return r}}}async function ae(e,t){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:t.type==="concept"?"f12":"f3",fs:t.fsFilter},s=t.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await ot(e,t.listUrl,n,s,100,(r,i)=>({rank:i,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 o.sort((r,i)=>(i.changePercent??0)-(r.changePercent??0)),o.forEach((r,i)=>{r.rank=i+1}),o}async function ue(e,t,n){let s=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${t}`}),o=`${n}?${s.toString()}`,i=(await e.get(o,{responseType:"json"}))?.data;return i?[{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=i[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function ce(e,t,n){let s={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${t} f:!50`};return ot(e,n,s,"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,i)=>({rank:i,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 pe(e,t,n,s={}){let{period:o="daily",adjust:r="",startDate:i="19700101",endDate:l="20500101"}=s;I(o),_(r);let a=new URLSearchParams({secid:`90.${t}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:K(o),fqt:E(r),beg:i,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await P(e,n,a);return u.length===0?[]:u.map(c=>L(c))}async function fe(e,t,n,s,o={}){let{period:r="5"}=o;if(Y(r),r==="1"){let i=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.${t}`}),l=`${s}?${i.toString()}`,u=(await e.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,R,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(R),amount:y(S),price:y(O)}})}else{let i=new URLSearchParams({secid:`90.${t}`,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}?${i.toString()}`,u=(await e.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,R,S,O,x,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(x),change:y($),volume:y(R),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var D={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:we,spotUrl:Ue,consUrl:De,klineUrl:Be,trendsUrl:ke,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},ln=le(D);async function de(e,t){return ln.getCode(e,t,st)}async function st(e){return ae(e,D)}async function Lt(e,t){let n=await de(e,t);return ue(e,n,D.spotUrl)}async function Pt(e,t){let n=await de(e,t);return ce(e,n,D.consUrl)}async function wt(e,t,n={}){let s=await de(e,t);return pe(e,s,D.klineUrl,n)}async function Ut(e,t,n={}){let s=await de(e,t);return fe(e,s,D.klineUrl,D.trendsUrl,n)}var B={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:ve,spotUrl:Ne,consUrl:He,klineUrl:qe,trendsUrl:je,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},an=le(B);async function me(e,t){return an.getCode(e,t,it)}async function it(e){return ae(e,B)}async function Dt(e,t){let n=await me(e,t);return ue(e,n,B.spotUrl)}async function Bt(e,t){let n=await me(e,t);return ce(e,n,B.consUrl)}async function kt(e,t,n={}){let s=await me(e,t);return pe(e,s,B.klineUrl,n)}async function vt(e,t,n={}){let s=await me(e,t);return fe(e,s,B.klineUrl,B.trendsUrl,n)}function k(e){if(!e)return null;let t=e.match(/^(\d{4}-\d{2}-\d{2})/);return t?t[1]:null}function un(e){return{code:e.SECURITY_CODE??"",name:e.SECURITY_NAME_ABBR??"",reportDate:k(e.REPORT_DATE),planNoticeDate:k(e.PLAN_NOTICE_DATE),disclosureDate:k(e.PUBLISH_DATE??e.PLAN_NOTICE_DATE),assignTransferRatio:e.BONUS_IT_RATIO??null,bonusRatio:e.BONUS_RATIO??null,transferRatio:e.IT_RATIO??null,dividendPretax:e.PRETAX_BONUS_RMB??null,dividendDesc:e.IMPL_PLAN_PROFILE??null,dividendYield:e.DIVIDENT_RATIO??null,eps:e.BASIC_EPS??null,bps:e.BVPS??null,capitalReserve:e.PER_CAPITAL_RESERVE??null,unassignedProfit:e.PER_UNASSIGN_PROFIT??null,netProfitYoy:e.PNP_YOY_RATIO??null,totalShares:e.TOTAL_SHARES??null,equityRecordDate:k(e.EQUITY_RECORD_DATE),exDividendDate:k(e.EX_DIVIDEND_DATE),payDate:k(e.PAY_DATE),assignProgress:e.ASSIGN_PROGRESS??null,noticeDate:k(e.NOTICE_DATE)}}async function Nt(e,t){let n=t.replace(/^(sh|sz|bj)/,""),s=[],o=1,r=1;do{let i=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(o),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${Qe}?${i.toString()}`,u=(await e.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;o===1&&(r=u.pages??1);let c=u.data.map(un);s.push(...c),o++}while(o<=r);return s}function X(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function v(e,t){let n=[];for(let s=0;s<e.length;s++){if(s<t-1){n.push(null);continue}let o=0,r=0;for(let i=s-t+1;i<=s;i++)e[i]!==null&&(o+=e[i],r++);n.push(r===t?X(o/t):null)}return n}function w(e,t){let n=[],s=2/(t+1),o=null,r=!1;for(let i=0;i<e.length;i++){if(i<t-1){n.push(null);continue}if(!r){let a=0,u=0;for(let c=i-t+1;c<=i;c++)e[c]!==null&&(a+=e[c],u++);u===t&&(o=a/t,r=!0),n.push(o!==null?X(o):null);continue}let l=e[i];l===null?n.push(o!==null?X(o):null):(o=s*l+(1-s)*o,n.push(X(o)))}return n}function lt(e,t){let n=[],s=Array.from({length:t},(r,i)=>i+1),o=s.reduce((r,i)=>r+i,0);for(let r=0;r<e.length;r++){if(r<t-1){n.push(null);continue}let i=0,l=!0;for(let a=0;a<t;a++){let u=e[r-t+1+a];if(u===null){l=!1;break}i+=u*s[a]}n.push(l?X(i/o):null)}return n}function he(e,t={}){let{periods:n=[5,10,20,30,60,120,250],type:s="sma"}=t,o=s==="ema"?w:s==="wma"?lt:v,r={};for(let i of n)r[`ma${i}`]=o(e,i);return e.map((i,l)=>{let a={};for(let u of n)a[`ma${u}`]=r[`ma${u}`][l];return a})}function Ht(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function ge(e,t={}){let{short:n=12,long:s=26,signal:o=9}=t,r=w(e,n),i=w(e,s),l=e.map((u,c)=>r[c]===null||i[c]===null?null:r[c]-i[c]),a=w(l,o);return e.map((u,c)=>({dif:l[c]!==null?Ht(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?Ht((l[c]-a[c])*2):null}))}function at(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function cn(e,t,n){let s=[];for(let o=0;o<e.length;o++){if(o<t-1||n[o]===null){s.push(null);continue}let r=0,i=0;for(let l=o-t+1;l<=o;l++)e[l]!==null&&n[o]!==null&&(r+=Math.pow(e[l]-n[o],2),i++);s.push(i===t?Math.sqrt(r/t):null)}return s}function ye(e,t={}){let{period:n=20,stdDev:s=2}=t,o=v(e,n),r=cn(e,n,o);return e.map((i,l)=>{if(o[l]===null||r[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=o[l]+s*r[l],u=o[l]-s*r[l],c=o[l]!==0?at((a-u)/o[l]*100):null;return{mid:o[l],upper:at(a),lower:at(u),bandwidth:c}})}function ut(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function Re(e,t={}){let{period:n=9,kPeriod:s=3,dPeriod:o=3}=t,r=[],i=50,l=50;for(let a=0;a<e.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(e[f].high===null||e[f].low===null){p=!1;break}u=Math.max(u,e[f].high),c=Math.min(c,e[f].low)}let d=e[a].close;if(!p||d===null||u===c){r.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;i=(s-1)/s*i+1/s*m,l=(o-1)/o*l+1/o*i;let g=3*i-2*l;r.push({k:ut(i),d:ut(l),j:ut(g)})}return r}function pn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function Ce(e,t={}){let{periods:n=[6,12,24]}=t,s=[null];for(let r=1;r<e.length;r++)e[r]===null||e[r-1]===null?s.push(null):s.push(e[r]-e[r-1]);let o={};for(let r of n){let i=[],l=0,a=0;for(let u=0;u<e.length;u++){if(u<r){i.push(null),s[u]!==null&&(s[u]>0?l+=s[u]:a+=Math.abs(s[u]));continue}if(u===r)l=l/r,a=a/r;else{let c=s[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)i.push(100);else if(l===0)i.push(0);else{let c=l/a;i.push(pn(100-100/(1+c)))}}o[`rsi${r}`]=i}return e.map((r,i)=>{let l={};for(let a of n)l[`rsi${a}`]=o[`rsi${a}`][i];return l})}function fn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function Se(e,t={}){let{periods:n=[6,10]}=t,s={};for(let o of n){let r=[];for(let i=0;i<e.length;i++){if(i<o-1){r.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=i-o+1;d<=i;d++){if(e[d].high===null||e[d].low===null){u=!1;break}l=Math.max(l,e[d].high),a=Math.min(a,e[d].low)}let c=e[i].close;if(!u||c===null||l===a){r.push(null);continue}let p=(l-c)/(l-a)*100;r.push(fn(p))}s[`wr${o}`]=r}return e.map((o,r)=>{let i={};for(let l of n)i[`wr${l}`]=s[`wr${l}`][r];return i})}function dn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function be(e,t={}){let{periods:n=[6,12,24]}=t,s={};for(let o of n){let r=v(e,o),i=[];for(let l=0;l<e.length;l++)if(e[l]===null||r[l]===null||r[l]===0)i.push(null);else{let a=(e[l]-r[l])/r[l]*100;i.push(dn(a))}s[`bias${o}`]=i}return e.map((o,r)=>{let i={};for(let l of n)i[`bias${l}`]=s[`bias${l}`][r];return i})}function mn(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function Ae(e,t={}){let{period:n=14}=t,s=[],o=e.map(r=>r.high===null||r.low===null||r.close===null?null:(r.high+r.low+r.close)/3);for(let r=0;r<e.length;r++){if(r<n-1){s.push({cci:null});continue}let i=0,l=0;for(let p=r-n+1;p<=r;p++)o[p]!==null&&(i+=o[p],l++);if(l!==n||o[r]===null){s.push({cci:null});continue}let a=i/n,u=0;for(let p=r-n+1;p<=r;p++)u+=Math.abs(o[p]-a);let c=u/n;if(c===0)s.push({cci:0});else{let p=(o[r]-a)/(.015*c);s.push({cci:mn(p)})}}return s}function ct(e,t=2){let n=Math.pow(10,t);return Math.round(e*n)/n}function F(e,t={}){let{period:n=14}=t,s=[],o=[];for(let i=0;i<e.length;i++){let{high:l,low:a,close:u}=e[i];if(l===null||a===null||u===null){o.push(null);continue}if(i===0)o.push(l-a);else{let c=e[i-1].close;if(c===null)o.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);o.push(Math.max(p,d,m))}}}let r=null;for(let i=0;i<e.length;i++){if(i<n-1){s.push({tr:o[i]!==null?ct(o[i]):null,atr:null});continue}if(i===n-1){let l=0,a=0;for(let u=0;u<n;u++)o[u]!==null&&(l+=o[u],a++);a===n&&(r=l/n)}else r!==null&&o[i]!==null&&(r=(r*(n-1)+o[i])/n);s.push({tr:o[i]!==null?ct(o[i]):null,atr:r!==null?ct(r):null})}return s}function qt(e,t={}){let{maPeriod:n}=t,s=[];if(e.length===0)return s;let o=e[0].volume??0;s.push({obv:o,obvMa:null});for(let r=1;r<e.length;r++){let i=e[r],l=e[r-1];if(i.close===null||l.close===null||i.volume===null||i.volume===void 0){s.push({obv:null,obvMa:null});continue}i.close>l.close?o+=i.volume:i.close<l.close&&(o-=i.volume),s.push({obv:o,obvMa:null})}if(n&&n>0)for(let r=n-1;r<s.length;r++){let i=0,l=0;for(let a=r-n+1;a<=r;a++)s[a].obv!==null&&(i+=s[a].obv,l++);l===n&&(s[r].obvMa=i/n)}return s}function jt(e,t={}){let{period:n=12,signalPeriod:s}=t,o=[];for(let r=0;r<e.length;r++){if(r<n){o.push({roc:null,signal:null});continue}let i=e[r].close,l=e[r-n].close;if(i===null||l===null||l===0){o.push({roc:null,signal:null});continue}let a=(i-l)/l*100;o.push({roc:a,signal:null})}if(s&&s>0)for(let r=n+s-1;r<o.length;r++){let i=0,l=0;for(let a=r-s+1;a<=r;a++)o[a].roc!==null&&(i+=o[a].roc,l++);l===s&&(o[r].signal=i/s)}return o}function Qt(e,t={}){let{period:n=14,adxPeriod:s=n}=t,o=[];if(e.length<2)return e.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],i=[],l=[];for(let f=0;f<e.length;f++){if(f===0){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let R=e[f],S=e[f-1];if(R.high===null||R.low===null||R.close===null||S.high===null||S.low===null||S.close===null){r.push(0),i.push(0),l.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=R.high-R.low,x=Math.abs(R.high-S.close),$=Math.abs(R.low-S.close);l.push(Math.max(O,x,$));let U=R.high-S.high,N=S.low-R.low;U>N&&U>0?r.push(U):r.push(0),N>U&&N>0?i.push(N):i.push(0),o.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<e.length;f++){if(f<n){a+=l[f],u+=r[f],c+=i[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+i[f]);let R=a>0?u/a*100:0,S=a>0?c/a*100:0;o[f].pdi=R,o[f].mdi=S;let O=R+S,x=O>0?Math.abs(R-S)/O*100:0;p.push(x)}let d=0,m=0,g=0;for(let f=n;f<e.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/s,o[f].adx=g;else{let R=p[f-n+1]||0;g=(g*(s-1)+R)/s,o[f].adx=g}}for(let f=n*2-1+s;f<e.length;f++){let R=o[f].adx,S=o[f-s]?.adx;R!==null&&S!==null&&(o[f].adxr=(R+S)/2)}return o}function Ft(e,t={}){let{afStart:n=.02,afIncrement:s=.02,afMax:o=.2}=t,r=[];if(e.length<2)return e.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=1,l=n,a=e[0].high??0,u=e[0].low??0,c=e[0],p=e[1];c.close!==null&&p.close!==null&&p.close<c.close&&(i=-1,a=c.low??0,u=c.high??0),r.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<e.length;d++){let m=e[d],g=e[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);i===1?(f=Math.min(f,g.low,e[Math.max(0,d-2)]?.low??g.low),m.low<f?(i=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+s,o))):(f=Math.max(f,g.high,e[Math.max(0,d-2)]?.high??g.high),m.high>f?(i=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+s,o))),u=f,r.push({sar:u,trend:i,ep:a,af:l})}return r}function $t(e,t={}){let{emaPeriod:n=20,atrPeriod:s=10,multiplier:o=2}=t,r=[],i=e.map(u=>u.close),l=w(i,n),a=F(e,{period:s});for(let u=0;u<e.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+o*p,m=c-o*p,g=c>0?(d-m)/c*100:null;r.push({mid:c,upper:d,lower:m,width:g})}return r}function Te(e,t={}){if(e.length===0)return[];let n=e.map(m=>m.close),s=e.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),o=t.ma?he(n,typeof t.ma=="object"?t.ma:{}):null,r=t.macd?ge(n,typeof t.macd=="object"?t.macd:{}):null,i=t.boll?ye(n,typeof t.boll=="object"?t.boll:{}):null,l=t.kdj?Re(s,typeof t.kdj=="object"?t.kdj:{}):null,a=t.rsi?Ce(n,typeof t.rsi=="object"?t.rsi:{}):null,u=t.wr?Se(s,typeof t.wr=="object"?t.wr:{}):null,c=t.bias?be(n,typeof t.bias=="object"?t.bias:{}):null,p=t.cci?Ae(s,typeof t.cci=="object"?t.cci:{}):null,d=t.atr?F(s,typeof t.atr=="object"?t.atr:{}):null;return e.map((m,g)=>({...m,...o&&{ma:o[g]},...r&&{macd:r[g]},...i&&{boll:i[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 Oe=class{constructor(t={}){this.client=new z(t)}getFullQuotes(t){return A.getFullQuotes(this.client,t)}getSimpleQuotes(t){return A.getSimpleQuotes(this.client,t)}getHKQuotes(t){return A.getHKQuotes(this.client,t)}getUSQuotes(t){return A.getUSQuotes(this.client,t)}getFundQuotes(t){return A.getFundQuotes(this.client,t)}getFundFlow(t){return A.getFundFlow(this.client,t)}getPanelLargeOrder(t){return A.getPanelLargeOrder(this.client,t)}getTodayTimeline(t){return A.getTodayTimeline(this.client,t)}getIndustryList(){return T.getIndustryList(this.client)}getIndustrySpot(t){return T.getIndustrySpot(this.client,t)}getIndustryConstituents(t){return T.getIndustryConstituents(this.client,t)}getIndustryKline(t,n){return T.getIndustryKline(this.client,t,n)}getIndustryMinuteKline(t,n){return T.getIndustryMinuteKline(this.client,t,n)}getConceptList(){return T.getConceptList(this.client)}getConceptSpot(t){return T.getConceptSpot(this.client,t)}getConceptConstituents(t){return T.getConceptConstituents(this.client,t)}getConceptKline(t,n){return T.getConceptKline(this.client,t,n)}getConceptMinuteKline(t,n){return T.getConceptMinuteKline(this.client,t,n)}getHistoryKline(t,n){return T.getHistoryKline(this.client,t,n)}getMinuteKline(t,n){return T.getMinuteKline(this.client,t,n)}getHKHistoryKline(t,n){return T.getHKHistoryKline(this.client,t,n)}getUSHistoryKline(t,n){return T.getUSHistoryKline(this.client,t,n)}search(t){return A.search(this.client,t)}getAShareCodeList(t){return A.getAShareCodeList(this.client,t)}getUSCodeList(t){return A.getUSCodeList(this.client,t)}getHKCodeList(){return A.getHKCodeList(this.client)}async getAllAShareQuotes(t={}){let{market:n,...s}=t,o=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(o,s)}async getAllHKShareQuotes(t={}){let n=await this.getHKCodeList();return A.getAllHKQuotesByCodes(this.client,n,t)}async getAllUSShareQuotes(t={}){let{market:n,...s}=t,o=await this.getUSCodeList({simple:!0,market:n});return A.getAllUSQuotesByCodes(this.client,o,s)}getAllQuotesByCodes(t,n={}){return A.getAllQuotesByCodes(this.client,t,n)}async batchRaw(t){return this.client.getTencentQuote(t)}getTradingCalendar(){return A.getTradingCalendar(this.client)}getDividendDetail(t){return T.getDividendDetail(this.client,t)}detectMarket(t){return/^\d{3}\.[A-Z]+$/i.test(t)?"US":/^\d{5}$/.test(t)?"HK":"A"}safeMax(t,n=0){return!t||t.length===0?n:Math.max(...t)}calcRequiredLookback(t){let n=0,s=!1;if(t.ma){let r=typeof t.ma=="object"?t.ma:{},i=r.periods??[5,10,20,30,60,120,250],l=r.type??"sma";n=Math.max(n,this.safeMax(i,20)),l==="ema"&&(s=!0)}if(t.macd){let r=typeof t.macd=="object"?t.macd:{},i=r.long??26,l=r.signal??9;n=Math.max(n,i*3+l),s=!0}if(t.boll){let r=typeof t.boll=="object"&&t.boll.period?t.boll.period:20;n=Math.max(n,r)}if(t.kdj){let r=typeof t.kdj=="object"&&t.kdj.period?t.kdj.period:9;n=Math.max(n,r)}if(t.rsi){let r=typeof t.rsi=="object"&&t.rsi.periods?t.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(r,14)+1)}if(t.wr){let r=typeof t.wr=="object"&&t.wr.periods?t.wr.periods:[6,10];n=Math.max(n,this.safeMax(r,10))}if(t.bias){let r=typeof t.bias=="object"&&t.bias.periods?t.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(r,12))}if(t.cci){let r=typeof t.cci=="object"&&t.cci.period?t.cci.period:14;n=Math.max(n,r)}if(t.atr){let r=typeof t.atr=="object"&&t.atr.period?t.atr.period:14;n=Math.max(n,r)}return Math.ceil(n*(s?1.5:1.2))}calcActualStartDate(t,n,s=1.5){let o=Math.ceil(n*s),r=new Date(parseInt(t.slice(0,4)),parseInt(t.slice(4,6))-1,parseInt(t.slice(6,8)));r.setDate(r.getDate()-o);let i=r.getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${i}${l}${a}`}calcActualStartDateByCalendar(t,n,s){if(!s||s.length===0)return;let o=this.normalizeDate(t),r=s.findIndex(l=>l>=o);r===-1&&(r=s.length-1);let i=Math.max(0,r-n);return this.toCompactDate(s[i])}normalizeDate(t){return t.includes("-")?t:t.length===8?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}toCompactDate(t){return t.replace(/-/g,"")}dateToTimestamp(t){let n=t.includes("-")?t:`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(t,n={}){let{startDate:s,endDate:o,indicators:r={}}=n,i=n.market??this.detectMarket(t),l=this.calcRequiredLookback(r),a={A:1.5,HK:1.46,US:1.45},u;if(s)if(i==="A")try{let m=await A.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(s,l,m)??this.calcActualStartDate(s,l,a[i])}catch{u=this.calcActualStartDate(s,l,a[i])}else u=this.calcActualStartDate(s,l,a[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(i){case"HK":p=await this.getHKHistoryKline(t,c);break;case"US":p=await this.getUSHistoryKline(t,c);break;default:p=await this.getHistoryKline(t,c)}if(s&&p.length<l)switch(i){case"HK":p=await this.getHKHistoryKline(t,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(t,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(t,{...c,startDate:void 0})}let d=Te(p,r);if(s){let m=this.dateToTimestamp(s),g=o?this.dateToTimestamp(o):1/0;return d.filter(f=>{let R=this.dateToTimestamp(f.date);return R>=m&&R<=g})}return d}},hn=Oe;export{H as HttpError,Oe as StockSDK,Te as addIndicators,j as asyncPool,F as calcATR,be as calcBIAS,ye as calcBOLL,Ae as calcCCI,Qt as calcDMI,w as calcEMA,$t as calcKC,Re as calcKDJ,he as calcMA,ge as calcMACD,qt as calcOBV,jt as calcROC,Ce as calcRSI,Ft as calcSAR,v as calcSMA,lt as calcWMA,Se as calcWR,q as chunkArray,J as decodeGBK,hn as default,Z as parseResponse,h as safeNumber,C as safeNumberOrNull};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stock-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",