stock-sdk 1.6.2 → 1.8.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/README.md CHANGED
@@ -55,6 +55,8 @@
55
55
  - ✅ **A 股、港股、美股、公募基金**实时行情
56
56
  - ✅ **历史 K 线**(日/周/月)、**分钟 K 线**(1/5/15/30/60 分钟)和**当日分时走势**数据
57
57
  - ✅ **技术指标**:内置 MA、MACD、BOLL、KDJ、RSI、WR 等常用指标计算
58
+ - ✅ **期货行情**:国内期货 K 线、全球期货实时行情与 K 线、期货库存数据
59
+ - ✅ **期权数据**:中金所股指期权、上交所 ETF 期权、商品期权的报价 / K 线 / 分钟行情
58
60
  - ✅ **资金流向**、**盘口大单**等扩展数据
59
61
  - ✅ 获取全部 **A 股代码列表**(5000+ 只股票)和批量获取**全市场行情**(内置并发控制)
60
62
 
@@ -161,6 +163,33 @@ console.log(`共获取 ${allQuotes.length} 只股票`);
161
163
  | `getConceptKline` | 概念板块历史 K 线(日/周/月) |
162
164
  | `getConceptMinuteKline` | 概念板块分时行情(1/5/15/30/60 分钟) |
163
165
 
166
+ ### 期货行情
167
+
168
+ | 方法 | 说明 |
169
+ |------|------|
170
+ | `getFuturesKline` | 国内期货历史 K 线(日/周/月) |
171
+ | `getGlobalFuturesSpot` | 全球期货实时行情 |
172
+ | `getGlobalFuturesKline` | 全球期货历史 K 线(日/周/月) |
173
+ | `getFuturesInventorySymbols` | 期货库存品种列表 |
174
+ | `getFuturesInventory` | 期货库存数据 |
175
+ | `getComexInventory` | COMEX 黄金/白银库存 |
176
+
177
+ ### 期权数据
178
+
179
+ | 方法 | 说明 |
180
+ |------|------|
181
+ | `getIndexOptionSpot` | 中金所股指期权 T 型报价(看涨 + 看跌) |
182
+ | `getIndexOptionKline` | 股指期权合约日 K 线 |
183
+ | `getCFFEXOptionQuotes` | 中金所全部期权实时行情列表 |
184
+ | `getETFOptionMonths` | 上交所 ETF 期权到期月份列表 |
185
+ | `getETFOptionExpireDay` | ETF 期权到期日与剩余天数 |
186
+ | `getETFOptionMinute` | ETF 期权当日分钟行情 |
187
+ | `getETFOptionDailyKline` | ETF 期权历史日 K 线 |
188
+ | `getETFOption5DayMinute` | ETF 期权 5 日分钟行情 |
189
+ | `getCommodityOptionSpot` | 商品期权 T 型报价 |
190
+ | `getCommodityOptionKline` | 商品期权合约日 K 线 |
191
+ | `getOptionLHB` | 期权龙虎榜 |
192
+
164
193
  ### 扩展数据
165
194
 
