stock-sdk 2.3.0 → 2.4.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.
Files changed (62) hide show
  1. package/README.md +3 -1
  2. package/dist/{adapters-BiH4keVd.d.cts → adapters-CZUNRbxi.d.cts} +29 -1
  3. package/dist/{adapters-BiH4keVd.d.ts → adapters-CZUNRbxi.d.ts} +29 -1
  4. package/dist/cache.cjs +1 -1
  5. package/dist/cache.d.cts +35 -3
  6. package/dist/cache.d.ts +35 -3
  7. package/dist/cache.js +1 -1
  8. package/dist/chunk-46ECBWOQ.cjs +1 -0
  9. package/dist/chunk-4RN7AVFQ.js +1 -0
  10. package/dist/chunk-6FZNYDNN.cjs +1 -0
  11. package/dist/chunk-6MCPZDKN.cjs +1 -0
  12. package/dist/chunk-H5FDXQRK.js +1 -0
  13. package/dist/chunk-HKREKO2F.js +1 -0
  14. package/dist/chunk-LDYRNH4X.cjs +1 -0
  15. package/dist/chunk-OPCBE3NR.js +1 -0
  16. package/dist/chunk-R7M3BHS4.cjs +1 -0
  17. package/dist/chunk-SMCYQ6NL.js +1 -0
  18. package/dist/chunk-USZUOBM2.cjs +1 -0
  19. package/dist/chunk-VKXPLWPL.js +1 -0
  20. package/dist/chunk-W625VPPB.js +1 -0
  21. package/dist/chunk-WJOFTWZL.cjs +1 -0
  22. package/dist/cli.cjs +16 -16
  23. package/dist/cli.js +16 -16
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.d.cts +23 -7
  26. package/dist/index.d.ts +23 -7
  27. package/dist/index.js +1 -1
  28. package/dist/indicators.cjs +1 -1
  29. package/dist/indicators.js +1 -1
  30. package/dist/mcp.cjs +83 -5
  31. package/dist/mcp.d.cts +28 -2
  32. package/dist/mcp.d.ts +28 -2
  33. package/dist/mcp.js +83 -5
  34. package/dist/screener.cjs +1 -1
  35. package/dist/screener.d.cts +51 -16
  36. package/dist/screener.d.ts +51 -16
  37. package/dist/screener.js +1 -1
  38. package/dist/{sdk-CtqVdrof.d.ts → sdk-DGgSDZRx.d.ts} +67 -16
  39. package/dist/{sdk-6Qozazec.d.cts → sdk-RzQ-drS4.d.cts} +67 -16
  40. package/dist/signals.d.cts +3 -42
  41. package/dist/signals.d.ts +3 -42
  42. package/dist/symbols.cjs +1 -1
  43. package/dist/symbols.d.cts +2 -2
  44. package/dist/symbols.d.ts +2 -2
  45. package/dist/symbols.js +1 -1
  46. package/dist/types-7n5rSHbd.d.cts +42 -0
  47. package/dist/types-7n5rSHbd.d.ts +42 -0
  48. package/package.json +2 -1
  49. package/dist/chunk-3ASJZ3YA.js +0 -1
  50. package/dist/chunk-6IFA2HGD.cjs +0 -1
  51. package/dist/chunk-C4CA7QBB.cjs +0 -1
  52. package/dist/chunk-DU7MCVLJ.js +0 -1
  53. package/dist/chunk-F3KZXCVO.js +0 -1
  54. package/dist/chunk-IWHFCLJM.js +0 -1
  55. package/dist/chunk-LCX5Q36O.js +0 -1
  56. package/dist/chunk-LMUFSVKQ.cjs +0 -1
  57. package/dist/chunk-QGYIBFXP.js +0 -1
  58. package/dist/chunk-T5CH7H3X.cjs +0 -1
  59. package/dist/chunk-TVIEKKDQ.cjs +0 -1
  60. package/dist/chunk-WCBK5KYA.cjs +0 -1
  61. package/dist/chunk-ZESMWMHP.cjs +0 -1
  62. package/dist/chunk-ZZ2IBUMV.js +0 -1
