stock-sdk 2.0.0-beta.0 → 2.0.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 +27 -23
- package/dist/{adapters-C0s5bM8O.d.cts → adapters-BvE63CMd.d.cts} +16 -1
- package/dist/{adapters-C0s5bM8O.d.ts → adapters-BvE63CMd.d.ts} +16 -1
- package/dist/{addIndicators-TPEcddTW.d.cts → addIndicators-DwEr9RKK.d.cts} +207 -191
- package/dist/{addIndicators-TPEcddTW.d.ts → addIndicators-DwEr9RKK.d.ts} +207 -191
- package/dist/cache.cjs +1 -1
- package/dist/cache.js +1 -1
- package/dist/chunk-2PYGJ5I5.cjs +1 -0
- package/dist/chunk-3NSUE34F.cjs +1 -0
- package/dist/chunk-4PVVFEOQ.js +1 -0
- package/dist/chunk-C4CA7QBB.cjs +1 -0
- package/dist/chunk-D2MGPO3R.js +1 -0
- package/dist/{chunk-JYHHLB34.js → chunk-DU7MCVLJ.js} +1 -1
- package/dist/{chunk-SPLQXFFF.js → chunk-F3KZXCVO.js} +1 -1
- package/dist/chunk-G5KF73BW.js +1 -0
- package/dist/chunk-GBHWMR2O.js +1 -0
- package/dist/chunk-LCX5Q36O.js +1 -0
- package/dist/chunk-PMERLSCU.cjs +1 -0
- package/dist/{chunk-DOOAXFSS.cjs → chunk-TVIEKKDQ.cjs} +1 -1
- package/dist/{chunk-BGZ4ZUAF.cjs → chunk-WCBK5KYA.cjs} +1 -1
- package/dist/chunk-YR2SVSXB.cjs +1 -0
- package/dist/cli.cjs +17 -16
- package/dist/cli.js +17 -16
- package/dist/errors.d.cts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/{index-B0PXWAkv.d.cts → index-mlzPfoON.d.cts} +12 -0
- package/dist/{index-B0PXWAkv.d.ts → index-mlzPfoON.d.ts} +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/indicators.cjs +1 -1
- package/dist/indicators.d.cts +55 -5
- package/dist/indicators.d.ts +55 -5
- package/dist/indicators.js +1 -1
- package/dist/mcp.cjs +5 -5
- package/dist/mcp.d.cts +3 -3
- package/dist/mcp.d.ts +3 -3
- package/dist/mcp.js +5 -5
- package/dist/screener.cjs +1 -1
- package/dist/screener.js +1 -1
- package/dist/{sdk-CGd_HgIM.d.ts → sdk-Cg_jTmTk.d.cts} +21 -527
- package/dist/{sdk-C_Agv5AV.d.cts → sdk-DOz03n_v.d.ts} +21 -527
- package/dist/signals.cjs +1 -1
- package/dist/signals.d.cts +1 -1
- package/dist/signals.d.ts +1 -1
- package/dist/signals.js +1 -1
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.d.cts +2 -2
- package/dist/symbols.d.ts +2 -2
- package/dist/symbols.js +1 -1
- package/package.json +6 -10
- package/dist/chunk-333W3ADG.js +0 -1
- package/dist/chunk-4RR2H3DC.js +0 -1
- package/dist/chunk-66NWE54C.cjs +0 -1
- package/dist/chunk-6JEP4QK7.cjs +0 -1
- package/dist/chunk-HFN6G5M4.js +0 -1
- package/dist/chunk-LRE63M2C.js +0 -1
- package/dist/chunk-NMRUSAWS.cjs +0 -1
- package/dist/chunk-PVSDXLQP.cjs +0 -1
- package/dist/chunk-XVLG3G7T.cjs +0 -1
- package/dist/chunk-ZAQ7DTRY.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stock-sdk",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -16,16 +16,12 @@
|
|
|
16
16
|
"test:integration": "RUN_INTEGRATION=1 vitest run",
|
|
17
17
|
"test:integration:smoke": "RUN_INTEGRATION=1 vitest run test/integration/providers/tencent/quote.int.test.ts test/integration/providers/tencent/batch.int.test.ts test/integration/providers/tencent/tradeCalendar.int.test.ts test/integration/sdk/timeout.int.test.ts",
|
|
18
18
|
"test:integration:full": "RUN_INTEGRATION=1 vitest run test/integration",
|
|
19
|
-
"docs:meta": "
|
|
20
|
-
"docs:check": "
|
|
19
|
+
"docs:meta": "pnpm build && node ./scripts/generate-doc-meta.js",
|
|
20
|
+
"docs:check": "pnpm docs:meta && node ./scripts/check-doc-consistency.js",
|
|
21
21
|
"dev": "vitepress dev website",
|
|
22
22
|
"preview": "vitepress preview website",
|
|
23
|
-
"build:docs": "
|
|
24
|
-
"build:pages": "
|
|
25
|
-
"dev:v2": "vitepress dev site-v2",
|
|
26
|
-
"preview:v2": "vitepress preview site-v2",
|
|
27
|
-
"build:v2": "DOCS_BASE=/ vitepress build site-v2",
|
|
28
|
-
"build:v2:pages": "DOCS_BASE=/stock-sdk/ vitepress build site-v2",
|
|
23
|
+
"build:docs": "pnpm docs:meta && DOCS_BASE=/ vitepress build website",
|
|
24
|
+
"build:pages": "pnpm docs:meta && DOCS_BASE=/stock-sdk/ vitepress build website",
|
|
29
25
|
"prepare": "node ./scripts/install-git-hooks.js"
|
|
30
26
|
},
|
|
31
27
|
"exports": {
|
|
@@ -124,5 +120,5 @@
|
|
|
124
120
|
"registry": "https://registry.npmjs.org/",
|
|
125
121
|
"provenance": true
|
|
126
122
|
},
|
|
127
|
-
"packageManager": "
|
|
123
|
+
"packageManager": "pnpm@10.34.4"
|
|
128
124
|
}
|
package/dist/chunk-333W3ADG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as en,v as tn}from"./chunk-LRE63M2C.js";import{d as W,f as re}from"./chunk-4RR2H3DC.js";import{$ as Pe,A as Lt,B as Kt,C as wt,D as Ce,E as Bt,F as Ut,G as Re,H as b,I as Q,J as Ae,K as xt,L as Ee,M as Ht,N as te,O as Ye,P as De,Q as Ie,R as qt,S as Ve,T as Qt,U as zt,V as $t,W as jt,X as Gt,Y as We,Z as Oe,_ as _e,aa as Wt,ba as V,c as f,ca as z,d as E,da as j,e as d,ea as H,f as s,fa as Fe,g as Tt,ga as be,h as ht,ha as $,i as Ct,ia as q,j as Rt,ja as Zt,k as At,ka as U,l as Et,la as Xt,m as $e,n as Dt,na as Me,o as je,p as Ge,pa as R,q as It,qa as Ne,r as Ot,ra as v,s as _t,sa as Jt,t as Pt,ta as ke,u as Ft,v as bt,w as Mt,x as Nt,y as kt,z as vt}from"./chunk-ZAQ7DTRY.js";import{b as J}from"./chunk-JYHHLB34.js";import{a as ne,d as Yt,e as A,g as Vt}from"./chunk-UBIQBXQ7.js";import{a as ze}from"./chunk-WOT6VMZA.js";var w=(t,e)=>t*60+e,Gr={A:{tz:R.CN,open:[[w(9,30),w(11,30)],[w(13,0),w(15,0)]],lunchBreak:[w(11,30),w(13,0)],tradingWeekdays:[1,2,3,4,5]},HK:{tz:R.HK,open:[[w(9,30),w(12,0)],[w(13,0),w(16,0)]],lunchBreak:[w(12,0),w(13,0)],tradingWeekdays:[1,2,3,4,5]},US:{tz:R.US,open:[[w(9,30),w(16,0)]],tradingWeekdays:[1,2,3,4,5]}};function Ze(t,e){if(t==null)return Xe(new Date,e);if(t instanceof Date)return Xe(t,e);let n=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(n))return n;if(/^\d{8}$/.test(n))return`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`;let r=new Date(n);if(!Number.isNaN(r.getTime()))return Xe(r,e);throw new A(`Unsupported date input: ${JSON.stringify(t)}. Expected 'YYYY-MM-DD', 'YYYYMMDD', or Date.`)}function Xe(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(t)}function Yr(t,e){let n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,weekday:"short",hour:"2-digit",minute:"2-digit"}),r={};for(let l of n.formatToParts(t))l.type!=="literal"&&(r[l.type]=l.value);let o=parseInt(r.hour??"0",10);o===24&&(o=0);let i=parseInt(r.minute??"0",10),u={Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6,Sun:7}[r.weekday??""]??0;return{minutes:o*60+i,weekday:u}}function Je(t,e){let n=0,r=t.length;for(;n<r;){let o=n+r>>>1;t[o]<e?n=o+1:r=o}return n}var oe=class{constructor(e){this.quoteService=e}async isTradingDay(e){let n=Ze(e,R.CN),r=await this.quoteService.getTradingCalendar(),o=Je(r,n);return o<r.length&&r[o]===n}async nextTradingDay(e){let n=Ze(e,R.CN),r=await this.quoteService.getTradingCalendar(),o=Je(r,n);if(o<r.length&&r[o]===n&&(o+=1),o>=r.length)throw new A(`nextTradingDay: ${n} \u4E4B\u540E\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5927\u65E5\u671F ${r[r.length-1]??"N/A"})`);return r[o]}async prevTradingDay(e){let n=Ze(e,R.CN),r=await this.quoteService.getTradingCalendar(),i=Je(r,n)-1;if(i<0)throw new A(`prevTradingDay: ${n} \u4E4B\u524D\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5C0F\u65E5\u671F ${r[0]??"N/A"})`);return r[i]}getMarketStatus(e="A",n=new Date){let r=Gr[e],{minutes:o,weekday:i}=Yr(n,r.tz);if(!r.tradingWeekdays.includes(i))return"closed";let a=r.open[0][0],u=r.open[r.open.length-1][1];if(o<a)return"pre_market";if(o>=u)return"after_hours";for(let[l,c]of r.open)if(o>=l&&o<c)return"open";return r.lunchBreak&&o>=r.lunchBreak[0]&&o<r.lunchBreak[1]?"lunch_break":"closed"}};var F={};ze(F,{getAShareCodeList:()=>ln,getAllHKQuotesByCodes:()=>gn,getAllQuotesByCodes:()=>pn,getAllUSQuotesByCodes:()=>mn,getFullQuotes:()=>ve,getFundCodeList:()=>fn,getFundFlow:()=>rn,getFundQuotes:()=>sn,getHKCodeList:()=>dn,getHKQuotes:()=>Le,getPanelLargeOrder:()=>on,getSimpleQuotes:()=>nn,getTodayTimeline:()=>an,getTradingCalendar:()=>yn,getUSCodeList:()=>cn,getUSQuotes:()=>Ke,parseFullQuote:()=>et,parseFundFlow:()=>nt,parseFundQuote:()=>st,parseHKQuote:()=>ot,parsePanelLargeOrder:()=>rt,parseSimpleQuote:()=>tt,parseUSQuote:()=>it,search:()=>Tn});function et(t){let e=[];for(let i=0;i<5;i++)e.push({price:f(t[9+i*2]),volume:f(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:f(t[19+i*2]),volume:f(t[20+i*2])});let r=t[30]??"",o=v(r,R.CN);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),prevClose:f(t[4]),open:f(t[5]),volume:f(t[6]),outerVolume:f(t[7]),innerVolume:f(t[8]),bid:e,ask:n,time:r,timestamp:o.timestamp,tz:o.tz,change:f(t[31]),changePercent:f(t[32]),high:f(t[33]),low:f(t[34]),volume2:f(t[36]),amount:f(t[37]),turnoverRate:E(t[38]),pe:E(t[39]),amplitude:E(t[43]),circulatingMarketCap:E(t[44]),totalMarketCap:E(t[45]),pb:E(t[46]),limitUp:E(t[47]),limitDown:E(t[48]),volumeRatio:E(t[49]),avgPrice:E(t[51]),peStatic:E(t[52]),peDynamic:E(t[53]),high52w:E(t[67]),low52w:E(t[68]),circulatingShares:E(t[72]),totalShares:E(t[73]),market:"CN",assetType:"stock",source:"tencent"}}function tt(t){return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),change:f(t[4]),changePercent:f(t[5]),volume:f(t[6]),amount:f(t[7]),marketCap:E(t[9]),marketType:t[10]??"",market:"CN",assetType:"stock",source:"tencent"}}function nt(t){let e=t[13]??"",n=v(e,R.CN);return{code:t[0]??"",mainInflow:f(t[1]),mainOutflow:f(t[2]),mainNet:f(t[3]),mainNetRatio:f(t[4]),retailInflow:f(t[5]),retailOutflow:f(t[6]),retailNet:f(t[7]),retailNetRatio:f(t[8]),totalFlow:f(t[9]),name:t[12]??"",date:e,timestamp:n.timestamp,tz:n.tz}}function rt(t){return{buyLargeRatio:f(t[0]),buySmallRatio:f(t[1]),sellLargeRatio:f(t[2]),sellSmallRatio:f(t[3])}}function ot(t){let e=t[30]??"",n=v(e,R.HK);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),prevClose:f(t[4]),open:f(t[5]),volume:f(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:f(t[31]),changePercent:f(t[32]),high:f(t[33]),low:f(t[34]),amount:f(t[37]),lotSize:E(t[40]),circulatingMarketCap:E(t[44]),totalMarketCap:E(t[45]),currency:t[t.length-3]??"",market:"HK",assetType:"stock",source:"tencent"}}function it(t){let e=t[30]??"",n=v(e,R.US);return{marketId:t[0]??"",name:t[1]??"",code:t[2]??"",price:f(t[3]),prevClose:f(t[4]),open:f(t[5]),volume:f(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:f(t[31]),changePercent:f(t[32]),high:f(t[33]),low:f(t[34]),amount:f(t[37]),turnoverRate:E(t[38]),pe:E(t[39]),amplitude:E(t[43]),totalMarketCap:E(t[45]),pb:E(t[47]),high52w:E(t[48]),low52w:E(t[49]),market:"US",assetType:"stock",source:"tencent"}}function st(t){let e=t[8]??"",n=v(e,R.CN);return{code:t[0]??"",name:t[1]??"",nav:f(t[5]),accNav:f(t[6]),change:f(t[7]),navDate:e,timestamp:n.timestamp,tz:n.tz,market:"CN",assetType:"fund",source:"tencent"}}async function ve(t,e){if(!e||e.length===0)return[];let n=await t.getTencentQuote(e.join(",")),r=new Set(e);return n.filter(o=>r.has(o.key)&&o.fields&&o.fields.length>5&&o.fields[0]!=="").map(o=>et(o.fields))}async function nn(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`s_${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>tt(i.fields))}async function rn(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`ff_${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=14&&i.fields[0]!=="").map(i=>nt(i.fields))}async function on(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`s_pk${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=4&&i.fields[0]!=="").map(i=>rt(i.fields))}async function Le(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`hk${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>ot(i.fields))}async function Ke(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`us${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>5&&i.fields[0]!=="").map(i=>it(i.fields))}async function sn(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`jj${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return r.filter(i=>o.has(i.key)&&i.fields&&i.fields.length>=9&&i.fields[0]!=="").map(i=>st(i.fields))}async function an(t,e){let n=`${Tt}?code=${encodeURIComponent(e)}`,r=await t.get(n,{responseType:"json",provider:"tencent"});if(r.code!==0)throw new Vt(r.msg||"API error","tencent",n);let o=r.data?.[e];if(!o){let y=v("",R.CN);return{code:e,date:"",timestamp:y.timestamp,tz:y.tz,preClose:0,data:[]}}let i=o.data?.data??[],a=o.data?.date??"",u=o.qt?.[e]??[],l=parseFloat(u[4]??"")||0,c=!1;for(let y of i){let T=y.split(" "),C=parseFloat(T[1])||0,h=parseInt(T[2],10)||0,m=parseFloat(T[3])||0;if(h>0&&C>0){m/h>C*50&&(c=!0);break}}let g=i.map(y=>{let T=y.split(" "),C=T[0],h=`${C.slice(0,2)}:${C.slice(2,4)}`,m=parseInt(T[2],10)||0,O=parseFloat(T[3])||0,I=c?m*100:m,N=I>0?O/I:0,P=Jt(a,h,R.CN);return{time:h,timestamp:P.timestamp,tz:P.tz,price:parseFloat(T[1])||0,volume:I,amount:O,avgPrice:Math.round(N*100)/100}}),S=v(a,R.CN);return{code:e,date:a,timestamp:S.timestamp,tz:S.tz,preClose:l,data:g}}var un=J("tencent:code-lists",{defaultTTL:360*60*1e3,maxSize:16});async function at(t,e,n){return un.getOrFetch(e,async()=>(await t.get(n,{responseType:"json"}))?.list||[])}function Vr(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("4")||n.startsWith("8")||n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function ln(t,e){let n=e?.simple??!1,r=e?.market,i=await at(t,"a-share:full",ht);return r&&(i=i.filter(a=>Vr(a,r))),n?i.map(a=>a.replace(/^(sh|sz|bj)/,"")):i.slice()}var Wr={NASDAQ:"105.",NYSE:"106.",AMEX:"107."};async function cn(t,e){let n=e?.simple??!1,r=e?.market,i=(await at(t,"us:full",Ct)).slice();if(r){let a=Wr[r];i=i.filter(u=>u.startsWith(a))}return n?i.map(a=>a.replace(/^\d{3}\./,"")):i}async function dn(t){return(await at(t,"hk:full",Rt)).slice()}async function pn(t,e,n={}){let{batchSize:r=Oe,concurrency:o=Pe,onProgress:i}=n;V(r,"batchSize"),V(o,"concurrency");let a=Math.min(r,_e),u=Fe(e,a),l=u.length,c=0,g=u.map(y=>async()=>{let T=await ve(t,y);return c++,i&&i(c,l),T});return(await be(g,o,!0)).flat()}async function gn(t,e,n={}){let{batchSize:r=Oe,concurrency:o=Pe,onProgress:i}=n;V(r,"batchSize"),V(o,"concurrency");let a=Math.min(r,_e),u=Fe(e,a),l=u.length,c=0,g=u.map(y=>async()=>{let T=await Le(t,y);return c++,i&&i(c,l),T});return(await be(g,o,!0)).flat()}async function mn(t,e,n={}){let{batchSize:r=Oe,concurrency:o=Pe,onProgress:i}=n;V(r,"batchSize"),V(o,"concurrency");let a=Math.min(r,_e),u=Fe(e,a),l=u.length,c=0,g=u.map(y=>async()=>{let T=await Ke(t,y);return c++,i&&i(c,l),T});return(await be(g,o,!0)).flat()}async function fn(t){return(await un.getOrFetch("fund:full",async()=>(await t.get(At,{responseType:"text"})).split(",").slice(1).filter(o=>o.trim()))).slice()}var Zr=J("tencent:trade-calendar",{defaultTTL:720*60*1e3,maxSize:4});async function yn(t){return(await Zr.getOrFetch("a-share",async()=>{let n=await t.get(Et);return!n||n.trim()===""?[]:n.trim().split(",").map(r=>r.trim()).filter(r=>r.length>0)})).slice()}var Sn="https://smartbox.gtimg.cn/s3/";function Xr(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function Jr(t){let e=t.toUpperCase();return e.startsWith("QDII")||e.startsWith("ETF")||e.startsWith("LOF")||e.startsWith("KJ")||e.startsWith("JJ")||e.includes("FUND")?"fund":e.startsWith("GP")||e.includes("STOCK")?"stock":e==="ZS"||e.includes("INDEX")?"index":e.startsWith("ZQ")||e.includes("BOND")?"bond":e.startsWith("QH")||e.includes("FUTURE")?"futures":e.startsWith("QZ")||e.includes("OPTION")?"option":"other"}function eo(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let r=n.split("~"),o=r[0]||"",i=r[1]||"",a=Xr(r[2]||""),u=r[4]||"";return{code:o+i,name:a,market:o,type:u,category:Jr(u)}})}function to(t){return new Promise((e,n)=>{let r=`${Sn}?v=2&t=all&q=${encodeURIComponent(t)}`;window.v_hint="";let o=document.createElement("script");o.src=r,o.charset="utf-8",o.onload=()=>{let i=window.v_hint||"";document.body.removeChild(o),e(i)},o.onerror=()=>{document.body.removeChild(o),n(new ne({code:"NETWORK_ERROR",message:"Network error calling Smartbox",url:r}))},document.body.appendChild(o)})}async function no(t,e){let n=`${Sn}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function ro(){return typeof window<"u"&&typeof document<"u"}async function Tn(t,e){if(!e||!e.trim())return[];let n;return ro()?n=await to(e):n=await no(t,e),eo(n)}var p={};ze(p,{extractVariety:()=>gt,fetchDatacenter:()=>lt,fetchDatacenterList:()=>D,getBlockTradeDailyStat:()=>vr,getBlockTradeDetail:()=>kr,getBlockTradeMarketStat:()=>Nr,getBoardChanges:()=>Er,getCFFEXOptionQuotes:()=>Jn,getComexInventory:()=>or,getConceptConstituents:()=>Bn,getConceptKline:()=>Un,getConceptList:()=>Kn,getConceptMinuteKline:()=>xn,getConceptSpot:()=>wn,getDividendDetail:()=>Hn,getDragonTigerBranchRank:()=>Pr,getDragonTigerDetail:()=>Ir,getDragonTigerInstitution:()=>_r,getDragonTigerStockSeatDetail:()=>Fr,getDragonTigerStockStats:()=>Or,getFundDividendList:()=>zn,getFundEstimate:()=>Gn,getFundFlowRank:()=>dr,getFundNavHistory:()=>jn,getFundRankHistory:()=>Yn,getFuturesHistoryKline:()=>Wn,getFuturesInventory:()=>rr,getFuturesInventorySymbols:()=>nr,getFuturesMarketCode:()=>mt,getGlobalFuturesKline:()=>Xn,getGlobalFuturesSpot:()=>Zn,getHKHistoryKline:()=>Rn,getHKMinuteKline:()=>An,getHistoryKline:()=>hn,getIndividualFundFlow:()=>lr,getIndustryConstituents:()=>kn,getIndustryKline:()=>vn,getIndustryList:()=>Mn,getIndustryMinuteKline:()=>Ln,getIndustrySpot:()=>Nn,getMarginAccountInfo:()=>Lr,getMarginTargetList:()=>Kr,getMarketFundFlow:()=>cr,getMinuteKline:()=>Cn,getNorthboundFlowSummary:()=>Sr,getNorthboundHistory:()=>hr,getNorthboundHoldingRank:()=>Tr,getNorthboundIndividual:()=>Cr,getNorthboundMinute:()=>yr,getOptionLHB:()=>er,getSectorFundFlowHistory:()=>gr,getSectorFundFlowRank:()=>pr,getStockChanges:()=>Ar,getUSHistoryKline:()=>En,getUSMinuteKline:()=>Dn,getZTPool:()=>Rr});async function ut(t,e,n,r,o=100,i){let a=[],u=1,l=0;do{let c=new URLSearchParams({...n,pn:String(u),pz:String(o),fields:r}),g=`${e}?${c.toString()}`,y=(await t.get(g,{responseType:"json"}))?.data;if(!y||!Array.isArray(y.diff))break;u===1&&(l=y.total??0);let T=y.diff.map((C,h)=>i(C,a.length+h+1));if(a.push(...T),T.length===0)break;u++}while(a.length<l);return a}function L(t){let[e,n,r,o,i,a,u,l,c,g,S]=t.split(",");return{date:e,open:d(n),close:d(r),high:d(o),low:d(i),volume:d(a),amount:d(u),amplitude:d(l),changePercent:d(c),change:d(g),turnoverRate:d(S)}}async function K(t,e,n){let r=`${e}?${n.toString()}`,o=await t.get(r,{responseType:"json"});return{klines:o?.data?.klines||[],name:o?.data?.name,code:o?.data?.code}}async function hn(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:i="19700101",endDate:a="20500101"}=n;z(r),H(o);let u=W(e,{market:"CN"}),l=re(u),c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:b,klt:$(r),fqt:q(o),secid:l,beg:i,end:a}),g=$e,{klines:S}=await K(t,g,c);return S.length===0?[]:S.map(y=>{let T=L(y),C=v(T.date,R.CN);return{...T,timestamp:C.timestamp,tz:C.tz,code:u.code}})}async function Cn(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:a="2222-01-01 09:32:00"}=n;j(r),H(o);let u=re(W(e,{market:"CN"}));if(r==="1"){let l=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:b,ndays:"5",iscr:"0",secid:u}),c=`${Dt}?${l.toString()}`,S=(await t.get(c,{responseType:"json"}))?.data?.trends;if(!Array.isArray(S)||S.length===0)return[];let y=i.replace("T"," ").slice(0,16),T=a.replace("T"," ").slice(0,16);return T.length===10&&(T+=" 23:59"),S.map(C=>{let[h,m,O,I,N,P,k,X]=C.split(","),B=v(h,R.CN);return{time:h,timestamp:B.timestamp,tz:B.tz,open:d(m),close:d(O),high:d(I),low:d(N),volume:d(P),amount:d(k),avgPrice:d(X)}}).filter(C=>C.time>=y&&C.time<=T)}else{let l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:b,klt:r,fqt:q(o||""),secid:u,beg:"0",end:"20500000"}),c=$e,{klines:g}=await K(t,c,l);if(g.length===0)return[];let S=i.replace("T"," ").slice(0,16),y=a.replace("T"," ").slice(0,16);return y.length===10&&(y+=" 23:59"),g.map(T=>{let C=L(T),h=v(C.date,R.CN);return{...C,time:C.date,timestamp:h.timestamp,tz:h.tz}}).filter(T=>T.time>=S&&T.time<=y)}}function we(t){return async function(n,r,o={}){let{period:i="daily",adjust:a="qfq",startDate:u="19700101",endDate:l="20500101"}=o;z(i),H(a);let c=t.normalizeSymbol(r),g=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:b,klt:$(i),fqt:q(a),secid:c.secid,beg:u,end:l,lmt:"1000000"}),{klines:S,name:y,code:T}=await K(n,t.url,g);if(S.length===0)return[];let C=t.resolveResultMeta?t.resolveResultMeta(r,c,{code:T,name:y}):{code:T||c.fallbackCode,name:y||""};return S.map(h=>{let m=L(h),O=v(m.date,t.tz),I={...m,timestamp:O.timestamp,tz:O.tz,code:C.code,name:C.name};return t.enrichItem(I)})}}var oo=we({url:je,tz:R.HK,normalizeSymbol:t=>{let e=t.replace(/^hk/i,"").padStart(5,"0");return{secid:`116.${e}`,fallbackCode:e}},enrichItem:t=>({...t,currency:"HKD",lotSize:null})});async function Rn(t,e,n={}){return oo(t,e,n)}async function An(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:a="2222-01-01 09:32:00",ndays:u=1}=n;j(r),H(o);let l=e.replace(/^hk/i,"").padStart(5,"0"),c=`116.${l}`,g=h=>{let m=Ne(h,R.CN);return{time:ke(m,R.HK)||h,timestamp:m}};if(r==="1"){let h=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:b,ndays:String(u),iscr:"0",secid:c}),m=`${It}?${h.toString()}`,I=(await t.get(m,{responseType:"json"}))?.data?.trends;if(!Array.isArray(I)||I.length===0)return[];let N=i.replace("T"," ").slice(0,16),P=a.replace("T"," ").slice(0,16);return P.length===10&&(P+=" 23:59"),I.map(k=>{let[X,B,ee,G,Y,Ue,xe,He]=k.split(","),{time:qe,timestamp:Qe}=g(X);return{time:qe,timestamp:Qe,tz:R.HK,open:d(B),close:d(ee),high:d(G),low:d(Y),volume:d(Ue),amount:d(xe),avgPrice:d(He),currency:"HKD",code:l}}).filter(k=>k.time>=N&&k.time<=P)}let S=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:b,klt:r,fqt:q(o),secid:c,beg:"0",end:"20500000"}),{klines:y}=await K(t,je,S);if(y.length===0)return[];let T=i.replace("T"," ").slice(0,16),C=a.replace("T"," ").slice(0,16);return C.length===10&&(C+=" 23:59"),y.map(h=>{let m=L(h),{time:O,timestamp:I}=g(m.date);return{time:O,timestamp:I,tz:R.HK,open:m.open,close:m.close,high:m.high,low:m.low,volume:m.volume,amount:m.amount,amplitude:m.amplitude,changePercent:m.changePercent,change:m.change,turnoverRate:m.turnoverRate,currency:"HKD",code:l}}).filter(h=>h.time>=T&&h.time<=C)}var io=we({url:Ge,tz:R.US,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:n.code||e.fallbackCode,name:n.name||""}),enrichItem:t=>({...t,currency:"USD"})});async function En(t,e,n={}){return io(t,e,n)}async function Dn(t,e,n={}){let{period:r="1",adjust:o="qfq",startDate:i="1979-09-01 09:32:00",endDate:a="2222-01-01 09:32:00",ndays:u=1}=n;j(r),H(o);let l=e,c=e.split(".")[1]||e,g=h=>{let m=Ne(h,R.CN);return{time:ke(m,R.US)||h,timestamp:m}};if(r==="1"){let h=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:b,ndays:String(u),iscr:"0",secid:l}),m=`${Ot}?${h.toString()}`,I=(await t.get(m,{responseType:"json"}))?.data?.trends;if(!Array.isArray(I)||I.length===0)return[];let N=i.replace("T"," ").slice(0,16),P=a.replace("T"," ").slice(0,16);return P.length===10&&(P+=" 23:59"),I.map(k=>{let[X,B,ee,G,Y,Ue,xe,He]=k.split(","),{time:qe,timestamp:Qe}=g(X);return{time:qe,timestamp:Qe,tz:R.US,open:d(B),close:d(ee),high:d(G),low:d(Y),volume:d(Ue),amount:d(xe),avgPrice:d(He),currency:"USD",code:c}}).filter(k=>k.time>=N&&k.time<=P)}let S=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:b,klt:r,fqt:q(o),secid:l,beg:"0",end:"20500000"}),{klines:y}=await K(t,Ge,S);if(y.length===0)return[];let T=i.replace("T"," ").slice(0,16),C=a.replace("T"," ").slice(0,16);return C.length===10&&(C+=" 23:59"),y.map(h=>{let m=L(h),{time:O,timestamp:I}=g(m.date);return{time:O,timestamp:I,tz:R.US,open:m.open,close:m.close,high:m.high,low:m.low,volume:m.volume,amount:m.amount,amplitude:m.amplitude,changePercent:m.changePercent,change:m.change,turnoverRate:m.turnoverRate,currency:"USD",code:c}}).filter(h=>h.time>=T&&h.time<=C)}function In(t){let e=J(`eastmoney:board-code-map:${t.type}`,{defaultTTL:36e5,maxSize:4});return{async getCode(n,r,o){if(r.startsWith("BK"))return r;let a=(await e.getOrFetch("name-code-map",async()=>{let u=await o(n);return Object.fromEntries(u.map(l=>[l.name,l.code]))}))[r];if(!a)throw new Yt(`${t.errorPrefix}: ${r}`,"eastmoney");return a}}}async function On(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},r=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await ut(t,e.listUrl,n,r,100,(i,a)=>({rank:a,name:String(i.f14??""),code:String(i.f12??""),price:s(i.f2),change:s(i.f4),changePercent:s(i.f3),totalMarketCap:s(i.f20),turnoverRate:s(i.f8),riseCount:s(i.f104),fallCount:s(i.f105),leadingStock:i.f128?String(i.f128):null,leadingStockChangePercent:s(i.f136)}));return o.sort((i,a)=>(a.changePercent??0)-(i.changePercent??0)),o.forEach((i,a)=>{i.rank=a+1}),o}async function _n(t,e,n){let r=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${r.toString()}`,a=(await t.get(o,{responseType:"json"}))?.data;return a?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:c,divide:g})=>{let S=a[l],y=null;return typeof S=="number"&&!isNaN(S)&&(y=g?S/100:S),{item:c,value:y}}):[]}async function Pn(t,e,n){let r={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return ut(t,n,r,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(i,a)=>({rank:a,code:String(i.f12??""),name:String(i.f14??""),price:s(i.f2),changePercent:s(i.f3),change:s(i.f4),volume:s(i.f5),amount:s(i.f6),amplitude:s(i.f7),high:s(i.f15),low:s(i.f16),open:s(i.f17),prevClose:s(i.f18),turnoverRate:s(i.f8),pe:s(i.f9),pb:s(i.f23)}))}async function Fn(t,e,n,r={}){let{period:o="daily",adjust:i="",startDate:a="19700101",endDate:u="20500101"}=r;z(o),H(i);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:$(o),fqt:q(i),beg:a,end:u,smplmt:"10000",lmt:"1000000"}),{klines:c}=await K(t,n,l);return c.length===0?[]:c.map(g=>L(g))}async function bn(t,e,n,r,o={}){let{period:i="5"}=o;if(j(i),i==="1"){let a=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}`}),u=`${r}?${a.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.trends;return!Array.isArray(c)||c.length===0?[]:c.map(g=>{let[S,y,T,C,h,m,O,I]=g.split(","),N=d(I);return{time:S,open:d(y),close:d(T),high:d(C),low:d(h),volume:d(m),amount:d(O),price:N}})}else{let a=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:i,fqt:"1",beg:"0",end:"20500101",smplmt:"10000",lmt:"1000000"}),u=`${n}?${a.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(g=>{let[S,y,T,C,h,m,O,I,N,P,k]=g.split(",");return{time:S,open:d(y),close:d(T),high:d(C),low:d(h),changePercent:d(N),change:d(P),volume:d(m),amount:d(O),amplitude:d(I),turnoverRate:d(k)}})}}function Be(t){let e=In(t);async function n(o){return On(o,t)}async function r(o,i){return e.getCode(o,i,n)}return{async getList(o){return n(o)},async getSpot(o,i){let a=await r(o,i);return _n(o,a,t.spotUrl)},async getConstituents(o,i){let a=await r(o,i);return Pn(o,a,t.consUrl)},async getKline(o,i,a={}){let u=await r(o,i);return Fn(o,u,t.klineUrl,a)},async getMinuteKline(o,i,a={}){let u=await r(o,i);return bn(o,u,t.klineUrl,t.trendsUrl,a)}}}var so={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:_t,spotUrl:Pt,consUrl:Ft,klineUrl:bt,trendsUrl:Mt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},ie=Be(so);async function Mn(t){return ie.getList(t)}async function Nn(t,e){return ie.getSpot(t,e)}async function kn(t,e){return ie.getConstituents(t,e)}async function vn(t,e,n={}){return ie.getKline(t,e,n)}async function Ln(t,e,n={}){return ie.getMinuteKline(t,e,n)}var ao={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Nt,spotUrl:kt,consUrl:vt,klineUrl:Lt,trendsUrl:Kt,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},se=Be(ao);async function Kn(t){return se.getList(t)}async function wn(t,e){return se.getSpot(t,e)}async function Bn(t,e){return se.getConstituents(t,e)}async function Un(t,e,n={}){return se.getKline(t,e,n)}async function xn(t,e,n={}){return se.getMinuteKline(t,e,n)}async function lt(t,e,n){let{reportName:r,columns:o="ALL",filter:i,sortColumns:a,sortTypes:u,pageSize:l=500,startPage:c=1,fetchAllPages:g=!0,maxPages:S=1e3,quoteColumns:y,quoteType:T,extraParams:C}=e,h=[],m=c,O=1,I=0,N=0;do{let P=new URLSearchParams({reportName:r,columns:o,pageSize:String(l),pageNumber:String(m),source:"WEB",client:"WEB"});if(i&&P.set("filter",i),a&&P.set("sortColumns",a),u&&P.set("sortTypes",u),y&&P.set("quoteColumns",y),T&&P.set("quoteType",T),C)for(let[G,Y]of Object.entries(C))P.set(G,Y);let k=`${wt}?${P.toString()}`,B=(await t.get(k,{responseType:"json"}))?.result;if(!B||!Array.isArray(B.data))break;m===c&&(O=B.pages??1,I=B.count??B.data.length);let ee=B.data.map((G,Y)=>n(G,h.length+Y));if(h.push(...ee),m++,N++,!g)break}while(m<=O&&N<S);return g&&N>=S&&m<=O&&console.warn(`[stock-sdk] fetchDatacenter("${r}") truncated at maxPages=${S} (server reports ${O} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:h,total:I,pages:O}}async function D(t,e,n){return(await lt(t,e,n)).data}function M(t){if(t==null)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}function Z(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function uo(t){return{code:t.SECURITY_CODE??"",name:t.SECURITY_NAME_ABBR??"",reportDate:Z(t.REPORT_DATE),planNoticeDate:Z(t.PLAN_NOTICE_DATE),disclosureDate:Z(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:Z(t.EQUITY_RECORD_DATE),exDividendDate:Z(t.EX_DIVIDEND_DATE),payDate:Z(t.PAY_DATE),assignProgress:t.ASSIGN_PROGRESS??null,noticeDate:Z(t.NOTICE_DATE)}}async function Hn(t,e){let n=e.replace(/^(sh|sz|bj)/,"");return D(t,{reportName:"RPT_SHAREBONUS_DET",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:500,filter:`(SECURITY_CODE="${n}")`},r=>uo(r))}var lo="https://fund.eastmoney.com/Data/funddataIndex_Interface.aspx",Qn="https://fund.eastmoney.com/pingzhongdata",co="https://fundgz.1234567.com.cn/js";function po(){return typeof document<"u"&&typeof window<"u"}var go=1e4;function mo(){return new Date().getFullYear()}function fo(t,e){let n=new URLSearchParams({dt:"8",page:String(e),rank:t.rank??"FSRQ",sort:t.sort??"desc",gs:"",ftype:t.fundType??"",year:String(t.year??mo())});return`${lo}?${n.toString()}`}function ct(t){if(!t)return null;let e=t.trim().match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function yo(t){if(t===void 0||t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function So(t){return{code:t[0]??"",name:t[1]??"",equityRecordDate:ct(t[2]),exDividendDate:ct(t[3]),dividendPerShare:yo(t[4]),payDate:ct(t[5])}}async function dt(t,e,n){let r=fo(e,n),o=await Me(r,["pageinfo","jjfh_data"],{client:t}),i=o.pageinfo??[0,0,n],[a=0,u=0,l=n]=i;return{items:(o.jjfh_data??[]).map(So),totalPages:a,pageSize:u,currentPage:l}}async function zn(t,e={}){if(e.page==="all"){let o=await dt(t,e,1),i=o.items;for(let a=2;a<=o.totalPages;a++){let u=await dt(t,e,a);i=i.concat(u.items)}return e.code&&(i=i.filter(a=>a.code===e.code)),{items:i,totalPages:o.totalPages,pageSize:o.pageSize,currentPage:-1}}let n=e.page??1,r=await dt(t,e,n);return e.code?{...r,items:r.items.filter(o=>o.code===e.code)}:r}function To(t){if(t===void 0||t===""||t===null)return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}function $n(t){return new Date(t).toISOString().slice(0,10)}async function jn(t,e){let n=`${Qn}/${encodeURIComponent(e)}.js`,r=await Me(n,["fS_code","fS_name","Data_netWorthTrend","Data_ACWorthTrend"],{client:t}),o=r.Data_netWorthTrend??[],i=new Map;for(let u of r.Data_ACWorthTrend??[])Array.isArray(u)&&u.length>=2&&i.set(u[0],u[1]);let a=o.map(u=>({date:$n(u.x),timestamp:u.x,nav:u.y,accNav:i.has(u.x)?i.get(u.x):null,dailyReturn:To(u.equityReturn),unitMoney:u.unitMoney??""}));return{code:r.fS_code??e,name:r.fS_name??null,items:a}}function ho(t,e,n=go){let r=`${co}/${encodeURIComponent(e)}.js?rt=${Date.now()}`;return po()?Xt("fundgz:jsonpgz",()=>Co(r,n)):Ro(t,r)}function Co(t,e){return new Promise((n,r)=>{let o=document.createElement("script"),i=window,a=i.jsonpgz,u=!1,l=()=>{if(o.parentNode&&o.parentNode.removeChild(o),a===void 0)try{delete i.jsonpgz}catch{}else i.jsonpgz=a},c=setTimeout(()=>{u||(u=!0,l(),r(new ne({code:"TIMEOUT",message:`fundgz JSONP timed out after ${e}ms: ${t}`,url:t,details:{timeout:e}})))},e);i.jsonpgz=g=>{u||(u=!0,clearTimeout(c),l(),n(g??{}))},o.onerror=()=>{u||(u=!0,clearTimeout(c),l(),r(new ne({code:"NETWORK_ERROR",message:`fundgz JSONP script load failed: ${t}`,url:t})))},o.src=t,document.head.appendChild(o)})}async function Ro(t,e){let r=(await t.get(e,{responseType:"text",provider:"eastmoney"})).trim();if(!r)return{};try{return Zt(r)}catch{return{}}}function pt(t){if(t===void 0||t===""||t==="--")return null;let e=Number(t);return Number.isFinite(e)?e:null}async function Gn(t,e){let n=await ho(t,e);return{code:n.fundcode??e,name:n.name??null,navDate:n.jzrq?.trim()?n.jzrq.trim():null,nav:pt(n.dwjz),estimatedNav:pt(n.gsz),estimatedChangePercent:pt(n.gszzl),estimateTime:n.gztime?.trim()?n.gztime.trim():null}}function qn(t){if(t===void 0||t===""||t===null)return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}async function Yn(t,e){let n=`${Qn}/${encodeURIComponent(e)}.js`,r=await Me(n,["fS_code","fS_name","Data_rateInSimilarType","Data_rateInSimilarPersent"],{client:t}),o=r.Data_rateInSimilarType??[],i=new Map;for(let u of r.Data_rateInSimilarPersent??[])Array.isArray(u)&&u.length>=2&&i.set(u[0],u[1]);let a=o.map(u=>({date:$n(u.x),timestamp:u.x,rank:qn(u.y),total:qn(u.sc),percentile:i.has(u.x)?i.get(u.x):null}));return{code:r.fS_code??e,name:r.fS_name??null,items:a}}function gt(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new A(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function Vn(t){return te[t]??te[t.toLowerCase()]??te[t.toUpperCase()]}function mt(t){let e=Vn(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=Vn(t.slice(0,-1))),!e){let r=Object.keys(te).join(", ");throw new A(`Unknown futures variety: "${t}". Supported varieties: ${r}`)}let n=Ht[e];if(n===void 0)throw new A(`No market code found for exchange: ${e}`);return n}function Ao(t){let e=L(t),n=t.split(",");return{...e,openInterest:n.length>12?d(n[12]):null}}async function Wn(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;z(r);let a=gt(e),l=`${mt(a)}.${e}`,c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:b,klt:$(r),fqt:"0",secid:l,beg:o,end:i}),{klines:g,name:S,code:y}=await K(t,Ae,c);return g.length===0?[]:g.map(T=>({...Ao(T),code:y||e,name:S||""}))}async function Zn(t,e={}){let n=e.pageSize??20,r=[],o=0,i=0;do{let a=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(o),token:Ee,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),u=`${xt}?${a.toString()}`,l=await t.get(u,{responseType:"json"});if(!l||!Array.isArray(l.list))break;o===0&&(i=l.total??0);let c=l.list.map(Eo);r.push(...c),o++}while(r.length<i);return r}function Eo(t){return{code:t.dm||"",name:t.name||"",price:d(String(t.p)),change:d(String(t.zde)),changePercent:d(String(t.zdf)),open:d(String(t.o)),high:d(String(t.h)),low:d(String(t.l)),prevSettle:d(String(t.zjsj)),volume:d(String(t.vol)),buyVolume:d(String(t.wp)),sellVolume:d(String(t.np)),openInterest:d(String(t.ccl))}}function Do(t){let e=L(t),n=t.split(",");return{...e,openInterest:n.length>12?d(n[12]):null}}function Io(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new A(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function Xn(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;z(r);let a=n.marketCode;if(a===void 0){let y=Io(e);if(a=Ye[y],a===void 0){let T=Object.keys(Ye).join(", ");throw new A(`Unknown global futures variety: "${y}". Supported: ${T}. Or specify marketCode manually via options.`)}}let u=`${a}.${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:b,klt:$(r),fqt:"0",secid:u,beg:o,end:i}),{klines:c,name:g,code:S}=await K(t,Ae,l);return c.length===0?[]:c.map(y=>({...Do(y),code:S||e,name:g||""}))}async function Jn(t,e={}){let{pageSize:n=2e4}=e,r=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:Ee,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${jt}?${r.toString()}`,a=(await t.get(o,{responseType:"json"}))?.list;return Array.isArray(a)?a.map(u=>({code:String(u.dm??""),name:String(u.name??""),price:s(u.p),change:s(u.zde),changePercent:s(u.zdf),volume:s(u.vol),amount:s(u.cje),openInterest:s(u.ccl),strikePrice:s(u.xqj),remainDays:s(u.syr),dailyChange:s(u.rz),prevSettle:s(u.zjsj),open:s(u.o)})):[]}async function er(t,e,n){let r=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:Q,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),o=`${Gt}?${r.toString()}`,a=(await t.get(o,{responseType:"json"}))?.result?.data;if(!Array.isArray(a))return[];function u(l){if(!l)return"";let c=String(l),g=c.match(/^(\d{4}-\d{2}-\d{2})/);return g?g[1]:c}return a.map(l=>({tradeType:String(l.TRADE_TYPE??""),date:u(l.TRADE_DATE),symbol:String(l.SECURITY_CODE??""),targetName:String(l.TARGET_NAME??""),memberName:String(l.MEMBER_NAME_ABBR??""),rank:s(l.MEMBER_RANK)??0,sellVolume:s(l.SELL_VOLUME),sellVolumeChange:s(l.SELL_VOLUME_CHANGE),netSellVolume:s(l.NET_SELL_VOLUME),sellVolumeRatio:s(l.SELL_VOLUME_RATIO),buyVolume:s(l.BUY_VOLUME),buyVolumeChange:s(l.BUY_VOLUME_CHANGE),netBuyVolume:s(l.NET_BUY_VOLUME),buyVolumeRatio:s(l.BUY_VOLUME_RATIO),sellPosition:s(l.SELL_POSITION),sellPositionChange:s(l.SELL_POSITION_CHANGE),netSellPosition:s(l.NET_SELL_POSITION),sellPositionRatio:s(l.SELL_POSITION_RATIO),buyPosition:s(l.BUY_POSITION),buyPositionChange:s(l.BUY_POSITION_CHANGE),netBuyPosition:s(l.NET_BUY_POSITION),buyPositionRatio:s(l.BUY_POSITION_RATIO)}))}var Oo={gold:"EMI00069026",silver:"EMI00069027"};function tr(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function nr(t){return D(t,{reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageSize:500,fetchAllPages:!1},e=>({code:String(e.TRADE_CODE??""),name:String(e.TRADE_TYPE??""),marketCode:String(e.TRADE_MARKET_CODE??"")}))}async function rr(t,e,n={}){let{startDate:r="2020-10-28",pageSize:o=500}=n,i=e.toUpperCase();return D(t,{reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${i}")(TRADE_DATE>='${r}')`,pageSize:o,sortColumns:"TRADE_DATE",sortTypes:"-1"},a=>({code:String(a.SECURITY_CODE??e),date:tr(a.TRADE_DATE),inventory:s(a.ON_WARRANT_NUM),change:s(a.ADDCHANGE)}))}async function or(t,e,n={}){let r=Oo[e];if(!r)throw new A(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:o=500}=n,i={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};return D(t,{reportName:"RPT_FUTUOPT_GOLDSIL",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:o,filter:`(INDICATOR_ID1="${r}")(@STORAGE_TON<>"NULL")`},a=>({date:tr(a.REPORT_DATE),name:i[e]??e,storageTon:s(a.STORAGE_TON),storageOunce:s(a.STORAGE_OUNCE)}))}var ir={daily:"101",weekly:"102",monthly:"103"},ft="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function sr(t){let e=t.split(",");return{date:e[0]??"",mainNetInflow:d(e[1]),smallNetInflow:d(e[2]),mediumNetInflow:d(e[3]),largeNetInflow:d(e[4]),superLargeNetInflow:d(e[5]),mainNetInflowPercent:d(e[6]),smallNetInflowPercent:d(e[7]),mediumNetInflowPercent:d(e[8]),largeNetInflowPercent:d(e[9]),superLargeNetInflowPercent:d(e[10]),close:d(e[11]),changePercent:d(e[12])}}function _o(t){let e=t.split(",");return{date:e[0]??"",mainNetInflow:d(e[1]),smallNetInflow:d(e[2]),mediumNetInflow:d(e[3]),largeNetInflow:d(e[4]),superLargeNetInflow:d(e[5]),mainNetInflowPercent:d(e[6]),smallNetInflowPercent:d(e[7]),mediumNetInflowPercent:d(e[8]),largeNetInflowPercent:d(e[9]),superLargeNetInflowPercent:d(e[10]),shClose:d(e[11]),shChangePercent:d(e[12]),szClose:d(e[13]),szChangePercent:d(e[14])}}var ar={today:{fid:"f62",fields:"f12,f14,f2,f3,f62,f184,f66,f69,f72,f75,f78,f81,f84,f87,f124",changePercentField:"f3",mainNet:"f62",mainPct:"f184",superLargeNet:"f66",superLargePct:"f69",largeNet:"f72",largePct:"f75",mediumNet:"f78",mediumPct:"f81",smallNet:"f84",smallPct:"f87"},"3day":{fid:"f267",fields:"f12,f14,f2,f127,f267,f268,f269,f270,f271,f272,f273,f274,f275,f276,f124",changePercentField:"f127",mainNet:"f267",mainPct:"f268",superLargeNet:"f269",superLargePct:"f270",largeNet:"f271",largePct:"f272",mediumNet:"f273",mediumPct:"f274",smallNet:"f275",smallPct:"f276"},"5day":{fid:"f164",fields:"f12,f14,f2,f109,f164,f165,f166,f167,f168,f169,f170,f171,f172,f173,f124",changePercentField:"f109",mainNet:"f164",mainPct:"f165",superLargeNet:"f166",superLargePct:"f167",largeNet:"f168",largePct:"f169",mediumNet:"f170",mediumPct:"f171",smallNet:"f172",smallPct:"f173"},"10day":{fid:"f174",fields:"f12,f14,f2,f160,f174,f175,f176,f177,f178,f179,f180,f181,f182,f183,f124",changePercentField:"f160",mainNet:"f174",mainPct:"f175",superLargeNet:"f176",superLargePct:"f177",largeNet:"f178",largePct:"f179",mediumNet:"f180",mediumPct:"f181",smallNet:"f182",smallPct:"f183"}},Po={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},Fo="m:0+t:6+f:!2,m:0+t:13+f:!2,m:0+t:80+f:!2,m:1+t:2+f:!2,m:1+t:23+f:!2,m:0+t:7+f:!2,m:1+t:3+f:!2";async function ur(t,e,n=100,r=1e3){let o=[],i=1,a=0;do{let u=new URLSearchParams({...e,pn:String(i),pz:String(n)}),l=`${Bt}?${u.toString()}`,g=(await t.get(l,{responseType:"json"}))?.data;if(!g||!Array.isArray(g.diff)||(i===1&&(a=g.total??0),o.push(...g.diff),o.length>=a||g.diff.length<n))break;i++}while(o.length<a&&i<=r);return i>r&&o.length<a&&console.warn(`[stock-sdk] fetchClistAllPages truncated at maxPages=${r} (server reports total=${a}, fetched=${o.length}). Pass a larger \`maxPages\` to fetch the full dataset.`),o}async function lr(t,e,n={}){let{period:r="daily"}=n,o=ir[r];if(!o)throw new A(`Invalid period: ${r}. Must be daily/weekly/monthly.`);let i=re(W(e,{market:"CN"})),a=new URLSearchParams({lmt:"0",klt:o,secid:i,fields1:"f1,f2,f3,f7",fields2:ft,ut:Q}),u=`${Ce}?${a.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(sr)}async function cr(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:ft,ut:Q}),n=`${Ce}?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.data?.klines;return!Array.isArray(o)||o.length===0?[]:o.map(_o)}async function dr(t,e={}){let{indicator:n="today"}=e,r=ar[n];if(!r)throw new A(`Invalid indicator: ${n}.`);let o={fid:r.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:Q,fs:Fo,fields:r.fields};return(await ur(t,o,100)).map(a=>({code:String(a.f12??""),name:String(a.f14??""),price:s(a.f2),changePercent:s(a[r.changePercentField]),mainNetInflow:s(a[r.mainNet]),mainNetInflowPercent:s(a[r.mainPct]),superLargeNetInflow:s(a[r.superLargeNet]),superLargeNetInflowPercent:s(a[r.superLargePct]),largeNetInflow:s(a[r.largeNet]),largeNetInflowPercent:s(a[r.largePct]),mediumNetInflow:s(a[r.mediumNet]),mediumNetInflowPercent:s(a[r.mediumPct]),smallNetInflow:s(a[r.smallNet]),smallNetInflowPercent:s(a[r.smallPct])}))}async function pr(t,e={}){let{indicator:n="today",sectorType:r="industry"}=e,o=ar[n];if(!o)throw new A(`Invalid indicator: ${n}.`);let i=Po[r];if(!i)throw new A(`Invalid sectorType: ${r}.`);let a=`${o.fields},f204,f205`,u={fid:o.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:Q,fs:i,fields:a};return(await ur(t,u,100)).map(c=>({code:String(c.f12??""),name:String(c.f14??""),changePercent:s(c[o.changePercentField]),mainNetInflow:s(c[o.mainNet]),mainNetInflowPercent:s(c[o.mainPct]),superLargeNetInflow:s(c[o.superLargeNet]),largeNetInflow:s(c[o.largeNet]),mediumNetInflow:s(c[o.mediumNet]),smallNetInflow:s(c[o.smallNet]),topStockCode:c.f204?String(c.f204):void 0,topStockName:c.f205?String(c.f205):void 0}))}async function gr(t,e,n={}){let{period:r="daily"}=n,o=ir[r];if(!o)throw new A(`Invalid period: ${r}. Must be daily/weekly/monthly.`);let i=e.includes(".")?e:`90.${e}`,a=new URLSearchParams({lmt:"0",klt:o,secid:i,fields1:"f1,f2,f3,f7",fields2:ft,ut:Q}),u=`${Ce}?${a.toString()}`,c=(await t.get(u,{responseType:"json"}))?.data?.klines;return!Array.isArray(c)||c.length===0?[]:c.map(sr)}var bo={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},Mo={shanghai:"001",shenzhen:"003"};function mr(t,e){let n=t.split(",");return{date:e,time:n[0]??"",shanghaiNetInflow:d(n[1]),shenzhenNetInflow:d(n[3]),totalNetInflow:d(n[5])}}async function yr(t,e="north"){let n=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:Q}),r=`${Ut}?${n.toString()}`,i=(await t.get(r,{responseType:"json"}))?.data;if(!i)return[];if(e==="south"){let l=i.n2s??[],c=i.n2sDate??"";return l.map(g=>mr(g,fr(c)))}let a=i.s2n??[],u=i.s2nDate??"";return a.map(l=>mr(l,fr(u)))}function fr(t){return t?/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t:""}async function Sr(t){return D(t,{reportName:"RPT_MUTUAL_QUOTA",columns:"TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,INDEX_CODE,INDEX_NAME,BOARD_CODE",quoteColumns:"status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE",quoteType:"0",sortColumns:"MUTUAL_TYPE",sortTypes:"1",pageSize:2e3,fetchAllPages:!1},e=>({date:M(e.TRADE_DATE),type:String(e.MUTUAL_TYPE??""),boardName:String(e.MUTUAL_TYPE_NAME??""),direction:String(e.FUNDS_DIRECTION??""),status:String(e.status??""),netBuyAmount:s(e.netBuyAmt),netInflow:s(e.dayNetAmtIn),remainAmount:s(e.dayAmtRemain),upCount:s(e.f104),flatCount:s(e.f106),downCount:s(e.f105),indexCode:String(e.INDEX_CODE??""),indexName:String(e.INDEX_NAME??""),indexChangePercent:s(e.INDEX_f3)}))}async function Tr(t,e={}){let{market:n="all",period:r="5day",date:o}=e,i=bo[r];if(!i)throw new A(`Invalid period: ${r}.`);let a=[`(INTERVAL_TYPE="${i}")`];return o&&a.push(`(TRADE_DATE='${o}')`),n!=="all"&&a.push(`(MUTUAL_TYPE="${Mo[n]}")`),D(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:a.join("")},u=>({date:M(u.TRADE_DATE),code:String(u.SECURITY_CODE??""),name:String(u.SECURITY_NAME??u.SECURITY_NAME_ABBR??""),close:s(u.CLOSE_PRICE),changePercent:s(u.CHANGE_RATE),holdShares:s(u.HOLD_SHARES),holdMarketValue:s(u.HOLD_MARKET_CAP),holdRatioFloat:s(u.HOLD_RATIO),holdRatioTotal:s(u.A_SHARES_RATIO),addShares:s(u.ADD_SHARES),addMarketValue:s(u.ADD_MARKET_CAP),addMarketValuePercent:s(u.ADD_MARKET_CAP_PROPORTION),sector:String(u.BOARD_NAME??"")}))}async function hr(t,e="north",n={}){let{startDate:r,endDate:o}=n,i=[e==="north"?'(BOARD_TYPE="1")':'(BOARD_TYPE="0")'];return r&&i.push(`(TRADE_DATE>='${r}')`),o&&i.push(`(TRADE_DATE<='${o}')`),D(t,{reportName:"RPT_MUTUAL_DEAL_HISTORY",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:i.join("")},a=>({date:M(a.TRADE_DATE),netBuyAmount:s(a.NET_DEAL_AMT),buyAmount:s(a.BUY_AMT),sellAmount:s(a.SELL_AMT),accNetBuyAmount:s(a.ACCUM_DEAL_AMT),netInflow:s(a.FUND_INFLOW),remainAmount:s(a.QUOTA_BALANCE),topStockCode:a.LEAD_STOCKS_CODE?String(a.LEAD_STOCKS_CODE):null,topStockName:a.LEAD_STOCKS_NAME?String(a.LEAD_STOCKS_NAME):null,topStockChangePercent:s(a.LS_CHANGE_RATE)}))}async function Cr(t,e,n={}){let r=e.replace(/^(sh|sz|bj)/i,""),{startDate:o,endDate:i}=n,a=[`(SECURITY_CODE="${r}")`];return o&&a.push(`(TRADE_DATE>='${o}')`),i&&a.push(`(TRADE_DATE<='${i}')`),D(t,{reportName:"RPT_MUTUAL_HOLDSTOCKNORTH_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:a.join("")},u=>({date:M(u.TRADE_DATE),holdShares:s(u.HOLD_SHARES),holdMarketValue:s(u.HOLD_MARKET_CAP),holdRatioFloat:s(u.HOLD_RATIO),holdRatioTotal:s(u.A_SHARES_RATIO),close:s(u.CLOSE_PRICE),changePercent:s(u.CHANGE_RATE)}))}var No={zt:{path:"/getTopicZTPool",sort:"fbt:asc"},yesterday:{path:"/getYesterdayZTPool",sort:"zs:desc"},strong:{path:"/getTopicQSPool",sort:"zdp:desc"},sub_new:{path:"/getTopicCXPool",sort:"ods:asc"},broken:{path:"/getTopicZBPool",sort:"fbt:asc"},dt:{path:"/getTopicDTPool",sort:"fund:asc"}},ko={rocket_launch:"8201",quick_rebound:"8202",large_buy:"8193",limit_up_seal:"4",limit_down_open:"32",big_buy_order:"64",auction_up:"8207",high_open_5d:"8209",gap_up:"8211",high_60d:"8213",surge_60d:"8215",accelerate_down:"8204",high_dive:"8203",large_sell:"8194",limit_down_seal:"8",limit_up_open:"16",big_sell_order:"128",auction_down:"8208",low_open_5d:"8210",gap_down:"8212",low_60d:"8214",drop_60d:"8216"},vo={8201:"\u706B\u7BAD\u53D1\u5C04",8202:"\u5FEB\u901F\u53CD\u5F39",8193:"\u5927\u7B14\u4E70\u5165",4:"\u5C01\u6DA8\u505C\u677F",32:"\u6253\u5F00\u8DCC\u505C\u677F",64:"\u6709\u5927\u4E70\u76D8",8207:"\u7ADE\u4EF7\u4E0A\u6DA8",8209:"\u9AD8\u5F005\u65E5\u7EBF",8211:"\u5411\u4E0A\u7F3A\u53E3",8213:"60\u65E5\u65B0\u9AD8",8215:"60\u65E5\u5927\u5E45\u4E0A\u6DA8",8204:"\u52A0\u901F\u4E0B\u8DCC",8203:"\u9AD8\u53F0\u8DF3\u6C34",8194:"\u5927\u7B14\u5356\u51FA",8:"\u5C01\u8DCC\u505C\u677F",16:"\u6253\u5F00\u6DA8\u505C\u677F",128:"\u6709\u5927\u5356\u76D8",8208:"\u7ADE\u4EF7\u4E0B\u8DCC",8210:"\u4F4E\u5F005\u65E5\u7EBF",8212:"\u5411\u4E0B\u7F3A\u53E3",8214:"60\u65E5\u65B0\u4F4E",8216:"60\u65E5\u5927\u5E45\u4E0B\u8DCC"};function yt(t){if(t==null)return"";let e=String(t).padStart(6,"0");return`${e.slice(0,2)}:${e.slice(2,4)}:${e.slice(4,6)}`}function Lo(t){if(!t||typeof t!="object")return"";let e=t;return`${e.days??""}/${e.ct??""}`}function Ko(t){let e=s(t.p),n=s(t.tp);return{code:String(t.c??t.m??""),name:String(t.n??""),price:e!==null?e/1e3:null,changePercent:s(t.zdp),limitPrice:n!==null?n/1e3:null,amount:s(t.amount??t.zb),floatMarketValue:s(t.ltsz),totalMarketValue:s(t.tshare),turnoverRate:s(t.hs),continuousBoardCount:s(t.lbc),firstBoardTime:t.fbt!==void 0&&t.fbt!==null?yt(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?yt(t.lbt):null,boardAmount:s(t.fund),sealAmount:s(t.fund),failedCount:s(t.zbc),industry:String(t.hybk??""),ztStatistics:Lo(t.zttj),amplitude:s(t.zf),speed:s(t.zs)}}function wo(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function Bo(){let t=new Date(Date.now()+288e5),e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),r=String(t.getUTCDate()).padStart(2,"0");return`${e}${n}${r}`}async function Rr(t,e="zt",n){let r=No[e];if(!r)throw new A(`Invalid ZTPool type: ${e}.`);let o=wo(n)??Bo(),i=new URLSearchParams({ut:b,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:r.sort,date:o}),a=`${Re}${r.path}?${i.toString()}`,l=(await t.get(a,{responseType:"json"}))?.data?.pool;return!Array.isArray(l)||l.length===0?[]:l.map(Ko)}async function Ar(t,e="large_buy"){let n=ko[e];if(!n)throw new A(`Invalid StockChangeType: ${e}.`);let r=new URLSearchParams({type:n,pageindex:"0",pagesize:"5000",ut:b,dpt:"wzchanges"}),o=`${Re}/getAllStockChanges?${r.toString()}`,a=(await t.get(o,{responseType:"json"}))?.data?.allstock;return!Array.isArray(a)||a.length===0?[]:a.map(u=>{let l=String(u.t??n);return{time:yt(u.tm),code:String(u.c??""),name:String(u.n??""),changeType:e,changeTypeLabel:vo[l]??"",info:String(u.i??"")}})}async function Er(t){let e=new URLSearchParams({ut:b,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),n=`${Re}/getAllBKChanges?${e.toString()}`,o=(await t.get(n,{responseType:"json"}))?.data?.allbk;return!Array.isArray(o)||o.length===0?[]:o.map(i=>{let a=i.ms??{},u=a.m===0?"\u5927\u7B14\u4E70\u5165":a.m===1?"\u5927\u7B14\u5356\u51FA":"",l={},c=i.bkdf??i.bkdfdis;if(c&&typeof c=="object")for(let[g,S]of Object.entries(c))l[g]=Number(S)||0;return{name:String(i.bkn??""),changePercent:s(i.bkz),mainNetInflow:s(i.bkj),totalChangeCount:s(i.bkc),topStockCode:String(a.c??""),topStockName:String(a.n??""),topStockDirection:u,changeTypeDistribution:l}})}var Dr={"1month":"01","3month":"02","6month":"03","1year":"04"};function ae(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}async function Ir(t,e){let n=ae(e.startDate),r=ae(e.endDate);return D(t,{reportName:"RPT_DAILYBILLBOARD_DETAILSNEW",columns:"SECURITY_CODE,SECUCODE,SECURITY_NAME_ABBR,TRADE_DATE,EXPLAIN,CLOSE_PRICE,CHANGE_RATE,BILLBOARD_NET_AMT,BILLBOARD_BUY_AMT,BILLBOARD_SELL_AMT,BILLBOARD_DEAL_AMT,ACCUM_AMOUNT,DEAL_NET_RATIO,DEAL_AMOUNT_RATIO,TURNOVERRATE,FREE_MARKET_CAP,EXPLANATION,D1_CLOSE_ADJCHRATE,D2_CLOSE_ADJCHRATE,D5_CLOSE_ADJCHRATE,D10_CLOSE_ADJCHRATE",sortColumns:"SECURITY_CODE,TRADE_DATE",sortTypes:"1,-1",pageSize:5e3,filter:`(TRADE_DATE<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:M(o.TRADE_DATE),close:s(o.CLOSE_PRICE),changePercent:s(o.CHANGE_RATE),netBuyAmount:s(o.BILLBOARD_NET_AMT),buyAmount:s(o.BILLBOARD_BUY_AMT),sellAmount:s(o.BILLBOARD_SELL_AMT),dealAmount:s(o.BILLBOARD_DEAL_AMT),totalAmount:s(o.ACCUM_AMOUNT),netBuyRatio:s(o.DEAL_NET_RATIO),dealAmountRatio:s(o.DEAL_AMOUNT_RATIO),turnoverRate:s(o.TURNOVERRATE),floatMarketValue:s(o.FREE_MARKET_CAP),reason:String(o.EXPLANATION??o.EXPLAIN??""),afterChange1d:s(o.D1_CLOSE_ADJCHRATE),afterChange2d:s(o.D2_CLOSE_ADJCHRATE),afterChange5d:s(o.D5_CLOSE_ADJCHRATE),afterChange10d:s(o.D10_CLOSE_ADJCHRATE)}))}async function Or(t,e="1month"){let n=Dr[e];if(!n)throw new A(`Invalid period: ${e}.`);return D(t,{reportName:"RPT_BILLBOARD_TRADEALL",columns:"ALL",sortColumns:"BILLBOARD_TIMES,LATEST_TDATE,SECURITY_CODE",sortTypes:"-1,-1,1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),latestDate:M(r.LATEST_TDATE),close:s(r.CLOSE_PRICE),changePercent:s(r.CHANGE_RATE),count:s(r.BILLBOARD_TIMES),totalBuyAmount:s(r.BILLBOARD_BUY_AMT),totalSellAmount:s(r.BILLBOARD_SELL_AMT),totalNetAmount:s(r.BILLBOARD_NET_AMT),totalDealAmount:s(r.BILLBOARD_DEAL_AMT),buyOrgCount:s(r.ORG_BUY_TIMES),sellOrgCount:s(r.ORG_SELL_TIMES)}))}async function _r(t,e){let n=ae(e.startDate),r=ae(e.endDate);return D(t,{reportName:"RPT_ORGANIZATION_TRADE_DETAILS",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:`(TRADE_DATE<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(o.SECURITY_CODE??""),name:String(o.SECURITY_NAME_ABBR??""),date:M(o.TRADE_DATE),close:s(o.CLOSE_PRICE),changePercent:s(o.CHANGE_RATE),buyOrgCount:s(o.BUY_TIMES),sellOrgCount:s(o.SELL_TIMES),orgBuyAmount:s(o.BUY_AMT),orgSellAmount:s(o.SELL_AMT),orgNetAmount:s(o.NET_AMT)}))}async function Pr(t,e="1month"){let n=Dr[e];if(!n)throw new A(`Invalid period: ${e}.`);return D(t,{reportName:"RPT_BILLBOARD_TRADEDETAILS",columns:"ALL",sortColumns:"TOTAL_BUYER_SALESTIMES",sortTypes:"-1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(r.OPERATEDEPT_CODE??""),name:String(r.OPERATEDEPT_NAME??""),totalBuyAmount:s(r.TOTAL_BUYAMT??r.BUY_AMT),totalSellAmount:s(r.TOTAL_SELLAMT??r.SELL_AMT),buyCount:s(r.TOTAL_BUYER_SALESTIMES??r.BUY_TIMES),sellCount:s(r.TOTAL_SELLER_SALESTIMES??r.SELL_TIMES),totalCount:s(r.TOTAL_TIMES)}))}async function Fr(t,e,n){let r=e.replace(/^(sh|sz|bj)/i,""),o=ae(n),i=`(SECURITY_CODE="${r}")(TRADE_DATE='${o}')`,[a,u]=await Promise.all([D(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSBUY",columns:"ALL",sortColumns:"BUY_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:s(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:s(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:s(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:s(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:s(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:s(l.NET_AMT),side:"buy"})),D(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSSELL",columns:"ALL",sortColumns:"SELL_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:s(l.RANK)??c+1,branchName:String(l.OPERATEDEPT_NAME??""),buyAmount:s(l.BUY_AMT_REAL??l.BUY_AMT),buyAmountRatio:s(l.BUY_RATIO_TOTAL??l.BUY_AMT_RATIO),sellAmount:s(l.SELL_AMT_REAL??l.SELL_AMT),sellAmountRatio:s(l.SELL_RATIO_TOTAL??l.SELL_AMT_RATIO),netAmount:s(l.NET_AMT),side:"sell"}))]);return[...a,...u]}function br(t){if(t)return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function Mr(t){if(!t)return"";let e=br(t.startDate),n=br(t.endDate),r=[];return e&&r.push(`(TRADE_DATE>='${e}')`),n&&r.push(`(TRADE_DATE<='${n}')`),r.join("")}async function Nr(t){return D(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:M(e.TRADE_DATE),shClose:s(e.CLOSE_PRICE??e.SH_CLOSE_PRICE),shChangePercent:s(e.CHANGE_RATE??e.SH_CHANGE_RATE),totalAmount:s(e.TURNOVER??e.TOTAL_AMOUNT),premiumAmount:s(e.PREMIUM_TURNOVER??e.PREMIUM_AMOUNT),premiumRatio:s(e.PREMIUM_RATIO),discountAmount:s(e.DISCOUNT_TURNOVER??e.DISCOUNT_AMOUNT),discountRatio:s(e.DISCOUNT_RATIO)}))}async function kr(t,e={}){let n=Mr(e);return D(t,{reportName:"RPT_BLOCK_TRADE_DETAIL",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:n||void 0},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:M(r.TRADE_DATE),close:s(r.CLOSE_PRICE),changePercent:s(r.CHANGE_RATE),dealPrice:s(r.DEAL_PRICE??r.PRICE),dealVolume:s(r.DEAL_VOLUME??r.VOLUME),dealAmount:s(r.DEAL_AMT??r.TURNOVER),premiumRate:s(r.PREMIUM_RATIO??r.PREMIUM_RATE),buyBranch:String(r.BUYER_DEPT??r.BUYER_OPERATEDEPT_NAME??""),sellBranch:String(r.SELLER_DEPT??r.SELLER_OPERATEDEPT_NAME??"")}))}async function vr(t,e={}){let n=Mr(e);return D(t,{reportName:"RPT_BLOCK_TRADE_STA",columns:"ALL",sortColumns:"TRADE_DATE,DEAL_AMT",sortTypes:"-1,-1",pageSize:5e3,filter:n||void 0},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:M(r.TRADE_DATE),changePercent:s(r.CHANGE_RATE),close:s(r.CLOSE_PRICE),dealCount:s(r.DEAL_NUM??r.DEAL_COUNT),dealTotalAmount:s(r.DEAL_AMT??r.TOTAL_AMOUNT),dealTotalVolume:s(r.DEAL_VOLUME??r.TOTAL_VOLUME),premiumAmount:s(r.PREMIUM_AMT??r.PREMIUM_AMOUNT),discountAmount:s(r.DISCOUNT_AMT??r.DISCOUNT_AMOUNT)}))}async function Lr(t){return D(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:M(e.STATISTICS_DATE??e.TRADE_DATE),finBalance:s(e.FIN_BALANCE),loanBalance:s(e.LOAN_BALANCE),finBuyAmount:s(e.FIN_BUY_AMT),loanSellAmount:s(e.LOAN_SELL_AMT),investorCount:s(e.OPERATE_INVESTOR_NUM??e.INVESTOR_NUM),liabilityInvestorCount:s(e.MARGIN_INVESTOR_NUM),totalGuarantee:s(e.TOTAL_GUARANTEE),avgGuaranteeRatio:s(e.AVG_GUARANTEE_RATIO)}))}async function Kr(t,e){let n=e?`(TRADE_DATE='${e}')`:void 0;return D(t,{reportName:"RPT_MARGIN_TRADE_DETAIL",columns:"ALL",sortColumns:"FIN_BALANCE",sortTypes:"-1",pageSize:5e3,filter:n},r=>({code:String(r.SECURITY_CODE??""),name:String(r.SECURITY_NAME_ABBR??""),date:M(r.TRADE_DATE),finBalance:s(r.FIN_BALANCE),finBuyAmount:s(r.FIN_BUY_AMT),finRepayAmount:s(r.FIN_REPAY_AMT),loanBalance:s(r.LOAN_BALANCE),loanSellVolume:s(r.LOAN_SELL_VOLUME),loanRepayVolume:s(r.LOAN_REPAY_VOLUME)}))}var x={};ze(x,{getCommodityOptionKline:()=>jr,getCommodityOptionSpot:()=>$r,getETFOption5DayMinute:()=>zr,getETFOptionDailyKline:()=>Qr,getETFOptionExpireDay:()=>xr,getETFOptionMinute:()=>qr,getETFOptionMonths:()=>Ur,getIndexOptionKline:()=>Br,getIndexOptionSpot:()=>wr});function Uo(t){return{buyVolume:s(t[0]),buyPrice:s(t[1]),price:s(t[2]),askPrice:s(t[3]),askVolume:s(t[4]),openInterest:s(t[5]),change:s(t[6]),strikePrice:s(t[7]),symbol:t[8]??""}}function xo(t){return{buyVolume:s(t[0]),buyPrice:s(t[1]),price:s(t[2]),askPrice:s(t[3]),askVolume:s(t[4]),openInterest:s(t[5]),change:s(t[6]),strikePrice:null,symbol:t[7]??""}}async function wr(t,e){let n=`${De}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,r=await U(n),o=r?.result?.data?.up??[],i=r?.result?.data?.down??[];return{calls:o.map(Uo),puts:i.map(xo)}}async function Br(t){let e=`${Ie}?symbol=${t}`,n=await U(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:s(r.o),high:s(r.h),low:s(r.l),close:s(r.c),volume:s(r.v)})):[]}async function Ur(t){let e=`${qt}?exchange=null&cate=${encodeURIComponent(t)}`,r=(await U(e))?.result?.data,o=r?.contractMonth??[];return{months:o.length>1?o.slice(1):o,stockId:r?.stockId??"",cateId:r?.cateId??"",cateList:r?.cateList??[]}}async function xr(t,e){let n=`${Ve}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,r=await U(n),o=r?.result?.data?.remainderDays;if(typeof o=="number"&&o<0){let a=`${Ve}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;r=await U(a)}let i=r?.result?.data;return{expireDay:i?.expireDay??"",remainderDays:i?.remainderDays??0,stockId:i?.stockId??"",name:i?.other?.name??""}}function Hr(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:s(n.p),volume:s(n.v),openInterest:s(n.t),avgPrice:s(n.a)}))}async function qr(t){let e=`CON_OP_${t}`,n=`${Qt}?symbol=${e}`,o=(await U(n))?.result?.data;return Array.isArray(o)?Hr(o):[]}async function Qr(t){let e=`CON_OP_${t}`,n=`${zt}?symbol=${e}`,r=await U(n,{callbackMode:"path"});return Array.isArray(r)?r.map(o=>({date:o.d,open:s(o.o),high:s(o.h),low:s(o.l),close:s(o.c),volume:s(o.v)})):[]}async function zr(t){let e=`CON_OP_${t}`,n=`${$t}?symbol=${e}`,o=(await U(n))?.result?.data;if(!Array.isArray(o))return[];let i=[];for(let a of o)Array.isArray(a)&&i.push(...Hr(a));return i}function Ho(t){return{buyVolume:s(t[0]),buyPrice:s(t[1]),price:s(t[2]),askPrice:s(t[3]),askVolume:s(t[4]),openInterest:s(t[5]),change:s(t[6]),strikePrice:s(t[7]),symbol:t[8]??""}}function qo(t){return{buyVolume:s(t[0]),buyPrice:s(t[1]),price:s(t[2]),askPrice:s(t[3]),askVolume:s(t[4]),openInterest:s(t[5]),change:s(t[6]),strikePrice:null,symbol:t[7]??""}}async function $r(t,e){let n=We[t];if(!n)throw new A(`Unknown commodity option variety: "${t}". Available: ${Object.keys(We).join(", ")}`);let r=`${De}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,o=await U(r),i=o?.result?.data?.up??[],a=o?.result?.data?.down??[];return{calls:i.map(Ho),puts:a.map(qo)}}async function jr(t){let e=`${Ie}?symbol=${t}`,n=await U(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:s(r.o),high:s(r.h),low:s(r.l),close:s(r.c),volume:s(r.v)})):[]}var _=class{constructor(e){this.client=e}};var ue=class extends _{constructor(e){super(e)}getFundDividendList(e){return p.getFundDividendList(this.client,e)}getFundNavHistory(e){return p.getFundNavHistory(this.client,e)}getFundEstimate(e){return p.getFundEstimate(this.client,e)}getFundRankHistory(e){return p.getFundRankHistory(this.client,e)}};var le=class extends _{constructor(e){super(e)}getFullQuotes(e){return F.getFullQuotes(this.client,e)}getSimpleQuotes(e){return F.getSimpleQuotes(this.client,e)}getHKQuotes(e){return F.getHKQuotes(this.client,e)}getUSQuotes(e){return F.getUSQuotes(this.client,e)}getFundQuotes(e){return F.getFundQuotes(this.client,e)}getFundFlow(e){return F.getFundFlow(this.client,e)}getPanelLargeOrder(e){return F.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return F.getTodayTimeline(this.client,e)}search(e){return F.search(this.client,e)}getAShareCodeList(e){return F.getAShareCodeList(this.client,e)}getUSCodeList(e){return F.getUSCodeList(this.client,e)}getHKCodeList(){return F.getHKCodeList(this.client)}getFundCodeList(){return F.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...r}=e,o=await this.getAShareCodeList({market:n});return F.getAllQuotesByCodes(this.client,o,r)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return F.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...r}=e,o=await this.getUSCodeList({simple:!0,market:n});return F.getAllUSQuotesByCodes(this.client,o,r)}getAllQuotesByCodes(e,n={}){return F.getAllQuotesByCodes(this.client,e,n)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return F.getTradingCalendar(this.client)}getDividendDetail(e){return p.getDividendDetail(this.client,e)}};var ce=class extends _{constructor(e){super(e)}getIndustryList(){return p.getIndustryList(this.client)}getIndustrySpot(e){return p.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return p.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return p.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return p.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return p.getConceptList(this.client)}getConceptSpot(e){return p.getConceptSpot(this.client,e)}getConceptConstituents(e){return p.getConceptConstituents(this.client,e)}getConceptKline(e,n){return p.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return p.getConceptMinuteKline(this.client,e,n)}};var de=class extends _{constructor(e){super(e)}getHistoryKline(e,n){return p.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return p.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return p.getHKHistoryKline(this.client,e,n)}getHKMinuteKline(e,n){return p.getHKMinuteKline(this.client,e,n)}getUSHistoryKline(e,n){return p.getUSHistoryKline(this.client,e,n)}getUSMinuteKline(e,n){return p.getUSMinuteKline(this.client,e,n)}};var pe=class extends _{constructor(e){super(e)}getFuturesKline(e,n){return p.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return p.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return p.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return p.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return p.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return p.getComexInventory(this.client,e,n)}};var ge=class extends _{constructor(e){super(e)}getIndexOptionSpot(e,n){return x.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return x.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return p.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return x.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return x.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return x.getETFOptionMinute(e)}getETFOptionDailyKline(e){return x.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return x.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return x.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return x.getCommodityOptionKline(e)}getOptionLHB(e,n){return p.getOptionLHB(this.client,e,n)}};var me=class{constructor(e,n){this.klineService=e;this.quoteService=n}detectMarket(e){try{let n=W(e);return n.market==="HK"?"HK":n.market==="US"?"US":"A"}catch{return"A"}}calcActualStartDate(e,n,r=1.5){let o=this.toCompactDate(e),i=Math.ceil(n*r),a=new Date(parseInt(o.slice(0,4)),parseInt(o.slice(4,6))-1,parseInt(o.slice(6,8)));a.setDate(a.getDate()-i);let u=a.getFullYear(),l=String(a.getMonth()+1).padStart(2,"0"),c=String(a.getDate()).padStart(2,"0");return`${u}${l}${c}`}calcActualStartDateByCalendar(e,n,r){if(!r||r.length===0)return;let o=this.normalizeDate(e),i=r.findIndex(u=>u>=o);i===-1&&(i=r.length-1);let a=Math.max(0,i-n);return this.toCompactDate(r[a])}normalizeDate(e){return e.includes("-")?e:e.length===8?`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`:e}toCompactDate(e){return e.replace(/-/g,"")}dateToTimestamp(e){let n=e.includes("-")?e:`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(n).getTime()}async getKlineWithIndicators(e,n={}){let{startDate:r,endDate:o,indicators:i={}}=n,a=n.market??this.detectMarket(e),{requiredBars:u}=en(i),l={A:1.5,HK:1.46,US:1.45},c;if(r)if(a==="A")try{let T=await this.quoteService.getTradingCalendar();c=this.calcActualStartDateByCalendar(r,u,T)??this.calcActualStartDate(r,u,l[a])}catch{c=this.calcActualStartDate(r,u,l[a])}else c=this.calcActualStartDate(r,u,l[a]);let g={period:n.period,adjust:n.adjust,startDate:c,endDate:n.endDate?this.toCompactDate(n.endDate):void 0},S;switch(a){case"HK":S=await this.klineService.getHKHistoryKline(e,g);break;case"US":S=await this.klineService.getUSHistoryKline(e,g);break;default:S=await this.klineService.getHistoryKline(e,g)}if(r&&S.length<u)switch(a){case"HK":S=await this.klineService.getHKHistoryKline(e,{...g,startDate:void 0});break;case"US":S=await this.klineService.getUSHistoryKline(e,{...g,startDate:void 0});break;default:S=await this.klineService.getHistoryKline(e,{...g,startDate:void 0})}let y=tn(S,i);if(r){let T=this.dateToTimestamp(r),C=o?this.dateToTimestamp(o):1/0;return y.filter(h=>{let m=this.dateToTimestamp(h.date);return m>=T&&m<=C})}return y}};var fe=class extends _{constructor(e){super(e)}getIndividualFundFlow(e,n){return p.getIndividualFundFlow(this.client,e,n)}getMarketFundFlow(){return p.getMarketFundFlow(this.client)}getFundFlowRank(e){return p.getFundFlowRank(this.client,e)}getSectorFundFlowRank(e){return p.getSectorFundFlowRank(this.client,e)}getSectorFundFlowHistory(e,n){return p.getSectorFundFlowHistory(this.client,e,n)}};var ye=class extends _{constructor(e){super(e)}getNorthboundMinute(e){return p.getNorthboundMinute(this.client,e)}getNorthboundFlowSummary(){return p.getNorthboundFlowSummary(this.client)}getNorthboundHoldingRank(e){return p.getNorthboundHoldingRank(this.client,e)}getNorthboundHistory(e,n){return p.getNorthboundHistory(this.client,e,n)}getNorthboundIndividual(e,n){return p.getNorthboundIndividual(this.client,e,n)}};var Se=class extends _{constructor(e){super(e)}getZTPool(e,n){return p.getZTPool(this.client,e,n)}getStockChanges(e){return p.getStockChanges(this.client,e)}getBoardChanges(){return p.getBoardChanges(this.client)}};var Te=class extends _{constructor(e){super(e)}getDragonTigerDetail(e){return p.getDragonTigerDetail(this.client,e)}getDragonTigerStockStats(e){return p.getDragonTigerStockStats(this.client,e)}getDragonTigerInstitution(e){return p.getDragonTigerInstitution(this.client,e)}getDragonTigerBranchRank(e){return p.getDragonTigerBranchRank(this.client,e)}getDragonTigerStockSeatDetail(e,n){return p.getDragonTigerStockSeatDetail(this.client,e,n)}};var he=class extends _{constructor(e){super(e)}getBlockTradeMarketStat(){return p.getBlockTradeMarketStat(this.client)}getBlockTradeDetail(e){return p.getBlockTradeDetail(this.client,e)}getBlockTradeDailyStat(e){return p.getBlockTradeDailyStat(this.client,e)}getMarginAccountInfo(){return p.getMarginAccountInfo(this.client)}getMarginTargetList(e){return p.getMarginTargetList(this.client,e)}};var St=class{constructor(e={}){this._ns={};this.client=new Wt(e),this.quoteService=new le(this.client),this.boardService=new ce(this.client),this.klineService=new de(this.client),this.futuresService=new pe(this.client),this.optionsService=new ge(this.client),this.indicatorService=new me(this.klineService,this.quoteService),this.fundFlowService=new fe(this.client),this.northboundService=new ye(this.client),this.marketEventService=new Se(this.client),this.dragonTigerService=new Te(this.client),this.dataService=new he(this.client),this.tradingCalendarService=new oe(this.quoteService),this.fundService=new ue(this.client)}memoNs(e,n){var r;return(r=this._ns)[e]??(r[e]=n())}get quotes(){return this.memoNs("quotes",()=>{let e=this.quoteService;return{cn:e.getFullQuotes.bind(e),cnSimple:e.getSimpleQuotes.bind(e),hk:e.getHKQuotes.bind(e),us:e.getUSQuotes.bind(e),fund:e.getFundQuotes.bind(e),fundFlow:e.getFundFlow.bind(e),largeOrder:e.getPanelLargeOrder.bind(e),timeline:e.getTodayTimeline.bind(e)}})}get codes(){return this.memoNs("codes",()=>{let e=this.quoteService;return{cn:e.getAShareCodeList.bind(e),us:e.getUSCodeList.bind(e),hk:e.getHKCodeList.bind(e),fund:e.getFundCodeList.bind(e)}})}get batch(){return this.memoNs("batch",()=>{let e=this.quoteService;return{cn:e.getAllAShareQuotes.bind(e),hk:e.getAllHKShareQuotes.bind(e),us:e.getAllUSShareQuotes.bind(e),byCodes:e.getAllQuotesByCodes.bind(e),raw:e.batchRaw.bind(e)}})}get kline(){return this.memoNs("kline",()=>{let e=this.klineService,n=this.indicatorService;return{cn:e.getHistoryKline.bind(e),cnMinute:e.getMinuteKline.bind(e),hk:e.getHKHistoryKline.bind(e),hkMinute:e.getHKMinuteKline.bind(e),us:e.getUSHistoryKline.bind(e),usMinute:e.getUSMinuteKline.bind(e),withIndicators:n.getKlineWithIndicators.bind(n)}})}get board(){return this.memoNs("board",()=>{let e=this.boardService;return{industry:{list:e.getIndustryList.bind(e),spot:e.getIndustrySpot.bind(e),constituents:e.getIndustryConstituents.bind(e),kline:e.getIndustryKline.bind(e),minuteKline:e.getIndustryMinuteKline.bind(e)},concept:{list:e.getConceptList.bind(e),spot:e.getConceptSpot.bind(e),constituents:e.getConceptConstituents.bind(e),kline:e.getConceptKline.bind(e),minuteKline:e.getConceptMinuteKline.bind(e)}}})}get options(){return this.memoNs("options",()=>{let e=this.optionsService;return{index:{spot:e.getIndexOptionSpot.bind(e),kline:e.getIndexOptionKline.bind(e)},etf:{months:e.getETFOptionMonths.bind(e),expireDay:e.getETFOptionExpireDay.bind(e),minute:e.getETFOptionMinute.bind(e),dailyKline:e.getETFOptionDailyKline.bind(e),fiveDayMinute:e.getETFOption5DayMinute.bind(e)},commodity:{spot:e.getCommodityOptionSpot.bind(e),kline:e.getCommodityOptionKline.bind(e)},cffex:{quotes:e.getCFFEXOptionQuotes.bind(e)},lhb:e.getOptionLHB.bind(e)}})}get futures(){return this.memoNs("futures",()=>{let e=this.futuresService;return{kline:e.getFuturesKline.bind(e),globalSpot:e.getGlobalFuturesSpot.bind(e),globalKline:e.getGlobalFuturesKline.bind(e),inventorySymbols:e.getFuturesInventorySymbols.bind(e),inventory:e.getFuturesInventory.bind(e),comexInventory:e.getComexInventory.bind(e)}})}get fundFlow(){return this.memoNs("fundFlow",()=>{let e=this.fundFlowService;return{individual:e.getIndividualFundFlow.bind(e),market:e.getMarketFundFlow.bind(e),rank:e.getFundFlowRank.bind(e),sectorRank:e.getSectorFundFlowRank.bind(e),sectorHistory:e.getSectorFundFlowHistory.bind(e)}})}get northbound(){return this.memoNs("northbound",()=>{let e=this.northboundService;return{minute:e.getNorthboundMinute.bind(e),summary:e.getNorthboundFlowSummary.bind(e),holdingRank:e.getNorthboundHoldingRank.bind(e),history:e.getNorthboundHistory.bind(e),individual:e.getNorthboundIndividual.bind(e)}})}get marketEvent(){return this.memoNs("marketEvent",()=>{let e=this.marketEventService;return{ztPool:e.getZTPool.bind(e),stockChanges:e.getStockChanges.bind(e),boardChanges:e.getBoardChanges.bind(e)}})}get dragonTiger(){return this.memoNs("dragonTiger",()=>{let e=this.dragonTigerService;return{detail:e.getDragonTigerDetail.bind(e),stockStats:e.getDragonTigerStockStats.bind(e),institution:e.getDragonTigerInstitution.bind(e),branchRank:e.getDragonTigerBranchRank.bind(e),seatDetail:e.getDragonTigerStockSeatDetail.bind(e)}})}get blockTrade(){return this.memoNs("blockTrade",()=>{let e=this.dataService;return{marketStat:e.getBlockTradeMarketStat.bind(e),detail:e.getBlockTradeDetail.bind(e),dailyStat:e.getBlockTradeDailyStat.bind(e)}})}get margin(){return this.memoNs("margin",()=>{let e=this.dataService;return{accountInfo:e.getMarginAccountInfo.bind(e),targetList:e.getMarginTargetList.bind(e)}})}get fund(){return this.memoNs("fund",()=>{let e=this.fundService;return{dividendList:e.getFundDividendList.bind(e),navHistory:e.getFundNavHistory.bind(e),estimate:e.getFundEstimate.bind(e),rankHistory:e.getFundRankHistory.bind(e)}})}get calendar(){return this.memoNs("calendar",()=>{let e=this.tradingCalendarService;return{isTradingDay:e.isTradingDay.bind(e),nextTradingDay:e.nextTradingDay.bind(e),prevTradingDay:e.prevTradingDay.bind(e),marketStatus:e.getMarketStatus.bind(e)}})}get reference(){return this.memoNs("reference",()=>{let e=this.quoteService;return{dividendDetail:e.getDividendDetail.bind(e),tradingCalendar:e.getTradingCalendar.bind(e)}})}getFullQuotes(e){return this.quoteService.getFullQuotes(e)}getSimpleQuotes(e){return this.quoteService.getSimpleQuotes(e)}getHKQuotes(e){return this.quoteService.getHKQuotes(e)}getUSQuotes(e){return this.quoteService.getUSQuotes(e)}getFundQuotes(e){return this.quoteService.getFundQuotes(e)}getFundFlow(e){return this.quoteService.getFundFlow(e)}getPanelLargeOrder(e){return this.quoteService.getPanelLargeOrder(e)}getTodayTimeline(e){return this.quoteService.getTodayTimeline(e)}getIndustryList(){return this.boardService.getIndustryList()}getIndustrySpot(e){return this.boardService.getIndustrySpot(e)}getIndustryConstituents(e){return this.boardService.getIndustryConstituents(e)}getIndustryKline(e,n){return this.boardService.getIndustryKline(e,n)}getIndustryMinuteKline(e,n){return this.boardService.getIndustryMinuteKline(e,n)}getConceptList(){return this.boardService.getConceptList()}getConceptSpot(e){return this.boardService.getConceptSpot(e)}getConceptConstituents(e){return this.boardService.getConceptConstituents(e)}getConceptKline(e,n){return this.boardService.getConceptKline(e,n)}getConceptMinuteKline(e,n){return this.boardService.getConceptMinuteKline(e,n)}getHistoryKline(e,n){return this.klineService.getHistoryKline(e,n)}getMinuteKline(e,n){return this.klineService.getMinuteKline(e,n)}getHKHistoryKline(e,n){return this.klineService.getHKHistoryKline(e,n)}getHKMinuteKline(e,n){return this.klineService.getHKMinuteKline(e,n)}getUSHistoryKline(e,n){return this.klineService.getUSHistoryKline(e,n)}getUSMinuteKline(e,n){return this.klineService.getUSMinuteKline(e,n)}search(e){return this.quoteService.search(e)}getAShareCodeList(e){return this.quoteService.getAShareCodeList(e)}getUSCodeList(e){return this.quoteService.getUSCodeList(e)}getHKCodeList(){return this.quoteService.getHKCodeList()}getFundCodeList(){return this.quoteService.getFundCodeList()}getAllAShareQuotes(e={}){return this.quoteService.getAllAShareQuotes(e)}getAllHKShareQuotes(e={}){return this.quoteService.getAllHKShareQuotes(e)}getAllUSShareQuotes(e={}){return this.quoteService.getAllUSShareQuotes(e)}getAllQuotesByCodes(e,n={}){return this.quoteService.getAllQuotesByCodes(e,n)}batchRaw(e){return this.quoteService.batchRaw(e)}getTradingCalendar(){return this.quoteService.getTradingCalendar()}isTradingDay(e){return this.tradingCalendarService.isTradingDay(e)}nextTradingDay(e){return this.tradingCalendarService.nextTradingDay(e)}prevTradingDay(e){return this.tradingCalendarService.prevTradingDay(e)}getMarketStatus(e="A"){return this.tradingCalendarService.getMarketStatus(e)}getDividendDetail(e){return this.quoteService.getDividendDetail(e)}getFuturesKline(e,n){return this.futuresService.getFuturesKline(e,n)}getGlobalFuturesSpot(e){return this.futuresService.getGlobalFuturesSpot(e)}getGlobalFuturesKline(e,n){return this.futuresService.getGlobalFuturesKline(e,n)}getFuturesInventorySymbols(){return this.futuresService.getFuturesInventorySymbols()}getFuturesInventory(e,n){return this.futuresService.getFuturesInventory(e,n)}getComexInventory(e,n){return this.futuresService.getComexInventory(e,n)}getIndexOptionSpot(e,n){return this.optionsService.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return this.optionsService.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return this.optionsService.getCFFEXOptionQuotes(e)}getETFOptionMonths(e){return this.optionsService.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return this.optionsService.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return this.optionsService.getETFOptionMinute(e)}getETFOptionDailyKline(e){return this.optionsService.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return this.optionsService.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return this.optionsService.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return this.optionsService.getCommodityOptionKline(e)}getOptionLHB(e,n){return this.optionsService.getOptionLHB(e,n)}getKlineWithIndicators(e,n={}){return this.indicatorService.getKlineWithIndicators(e,n)}getIndividualFundFlow(e,n){return this.fundFlowService.getIndividualFundFlow(e,n)}getMarketFundFlow(){return this.fundFlowService.getMarketFundFlow()}getFundFlowRank(e){return this.fundFlowService.getFundFlowRank(e)}getSectorFundFlowRank(e){return this.fundFlowService.getSectorFundFlowRank(e)}getSectorFundFlowHistory(e,n){return this.fundFlowService.getSectorFundFlowHistory(e,n)}getNorthboundMinute(e){return this.northboundService.getNorthboundMinute(e)}getNorthboundFlowSummary(){return this.northboundService.getNorthboundFlowSummary()}getNorthboundHoldingRank(e){return this.northboundService.getNorthboundHoldingRank(e)}getNorthboundHistory(e,n){return this.northboundService.getNorthboundHistory(e,n)}getNorthboundIndividual(e,n){return this.northboundService.getNorthboundIndividual(e,n)}getZTPool(e,n){return this.marketEventService.getZTPool(e,n)}getStockChanges(e){return this.marketEventService.getStockChanges(e)}getBoardChanges(){return this.marketEventService.getBoardChanges()}getDragonTigerDetail(e){return this.dragonTigerService.getDragonTigerDetail(e)}getDragonTigerStockStats(e){return this.dragonTigerService.getDragonTigerStockStats(e)}getDragonTigerInstitution(e){return this.dragonTigerService.getDragonTigerInstitution(e)}getDragonTigerBranchRank(e){return this.dragonTigerService.getDragonTigerBranchRank(e)}getDragonTigerStockSeatDetail(e,n){return this.dragonTigerService.getDragonTigerStockSeatDetail(e,n)}getBlockTradeMarketStat(){return this.dataService.getBlockTradeMarketStat()}getBlockTradeDetail(e){return this.dataService.getBlockTradeDetail(e)}getBlockTradeDailyStat(e){return this.dataService.getBlockTradeDailyStat(e)}getMarginAccountInfo(){return this.dataService.getMarginAccountInfo()}getMarginTargetList(e){return this.dataService.getMarginTargetList(e)}getFundDividendList(e){return this.fundService.getFundDividendList(e)}getFundNavHistory(e){return this.fundService.getFundNavHistory(e)}getFundEstimate(e){return this.fundService.getFundEstimate(e)}getFundRankHistory(e){return this.fundService.getFundRankHistory(e)}},Ku=St;export{oe as a,ue as b,St as c,Ku as d};
|
package/dist/chunk-4RR2H3DC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as i,f as E}from"./chunk-UBIQBXQ7.js";function d(e){if(e.startsWith("92")||/^[48]/.test(e))return"BSE";let a=e[0];return a==="6"||a==="5"||a==="9"?"SSE":"SZSE"}var x={SHFE:{market:"CN",exchange:"SHFE"},DCE:{market:"CN",exchange:"DCE"},CZCE:{market:"CN",exchange:"CZCE"},INE:{market:"CN",exchange:"INE"},CFFEX:{market:"CN",exchange:"CFFEX"},GFEX:{market:"CN",exchange:"GFEX"},COMEX:{market:"GLOBAL",exchange:"COMEX"},NYMEX:{market:"GLOBAL",exchange:"NYMEX"},CBOT:{market:"GLOBAL",exchange:"CBOT"},LME:{market:"GLOBAL",exchange:"LME"}};function f(e){let a=e.match(/^([A-Za-z]+)/);return(a?a[1]:e).toUpperCase()}var U={sh:{market:"CN",exchange:"SSE"},sz:{market:"CN",exchange:"SZSE"},bj:{market:"CN",exchange:"BSE"},hk:{market:"HK",exchange:"HKEX"},us:{market:"US",exchange:"US"}},C=["sh","sz","bj","hk","us"],N={SH:{market:"CN",exchange:"SSE"},SZ:{market:"CN",exchange:"SZSE"},BJ:{market:"CN",exchange:"BSE"},HK:{market:"HK",exchange:"HKEX"},US:{market:"US",exchange:"US"}},A={0:{market:"CN",exchange:"SZSE"},1:{market:"CN",exchange:"SSE"},116:{market:"HK",exchange:"HKEX"},105:{market:"US",exchange:"NASDAQ"},106:{market:"US",exchange:"NYSE"},107:{market:"US",exchange:"AMEX"}};function X(e,a){let S=typeof e=="string"?{code:e}:{...e},p=typeof e=="string"?e:e.code,t=String(S.code??"").trim(),h=S.market??a?.market,y=S.assetType??a?.assetType,u=S.exchange??a?.exchange;if(!t)throw new E(String(p));let c=(o,r,n,g,m)=>({market:o,exchange:u??r,assetType:y??g,code:n,variety:m,input:p});if(t.includes(".")){let o=t.indexOf("."),r=t.slice(0,o),n=t.slice(o+1),g=r.toUpperCase(),m=n.toUpperCase();if(/^\d+$/.test(r)&&A[r]){let s=A[r];return c(s.market,s.exchange,n,"stock")}if(N[m]){let s=N[m],l=r,b=r.toLowerCase();for(let k of C)if(b.startsWith(k)&&r.length>k.length){l=r.slice(k.length);break}return c(s.market,s.exchange,l,"stock")}if(x[g]){let s=x[g];return c(s.market,s.exchange,m,"futures",f(n))}if(r==="90")return c("CN","SSE",n,"board")}let T=t.toLowerCase();for(let o of C)if(T.startsWith(o)&&t.length>o.length){let r=t.slice(o.length),n=U[o];if(n.market==="CN"?/^\d+$/.test(r):/^[0-9A-Za-z]+$/.test(r)){let m=n.market==="HK"?r.padStart(5,"0"):n.market==="US"?r.toUpperCase():r;return c(n.market,n.exchange,m,"stock")}}if(/^\d+$/.test(t))return h==="US"?c("US","US",t,"stock"):h==="HK"||t.length===5||t.length===4?c("HK","HKEX",t.padStart(5,"0"),"stock"):c("CN",d(t),t,"stock");if((y==="futures"||h==="GLOBAL")&&/[A-Za-z]/.test(t)){let o=u;if(!o&&h==="GLOBAL")throw new E(`${p} (GLOBAL futures require an explicit exchange, e.g. { exchange: 'COMEX' })`);return c(h??"CN",o??"SHFE",t.toUpperCase(),"futures",f(t))}if(/^[A-Za-z][A-Za-z.\-]*$/.test(t))return c("US","US",t.toUpperCase(),"stock");throw new E(String(p))}var H={SSE:"1",SZSE:"0",BSE:"0",HKEX:"116",NASDAQ:"105",NYSE:"106",AMEX:"107",US:"105"},w={SSE:"sh",SZSE:"sz",BSE:"bj"};function L(e){if(e.assetType==="board"||e.assetType==="futures"||e.assetType==="option")throw new i(`Tencent quote symbol does not support assetType '${e.assetType}'`,{assetType:e.assetType,code:e.code});switch(e.market){case"CN":{let a=w[e.exchange];if(!a)throw new i(`Cannot map to Tencent symbol: unsupported CN exchange '${e.exchange}'`,{exchange:e.exchange,code:e.code});return`${a}${e.code}`}case"HK":return`hk${e.code.padStart(5,"0")}`;case"US":return`us${e.code}`;default:throw new i(`Cannot map to Tencent symbol: unsupported market '${e.market}'`,{market:e.market,code:e.code})}}function M(e){if(e.assetType==="board")return`90.${e.code}`;if(e.assetType==="futures"||e.assetType==="option")throw new i(`Eastmoney secid for assetType '${e.assetType}' uses a separate scheme; use the dedicated futures/options provider instead of toEastmoneySecid`,{assetType:e.assetType,exchange:e.exchange,code:e.code});if(e.market==="HK")return`116.${e.code.padStart(5,"0")}`;let a=H[e.exchange];if(!a)throw new i(`Cannot map to Eastmoney secid: unsupported exchange '${e.exchange}' (market=${e.market})`,{exchange:e.exchange,market:e.market,code:e.code});return`${a}.${e.code}`}function $(e){return e.code}export{d as a,x as b,f as c,X as d,L as e,M as f,$ as g};
|
package/dist/chunk-66NWE54C.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');function A(t){return new TextDecoder("gbk").decode(t)}function k(t){let e=t.split(";").map(n=>n.trim()).filter(Boolean),r=[];for(let n of e){let o=n.indexOf("=");if(o<0)continue;let s=n.slice(0,o).trim();s.startsWith("v_")&&(s=s.slice(2));let a=n.slice(o+1).trim();a.startsWith('"')&&a.endsWith('"')&&(a=a.slice(1,-1));let i=a.split("~");r.push({key:s,fields:i})}return r}function se(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function ie(t){if(!t||t==="")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function W(t){if(!t||t===""||t==="-")return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function ae(t){return t==null?null:W(String(t))}var ce=new Set(["daily","weekly","monthly"]),ue=new Set(["1","5","15","30","60"]),le=new Set(["","qfq","hfq"]);function P(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`${e} must be a positive integer`,{argument:e,value:t})}function pe(t){if(!ce.has(t))throw new (0, _chunk4Q7UQ5Q3cjs.e)("period must be one of: daily, weekly, monthly",{argument:"period",value:t})}function de(t){if(!ue.has(t))throw new (0, _chunk4Q7UQ5Q3cjs.e)("period must be one of: 1, 5, 15, 30, 60",{argument:"period",value:t})}function me(t){if(!le.has(t))throw new (0, _chunk4Q7UQ5Q3cjs.e)("adjust must be one of: '', 'qfq', 'hfq'",{argument:"adjust",value:t})}function he(t,e){P(e,"chunkSize");let r=[];for(let n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}async function fe(t,e,r=!1){if(P(e,"concurrency"),t.length===0)return[];let n=r?new Array(t.length):[],o=0,s=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let a=o++;if(a>=t.length)return;let i=await t[a]();r?n[a]=i:n.push(i)}});return await Promise.all(s),n}function Ee(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function Te(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var _e=typeof document<"u"&&typeof window<"u",ge=0;function X(){return`__stock_sdk_jsonp_${Date.now()}_${ge++}`}function $(t){let e=t,r=e.indexOf("*/");r!==-1&&(e=e.slice(r+2).trim());let n=e.indexOf("(");if(n===-1)throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:"Invalid JSONP response: no opening parenthesis found"});let o=e.lastIndexOf(")");if(o===-1||o<=n)throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:"Invalid JSONP response: no closing parenthesis found"});let s=e.slice(n+1,o);try{return JSON.parse(s)}catch(a){throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:"Invalid JSONP response: payload is not valid JSON",cause:a})}}function Re(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e;return new Promise((s,a)=>{let i=X(),u;if(o==="path")u=t.replace("{callback}",i);else{let R=t.includes("?")?"&":"?";u=`${t}${R}${n}=${i}`}let c=document.createElement("script"),l=!1,m=window,d=()=>{c.parentNode&&c.parentNode.removeChild(c),delete m[i]},E=setTimeout(()=>{l||(l=!0,d(),a(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`JSONP request timed out after ${r}ms: ${t}`,url:t,details:{timeout:r}})))},r);m[i]=R=>{l||(l=!0,clearTimeout(E),d(),s(R))},c.onerror=()=>{l||(l=!0,clearTimeout(E),d(),a(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`JSONP script load failed: ${t}`,url:t})))},c.src=u,document.head.appendChild(c)})}async function ye(t,e){let{timeout:r=15e3,callbackParam:n="callback",callbackMode:o="query"}=e,s=X(),a;if(o==="path")a=t.replace("{callback}",s);else{let c=t.includes("?")?"&":"?";a=`${t}${c}${n}=${s}`}let i=new AbortController,u=setTimeout(()=>i.abort(),r);try{let c=await fetch(a,{signal:i.signal});if(!c.ok)throw new (0, _chunk4Q7UQ5Q3cjs.b)(c.status,c.statusText,t);let l=await c.text();return $(l)}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`JSONP request timed out after ${r}ms: ${t}`,url:t,details:{timeout:r}}):c}finally{clearTimeout(u)}}function Se(t,e={}){return _e?Re(t,e):ye(t,e)}var z=new Map;async function b(t,e){let n=(_nullishCoalesce(z.get(t), () => (Promise.resolve()))).then(e,e);return z.set(t,n.then(()=>{},()=>{})),n}function Oe(){return typeof document<"u"&&typeof window<"u"}var Ce=15e3,xe= exports.ma ="jsVars";async function Le(t,e,r={}){let n=_nullishCoalesce(r.timeout, () => (Ce));return Oe()?b(xe,()=>Ae(t,e,n)):ke(t,e,n,r.headers,r.client)}function N(t,e){let r={};for(let n of e){let o=Pe(t,n);o!==void 0&&(r[n]=o)}return r}function Ae(t,e,r){return new Promise((n,o)=>{let s=document.createElement("script"),a=!1,i=()=>{s.parentNode&&s.parentNode.removeChild(s)},u=setTimeout(()=>{a||(a=!0,i(),o(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`fetchJsVars timed out after ${r}ms: ${t}`,url:t,details:{timeout:r}})))},r);s.onload=()=>{if(a)return;a=!0,clearTimeout(u);let c=window,l={};for(let m of e)if(m in c){l[m]=c[m];try{delete c[m]}catch (e2){}}i(),n(l)},s.onerror=()=>{a||(a=!0,clearTimeout(u),i(),o(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`fetchJsVars script load failed: ${t}`,url:t})))},s.src=t,document.head.appendChild(s)})}async function ke(t,e,r,n,o){if(o){let i=await o.get(t,{responseType:"text"});return N(i,e)}let s=new AbortController,a=setTimeout(()=>s.abort(),r);try{let i=await fetch(t,{signal:s.signal,headers:n});if(!i.ok)throw new (0, _chunk4Q7UQ5Q3cjs.b)(i.status,i.statusText,t);let u=await i.text();return N(u,e)}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`fetchJsVars timed out after ${r}ms: ${t}`,url:t,details:{timeout:r}}):i}finally{clearTimeout(a)}}function Pe(t,e){let n=new RegExp(`(?:^|[^\\w$])(?:var|let|const)\\s+${be(e)}\\s*=\\s*`,"m").exec(t);if(!n)return;let o=n.index+n[0].length,s=Ne(t,o),a=t.slice(o,s).trim();try{return JSON.parse(a)}catch (e3){return}}function be(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(t,e){let r=0,n=null;for(let o=e;o<t.length;o++){let s=t[o];if(n){if(s==="\\"){o++;continue}s===n&&(n=null);continue}if(s==='"'||s==="'"){n=s;continue}if(s==="["||s==="{"||s==="("){r++;continue}if(s==="]"||s==="}"||s===")"){r--;continue}if(s===";"&&r===0)return o}return t.length}var Ue={CN:"Asia/Shanghai",HK:"Asia/Hong_Kong",US:"America/New_York"};function Me(t){if(!t)return null;let e=t.trim();if(!e)return null;let r=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/.exec(e);if(r)return{year:+r[1],month:+r[2],day:+r[3],hour:+r[4],minute:+r[5],second:r[6]?+r[6]:0};let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return n?{year:+n[1],month:+n[2],day:+n[3],hour:0,minute:0,second:0}:/^\d{14}$/.test(e)?{year:+e.slice(0,4),month:+e.slice(4,6),day:+e.slice(6,8),hour:+e.slice(8,10),minute:+e.slice(10,12),second:+e.slice(12,14)}:/^\d{8}$/.test(e)?{year:+e.slice(0,4),month:+e.slice(4,6),day:+e.slice(6,8),hour:0,minute:0,second:0}:null}var Z=new Map;function J(t,e,r){let n=`${t}|${e}|${JSON.stringify(r)}`,o=Z.get(n);return o||(o=new Intl.DateTimeFormat(t,{timeZone:e,...r}),Z.set(n,o)),o}function j(t,e){let r=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second),o=J("en-US",e,{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(r)),s={};for(let c of o)c.type!=="literal"&&(s[c.type]=c.value);let a=parseInt(_nullishCoalesce(s.hour, () => ("0")),10);a===24&&(a=0);let i=Date.UTC(parseInt(_nullishCoalesce(s.year, () => ("0")),10),parseInt(_nullishCoalesce(s.month, () => ("1")),10)-1,parseInt(_nullishCoalesce(s.day, () => ("1")),10),a,parseInt(_nullishCoalesce(s.minute, () => ("0")),10),parseInt(_nullishCoalesce(s.second, () => ("0")),10)),u=r-i;return r+u}function Ie(t,e){let r=(t||"").trim(),n=_nullishCoalesce(/^(\d{4})-(\d{2})-(\d{2})$/.exec(r), () => (/^(\d{4})(\d{2})(\d{2})$/.exec(r)));if(!n)return null;let o=/^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec((e||"").trim());return o?{year:+n[1],month:+n[2],day:+n[3],hour:+o[1],minute:+o[2],second:o[3]?+o[3]:0}:null}function Y(t,e){let r=Me(t);return r?j(r,e):NaN}function V(t){return Number.isNaN(t)?null:t}function we(t,e){return{timestamp:V(Y(t,e)),tz:e}}function ve(t,e,r){let n=Ie(t,e);return n?{timestamp:V(j(n,r)),tz:r}:{timestamp:null,tz:r}}function Fe(t,e){if(t==null||!Number.isFinite(t))return"";let r=J("sv-SE",e,{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t)),n=r.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/);if(!n)return r;let o=n[2]==="24"?"00":n[2];return`${n[1]} ${o}:${n[3]}`}var U="https://qt.gtimg.cn",De= exports.g ="https://web.ifzq.gtimg.cn/appstock/app/minute/query",He= exports.h ="https://assets.linkdiary.cn/shares/zh_a_list.json",qe= exports.i ="https://assets.linkdiary.cn/shares/us_list.json",Be= exports.j ="https://assets.linkdiary.cn/shares/hk_list.json",Ke= exports.k ="https://assets.linkdiary.cn/shares/fund_list",jt= exports.l ="https://assets.linkdiary.cn/shares/trade-data-list.txt";var Ge="https://push2his.eastmoney.com/api/qt/stock/kline/get",We= exports.n ="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Xe= exports.o ="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",$e= exports.p ="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",ze= exports.q ="https://33.push2his.eastmoney.com/api/qt/stock/trends2/get",Ze= exports.r ="https://63.push2his.eastmoney.com/api/qt/stock/trends2/get",Je= exports.s ="https://17.push2.eastmoney.com/api/qt/clist/get",je= exports.t ="https://91.push2.eastmoney.com/api/qt/stock/get",Ye= exports.u ="https://29.push2.eastmoney.com/api/qt/clist/get",Ve= exports.v ="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Qe= exports.w ="https://push2his.eastmoney.com/api/qt/stock/trends2/get",et= exports.x ="https://79.push2.eastmoney.com/api/qt/clist/get",tt= exports.y ="https://91.push2.eastmoney.com/api/qt/stock/get",rt= exports.z ="https://29.push2.eastmoney.com/api/qt/clist/get",nt= exports.A ="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",ot= exports.B ="https://push2his.eastmoney.com/api/qt/stock/trends2/get",st= exports.C ="https://datacenter-web.eastmoney.com/api/data/v1/get",it= exports.D ="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",at= exports.E ="https://push2.eastmoney.com/api/qt/clist/get",ct= exports.F ="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",ut= exports.G ="https://push2ex.eastmoney.com",lt= exports.H ="7eea3edcaed734bea9cbfc24409ed989",pt= exports.I ="b2884a393a59ad64002292a3e90d46a5",dt= exports.J ="https://push2his.eastmoney.com/api/qt/stock/kline/get",mt= exports.K ="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",ht= exports.L ="58b2fa8f54638b60b87d69b31969089c",ft= exports.M ={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},Et= exports.N ={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},Tt= exports.O ={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},_t= exports.P ="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",gt= exports.Q ="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",Rt= exports.R ="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",yt= exports.S ="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",St= exports.T ="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",Ot= exports.U ="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",Ct= exports.V ="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",xt= exports.W ="https://futsseapi.eastmoney.com/list/option/221",Lt= exports.X ="https://datacenter-web.eastmoney.com/api/data/get";var At={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"}},M=3e4,kt= exports.Z =500,Pt= exports._ =500,bt= exports.$ =7,I=3,w=1e3,v=3e4,F=2,D=[408,429,500,502,503,504];var O=class{constructor(e={}){this.acquireChain=Promise.resolve();let r=_nullishCoalesce(e.requestsPerSecond, () => (5));this.maxTokens=_nullishCoalesce(e.maxBurst, () => (r)),this.tokens=this.maxTokens,this.refillRate=r/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),n=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+n),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.acquireChain,r;this.acquireChain=new Promise(n=>{r=n});try{await e;let n=this.getWaitTime();n>0&&await this.sleep(n),this.refill(),this.tokens-=1}finally{r()}}sleep(e){return new Promise(r=>setTimeout(r,e))}getAvailableTokens(){return this.refill(),this.tokens}};var Q=["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"],H=0;function Nt(){return typeof window<"u"&&typeof window.document<"u"}function ee(){if(Nt())return;let t=Q[H];return H=(H+1)%Q.length,t}var g=class extends _chunk4Q7UQ5Q3cjs.a{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},C=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.failureThreshold=_nullishCoalesce(e.failureThreshold, () => (5)),this.resetTimeout=_nullishCoalesce(e.resetTimeout, () => (3e4)),this.halfOpenRequests=_nullishCoalesce(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 r=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0),_optionalChain([this, 'access', _2 => _2.onStateChange, 'optionalCall', _3 => _3(r,e)])}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new g;try{let r=await e();return this.recordSuccess(),r}catch(r){throw this.recordFailure(),r}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var Ut=3e4,Mt=1,te=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],re=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function It(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?te:t.includes("push2.eastmoney.com")?re:[t]}function wt(t){return Array.from(new Set(t))}var x=class{constructor(e=Ut,r=Mt){this.cooldownMs=e;this.failureThreshold=r;this.states=new Map}getCandidateUrls(e,r){let n;try{n=new URL(e)}catch (e4){return[e]}let o=Date.now(),s=It(n.hostname,r);if(s.length<=1)return[e];let a=s.filter(c=>{let l=this.states.get(c);return!l||l.cooldownUntil<=o}),i=s.filter(c=>{let l=this.states.get(c);return l&&l.cooldownUntil>o});return wt([...a.includes(n.hostname)?[n.hostname]:[],...a.filter(c=>c!==n.hostname),...i.includes(n.hostname)?[n.hostname]:[],...i.filter(c=>c!==n.hostname)]).map(c=>{let l=new URL(e);return l.hostname=c,l.toString()})}recordSuccess(e){let r=this.safeGetHost(e);if(!r)return;let n=this.getState(r);n.failureCount=0,n.cooldownUntil=0,n.successCount++,n.lastErrorCode=void 0}recordFailure(e,r){let n=this.safeGetHost(e);if(!n)return;let o=this.getState(n);o.failureCount++,o.lastFailureAt=Date.now(),o.lastErrorCode=_chunk4Q7UQ5Q3cjs.k.call(void 0, r),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let r=_chunk4Q7UQ5Q3cjs.k.call(void 0, e);return r==="NETWORK_ERROR"||r==="TIMEOUT"||r==="PARSE_ERROR"?!0:e instanceof _chunk4Q7UQ5Q3cjs.b?e.status===408||e.status===429||e.status>=500:!1}getStats(e){let r=Array.from(this.states.values()).map(o=>({...o}));if(!e)return r;if(e!=="eastmoney")return[];let n=new Set([...te,...re]);return r.filter(o=>n.has(o.host))}safeGetHost(e){try{return new URL(e).hostname}catch (e5){return null}}getState(e){let r=this.states.get(e);if(r)return r;let n={host:e,failureCount:0,successCount:0,cooldownUntil:0,lastFailureAt:0};return this.states.set(e,n),n}};function vt(t){return{maxRetries:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _4 => _4.maxRetries]), () => (I)),baseDelay:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _5 => _5.baseDelay]), () => (w)),maxDelay:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _6 => _6.maxDelay]), () => (v)),backoffMultiplier:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _7 => _7.backoffMultiplier]), () => (F)),retryableStatusCodes:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _8 => _8.retryableStatusCodes]), () => (D)),retryOnNetworkError:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _9 => _9.retryOnNetworkError]), () => (!0)),retryOnTimeout:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _10 => _10.retryOnTimeout]), () => (!0)),onRetry:_optionalChain([t, 'optionalAccess', _11 => _11.onRetry])}}function Ft(t,e){let r={..._nullishCoalesce(t, () => ({}))};return e&&(Object.keys(r).some(o=>o.toLowerCase()==="user-agent")||(r["User-Agent"]=e)),r}function ne(t,e){return e?{timeout:_nullishCoalesce(e.timeout, () => (t.timeout)),retry:e.retry?{..._nullishCoalesce(t.retry, () => ({})),...e.retry}:t.retry?{...t.retry}:void 0,headers:{..._nullishCoalesce(t.headers, () => ({})),..._nullishCoalesce(e.headers, () => ({}))},userAgent:_nullishCoalesce(e.userAgent, () => (t.userAgent)),rateLimit:e.rateLimit?{..._nullishCoalesce(t.rateLimit, () => ({})),...e.rateLimit}:t.rateLimit?{...t.rateLimit}:void 0,rotateUserAgent:_nullishCoalesce(e.rotateUserAgent, () => (t.rotateUserAgent)),circuitBreaker:e.circuitBreaker?{..._nullishCoalesce(t.circuitBreaker, () => ({})),...e.circuitBreaker}:t.circuitBreaker?{...t.circuitBreaker}:void 0}:{...t,headers:{..._nullishCoalesce(t.headers, () => ({}))},retry:t.retry?{...t.retry}:void 0,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function q(t={}){return{timeout:_nullishCoalesce(t.timeout, () => (M)),retry:vt(t.retry),headers:Ft(t.headers,t.userAgent),rotateUserAgent:_nullishCoalesce(t.rotateUserAgent, () => (!1)),rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function oe(t,e){if(e)return e;try{let r=new URL(t).hostname;if(r.includes("eastmoney.com"))return"eastmoney";if(r.includes("gtimg.cn"))return"tencent";if(r.includes("sina.com.cn"))return"sina";if(r.includes("linkdiary.cn"))return"linkdiary"}catch (e6){return"unknown"}return"unknown"}var B=Symbol("stock-sdk:timeout");function Dt(t){if(t instanceof DOMException&&t.name==="AbortError")return!0;if(t instanceof Error){if(t.name==="AbortError")return!0;let e=t.cause;if((e instanceof Error||e instanceof DOMException)&&e.name==="AbortError")return!0}return!1}var K=()=>{};function Ht(t){let e=t.filter(i=>!!i);if(e.length===0)return{signal:void 0,cleanup:K};if(e.length===1)return{signal:e[0],cleanup:K};let r=AbortSignal.any;if(typeof r=="function")return{signal:r(e),cleanup:K};let n=new AbortController,o=i=>{n.signal.aborted||n.abort(i)},s=[];for(let i of e){if(i.aborted){o(i.reason);break}let u=()=>o(i.reason);i.addEventListener("abort",u,{once:!0}),s.push({s:i,handler:u})}let a=()=>{for(let{s:i,handler:u}of s)i.removeEventListener("abort",u)};return{signal:n.signal,cleanup:a}}var G=class{constructor(e={}){this.baseUrl=_nullishCoalesce(e.baseUrl, () => (U));let r={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=q(r),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new x,this.fetchImpl=e.fetchImpl,this.clientSignal=e.signal,this.hooks=e.hooks;for(let[n,o]of Object.entries(_nullishCoalesce(e.providerPolicies, () => ({})))){let s=ne(r,o);this.providerPolicies[n]=q(s)}}getProviderState(e){let r=this.runtimeStates.get(e);if(r)return r;let n=_nullishCoalesce(this.providerPolicies[e], () => (this.defaultPolicy)),o={policy:n,rateLimiter:n.rateLimit?new O(n.rateLimit):null,circuitBreaker:n.circuitBreaker?new C(n.circuitBreaker):null};return this.runtimeStates.set(e,o),o}getTimeout(){return this.defaultPolicy.timeout}getHostHealth(e){return this.fallbackManager.getStats(e)}safe(e){try{e()}catch (e7){}}toSdkError(e){return e instanceof _chunk4Q7UQ5Q3cjs.a?e:new (0, _chunk4Q7UQ5Q3cjs.a)({code:_nullishCoalesce(_chunk4Q7UQ5Q3cjs.k.call(void 0, e), () => ("NETWORK_ERROR")),message:e.message,provider:e.provider,url:e.url,status:e.status,details:e.details,cause:e})}calculateDelay(e,r){return Math.min(r.baseDelay*Math.pow(r.backoffMultiplier,e),r.maxDelay)+Math.random()*100}sleep(e){return new Promise(r=>setTimeout(r,e))}shouldRetry(e,r,n){if(r>=n.maxRetries)return!1;let o=_chunk4Q7UQ5Q3cjs.k.call(void 0, e);return o==="ABORTED"?!1:o==="TIMEOUT"?n.retryOnTimeout:o==="NETWORK_ERROR"?n.retryOnNetworkError:e instanceof _chunk4Q7UQ5Q3cjs.b?n.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,r,n,o=0){try{return await e(o)}catch(s){let a=_chunk4Q7UQ5Q3cjs.l.call(void 0, s,n),i={provider:n.provider,url:n.url,timeout:n.timeout,attempt:o,responseType:n.responseType};if(this.safe(()=>_optionalChain([this, 'access', _12 => _12.hooks, 'optionalAccess', _13 => _13.onError, 'optionalCall', _14 => _14(i,this.toSdkError(a))])),this.safe(()=>_optionalChain([this, 'access', _15 => _15.hooks, 'optionalAccess', _16 => _16.trace, 'optionalCall', _17 => _17("error",i)])),this.shouldRetry(a,o,r)){let u=this.calculateDelay(o,r);return r.onRetry&&r.onRetry(o+1,a,u),this.safe(()=>_optionalChain([this, 'access', _18 => _18.hooks, 'optionalAccess', _19 => _19.onRetry, 'optionalCall', _20 => _20(i,this.toSdkError(a),u)])),this.safe(()=>_optionalChain([this, 'access', _21 => _21.hooks, 'optionalAccess', _22 => _22.trace, 'optionalCall', _23 => _23("retry",i)])),await this.sleep(u),this.executeWithRetry(e,r,n,o+1)}throw a}}async performRequest(e,r,n,o="text",s={},a=0){r.rateLimiter&&await r.rateLimiter.acquire();let i=new AbortController,u=setTimeout(()=>i.abort(B),r.policy.timeout),{signal:c,cleanup:l}=Ht([i.signal,s.signal,this.clientSignal]),m=_nullishCoalesce(_nullishCoalesce(s.fetchImpl, () => (this.fetchImpl)), () => (globalThis.fetch)),d={...r.policy.headers};if(r.policy.rotateUserAgent){let h=ee();if(h){for(let y of Object.keys(d))y.toLowerCase()==="user-agent"&&delete d[y];d["User-Agent"]=h}}let E={provider:n,url:e,timeout:r.policy.timeout,attempt:a,responseType:o};this.safe(()=>_optionalChain([this, 'access', _24 => _24.hooks, 'optionalAccess', _25 => _25.onRequest, 'optionalCall', _26 => _26(E)])),this.safe(()=>_optionalChain([this, 'access', _27 => _27.hooks, 'optionalAccess', _28 => _28.trace, 'optionalCall', _29 => _29("request",E)]));let R=Date.now();try{let h=await m(e,{signal:c,headers:d});if(this.safe(()=>_optionalChain([this, 'access', _30 => _30.hooks, 'optionalAccess', _31 => _31.onResponse, 'optionalCall', _32 => _32(E,{status:h.status,durationMs:Date.now()-R})])),this.safe(()=>_optionalChain([this, 'access', _33 => _33.hooks, 'optionalAccess', _34 => _34.trace, 'optionalCall', _35 => _35("response",E)])),!h.ok)throw new (0, _chunk4Q7UQ5Q3cjs.b)(h.status,h.statusText,e,n);switch(o){case"json":try{return await h.json()}catch(y){throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:`Failed to parse JSON response from ${e}`,provider:n,url:e,cause:y})}case"arraybuffer":return await h.arrayBuffer();default:return await h.text()}}catch(h){throw(_optionalChain([s, 'access', _36 => _36.signal, 'optionalAccess', _37 => _37.aborted])&&s.signal.reason!==B||_optionalChain([this, 'access', _38 => _38.clientSignal, 'optionalAccess', _39 => _39.aborted])&&this.clientSignal.reason!==B)&&Dt(h)?new (0, _chunk4Q7UQ5Q3cjs.h)("Request aborted by external signal",n,e):h}finally{clearTimeout(u),l()}}async get(e,r={}){let n=oe(e,r.provider),o=this.getProviderState(n);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new g("Circuit breaker is OPEN, request rejected");let s={fetchImpl:r.fetchImpl,signal:r.signal},a=this.fallbackManager.getCandidateUrls(e,n),i;for(let u=0;u<a.length;u++){let c=a[u],l=u===0?o.policy.retry:{...o.policy.retry,maxRetries:0};try{let m=await this.executeWithRetry(d=>this.performRequest(c,o,n,r.responseType,s,d),l,{provider:n,url:c,timeout:o.policy.timeout,responseType:r.responseType});return _optionalChain([o, 'access', _40 => _40.circuitBreaker, 'optionalAccess', _41 => _41.recordSuccess, 'call', _42 => _42()]),this.fallbackManager.recordSuccess(c),m}catch(m){let d=_chunk4Q7UQ5Q3cjs.l.call(void 0, m,{provider:n,url:c,timeout:o.policy.timeout});if(i=d,this.fallbackManager.recordFailure(c,d),u<a.length-1&&this.fallbackManager.shouldFallback(d)){this.safe(()=>_optionalChain([this, 'access', _43 => _43.hooks, 'optionalAccess', _44 => _44.trace, 'optionalCall', _45 => _45("fallback",{provider:n,url:c,timeout:o.policy.timeout,attempt:0,responseType:r.responseType})]));continue}throw _optionalChain([o, 'access', _46 => _46.circuitBreaker, 'optionalAccess', _47 => _47.recordFailure, 'call', _48 => _48()]),this.toSdkError(d)}}throw _optionalChain([o, 'access', _49 => _49.circuitBreaker, 'optionalAccess', _50 => _50.recordFailure, 'call', _51 => _51()]),i?this.toSdkError(i):new g("Request failed without a concrete error")}async getTencentQuote(e){let r=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,n=await this.get(r,{responseType:"arraybuffer",provider:"tencent"}),o=A(n);return k(o)}};exports.a = A; exports.b = k; exports.c = se; exports.d = ie; exports.e = W; exports.f = ae; exports.g = De; exports.h = He; exports.i = qe; exports.j = Be; exports.k = Ke; exports.l = jt; exports.m = Ge; exports.n = We; exports.o = Xe; exports.p = $e; exports.q = ze; exports.r = Ze; exports.s = Je; exports.t = je; exports.u = Ye; exports.v = Ve; exports.w = Qe; exports.x = et; exports.y = tt; exports.z = rt; exports.A = nt; exports.B = ot; exports.C = st; exports.D = it; exports.E = at; exports.F = ct; exports.G = ut; exports.H = lt; exports.I = pt; exports.J = dt; exports.K = mt; exports.L = ht; exports.M = ft; exports.N = Et; exports.O = Tt; exports.P = _t; exports.Q = gt; exports.R = Rt; exports.S = yt; exports.T = St; exports.U = Ot; exports.V = Ct; exports.W = xt; exports.X = Lt; exports.Y = At; exports.Z = kt; exports._ = Pt; exports.$ = bt; exports.aa = G; exports.ba = P; exports.ca = pe; exports.da = de; exports.ea = me; exports.fa = he; exports.ga = fe; exports.ha = Ee; exports.ia = Te; exports.ja = $; exports.ka = Se; exports.la = b; exports.ma = xe; exports.na = Le; exports.oa = N; exports.pa = Ue; exports.qa = Y; exports.ra = we; exports.sa = ve; exports.ta = Fe;
|
package/dist/chunk-6JEP4QK7.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');function d(e){if(e.startsWith("92")||/^[48]/.test(e))return"BSE";let a=e[0];return a==="6"||a==="5"||a==="9"?"SSE":"SZSE"}var x={SHFE:{market:"CN",exchange:"SHFE"},DCE:{market:"CN",exchange:"DCE"},CZCE:{market:"CN",exchange:"CZCE"},INE:{market:"CN",exchange:"INE"},CFFEX:{market:"CN",exchange:"CFFEX"},GFEX:{market:"CN",exchange:"GFEX"},COMEX:{market:"GLOBAL",exchange:"COMEX"},NYMEX:{market:"GLOBAL",exchange:"NYMEX"},CBOT:{market:"GLOBAL",exchange:"CBOT"},LME:{market:"GLOBAL",exchange:"LME"}};function f(e){let a=e.match(/^([A-Za-z]+)/);return(a?a[1]:e).toUpperCase()}var U={sh:{market:"CN",exchange:"SSE"},sz:{market:"CN",exchange:"SZSE"},bj:{market:"CN",exchange:"BSE"},hk:{market:"HK",exchange:"HKEX"},us:{market:"US",exchange:"US"}},C=["sh","sz","bj","hk","us"],N={SH:{market:"CN",exchange:"SSE"},SZ:{market:"CN",exchange:"SZSE"},BJ:{market:"CN",exchange:"BSE"},HK:{market:"HK",exchange:"HKEX"},US:{market:"US",exchange:"US"}},A={0:{market:"CN",exchange:"SZSE"},1:{market:"CN",exchange:"SSE"},116:{market:"HK",exchange:"HKEX"},105:{market:"US",exchange:"NASDAQ"},106:{market:"US",exchange:"NYSE"},107:{market:"US",exchange:"AMEX"}};function X(e,a){let S=typeof e=="string"?{code:e}:{...e},p=typeof e=="string"?e:e.code,t=String(_nullishCoalesce(S.code, () => (""))).trim(),h=_nullishCoalesce(S.market, () => (_optionalChain([a, 'optionalAccess', _ => _.market]))),y=_nullishCoalesce(S.assetType, () => (_optionalChain([a, 'optionalAccess', _2 => _2.assetType]))),u=_nullishCoalesce(S.exchange, () => (_optionalChain([a, 'optionalAccess', _3 => _3.exchange])));if(!t)throw new (0, _chunk4Q7UQ5Q3cjs.f)(String(p));let c=(o,r,n,g,m)=>({market:o,exchange:_nullishCoalesce(u, () => (r)),assetType:_nullishCoalesce(y, () => (g)),code:n,variety:m,input:p});if(t.includes(".")){let o=t.indexOf("."),r=t.slice(0,o),n=t.slice(o+1),g=r.toUpperCase(),m=n.toUpperCase();if(/^\d+$/.test(r)&&A[r]){let s=A[r];return c(s.market,s.exchange,n,"stock")}if(N[m]){let s=N[m],l=r,b=r.toLowerCase();for(let k of C)if(b.startsWith(k)&&r.length>k.length){l=r.slice(k.length);break}return c(s.market,s.exchange,l,"stock")}if(x[g]){let s=x[g];return c(s.market,s.exchange,m,"futures",f(n))}if(r==="90")return c("CN","SSE",n,"board")}let T=t.toLowerCase();for(let o of C)if(T.startsWith(o)&&t.length>o.length){let r=t.slice(o.length),n=U[o];if(n.market==="CN"?/^\d+$/.test(r):/^[0-9A-Za-z]+$/.test(r)){let m=n.market==="HK"?r.padStart(5,"0"):n.market==="US"?r.toUpperCase():r;return c(n.market,n.exchange,m,"stock")}}if(/^\d+$/.test(t))return h==="US"?c("US","US",t,"stock"):h==="HK"||t.length===5||t.length===4?c("HK","HKEX",t.padStart(5,"0"),"stock"):c("CN",d(t),t,"stock");if((y==="futures"||h==="GLOBAL")&&/[A-Za-z]/.test(t)){let o=u;if(!o&&h==="GLOBAL")throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${p} (GLOBAL futures require an explicit exchange, e.g. { exchange: 'COMEX' })`);return c(_nullishCoalesce(h, () => ("CN")),_nullishCoalesce(o, () => ("SHFE")),t.toUpperCase(),"futures",f(t))}if(/^[A-Za-z][A-Za-z.\-]*$/.test(t))return c("US","US",t.toUpperCase(),"stock");throw new (0, _chunk4Q7UQ5Q3cjs.f)(String(p))}var H={SSE:"1",SZSE:"0",BSE:"0",HKEX:"116",NASDAQ:"105",NYSE:"106",AMEX:"107",US:"105"},w={SSE:"sh",SZSE:"sz",BSE:"bj"};function L(e){if(e.assetType==="board"||e.assetType==="futures"||e.assetType==="option")throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Tencent quote symbol does not support assetType '${e.assetType}'`,{assetType:e.assetType,code:e.code});switch(e.market){case"CN":{let a=w[e.exchange];if(!a)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Cannot map to Tencent symbol: unsupported CN exchange '${e.exchange}'`,{exchange:e.exchange,code:e.code});return`${a}${e.code}`}case"HK":return`hk${e.code.padStart(5,"0")}`;case"US":return`us${e.code}`;default:throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Cannot map to Tencent symbol: unsupported market '${e.market}'`,{market:e.market,code:e.code})}}function M(e){if(e.assetType==="board")return`90.${e.code}`;if(e.assetType==="futures"||e.assetType==="option")throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Eastmoney secid for assetType '${e.assetType}' uses a separate scheme; use the dedicated futures/options provider instead of toEastmoneySecid`,{assetType:e.assetType,exchange:e.exchange,code:e.code});if(e.market==="HK")return`116.${e.code.padStart(5,"0")}`;let a=H[e.exchange];if(!a)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Cannot map to Eastmoney secid: unsupported exchange '${e.exchange}' (market=${e.market})`,{exchange:e.exchange,market:e.market,code:e.code});return`${a}.${e.code}`}function $(e){return e.code}exports.a = d; exports.b = x; exports.c = f; exports.d = X; exports.e = L; exports.f = M; exports.g = $;
|
package/dist/chunk-HFN6G5M4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as k}from"./chunk-UBIQBXQ7.js";function P(b){let e=b.slice(),d={where(t){return e=e.filter(t),d},sortBy(t,c="desc"){let f=c==="asc"?1:-1;return e=e.slice().sort((s,n)=>{let m=t(s),p=t(n),a=Number.isFinite(m),l=Number.isFinite(p);return!a&&!l?0:a?l?(m-p)*f:-1:1}),d},top(t){if(!Number.isInteger(t)||t<0)throw new k(`top(n): n must be a non-negative integer, got ${t}`,{n:t});return e.slice(0,t)},toArray(){return e.slice()}};return d}function R(b){let e=b.close;return e!=null&&Number.isFinite(e)?e:null}function v(b){let{klines:e,strategy:d,initialCapital:t=1e5,fee:c=0,getClose:f=R}=b,s=t,n=0,m=0,p=-1,a=0,l=[],o=[],T=(r,i)=>{let u=(i/m*(1-c)*(1-c)-1)*100;l.push({entryIndex:p,exitIndex:r,entryPrice:m,exitPrice:i,returnPercent:u})};for(let r=0;r<e.length;r++){let i=f(e[r]),u=i!=null&&Number.isFinite(i)&&i>0?i:null,x=d(e[r],r,e);u!=null&&(a=u,x==="buy"&&n===0?(n=s*(1-c)/u,m=u,p=r,s=0):x==="sell"&&n>0&&(s=n*u*(1-c),T(r,u),n=0));let C=s+n*(u??a);o.push(C)}n>0&&a>0&&(s=n*a*(1-c),T(e.length-1,a),n=0,o.length>0&&(o[o.length-1]=s));let h=o.length?o[o.length-1]:t,S=(h/t-1)*100,B=l.filter(r=>r.returnPercent>0).length,w=l.length?B/l.length*100:0,y=-1/0,g=0;for(let r of o){r>y&&(y=r);let i=y>0?(y-r)/y*100:0;i>g&&(g=i)}return{initialCapital:t,finalEquity:h,totalReturn:S,winRate:w,maxDrawdown:g,tradeCount:l.length,trades:l,equityCurve:o}}export{P as a,v as b};
|
package/dist/chunk-LRE63M2C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function M(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function x(e,t){let l=[];for(let s=0;s<e.length;s++){if(s<t-1){l.push(null);continue}let u=0,n=0;for(let o=s-t+1;o<=s;o++)e[o]!==null&&(u+=e[o],n++);l.push(n===t?M(u/t):null)}return l}function y(e,t){let l=[],s=2/(t+1),u=null,n=!1;for(let o=0;o<e.length;o++){if(o<t-1){l.push(null);continue}if(!n){let c=0,i=0;for(let a=o-t+1;a<=o;a++)e[a]!==null&&(c+=e[a],i++);i===t&&(u=c/t,n=!0),l.push(u!==null?M(u):null);continue}let r=e[o];r===null?l.push(u!==null?M(u):null):(u=s*r+(1-s)*u,l.push(M(u)))}return l}function G(e,t){let l=[],s=Array.from({length:t},(n,o)=>o+1),u=s.reduce((n,o)=>n+o,0);for(let n=0;n<e.length;n++){if(n<t-1){l.push(null);continue}let o=0,r=!0;for(let c=0;c<t;c++){let i=e[n-t+1+c];if(i===null){r=!1;break}o+=i*s[c]}l.push(r?M(o/u):null)}return l}function v(e,t={}){let{periods:l=[5,10,20,30,60,120,250],type:s="sma"}=t,u=s==="ema"?y:s==="wma"?G:x,n={};for(let o of l)n[`ma${o}`]=u(e,o);return e.map((o,r)=>{let c={};for(let i of l)c[`ma${i}`]=n[`ma${i}`][r];return c})}function Y(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function K(e,t={}){let{short:l=12,long:s=26,signal:u=9}=t,n=y(e,l),o=y(e,s),r=e.map((i,a)=>n[a]===null||o[a]===null?null:n[a]-o[a]),c=y(r,u);return e.map((i,a)=>({dif:r[a]!==null?Y(r[a]):null,dea:c[a],macd:r[a]!==null&&c[a]!==null?Y((r[a]-c[a])*2):null}))}function j(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function F(e,t,l){let s=[];for(let u=0;u<e.length;u++){if(u<t-1||l[u]===null){s.push(null);continue}let n=0,o=0;for(let r=u-t+1;r<=u;r++)e[r]!==null&&l[u]!==null&&(n+=Math.pow(e[r]-l[u],2),o++);s.push(o===t?Math.sqrt(n/t):null)}return s}function S(e,t={}){let{period:l=20,stdDev:s=2}=t,u=x(e,l),n=F(e,l,u);return e.map((o,r)=>{if(u[r]===null||n[r]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let c=u[r]+s*n[r],i=u[r]-s*n[r],a=u[r]!==0?j((c-i)/u[r]*100):null;return{mid:u[r],upper:j(c),lower:j(i),bandwidth:a}})}function D(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function B(e,t={}){let{period:l=9,kPeriod:s=3,dPeriod:u=3}=t,n=[],o=50,r=50;for(let c=0;c<e.length;c++){if(c<l-1){n.push({k:null,d:null,j:null});continue}let i=-1/0,a=1/0,p=!0;for(let m=c-l+1;m<=c;m++){if(e[m].high===null||e[m].low===null){p=!1;break}i=Math.max(i,e[m].high),a=Math.min(a,e[m].low)}let f=e[c].close;if(!p||f===null||i===a){n.push({k:null,d:null,j:null});continue}let h=(f-a)/(i-a)*100;o=(s-1)/s*o+1/s*h,r=(u-1)/u*r+1/u*o;let d=3*o-2*r;n.push({k:D(o),d:D(r),j:D(d)})}return n}function Q(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function V(e,t={}){let{periods:l=[6,12,24]}=t,s=[null];for(let n=1;n<e.length;n++)e[n]===null||e[n-1]===null?s.push(null):s.push(e[n]-e[n-1]);let u={};for(let n of l){let o=[],r=0,c=0;for(let i=0;i<e.length;i++){if(i<n){o.push(null),s[i]!==null&&(s[i]>0?r+=s[i]:c+=Math.abs(s[i]));continue}if(i===n)s[i]!==null&&(s[i]>0?r+=s[i]:c+=Math.abs(s[i])),r=r/n,c=c/n;else{let a=s[i]??0,p=a>0?a:0,f=a<0?Math.abs(a):0;r=(r*(n-1)+p)/n,c=(c*(n-1)+f)/n}if(c===0)o.push(100);else if(r===0)o.push(0);else{let a=r/c;o.push(Q(100-100/(1+a)))}}u[`rsi${n}`]=o}return e.map((n,o)=>{let r={};for(let c of l)r[`rsi${c}`]=u[`rsi${c}`][o];return r})}function U(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function H(e,t={}){let{periods:l=[6,10]}=t,s={};for(let u of l){let n=[];for(let o=0;o<e.length;o++){if(o<u-1){n.push(null);continue}let r=-1/0,c=1/0,i=!0;for(let f=o-u+1;f<=o;f++){if(e[f].high===null||e[f].low===null){i=!1;break}r=Math.max(r,e[f].high),c=Math.min(c,e[f].low)}let a=e[o].close;if(!i||a===null||r===c){n.push(null);continue}let p=(r-a)/(r-c)*100;n.push(U(p))}s[`wr${u}`]=n}return e.map((u,n)=>{let o={};for(let r of l)o[`wr${r}`]=s[`wr${r}`][n];return o})}function X(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function T(e,t={}){let{periods:l=[6,12,24]}=t,s={};for(let u of l){let n=x(e,u),o=[];for(let r=0;r<e.length;r++)if(e[r]===null||n[r]===null||n[r]===0)o.push(null);else{let c=(e[r]-n[r])/n[r]*100;o.push(X(c))}s[`bias${u}`]=o}return e.map((u,n)=>{let o={};for(let r of l)o[`bias${r}`]=s[`bias${r}`][n];return o})}function Z(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function P(e,t={}){let{period:l=14}=t,s=[],u=e.map(n=>n.high===null||n.low===null||n.close===null?null:(n.high+n.low+n.close)/3);for(let n=0;n<e.length;n++){if(n<l-1){s.push({cci:null});continue}let o=0,r=0;for(let p=n-l+1;p<=n;p++)u[p]!==null&&(o+=u[p],r++);if(r!==l||u[n]===null){s.push({cci:null});continue}let c=o/l,i=0;for(let p=n-l+1;p<=n;p++)i+=Math.abs(u[p]-c);let a=i/l;if(a===0)s.push({cci:0});else{let p=(u[n]-c)/(.015*a);s.push({cci:Z(p)})}}return s}function W(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function I(e,t={}){let{period:l=14}=t,s=[],u=[];for(let o=0;o<e.length;o++){let{high:r,low:c,close:i}=e[o];if(r===null||c===null||i===null){u.push(null);continue}if(o===0)u.push(r-c);else{let a=e[o-1].close;if(a===null)u.push(r-c);else{let p=r-c,f=Math.abs(r-a),h=Math.abs(c-a);u.push(Math.max(p,f,h))}}}let n=null;for(let o=0;o<e.length;o++){if(o<l-1){s.push({tr:u[o]!==null?W(u[o]):null,atr:null});continue}if(o===l-1){let r=0,c=0;for(let i=0;i<l;i++)u[i]!==null&&(r+=u[i],c++);c===l&&(n=r/l)}else n!==null&&u[o]!==null&&(n=(n*(l-1)+u[o])/l);s.push({tr:u[o]!==null?W(u[o]):null,atr:n!==null?W(n):null})}return s}function E(e,t={}){let{maPeriod:l}=t,s=[];if(e.length===0)return s;let u=e[0].volume??0;s.push({obv:u,obvMa:null});for(let n=1;n<e.length;n++){let o=e[n],r=e[n-1];if(o.close===null||r.close===null||o.volume===null||o.volume===void 0){s.push({obv:null,obvMa:null});continue}o.close>r.close?u+=o.volume:o.close<r.close&&(u-=o.volume),s.push({obv:u,obvMa:null})}if(l&&l>0)for(let n=l-1;n<s.length;n++){let o=0,r=0;for(let c=n-l+1;c<=n;c++)s[c].obv!==null&&(o+=s[c].obv,r++);r===l&&(s[n].obvMa=o/l)}return s}function $(e,t={}){let{period:l=12,signalPeriod:s}=t,u=[];for(let n=0;n<e.length;n++){if(n<l){u.push({roc:null,signal:null});continue}let o=e[n].close,r=e[n-l].close;if(o===null||r===null||r===0){u.push({roc:null,signal:null});continue}let c=(o-r)/r*100;u.push({roc:c,signal:null})}if(s&&s>0)for(let n=l+s-1;n<u.length;n++){let o=0,r=0;for(let c=n-s+1;c<=n;c++)u[c].roc!==null&&(o+=u[c].roc,r++);r===s&&(u[n].signal=o/s)}return u}function _(e,t={}){let{period:l=14,adxPeriod:s=l}=t,u=[];if(e.length<2)return e.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let n=[],o=[],r=[];for(let m=0;m<e.length;m++){if(m===0){n.push(0),o.push(0),r.push(0),u.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let b=e[m],R=e[m-1];if(b.high===null||b.low===null||b.close===null||R.high===null||R.low===null||R.close===null){n.push(0),o.push(0),r.push(0),u.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=b.high-b.low,L=Math.abs(b.high-R.close),z=Math.abs(b.low-R.close);r.push(Math.max(O,L,z));let C=b.high-R.high,k=R.low-b.low;C>k&&C>0?n.push(C):n.push(0),k>C&&k>0?o.push(k):o.push(0),u.push({pdi:null,mdi:null,adx:null,adxr:null})}let c=0,i=0,a=0,p=[];for(let m=1;m<e.length;m++){if(m<l){c+=r[m],i+=n[m],a+=o[m],p.push(0);continue}m===l?(c+=r[m],i+=n[m],a+=o[m]):(c=c-c/l+r[m],i=i-i/l+n[m],a=a-a/l+o[m]);let b=c>0?i/c*100:0,R=c>0?a/c*100:0;u[m].pdi=b,u[m].mdi=R;let O=b+R,L=O>0?Math.abs(b-R)/O*100:0;p.push(L)}let f=0,h=0,d=0;for(let m=l;m<e.length;m++){if(m<l*2-1){f+=p[m-1]||0,h++;continue}if(m===l*2-1)f+=p[m-1]||0,d=f/s,u[m].adx=d;else{let b=p[m-1]||0;d=(d*(s-1)+b)/s,u[m].adx=d}}for(let m=l*2-1+s;m<e.length;m++){let b=u[m].adx,R=u[m-s]?.adx;b!==null&&R!==null&&(u[m].adxr=(b+R)/2)}return u}function J(e,t={}){let{afStart:l=.02,afIncrement:s=.02,afMax:u=.2}=t,n=[];if(e.length<2)return e.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,r=l,c=e[0].high??0,i=e[0].low??0,a=e[0],p=e[1];a.close!==null&&p.close!==null&&p.close<a.close&&(o=-1,c=a.low??0,i=a.high??0),n.push({sar:null,trend:null,ep:null,af:null});for(let f=1;f<e.length;f++){let h=e[f],d=e[f-1];if(h.high===null||h.low===null||d.high===null||d.low===null){n.push({sar:null,trend:null,ep:null,af:null});continue}let m=i+r*(c-i);o===1?(m=Math.min(m,d.low,e[Math.max(0,f-2)]?.low??d.low),h.low<m?(o=-1,m=c,c=h.low,r=l):h.high>c&&(c=h.high,r=Math.min(r+s,u))):(m=Math.max(m,d.high,e[Math.max(0,f-2)]?.high??d.high),h.high>m?(o=1,m=c,c=h.high,r=l):h.low<c&&(c=h.low,r=Math.min(r+s,u))),i=m,n.push({sar:i,trend:o,ep:c,af:r})}return n}function N(e,t={}){let{emaPeriod:l=20,atrPeriod:s=10,multiplier:u=2}=t,n=[],o=e.map(i=>i.close),r=y(o,l),c=I(e,{period:s});for(let i=0;i<e.length;i++){let a=r[i],p=c[i]?.atr;if(a===null||p===null){n.push({mid:null,upper:null,lower:null,width:null});continue}let f=a+u*p,h=a-u*p,d=a>0?(f-h)/a*100:null;n.push({mid:a,upper:f,lower:h,width:d})}return n}function A(e,t=0){return e.length===0?t:Math.max(...e)}function q(e){return{closes:e.map(t=>t.close),ohlcv:e.map(t=>({open:t.open,high:t.high,low:t.low,close:t.close,volume:t.volume}))}}var g={ma:{key:"ma",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=t.periods??[5,10,20,30,60,120,250],s=t.type??"sma";return{bars:A(l,20),emaBased:s==="ema"}},compute:(e,t)=>v(e.closes,typeof t=="object"?t:{})},macd:{key:"macd",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=t.long??26,s=t.signal??9;return{bars:l*3+s,emaBased:!0}},compute:(e,t)=>K(e.closes,typeof t=="object"?t:{})},boll:{key:"boll",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:20}),compute:(e,t)=>S(e.closes,typeof t=="object"?t:{})},kdj:{key:"kdj",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:9}),compute:(e,t)=>B(e.ohlcv,typeof t=="object"?t:{})},rsi:{key:"rsi",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,12,24];return{bars:A(t,14)+1}},compute:(e,t)=>V(e.closes,typeof t=="object"?t:{})},wr:{key:"wr",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,10];return{bars:A(t,10)}},compute:(e,t)=>H(e.ohlcv,typeof t=="object"?t:{})},bias:{key:"bias",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,12,24];return{bars:A(t,12)}},compute:(e,t)=>T(e.closes,typeof t=="object"?t:{})},cci:{key:"cci",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:14}),compute:(e,t)=>P(e.ohlcv,typeof t=="object"?t:{})},atr:{key:"atr",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:14}),compute:(e,t)=>I(e.ohlcv,typeof t=="object"?t:{})},obv:{key:"obv",estimateLookback:e=>{let t=typeof e=="object"&&e.maPeriod?e.maPeriod:0;return{bars:Math.max(2,t)}},compute:(e,t)=>E(e.ohlcv,typeof t=="object"?t:{})},roc:{key:"roc",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=t.period??12,s=t.signalPeriod??0;return{bars:l+s}},compute:(e,t)=>$(e.ohlcv,typeof t=="object"?t:{})},dmi:{key:"dmi",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=t.period??14,s=t.adxPeriod??l;return{bars:l*2+s}},compute:(e,t)=>_(e.ohlcv,typeof t=="object"?t:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(e,t)=>J(e.ohlcv,typeof t=="object"?t:{})},kc:{key:"kc",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=t.emaPeriod??20,s=t.atrPeriod??10;return{bars:Math.max(l*3,s),emaBased:!0}},compute:(e,t)=>N(e.ohlcv,typeof t=="object"?t:{})}};function w(e){return Object.keys(g).filter(t=>!!e[t])}function ee(e){let t=0,l=!1;for(let u of w(e)){let o=g[u].estimateLookback(e[u]);t=Math.max(t,o.bars),l||(l=!!o.emaBased)}return{maxLookback:t,hasEmaBasedIndicator:l,requiredBars:Math.ceil(t*(l?1.5:1.2))}}function te(e,t={}){if(e.length===0)return[];let l=q(e),s=new Map;for(let u of w(t)){let n=g[u];s.set(u,n.compute(l,t[u]))}return e.map((u,n)=>({...u,...Object.fromEntries(Array.from(s.entries()).map(([o,r])=>[o,r[n]]))}))}export{x as a,y as b,G as c,v as d,K as e,S as f,B as g,V as h,H as i,T as j,P as k,I as l,E as m,$ as n,_ as o,J as p,N as q,q as r,g as s,w as t,ee as u,te as v};
|
package/dist/chunk-NMRUSAWS.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }function M(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function x(e,t){let l=[];for(let s=0;s<e.length;s++){if(s<t-1){l.push(null);continue}let u=0,n=0;for(let o=s-t+1;o<=s;o++)e[o]!==null&&(u+=e[o],n++);l.push(n===t?M(u/t):null)}return l}function y(e,t){let l=[],s=2/(t+1),u=null,n=!1;for(let o=0;o<e.length;o++){if(o<t-1){l.push(null);continue}if(!n){let c=0,i=0;for(let a=o-t+1;a<=o;a++)e[a]!==null&&(c+=e[a],i++);i===t&&(u=c/t,n=!0),l.push(u!==null?M(u):null);continue}let r=e[o];r===null?l.push(u!==null?M(u):null):(u=s*r+(1-s)*u,l.push(M(u)))}return l}function G(e,t){let l=[],s=Array.from({length:t},(n,o)=>o+1),u=s.reduce((n,o)=>n+o,0);for(let n=0;n<e.length;n++){if(n<t-1){l.push(null);continue}let o=0,r=!0;for(let c=0;c<t;c++){let i=e[n-t+1+c];if(i===null){r=!1;break}o+=i*s[c]}l.push(r?M(o/u):null)}return l}function v(e,t={}){let{periods:l=[5,10,20,30,60,120,250],type:s="sma"}=t,u=s==="ema"?y:s==="wma"?G:x,n={};for(let o of l)n[`ma${o}`]=u(e,o);return e.map((o,r)=>{let c={};for(let i of l)c[`ma${i}`]=n[`ma${i}`][r];return c})}function Y(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function K(e,t={}){let{short:l=12,long:s=26,signal:u=9}=t,n=y(e,l),o=y(e,s),r=e.map((i,a)=>n[a]===null||o[a]===null?null:n[a]-o[a]),c=y(r,u);return e.map((i,a)=>({dif:r[a]!==null?Y(r[a]):null,dea:c[a],macd:r[a]!==null&&c[a]!==null?Y((r[a]-c[a])*2):null}))}function j(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function F(e,t,l){let s=[];for(let u=0;u<e.length;u++){if(u<t-1||l[u]===null){s.push(null);continue}let n=0,o=0;for(let r=u-t+1;r<=u;r++)e[r]!==null&&l[u]!==null&&(n+=Math.pow(e[r]-l[u],2),o++);s.push(o===t?Math.sqrt(n/t):null)}return s}function S(e,t={}){let{period:l=20,stdDev:s=2}=t,u=x(e,l),n=F(e,l,u);return e.map((o,r)=>{if(u[r]===null||n[r]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let c=u[r]+s*n[r],i=u[r]-s*n[r],a=u[r]!==0?j((c-i)/u[r]*100):null;return{mid:u[r],upper:j(c),lower:j(i),bandwidth:a}})}function D(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function B(e,t={}){let{period:l=9,kPeriod:s=3,dPeriod:u=3}=t,n=[],o=50,r=50;for(let c=0;c<e.length;c++){if(c<l-1){n.push({k:null,d:null,j:null});continue}let i=-1/0,a=1/0,p=!0;for(let m=c-l+1;m<=c;m++){if(e[m].high===null||e[m].low===null){p=!1;break}i=Math.max(i,e[m].high),a=Math.min(a,e[m].low)}let f=e[c].close;if(!p||f===null||i===a){n.push({k:null,d:null,j:null});continue}let h=(f-a)/(i-a)*100;o=(s-1)/s*o+1/s*h,r=(u-1)/u*r+1/u*o;let d=3*o-2*r;n.push({k:D(o),d:D(r),j:D(d)})}return n}function Q(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function V(e,t={}){let{periods:l=[6,12,24]}=t,s=[null];for(let n=1;n<e.length;n++)e[n]===null||e[n-1]===null?s.push(null):s.push(e[n]-e[n-1]);let u={};for(let n of l){let o=[],r=0,c=0;for(let i=0;i<e.length;i++){if(i<n){o.push(null),s[i]!==null&&(s[i]>0?r+=s[i]:c+=Math.abs(s[i]));continue}if(i===n)s[i]!==null&&(s[i]>0?r+=s[i]:c+=Math.abs(s[i])),r=r/n,c=c/n;else{let a=_nullishCoalesce(s[i], () => (0)),p=a>0?a:0,f=a<0?Math.abs(a):0;r=(r*(n-1)+p)/n,c=(c*(n-1)+f)/n}if(c===0)o.push(100);else if(r===0)o.push(0);else{let a=r/c;o.push(Q(100-100/(1+a)))}}u[`rsi${n}`]=o}return e.map((n,o)=>{let r={};for(let c of l)r[`rsi${c}`]=u[`rsi${c}`][o];return r})}function U(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function H(e,t={}){let{periods:l=[6,10]}=t,s={};for(let u of l){let n=[];for(let o=0;o<e.length;o++){if(o<u-1){n.push(null);continue}let r=-1/0,c=1/0,i=!0;for(let f=o-u+1;f<=o;f++){if(e[f].high===null||e[f].low===null){i=!1;break}r=Math.max(r,e[f].high),c=Math.min(c,e[f].low)}let a=e[o].close;if(!i||a===null||r===c){n.push(null);continue}let p=(r-a)/(r-c)*100;n.push(U(p))}s[`wr${u}`]=n}return e.map((u,n)=>{let o={};for(let r of l)o[`wr${r}`]=s[`wr${r}`][n];return o})}function X(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function T(e,t={}){let{periods:l=[6,12,24]}=t,s={};for(let u of l){let n=x(e,u),o=[];for(let r=0;r<e.length;r++)if(e[r]===null||n[r]===null||n[r]===0)o.push(null);else{let c=(e[r]-n[r])/n[r]*100;o.push(X(c))}s[`bias${u}`]=o}return e.map((u,n)=>{let o={};for(let r of l)o[`bias${r}`]=s[`bias${r}`][n];return o})}function Z(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function P(e,t={}){let{period:l=14}=t,s=[],u=e.map(n=>n.high===null||n.low===null||n.close===null?null:(n.high+n.low+n.close)/3);for(let n=0;n<e.length;n++){if(n<l-1){s.push({cci:null});continue}let o=0,r=0;for(let p=n-l+1;p<=n;p++)u[p]!==null&&(o+=u[p],r++);if(r!==l||u[n]===null){s.push({cci:null});continue}let c=o/l,i=0;for(let p=n-l+1;p<=n;p++)i+=Math.abs(u[p]-c);let a=i/l;if(a===0)s.push({cci:0});else{let p=(u[n]-c)/(.015*a);s.push({cci:Z(p)})}}return s}function W(e,t=2){let l=Math.pow(10,t);return Math.round(e*l)/l}function I(e,t={}){let{period:l=14}=t,s=[],u=[];for(let o=0;o<e.length;o++){let{high:r,low:c,close:i}=e[o];if(r===null||c===null||i===null){u.push(null);continue}if(o===0)u.push(r-c);else{let a=e[o-1].close;if(a===null)u.push(r-c);else{let p=r-c,f=Math.abs(r-a),h=Math.abs(c-a);u.push(Math.max(p,f,h))}}}let n=null;for(let o=0;o<e.length;o++){if(o<l-1){s.push({tr:u[o]!==null?W(u[o]):null,atr:null});continue}if(o===l-1){let r=0,c=0;for(let i=0;i<l;i++)u[i]!==null&&(r+=u[i],c++);c===l&&(n=r/l)}else n!==null&&u[o]!==null&&(n=(n*(l-1)+u[o])/l);s.push({tr:u[o]!==null?W(u[o]):null,atr:n!==null?W(n):null})}return s}function E(e,t={}){let{maPeriod:l}=t,s=[];if(e.length===0)return s;let u=_nullishCoalesce(e[0].volume, () => (0));s.push({obv:u,obvMa:null});for(let n=1;n<e.length;n++){let o=e[n],r=e[n-1];if(o.close===null||r.close===null||o.volume===null||o.volume===void 0){s.push({obv:null,obvMa:null});continue}o.close>r.close?u+=o.volume:o.close<r.close&&(u-=o.volume),s.push({obv:u,obvMa:null})}if(l&&l>0)for(let n=l-1;n<s.length;n++){let o=0,r=0;for(let c=n-l+1;c<=n;c++)s[c].obv!==null&&(o+=s[c].obv,r++);r===l&&(s[n].obvMa=o/l)}return s}function $(e,t={}){let{period:l=12,signalPeriod:s}=t,u=[];for(let n=0;n<e.length;n++){if(n<l){u.push({roc:null,signal:null});continue}let o=e[n].close,r=e[n-l].close;if(o===null||r===null||r===0){u.push({roc:null,signal:null});continue}let c=(o-r)/r*100;u.push({roc:c,signal:null})}if(s&&s>0)for(let n=l+s-1;n<u.length;n++){let o=0,r=0;for(let c=n-s+1;c<=n;c++)u[c].roc!==null&&(o+=u[c].roc,r++);r===s&&(u[n].signal=o/s)}return u}function _(e,t={}){let{period:l=14,adxPeriod:s=l}=t,u=[];if(e.length<2)return e.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let n=[],o=[],r=[];for(let m=0;m<e.length;m++){if(m===0){n.push(0),o.push(0),r.push(0),u.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let b=e[m],R=e[m-1];if(b.high===null||b.low===null||b.close===null||R.high===null||R.low===null||R.close===null){n.push(0),o.push(0),r.push(0),u.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let O=b.high-b.low,L=Math.abs(b.high-R.close),z=Math.abs(b.low-R.close);r.push(Math.max(O,L,z));let C=b.high-R.high,k=R.low-b.low;C>k&&C>0?n.push(C):n.push(0),k>C&&k>0?o.push(k):o.push(0),u.push({pdi:null,mdi:null,adx:null,adxr:null})}let c=0,i=0,a=0,p=[];for(let m=1;m<e.length;m++){if(m<l){c+=r[m],i+=n[m],a+=o[m],p.push(0);continue}m===l?(c+=r[m],i+=n[m],a+=o[m]):(c=c-c/l+r[m],i=i-i/l+n[m],a=a-a/l+o[m]);let b=c>0?i/c*100:0,R=c>0?a/c*100:0;u[m].pdi=b,u[m].mdi=R;let O=b+R,L=O>0?Math.abs(b-R)/O*100:0;p.push(L)}let f=0,h=0,d=0;for(let m=l;m<e.length;m++){if(m<l*2-1){f+=p[m-1]||0,h++;continue}if(m===l*2-1)f+=p[m-1]||0,d=f/s,u[m].adx=d;else{let b=p[m-1]||0;d=(d*(s-1)+b)/s,u[m].adx=d}}for(let m=l*2-1+s;m<e.length;m++){let b=u[m].adx,R=_optionalChain([u, 'access', _2 => _2[m-s], 'optionalAccess', _3 => _3.adx]);b!==null&&R!==null&&(u[m].adxr=(b+R)/2)}return u}function J(e,t={}){let{afStart:l=.02,afIncrement:s=.02,afMax:u=.2}=t,n=[];if(e.length<2)return e.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,r=l,c=_nullishCoalesce(e[0].high, () => (0)),i=_nullishCoalesce(e[0].low, () => (0)),a=e[0],p=e[1];a.close!==null&&p.close!==null&&p.close<a.close&&(o=-1,c=_nullishCoalesce(a.low, () => (0)),i=_nullishCoalesce(a.high, () => (0))),n.push({sar:null,trend:null,ep:null,af:null});for(let f=1;f<e.length;f++){let h=e[f],d=e[f-1];if(h.high===null||h.low===null||d.high===null||d.low===null){n.push({sar:null,trend:null,ep:null,af:null});continue}let m=i+r*(c-i);o===1?(m=Math.min(m,d.low,_nullishCoalesce(_optionalChain([e, 'access', _4 => _4[Math.max(0,f-2)], 'optionalAccess', _5 => _5.low]), () => (d.low))),h.low<m?(o=-1,m=c,c=h.low,r=l):h.high>c&&(c=h.high,r=Math.min(r+s,u))):(m=Math.max(m,d.high,_nullishCoalesce(_optionalChain([e, 'access', _6 => _6[Math.max(0,f-2)], 'optionalAccess', _7 => _7.high]), () => (d.high))),h.high>m?(o=1,m=c,c=h.high,r=l):h.low<c&&(c=h.low,r=Math.min(r+s,u))),i=m,n.push({sar:i,trend:o,ep:c,af:r})}return n}function N(e,t={}){let{emaPeriod:l=20,atrPeriod:s=10,multiplier:u=2}=t,n=[],o=e.map(i=>i.close),r=y(o,l),c=I(e,{period:s});for(let i=0;i<e.length;i++){let a=r[i],p=_optionalChain([c, 'access', _8 => _8[i], 'optionalAccess', _9 => _9.atr]);if(a===null||p===null){n.push({mid:null,upper:null,lower:null,width:null});continue}let f=a+u*p,h=a-u*p,d=a>0?(f-h)/a*100:null;n.push({mid:a,upper:f,lower:h,width:d})}return n}function A(e,t=0){return e.length===0?t:Math.max(...e)}function q(e){return{closes:e.map(t=>t.close),ohlcv:e.map(t=>({open:t.open,high:t.high,low:t.low,close:t.close,volume:t.volume}))}}var g={ma:{key:"ma",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=_nullishCoalesce(t.periods, () => ([5,10,20,30,60,120,250])),s=_nullishCoalesce(t.type, () => ("sma"));return{bars:A(l,20),emaBased:s==="ema"}},compute:(e,t)=>v(e.closes,typeof t=="object"?t:{})},macd:{key:"macd",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=_nullishCoalesce(t.long, () => (26)),s=_nullishCoalesce(t.signal, () => (9));return{bars:l*3+s,emaBased:!0}},compute:(e,t)=>K(e.closes,typeof t=="object"?t:{})},boll:{key:"boll",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:20}),compute:(e,t)=>S(e.closes,typeof t=="object"?t:{})},kdj:{key:"kdj",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:9}),compute:(e,t)=>B(e.ohlcv,typeof t=="object"?t:{})},rsi:{key:"rsi",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,12,24];return{bars:A(t,14)+1}},compute:(e,t)=>V(e.closes,typeof t=="object"?t:{})},wr:{key:"wr",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,10];return{bars:A(t,10)}},compute:(e,t)=>H(e.ohlcv,typeof t=="object"?t:{})},bias:{key:"bias",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,12,24];return{bars:A(t,12)}},compute:(e,t)=>T(e.closes,typeof t=="object"?t:{})},cci:{key:"cci",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:14}),compute:(e,t)=>P(e.ohlcv,typeof t=="object"?t:{})},atr:{key:"atr",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:14}),compute:(e,t)=>I(e.ohlcv,typeof t=="object"?t:{})},obv:{key:"obv",estimateLookback:e=>{let t=typeof e=="object"&&e.maPeriod?e.maPeriod:0;return{bars:Math.max(2,t)}},compute:(e,t)=>E(e.ohlcv,typeof t=="object"?t:{})},roc:{key:"roc",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=_nullishCoalesce(t.period, () => (12)),s=_nullishCoalesce(t.signalPeriod, () => (0));return{bars:l+s}},compute:(e,t)=>$(e.ohlcv,typeof t=="object"?t:{})},dmi:{key:"dmi",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=_nullishCoalesce(t.period, () => (14)),s=_nullishCoalesce(t.adxPeriod, () => (l));return{bars:l*2+s}},compute:(e,t)=>_(e.ohlcv,typeof t=="object"?t:{})},sar:{key:"sar",estimateLookback:()=>({bars:5}),compute:(e,t)=>J(e.ohlcv,typeof t=="object"?t:{})},kc:{key:"kc",estimateLookback:e=>{let t=typeof e=="object"?e:{},l=_nullishCoalesce(t.emaPeriod, () => (20)),s=_nullishCoalesce(t.atrPeriod, () => (10));return{bars:Math.max(l*3,s),emaBased:!0}},compute:(e,t)=>N(e.ohlcv,typeof t=="object"?t:{})}};function w(e){return Object.keys(g).filter(t=>!!e[t])}function ee(e){let t=0,l=!1;for(let u of w(e)){let o=g[u].estimateLookback(e[u]);t=Math.max(t,o.bars),l||(l=!!o.emaBased)}return{maxLookback:t,hasEmaBasedIndicator:l,requiredBars:Math.ceil(t*(l?1.5:1.2))}}function te(e,t={}){if(e.length===0)return[];let l=q(e),s=new Map;for(let u of w(t)){let n=g[u];s.set(u,n.compute(l,t[u]))}return e.map((u,n)=>({...u,...Object.fromEntries(Array.from(s.entries()).map(([o,r])=>[o,r[n]]))}))}exports.a = x; exports.b = y; exports.c = G; exports.d = v; exports.e = K; exports.f = S; exports.g = B; exports.h = V; exports.i = H; exports.j = T; exports.k = P; exports.l = I; exports.m = E; exports.n = $; exports.o = _; exports.p = J; exports.q = N; exports.r = q; exports.s = g; exports.t = w; exports.u = ee; exports.v = te;
|