166
195
  | 方法 | 说明 |
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Le=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var ln=Object.prototype.hasOwnProperty;var Ie=(t,e)=>{for(var n in e)Le(t,n,{get:e[n],enumerable:!0})},an=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of on(e))!ln.call(t,r)&&r!==n&&Le(t,r,{get:()=>e[r],enumerable:!(i=sn(e,r))||i.enumerable});return t};var un=t=>an(Le({},"__esModule",{value:!0}),t);var Kn={};Ie(Kn,{HttpError:()=>D,StockSDK:()=>ce,addIndicators:()=>ue,asyncPool:()=>v,calcATR:()=>F,calcBIAS:()=>le,calcBOLL:()=>re,calcCCI:()=>ae,calcDMI:()=>bt,calcEMA:()=>E,calcKC:()=>At,calcKDJ:()=>se,calcMA:()=>te,calcMACD:()=>ne,calcOBV:()=>Rt,calcROC:()=>St,calcRSI:()=>ie,calcSAR:()=>Tt,calcSMA:()=>k,calcWMA:()=>Ee,calcWR:()=>oe,chunkArray:()=>B,decodeGBK:()=>W,default:()=>nn,parseResponse:()=>G,safeNumber:()=>h,safeNumberOrNull:()=>R});module.exports=un(Kn);function W(t){return new TextDecoder("gbk").decode(t)}function G(t){let e=t.split(";").map(i=>i.trim()).filter(Boolean),n=[];for(let i of e){let r=i.indexOf("=");if(r<0)continue;let s=i.slice(0,r).trim();s.startsWith("v_")&&(s=s.slice(2));let o=i.slice(r+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));let l=o.split("~");n.push({key:s,fields:l})}return n}function h(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function R(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function y(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function b(t){return t==null?null:y(String(t))}var Ke="https://qt.gtimg.cn",we="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Pe="https://assets.linkdiary.cn/shares/zh_a_list.json",Ue="https://assets.linkdiary.cn/shares/us_list.json",ke="https://assets.linkdiary.cn/shares/hk_list.json",De="https://assets.linkdiary.cn/shares/fund_list",Ot="https://assets.linkdiary.cn/shares/trade-data-list.txt";var pe="https://push2his.eastmoney.com/api/qt/stock/kline/get",Be="https://push2his.eastmoney.com/api/qt/stock/trends2/get",ve="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Ne="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",He="https://17.push2.eastmoney.com/api/qt/clist/get",qe="https://91.push2.eastmoney.com/api/qt/stock/get",Fe="https://29.push2.eastmoney.com/api/qt/clist/get",je="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Qe="https://push2his.eastmoney.com/api/qt/stock/trends2/get",$e="https://79.push2.eastmoney.com/api/qt/clist/get",We="https://91.push2.eastmoney.com/api/qt/stock/get",Ge="https://29.push2.eastmoney.com/api/qt/clist/get",Ve="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",ze="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Ye="https://datacenter-web.eastmoney.com/api/data/v1/get",Xe=3e4,V=500,z=500,Y=7,Je=3,Ze=1e3,et=3e4,tt=2,nt=[408,429,500,502,503,504];var fe=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),i=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+i),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Mt=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],rt=0;function cn(){return typeof window<"u"&&typeof window.document<"u"}function _t(){if(cn())return;let t=Mt[rt];return rt=(rt+1)%Mt.length,t}var X=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},de=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new X;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var D=class extends Error{constructor(n,i,r,s){let o=i?` ${i}`:"",l=r?`, url: ${r}`:"",a=s?`, provider: ${s}`:"";super(`HTTP error! status: ${n}${o}${l}${a}`);this.status=n;this.statusText=i;this.url=r;this.provider=s;this.name="HttpError"}},J=class{constructor(e={}){this.baseUrl=e.baseUrl??Ke,this.timeout=e.timeout??Xe,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new fe(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new de(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(i=>i.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Je,baseDelay:e?.baseDelay??Ze,maxDelay:e?.maxDelay??et,backoffMultiplier:e?.backoffMultiplier??tt,retryableStatusCodes:e?.retryableStatusCodes??nt,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof D?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let i=await e();return this.circuitBreaker?.recordSuccess(),i}catch(i){if(this.shouldRetry(i,n)){let r=this.calculateDelay(n);return this.retryOptions.onRetry&&i instanceof Error&&this.retryOptions.onRetry(n+1,i,r),await this.sleep(r),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),i}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new X("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let i=new AbortController,r=setTimeout(()=>i.abort(),this.timeout),s=this.inferProvider(e),o={...this.headers};if(this.rotateUserAgent){let l=_t();l&&(o["User-Agent"]=l)}try{let l=await fetch(e,{signal:i.signal,headers:o});if(!l.ok)throw new D(l.status,l.statusText,e,s);switch(n.responseType){case"json":return await l.json();case"arraybuffer":return await l.arrayBuffer();default:return await l.text()}}catch(l){throw l instanceof Error&&(l.url=e,l.provider=s),l}finally{clearTimeout(r)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,i=await this.get(n,{responseType:"arraybuffer"}),r=W(i);return G(r)}};var pn=new Set(["daily","weekly","monthly"]),fn=new Set(["1","5","15","30","60"]),dn=new Set(["","qfq","hfq"]);function M(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function I(t){if(!pn.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function Z(t){if(!fn.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function _(t){if(!dn.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function B(t,e){M(e,"chunkSize");let n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n}async function v(t,e){M(e,"concurrency");let n=[],i=[];for(let r of t){let s=Promise.resolve().then(()=>r()).then(o=>{n.push(o)});if(i.push(s),i.length>=e){await Promise.race(i);for(let o=i.length-1;o>=0;o--)await Promise.race([i[o].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&i.splice(o,1)}}return await Promise.all(i),n}function me(t){return t.startsWith("sh")?"1":t.startsWith("sz")||t.startsWith("bj")?"0":t.startsWith("6")?"1":"0"}function K(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function x(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var T={};Ie(T,{getAShareCodeList:()=>wt,getAllHKQuotesByCodes:()=>Dt,getAllQuotesByCodes:()=>kt,getAllUSQuotesByCodes:()=>Bt,getFullQuotes:()=>he,getFundCodeList:()=>vt,getFundFlow:()=>Et,getFundQuotes:()=>It,getHKCodeList:()=>Ut,getHKQuotes:()=>ge,getPanelLargeOrder:()=>Lt,getSimpleQuotes:()=>xt,getTodayTimeline:()=>Kt,getTradingCalendar:()=>Nt,getUSCodeList:()=>Pt,getUSQuotes:()=>ye,parseFullQuote:()=>st,parseFundFlow:()=>ot,parseFundQuote:()=>ct,parseHKQuote:()=>at,parsePanelLargeOrder:()=>lt,parseSimpleQuote:()=>it,parseUSQuote:()=>ut,search:()=>qt});function st(t){let e=[];for(let i=0;i<5;i++)e.push({price:h(t[9+i*2]),volume:h(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:h(t[19+i*2]),volume:h(t[20+i*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),outerVolume:h(t[7]),innerVolume:h(t[8]),bid:e,ask:n,time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),volume2:h(t[36]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),pb:R(t[46]),limitUp:R(t[47]),limitDown:R(t[48]),volumeRatio:R(t[49]),avgPrice:R(t[51]),peStatic:R(t[52]),peDynamic:R(t[53]),high52w:R(t[67]),low52w:R(t[68]),circulatingShares:R(t[72]),totalShares:R(t[73]),raw:t}}function it(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),change:h(t[4]),changePercent:h(t[5]),volume:h(t[6]),amount:h(t[7]),marketCap:R(t[9]),marketType:t[10]??"",raw:t}}function ot(t){return{code:t[0]??"",mainInflow:h(t[1]),mainOutflow:h(t[2]),mainNet:h(t[3]),mainNetRatio:h(t[4]),retailInflow:h(t[5]),retailOutflow:h(t[6]),retailNet:h(t[7]),retailNetRatio:h(t[8]),totalFlow:h(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function lt(t){return{buyLargeRatio:h(t[0]),buySmallRatio:h(t[1]),sellLargeRatio:h(t[2]),sellSmallRatio:h(t[3]),raw:t}}function at(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),lotSize:R(t[40]),circulatingMarketCap:R(t[44]),totalMarketCap:R(t[45]),currency:t[t.length-3]??"",raw:t}}function ut(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:h(t[3]),prevClose:h(t[4]),open:h(t[5]),volume:h(t[6]),time:t[30]??"",change:h(t[31]),changePercent:h(t[32]),high:h(t[33]),low:h(t[34]),amount:h(t[37]),turnoverRate:R(t[38]),pe:R(t[39]),amplitude:R(t[43]),totalMarketCap:R(t[45]),pb:R(t[47]),high52w:R(t[48]),low52w:R(t[49]),raw:t}}function ct(t){return{code:t[0]??"",name:t[1]??"",nav:h(t[5]),accNav:h(t[6]),change:h(t[7]),navDate:t[8]??"",raw:t}}async function he(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(i=>i.fields&&i.fields.length>0&&i.fields[0]!=="").map(i=>st(i.fields))}async function xt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>it(r.fields))}async function Et(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`ff_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ot(r.fields))}async function Lt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_pk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>lt(r.fields))}async function ge(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`hk${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>at(r.fields))}async function ye(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`us${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ut(r.fields))}async function It(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`jj${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>ct(r.fields))}async function Kt(t,e){let n=t.getTimeout(),i=new AbortController,r=setTimeout(()=>i.abort(),n);try{let s=await fetch(`${we}?code=${e}`,{signal:i.signal});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);let o=await s.json();if(o.code!==0)throw new Error(o.msg||"API error");let l=o.data?.[e];if(!l)return{code:e,date:"",data:[]};let a=l.data?.data||[],u=l.data?.date||"",c=!1;if(a.length>0){let d=a[0].split(" "),m=parseFloat(d[1])||0,g=parseInt(d[2],10)||0,f=parseFloat(d[3])||0;g>0&&m>0&&f/g>m*50&&(c=!0)}let p=a.map(d=>{let m=d.split(" "),g=m[0],f=`${g.slice(0,2)}:${g.slice(2,4)}`,C=parseInt(m[2],10)||0,S=parseFloat(m[3])||0,O=c?C*100:C,L=O>0?S/O:0;return{time:f,price:parseFloat(m[1])||0,volume:O,amount:S,avgPrice:Math.round(L*100)/100}});return{code:e,date:u,data:p}}finally{clearTimeout(r)}}var pt=null,mn=null,Ce=null,hn=null,Re=null,ft=null;function gn(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function wt(t,e){let n=!1,i;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),!pt){let o=(await t.get(Pe,{responseType:"json"}))?.list||[];pt=o,mn=o.map(l=>l.replace(/^(sh|sz|bj)/,""))}let r=pt;return i&&(r=r.filter(s=>gn(s,i))),n?r.map(s=>s.replace(/^(sh|sz|bj)/,"")):r.slice()}var yn={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function Pt(t,e){let n=!1,i;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,i=e.market),Ce||(Ce=(await t.get(Ue,{responseType:"json"}))?.list||[],hn=Ce.map(o=>o.replace(/^\d{3}\./,"")));let r=Ce.slice();if(i){let s=yn[i];r=r.filter(o=>o.startsWith(s))}return n?r.map(s=>s.replace(/^\d{3}\./,"")):r}async function Ut(t){return Re||(Re=(await t.get(ke,{responseType:"json"}))?.list||[]),Re.slice()}async function kt(t,e,n={}){let{batchSize:i=V,concurrency:r=Y,onProgress:s}=n;M(i,"batchSize"),M(r,"concurrency");let o=Math.min(i,z),l=B(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await he(t,d);return u++,s&&s(u,a),m});return(await v(c,r)).flat()}async function Dt(t,e,n={}){let{batchSize:i=V,concurrency:r=Y,onProgress:s}=n;M(i,"batchSize"),M(r,"concurrency");let o=Math.min(i,z),l=B(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ge(t,d);return u++,s&&s(u,a),m});return(await v(c,r)).flat()}async function Bt(t,e,n={}){let{batchSize:i=V,concurrency:r=Y,onProgress:s}=n;M(i,"batchSize"),M(r,"concurrency");let o=Math.min(i,z),l=B(e,o),a=l.length,u=0,c=l.map(d=>async()=>{let m=await ye(t,d);return u++,s&&s(u,a),m});return(await v(c,r)).flat()}async function vt(t){if(ft)return ft.slice();let i=(await t.get(De,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return ft=i,i.slice()}var Q=null;async function Nt(t){if(Q)return Q.slice();let e=await t.get(Ot);return!e||e.trim()===""?(Q=[],Q.slice()):(Q=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),Q.slice())}var Ht="https://smartbox.gtimg.cn/s3/";function Cn(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function Rn(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let i=n.split("~"),r=i[0]||"",s=i[1]||"",o=Cn(i[2]||""),l=i[4]||"";return{code:r+s,name:o,market:r,type:l}})}function Sn(t){return new Promise((e,n)=>{let i=`${Ht}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=i,r.charset="utf-8",r.onload=()=>{let s=window.v_hint||"";document.body.removeChild(r),e(s)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function bn(t,e){let n=`${Ht}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function Tn(){return typeof window<"u"&&typeof document<"u"}async function qt(t,e){if(!e||!e.trim())return[];let n;return Tn()?n=await Sn(e):n=await bn(t,e),Rn(n)}var A={};Ie(A,{getConceptConstituents:()=>Xt,getConceptKline:()=>Jt,getConceptList:()=>ht,getConceptMinuteKline:()=>Zt,getConceptSpot:()=>Yt,getDividendDetail:()=>en,getHKHistoryKline:()=>Qt,getHistoryKline:()=>Ft,getIndustryConstituents:()=>Gt,getIndustryKline:()=>Vt,getIndustryList:()=>mt,getIndustryMinuteKline:()=>zt,getIndustrySpot:()=>Wt,getMinuteKline:()=>jt,getUSHistoryKline:()=>$t});async function dt(t,e,n,i,r=100,s){let o=[],l=1,a=0;do{let u=new URLSearchParams({...n,pn:String(l),pz:String(r),fields:i}),c=`${e}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data;if(!d||!Array.isArray(d.diff))break;l===1&&(a=d.total??0);let m=d.diff.map((g,f)=>s(g,o.length+f+1));o.push(...m),l++}while(o.length<a);return o}function w(t){let[e,n,i,r,s,o,l,a,u,c,p]=t.split(",");return{date:e,open:y(n),close:y(i),high:y(r),low:y(s),volume:y(o),amount:y(l),amplitude:y(a),changePercent:y(u),change:y(c),turnoverRate:y(p)}}async function P(t,e,n){let i=`${e}?${n.toString()}`,r=await t.get(i,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function Ft(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:s="19700101",endDate:o="20500101"}=n;I(i),_(r);let l=e.replace(/^(sh|sz|bj)/,""),a=`${me(e)}.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(r),secid:a,beg:s,end:o}),c=pe,{klines:p}=await P(t,c,u);return p.length===0?[]:p.map(d=>({...w(d),code:l}))}async function jt(t,e,n={}){let{period:i="1",adjust:r="qfq",startDate:s="1979-09-01 09:32:00",endDate:o="2222-01-01 09:32:00"}=n;Z(i),_(r);let l=e.replace(/^(sh|sz|bj)/,""),a=`${me(e)}.${l}`;if(i==="1"){let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",ut:"7eea3edcaed734bea9cbfc24409ed989",ndays:"5",iscr:"0",secid:a}),c=`${Be}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let m=s.replace("T"," ").slice(0,16),g=o.replace("T"," ").slice(0,16);return d.map(f=>{let[C,S,O,L,$,U,j,rn]=f.split(",");return{time:C,open:y(S),close:y(O),high:y(L),low:y($),volume:y(U),amount:y(j),avgPrice:y(rn)}}).filter(f=>f.time>=m&&f.time<=g)}else{let u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:i,fqt:x(r||""),secid:a,beg:"0",end:"20500000"}),c=pe,{klines:p}=await P(t,c,u);if(p.length===0)return[];let d=s.replace("T"," ").slice(0,16),m=o.replace("T"," ").slice(0,16);return p.map(g=>{let f=w(g);return{...f,time:f.date}}).filter(g=>g.time>=d&&g.time<=m)}}async function Qt(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:s="19700101",endDate:o="20500101"}=n;I(i),_(r);let l=e.replace(/^hk/i,"").padStart(5,"0"),a=`116.${l}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(r),secid:a,beg:s,end:o,lmt:"1000000"}),c=ve,{klines:p,name:d}=await P(t,c,u);return p.length===0?[]:p.map(m=>({...w(m),code:l,name:d||""}))}async function $t(t,e,n={}){let{period:i="daily",adjust:r="qfq",startDate:s="19700101",endDate:o="20500101"}=n;I(i),_(r);let l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:K(i),fqt:x(r),secid:e,beg:s,end:o,lmt:"1000000"}),a=Ne,{klines:u,name:c,code:p}=await P(t,a,l),d=p||e.split(".")[1]||e,m=c||"";return u.length===0?[]:u.map(g=>({...w(g),code:d,name:m}))}function Se(t){let e=null;return{async getCode(n,i,r){if(i.startsWith("BK"))return i;if(!e){let o=await r(n);e=new Map(o.map(l=>[l.name,l.code]))}let s=e.get(i);if(!s)throw new Error(`${t.errorPrefix}: ${i}`);return s}}}async function be(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},i=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await dt(t,e.listUrl,n,i,100,(s,o)=>({rank:o,name:String(s.f14??""),code:String(s.f12??""),price:b(s.f2),change:b(s.f4),changePercent:b(s.f3),totalMarketCap:b(s.f20),turnoverRate:b(s.f8),riseCount:b(s.f104),fallCount:b(s.f105),leadingStock:s.f128?String(s.f128):null,leadingStockChangePercent:b(s.f136)}));return r.sort((s,o)=>(o.changePercent??0)-(s.changePercent??0)),r.forEach((s,o)=>{s.rank=o+1}),r}async function Te(t,e,n){let i=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${i.toString()}`,o=(await t.get(r,{responseType:"json"}))?.data;return o?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:a,name:u,divide:c})=>{let p=o[a],d=null;return typeof p=="number"&&!isNaN(p)&&(d=c?p/100:p),{item:u,value:d}}):[]}async function Ae(t,e,n){let i={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return dt(t,n,i,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(s,o)=>({rank:o,code:String(s.f12??""),name:String(s.f14??""),price:b(s.f2),changePercent:b(s.f3),change:b(s.f4),volume:b(s.f5),amount:b(s.f6),amplitude:b(s.f7),high:b(s.f15),low:b(s.f16),open:b(s.f17),prevClose:b(s.f18),turnoverRate:b(s.f8),pe:b(s.f9),pb:b(s.f23)}))}async function Oe(t,e,n,i={}){let{period:r="daily",adjust:s="",startDate:o="19700101",endDate:l="20500101"}=i;I(r),_(s);let a=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:K(r),fqt:x(s),beg:o,end:l,smplmt:"10000",lmt:"1000000"}),{klines:u}=await P(t,n,a);return u.length===0?[]:u.map(c=>w(c))}async function Me(t,e,n,i,r={}){let{period:s="5"}=r;if(Z(s),s==="1"){let o=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",iscr:"0",ndays:"1",secid:`90.${e}`}),l=`${i}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),volume:y(C),amount:y(S),price:y(O)}})}else{let o=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:s,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),l=`${n}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.data?.klines;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[p,d,m,g,f,C,S,O,L,$,U]=c.split(",");return{time:p,open:y(d),close:y(m),high:y(g),low:y(f),changePercent:y(L),change:y($),volume:y(C),amount:y(S),amplitude:y(O),turnoverRate:y(U)}})}}var N={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:He,spotUrl:qe,consUrl:Fe,klineUrl:je,trendsUrl:Qe,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},An=Se(N);async function _e(t,e){return An.getCode(t,e,mt)}async function mt(t){return be(t,N)}async function Wt(t,e){let n=await _e(t,e);return Te(t,n,N.spotUrl)}async function Gt(t,e){let n=await _e(t,e);return Ae(t,n,N.consUrl)}async function Vt(t,e,n={}){let i=await _e(t,e);return Oe(t,i,N.klineUrl,n)}async function zt(t,e,n={}){let i=await _e(t,e);return Me(t,i,N.klineUrl,N.trendsUrl,n)}var H={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:$e,spotUrl:We,consUrl:Ge,klineUrl:Ve,trendsUrl:ze,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},On=Se(H);async function xe(t,e){return On.getCode(t,e,ht)}async function ht(t){return be(t,H)}async function Yt(t,e){let n=await xe(t,e);return Te(t,n,H.spotUrl)}async function Xt(t,e){let n=await xe(t,e);return Ae(t,n,H.consUrl)}async function Jt(t,e,n={}){let i=await xe(t,e);return Oe(t,i,H.klineUrl,n)}async function Zt(t,e,n={}){let i=await xe(t,e);return Me(t,i,H.klineUrl,H.trendsUrl,n)}function q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Mn(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:q(t.REPORT_DATE),planNoticeDate:q(t.PLAN_NOTICE_DATE),disclosureDate:q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:q(t.EQUITY_RECORD_DATE),exDividendDate:q(t.EX_DIVIDEND_DATE),payDate:q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:q(t.NOTICE_DATE)}}async function en(t,e){let n=e.replace(/^(sh|sz|bj)/,""),i=[],r=1,s=1;do{let o=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),l=`${Ye}?${o.toString()}`,u=(await t.get(l,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(s=u.pages??1);let c=u.data.map(Mn);i.push(...c),r++}while(r<=s);return i}function ee(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function k(t,e){let n=[];for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}let r=0,s=0;for(let o=i-e+1;o<=i;o++)t[o]!==null&&(r+=t[o],s++);n.push(s===e?ee(r/e):null)}return n}function E(t,e){let n=[],i=2/(e+1),r=null,s=!1;for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}if(!s){let a=0,u=0;for(let c=o-e+1;c<=o;c++)t[c]!==null&&(a+=t[c],u++);u===e&&(r=a/e,s=!0),n.push(r!==null?ee(r):null);continue}let l=t[o];l===null?n.push(r!==null?ee(r):null):(r=i*l+(1-i)*r,n.push(ee(r)))}return n}function Ee(t,e){let n=[],i=Array.from({length:e},(s,o)=>o+1),r=i.reduce((s,o)=>s+o,0);for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let o=0,l=!0;for(let a=0;a<e;a++){let u=t[s-e+1+a];if(u===null){l=!1;break}o+=u*i[a]}n.push(l?ee(o/r):null)}return n}function te(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:i="sma"}=e,r=i==="ema"?E:i==="wma"?Ee:k,s={};for(let o of n)s[`ma${o}`]=r(t,o);return t.map((o,l)=>{let a={};for(let u of n)a[`ma${u}`]=s[`ma${u}`][l];return a})}function tn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ne(t,e={}){let{short:n=12,long:i=26,signal:r=9}=e,s=E(t,n),o=E(t,i),l=t.map((u,c)=>s[c]===null||o[c]===null?null:s[c]-o[c]),a=E(l,r);return t.map((u,c)=>({dif:l[c]!==null?tn(l[c]):null,dea:a[c],macd:l[c]!==null&&a[c]!==null?tn((l[c]-a[c])*2):null}))}function gt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function _n(t,e,n){let i=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){i.push(null);continue}let s=0,o=0;for(let l=r-e+1;l<=r;l++)t[l]!==null&&n[r]!==null&&(s+=Math.pow(t[l]-n[r],2),o++);i.push(o===e?Math.sqrt(s/e):null)}return i}function re(t,e={}){let{period:n=20,stdDev:i=2}=e,r=k(t,n),s=_n(t,n,r);return t.map((o,l)=>{if(r[l]===null||s[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let a=r[l]+i*s[l],u=r[l]-i*s[l],c=r[l]!==0?gt((a-u)/r[l]*100):null;return{mid:r[l],upper:gt(a),lower:gt(u),bandwidth:c}})}function yt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function se(t,e={}){let{period:n=9,kPeriod:i=3,dPeriod:r=3}=e,s=[],o=50,l=50;for(let a=0;a<t.length;a++){if(a<n-1){s.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,p=!0;for(let f=a-n+1;f<=a;f++){if(t[f].high===null||t[f].low===null){p=!1;break}u=Math.max(u,t[f].high),c=Math.min(c,t[f].low)}let d=t[a].close;if(!p||d===null||u===c){s.push({k:null,d:null,j:null});continue}let m=(d-c)/(u-c)*100;o=(i-1)/i*o+1/i*m,l=(r-1)/r*l+1/r*o;let g=3*o-2*l;s.push({k:yt(o),d:yt(l),j:yt(g)})}return s}function xn(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ie(t,e={}){let{periods:n=[6,12,24]}=e,i=[null];for(let s=1;s<t.length;s++)t[s]===null||t[s-1]===null?i.push(null):i.push(t[s]-t[s-1]);let r={};for(let s of n){let o=[],l=0,a=0;for(let u=0;u<t.length;u++){if(u<s){o.push(null),i[u]!==null&&(i[u]>0?l+=i[u]:a+=Math.abs(i[u]));continue}if(u===s)l=l/s,a=a/s;else{let c=i[u]??0,p=c>0?c:0,d=c<0?Math.abs(c):0;l=(l*(s-1)+p)/s,a=(a*(s-1)+d)/s}if(a===0)o.push(100);else if(l===0)o.push(0);else{let c=l/a;o.push(xn(100-100/(1+c)))}}r[`rsi${s}`]=o}return t.map((s,o)=>{let l={};for(let a of n)l[`rsi${a}`]=r[`rsi${a}`][o];return l})}function En(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function oe(t,e={}){let{periods:n=[6,10]}=e,i={};for(let r of n){let s=[];for(let o=0;o<t.length;o++){if(o<r-1){s.push(null);continue}let l=-1/0,a=1/0,u=!0;for(let d=o-r+1;d<=o;d++){if(t[d].high===null||t[d].low===null){u=!1;break}l=Math.max(l,t[d].high),a=Math.min(a,t[d].low)}let c=t[o].close;if(!u||c===null||l===a){s.push(null);continue}let p=(l-c)/(l-a)*100;s.push(En(p))}i[`wr${r}`]=s}return t.map((r,s)=>{let o={};for(let l of n)o[`wr${l}`]=i[`wr${l}`][s];return o})}function Ln(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function le(t,e={}){let{periods:n=[6,12,24]}=e,i={};for(let r of n){let s=k(t,r),o=[];for(let l=0;l<t.length;l++)if(t[l]===null||s[l]===null||s[l]===0)o.push(null);else{let a=(t[l]-s[l])/s[l]*100;o.push(Ln(a))}i[`bias${r}`]=o}return t.map((r,s)=>{let o={};for(let l of n)o[`bias${l}`]=i[`bias${l}`][s];return o})}function In(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ae(t,e={}){let{period:n=14}=e,i=[],r=t.map(s=>s.high===null||s.low===null||s.close===null?null:(s.high+s.low+s.close)/3);for(let s=0;s<t.length;s++){if(s<n-1){i.push({cci:null});continue}let o=0,l=0;for(let p=s-n+1;p<=s;p++)r[p]!==null&&(o+=r[p],l++);if(l!==n||r[s]===null){i.push({cci:null});continue}let a=o/n,u=0;for(let p=s-n+1;p<=s;p++)u+=Math.abs(r[p]-a);let c=u/n;if(c===0)i.push({cci:0});else{let p=(r[s]-a)/(.015*c);i.push({cci:In(p)})}}return i}function Ct(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function F(t,e={}){let{period:n=14}=e,i=[],r=[];for(let o=0;o<t.length;o++){let{high:l,low:a,close:u}=t[o];if(l===null||a===null||u===null){r.push(null);continue}if(o===0)r.push(l-a);else{let c=t[o-1].close;if(c===null)r.push(l-a);else{let p=l-a,d=Math.abs(l-c),m=Math.abs(a-c);r.push(Math.max(p,d,m))}}}let s=null;for(let o=0;o<t.length;o++){if(o<n-1){i.push({tr:r[o]!==null?Ct(r[o]):null,atr:null});continue}if(o===n-1){let l=0,a=0;for(let u=0;u<n;u++)r[u]!==null&&(l+=r[u],a++);a===n&&(s=l/n)}else s!==null&&r[o]!==null&&(s=(s*(n-1)+r[o])/n);i.push({tr:r[o]!==null?Ct(r[o]):null,atr:s!==null?Ct(s):null})}return i}function Rt(t,e={}){let{maPeriod:n}=e,i=[];if(t.length===0)return i;let r=t[0].volume??0;i.push({obv:r,obvMa:null});for(let s=1;s<t.length;s++){let o=t[s],l=t[s-1];if(o.close===null||l.close===null||o.volume===null||o.volume===void 0){i.push({obv:null,obvMa:null});continue}o.close>l.close?r+=o.volume:o.close<l.close&&(r-=o.volume),i.push({obv:r,obvMa:null})}if(n&&n>0)for(let s=n-1;s<i.length;s++){let o=0,l=0;for(let a=s-n+1;a<=s;a++)i[a].obv!==null&&(o+=i[a].obv,l++);l===n&&(i[s].obvMa=o/n)}return i}function St(t,e={}){let{period:n=12,signalPeriod:i}=e,r=[];for(let s=0;s<t.length;s++){if(s<n){r.push({roc:null,signal:null});continue}let o=t[s].close,l=t[s-n].close;if(o===null||l===null||l===0){r.push({roc:null,signal:null});continue}let a=(o-l)/l*100;r.push({roc:a,signal:null})}if(i&&i>0)for(let s=n+i-1;s<r.length;s++){let o=0,l=0;for(let a=s-i+1;a<=s;a++)r[a].roc!==null&&(o+=r[a].roc,l++);l===i&&(r[s].signal=o/i)}return r}function bt(t,e={}){let{period:n=14,adxPeriod:i=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let s=[],o=[],l=[];for(let f=0;f<t.length;f++){if(f===0){s.push(0),o.push(0),l.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let C=t[f],S=t[f-1];if(C.high===null||C.low===null||C.close===null||S.high===null||S.low===null||S.close===null){s.push(0),o.push(0),l.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=C.high-C.low,L=Math.abs(C.high-S.close),$=Math.abs(C.low-S.close);l.push(Math.max(O,L,$));let U=C.high-S.high,j=S.low-C.low;U>j&&U>0?s.push(U):s.push(0),j>U&&j>0?o.push(j):o.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let a=0,u=0,c=0,p=[];for(let f=1;f<t.length;f++){if(f<n){a+=l[f],u+=s[f],c+=o[f],p.push(0);continue}f===n?(a=a,u=u,c=c):(a=a-a/n+l[f],u=u-u/n+s[f],c=c-c/n+o[f]);let C=a>0?u/a*100:0,S=a>0?c/a*100:0;r[f].pdi=C,r[f].mdi=S;let O=C+S,L=O>0?Math.abs(C-S)/O*100:0;p.push(L)}let d=0,m=0,g=0;for(let f=n;f<t.length;f++){if(f<n*2-1){d+=p[f-n+1]||0,m++;continue}if(f===n*2-1)d+=p[f-n+1]||0,g=d/i,r[f].adx=g;else{let C=p[f-n+1]||0;g=(g*(i-1)+C)/i,r[f].adx=g}}for(let f=n*2-1+i;f<t.length;f++){let C=r[f].adx,S=r[f-i]?.adx;C!==null&&S!==null&&(r[f].adxr=(C+S)/2)}return r}function Tt(t,e={}){let{afStart:n=.02,afIncrement:i=.02,afMax:r=.2}=e,s=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,l=n,a=t[0].high??0,u=t[0].low??0,c=t[0],p=t[1];c.close!==null&&p.close!==null&&p.close<c.close&&(o=-1,a=c.low??0,u=c.high??0),s.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let m=t[d],g=t[d-1];if(m.high===null||m.low===null||g.high===null||g.low===null){s.push({sar:null,trend:null,ep:null,af:null});continue}let f=u+l*(a-u);o===1?(f=Math.min(f,g.low,t[Math.max(0,d-2)]?.low??g.low),m.low<f?(o=-1,f=a,a=m.low,l=n):m.high>a&&(a=m.high,l=Math.min(l+i,r))):(f=Math.max(f,g.high,t[Math.max(0,d-2)]?.high??g.high),m.high>f?(o=1,f=a,a=m.high,l=n):m.low<a&&(a=m.low,l=Math.min(l+i,r))),u=f,s.push({sar:u,trend:o,ep:a,af:l})}return s}function At(t,e={}){let{emaPeriod:n=20,atrPeriod:i=10,multiplier:r=2}=e,s=[],o=t.map(u=>u.close),l=E(o,n),a=F(t,{period:i});for(let u=0;u<t.length;u++){let c=l[u],p=a[u]?.atr;if(c===null||p===null){s.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*p,m=c-r*p,g=c>0?(d-m)/c*100:null;s.push({mid:c,upper:d,lower:m,width:g})}return s}function ue(t,e={}){if(t.length===0)return[];let n=t.map(m=>m.close),i=t.map(m=>({open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume})),r=e.ma?te(n,typeof e.ma=="object"?e.ma:{}):null,s=e.macd?ne(n,typeof e.macd=="object"?e.macd:{}):null,o=e.boll?re(n,typeof e.boll=="object"?e.boll:{}):null,l=e.kdj?se(i,typeof e.kdj=="object"?e.kdj:{}):null,a=e.rsi?ie(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?oe(i,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?le(n,typeof e.bias=="object"?e.bias:{}):null,p=e.cci?ae(i,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?F(i,typeof e.atr=="object"?e.atr:{}):null;return t.map((m,g)=>({...m,...r&&{ma:r[g]},...s&&{macd:s[g]},...o&&{boll:o[g]},...l&&{kdj:l[g]},...a&&{rsi:a[g]},...u&&{wr:u[g]},...c&&{bias:c[g]},...p&&{cci:p[g]},...d&&{atr:d[g]}}))}var ce=class{constructor(e={}){this.client=new J(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return A.getIndustryList(this.client)}getIndustrySpot(e){return A.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return A.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return A.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return A.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return A.getConceptList(this.client)}getConceptSpot(e){return A.getConceptSpot(this.client,e)}getConceptConstituents(e){return A.getConceptConstituents(this.client,e)}getConceptKline(e,n){return A.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return A.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return A.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return A.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return A.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return A.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}getFundCodeList(){return T.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...i}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,i)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...i}=e,r=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,r,i)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return A.getDividendDetail(this.client,e)}detectMarket(e){return/^\d{3}\.[A-Z]+$/i.test(e)?"US":/^\d{5}$/.test(e)?"HK":"A"}safeMax(e,n=0){return!e||e.length===0?n:Math.max(...e)}calcRequiredLookback(e){let n=0,i=!1;if(e.ma){let s=typeof e.ma=="object"?e.ma:{},o=s.periods??[5,10,20,30,60,120,250],l=s.type??"sma";n=Math.max(n,this.safeMax(o,20)),l==="ema"&&(i=!0)}if(e.macd){let s=typeof e.macd=="object"?e.macd:{},o=s.long??26,l=s.signal??9;n=Math.max(n,o*3+l),i=!0}if(e.boll){let s=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,s)}if(e.kdj){let s=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,s)}if(e.rsi){let s=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(s,14)+1)}if(e.wr){let s=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(s,10))}if(e.bias){let s=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(s,12))}if(e.cci){let s=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,s)}if(e.atr){let s=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,s)}return Math.ceil(n*(i?1.5:1.2))}calcActualStartDate(e,n,i=1.5){let r=Math.ceil(n*i),s=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));s.setDate(s.getDate()-r);let o=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");return`${o}${l}${a}`}calcActualStartDateByCalendar(e,n,i){if(!i||i.length===0)return;let r=this.normalizeDate(e),s=i.findIndex(l=>l>=r);s===-1&&(s=i.length-1);let o=Math.max(0,s-n);return this.toCompactDate(i[o])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:i,endDate:r,indicators:s={}}=n,o=n.market??this.detectMarket(e),l=this.calcRequiredLookback(s),a={A:1.5,HK:1.46,US:1.45},u;if(i)if(o==="A")try{let m=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(i,l,m)??this.calcActualStartDate(i,l,a[o])}catch{u=this.calcActualStartDate(i,l,a[o])}else u=this.calcActualStartDate(i,l,a[o]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},p;switch(o){case"HK":p=await this.getHKHistoryKline(e,c);break;case"US":p=await this.getUSHistoryKline(e,c);break;default:p=await this.getHistoryKline(e,c)}if(i&&p.length<l)switch(o){case"HK":p=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":p=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:p=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=ue(p,s);if(i){let m=this.dateToTimestamp(i),g=r?this.dateToTimestamp(r):1/0;return d.filter(f=>{let C=this.dateToTimestamp(f.date);return C>=m&&C<=g})}return d}},nn=ce;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,parseResponse,safeNumber,safeNumberOrNull});
1
+ "use strict";var qe=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Xn=Object.prototype.hasOwnProperty;var Oe=(t,e)=>{for(var n in e)qe(t,n,{get:e[n],enumerable:!0})},Yn=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wn(e))!Xn.call(t,r)&&r!==n&&qe(t,r,{get:()=>e[r],enumerable:!(o=Vn(e,r))||o.enumerable});return t};var Zn=t=>Yn(qe({},"__esModule",{value:!0}),t);var Dr={};Oe(Dr,{HttpError:()=>B,StockSDK:()=>Ce,addIndicators:()=>ye,asyncPool:()=>H,calcATR:()=>$,calcBIAS:()=>ge,calcBOLL:()=>pe,calcCCI:()=>he,calcDMI:()=>jt,calcEMA:()=>K,calcKC:()=>$t,calcKDJ:()=>de,calcMA:()=>ue,calcMACD:()=>ce,calcOBV:()=>Ht,calcROC:()=>qt,calcRSI:()=>me,calcSAR:()=>Qt,calcSMA:()=>N,calcWMA:()=>He,calcWR:()=>fe,chunkArray:()=>v,decodeGBK:()=>X,default:()=>Gn,extractJsonFromJsonp:()=>Ie,jsonpRequest:()=>_,parseResponse:()=>Y,safeNumber:()=>y,safeNumberOrNull:()=>S});module.exports=Zn(Dr);function X(t){return new TextDecoder("gbk").decode(t)}function Y(t){let e=t.split(";").map(o=>o.trim()).filter(Boolean),n=[];for(let o of e){let r=o.indexOf("=");if(r<0)continue;let s=o.slice(0,r).trim();s.startsWith("v_")&&(s=s.slice(2));let i=o.slice(r+1).trim();i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1));let a=i.split("~");n.push({key:s,fields:a})}return n}function y(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function S(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function C(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function p(t){return t==null?null:C(String(t))}var je="https://qt.gtimg.cn",Qe="https://web.ifzq.gtimg.cn/appstock/app/minute/query",$e="https://assets.linkdiary.cn/shares/zh_a_list.json",Ge="https://assets.linkdiary.cn/shares/us_list.json",ze="https://assets.linkdiary.cn/shares/hk_list.json",Ve="https://assets.linkdiary.cn/shares/fund_list",Gt="https://assets.linkdiary.cn/shares/trade-data-list.txt";var Se="https://push2his.eastmoney.com/api/qt/stock/kline/get",We="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Xe="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Ye="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",Ze="https://17.push2.eastmoney.com/api/qt/clist/get",Je="https://91.push2.eastmoney.com/api/qt/stock/get",et="https://29.push2.eastmoney.com/api/qt/clist/get",tt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",nt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",rt="https://79.push2.eastmoney.com/api/qt/clist/get",ot="https://91.push2.eastmoney.com/api/qt/stock/get",st="https://29.push2.eastmoney.com/api/qt/clist/get",it="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",at="https://push2his.eastmoney.com/api/qt/stock/trends2/get",w="https://datacenter-web.eastmoney.com/api/data/v1/get",Z="https://push2his.eastmoney.com/api/qt/stock/kline/get",lt="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",J="58b2fa8f54638b60b87d69b31969089c",ut={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},z={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},Re={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},ee="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",te="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",ct="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",Ee="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",pt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",dt="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",mt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",ft="https://futsseapi.eastmoney.com/list/option/221",gt="https://datacenter-web.eastmoney.com/api/data/get",ht="b2884a393a59ad64002292a3e90d46a5";var Te={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},yt=3e4,ne=500,re=500,oe=7,Ct=3,Ot=1e3,St=3e4,Rt=2,Et=[408,429,500,502,503,504];var _e=class{constructor(e={}){let n=e.requestsPerSecond??5;this.maxTokens=e.maxBurst??n,this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),o=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+o),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.getWaitTime();e>0&&await this.sleep(e),this.refill(),this.tokens-=1}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var zt=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Tt=0;function Jn(){return typeof window<"u"&&typeof window.document<"u"}function Vt(){if(Jn())return;let t=zt[Tt];return Tt=(Tt+1)%zt.length,t}var se=class extends Error{constructor(e="Circuit breaker is OPEN"){super(e),this.name="CircuitBreakerError"}},be=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=e.failureThreshold??5,this.resetTimeout=e.resetTimeout??3e4,this.halfOpenRequests=e.halfOpenRequests??1,this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":return this.halfOpenSuccessCount<this.halfOpenRequests}}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?this.transitionTo("OPEN"):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),this.onStateChange?.(n,e)}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new se;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var B=class extends Error{constructor(n,o,r,s){let i=o?` ${o}`:"",a=r?`, url: ${r}`:"",l=s?`, provider: ${s}`:"";super(`HTTP error! status: ${n}${i}${a}${l}`);this.status=n;this.statusText=o;this.url=r;this.provider=s;this.name="HttpError"}},ie=class{constructor(e={}){this.baseUrl=e.baseUrl??je,this.timeout=e.timeout??yt,this.retryOptions=this.resolveRetryOptions(e.retry),this.headers={...e.headers??{}},this.rotateUserAgent=e.rotateUserAgent??!1,this.rateLimiter=e.rateLimit?new _e(e.rateLimit):null,this.circuitBreaker=e.circuitBreaker?new be(e.circuitBreaker):null,e.userAgent&&(Object.keys(this.headers).some(o=>o.toLowerCase()==="user-agent")||(this.headers["User-Agent"]=e.userAgent))}resolveRetryOptions(e){return{maxRetries:e?.maxRetries??Ct,baseDelay:e?.baseDelay??Ot,maxDelay:e?.maxDelay??St,backoffMultiplier:e?.backoffMultiplier??Rt,retryableStatusCodes:e?.retryableStatusCodes??Et,retryOnNetworkError:e?.retryOnNetworkError??!0,retryOnTimeout:e?.retryOnTimeout??!0,onRetry:e?.onRetry}}inferProvider(e){try{let n=new URL(e).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("linkdiary.cn"))return"linkdiary"}catch{return}}getTimeout(){return this.timeout}calculateDelay(e){return Math.min(this.retryOptions.baseDelay*Math.pow(this.retryOptions.backoffMultiplier,e),this.retryOptions.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n){return n>=this.retryOptions.maxRetries?!1:e instanceof DOMException&&e.name==="AbortError"?this.retryOptions.retryOnTimeout:e instanceof TypeError?this.retryOptions.retryOnNetworkError:e instanceof B?this.retryOptions.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n=0){try{let o=await e();return this.circuitBreaker?.recordSuccess(),o}catch(o){if(this.shouldRetry(o,n)){let r=this.calculateDelay(n);return this.retryOptions.onRetry&&o instanceof Error&&this.retryOptions.onRetry(n+1,o,r),await this.sleep(r),this.executeWithRetry(e,n+1)}throw this.circuitBreaker?.recordFailure(),o}}async get(e,n={}){if(this.circuitBreaker&&!this.circuitBreaker.canRequest())throw new se("Circuit breaker is OPEN, request rejected");return this.rateLimiter&&await this.rateLimiter.acquire(),this.executeWithRetry(async()=>{let o=new AbortController,r=setTimeout(()=>o.abort(),this.timeout),s=this.inferProvider(e),i={...this.headers};if(this.rotateUserAgent){let a=Vt();a&&(i["User-Agent"]=a)}try{let a=await fetch(e,{signal:o.signal,headers:i});if(!a.ok)throw new B(a.status,a.statusText,e,s);switch(n.responseType){case"json":return await a.json();case"arraybuffer":return await a.arrayBuffer();default:return await a.text()}}catch(a){throw a instanceof Error&&(a.url=e,a.provider=s),a}finally{clearTimeout(r)}})}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,o=await this.get(n,{responseType:"arraybuffer"}),r=X(o);return Y(r)}};var er=new Set(["daily","weekly","monthly"]),tr=new Set(["1","5","15","30","60"]),nr=new Set(["","qfq","hfq"]);function L(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new RangeError(`${e} must be a positive integer`)}function A(t){if(!er.has(t))throw new RangeError("period must be one of: daily, weekly, monthly")}function ae(t){if(!tr.has(t))throw new RangeError("period must be one of: 1, 5, 15, 30, 60")}function U(t){if(!nr.has(t))throw new RangeError("adjust must be one of: '', 'qfq', 'hfq'")}function v(t,e){L(e,"chunkSize");let n=[];for(let o=0;o<t.length;o+=e)n.push(t.slice(o,o+e));return n}async function H(t,e){L(e,"concurrency");let n=[],o=[];for(let r of t){let s=Promise.resolve().then(()=>r()).then(i=>{n.push(i)});if(o.push(s),o.length>=e){await Promise.race(o);for(let i=o.length-1;i>=0;i--)await Promise.race([o[i].then(()=>"fulfilled"),Promise.resolve("pending")])==="fulfilled"&&o.splice(i,1)}}return await Promise.all(o),n}function Ae(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 D(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var rr=typeof document<"u"&&typeof window<"u",or=0;function Wt(){return`__stock_sdk_jsonp_${Date.now()}_${or++}`}function Ie(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let o=e.indexOf("(");if(o===-1)throw new Error("Invalid JSONP response: no opening parenthesis found");let r=e.lastIndexOf(")");if(r===-1||r<=o)throw new Error("Invalid JSONP response: no closing parenthesis found");let s=e.slice(o+1,r);return JSON.parse(s)}function sr(t,e){let{timeout:n=15e3,callbackParam:o="callback",callbackMode:r="query"}=e;return new Promise((s,i)=>{let a=Wt(),l;if(r==="path")l=t.replace("{callback}",a);else{let h=t.includes("?")?"&":"?";l=`${t}${h}${o}=${a}`}let u=document.createElement("script"),c=!1,m=window,d=()=>{u.parentNode&&u.parentNode.removeChild(u),delete m[a]},f=setTimeout(()=>{c||(c=!0,d(),i(new Error(`JSONP request timed out after ${n}ms: ${t}`)))},n);m[a]=h=>{c||(c=!0,clearTimeout(f),d(),s(h))},u.onerror=()=>{c||(c=!0,clearTimeout(f),d(),i(new Error(`JSONP script load failed: ${t}`)))},u.src=l,document.head.appendChild(u)})}async function ir(t,e){let{timeout:n=15e3,callbackParam:o="callback",callbackMode:r="query"}=e,s=Wt(),i;if(r==="path")i=t.replace("{callback}",s);else{let u=t.includes("?")?"&":"?";i=`${t}${u}${o}=${s}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let u=await fetch(i,{signal:a.signal});if(!u.ok)throw new Error(`JSONP fetch failed with status ${u.status}: ${t}`);let c=await u.text();return Ie(c)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new Error(`JSONP request timed out after ${n}ms: ${t}`):u}finally{clearTimeout(l)}}function _(t,e={}){return rr?sr(t,e):ir(t,e)}var T={};Oe(T,{getAShareCodeList:()=>tn,getAllHKQuotesByCodes:()=>sn,getAllQuotesByCodes:()=>on,getAllUSQuotesByCodes:()=>an,getFullQuotes:()=>xe,getFundCodeList:()=>ln,getFundFlow:()=>Yt,getFundQuotes:()=>Jt,getHKCodeList:()=>rn,getHKQuotes:()=>Me,getPanelLargeOrder:()=>Zt,getSimpleQuotes:()=>Xt,getTodayTimeline:()=>en,getTradingCalendar:()=>un,getUSCodeList:()=>nn,getUSQuotes:()=>Pe,parseFullQuote:()=>_t,parseFundFlow:()=>At,parseFundQuote:()=>Pt,parseHKQuote:()=>xt,parsePanelLargeOrder:()=>It,parseSimpleQuote:()=>bt,parseUSQuote:()=>Mt,search:()=>pn});function _t(t){let e=[];for(let o=0;o<5;o++)e.push({price:y(t[9+o*2]),volume:y(t[10+o*2])});let n=[];for(let o=0;o<5;o++)n.push({price:y(t[19+o*2]),volume:y(t[20+o*2])});return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),outerVolume:y(t[7]),innerVolume:y(t[8]),bid:e,ask:n,time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),volume2:y(t[36]),amount:y(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),pb:S(t[46]),limitUp:S(t[47]),limitDown:S(t[48]),volumeRatio:S(t[49]),avgPrice:S(t[51]),peStatic:S(t[52]),peDynamic:S(t[53]),high52w:S(t[67]),low52w:S(t[68]),circulatingShares:S(t[72]),totalShares:S(t[73]),raw:t}}function bt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),change:y(t[4]),changePercent:y(t[5]),volume:y(t[6]),amount:y(t[7]),marketCap:S(t[9]),marketType:t[10]??"",raw:t}}function At(t){return{code:t[0]??"",mainInflow:y(t[1]),mainOutflow:y(t[2]),mainNet:y(t[3]),mainNetRatio:y(t[4]),retailInflow:y(t[5]),retailOutflow:y(t[6]),retailNet:y(t[7]),retailNetRatio:y(t[8]),totalFlow:y(t[9]),name:t[12]??"",date:t[13]??"",raw:t}}function It(t){return{buyLargeRatio:y(t[0]),buySmallRatio:y(t[1]),sellLargeRatio:y(t[2]),sellSmallRatio:y(t[3]),raw:t}}function xt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),amount:y(t[37]),lotSize:S(t[40]),circulatingMarketCap:S(t[44]),totalMarketCap:S(t[45]),currency:t[t.length-3]??"",raw:t}}function Mt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:y(t[3]),prevClose:y(t[4]),open:y(t[5]),volume:y(t[6]),time:t[30]??"",change:y(t[31]),changePercent:y(t[32]),high:y(t[33]),low:y(t[34]),amount:y(t[37]),turnoverRate:S(t[38]),pe:S(t[39]),amplitude:S(t[43]),totalMarketCap:S(t[45]),pb:S(t[47]),high52w:S(t[48]),low52w:S(t[49]),raw:t}}function Pt(t){return{code:t[0]??"",name:t[1]??"",nav:y(t[5]),accNav:y(t[6]),change:y(t[7]),navDate:t[8]??"",raw:t}}async function xe(t,e){return!e||e.length===0?[]:(await t.getTencentQuote(e.join(","))).filter(o=>o.fields&&o.fields.length>0&&o.fields[0]!=="").map(o=>_t(o.fields))}async function Xt(t,e){if(!e||e.length===0)return[];let n=e.map(r=>`s_${r}`);return(await t.getTencentQuote(n.join(","))).filter(r=>r.fields&&r.fields.length>0&&r.fields[0]!=="").map(r=>bt(r.fields))}async function Yt(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=>At(r.fields))}async function Zt(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=>It(r.fields))}async function Me(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=>xt(r.fields))}async function Pe(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=>Mt(r.fields))}async function Jt(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=>Pt(r.fields))}async function en(t,e){let n=t.getTimeout(),o=new AbortController,r=setTimeout(()=>o.abort(),n);try{let s=await fetch(`${Qe}?code=${e}`,{signal:o.signal});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);let i=await s.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(" "),f=parseFloat(d[1])||0,h=parseInt(d[2],10)||0,g=parseFloat(d[3])||0;h>0&&f>0&&g/h>f*50&&(c=!0)}let m=l.map(d=>{let f=d.split(" "),h=f[0],g=`${h.slice(0,2)}:${h.slice(2,4)}`,O=parseInt(f[2],10)||0,E=parseFloat(f[3])||0,b=c?O*100:O,k=b>0?E/b:0;return{time:g,price:parseFloat(f[1])||0,volume:b,amount:E,avgPrice:Math.round(k*100)/100}});return{code:e,date:u,data:m}}finally{clearTimeout(r)}}var Lt=null,ar=null,Le=null,lr=null,Ue=null,Ut=null;function ur(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 tn(t,e){let n=!1,o;if(typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,o=e.market),!Lt){let i=(await t.get($e,{responseType:"json"}))?.list||[];Lt=i,ar=i.map(a=>a.replace(/^(sh|sz|bj)/,""))}let r=Lt;return o&&(r=r.filter(s=>ur(s,o))),n?r.map(s=>s.replace(/^(sh|sz|bj)/,"")):r.slice()}var cr={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function nn(t,e){let n=!1,o;typeof e=="boolean"?n=!e:e&&(n=e.simple??!1,o=e.market),Le||(Le=(await t.get(Ge,{responseType:"json"}))?.list||[],lr=Le.map(i=>i.replace(/^\d{3}\./,"")));let r=Le.slice();if(o){let s=cr[o];r=r.filter(i=>i.startsWith(s))}return n?r.map(s=>s.replace(/^\d{3}\./,"")):r}async function rn(t){return Ue||(Ue=(await t.get(ze,{responseType:"json"}))?.list||[]),Ue.slice()}async function on(t,e,n={}){let{batchSize:o=ne,concurrency:r=oe,onProgress:s}=n;L(o,"batchSize"),L(r,"concurrency");let i=Math.min(o,re),a=v(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await xe(t,d);return u++,s&&s(u,l),f});return(await H(c,r)).flat()}async function sn(t,e,n={}){let{batchSize:o=ne,concurrency:r=oe,onProgress:s}=n;L(o,"batchSize"),L(r,"concurrency");let i=Math.min(o,re),a=v(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await Me(t,d);return u++,s&&s(u,l),f});return(await H(c,r)).flat()}async function an(t,e,n={}){let{batchSize:o=ne,concurrency:r=oe,onProgress:s}=n;L(o,"batchSize"),L(r,"concurrency");let i=Math.min(o,re),a=v(e,i),l=a.length,u=0,c=a.map(d=>async()=>{let f=await Pe(t,d);return u++,s&&s(u,l),f});return(await H(c,r)).flat()}async function ln(t){if(Ut)return Ut.slice();let o=(await t.get(Ve,{responseType:"text"})).split(",").slice(1).filter(r=>r.trim());return Ut=o,o.slice()}var V=null;async function un(t){if(V)return V.slice();let e=await t.get(Gt);return!e||e.trim()===""?(V=[],V.slice()):(V=e.trim().split(",").map(n=>n.trim()).filter(n=>n.length>0),V.slice())}var cn="https://smartbox.gtimg.cn/s3/";function pr(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function dr(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let o=n.split("~"),r=o[0]||"",s=o[1]||"",i=pr(o[2]||""),a=o[4]||"";return{code:r+s,name:i,market:r,type:a}})}function mr(t){return new Promise((e,n)=>{let o=`${cn}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let r=document.createElement("script");r.src=o,r.charset="utf-8",r.onload=()=>{let s=window.v_hint||"";document.body.removeChild(r),e(s)},r.onerror=()=>{document.body.removeChild(r),n(new Error("Network error calling Smartbox"))},document.body.appendChild(r)})}async function fr(t,e){let n=`${cn}?v=2&t=all&q=${encodeURIComponent(e)}`,r=(await t.get(n)).match(/v_hint="([^"]*)"/);return r?r[1]:""}function gr(){return typeof window<"u"&&typeof document<"u"}async function pn(t,e){if(!e||!e.trim())return[];let n;return gr()?n=await mr(e):n=await fr(t,e),dr(n)}var R={};Oe(R,{extractVariety:()=>Ft,getCFFEXOptionQuotes:()=>Mn,getComexInventory:()=>Kn,getConceptConstituents:()=>Rn,getConceptKline:()=>En,getConceptList:()=>kt,getConceptMinuteKline:()=>Tn,getConceptSpot:()=>Sn,getDividendDetail:()=>_n,getFuturesHistoryKline:()=>An,getFuturesInventory:()=>Dn,getFuturesInventorySymbols:()=>Ln,getFuturesMarketCode:()=>Nt,getGlobalFuturesKline:()=>xn,getGlobalFuturesSpot:()=>In,getHKHistoryKline:()=>fn,getHistoryKline:()=>dn,getIndustryConstituents:()=>yn,getIndustryKline:()=>Cn,getIndustryList:()=>Kt,getIndustryMinuteKline:()=>On,getIndustrySpot:()=>hn,getMinuteKline:()=>mn,getOptionLHB:()=>Pn,getUSHistoryKline:()=>gn});async function Dt(t,e,n,o,r=100,s){let i=[],a=1,l=0;do{let u=new URLSearchParams({...n,pn:String(a),pz:String(r),fields:o}),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 f=d.diff.map((h,g)=>s(h,i.length+g+1));i.push(...f),a++}while(i.length<l);return i}function x(t){let[e,n,o,r,s,i,a,l,u,c,m]=t.split(",");return{date:e,open:C(n),close:C(o),high:C(r),low:C(s),volume:C(i),amount:C(a),amplitude:C(l),changePercent:C(u),change:C(c),turnoverRate:C(m)}}async function M(t,e,n){let o=`${e}?${n.toString()}`,r=await t.get(o,{responseType:"json"});return{klines:r?.data?.klines||[],name:r?.data?.name,code:r?.data?.code}}async function dn(t,e,n={}){let{period:o="daily",adjust:r="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(o),U(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Ae(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:I(o),fqt:D(r),secid:l,beg:s,end:i}),c=Se,{klines:m}=await M(t,c,u);return m.length===0?[]:m.map(d=>({...x(d),code:a}))}async function mn(t,e,n={}){let{period:o="1",adjust:r="qfq",startDate:s="1979-09-01 09:32:00",endDate:i="2222-01-01 09:32:00"}=n;ae(o),U(r);let a=e.replace(/^(sh|sz|bj)/,""),l=`${Ae(e)}.${a}`;if(o==="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=`${We}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(d)||d.length===0)return[];let f=s.replace("T"," ").slice(0,16),h=i.replace("T"," ").slice(0,16);return d.map(g=>{let[O,E,b,k,W,F,G,zn]=g.split(",");return{time:O,open:C(E),close:C(b),high:C(k),low:C(W),volume:C(F),amount:C(G),avgPrice:C(zn)}}).filter(g=>g.time>=f&&g.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:o,fqt:D(r||""),secid:l,beg:"0",end:"20500000"}),c=Se,{klines:m}=await M(t,c,u);if(m.length===0)return[];let d=s.replace("T"," ").slice(0,16),f=i.replace("T"," ").slice(0,16);return m.map(h=>{let g=x(h);return{...g,time:g.date}}).filter(h=>h.time>=d&&h.time<=f)}}async function fn(t,e,n={}){let{period:o="daily",adjust:r="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(o),U(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:I(o),fqt:D(r),secid:l,beg:s,end:i,lmt:"1000000"}),c=Xe,{klines:m,name:d}=await M(t,c,u);return m.length===0?[]:m.map(f=>({...x(f),code:a,name:d||""}))}async function gn(t,e,n={}){let{period:o="daily",adjust:r="qfq",startDate:s="19700101",endDate:i="20500101"}=n;A(o),U(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:I(o),fqt:D(r),secid:e,beg:s,end:i,lmt:"1000000"}),l=Ye,{klines:u,name:c,code:m}=await M(t,l,a),d=m||e.split(".")[1]||e,f=c||"";return u.length===0?[]:u.map(h=>({...x(h),code:d,name:f}))}function De(t){let e=null;return{async getCode(n,o,r){if(o.startsWith("BK"))return o;if(!e){let i=await r(n);e=new Map(i.map(a=>[a.name,a.code]))}let s=e.get(o);if(!s)throw new Error(`${t.errorPrefix}: ${o}`);return s}}}async function Ke(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},o=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",r=await Dt(t,e.listUrl,n,o,100,(s,i)=>({rank:i,name:String(s.f14??""),code:String(s.f12??""),price:p(s.f2),change:p(s.f4),changePercent:p(s.f3),totalMarketCap:p(s.f20),turnoverRate:p(s.f8),riseCount:p(s.f104),fallCount:p(s.f105),leadingStock:s.f128?String(s.f128):null,leadingStockChangePercent:p(s.f136)}));return r.sort((s,i)=>(i.changePercent??0)-(s.changePercent??0)),r.forEach((s,i)=>{s.rank=i+1}),r}async function ke(t,e,n){let o=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),r=`${n}?${o.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 m=i[l],d=null;return typeof m=="number"&&!isNaN(m)&&(d=c?m/100:m),{item:u,value:d}}):[]}async function Fe(t,e,n){let o={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Dt(t,n,o,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(s,i)=>({rank:i,code:String(s.f12??""),name:String(s.f14??""),price:p(s.f2),changePercent:p(s.f3),change:p(s.f4),volume:p(s.f5),amount:p(s.f6),amplitude:p(s.f7),high:p(s.f15),low:p(s.f16),open:p(s.f17),prevClose:p(s.f18),turnoverRate:p(s.f8),pe:p(s.f9),pb:p(s.f23)}))}async function Ne(t,e,n,o={}){let{period:r="daily",adjust:s="",startDate:i="19700101",endDate:a="20500101"}=o;A(r),U(s);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:I(r),fqt:D(s),beg:i,end:a,smplmt:"10000",lmt:"1000000"}),{klines:u}=await M(t,n,l);return u.length===0?[]:u.map(c=>x(c))}async function we(t,e,n,o,r={}){let{period:s="5"}=r;if(ae(s),s==="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=`${o}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.data?.trends;return!Array.isArray(u)||u.length===0?[]:u.map(c=>{let[m,d,f,h,g,O,E,b]=c.split(",");return{time:m,open:C(d),close:C(f),high:C(h),low:C(g),volume:C(O),amount:C(E),price:C(b)}})}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:s,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[m,d,f,h,g,O,E,b,k,W,F]=c.split(",");return{time:m,open:C(d),close:C(f),high:C(h),low:C(g),changePercent:C(k),change:C(W),volume:C(O),amount:C(E),amplitude:C(b),turnoverRate:C(F)}})}}var q={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:Ze,spotUrl:Je,consUrl:et,klineUrl:tt,trendsUrl:nt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},hr=De(q);async function Be(t,e){return hr.getCode(t,e,Kt)}async function Kt(t){return Ke(t,q)}async function hn(t,e){let n=await Be(t,e);return ke(t,n,q.spotUrl)}async function yn(t,e){let n=await Be(t,e);return Fe(t,n,q.consUrl)}async function Cn(t,e,n={}){let o=await Be(t,e);return Ne(t,o,q.klineUrl,n)}async function On(t,e,n={}){let o=await Be(t,e);return we(t,o,q.klineUrl,q.trendsUrl,n)}var j={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:rt,spotUrl:ot,consUrl:st,klineUrl:it,trendsUrl:at,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},yr=De(j);async function ve(t,e){return yr.getCode(t,e,kt)}async function kt(t){return Ke(t,j)}async function Sn(t,e){let n=await ve(t,e);return ke(t,n,j.spotUrl)}async function Rn(t,e){let n=await ve(t,e);return Fe(t,n,j.consUrl)}async function En(t,e,n={}){let o=await ve(t,e);return Ne(t,o,j.klineUrl,n)}async function Tn(t,e,n={}){let o=await ve(t,e);return we(t,o,j.klineUrl,j.trendsUrl,n)}function Q(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Cr(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:Q(t.REPORT_DATE),planNoticeDate:Q(t.PLAN_NOTICE_DATE),disclosureDate:Q(t.PUBLISH_DATE??t.PLAN_NOTICE_DATE),assignTransferRatio:t.BONUS_IT_RATIO??null,bonusRatio:t.BONUS_RATIO??null,transferRatio:t.IT_RATIO??null,dividendPretax:t.PRETAX_BONUS_RMB??null,dividendDesc:t.IMPL_PLAN_PROFILE??null,dividendYield:t.DIVIDENT_RATIO??null,eps:t.BASIC_EPS??null,bps:t.BVPS??null,capitalReserve:t.PER_CAPITAL_RESERVE??null,unassignedProfit:t.PER_UNASSIGN_PROFIT??null,netProfitYoy:t.PNP_YOY_RATIO??null,totalShares:t.TOTAL_SHARES??null,equityRecordDate:Q(t.EQUITY_RECORD_DATE),exDividendDate:Q(t.EX_DIVIDEND_DATE),payDate:Q(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:Q(t.NOTICE_DATE)}}async function _n(t,e){let n=e.replace(/^(sh|sz|bj)/,""),o=[],r=1,s=1;do{let i=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:"500",pageNumber:String(r),reportName:"RPT_SHAREBONUS_DET",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(SECURITY_CODE="${n}")`}),a=`${w}?${i.toString()}`,u=(await t.get(a,{responseType:"json"}))?.result;if(!u||!Array.isArray(u.data))break;r===1&&(s=u.pages??1);let c=u.data.map(Cr);o.push(...c),r++}while(r<=s);return o}function Ft(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new RangeError(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function bn(t){return z[t]??z[t.toLowerCase()]??z[t.toUpperCase()]}function Nt(t){let e=bn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=bn(t.slice(0,-1))),!e){let o=Object.keys(z).join(", ");throw new RangeError(`Unknown futures variety: "${t}". Supported varieties: ${o}`)}let n=ut[e];if(n===void 0)throw new RangeError(`No market code found for exchange: ${e}`);return n}function Or(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?C(n[12]):null}}async function An(t,e,n={}){let{period:o="daily",startDate:r="19700101",endDate:s="20500101"}=n;A(o);let i=Ft(e),l=`${Nt(i)}.${e}`,u=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:"0",secid:l,beg:r,end:s}),{klines:c,name:m,code:d}=await M(t,Z,u);return c.length===0?[]:c.map(f=>({...Or(f),code:d||e,name:m||""}))}async function In(t,e={}){let n=e.pageSize??20,o=[],r=0,s=0;do{let i=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(r),token:J,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),a=`${lt}?${i.toString()}`,l=await t.get(a,{responseType:"json"});if(!l||!Array.isArray(l.list))break;r===0&&(s=l.total??0);let u=l.list.map(Sr);o.push(...u),r++}while(o.length<s);return o}function Sr(t){return{code:t.dm||"",name:t.name||"",price:C(String(t.p)),change:C(String(t.zde)),changePercent:C(String(t.zdf)),open:C(String(t.o)),high:C(String(t.h)),low:C(String(t.l)),prevSettle:C(String(t.zjsj)),volume:C(String(t.vol)),buyVolume:C(String(t.wp)),sellVolume:C(String(t.np)),openInterest:C(String(t.ccl))}}function Rr(t){let e=x(t),n=t.split(",");return{...e,openInterest:n.length>12?C(n[12]):null}}function Er(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new RangeError(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function xn(t,e,n={}){let{period:o="daily",startDate:r="19700101",endDate:s="20500101"}=n;A(o);let i=n.marketCode;if(i===void 0){let d=Er(e);if(i=Re[d],i===void 0){let f=Object.keys(Re).join(", ");throw new RangeError(`Unknown global futures variety: "${d}". Supported: ${f}. Or specify marketCode manually via options.`)}}let a=`${i}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:"7eea3edcaed734bea9cbfc24409ed989",klt:I(o),fqt:"0",secid:a,beg:r,end:s}),{klines:u,name:c,code:m}=await M(t,Z,l);return u.length===0?[]:u.map(d=>({...Rr(d),code:m||e,name:c||""}))}async function Mn(t,e={}){let{pageSize:n=2e4}=e,o=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:J,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),r=`${ft}?${o.toString()}`,i=(await t.get(r,{responseType:"json"}))?.list;return Array.isArray(i)?i.map(a=>({code:String(a.dm??""),name:String(a.name??""),price:p(a.p),change:p(a.zde),changePercent:p(a.zdf),volume:p(a.vol),amount:p(a.cje),openInterest:p(a.ccl),strikePrice:p(a.xqj),remainDays:p(a.syr),dailyChange:p(a.rz),prevSettle:p(a.zjsj),open:p(a.o)})):[]}async function Pn(t,e,n){let o=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:ht,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),r=`${gt}?${o.toString()}`,i=(await t.get(r,{responseType:"json"}))?.result?.data;if(!Array.isArray(i))return[];function a(l){if(!l)return"";let u=String(l),c=u.match(/^(\d{4}-\d{2}-\d{2})/);return c?c[1]:u}return i.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:a(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:p(l.MEMBER_RANK)??0,sellVolume:p(l.SELL_VOLUME),sellVolumeChange:p(l.SELL_VOLUME_CHANGE),netSellVolume:p(l.NET_SELL_VOLUME),sellVolumeRatio:p(l.SELL_VOLUME_RATIO),buyVolume:p(l.BUY_VOLUME),buyVolumeChange:p(l.BUY_VOLUME_CHANGE),netBuyVolume:p(l.NET_BUY_VOLUME),buyVolumeRatio:p(l.BUY_VOLUME_RATIO),sellPosition:p(l.SELL_POSITION),sellPositionChange:p(l.SELL_POSITION_CHANGE),netSellPosition:p(l.NET_SELL_POSITION),sellPositionRatio:p(l.SELL_POSITION_RATIO),buyPosition:p(l.BUY_POSITION),buyPositionChange:p(l.BUY_POSITION_CHANGE),netBuyPosition:p(l.NET_BUY_POSITION),buyPositionRatio:p(l.BUY_POSITION_RATIO)}))}var Tr={gold:"EMI00069026",silver:"EMI00069027"};async function Ln(t){let e=new URLSearchParams({reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageNumber:"1",pageSize:"500",source:"WEB",client:"WEB"}),n=`${w}?${e.toString()}`,r=(await t.get(n,{responseType:"json"}))?.result?.data;return Array.isArray(r)?r.map(s=>({code:String(s.TRADE_CODE??""),name:String(s.TRADE_TYPE??""),marketCode:String(s.TRADE_MARKET_CODE??"")})):[]}function Un(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function Dn(t,e,n={}){let{startDate:o="2020-10-28",pageSize:r=500}=n,s=e.toUpperCase(),i=[],a=1,l=1;do{let u=new URLSearchParams({reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${s}")(TRADE_DATE>='${o}')`,pageNumber:String(a),pageSize:String(r),sortTypes:"-1",sortColumns:"TRADE_DATE",source:"WEB",client:"WEB"}),c=`${w}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;a===1&&(l=d.pages??1);let f=d.data.map(h=>({code:String(h.SECURITY_CODE??e),date:Un(h.TRADE_DATE),inventory:p(h.ON_WARRANT_NUM),change:p(h.ADDCHANGE)}));i.push(...f),a++}while(a<=l);return i}async function Kn(t,e,n={}){let o=Tr[e];if(!o)throw new RangeError(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:r=500}=n,s=[],i=1,a=1,l={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};do{let u=new URLSearchParams({sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:String(r),pageNumber:String(i),reportName:"RPT_FUTUOPT_GOLDSIL",columns:"ALL",quoteColumns:"",source:"WEB",client:"WEB",filter:`(INDICATOR_ID1="${o}")(@STORAGE_TON<>"NULL")`}),c=`${w}?${u.toString()}`,d=(await t.get(c,{responseType:"json"}))?.result;if(!d||!Array.isArray(d.data))break;i===1&&(a=d.pages??1);let f=d.data.map(h=>({date:Un(h.REPORT_DATE),name:l[e]??e,storageTon:p(h.STORAGE_TON),storageOunce:p(h.STORAGE_OUNCE)}));s.push(...f),i++}while(i<=a);return s}var P={};Oe(P,{getCommodityOptionKline:()=>Qn,getCommodityOptionSpot:()=>jn,getETFOption5DayMinute:()=>qn,getETFOptionDailyKline:()=>Hn,getETFOptionExpireDay:()=>wn,getETFOptionMinute:()=>vn,getETFOptionMonths:()=>Nn,getIndexOptionKline:()=>Fn,getIndexOptionSpot:()=>kn});function _r(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function br(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function kn(t,e){let n=`${ee}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,o=await _(n),r=o?.result?.data?.up??[],s=o?.result?.data?.down??[];return{calls:r.map(_r),puts:s.map(br)}}async function Fn(t){let e=`${te}?symbol=${t}`,n=await _(e,{callbackMode:"path"});return Array.isArray(n)?n.map(o=>({date:o.d,open:p(o.o),high:p(o.h),low:p(o.l),close:p(o.c),volume:p(o.v)})):[]}async function Nn(t){let e=`${ct}?exchange=null&cate=${encodeURIComponent(t)}`,o=(await _(e))?.result?.data,r=o?.contractMonth??[];return{months:r.length>1?r.slice(1):r,stockId:o?.stockId??"",cateId:o?.cateId??"",cateList:o?.cateList??[]}}async function wn(t,e){let n=`${Ee}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,o=await _(n),r=o?.result?.data?.remainderDays;if(typeof r=="number"&&r<0){let i=`${Ee}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;o=await _(i)}let s=o?.result?.data;return{expireDay:s?.expireDay??"",remainderDays:s?.remainderDays??0,stockId:s?.stockId??"",name:s?.other?.name??""}}function Bn(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:p(n.p),volume:p(n.v),openInterest:p(n.t),avgPrice:p(n.a)}))}async function vn(t){let e=`CON_OP_${t}`,n=`${pt}?symbol=${e}`,r=(await _(n))?.result?.data;return Array.isArray(r)?Bn(r):[]}async function Hn(t){let e=`CON_OP_${t}`,n=`${dt}?symbol=${e}`,o=await _(n,{callbackMode:"path"});return Array.isArray(o)?o.map(r=>({date:r.d,open:p(r.o),high:p(r.h),low:p(r.l),close:p(r.c),volume:p(r.v)})):[]}async function qn(t){let e=`CON_OP_${t}`,n=`${mt}?symbol=${e}`,r=(await _(n))?.result?.data;if(!Array.isArray(r))return[];let s=[];for(let i of r)Array.isArray(i)&&s.push(...Bn(i));return s}function Ar(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:p(t[7]),symbol:t[8]??""}}function Ir(t){return{buyVolume:p(t[0]),buyPrice:p(t[1]),price:p(t[2]),askPrice:p(t[3]),askVolume:p(t[4]),openInterest:p(t[5]),change:p(t[6]),strikePrice:null,symbol:t[7]??""}}async function jn(t,e){let n=Te[t];if(!n)throw new RangeError(`Unknown commodity option variety: "${t}". Available: ${Object.keys(Te).join(", ")}`);let o=`${ee}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,r=await _(o),s=r?.result?.data?.up??[],i=r?.result?.data?.down??[];return{calls:s.map(Ar),puts:i.map(Ir)}}async function Qn(t){let e=`${te}?symbol=${t}`,n=await _(e,{callbackMode:"path"});return Array.isArray(n)?n.map(o=>({date:o.d,open:p(o.o),high:p(o.h),low:p(o.l),close:p(o.c),volume:p(o.v)})):[]}function le(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function N(t,e){let n=[];for(let o=0;o<t.length;o++){if(o<e-1){n.push(null);continue}let r=0,s=0;for(let i=o-e+1;i<=o;i++)t[i]!==null&&(r+=t[i],s++);n.push(s===e?le(r/e):null)}return n}function K(t,e){let n=[],o=2/(e+1),r=null,s=!1;for(let i=0;i<t.length;i++){if(i<e-1){n.push(null);continue}if(!s){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,s=!0),n.push(r!==null?le(r):null);continue}let a=t[i];a===null?n.push(r!==null?le(r):null):(r=o*a+(1-o)*r,n.push(le(r)))}return n}function He(t,e){let n=[],o=Array.from({length:e},(s,i)=>i+1),r=o.reduce((s,i)=>s+i,0);for(let s=0;s<t.length;s++){if(s<e-1){n.push(null);continue}let i=0,a=!0;for(let l=0;l<e;l++){let u=t[s-e+1+l];if(u===null){a=!1;break}i+=u*o[l]}n.push(a?le(i/r):null)}return n}function ue(t,e={}){let{periods:n=[5,10,20,30,60,120,250],type:o="sma"}=e,r=o==="ema"?K:o==="wma"?He:N,s={};for(let i of n)s[`ma${i}`]=r(t,i);return t.map((i,a)=>{let l={};for(let u of n)l[`ma${u}`]=s[`ma${u}`][a];return l})}function $n(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ce(t,e={}){let{short:n=12,long:o=26,signal:r=9}=e,s=K(t,n),i=K(t,o),a=t.map((u,c)=>s[c]===null||i[c]===null?null:s[c]-i[c]),l=K(a,r);return t.map((u,c)=>({dif:a[c]!==null?$n(a[c]):null,dea:l[c],macd:a[c]!==null&&l[c]!==null?$n((a[c]-l[c])*2):null}))}function wt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function xr(t,e,n){let o=[];for(let r=0;r<t.length;r++){if(r<e-1||n[r]===null){o.push(null);continue}let s=0,i=0;for(let a=r-e+1;a<=r;a++)t[a]!==null&&n[r]!==null&&(s+=Math.pow(t[a]-n[r],2),i++);o.push(i===e?Math.sqrt(s/e):null)}return o}function pe(t,e={}){let{period:n=20,stdDev:o=2}=e,r=N(t,n),s=xr(t,n,r);return t.map((i,a)=>{if(r[a]===null||s[a]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let l=r[a]+o*s[a],u=r[a]-o*s[a],c=r[a]!==0?wt((l-u)/r[a]*100):null;return{mid:r[a],upper:wt(l),lower:wt(u),bandwidth:c}})}function Bt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function de(t,e={}){let{period:n=9,kPeriod:o=3,dPeriod:r=3}=e,s=[],i=50,a=50;for(let l=0;l<t.length;l++){if(l<n-1){s.push({k:null,d:null,j:null});continue}let u=-1/0,c=1/0,m=!0;for(let g=l-n+1;g<=l;g++){if(t[g].high===null||t[g].low===null){m=!1;break}u=Math.max(u,t[g].high),c=Math.min(c,t[g].low)}let d=t[l].close;if(!m||d===null||u===c){s.push({k:null,d:null,j:null});continue}let f=(d-c)/(u-c)*100;i=(o-1)/o*i+1/o*f,a=(r-1)/r*a+1/r*i;let h=3*i-2*a;s.push({k:Bt(i),d:Bt(a),j:Bt(h)})}return s}function Mr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function me(t,e={}){let{periods:n=[6,12,24]}=e,o=[null];for(let s=1;s<t.length;s++)t[s]===null||t[s-1]===null?o.push(null):o.push(t[s]-t[s-1]);let r={};for(let s of n){let i=[],a=0,l=0;for(let u=0;u<t.length;u++){if(u<s){i.push(null),o[u]!==null&&(o[u]>0?a+=o[u]:l+=Math.abs(o[u]));continue}if(u===s)a=a/s,l=l/s;else{let c=o[u]??0,m=c>0?c:0,d=c<0?Math.abs(c):0;a=(a*(s-1)+m)/s,l=(l*(s-1)+d)/s}if(l===0)i.push(100);else if(a===0)i.push(0);else{let c=a/l;i.push(Mr(100-100/(1+c)))}}r[`rsi${s}`]=i}return t.map((s,i)=>{let a={};for(let l of n)a[`rsi${l}`]=r[`rsi${l}`][i];return a})}function Pr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function fe(t,e={}){let{periods:n=[6,10]}=e,o={};for(let r of n){let s=[];for(let i=0;i<t.length;i++){if(i<r-1){s.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){s.push(null);continue}let m=(a-c)/(a-l)*100;s.push(Pr(m))}o[`wr${r}`]=s}return t.map((r,s)=>{let i={};for(let a of n)i[`wr${a}`]=o[`wr${a}`][s];return i})}function Lr(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function ge(t,e={}){let{periods:n=[6,12,24]}=e,o={};for(let r of n){let s=N(t,r),i=[];for(let a=0;a<t.length;a++)if(t[a]===null||s[a]===null||s[a]===0)i.push(null);else{let l=(t[a]-s[a])/s[a]*100;i.push(Lr(l))}o[`bias${r}`]=i}return t.map((r,s)=>{let i={};for(let a of n)i[`bias${a}`]=o[`bias${a}`][s];return i})}function Ur(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function he(t,e={}){let{period:n=14}=e,o=[],r=t.map(s=>s.high===null||s.low===null||s.close===null?null:(s.high+s.low+s.close)/3);for(let s=0;s<t.length;s++){if(s<n-1){o.push({cci:null});continue}let i=0,a=0;for(let m=s-n+1;m<=s;m++)r[m]!==null&&(i+=r[m],a++);if(a!==n||r[s]===null){o.push({cci:null});continue}let l=i/n,u=0;for(let m=s-n+1;m<=s;m++)u+=Math.abs(r[m]-l);let c=u/n;if(c===0)o.push({cci:0});else{let m=(r[s]-l)/(.015*c);o.push({cci:Ur(m)})}}return o}function vt(t,e=2){let n=Math.pow(10,e);return Math.round(t*n)/n}function $(t,e={}){let{period:n=14}=e,o=[],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 m=a-l,d=Math.abs(a-c),f=Math.abs(l-c);r.push(Math.max(m,d,f))}}}let s=null;for(let i=0;i<t.length;i++){if(i<n-1){o.push({tr:r[i]!==null?vt(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&&(s=a/n)}else s!==null&&r[i]!==null&&(s=(s*(n-1)+r[i])/n);o.push({tr:r[i]!==null?vt(r[i]):null,atr:s!==null?vt(s):null})}return o}function Ht(t,e={}){let{maPeriod:n}=e,o=[];if(t.length===0)return o;let r=t[0].volume??0;o.push({obv:r,obvMa:null});for(let s=1;s<t.length;s++){let i=t[s],a=t[s-1];if(i.close===null||a.close===null||i.volume===null||i.volume===void 0){o.push({obv:null,obvMa:null});continue}i.close>a.close?r+=i.volume:i.close<a.close&&(r-=i.volume),o.push({obv:r,obvMa:null})}if(n&&n>0)for(let s=n-1;s<o.length;s++){let i=0,a=0;for(let l=s-n+1;l<=s;l++)o[l].obv!==null&&(i+=o[l].obv,a++);a===n&&(o[s].obvMa=i/n)}return o}function qt(t,e={}){let{period:n=12,signalPeriod:o}=e,r=[];for(let s=0;s<t.length;s++){if(s<n){r.push({roc:null,signal:null});continue}let i=t[s].close,a=t[s-n].close;if(i===null||a===null||a===0){r.push({roc:null,signal:null});continue}let l=(i-a)/a*100;r.push({roc:l,signal:null})}if(o&&o>0)for(let s=n+o-1;s<r.length;s++){let i=0,a=0;for(let l=s-o+1;l<=s;l++)r[l].roc!==null&&(i+=r[l].roc,a++);a===o&&(r[s].signal=i/o)}return r}function jt(t,e={}){let{period:n=14,adxPeriod:o=n}=e,r=[];if(t.length<2)return t.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let s=[],i=[],a=[];for(let g=0;g<t.length;g++){if(g===0){s.push(0),i.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=t[g],E=t[g-1];if(O.high===null||O.low===null||O.close===null||E.high===null||E.low===null||E.close===null){s.push(0),i.push(0),a.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let b=O.high-O.low,k=Math.abs(O.high-E.close),W=Math.abs(O.low-E.close);a.push(Math.max(b,k,W));let F=O.high-E.high,G=E.low-O.low;F>G&&F>0?s.push(F):s.push(0),G>F&&G>0?i.push(G):i.push(0),r.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,u=0,c=0,m=[];for(let g=1;g<t.length;g++){if(g<n){l+=a[g],u+=s[g],c+=i[g],m.push(0);continue}g===n?(l=l,u=u,c=c):(l=l-l/n+a[g],u=u-u/n+s[g],c=c-c/n+i[g]);let O=l>0?u/l*100:0,E=l>0?c/l*100:0;r[g].pdi=O,r[g].mdi=E;let b=O+E,k=b>0?Math.abs(O-E)/b*100:0;m.push(k)}let d=0,f=0,h=0;for(let g=n;g<t.length;g++){if(g<n*2-1){d+=m[g-n+1]||0,f++;continue}if(g===n*2-1)d+=m[g-n+1]||0,h=d/o,r[g].adx=h;else{let O=m[g-n+1]||0;h=(h*(o-1)+O)/o,r[g].adx=h}}for(let g=n*2-1+o;g<t.length;g++){let O=r[g].adx,E=r[g-o]?.adx;O!==null&&E!==null&&(r[g].adxr=(O+E)/2)}return r}function Qt(t,e={}){let{afStart:n=.02,afIncrement:o=.02,afMax:r=.2}=e,s=[];if(t.length<2)return t.map(()=>({sar:null,trend:null,ep:null,af:null}));let i=1,a=n,l=t[0].high??0,u=t[0].low??0,c=t[0],m=t[1];c.close!==null&&m.close!==null&&m.close<c.close&&(i=-1,l=c.low??0,u=c.high??0),s.push({sar:null,trend:null,ep:null,af:null});for(let d=1;d<t.length;d++){let f=t[d],h=t[d-1];if(f.high===null||f.low===null||h.high===null||h.low===null){s.push({sar:null,trend:null,ep:null,af:null});continue}let g=u+a*(l-u);i===1?(g=Math.min(g,h.low,t[Math.max(0,d-2)]?.low??h.low),f.low<g?(i=-1,g=l,l=f.low,a=n):f.high>l&&(l=f.high,a=Math.min(a+o,r))):(g=Math.max(g,h.high,t[Math.max(0,d-2)]?.high??h.high),f.high>g?(i=1,g=l,l=f.high,a=n):f.low<l&&(l=f.low,a=Math.min(a+o,r))),u=g,s.push({sar:u,trend:i,ep:l,af:a})}return s}function $t(t,e={}){let{emaPeriod:n=20,atrPeriod:o=10,multiplier:r=2}=e,s=[],i=t.map(u=>u.close),a=K(i,n),l=$(t,{period:o});for(let u=0;u<t.length;u++){let c=a[u],m=l[u]?.atr;if(c===null||m===null){s.push({mid:null,upper:null,lower:null,width:null});continue}let d=c+r*m,f=c-r*m,h=c>0?(d-f)/c*100:null;s.push({mid:c,upper:d,lower:f,width:h})}return s}function ye(t,e={}){if(t.length===0)return[];let n=t.map(f=>f.close),o=t.map(f=>({open:f.open,high:f.high,low:f.low,close:f.close,volume:f.volume})),r=e.ma?ue(n,typeof e.ma=="object"?e.ma:{}):null,s=e.macd?ce(n,typeof e.macd=="object"?e.macd:{}):null,i=e.boll?pe(n,typeof e.boll=="object"?e.boll:{}):null,a=e.kdj?de(o,typeof e.kdj=="object"?e.kdj:{}):null,l=e.rsi?me(n,typeof e.rsi=="object"?e.rsi:{}):null,u=e.wr?fe(o,typeof e.wr=="object"?e.wr:{}):null,c=e.bias?ge(n,typeof e.bias=="object"?e.bias:{}):null,m=e.cci?he(o,typeof e.cci=="object"?e.cci:{}):null,d=e.atr?$(o,typeof e.atr=="object"?e.atr:{}):null;return t.map((f,h)=>({...f,...r&&{ma:r[h]},...s&&{macd:s[h]},...i&&{boll:i[h]},...a&&{kdj:a[h]},...l&&{rsi:l[h]},...u&&{wr:u[h]},...c&&{bias:c[h]},...m&&{cci:m[h]},...d&&{atr:d[h]}}))}var Ce=class{constructor(e={}){this.client=new ie(e)}getFullQuotes(e){return T.getFullQuotes(this.client,e)}getSimpleQuotes(e){return T.getSimpleQuotes(this.client,e)}getHKQuotes(e){return T.getHKQuotes(this.client,e)}getUSQuotes(e){return T.getUSQuotes(this.client,e)}getFundQuotes(e){return T.getFundQuotes(this.client,e)}getFundFlow(e){return T.getFundFlow(this.client,e)}getPanelLargeOrder(e){return T.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return T.getTodayTimeline(this.client,e)}getIndustryList(){return R.getIndustryList(this.client)}getIndustrySpot(e){return R.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return R.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return R.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return R.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return R.getConceptList(this.client)}getConceptSpot(e){return R.getConceptSpot(this.client,e)}getConceptConstituents(e){return R.getConceptConstituents(this.client,e)}getConceptKline(e,n){return R.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return R.getConceptMinuteKline(this.client,e,n)}getHistoryKline(e,n){return R.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return R.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return R.getHKHistoryKline(this.client,e,n)}getUSHistoryKline(e,n){return R.getUSHistoryKline(this.client,e,n)}search(e){return T.search(this.client,e)}getAShareCodeList(e){return T.getAShareCodeList(this.client,e)}getUSCodeList(e){return T.getUSCodeList(this.client,e)}getHKCodeList(){return T.getHKCodeList(this.client)}getFundCodeList(){return T.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...o}=e,r=await this.getAShareCodeList({market:n});return this.getAllQuotesByCodes(r,o)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return T.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...o}=e,r=await this.getUSCodeList({simple:!0,market:n});return T.getAllUSQuotesByCodes(this.client,r,o)}getAllQuotesByCodes(e,n={}){return T.getAllQuotesByCodes(this.client,e,n)}async batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return T.getTradingCalendar(this.client)}getDividendDetail(e){return R.getDividendDetail(this.client,e)}getFuturesKline(e,n){return R.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return R.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return R.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return R.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return R.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return R.getComexInventory(this.client,e,n)}getIndexOptionSpot(e,n){return P.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return P.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return R.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return P.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return P.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return P.getETFOptionMinute(e)}getETFOptionDailyKline(e){return P.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return P.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return P.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return P.getCommodityOptionKline(e)}getOptionLHB(e,n){return R.getOptionLHB(this.client,e,n)}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,o=!1;if(e.ma){let s=typeof e.ma=="object"?e.ma:{},i=s.periods??[5,10,20,30,60,120,250],a=s.type??"sma";n=Math.max(n,this.safeMax(i,20)),a==="ema"&&(o=!0)}if(e.macd){let s=typeof e.macd=="object"?e.macd:{},i=s.long??26,a=s.signal??9;n=Math.max(n,i*3+a),o=!0}if(e.boll){let s=typeof e.boll=="object"&&e.boll.period?e.boll.period:20;n=Math.max(n,s)}if(e.kdj){let s=typeof e.kdj=="object"&&e.kdj.period?e.kdj.period:9;n=Math.max(n,s)}if(e.rsi){let s=typeof e.rsi=="object"&&e.rsi.periods?e.rsi.periods:[6,12,24];n=Math.max(n,this.safeMax(s,14)+1)}if(e.wr){let s=typeof e.wr=="object"&&e.wr.periods?e.wr.periods:[6,10];n=Math.max(n,this.safeMax(s,10))}if(e.bias){let s=typeof e.bias=="object"&&e.bias.periods?e.bias.periods:[6,12,24];n=Math.max(n,this.safeMax(s,12))}if(e.cci){let s=typeof e.cci=="object"&&e.cci.period?e.cci.period:14;n=Math.max(n,s)}if(e.atr){let s=typeof e.atr=="object"&&e.atr.period?e.atr.period:14;n=Math.max(n,s)}return Math.ceil(n*(o?1.5:1.2))}calcActualStartDate(e,n,o=1.5){let r=Math.ceil(n*o),s=new Date(parseInt(e.slice(0,4)),parseInt(e.slice(4,6))-1,parseInt(e.slice(6,8)));s.setDate(s.getDate()-r);let i=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${i}${a}${l}`}calcActualStartDateByCalendar(e,n,o){if(!o||o.length===0)return;let r=this.normalizeDate(e),s=o.findIndex(a=>a>=r);s===-1&&(s=o.length-1);let i=Math.max(0,s-n);return this.toCompactDate(o[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:o,endDate:r,indicators:s={}}=n,i=n.market??this.detectMarket(e),a=this.calcRequiredLookback(s),l={A:1.5,HK:1.46,US:1.45},u;if(o)if(i==="A")try{let f=await T.getTradingCalendar(this.client);u=this.calcActualStartDateByCalendar(o,a,f)??this.calcActualStartDate(o,a,l[i])}catch{u=this.calcActualStartDate(o,a,l[i])}else u=this.calcActualStartDate(o,a,l[i]);let c={period:n.period,adjust:n.adjust,startDate:u,endDate:n.endDate},m;switch(i){case"HK":m=await this.getHKHistoryKline(e,c);break;case"US":m=await this.getUSHistoryKline(e,c);break;default:m=await this.getHistoryKline(e,c)}if(o&&m.length<a)switch(i){case"HK":m=await this.getHKHistoryKline(e,{...c,startDate:void 0});break;case"US":m=await this.getUSHistoryKline(e,{...c,startDate:void 0});break;default:m=await this.getHistoryKline(e,{...c,startDate:void 0})}let d=ye(m,s);if(o){let f=this.dateToTimestamp(o),h=r?this.dateToTimestamp(r):1/0;return d.filter(g=>{let O=this.dateToTimestamp(g.date);return O>=f&&O<=h})}return d}},Gn=Ce;0&&(module.exports={HttpError,StockSDK,addIndicators,asyncPool,calcATR,calcBIAS,calcBOLL,calcCCI,calcDMI,calcEMA,calcKC,calcKDJ,calcMA,calcMACD,calcOBV,calcROC,calcRSI,calcSAR,calcSMA,calcWMA,calcWR,chunkArray,decodeGBK,extractJsonFromJsonp,jsonpRequest,parseResponse,safeNumber,safeNumberOrNull});