@@ -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 $(e){if(e.startsWith("92")||/^[48]/.test(e))return"BSE";let r=e[0];return r==="6"||r==="5"||r==="9"?"SSE":"SZSE"}var y={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 I(e){let r=e.match(/^([A-Za-z]+)/);return(r?r[1]:e).toUpperCase()}var w={market:"CN",exchange:"CSI",secidPrefix:"2"},F=[/^93\d{4}$/,/^H\d{5}$/],O={HSHCI:{market:"HK",exchange:"HSI",secidPrefix:"124"},GDAXI:{market:"GLOBAL",exchange:"DAX",secidPrefix:"100"}},R=[[w.exchange,w.market],...Object.values(O).map(e=>[e.exchange,e.market])];function u(e){let r=e.toUpperCase();if(F.some(c=>c.test(r)))return{...w,code:r};let i=O[r];return i?{...i,code:r}:void 0}var A={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"}},P=Object.keys(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"}},B={0:["SZSE","BSE"]},D={SSE:"CN",SZSE:"CN",BSE:"CN",HKEX:"HK",NASDAQ:"US",NYSE:"US",AMEX:"US",US:"US",...Object.fromEntries(R),...Object.fromEntries(Object.values(y).map(e=>[e.exchange,e.market]))};function L(e,r,i,c){let n=_nullishCoalesce(c, () => ([r.exchange])),f=e.toLowerCase();for(let d of P){if(!f.startsWith(d)||e.length<=d.length)continue;let m=e.slice(d.length);if(!/^\d+$/.test(m))continue;let s=A[d];if(s.market!==r.market||!n.includes(s.exchange))throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${i} (prefix '${d}' conflicts with resolved ${r.market}/${r.exchange})`);return{code:m,exchange:s.exchange}}return{code:e,exchange:r.exchange}}function K(e,r){let i=typeof e=="string"?{code:e}:{...e},c=typeof e=="string"?e:e.code,n=String(_nullishCoalesce(i.code, () => (""))).trim(),f=_nullishCoalesce(i.market, () => (_optionalChain([r, 'optionalAccess', _2 => _2.market]))),d=_nullishCoalesce(i.assetType, () => (_optionalChain([r, 'optionalAccess', _3 => _3.assetType]))),m=_nullishCoalesce(i.exchange, () => (_optionalChain([r, 'optionalAccess', _4 => _4.exchange])));if(!n)throw new (0, _chunk4Q7UQ5Q3cjs.f)(String(c));let s=(t,o,a,S,C,h={})=>{if(f&&f!==t)throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (market hint '${f}' conflicts with resolved market ${t})`);if(m){let l=D[m];if(l&&l!==t)throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (exchange hint '${m}' belongs to market ${l}, conflicts with resolved market ${t})`);if(h.exchange&&m!==o)throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (exchange hint '${m}' conflicts with resolved exchange ${o})`)}if(d&&d!==S){if(h.assetType)throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (assetType hint '${d}' conflicts with resolved assetType ${S})`);if(d==="board"||d==="futures")throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (assetType hint '${d}' conflicts with a ${S}-shaped code)`)}return{market:t,exchange:_nullishCoalesce(m, () => (o)),assetType:_nullishCoalesce(d, () => (S)),code:a,variety:C,input:c}},T=t=>s(t.market,t.exchange,t.code,"index",void 0,{exchange:!0,assetType:!0}),b=(t,o)=>o==="HK"&&/^\d+$/.test(t)?t.padStart(5,"0"):o==="US"?t.toUpperCase():t;if(n.includes(".")){let t=n.indexOf("."),o=n.slice(0,t),a=n.slice(t+1),S=o.toUpperCase(),C=a.toUpperCase(),h=u(a);if(h&&h.secidPrefix===o)return T(h);if(/^\d+$/.test(o)&&_[o]){let p=_[o],g=B[o],N=L(a,p,c,g),X=N.exchange,H=!0;if(g&&N.code===a&&/^\d+$/.test(N.code)){let M=$(N.code);g.includes(M)&&(X=M),H=!1}return s(p.market,X,b(N.code,p.market),"stock",void 0,{exchange:H})}let l=a.toLowerCase(),k=Object.prototype.hasOwnProperty.call(A,l)?A[l]:void 0;if(k){if(k.market==="CN"||k.market==="HK"){let g=u(o);if(g)throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (special index code '${g.code}' conflicts with exchange suffix '${a}'; use bare '${g.code}' or secid '${g.secidPrefix}.${g.code}')`)}let p=L(o,k,c);return s(k.market,p.exchange,b(p.code,k.market),"stock",void 0,{exchange:p.exchange!=="US"})}if(y[S]){let p=y[S];return s(p.market,p.exchange,C,"futures",I(a),{exchange:!0,assetType:!0})}if(o==="90")return s("CN","SSE",a,"board",void 0,{exchange:!0,assetType:!0})}let z=n.toLowerCase();for(let t of P)if(z.startsWith(t)&&n.length>t.length){let o=n.slice(t.length),a=A[t];if(a.market==="CN"?/^\d+$/.test(o):/^[0-9A-Za-z]+$/.test(o)){if(a.market==="CN"||a.market==="HK"){let h=u(o);if(h)throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (special index code '${h.code}' conflicts with exchange prefix '${t}'; use bare '${h.code}' or secid '${h.secidPrefix}.${h.code}')`)}let C=a.market==="HK"?o.padStart(5,"0"):a.market==="US"?o.toUpperCase():o;return s(a.market,a.exchange,C,"stock",void 0,{exchange:a.exchange!=="US"})}}let U=u(n);if(U)return T(U);if(/^\d+$/.test(n))return f==="US"?s("US","US",n,"stock"):f==="CN"?s("CN",$(n),n,"stock"):f==="HK"||n.length===5||n.length===4?s("HK","HKEX",n.padStart(5,"0"),"stock",void 0,{exchange:!0}):s("CN",$(n),n,"stock");if((d==="futures"||f==="GLOBAL")&&/[A-Za-z]/.test(n)){let t=m;if(!t&&f==="GLOBAL")throw new (0, _chunk4Q7UQ5Q3cjs.f)(`${c} (GLOBAL futures require an explicit exchange, e.g. { exchange: 'COMEX' })`);let o=t?_optionalChain([y, 'access', _5 => _5[String(t).toUpperCase()], 'optionalAccess', _6 => _6.market]):void 0;return s(_nullishCoalesce(_nullishCoalesce(f, () => (o)), () => ("CN")),_nullishCoalesce(t, () => ("SHFE")),n.toUpperCase(),"futures",I(n),{assetType:!0})}if(/^[A-Za-z][A-Za-z.\-]*$/.test(n))return s("US","US",n.toUpperCase(),"stock");throw new (0, _chunk4Q7UQ5Q3cjs.f)(String(c))}function Z(e){try{return K(e).market}catch (e2){return}}var G={SSE:"1",SZSE:"0",BSE:"0",HKEX:"116",NASDAQ:"105",NYSE:"106",AMEX:"107",US:"105"},j={SSE:"sh",SZSE:"sz",BSE:"bj"};function v(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 r=j[e.exchange];if(!r)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Cannot map to Tencent symbol: unsupported CN exchange '${e.exchange}'`,{exchange:e.exchange,code:e.code});return`${r}${e.code}`}case"HK":if(!/^\d+$/.test(e.code))throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Cannot map to Tencent symbol: HK code '${e.code}' is not numeric`,{market:e.market,code:e.code});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 Y(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.assetType==="index"){let i=u(e.code);if(i&&i.exchange===e.exchange)return`${i.secidPrefix}.${i.code}`}if(e.market==="HK")return`116.${e.code.padStart(5,"0")}`;let r=G[e.exchange];if(!r)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`${r}.${e.code}`}function Q(e){return e.code}exports.a = $; exports.b = y; exports.c = I; exports.d = u; exports.e = K; exports.f = Z; exports.g = G; exports.h = v; exports.i = Y; exports.j = Q;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var c=class{constructor(e={}){this.cache=new Map;this.inflight=new Map;this.defaultTTL=_nullishCoalesce(e.defaultTTL, () => (0)),this.maxSize=_nullishCoalesce(e.maxSize, () => (1e3))}get(e){let t=this.cache.get(e);if(t){if(t.expireAt>0&&Date.now()>t.expireAt){this.cache.delete(e);return}return t.lastAccess=Date.now(),t.value}}set(e,t,i){this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictLRU();let n=_nullishCoalesce(i, () => (this.defaultTTL)),s=Date.now();this.cache.set(e,{value:t,expireAt:n>0?s+n:0,lastAccess:s})}has(e){return this.get(e)!==void 0}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.inflight.clear()}get size(){return this.cache.size}cleanup(){let e=Date.now(),t=0;for(let[i,n]of this.cache)n.expireAt>0&&e>n.expireAt&&(this.cache.delete(i),t++);return t}evictLRU(){let e=null,t=1/0;for(let[i,n]of this.cache)n.lastAccess<t&&(t=n.lastAccess,e=i);e&&this.cache.delete(e)}async getOrFetch(e,t,i){let n=this.get(e);if(n!==void 0)return n;let s=this.inflight.get(e);if(s)return s;let h=t().then(o=>(this.set(e,o,i),o)).finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,h),h}},a=new Map;function u(r,e){let t=a.get(r);if(t)return t;let i=new c(e);return a.set(r,i),i}function l(){for(let r of a.values())r.clear()}function f(...r){return r.map(e=>e==null?"\u2205":String(e)).join(":")}exports.a = c; exports.b = u; exports.c = l; exports.d = f;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTVIEKKDQcjs = require('./chunk-TVIEKKDQ.cjs');var m=class{constructor(e){this.cache=new (0, _chunkTVIEKKDQcjs.a)(e)}get(e){return this.cache.get(e)}set(e,r,i){this.cache.set(e,r,i)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}},u=new WeakMap;async function y(n,e,r,i){let s=await n.get(e);if(s!==void 0)return s;let t=u.get(n);t||(t=new Map,u.set(n,t));let o=t.get(e);if(o)return o;let c=(async()=>{let a=await r();return a!==void 0&&await n.set(e,a,i),a})().finally(()=>{t.delete(e)});return t.set(e,c),c}exports.a = m; exports.b = y;
@@ -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 b(e,t=3){let s=Math.pow(10,t);return Math.round(e*s)/s}var A=class{constructor(t,s){this.sum=0;this.comp=0;this.count=0;this.data=t,this.period=s}advance(t){let s=this.data[t];if(s!==null&&(this.add(s),this.count++),t>=this.period){let u=this.data[t-this.period];u!==null&&(this.add(-u),this.count--)}Number.isFinite(this.sum)||this.refill(t)}get value(){return this.sum}get nonNullCount(){return this.count}add(t){let s=t-this.comp,u=this.sum+s;this.comp=u-this.sum-s,this.sum=u}refill(t){this.sum=0,this.comp=0;let s=Math.max(0,t-this.period+1);for(let u=s;u<=t;u++){let i=this.data[u];i!==null&&this.add(i)}}};function j(e,t,s){let u=new Array(e.length),i=new A(e,t);for(let r=0;r<e.length;r++)i.advance(r),u[r]=r>=t-1&&i.nonNullCount===t?b(i.value/t,s):null;return u}function D(e,t,s){let u=[],i=2/(t+1),r=null,o=!1;for(let n=0;n<e.length;n++){if(n<t-1){u.push(null);continue}if(!o){let c=0,a=0;for(let m=n-t+1;m<=n;m++)e[m]!==null&&(c+=e[m],a++);a===t&&(r=c/t,o=!0),u.push(r!==null?b(r,s):null);continue}let l=e[n];l===null?u.push(r!==null?b(r,s):null):(r=i*l+(1-i)*r,u.push(b(r,s)))}return u}function re(e,t,s){let u=[],i=Array.from({length:t},(o,n)=>n+1),r=i.reduce((o,n)=>o+n,0);for(let o=0;o<e.length;o++){if(o<t-1){u.push(null);continue}let n=0,l=!0;for(let c=0;c<t;c++){let a=e[o-t+1+c];if(a===null){l=!1;break}n+=a*i[c]}u.push(l?b(n/r,s):null)}return u}function J(e,t={}){let{periods:s=[5,10,20,30,60,120,250],type:u="sma",decimals:i}=t,r=u==="ema"?D:u==="wma"?re:j,o={};for(let n of s)o[`ma${n}`]=r(e,n,i);return e.map((n,l)=>{let c={};for(let a of s)c[`ma${a}`]=o[`ma${a}`][l];return c})}function F(e,t={}){let{short:s=12,long:u=26,signal:i=9,decimals:r}=t,o=D(e,s,r),n=D(e,u,r),l=e.map((a,m)=>o[m]===null||n[m]===null?null:o[m]-n[m]),c=D(l,i,r);return e.map((a,m)=>({dif:l[m]!==null?b(l[m],r):null,dea:c[m],macd:l[m]!==null&&c[m]!==null?b((l[m]-c[m])*2,r):null}))}function ae(e,t,s){let u=new Array(e.length),i=e.map(n=>n===null?null:n*n),r=new A(e,t),o=new A(i,t);for(let n=0;n<e.length;n++){r.advance(n),o.advance(n);let l=s[n];if(n<t-1||l===null){u[n]=null;continue}if(r.nonNullCount!==t){u[n]=null;continue}let c=o.value-2*l*r.value+t*l*l;u[n]=Math.sqrt(Math.max(0,c)/t)}return u}function q(e,t={}){let{period:s=20,stdDev:u=2,decimals:i}=t,r=j(e,s,i),o=ae(e,s,r);return e.map((n,l)=>{if(r[l]===null||o[l]===null)return{mid:null,upper:null,lower:null,bandwidth:null};let c=r[l]+u*o[l],a=r[l]-u*o[l],m=r[l]!==0?b((c-a)/r[l]*100,i):null;return{mid:r[l],upper:b(c,i),lower:b(a,i),bandwidth:m}})}function G(e,t={}){let{period:s=9,kPeriod:u=3,dPeriod:i=3,decimals:r}=t,o=[],n=50,l=50,c=[],a=0,m=[],f=0,h=0;for(let d=0;d<e.length;d++){let p=e[d];if(p.high===null||p.low===null)h++;else{for(;c.length>a&&e[c[c.length-1]].high<=p.high;)c.pop();for(c.push(d);m.length>f&&e[m[m.length-1]].low>=p.low;)m.pop();m.push(d)}let R=d-s+1;if(d>=s){let g=e[d-s];(g.high===null||g.low===null)&&h--}for(;c.length>a&&c[a]<R;)a++;for(;m.length>f&&m[f]<R;)f++;if(d<s-1){o.push({k:null,d:null,j:null});continue}let y=c.length>a?e[c[a]].high:-1/0,w=m.length>f?e[m[f]].low:1/0,v=e[d].close;if(h>0||v===null||y===w){o.push({k:null,d:null,j:null});continue}let S=(v-w)/(y-w)*100;n=(u-1)/u*n+1/u*S,l=(i-1)/i*l+1/i*n;let L=3*n-2*l;o.push({k:b(n,r),d:b(l,r),j:b(L,r)})}return o}function U(e,t={}){let{periods:s=[6,12,24],decimals:u}=t,i=[null];for(let o=1;o<e.length;o++)e[o]===null||e[o-1]===null?i.push(null):i.push(e[o]-e[o-1]);let r={};for(let o of s){let n=[],l=0,c=0;for(let a=0;a<e.length;a++){if(a<o){n.push(null),i[a]!==null&&(i[a]>0?l+=i[a]:c+=Math.abs(i[a]));continue}if(a===o)i[a]!==null&&(i[a]>0?l+=i[a]:c+=Math.abs(i[a])),l=l/o,c=c/o;else{let m=_nullishCoalesce(i[a], () => (0)),f=m>0?m:0,h=m<0?Math.abs(m):0;l=(l*(o-1)+f)/o,c=(c*(o-1)+h)/o}if(c===0)n.push(100);else if(l===0)n.push(0);else{let m=l/c;n.push(b(100-100/(1+m),u))}}r[`rsi${o}`]=n}return e.map((o,n)=>{let l={};for(let c of s)l[`rsi${c}`]=r[`rsi${c}`][n];return l})}function Y(e,t={}){let{periods:s=[6,10],decimals:u}=t,i={};for(let r of s){let o=[];for(let n=0;n<e.length;n++){if(n<r-1){o.push(null);continue}let l=-1/0,c=1/0,a=!0;for(let h=n-r+1;h<=n;h++){if(e[h].high===null||e[h].low===null){a=!1;break}l=Math.max(l,e[h].high),c=Math.min(c,e[h].low)}let m=e[n].close;if(!a||m===null||l===c){o.push(null);continue}let f=(l-m)/(l-c)*100;o.push(b(f,u))}i[`wr${r}`]=o}return e.map((r,o)=>{let n={};for(let l of s)n[`wr${l}`]=i[`wr${l}`][o];return n})}function z(e,t={}){let{periods:s=[6,12,24],decimals:u}=t,i={};for(let r of s){let o=j(e,r,u),n=[];for(let l=0;l<e.length;l++)if(e[l]===null||o[l]===null||o[l]===0)n.push(null);else{let c=(e[l]-o[l])/o[l]*100;n.push(b(c,u))}i[`bias${r}`]=n}return e.map((r,o)=>{let n={};for(let l of s)n[`bias${l}`]=i[`bias${l}`][o];return n})}function Q(e,t={}){let{period:s=14,decimals:u}=t,i=[],r=e.map(o=>o.high===null||o.low===null||o.close===null?null:(o.high+o.low+o.close)/3);for(let o=0;o<e.length;o++){if(o<s-1){i.push({cci:null});continue}let n=0,l=0;for(let f=o-s+1;f<=o;f++)r[f]!==null&&(n+=r[f],l++);if(l!==s||r[o]===null){i.push({cci:null});continue}let c=n/s,a=0;for(let f=o-s+1;f<=o;f++)a+=Math.abs(r[f]-c);let m=a/s;if(m===0)i.push({cci:0});else{let f=(r[o]-c)/(.015*m);i.push({cci:b(f,u)})}}return i}function T(e,t={}){let{period:s=14,decimals:u}=t,i=[],r=[];for(let n=0;n<e.length;n++){let{high:l,low:c,close:a}=e[n];if(l===null||c===null||a===null){r.push(null);continue}if(n===0)r.push(l-c);else{let m=e[n-1].close;if(m===null)r.push(l-c);else{let f=l-c,h=Math.abs(l-m),d=Math.abs(c-m);r.push(Math.max(f,h,d))}}}let o=null;for(let n=0;n<e.length;n++){if(n<s-1){i.push({tr:r[n]!==null?b(r[n],u):null,atr:null});continue}if(n===s-1){let l=0,c=0;for(let a=0;a<s;a++)r[a]!==null&&(l+=r[a],c++);c===s&&(o=l/s)}else o!==null&&r[n]!==null&&(o=(o*(s-1)+r[n])/s);i.push({tr:r[n]!==null?b(r[n],u):null,atr:o!==null?b(o,u):null})}return i}function X(e,t={}){let{maPeriod:s}=t,u=[];if(e.length===0)return u;let i=_nullishCoalesce(e[0].volume, () => (0));u.push({obv:i,obvMa:null});for(let r=1;r<e.length;r++){let o=e[r],n=e[r-1];if(o.close===null||n.close===null||o.volume===null||o.volume===void 0){u.push({obv:null,obvMa:null});continue}o.close>n.close?i+=o.volume:o.close<n.close&&(i-=o.volume),u.push({obv:i,obvMa:null})}if(s&&s>0){let r=u.map(n=>n.obv),o=new A(r,s);for(let n=0;n<u.length;n++)o.advance(n),n>=s-1&&o.nonNullCount===s&&(u[n].obvMa=o.value/s)}return u}function Z(e,t={}){let{period:s=12,signalPeriod:u}=t,i=[];for(let r=0;r<e.length;r++){if(r<s){i.push({roc:null,signal:null});continue}let o=e[r].close,n=e[r-s].close;if(o===null||n===null||n===0){i.push({roc:null,signal:null});continue}let l=(o-n)/n*100;i.push({roc:l,signal:null})}if(u&&u>0){let r=i.map(n=>n.roc),o=new A(r,u);for(let n=0;n<i.length;n++)o.advance(n),n>=s+u-1&&o.nonNullCount===u&&(i[n].signal=o.value/u)}return i}function ee(e,t={}){let{period:s=14,adxPeriod:u=s}=t,i=[];if(e.length<2)return e.map(()=>({pdi:null,mdi:null,adx:null,adxr:null}));let r=[],o=[],n=[];for(let p=0;p<e.length;p++){if(p===0){r.push(0),o.push(0),n.push(0),i.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let R=e[p],y=e[p-1];if(R.high===null||R.low===null||R.close===null||y.high===null||y.low===null||y.close===null){r.push(0),o.push(0),n.push(0),i.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let w=R.high-R.low,v=Math.abs(R.high-y.close),S=Math.abs(R.low-y.close);n.push(Math.max(w,v,S));let L=R.high-y.high,g=y.low-R.low;L>g&&L>0?r.push(L):r.push(0),g>L&&g>0?o.push(g):o.push(0),i.push({pdi:null,mdi:null,adx:null,adxr:null})}let l=0,c=0,a=0,m=[];for(let p=1;p<e.length;p++){if(p<s){l+=n[p],c+=r[p],a+=o[p],m.push(0);continue}p===s?(l+=n[p],c+=r[p],a+=o[p]):(l=l-l/s+n[p],c=c-c/s+r[p],a=a-a/s+o[p]);let R=l>0?c/l*100:0,y=l>0?a/l*100:0;i[p].pdi=R,i[p].mdi=y;let w=R+y,v=w>0?Math.abs(R-y)/w*100:0;m.push(v)}let f=0,h=0,d=s+u-1;for(let p=s;p<e.length;p++){if(p<d){f+=m[p-1]||0;continue}if(p===d)f+=m[p-1]||0,h=f/u,i[p].adx=h;else{let R=m[p-1]||0;h=(h*(u-1)+R)/u,i[p].adx=h}}for(let p=d+u;p<e.length;p++){let R=i[p].adx,y=_optionalChain([i, 'access', _2 => _2[p-u], 'optionalAccess', _3 => _3.adx]);R!==null&&y!==null&&(i[p].adxr=(R+y)/2)}return i}function te(e,t={}){let{afStart:s=.02,afIncrement:u=.02,afMax:i=.2}=t,r=[];if(e.length<2)return e.map(()=>({sar:null,trend:null,ep:null,af:null}));let o=1,n=s,l=_nullishCoalesce(e[0].high, () => (0)),c=_nullishCoalesce(e[0].low, () => (0)),a=e[0],m=e[1];a.close!==null&&m.close!==null&&m.close<a.close&&(o=-1,l=_nullishCoalesce(a.low, () => (0)),c=_nullishCoalesce(a.high, () => (0))),r.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){r.push({sar:null,trend:null,ep:null,af:null});continue}let p=c+n*(l-c);o===1?(p=Math.min(p,d.low,_nullishCoalesce(_optionalChain([e, 'access', _4 => _4[Math.max(0,f-2)], 'optionalAccess', _5 => _5.low]), () => (d.low))),h.low<p?(o=-1,p=l,l=h.low,n=s):h.high>l&&(l=h.high,n=Math.min(n+u,i))):(p=Math.max(p,d.high,_nullishCoalesce(_optionalChain([e, 'access', _6 => _6[Math.max(0,f-2)], 'optionalAccess', _7 => _7.high]), () => (d.high))),h.high>p?(o=1,p=l,l=h.high,n=s):h.low<l&&(l=h.low,n=Math.min(n+u,i))),c=p,r.push({sar:c,trend:o,ep:l,af:n})}return r}function ne(e,t={}){let{emaPeriod:s=20,atrPeriod:u=10,multiplier:i=2}=t,r=[],o=e.map(c=>c.close),n=D(o,s),l=T(e,{period:u});for(let c=0;c<e.length;c++){let a=n[c],m=_optionalChain([l, 'access', _8 => _8[c], 'optionalAccess', _9 => _9.atr]);if(a===null||m===null){r.push({mid:null,upper:null,lower:null,width:null});continue}let f=a+i*m,h=a-i*m,d=a>0?(f-h)/a*100:null;r.push({mid:a,upper:f,lower:h,width:d})}return r}var k=150;function le(e){return e.open!==null&&e.high!==null&&e.low!==null&&e.close!==null}function pe(e){return Number(e.toPrecision(12))}function E(e){return Number(e.toFixed(2))}function ue(e){return{date:e,profitRatio:null,avgCost:null,cost90Low:null,cost90High:null,concentration90:null,cost70Low:null,cost70High:null,concentration70:null}}function fe(e,t={}){let{range:s=120,tail:u,includeHistogram:i=!1,decimals:r=3}=t,o=e.length;if(o===0)return[];let n=u!==void 0?o-Math.min(o,Math.max(0,Math.floor(u))):0,l=i===!0?"last":i||!1,c=[];for(let a=n;a<o;a++){let m=l==="all"||l==="last"&&a===o-1;c.push(he(e,a,s,r,m))}return c}function he(e,t,s,u,i){let r=e[t].date,o=s?Math.max(0,t-s+1):0,n=e.slice(o,Math.max(1,t+1)),l=-1/0,c=1/0,a=!1;for(let g of n)le(g)&&(a=!0,l=Math.max(l,g.high),c=Math.min(c,g.low));if(!a)return ue(r);let m=Math.max(.01,(l-c)/(k-1)),f=new Array(k).fill(0);for(let g of n){if(!le(g))continue;let{open:I,close:x,high:C,low:M}=g,K=(I+x+C+M)/4,B=Math.max(0,Math.min(1,(_nullishCoalesce(g.turnoverRate, () => (0)))/100||0)),N=O=>Math.min(k-1,Math.max(0,O)),se=N(Math.floor((C-c)/m)),ie=N(Math.ceil((M-c)/m)),V=C===M?k-1:2/(C-M),ce=N(Math.floor((K-c)/m));for(let O=0;O<f.length;O++)f[O]*=1-B;if(C===M)f[ce]+=V*B/2;else for(let O=ie;O<=se;O++){let $=c+m*O;$<=K?f[O]+=Math.abs(K-M)<1e-8?V*B:($-M)/(K-M)*V*B:f[O]+=Math.abs(C-K)<1e-8?V*B:(C-$)/(C-K)*V*B}}let h=new Array(k),d=0;for(let g=0;g<k;g++)h[g]=pe(f[g]),d+=h[g];if(d===0)return ue(r);let p=g=>{let I=0,x=0;for(let C=0;C<k;C++){let M=h[C];if(x+M>g){I=c+C*m;break}x+=M}return I},R=g=>{let I=0;for(let x=0;x<k;x++)g>=c+x*m&&(I+=h[x]);return I/d},y=g=>{let I=p(d*((1-g)/2)),x=p(d*((1+g)/2));return{low:E(I),high:E(x),concentration:I+x===0?0:(x-I)/(I+x)}},w=e[t].close,v=y(.9),S=y(.7),L={date:r,profitRatio:w!==null?b(R(w),u):null,avgCost:E(p(d*.5)),cost90Low:v.low,cost90High:v.high,concentration90:b(v.concentration,u),cost70Low:S.low,cost70High:S.high,concentration70:b(S.concentration,u)};if(i){let g=new Array(k),I=new Array(k);for(let x=0;x<k;x++)g[x]=E(c+m*x),I[x]=b(h[x]/d,6);L.histogram={prices:g,ratios:I}}return L}function W(e,t=0){return e.length===0?t:Math.max(...e)}function oe(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 H={ma:{key:"ma",estimateLookback:e=>{let t=typeof e=="object"?e:{},s=_nullishCoalesce(t.periods, () => ([5,10,20,30,60,120,250])),u=_nullishCoalesce(t.type, () => ("sma"));return{bars:W(s,20),emaBased:u==="ema"}},compute:(e,t)=>J(e.closes,typeof t=="object"?t:{})},macd:{key:"macd",recursive:!0,estimateLookback:e=>{let t=typeof e=="object"?e:{},s=_nullishCoalesce(t.long, () => (26)),u=_nullishCoalesce(t.signal, () => (9));return{bars:s*3+u,emaBased:!0}},compute:(e,t)=>F(e.closes,typeof t=="object"?t:{})},boll:{key:"boll",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:20}),compute:(e,t)=>q(e.closes,typeof t=="object"?t:{})},kdj:{key:"kdj",recursive:!0,estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:9}),compute:(e,t)=>G(e.ohlcv,typeof t=="object"?t:{})},rsi:{key:"rsi",recursive:!0,estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,12,24];return{bars:W(t,14)+1}},compute:(e,t)=>U(e.closes,typeof t=="object"?t:{})},wr:{key:"wr",estimateLookback:e=>{let t=typeof e=="object"&&e.periods?e.periods:[6,10];return{bars:W(t,10)}},compute:(e,t)=>Y(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:W(t,12)}},compute:(e,t)=>z(e.closes,typeof t=="object"?t:{})},cci:{key:"cci",estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:14}),compute:(e,t)=>Q(e.ohlcv,typeof t=="object"?t:{})},atr:{key:"atr",recursive:!0,estimateLookback:e=>({bars:typeof e=="object"&&e.period?e.period:14}),compute:(e,t)=>T(e.ohlcv,typeof t=="object"?t:{})},obv:{key:"obv",cumulative:!0,estimateLookback:e=>{let t=typeof e=="object"&&e.maPeriod?e.maPeriod:0;return{bars:Math.max(2,t)}},compute:(e,t)=>X(e.ohlcv,typeof t=="object"?t:{})},roc:{key:"roc",estimateLookback:e=>{let t=typeof e=="object"?e:{},s=_nullishCoalesce(t.period, () => (12)),u=_nullishCoalesce(t.signalPeriod, () => (0));return{bars:s+u}},compute:(e,t)=>Z(e.ohlcv,typeof t=="object"?t:{})},dmi:{key:"dmi",recursive:!0,estimateLookback:e=>{let t=typeof e=="object"?e:{},s=_nullishCoalesce(t.period, () => (14)),u=_nullishCoalesce(t.adxPeriod, () => (s));return{bars:s*2+u}},compute:(e,t)=>ee(e.ohlcv,typeof t=="object"?t:{})},sar:{key:"sar",recursive:!0,estimateLookback:()=>({bars:5}),compute:(e,t)=>te(e.ohlcv,typeof t=="object"?t:{})},kc:{key:"kc",recursive:!0,estimateLookback:e=>{let t=typeof e=="object"?e:{},s=_nullishCoalesce(t.emaPeriod, () => (20)),u=_nullishCoalesce(t.atrPeriod, () => (10));return{bars:Math.max(s*3,u),emaBased:!0}},compute:(e,t)=>ne(e.ohlcv,typeof t=="object"?t:{})}},be=["ma","rsi","wr","bias"];function _(e){let t=null;for(let s of be){let u=e[s];if(Array.isArray(u))(_nullishCoalesce(t, () => ((t={...e}))))[s]={periods:u};else if(u&&typeof u=="object"&&!("periods"in u)&&typeof u.period=="number"){let{period:i,...r}=u;(_nullishCoalesce(t, () => ((t={...e}))))[s]={...r,periods:[i]}}}return _nullishCoalesce(t, () => (e))}function de(e){return P(_(e)).some(t=>H[t].cumulative===!0)}function P(e){return Object.keys(H).filter(t=>!!e[t])}function ge(e){e=_(e);let t=0,s=0,u=!1;for(let r of P(e)){let o=H[r],n=o.estimateLookback(e[r]);t=Math.max(t,n.bars),u||(u=!!n.emaBased),(o.recursive===!0||n.emaBased===!0)&&(s=Math.max(s,n.bars))}return{maxLookback:t,hasEmaBasedIndicator:u,requiredBars:Math.ceil(t*(u?1.5:1.2)),maxRecursiveLookback:s}}function Re(e,t={}){if(e.length===0)return[];t=_(t);let s=oe(e),u=new Map;for(let o of P(t)){let n=H[o];u.set(o,n.compute(s,t[o]))}let i=[],r=[];for(let[o,n]of u)i.push(o),r.push(n);return e.map((o,n)=>{let l={...o},c=l;for(let a=0;a<i.length;a++)c[i[a]]=r[a][n];return l})}exports.a = j; exports.b = D; exports.c = re; exports.d = J; exports.e = F; exports.f = q; exports.g = G; exports.h = U; exports.i = Y; exports.j = z; exports.k = Q; exports.l = T; exports.m = X; exports.n = Z; exports.o = ee; exports.p = te; exports.q = ne; exports.r = fe; exports.s = oe; exports.t = H; exports.u = de; exports.v = P; exports.w = ge; exports.x = Re;
@@ -1 +0,0 @@
1
- import{e as E,f as x}from"./chunk-UBIQBXQ7.js";function $(e){if(e.startsWith("92")||/^[48]/.test(e))return"BSE";let r=e[0];return r==="6"||r==="5"||r==="9"?"SSE":"SZSE"}var y={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 I(e){let r=e.match(/^([A-Za-z]+)/);return(r?r[1]:e).toUpperCase()}var w={market:"CN",exchange:"CSI",secidPrefix:"2"},F=[/^93\d{4}$/,/^H\d{5}$/],O={HSHCI:{market:"HK",exchange:"HSI",secidPrefix:"124"},GDAXI:{market:"GLOBAL",exchange:"DAX",secidPrefix:"100"}},R=[[w.exchange,w.market],...Object.values(O).map(e=>[e.exchange,e.market])];function u(e){let r=e.toUpperCase();if(F.some(c=>c.test(r)))return{...w,code:r};let i=O[r];return i?{...i,code:r}:void 0}var A={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"}},P=Object.keys(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"}},B={0:["SZSE","BSE"]},D={SSE:"CN",SZSE:"CN",BSE:"CN",HKEX:"HK",NASDAQ:"US",NYSE:"US",AMEX:"US",US:"US",...Object.fromEntries(R),...Object.fromEntries(Object.values(y).map(e=>[e.exchange,e.market]))};function L(e,r,i,c){let n=c??[r.exchange],f=e.toLowerCase();for(let d of P){if(!f.startsWith(d)||e.length<=d.length)continue;let m=e.slice(d.length);if(!/^\d+$/.test(m))continue;let s=A[d];if(s.market!==r.market||!n.includes(s.exchange))throw new x(`${i} (prefix '${d}' conflicts with resolved ${r.market}/${r.exchange})`);return{code:m,exchange:s.exchange}}return{code:e,exchange:r.exchange}}function K(e,r){let i=typeof e=="string"?{code:e}:{...e},c=typeof e=="string"?e:e.code,n=String(i.code??"").trim(),f=i.market??r?.market,d=i.assetType??r?.assetType,m=i.exchange??r?.exchange;if(!n)throw new x(String(c));let s=(t,o,a,S,C,h={})=>{if(f&&f!==t)throw new x(`${c} (market hint '${f}' conflicts with resolved market ${t})`);if(m){let l=D[m];if(l&&l!==t)throw new x(`${c} (exchange hint '${m}' belongs to market ${l}, conflicts with resolved market ${t})`);if(h.exchange&&m!==o)throw new x(`${c} (exchange hint '${m}' conflicts with resolved exchange ${o})`)}if(d&&d!==S){if(h.assetType)throw new x(`${c} (assetType hint '${d}' conflicts with resolved assetType ${S})`);if(d==="board"||d==="futures")throw new x(`${c} (assetType hint '${d}' conflicts with a ${S}-shaped code)`)}return{market:t,exchange:m??o,assetType:d??S,code:a,variety:C,input:c}},T=t=>s(t.market,t.exchange,t.code,"index",void 0,{exchange:!0,assetType:!0}),b=(t,o)=>o==="HK"&&/^\d+$/.test(t)?t.padStart(5,"0"):o==="US"?t.toUpperCase():t;if(n.includes(".")){let t=n.indexOf("."),o=n.slice(0,t),a=n.slice(t+1),S=o.toUpperCase(),C=a.toUpperCase(),h=u(a);if(h&&h.secidPrefix===o)return T(h);if(/^\d+$/.test(o)&&_[o]){let p=_[o],g=B[o],N=L(a,p,c,g),X=N.exchange,H=!0;if(g&&N.code===a&&/^\d+$/.test(N.code)){let M=$(N.code);g.includes(M)&&(X=M),H=!1}return s(p.market,X,b(N.code,p.market),"stock",void 0,{exchange:H})}let l=a.toLowerCase(),k=Object.prototype.hasOwnProperty.call(A,l)?A[l]:void 0;if(k){if(k.market==="CN"||k.market==="HK"){let g=u(o);if(g)throw new x(`${c} (special index code '${g.code}' conflicts with exchange suffix '${a}'; use bare '${g.code}' or secid '${g.secidPrefix}.${g.code}')`)}let p=L(o,k,c);return s(k.market,p.exchange,b(p.code,k.market),"stock",void 0,{exchange:p.exchange!=="US"})}if(y[S]){let p=y[S];return s(p.market,p.exchange,C,"futures",I(a),{exchange:!0,assetType:!0})}if(o==="90")return s("CN","SSE",a,"board",void 0,{exchange:!0,assetType:!0})}let z=n.toLowerCase();for(let t of P)if(z.startsWith(t)&&n.length>t.length){let o=n.slice(t.length),a=A[t];if(a.market==="CN"?/^\d+$/.test(o):/^[0-9A-Za-z]+$/.test(o)){if(a.market==="CN"||a.market==="HK"){let h=u(o);if(h)throw new x(`${c} (special index code '${h.code}' conflicts with exchange prefix '${t}'; use bare '${h.code}' or secid '${h.secidPrefix}.${h.code}')`)}let C=a.market==="HK"?o.padStart(5,"0"):a.market==="US"?o.toUpperCase():o;return s(a.market,a.exchange,C,"stock",void 0,{exchange:a.exchange!=="US"})}}let U=u(n);if(U)return T(U);if(/^\d+$/.test(n))return f==="US"?s("US","US",n,"stock"):f==="CN"?s("CN",$(n),n,"stock"):f==="HK"||n.length===5||n.length===4?s("HK","HKEX",n.padStart(5,"0"),"stock",void 0,{exchange:!0}):s("CN",$(n),n,"stock");if((d==="futures"||f==="GLOBAL")&&/[A-Za-z]/.test(n)){let t=m;if(!t&&f==="GLOBAL")throw new x(`${c} (GLOBAL futures require an explicit exchange, e.g. { exchange: 'COMEX' })`);let o=t?y[String(t).toUpperCase()]?.market:void 0;return s(f??o??"CN",t??"SHFE",n.toUpperCase(),"futures",I(n),{assetType:!0})}if(/^[A-Za-z][A-Za-z.\-]*$/.test(n))return s("US","US",n.toUpperCase(),"stock");throw new x(String(c))}function Z(e){try{return K(e).market}catch{return}}var G={SSE:"1",SZSE:"0",BSE:"0",HKEX:"116",NASDAQ:"105",NYSE:"106",AMEX:"107",US:"105"},j={SSE:"sh",SZSE:"sz",BSE:"bj"};function v(e){if(e.assetType==="board"||e.assetType==="futures"||e.assetType==="option")throw new E(`Tencent quote symbol does not support assetType '${e.assetType}'`,{assetType:e.assetType,code:e.code});switch(e.market){case"CN":{let r=j[e.exchange];if(!r)throw new E(`Cannot map to Tencent symbol: unsupported CN exchange '${e.exchange}'`,{exchange:e.exchange,code:e.code});return`${r}${e.code}`}case"HK":if(!/^\d+$/.test(e.code))throw new E(`Cannot map to Tencent symbol: HK code '${e.code}' is not numeric`,{market:e.market,code:e.code});return`hk${e.code.padStart(5,"0")}`;case"US":return`us${e.code}`;default:throw new E(`Cannot map to Tencent symbol: unsupported market '${e.market}'`,{market:e.market,code:e.code})}}function Y(e){if(e.assetType==="board")return`90.${e.code}`;if(e.assetType==="futures"||e.assetType==="option")throw new 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.assetType==="index"){let i=u(e.code);if(i&&i.exchange===e.exchange)return`${i.secidPrefix}.${i.code}`}if(e.market==="HK")return`116.${e.code.padStart(5,"0")}`;let r=G[e.exchange];if(!r)throw new E(`Cannot map to Eastmoney secid: unsupported exchange '${e.exchange}' (market=${e.market})`,{exchange:e.exchange,market:e.market,code:e.code});return`${r}.${e.code}`}function Q(e){return e.code}export{$ as a,y as b,I as c,u as d,K as e,Z as f,G as g,v as h,Y as i,Q as j};