stock-sdk 1.4.5 → 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 +1 -1
- package/dist/index.d.cts +509 -6
- package/dist/index.d.ts +509 -6
- package/dist/index.js +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var xe=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var $t=Object.prototype.hasOwnProperty;var Le=(t,e)=>{for(var n in e)xe(t,n,{get:e[n],enumerable:!0})},Wt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ft(e))!$t.call(t,r)&&r!==n&&xe(t,r,{get:()=>e[r],enumerable:!(s=Qt(e,r))||s.enumerable});return t};var zt=t=>Wt(xe({},"__esModule",{value:!0}),t);var cn={};Le(cn,{HttpError:()=>B,StockSDK:()=>ae,addIndicators:()=>ie,asyncPool:()=>k,calcATR:()=>se,calcBIAS:()=>re,calcBOLL:()=>Z,calcCCI:()=>oe,calcEMA:()=>U,calcKDJ:()=>ee,calcMA:()=>J,calcMACD:()=>X,calcRSI:()=>te,calcSMA:()=>E,calcWMA:()=>Me,calcWR:()=>ne,chunkArray:()=>P,decodeGBK:()=>v,default:()=>Nt,parseResponse:()=>j,safeNumber:()=>f,safeNumberOrNull:()=>y});module.exports=zt(cn);function v(t){return new TextDecoder("gbk").decode(t)}function j(t){let e=t.split(";").map(s=>s.trim()).filter(Boolean),n=[];for(let s of e){let r=s.indexOf("=");if(r<0)continue;let o=s.slice(0,r).trim();o.startsWith("v_")&&(o=o.slice(2));let i=s.slice(r+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let a=i.split("~");n.push({key:o,fields:a})}return n}function f(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function y(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function g(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function R(t){return t==null?null:g(String(t))}var Oe="https://qt.gtimg.cn",we="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Ie="https://assets.linkdiary.cn/shares/zh_a_list.json",Ee="https://assets.linkdiary.cn/shares/us_list.json",Ue="https://assets.linkdiary.cn/shares/hk_list.json",ft="https://assets.linkdiary.cn/shares/trade-data-list.txt";var le="https://push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Pe="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",ke="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",De="https://17.push2.eastmoney.com/api/qt/clist/get",qe="https://91.push2.eastmoney.com/api/qt/stock/get",He="https://29.push2.eastmoney.com/api/qt/clist/get",Ne="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",ve="https://push2his.eastmoney.com/api/qt/stock/trends2/get",je="https://79.push2.eastmoney.com/api/qt/clist/get",Qe="https://91.push2.eastmoney.com/api/qt/stock/get",Fe="https://29.push2.eastmoney.com/api/qt/clist/get",$e="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",We="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ze=3e4,Q=500,F=500,$=7,Ge=3,Ve=1e3,Ye=3e4,Je=2,Xe=[408,429,500,502,503,504];var B=class extends Error{constructor(n,s,r,o){let i=s?` ${s}`:"",a=r?`, url: ${r}`:"",l=o?`, provider: ${o}`:"";super(`HTTP error! status: ${n}${i}${a}${l}`);this.status=n;this.statusText=s;this.url=r;this.provider=o;this.name="HttpError"}},W=class{constructor(e={}){this.baseUrl=e.baseUrl??Oe,this.timeout=e.timeout??ze,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??Ge,baseDelay:e?.baseDelay??Ve,maxDelay:e?.maxDelay??Ye,backoffMultiplier:e?.backoffMultiplier??Je,retryableStatusCodes:e?.retryableStatusCodes??Xe,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof B?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{return await e()}catch(s){if(this.shouldRetry(s,n)){let r=this.calculateDelay(n);return this.retryOptions.onRetry&&s instanceof Error&&this.retryOptions.onRetry(n+1,s,r),await this.sleep(r),this.executeWithRetry(e,n+1)}throw s}}async get(e,n={}){return this.executeWithRetry(async()=>{let s=new AbortController,r=setTimeout(()=>s.abort(),this.timeout),o=this.inferProvider(e);try{let i=await fetch(e,{signal:s.signal,headers:{...this.headers}});if(!i.ok)throw new B(i.status,i.statusText,e,o);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=o),i}finally{clearTimeout(r)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,s=await this.get(n,{responseType:"arraybuffer"}),r=v(s);return j(r)}};var Gt=new Set(["daily","weekly","monthly"]),Vt=new Set(["1","5","15","30","60"]),Yt=new Set(["","qfq","hfq"]);function K(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function x(t){if(!Gt.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 M(t){if(!Yt.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function P(t,e){K(e,"chunkSize");let n=[];for(let s=0;s<t.length;s+=e)n.push(t.slice(s,s+e));return n}async function k(t,e){K(e,"concurrency");let n=[],s=[];for(let r of t){let o=Promise.resolve().then(()=>r()).then(i=>{n.push(i)});if(s.push(o),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 ue(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function L(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function A(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var b={};Le(b,{getAShareCodeList:()=>Ct,getAllHKQuotesByCodes:()=>Tt,getAllQuotesByCodes:()=>St,getAllUSQuotesByCodes:()=>Kt,getFullQuotes:()=>ce,getFundFlow:()=>mt,getFundQuotes:()=>ht,getHKCodeList:()=>bt,getHKQuotes:()=>pe,getPanelLargeOrder:()=>gt,getSimpleQuotes:()=>dt,getTodayTimeline:()=>yt,getTradingCalendar:()=>Mt,getUSCodeList:()=>Rt,getUSQuotes:()=>fe,parseFullQuote:()=>Ze,parseFundFlow:()=>tt,parseFundQuote:()=>st,parseHKQuote:()=>rt,parsePanelLargeOrder:()=>nt,parseSimpleQuote:()=>et,parseUSQuote:()=>ot,search:()=>_t});function Ze(t){let e=[];for(let s=0;s<5;s++)e.push({price:f(t[9+s*2]),volume:f(t[10+s*2])});let n=[];for(let s=0;s<5;s++)n.push({price:f(t[19+s*2]),volume:f(t[20+s*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),prevClose:f(t[4]),open:f(t[5]),volume:f(t[6]),outerVolume:f(t[7]),innerVolume:f(t[8]),bid:e,ask:n,time:t[30]??"",change:f(t[31]),changePercent:f(t[32]),high:f(t[33]),low:f(t[34]),volume2:f(t[36]),amount:f(t[37]),turnoverRate:y(t[38]),pe:y(t[39]),amplitude:y(t[43]),circulatingMarketCap:y(t[44]),totalMarketCap:y(t[45]),pb:y(t[46]),limitUp:y(t[47]),limitDown:y(t[48]),volumeRatio:y(t[49]),avgPrice:y(t[51]),peStatic:y(t[52]),peDynamic:y(t[53]),high52w:y(t[67]),low52w:y(t[68]),circulatingShares:y(t[72]),totalShares:y(t[73]),raw:t}}function et(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),change:f(t[4]),changePercent:f(t[5]),volume:f(t[6]),amount:f(t[7]),marketCap:y(t[9]),marketType:t[10]??"",raw:t}}function tt(t){return{code:t[0]??"",mainInflow:f(t[1]),mainOutflow:f(t[2]),mainNet:f(t[3]),mainNetRatio:f(t[4]),retailInflow:f(t[5]),retailOutflow:f(t[6]),retailNet:f(t[7]),retailNetRatio:f(t[8]),totalFlow:f(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function nt(t){return{buyLargeRatio:f(t[0]),buySmallRatio:f(t[1]),sellLargeRatio:f(t[2]),sellSmallRatio:f(t[3]),raw:t}}function rt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),prevClose:f(t[4]),open:f(t[5]),volume:f(t[6]),time:t[30]??"",change:f(t[31]),changePercent:f(t[32]),high:f(t[33]),low:f(t[34]),amount:f(t[37]),lotSize:y(t[40]),circulatingMarketCap:y(t[44]),totalMarketCap:y(t[45]),currency:t[t.length-3]??"",raw:t}}function ot(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),prevClose:f(t[4]),open:f(t[5]),volume:f(t[6]),time:t[30]??"",change:f(t[31]),changePercent:f(t[32]),high:f(t[33]),low:f(t[34]),amount:f(t[37]),turnoverRate:y(t[38]),pe:y(t[39]),amplitude:y(t[43]),totalMarketCap:y(t[45]),pb:y(t[47]),high52w:y(t[48]),low52w:y(t[49]),raw:t}}function st(t){return{code:t[0]??"",name:t[1]??"",nav:f(t[5]),accNav:f(t[6]),change:f(t[7]),navDate:t[8]??"",raw:t}}async function ce(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=>Ze(s.fields))}async function dt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>et(r.fields))}async function mt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>tt(r.fields))}async function gt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>nt(r.fields))}async function pe(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>rt(r.fields))}async function fe(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ot(r.fields))}async function ht(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>st(r.fields))}async function yt(t,e){let n=t.getTimeout(),s=new AbortController,r=setTimeout(()=>s.abort(),n);try{let o=await fetch(`${we}?code=${e}`,{signal:s.signal});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let i=await o.json();if(i.code!==0)throw new Error(i.msg||"API error");let a=i.data?.[e];if(!a)return{code:e,date:"",data:[]};let l=a.data?.data||[],u=a.data?.date||"",c=!1;if(l.length>0){let d=l[0].split(" "),m=parseFloat(d[1])||0,h=parseInt(d[2],10)||0,C=parseFloat(d[3])||0;h>0&&m>0&&C/h>m*50&&(c=!0)}let p=l.map(d=>{let m=d.split(" "),h=m[0],C=`${h.slice(0,2)}:${h.slice(2,4)}`,T=parseInt(m[2],10)||0,I=parseFloat(m[3])||0,_=c?T*100:T,N=_>0?I/_:0;return{time:C,price:parseFloat(m[1])||0,volume:_,amount:I,avgPrice:Math.round(N*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(r)}}var de=null,G=null,me=null,V=null,ge=null;async function Ct(t,e=!0){if(de)return e?de.slice():(G||(G=de.map(r=>r.replace(/^(sh|sz|bj)/,""))),G.slice());let s=(await t.get(Ie,{responseType:"json"}))?.list||[];return de=s,G=s.map(r=>r.replace(/^(sh|sz|bj)/,"")),e?s.slice():G.slice()}async function Rt(t,e=!0){if(me)return e?me.slice():(V||(V=me.map(r=>r.replace(/^\d{3}\./,""))),V.slice());let s=(await t.get(Ee,{responseType:"json"}))?.list||[];return me=s,V=s.map(r=>r.replace(/^\d{3}\./,"")),e?s.slice():V.slice()}async function bt(t){return ge||(ge=(await t.get(Ue,{responseType:"json"}))?.list||[]),ge.slice()}async function St(t,e,n={}){let{batchSize:s=Q,concurrency:r=$,onProgress:o}=n;K(s,"batchSize"),K(r,"concurrency");let i=Math.min(s,F),a=P(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let m=await ce(t,d);return u++,o&&o(u,l),m});return(await k(c,r)).flat()}async function Tt(t,e,n={}){let{batchSize:s=Q,concurrency:r=$,onProgress:o}=n;K(s,"batchSize"),K(r,"concurrency");let i=Math.min(s,F),a=P(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let m=await pe(t,d);return u++,o&&o(u,l),m});return(await k(c,r)).flat()}async function Kt(t,e,n={}){let{batchSize:s=Q,concurrency:r=$,onProgress:o}=n;K(s,"batchSize"),K(r,"concurrency");let i=Math.min(s,F),a=P(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let m=await fe(t,d);return u++,o&&o(u,l),m});return(await k(c,r)).flat()}var H=null;async function Mt(t){if(H)return H.slice();let e=await t.get(ft);return!e||e.trim()===""?(H=[],H.slice()):(H=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),H.slice())}var At="https://smartbox.gtimg.cn/s3/";function Jt(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function Xt(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let s=n.split("~"),r=s[0]||"",o=s[1]||"",i=Jt(s[2]||""),a=s[4]||"";return{code:r+o,name:i,market:r,type:a}})}function Zt(t){return new Promise((e,n)=>{let s=`${At}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=s,r.charset="utf-8",r.onload=()=>{let o=window.v_hint||"";document.body.removeChild(r),e(o)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function en(t,e){let n=`${At}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function tn(){return typeof window<"u"&&typeof document<"u"}async function _t(t,e){if(!e||!e.trim())return[];let n;return tn()?n=await Zt(e):n=await en(t,e),Xt(n)}var S={};Le(S,{getConceptConstituents:()=>kt,getConceptKline:()=>Dt,getConceptList:()=>lt,getConceptMinuteKline:()=>qt,getConceptSpot:()=>Pt,getHKHistoryKline:()=>Ot,getHistoryKline:()=>xt,getIndustryConstituents:()=>Et,getIndustryKline:()=>Ut,getIndustryList:()=>at,getIndustryMinuteKline:()=>Bt,getIndustrySpot:()=>It,getMinuteKline:()=>Lt,getUSHistoryKline:()=>wt});async function it(t,e,n,s,r=100,o){let i=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(r),fields:s}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;a===1&&(l=d.total??0);let m=d.diff.map((h,C)=>o(h,i.length+C+1));i.push(...m),a++}while(i.length<l);return i}function O(t){let[e,n,s,r,o,i,a,l,u,c,p]=t.split(",");return{date:e,open:g(n),close:g(s),high:g(r),low:g(o),volume:g(i),amount:g(a),amplitude:g(l),changePercent:g(u),change:g(c),turnoverRate:g(p)}}async function w(t,e,n){let s=`${e}?${n.toString()}`,r=await t.get(s,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function xt(t,e,n={}){let{period:s="daily",adjust:r="qfq",startDate:o="19700101",endDate:i="20500101"}=n;x(s),M(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${ue(e)}.${a}`,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:A(r),secid:l,beg:o,end:i}),c=le,{klines:p}=await w(t,c,u);return p.length===0?[]:p.map(d=>({...O(d),code:a}))}async function Lt(t,e,n={}){let{period:s="1",adjust:r="qfq",startDate:o="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;z(s),M(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${ue(e)}.${a}`;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:l}),c=`${Be}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=o.replace("T"," ").slice(0,16),h=i.replace("T"," ").slice(0,16);return d.map(C=>{let[T,I,_,N,Ae,_e,vt,jt]=C.split(",");return{time:T,open:g(I),close:g(_),high:g(N),low:g(Ae),volume:g(_e),amount:g(vt),avgPrice:g(jt)}}).filter(C=>C.time>=m&&C.time<=h)}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:A(r||""),secid:l,beg:"0",end:"20500000"}),c=le,{klines:p}=await w(t,c,u);if(p.length===0)return[];let d=o.replace("T"," ").slice(0,16),m=i.replace("T"," ").slice(0,16);return p.map(h=>{let C=O(h);return{...C,time:C.date}}).filter(h=>h.time>=d&&h.time<=m)}}async function Ot(t,e,n={}){let{period:s="daily",adjust:r="qfq",startDate:o="19700101",endDate:i="20500101"}=n;x(s),M(r);let a=e.replace(/^hk/i,"").padStart(5,"0"),l=`116.${a}`,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:A(r),secid:l,beg:o,end:i,lmt:"1000000"}),c=Pe,{klines:p,name:d}=await w(t,c,u);return p.length===0?[]:p.map(m=>({...O(m),code:a,name:d||""}))}async function wt(t,e,n={}){let{period:s="daily",adjust:r="qfq",startDate:o="19700101",endDate:i="20500101"}=n;x(s),M(r);let a=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:A(r),secid:e,beg:o,end:i,lmt:"1000000"}),l=ke,{klines:u,name:c,code:p}=await w(t,l,a),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(h=>({...O(h),code:d,name:m}))}function he(t){let e=null;return{async getCode(n,s,r){if(s.startsWith("BK"))return s;if(!e){let i=await r(n);e=new Map(i.map(a=>[a.name,a.code]))}let o=e.get(s);if(!o)throw new Error(`${t.errorPrefix}: ${s}`);return o}}}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",r=await it(t,e.listUrl,n,s,100,(o,i)=>({rank:i,name:String(o.f14??""),code:String(o.f12??""),price:R(o.f2),change:R(o.f4),changePercent:R(o.f3),totalMarketCap:R(o.f20),turnoverRate:R(o.f8),riseCount:R(o.f104),fallCount:R(o.f105),leadingStock:o.f128?String(o.f128):null,leadingStockChangePercent:R(o.f136)}));return r.sort((o,i)=>(i.changePercent??0)-(o.changePercent??0)),r.forEach((o,i)=>{o.rank=i+1}),r}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}`}),r=`${n}?${s.toString()}`,i=(await t.get(r,{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:l,name:u,divide:c})=>{let p=i[l],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 it(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,(o,i)=>({rank:i,code:String(o.f12??""),name:String(o.f14??""),price:R(o.f2),changePercent:R(o.f3),change:R(o.f4),volume:R(o.f5),amount:R(o.f6),amplitude:R(o.f7),high:R(o.f15),low:R(o.f16),open:R(o.f17),prevClose:R(o.f18),turnoverRate:R(o.f8),pe:R(o.f9),pb:R(o.f23)}))}async function be(t,e,n,s={}){let{period:r="daily",adjust:o="",startDate:i="19700101",endDate:a="20500101"}=s;x(r),M(o);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:L(r),fqt:A(o),beg:i,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await w(t,n,l);return u.length===0?[]:u.map(c=>O(c))}async function Se(t,e,n,s,r={}){let{period:o="5"}=r;if(z(o),o==="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}`}),a=`${s}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,h,C,T,I,_]=c.split(",");return{time:p,open:g(d),close:g(m),high:g(h),low:g(C),volume:g(T),amount:g(I),price:g(_)}})}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:o,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),a=`${n}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,h,C,T,I,_,N,Ae,_e]=c.split(",");return{time:p,open:g(d),close:g(m),high:g(h),low:g(C),changePercent:g(N),change:g(Ae),volume:g(T),amount:g(I),amplitude:g(_),turnoverRate:g(_e)}})}}var D={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:De,spotUrl:qe,consUrl:He,klineUrl:Ne,trendsUrl:ve,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},nn=he(D);async function Te(t,e){return nn.getCode(t,e,at)}async function at(t){return ye(t,D)}async function It(t,e){let n=await Te(t,e);return Ce(t,n,D.spotUrl)}async function Et(t,e){let n=await Te(t,e);return Re(t,n,D.consUrl)}async function Ut(t,e,n={}){let s=await Te(t,e);return be(t,s,D.klineUrl,n)}async function Bt(t,e,n={}){let s=await Te(t,e);return Se(t,s,D.klineUrl,D.trendsUrl,n)}var q={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:je,spotUrl:Qe,consUrl:Fe,klineUrl:$e,trendsUrl:We,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},rn=he(q);async function Ke(t,e){return rn.getCode(t,e,lt)}async function lt(t){return ye(t,q)}async function Pt(t,e){let n=await Ke(t,e);return Ce(t,n,q.spotUrl)}async function kt(t,e){let n=await Ke(t,e);return Re(t,n,q.consUrl)}async function Dt(t,e,n={}){let s=await Ke(t,e);return be(t,s,q.klineUrl,n)}async function qt(t,e,n={}){let s=await Ke(t,e);return Se(t,s,q.klineUrl,q.trendsUrl,n)}function Y(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function E(t,e){let n=[];for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let r=0,o=0;for(let i=s-e+1;i<=s;i++)t[i]!==null&&(r+=t[i],o++);n.push(o===e?Y(r/e):null)}return n}function U(t,e){let n=[],s=2/(e+1),r=null,o=!1;for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}if(!o){let l=0,u=0;for(let c=i-e+1;c<=i;c++)t[c]!==null&&(l+=t[c],u++);u===e&&(r=l/e,o=!0),n.push(r!==null?Y(r):null);continue}let a=t[i];a===null?n.push(r!==null?Y(r):null):(r=s*a+(1-s)*r,n.push(Y(r)))}return n}function Me(t,e){let n=[],s=Array.from({length:e},(o,i)=>i+1),r=s.reduce((o,i)=>o+i,0);for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}let i=0,a=!0;for(let l=0;l<e;l++){let u=t[o-e+1+l];if(u===null){a=!1;break}i+=u*s[l]}n.push(a?Y(i/r):null)}return n}function J(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:s="sma"}=e,r=s==="ema"?U:s==="wma"?Me:E,o={};for(let i of n)o[`ma${i}`]=r(t,i);return t.map((i,a)=>{let l={};for(let u of n)l[`ma${u}`]=o[`ma${u}`][a];return l})}function Ht(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function X(t,e={}){let{short:n=12,long:s=26,signal:r=9}=e,o=U(t,n),i=U(t,s),a=t.map((u,c)=>o[c]===null||i[c]===null?null:o[c]-i[c]),l=U(a,r);return t.map((u,c)=>({dif:a[c]!==null?Ht(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?Ht((a[c]-l[c])*2):null}))}function ut(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function on(t,e,n){let s=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){s.push(null);continue}let o=0,i=0;for(let a=r-e+1;a<=r;a++)t[a]!==null&&n[r]!==null&&(o+=Math.pow(t[a]-n[r],2),i++);s.push(i===e?Math.sqrt(o/e):null)}return s}function Z(t,e={}){let{period:n=20,stdDev:s=2}=e,r=E(t,n),o=on(t,n,r);return t.map((i,a)=>{if(r[a]===null||o[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=r[a]+s*o[a],u=r[a]-s*o[a],c=r[a]!==0?ut((l-u)/r[a]*100):null;return{mid:r[a],upper:ut(l),lower:ut(u),bandwidth:c}})}function ct(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ee(t,e={}){let{period:n=9,kPeriod:s=3,dPeriod:r=3}=e,o=[],i=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){o.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,p=!0;for(let C=l-n+1;C<=l;C++){if(t[C].high===null||t[C].low===null){p=!1;break}u=Math.max(u,t[C].high),c=Math.min(c,t[C].low)}let d=t[l].close;if(!p||d===null||u===c){o.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;i=(s-1)/s*i+1/s*m,a=(r-1)/r*a+1/r*i;let h=3*i-2*a;o.push({k:ct(i),d:ct(a),j:ct(h)})}return o}function sn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function te(t,e={}){let{periods:n=[6,12,24]}=e,s=[null];for(let o=1;o<t.length;o++)t[o]===null||t[o-1]===null?s.push(null):s.push(t[o]-t[o-1]);let r={};for(let o of n){let i=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<o){i.push(null),s[u]!==null&&(s[u]>0?a+=s[u]:l+=Math.abs(s[u]));continue}if(u===o)a=a/o,l=l/o;else{let c=s[u]??0,p=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(o-1)+p)/o,l=(l*(o-1)+d)/o}if(l===0)i.push(100);else if(a===0)i.push(0);else{let c=a/l;i.push(sn(100-100/(1+c)))}}r[`rsi${o}`]=i}return t.map((o,i)=>{let a={};for(let l of n)a[`rsi${l}`]=r[`rsi${l}`][i];return a})}function an(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ne(t,e={}){let{periods:n=[6,10]}=e,s={};for(let r of n){let o=[];for(let i=0;i<t.length;i++){if(i<r-1){o.push(null);continue}let a=-1/0,l=1/0,u=!0;for(let d=i-r+1;d<=i;d++){if(t[d].high===null||t[d].low===null){u=!1;break}a=Math.max(a,t[d].high),l=Math.min(l,t[d].low)}let c=t[i].close;if(!u||c===null||a===l){o.push(null);continue}let p=(a-c)/(a-l)*100;o.push(an(p))}s[`wr${r}`]=o}return t.map((r,o)=>{let i={};for(let a of n)i[`wr${a}`]=s[`wr${a}`][o];return i})}function ln(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={};for(let r of n){let o=E(t,r),i=[];for(let a=0;a<t.length;a++)if(t[a]===null||o[a]===null||o[a]===0)i.push(null);else{let l=(t[a]-o[a])/o[a]*100;i.push(ln(l))}s[`bias${r}`]=i}return t.map((r,o)=>{let i={};for(let a of n)i[`bias${a}`]=s[`bias${a}`][o];return i})}function un(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function oe(t,e={}){let{period:n=14}=e,s=[],r=t.map(o=>o.high===null||o.low===null||o.close===null?null:(o.high+o.low+o.close)/3);for(let o=0;o<t.length;o++){if(o<n-1){s.push({cci:null});continue}let i=0,a=0;for(let p=o-n+1;p<=o;p++)r[p]!==null&&(i+=r[p],a++);if(a!==n||r[o]===null){s.push({cci:null});continue}let l=i/n,u=0;for(let p=o-n+1;p<=o;p++)u+=Math.abs(r[p]-l);let c=u/n;if(c===0)s.push({cci:0});else{let p=(r[o]-l)/(.015*c);s.push({cci:un(p)})}}return s}function pt(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=[],r=[];for(let i=0;i<t.length;i++){let{high:a,low:l,close:u}=t[i];if(a===null||l===null||u===null){r.push(null);continue}if(i===0)r.push(a-l);else{let c=t[i-1].close;if(c===null)r.push(a-l);else{let p=a-l,d=Math.abs(a-c),m=Math.abs(l-c);r.push(Math.max(p,d,m))}}}let o=null;for(let i=0;i<t.length;i++){if(i<n-1){s.push({tr:r[i]!==null?pt(r[i]):null,atr:null});continue}if(i===n-1){let a=0,l=0;for(let u=0;u<n;u++)r[u]!==null&&(a+=r[u],l++);l===n&&(o=a/n)}else o!==null&&r[i]!==null&&(o=(o*(n-1)+r[i])/n);s.push({tr:r[i]!==null?pt(r[i]):null,atr:o!==null?pt(o):null})}return s}function ie(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})),r=e.ma?J(n,typeof e.ma=="object"?e.ma:{}):null,o=e.macd?X(n,typeof e.macd=="object"?e.macd:{}):null,i=e.boll?Z(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?ee(s,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?te(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?ne(s,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?re(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?oe(s,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?se(s,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,h)=>({...m,...r&&{ma:r[h]},...o&&{macd:o[h]},...i&&{boll:i[h]},...a&&{kdj:a[h]},...l&&{rsi:l[h]},...u&&{wr:u[h]},...c&&{bias:c[h]},...p&&{cci:p[h]},...d&&{atr:d[h]}}))}var ae=class{constructor(e={}){this.client=new W(e)}getFullQuotes(e){return b.getFullQuotes(this.client,e)}getSimpleQuotes(e){return b.getSimpleQuotes(this.client,e)}getHKQuotes(e){return b.getHKQuotes(this.client,e)}getUSQuotes(e){return b.getUSQuotes(this.client,e)}getFundQuotes(e){return b.getFundQuotes(this.client,e)}getFundFlow(e){return b.getFundFlow(this.client,e)}getPanelLargeOrder(e){return b.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return b.getTodayTimeline(this.client,e)}getIndustryList(){return S.getIndustryList(this.client)}getIndustrySpot(e){return S.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return S.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return S.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return S.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return S.getConceptList(this.client)}getConceptSpot(e){return S.getConceptSpot(this.client,e)}getConceptConstituents(e){return S.getConceptConstituents(this.client,e)}getConceptKline(e,n){return S.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return S.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return S.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return S.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return S.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return S.getUSHistoryKline(this.client,e,n)}search(e){return b.search(this.client,e)}getAShareCodeList(e=!0){return b.getAShareCodeList(this.client,e)}getUSCodeList(e=!0){return b.getUSCodeList(this.client,e)}getHKCodeList(){return b.getHKCodeList(this.client)}async getAllAShareQuotes(e={}){let n=await this.getAShareCodeList();return this.getAllQuotesByCodes(n,e)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return b.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let n=await this.getUSCodeList(!1);return b.getAllUSQuotesByCodes(this.client,n,e)}getAllQuotesByCodes(e,n={}){return b.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return b.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 o=typeof e.ma=="object"?e.ma:{},i=o.periods??[5,10,20,30,60,120,250],a=o.type??"sma";n=Math.max(n,this.safeMax(i,20)),a==="ema"&&(s=!0)}if(e.macd){let o=typeof e.macd=="object"?e.macd:{},i=o.long??26,a=o.signal??9;n=Math.max(n,i*3+a),s=!0}if(e.boll){let o=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,o)}if(e.kdj){let o=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,o)}if(e.rsi){let o=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(o,14)+1)}if(e.wr){let o=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(o,10))}if(e.bias){let o=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(o,12))}if(e.cci){let o=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,o)}if(e.atr){let o=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,o)}return Math.ceil(n*(s?1.5:1.2))}calcActualStartDate(e,n,s=1.5){let r=Math.ceil(n*s),o=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));o.setDate(o.getDate()-r);let i=o.getFullYear(),a=String(o.getMonth()+1).padStart(2,"0"),l=String(o.getDate()).padStart(2,"0");return`${i}${a}${l}`}calcActualStartDateByCalendar(e,n,s){if(!s||s.length===0)return;let r=this.normalizeDate(e),o=s.findIndex(a=>a>=r);o===-1&&(o=s.length-1);let i=Math.max(0,o-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:r,indicators:o={}}=n,i=n.market??this.detectMarket(e),a=this.calcRequiredLookback(o),l={A:1.5,HK:1.46,US:1.45},u;if(s)if(i==="A")try{let m=await b.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(s,a,m)??this.calcActualStartDate(s,a,l[i])}catch{u=this.calcActualStartDate(s,a,l[i])}else u=this.calcActualStartDate(s,a,l[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<a)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=ie(p,o);if(s){let m=this.dateToTimestamp(s),h=r?this.dateToTimestamp(r):1/0;return d.filter(C=>{let T=this.dateToTimestamp(C.date);return T>=m&&T<=h})}return d}},Nt=ae;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcEMA,calcKDJ,calcMA,calcMACD,calcRSI,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});
|