stock-sdk 2.2.1 → 2.3.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 +4 -1
- package/dist/{addIndicators-DQNysyLs.d.cts → addIndicators-_V3HEi0q.d.cts} +18 -0
- package/dist/{addIndicators-DQNysyLs.d.ts → addIndicators-_V3HEi0q.d.ts} +18 -0
- package/dist/chip-BbA23rr1.d.cts +113 -0
- package/dist/chip-BbA23rr1.d.ts +113 -0
- package/dist/chunk-3ASJZ3YA.js +1 -0
- package/dist/chunk-6IFA2HGD.cjs +1 -0
- package/dist/chunk-IWHFCLJM.js +1 -0
- package/dist/chunk-LMUFSVKQ.cjs +1 -0
- package/dist/chunk-QGYIBFXP.js +1 -0
- package/dist/chunk-ZESMWMHP.cjs +1 -0
- package/dist/cli.cjs +6 -6
- package/dist/cli.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/indicators.cjs +1 -1
- package/dist/indicators.d.cts +8 -7
- package/dist/indicators.d.ts +8 -7
- package/dist/indicators.js +1 -1
- package/dist/mcp.cjs +2 -2
- package/dist/mcp.d.cts +3 -2
- package/dist/mcp.d.ts +3 -2
- package/dist/mcp.js +2 -2
- package/dist/{sdk-C1spOI0V.d.cts → sdk-6Qozazec.d.cts} +134 -6
- package/dist/{sdk-tyHVl5Ki.d.ts → sdk-CtqVdrof.d.ts} +134 -6
- package/dist/signals.d.cts +1 -1
- package/dist/signals.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-G5KF73BW.js +0 -1
- package/dist/chunk-LNFNYJHT.cjs +0 -1
- package/dist/chunk-PMERLSCU.cjs +0 -1
- package/dist/chunk-RHTNYDO2.cjs +0 -1
- package/dist/chunk-TXJPUZJI.js +0 -1
- package/dist/chunk-WHIIIKKO.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
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;
|
package/dist/cli.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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
|
|
3
|
-
${n.hint}`:"";return{text:`stock-sdk: ${o}${r}`}}let e=_chunk4Q7UQ5Q3cjs.k.call(void 0, n);return t==="json"?{text:JSON.stringify({error:{code:e,message:o}})}:{text:`stock-sdk: ${e}: ${o}`}}var bn={start:"startDate",end:"endDate"},Cn=new Set(["format","f","pretty","quiet","q","help","h","version","V","timeout"]),En=new Set(["limit"]);function B(n){return Cn.has(n)||En.has(n)}function An(n,t){let o={},e=new Map;for(let r of _nullishCoalesce(n.options, () => ([])))e.set(r.flag,r);for(let[r,s]of Object.entries(t)){if(B(r))continue;let c=e.get(r);if(!c){if(s===!0)continue;o[_nullishCoalesce(bn[r], () => (r))]=s;continue}o[_nullishCoalesce(c.field, () => (c.flag))]=Pn(c,s)}for(let r of _nullishCoalesce(n.options, () => ([]))){let s=_nullishCoalesce(r.field, () => (r.flag));o[s]===void 0&&r.default!==void 0&&(o[s]=r.default)}return o}function Pn(n,t){switch(n.type){case"boolean":return t===!0||t==="true";case"number":return Number(S(t));case"number[]":return E(t);case"enum":case"string":{let o=S(t),e=typeof o=="boolean"?o:String(o);if(n.upper&&typeof e=="string"&&(e=e.toUpperCase()),n.type==="enum"&&n.enum&&typeof e=="string"&&!n.enum.includes(e))throw new p(`--${n.flag} \u975E\u6CD5\u503C\u300C${e}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return n.map&&typeof e=="string"&&e in n.map&&(e=n.map[e]),e}default:return t}}function S(n){return Array.isArray(n)?n[n.length-1]:n}function E(n){return(Array.isArray(n)?n.join(","):String(n)).split(",").map(o=>o.trim()).filter(o=>o.length>0).map(o=>Number(o)).filter(o=>Number.isInteger(o)&&o>0)}function H(n,t){let o=_nullishCoalesce(n.positional, () => ([])),e=[],r=0;for(let s of o){if(s.variadic){let d=t.slice(r);if(s.required&&d.length===0)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);for(let i of d)e.push(J(s,i));return e}let c=t[r];if(c===void 0){if(s.required)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);e.push(void 0)}else e.push(J(s,c));r++}return e}function J(n,t){let o=t;if(n.upper&&(o=o.toUpperCase()),n.enum&&!n.enum.includes(o))throw new p(`<${n.name}> \u975E\u6CD5\u503C\u300C${t}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return o}function m(n,t,o){let e=
|
|
2
|
+
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunk6IFA2HGDcjs = require('./chunk-6IFA2HGD.cjs');var _chunkLMUFSVKQcjs = require('./chunk-LMUFSVKQ.cjs');require('./chunk-ZESMWMHP.cjs');var _chunkT5CH7H3Xcjs = require('./chunk-T5CH7H3X.cjs');require('./chunk-TVIEKKDQ.cjs');var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');require('./chunk-4VDLQK6F.cjs');var p=class extends Error{constructor(t,o){super(t),this.name="CliUsageError",this.hint=o}},On={INVALID_ARGUMENT:2,INVALID_SYMBOL:2,NOT_FOUND:2,NETWORK_ERROR:3,TIMEOUT:3,ABORTED:3,UPSTREAM_ERROR:4,UPSTREAM_EMPTY:4,PARSE_ERROR:4,HTTP_ERROR:4,RATE_LIMITED:5,CIRCUIT_OPEN:5};function V(n){if(n instanceof p)return 2;let t=_chunk4Q7UQ5Q3cjs.k.call(void 0, n);return _nullishCoalesce(On[t], () => (1))}function G(n,t){let o=n instanceof Error?n.message:String(n);if(n instanceof p){if(t==="json")return{text:JSON.stringify({error:{code:"USAGE",message:o}})};let r=n.hint?`
|
|
3
|
+
${n.hint}`:"";return{text:`stock-sdk: ${o}${r}`}}let e=_chunk4Q7UQ5Q3cjs.k.call(void 0, n);return t==="json"?{text:JSON.stringify({error:{code:e,message:o}})}:{text:`stock-sdk: ${e}: ${o}`}}var bn={start:"startDate",end:"endDate"},Cn=new Set(["format","f","pretty","quiet","q","help","h","version","V","timeout"]),En=new Set(["limit"]);function B(n){return Cn.has(n)||En.has(n)}function An(n,t){let o={},e=new Map;for(let r of _nullishCoalesce(n.options, () => ([])))e.set(r.flag,r);for(let[r,s]of Object.entries(t)){if(B(r))continue;let c=e.get(r);if(!c){if(s===!0)continue;o[_nullishCoalesce(bn[r], () => (r))]=s;continue}o[_nullishCoalesce(c.field, () => (c.flag))]=Pn(c,s)}for(let r of _nullishCoalesce(n.options, () => ([]))){let s=_nullishCoalesce(r.field, () => (r.flag));o[s]===void 0&&r.default!==void 0&&(o[s]=r.default)}return o}function Pn(n,t){switch(n.type){case"boolean":return t===!0||t==="true";case"number":return Number(S(t));case"number[]":return E(t);case"enum":case"string":{let o=S(t),e=typeof o=="boolean"?o:String(o);if(n.upper&&typeof e=="string"&&(e=e.toUpperCase()),n.type==="enum"&&n.enum&&typeof e=="string"&&!n.enum.includes(e))throw new p(`--${n.flag} \u975E\u6CD5\u503C\u300C${e}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return n.map&&typeof e=="string"&&e in n.map&&(e=n.map[e]),e}default:return t}}function S(n){return Array.isArray(n)?n[n.length-1]:n}function E(n){return(Array.isArray(n)?n.join(","):String(n)).split(",").map(o=>o.trim()).filter(o=>o.length>0).map(o=>Number(o)).filter(o=>Number.isInteger(o)&&o>0)}function H(n,t){let o=_nullishCoalesce(n.positional, () => ([])),e=[],r=0;for(let s of o){if(s.variadic){let d=t.slice(r);if(s.required&&d.length===0)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);for(let i of d)e.push(J(s,i));return e}let c=t[r];if(c===void 0){if(s.required)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);e.push(void 0)}else e.push(J(s,c));r++}return e}function J(n,t){let o=t;if(n.upper&&(o=o.toUpperCase()),n.enum&&!n.enum.includes(o))throw new p(`<${n.name}> \u975E\u6CD5\u503C\u300C${t}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return o}function m(n,t,o){let e=_chunk6IFA2HGDcjs.a.call(void 0, n,t);if(!e)throw new p(`\u672A\u77E5\u547D\u4EE4: ${t.join(" ")}`);return Promise.resolve(e.fn.apply(e.parent,o))}function vn(n,t){let o=new Map;for(let r of _nullishCoalesce(n.options, () => ([])))o.set(r.flag,r);let e=o.size>0;for(let[r,s]of Object.entries(t)){if(B(r))continue;let c=o.get(r);if(!c){if(e)throw new p(`\u672A\u77E5\u9009\u9879 --${r}`,`\u8FD0\u884C \`stock-sdk ${n.path.join(" ")} --help\` \u67E5\u770B\u53EF\u7528\u9009\u9879`);continue}if(s===!0&&c.type!=="boolean"&&c.type!=="number[]")throw new p(`--${r} \u7F3A\u5C11\u503C`);if(c.type!=="number[]"){let d=S(s);if(c.upper&&typeof d=="string"&&(d=d.toUpperCase()),d!==s&&(t[r]=d),c.type==="enum"&&c.enum){let i=typeof d=="string"?d:String(d);if(!c.enum.includes(i))throw new p(`--${r} \u975E\u6CD5\u503C\u300C${i}\u300D`,`\u53EF\u9009: ${c.enum.join(" / ")}`)}if(c.type==="number"&&d!==!0&&Number.isNaN(Number(d)))throw new p(`--${r} \u9700\u8981\u6570\u503C\uFF0C\u5F97\u5230\u300C${String(d)}\u300D`)}}for(let r of _nullishCoalesce(n.options, () => ([])))if(r.required&&t[r.flag]===void 0)throw new p(`\u7F3A\u5C11\u5FC5\u586B\u9009\u9879 --${r.flag}`,r.desc)}function _n(n,t){let o=_nullishCoalesce(n.positional, () => ([]));for(let e=0;e<o.length;e++){let r=o[e],s=t[e];if(s===void 0||!r.enum)continue;let c=r.upper?s.toUpperCase():s;if(!r.enum.includes(c))throw new p(`<${r.name}> \u975E\u6CD5\u503C\u300C${s}\u300D`,`\u53EF\u9009: ${r.enum.join(" / ")}`)}}function Rn(n,t){let o=t.limit;if(o===void 0||o===!0||!Array.isArray(n))return n;let e=Number(S(o));return!Number.isNaN(e)&&e>=1?n.slice(0,e):n}function W(n,t,o){vn(t,o.options),_n(t,o.positional);let e=t.invoke?t.invoke(n,o):Nn(n,t,o);return Promise.resolve(e).then(r=>Rn(r,o.options))}function Nn(n,t,o){let e=An(t,o.options);switch(t.argShape){case"none":return m(n,t.path,[]);case"codes[]":return z(o.positional,t),m(n,t.path,[o.positional]);case"codes+options":return z(o.positional,t),m(n,t.path,[o.positional,e]);case"symbol+options":{let r=H(t,o.positional);return m(n,t.path,[...r,e])}case"options":return m(n,t.path,[e]);case"positional":return m(n,t.path,H(t,o.positional));default:throw new p(`\u4E0D\u652F\u6301\u7684\u547D\u4EE4\u5F62\u6001: ${t.argShape}`)}}function z(n,t){if(n.length===0)throw new p(`\u547D\u4EE4 "${t.path.join(" ")}" \u9700\u8981\u81F3\u5C11\u4E00\u4E2A\u4EE3\u7801\u53C2\u6570`)}function Z(n,t,o){if(t==="json")return o?JSON.stringify(n,null,2):JSON.stringify(n);let e=Mn(n);return e.length===0?"":t==="csv"?Dn(e):jn(e)}function nn(n){return n==null||Array.isArray(n)&&n.length===0}function Mn(n){return Array.isArray(n)?n.map(t=>Y(t)?t:{value:t}):Y(n)?[n]:n==null?[]:[{value:n}]}function Y(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function tn(n){let t=[],o=new Set;for(let e of n)for(let r of Object.keys(e))o.has(r)||(o.add(r),t.push(r));return t}function on(n){return n==null?"":typeof n=="object"?JSON.stringify(n):String(n)}function A(n){let t=0;for(let o of n){let e=_nullishCoalesce(o.codePointAt(0), () => (0));t+=In(e)?2:1}return t}function In(n){return n>=4352&&n<=4447||n>=11904&&n<=42191||n>=44032&&n<=55203||n>=63744&&n<=64255||n>=65072&&n<=65103||n>=65280&&n<=65376||n>=65504&&n<=65510||n>=131072&&n<=262141}function Q(n,t,o){let e=Math.max(0,t-A(n)),r=" ".repeat(e);return o?r+n:n+r}function jn(n){let t=tn(n),o=n.map(i=>t.map(a=>on(i[a]))),e=t.map((i,a)=>o.every(u=>u[a]===""||Tn(u[a]))),r=t.map((i,a)=>Math.max(A(i),...o.map(u=>A(u[a])))),s=t.map((i,a)=>Q(i,r[a],e[a])).join(" "),c=r.map(i=>"-".repeat(i)).join(" "),d=o.map(i=>i.map((a,u)=>Q(a,r[u],e[u])).join(" ")).join(`
|
|
4
4
|
`);return[s,c,d].join(`
|
|
5
5
|
`)}function Tn(n){return n!==""&&!Number.isNaN(Number(n))}function Dn(n){let t=tn(n),o=[t.map(X).join(",")];for(let e of n)o.push(t.map(r=>X(on(e[r]))).join(","));return o.join(`
|
|
6
|
-
`)}function X(n){return/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function h(n){let t={flag:n.flag,type:n.type,desc:n.desc};return n.field!==void 0&&(t.field=n.field),n.enum&&(t.enum=n.enum),n.required&&(t.required=!0),n.upper&&(t.upper=!0),n.map&&(t.map=n.map),t}function $n(n){let t={name:n.name};return n.required&&(t.required=!0),n.variadic&&(t.variadic=!0),n.enum&&(t.enum=n.enum),n.upper&&(t.upper=!0),t}function en(n,t){let o=(_nullishCoalesce(n.params, () => ([]))).filter(e=>e.cli!==!1).map(h);return{path:n.path,summary:n.summary,argShape:n.argShape,positional:_optionalChain([n, 'access', _2 => _2.positional, 'optionalAccess', _3 => _3.map, 'call', _4 => _4($n)]),options:o.length>0?o:void 0,invoke:t}}var qn=h(
|
|
7
|
-
`)}return i}},{path:["kline","cn"],alias:["kline"],summary:"K\u7EBF(--market a/hk/us\uFF1B--limit \u622A\u65AD)",argShape:"symbol+options",positional:P,options:[qn,rn,sn,an,un,v],invoke:async(n,t)=>{let o=_(t,"kline"),e=_nullishCoalesce(cn(t.options.market), () => (pn(o))),r=fn(t);return m(n,["kline",e==="hk"?"hk":e==="us"?"us":"cn"],[o,r])}},{path:["kline","cnMinute"],alias:["minute"],summary:"\u5206\u949FK\u7EBF/\u5206\u65F6(--period 1/5/15/30/60\uFF1B--market\uFF1B\u6E2F/\u7F8E --ndays)",argShape:"symbol+options",positional:P,options:[Kn,rn,sn,an,un,v,Ln],invoke:async(n,t)=>{let o=_(t,"minute"),e=_nullishCoalesce(cn(t.options.market), () => (pn(o))),r=fn(t),s=e==="hk"?"hkMinute":e==="us"?"usMinute":"cnMinute";if(t.options.ndays!==void 0){if(s==="cnMinute")throw new p("--ndays \u4EC5\u652F\u6301\u6E2F/\u7F8E\u80A1\u5206\u65F6","\u793A\u4F8B: stock-sdk minute 00700 --ndays 5");r.ndays=Number(t.options.ndays)}return m(n,["kline",s],[o,r])}},{path:["kline","withIndicators"],alias:["indicators"],summary:"\u5E26\u6307\u6807K\u7EBF(--ma 5,10,20 --macd --kdj --rsi --boll ...\uFF1B--market)",argShape:"symbol+options",positional:P,options:Fn,invoke:ln},{path:["search"],alias:["search"],summary:"\u641C\u7D22\u80A1\u7968/\u6307\u6570/\u57FA\u91D1(--limit \u622A\u65AD)",argShape:"positional",positional:[{name:"keyword",required:!0}],options:[v],invoke:async(n,t)=>{let o=t.positional[0];if(!o)throw new p("\u7F3A\u5C11\u641C\u7D22\u5173\u952E\u8BCD","\u7528\u6CD5: stock-sdk search <keyword>");return n.search(o)}},{path:["quotes","timeline"],alias:["timeline"],summary:"\u5F53\u65E5\u5206\u65F6",argShape:"positional",positional:Un,invoke:async(n,t)=>{let o=t.positional[0];if(!o)throw new p("\u7F3A\u5C11\u80A1\u7968\u4EE3\u7801","\u7528\u6CD5: stock-sdk timeline <code>");return n.quotes.timeline(o)}},{path:["codes","cn"],alias:["codes"],summary:"\u4EE3\u7801\u5217\u8868(market: a/hk/us/fund\uFF1B--simple\uFF1B--board sh/sz/bj/kc/cy)",argShape:"positional",positional:[{name:"market",required:!0,enum:["a","hk","us","fund"]}],options:[{flag:"simple",type:"boolean",desc:"\u53BB\u524D\u7F00"},{flag:"board",field:"market",type:"string",desc:"\u677F\u5757 sh/sz/bj/kc/cy(\u4EC5A\u80A1)"}],invoke:async(n,t)=>{let o=t.positional[0],e={};if(t.options.simple===!0&&(e.simple=!0),t.options.board!==void 0){if(o!=="a")throw new p("--board \u4EC5\u652F\u6301 A \u80A1(market=a)","\u53EF\u9009: sh / sz / bj / kc / cy");e.market=t.options.board}switch(o){case"a":return m(n,["codes","cn"],[e]);case"us":return m(n,["codes","us"],[e]);case"hk":return n.codes.hk();case"fund":return n.codes.fund();default:throw new p(`\u672A\u77E5\u5E02\u573A: ${o}`,"\u53EF\u9009: a / hk / us / fund")}}},{path:["calendar","marketStatus"],alias:["status"],summary:"\u5E02\u573A\u72B6\u6001(a/hk/us\uFF0C\u9ED8\u8BA4 a)",argShape:"positional",positional:[{name:"market",upper:!0,enum:
|
|
6
|
+
`)}function X(n){return/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function h(n){let t={flag:n.flag,type:n.type,desc:n.desc};return n.field!==void 0&&(t.field=n.field),n.enum&&(t.enum=n.enum),n.required&&(t.required=!0),n.upper&&(t.upper=!0),n.map&&(t.map=n.map),t}function $n(n){let t={name:n.name};return n.required&&(t.required=!0),n.variadic&&(t.variadic=!0),n.enum&&(t.enum=n.enum),n.upper&&(t.upper=!0),t}function en(n,t){let o=(_nullishCoalesce(n.params, () => ([]))).filter(e=>e.cli!==!1).map(h);return{path:n.path,summary:n.summary,argShape:n.argShape,positional:_optionalChain([n, 'access', _2 => _2.positional, 'optionalAccess', _3 => _3.map, 'call', _4 => _4($n)]),options:o.length>0?o:void 0,invoke:t}}var qn=h(_chunk6IFA2HGDcjs.e),Kn=h(_chunk6IFA2HGDcjs.f),rn=h(_chunk6IFA2HGDcjs.d),sn=h(_chunk6IFA2HGDcjs.g),an=h(_chunk6IFA2HGDcjs.h),Ln=h(_chunk6IFA2HGDcjs.i),P=[{name:"symbol",required:!0}],Un=[{name:"code",required:!0}],mn={"kline.withIndicators":(n,t)=>ln(n,t),"northbound.minute":(n,t)=>m(n,["northbound","minute"],[dn(t)]),"northbound.history":(n,t)=>{let o={};return t.options.start!==void 0&&(o.startDate=t.options.start),t.options.end!==void 0&&(o.endDate=t.options.end),m(n,["northbound","history"],[dn(t),o])}};{let n=new Set(_chunk6IFA2HGDcjs.m.map(t=>t.path.join(".")));for(let t of Object.keys(mn))if(!n.has(t))throw new Error(`CLI_INVOKE_OVERRIDES \u5F15\u7528\u4E86 spec \u4E2D\u4E0D\u5B58\u5728\u7684\u65B9\u6CD5\u8DEF\u5F84: ${t}`)}var k=_chunk6IFA2HGDcjs.m.map(n=>en(n,mn[n.path.join(".")]));function xn(n){return _nullishCoalesce(_optionalChain([k, 'access', _5 => _5.find, 'call', _6 => _6(t=>t.path.join(".")===n), 'optionalAccess', _7 => _7.options]), () => ([]))}var Fn=xn("kline.withIndicators"),un={flag:"market",type:"enum",enum:["a","hk","us"],desc:"\u5E02\u573A a/hk/us(\u9ED8\u8BA4\u6309\u4EE3\u7801\u81EA\u52A8\u8BC6\u522B)"},Vn={flag:"market",type:"enum",enum:["a","hk","us","fund"],desc:"\u5E02\u573A a/hk/us/fund(\u9ED8\u8BA4\u6309\u4EE3\u7801\u81EA\u52A8\u8BC6\u522B\uFF1B\u57FA\u91D1\u987B\u663E\u5F0F --market fund)"},v={flag:"limit",type:"number",desc:"\u53EA\u53D6\u524D N \u6761(CLI \u8F93\u51FA\u5C42\u88C1\u526A)"};function pn(n){let t=_chunkT5CH7H3Xcjs.f.call(void 0, n);if(t==="GLOBAL")throw new p(`\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u8DEF\u7531 GLOBAL \u5E02\u573A\u7B26\u53F7: ${n}`,"\u6D77\u5916\u7279\u6B8A\u6307\u6570\u6682\u65E0\u6B63\u5F0F K \u7EBF\u5165\u53E3,\u53EF\u7528 raw-secid \u76F4\u901A: stock-sdk kline 100.GDAXI --market us");return t==="HK"?"hk":t==="US"?"us":"a"}function Gn(n){return n==="hk"?"HK":n==="us"?"US":"CN"}function cn(n){if(n!==void 0){if(n==="a"||n==="hk"||n==="us")return n;throw new p("--market \u975E\u6CD5\u503C","\u53EF\u9009: a / hk / us")}}function Hn(n){if(n!==void 0){if(n==="a"||n==="hk"||n==="us"||n==="fund")return n;throw new p("--market \u975E\u6CD5\u503C","\u53EF\u9009: a / hk / us / fund")}}function dn(n){let t=_nullishCoalesce(n.options.direction, () => (n.positional[0]));if(t!==void 0){if(t==="north"||t==="south")return t;throw new p("direction \u975E\u6CD5\u503C","\u53EF\u9009: north / south")}}function fn(n){let t={};return n.options.period!==void 0&&(t.period=n.options.period),n.options.adjust!==void 0&&(t.adjust=n.options.adjust==="none"?"":n.options.adjust),n.options.start!==void 0&&(t.startDate=n.options.start),n.options.end!==void 0&&(t.endDate=n.options.end),t}function Jn(n){let t={};for(let o of _chunk6IFA2HGDcjs.k){let e=n[o];if(e===void 0)continue;if(e===!0){t[o]={};continue}let r=E(e);r.length>0&&(t[o]={periods:r})}for(let o of _chunk6IFA2HGDcjs.l){let e=n[o];e!==void 0&&(e===!0||e==="true"||e==="1"||e==="yes")&&(t[o]=!0)}return t}function ln(n,t){let o=_(t,"indicators"),e={};return t.options.period!==void 0&&(e.period=t.options.period),t.options.adjust!==void 0&&(e.adjust=t.options.adjust==="none"?"":t.options.adjust),t.options.start!==void 0&&(e.startDate=t.options.start),t.options.end!==void 0&&(e.endDate=t.options.end),t.options.market!==void 0&&(e.market=t.options.market),e.indicators=Jn(t.options),m(n,["kline","withIndicators"],[o,e])}var y=[{path:["quotes","cnSimple"],alias:["quote"],summary:"\u884C\u60C5(\u81EA\u52A8\u8BC6\u522B\u5E02\u573A\uFF1B--full \u5168\u91CF\u4E94\u6863\uFF1B--market \u5F3A\u5236\u5E02\u573A)",argShape:"codes[]",positional:[{name:"code",required:!0,variadic:!0}],options:[Vn,{flag:"full",type:"boolean",desc:"A\u80A1\u5168\u91CF\u4E94\u6863\u884C\u60C5"}],invoke:async(n,t)=>{let o=t.positional;if(o.length===0)throw new p("\u7F3A\u5C11\u80A1\u7968\u4EE3\u7801","\u7528\u6CD5: stock-sdk quote <code...>");let e=Hn(t.options.market),r=t.options.full===!0,s={a:[],hk:[],us:[],fund:[]};for(let u of o){if(e==="fund"){s.fund.push(u);continue}let f=_nullishCoalesce(e, () => ("a"));try{let l=e?_chunkT5CH7H3Xcjs.e.call(void 0, u,{market:Gn(e)}):_chunkT5CH7H3Xcjs.e.call(void 0, u);if(e||(f=l.market==="HK"?"hk":l.market==="US"?"us":"a"),l.assetType==="index"&&_chunkT5CH7H3Xcjs.d.call(void 0, l.code))throw new p(`\u7279\u6B8A\u6307\u6570 ${l.code} \u65E0\u884C\u60C5\u63A5\u53E3`,`\u884C\u60C5\u6E90(\u817E\u8BAF)\u4E0D\u8986\u76D6\u4E2D\u8BC1/\u6052\u751F/\u6D77\u5916\u7279\u6B8A\u6307\u6570;K \u7EBF\u8BF7\u7528: stock-sdk kline ${l.code}`);s[f].push(f==="a"?_chunkT5CH7H3Xcjs.h.call(void 0, l):l.code)}catch(l){if(l instanceof p||e&&l instanceof _chunk4Q7UQ5Q3cjs.f&&_chunkT5CH7H3Xcjs.f.call(void 0, u)!==void 0)throw l;s[f].push(u)}}let c=[];s.a.length&&c.push(Promise.resolve(r?n.quotes.cn(s.a):n.quotes.cnSimple(s.a))),s.hk.length&&c.push(Promise.resolve(n.quotes.hk(s.hk))),s.us.length&&c.push(Promise.resolve(n.quotes.us(s.us))),s.fund.length&&c.push(Promise.resolve(n.quotes.fund(s.fund)));let d=await Promise.allSettled(c),i=[],a=[];for(let u of d)u.status==="fulfilled"?i.push(...u.value):a.push(u.reason);if(i.length===0&&a.length>0)throw a[0];if(a.length>0){let u=a.map(f=>f instanceof Error?f.message:String(f)).join("; ");process.stderr.write(`stock-sdk: \u90E8\u5206\u5E02\u573A\u884C\u60C5\u67E5\u8BE2\u5931\u8D25: ${u}
|
|
7
|
+
`)}return i}},{path:["kline","cn"],alias:["kline"],summary:"K\u7EBF(--market a/hk/us\uFF1B--limit \u622A\u65AD)",argShape:"symbol+options",positional:P,options:[qn,rn,sn,an,un,v],invoke:async(n,t)=>{let o=_(t,"kline"),e=_nullishCoalesce(cn(t.options.market), () => (pn(o))),r=fn(t);return m(n,["kline",e==="hk"?"hk":e==="us"?"us":"cn"],[o,r])}},{path:["kline","cnMinute"],alias:["minute"],summary:"\u5206\u949FK\u7EBF/\u5206\u65F6(--period 1/5/15/30/60\uFF1B--market\uFF1B\u6E2F/\u7F8E --ndays)",argShape:"symbol+options",positional:P,options:[Kn,rn,sn,an,un,v,Ln],invoke:async(n,t)=>{let o=_(t,"minute"),e=_nullishCoalesce(cn(t.options.market), () => (pn(o))),r=fn(t),s=e==="hk"?"hkMinute":e==="us"?"usMinute":"cnMinute";if(t.options.ndays!==void 0){if(s==="cnMinute")throw new p("--ndays \u4EC5\u652F\u6301\u6E2F/\u7F8E\u80A1\u5206\u65F6","\u793A\u4F8B: stock-sdk minute 00700 --ndays 5");r.ndays=Number(t.options.ndays)}return m(n,["kline",s],[o,r])}},{path:["kline","withIndicators"],alias:["indicators"],summary:"\u5E26\u6307\u6807K\u7EBF(--ma 5,10,20 --macd --kdj --rsi --boll ...\uFF1B--market)",argShape:"symbol+options",positional:P,options:Fn,invoke:ln},{path:["search"],alias:["search"],summary:"\u641C\u7D22\u80A1\u7968/\u6307\u6570/\u57FA\u91D1(--limit \u622A\u65AD)",argShape:"positional",positional:[{name:"keyword",required:!0}],options:[v],invoke:async(n,t)=>{let o=t.positional[0];if(!o)throw new p("\u7F3A\u5C11\u641C\u7D22\u5173\u952E\u8BCD","\u7528\u6CD5: stock-sdk search <keyword>");return n.search(o)}},{path:["quotes","timeline"],alias:["timeline"],summary:"\u5F53\u65E5\u5206\u65F6",argShape:"positional",positional:Un,invoke:async(n,t)=>{let o=t.positional[0];if(!o)throw new p("\u7F3A\u5C11\u80A1\u7968\u4EE3\u7801","\u7528\u6CD5: stock-sdk timeline <code>");return n.quotes.timeline(o)}},{path:["codes","cn"],alias:["codes"],summary:"\u4EE3\u7801\u5217\u8868(market: a/hk/us/fund\uFF1B--simple\uFF1B--board sh/sz/bj/kc/cy)",argShape:"positional",positional:[{name:"market",required:!0,enum:["a","hk","us","fund"]}],options:[{flag:"simple",type:"boolean",desc:"\u53BB\u524D\u7F00"},{flag:"board",field:"market",type:"string",desc:"\u677F\u5757 sh/sz/bj/kc/cy(\u4EC5A\u80A1)"}],invoke:async(n,t)=>{let o=t.positional[0],e={};if(t.options.simple===!0&&(e.simple=!0),t.options.board!==void 0){if(o!=="a")throw new p("--board \u4EC5\u652F\u6301 A \u80A1(market=a)","\u53EF\u9009: sh / sz / bj / kc / cy");e.market=t.options.board}switch(o){case"a":return m(n,["codes","cn"],[e]);case"us":return m(n,["codes","us"],[e]);case"hk":return n.codes.hk();case"fund":return n.codes.fund();default:throw new p(`\u672A\u77E5\u5E02\u573A: ${o}`,"\u53EF\u9009: a / hk / us / fund")}}},{path:["calendar","marketStatus"],alias:["status"],summary:"\u5E02\u573A\u72B6\u6001(a/hk/us\uFF0C\u9ED8\u8BA4 a)",argShape:"positional",positional:[{name:"market",upper:!0,enum:_chunk6IFA2HGDcjs.b}],invoke:async(n,t)=>{let o=t.positional[0],e=o?o.toUpperCase():"A";return n.calendar.marketStatus(e)}},{path:["marketEvent","ztPool"],alias:["ztpool"],summary:"\u6DA8\u505C\u80A1\u6C60 zt/yesterday/strong/sub_new/broken/dt(--date)",argShape:"positional",positional:[{name:"type",enum:_chunk6IFA2HGDcjs.c}],options:[{flag:"date",type:"string",desc:"\u4EA4\u6613\u65E5 YYYYMMDD"}],invoke:async(n,t)=>{let o=t.positional[0],e=t.options.date;return n.marketEvent.ztPool(o,e)}},{path:["call"],alias:["call"],summary:"\u539F\u59CB\u76F4\u901A\uFF1A\u8C03\u7528\u4EFB\u610F\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5\uFF08--args \u4F20 JSON \u5B9E\u53C2\u6570\u7EC4\uFF09",argShape:"positional",positional:[{name:"method",required:!0}],options:[{flag:"args",type:"string",desc:`JSON \u5B9E\u53C2\u6570\u7EC4\uFF0C\u5982 '[["sh600519"]]'`}],invoke:(n,t)=>{let o=t.positional[0];if(!o)throw new p("call \u7F3A\u5C11\u65B9\u6CD5\u8DEF\u5F84","\u7528\u6CD5: stock-sdk call <ns.method> --args '[...]'");let e=[],r=t.options.args;if(typeof r=="string")try{let c=JSON.parse(r);e=Array.isArray(c)?c:[c]}catch (e2){throw new p("--args \u4E0D\u662F\u5408\u6CD5 JSON",`\u793A\u4F8B: --args '[["sh600519"]]'`)}if(!new Set(Bn()).has(o))throw new p(`\u672A\u77E5\u65B9\u6CD5: ${o}`,"\u5F62\u5982 quotes.cn / kline.cn(\u4EC5\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5,\u89C1 stock-sdk --help)");return m(n,o.split("."),e)}}],hn="mcp",zn=[...y,...k];function Bn(){return _chunk6IFA2HGDcjs.m.map(n=>n.path.join("."))}function _(n,t){let o=n.positional[0];if(!o)throw new p("\u7F3A\u5C11\u4EE3\u7801\u53C2\u6570",`\u7528\u6CD5: stock-sdk ${t} <symbol>`);return o}function kn(){let n=new Set(["help","h","version","V","quiet","q","pretty"]);for(let t of zn)for(let o of _nullishCoalesce(t.options, () => ([])))o.type==="boolean"&&n.add(o.flag);for(let t of _chunk6IFA2HGDcjs.l)n.add(t);return n}function gn(n){if(n.length===0)return null;for(let o=Math.min(3,n.length);o>=2;o--){let e=n.slice(0,o).join("."),r=k.find(s=>s.path.join(".")===e);if(r)return{spec:r,rest:n.slice(o)}}for(let o of y)if(_optionalChain([o, 'access', _8 => _8.alias, 'optionalAccess', _9 => _9.includes, 'call', _10 => _10(n[0])]))return{spec:o,rest:n.slice(1)};let t=k.find(o=>o.path.join(".")===n[0]);return t?{spec:t,rest:n.slice(1)}:null}function Sn(){let n=["stock-sdk \u2014\u2014 \u80A1\u7968\u884C\u60C5\u547D\u4EE4\u884C\uFF08\u57FA\u4E8E stock-sdk v2 \u547D\u540D\u7A7A\u95F4 API\uFF09","","\u7528\u6CD5:"," stock-sdk <command> [args] [--flags]"," stock-sdk <namespace> <method> [args] [--flags] # \u76F4\u8FBE\u4EFB\u610F\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5","","\u5E38\u7528\u547D\u4EE4:"];for(let o of y){let e=_nullishCoalesce(_optionalChain([o, 'access', _11 => _11.alias, 'optionalAccess', _12 => _12[0]]), () => (o.path.join(" ")));n.push(` ${e.padEnd(12)} ${o.summary}`)}n.push(" mcp \u542F\u52A8 MCP server (stdio)"),n.push(""),n.push("\u547D\u540D\u7A7A\u95F4\uFF08stock-sdk <ns> <method> ...\uFF09:");let t=[...new Set(k.map(o=>o.path[0]))];return n.push(" "+t.join(" / ")),n.push(""),n.push("\u5168\u5C40\u9009\u9879:"),n.push(" -f, --format json|table|csv \u8F93\u51FA\u683C\u5F0F (\u9ED8\u8BA4 json)"),n.push(" --pretty JSON \u7F29\u8FDB\u7F8E\u5316"),n.push(" --timeout <ms> \u8BF7\u6C42\u8D85\u65F6"),n.push(" -q, --quiet \u9759\u9ED8(\u53EA\u8F93\u51FA\u6570\u636E)"),n.push(" -h, --help \u663E\u793A\u5E2E\u52A9"),n.push(" -V, --version \u663E\u793A\u7248\u672C"),n.push(""),n.push("\u793A\u4F8B:"),n.push(" stock-sdk quote 600519 000858 00700"),n.push(" stock-sdk kline 600519 --period weekly --adjust hfq --limit 30"),n.push(" stock-sdk indicators 600519 --ma 5,10,20 --macd"),n.push(" stock-sdk board industry list --format table"),n.push(" stock-sdk options etf dailyKline 10004336"),n.push(""),n.push("\u8FD0\u884C `stock-sdk <command> --help` \u67E5\u770B\u5355\u6761\u547D\u4EE4\u7528\u6CD5\u3002"),n.join(`
|
|
8
8
|
`)}function yn(n){let t=_nullishCoalesce(_optionalChain([n, 'access', _13 => _13.alias, 'optionalAccess', _14 => _14[0]]), () => (n.path.join(" "))),o=[`${t} \u2014\u2014 ${n.summary}`,""],e=(_nullishCoalesce(n.positional, () => ([]))).map(r=>{let s=r.required?`<${r.name}>`:`[${r.name}]`;return r.variadic?`${s}...`:s}).join(" ");if(o.push(`\u7528\u6CD5: stock-sdk ${t}${e?" "+e:""} [--flags]`),_optionalChain([n, 'access', _15 => _15.options, 'optionalAccess', _16 => _16.length])){o.push(""),o.push("\u9009\u9879:");for(let r of n.options){let s=r.enum?` (${r.enum.join("/")})`:"";o.push(` --${r.flag.padEnd(12)} ${r.desc}${s}`)}}return o.join(`
|
|
9
9
|
`)}function wn(n,t=new Set){let o=[],e={},r=!1,s=(i,a)=>{let u=e[i];if(u===void 0){e[i]=a;return}if(typeof a!="string"){e[i]=a;return}Array.isArray(u)?u.push(a):typeof u=="string"?e[i]=[u,a]:e[i]=a},c=i=>i!==void 0&&(i==="-"||!i.startsWith("-")||/^-\d/.test(i)),d=(i,a)=>{if(t.has(i))return s(i,!0),a;let u=n[a+1];return c(u)?(s(i,u),a+1):(s(i,!0),a)};for(let i=0;i<n.length;i++){let a=n[i];if(r){o.push(a);continue}if(a==="--"){r=!0;continue}if(a.startsWith("--")&&a.length>2){let u=a.slice(2),f=u.indexOf("=");f>=0?s(u.slice(0,f),u.slice(f+1)):i=d(u,i)}else if(a.startsWith("-")&&a.length>1&&!Wn(a)){let u=a.slice(1),f=u.indexOf("=");f>=0?s(u.slice(0,f),u.slice(f+1)):i=d(u,i)}else o.push(a)}return{positional:o,options:e}}function Wn(n){return/^-\d/.test(n)}var Yn=kn();process.stdout.on("error",n=>{n.code==="EPIPE"&&process.exit(0),process.stderr.write(`stock-sdk: stdout error: ${n.message}
|
|
10
|
-
`)});function Qn(){return"2.
|
|
10
|
+
`)});function Qn(){return"2.3.0"}function Xn(n){let t=_nullishCoalesce(n.format, () => (n.f)),o=t==="table"||t==="csv"?t:"json",e;if(typeof n.timeout=="string"||typeof n.timeout=="number"){let r=Number(n.timeout);!Number.isNaN(r)&&r>0&&(e=r)}return{format:o,pretty:n.pretty===!0,quiet:n.quiet===!0||n.q===!0,help:n.help===!0||n.h===!0,version:n.version===!0||n.V===!0,timeout:e}}async function Zn(){try{return(await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp.cjs")))).startMcpServer(),0}catch(n){let t=n instanceof Error?n.message:String(n);return process.stderr.write(`stock-sdk: \u65E0\u6CD5\u542F\u52A8 MCP server: ${t}
|
|
11
11
|
`),1}}async function nt(n){let t="json";try{let o=wn(n,Yn),e=Xn(o.options);if(t=e.format,e.version)return process.stdout.write(Qn()+`
|
|
12
12
|
`),0;if(o.positional.length===0)return process.stdout.write(Sn()+`
|
|
13
13
|
`),0;if(o.positional[0]===hn)return e.help?(process.stdout.write(`stock-sdk mcp \u2014\u2014 \u542F\u52A8 MCP server (stdio transport)
|
|
@@ -15,7 +15,7 @@ ${n.hint}`:"";return{text:`stock-sdk: ${o}${r}`}}let e=_chunk4Q7UQ5Q3cjs.k.call(
|
|
|
15
15
|
\u7528\u6CD5: stock-sdk mcp
|
|
16
16
|
\u73AF\u5883\u53D8\u91CF: STOCK_SDK_MCP_TOOLS=core|full|<\u9017\u53F7\u5206\u9694\u5DE5\u5177\u540D>\uFF08\u9ED8\u8BA4 core\uFF09
|
|
17
17
|
`),0):await Zn();let r=gn(o.positional);if(!r)throw new p(`\u672A\u77E5\u547D\u4EE4 "${o.positional.join(" ")}"`,"\u8FD0\u884C `stock-sdk --help` \u67E5\u770B\u53EF\u7528\u547D\u4EE4");if(e.help)return process.stdout.write(yn(r.spec)+`
|
|
18
|
-
`),0;let s=new (0,
|
|
18
|
+
`),0;let s=new (0, _chunkLMUFSVKQcjs.t)(e.timeout!==void 0?{timeout:e.timeout}:{}),c={positional:r.rest,options:o.options},d=await W(s,r.spec,c);nn(d)&&!e.quiet&&process.stderr.write(`stock-sdk: \u65E0\u6570\u636E
|
|
19
19
|
`);let i=Z(d,e.format,e.pretty);return i.length>0&&process.stdout.write(i+`
|
|
20
20
|
`),0}catch(o){let e=G(o,t);return process.stderr.write(e.text+`
|
|
21
21
|
`),V(o)}}nt(process.argv.slice(2)).then(n=>{process.exitCode=n},n=>{let t=n instanceof Error?n.message:String(n);process.stderr.write(`stock-sdk: ${t}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as j,b as T,c as D,d as $,e as q,f as K,g as L,h as U,i as x,k as F,l as C,m as g}from"./chunk-
|
|
2
|
+
import{a as j,b as T,c as D,d as $,e as q,f as K,g as L,h as U,i as x,k as F,l as C,m as g}from"./chunk-IWHFCLJM.js";import{t as I}from"./chunk-3ASJZ3YA.js";import"./chunk-QGYIBFXP.js";import{d as N,e as O,f as b,h as M}from"./chunk-ZZ2IBUMV.js";import"./chunk-DU7MCVLJ.js";import{f as R,k as w}from"./chunk-UBIQBXQ7.js";import"./chunk-WOT6VMZA.js";var p=class extends Error{constructor(t,o){super(t),this.name="CliUsageError",this.hint=o}},On={INVALID_ARGUMENT:2,INVALID_SYMBOL:2,NOT_FOUND:2,NETWORK_ERROR:3,TIMEOUT:3,ABORTED:3,UPSTREAM_ERROR:4,UPSTREAM_EMPTY:4,PARSE_ERROR:4,HTTP_ERROR:4,RATE_LIMITED:5,CIRCUIT_OPEN:5};function V(n){if(n instanceof p)return 2;let t=w(n);return On[t]??1}function G(n,t){let o=n instanceof Error?n.message:String(n);if(n instanceof p){if(t==="json")return{text:JSON.stringify({error:{code:"USAGE",message:o}})};let r=n.hint?`
|
|
3
3
|
${n.hint}`:"";return{text:`stock-sdk: ${o}${r}`}}let e=w(n);return t==="json"?{text:JSON.stringify({error:{code:e,message:o}})}:{text:`stock-sdk: ${e}: ${o}`}}var bn={start:"startDate",end:"endDate"},Cn=new Set(["format","f","pretty","quiet","q","help","h","version","V","timeout"]),En=new Set(["limit"]);function B(n){return Cn.has(n)||En.has(n)}function An(n,t){let o={},e=new Map;for(let r of n.options??[])e.set(r.flag,r);for(let[r,s]of Object.entries(t)){if(B(r))continue;let c=e.get(r);if(!c){if(s===!0)continue;o[bn[r]??r]=s;continue}o[c.field??c.flag]=Pn(c,s)}for(let r of n.options??[]){let s=r.field??r.flag;o[s]===void 0&&r.default!==void 0&&(o[s]=r.default)}return o}function Pn(n,t){switch(n.type){case"boolean":return t===!0||t==="true";case"number":return Number(S(t));case"number[]":return E(t);case"enum":case"string":{let o=S(t),e=typeof o=="boolean"?o:String(o);if(n.upper&&typeof e=="string"&&(e=e.toUpperCase()),n.type==="enum"&&n.enum&&typeof e=="string"&&!n.enum.includes(e))throw new p(`--${n.flag} \u975E\u6CD5\u503C\u300C${e}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return n.map&&typeof e=="string"&&e in n.map&&(e=n.map[e]),e}default:return t}}function S(n){return Array.isArray(n)?n[n.length-1]:n}function E(n){return(Array.isArray(n)?n.join(","):String(n)).split(",").map(o=>o.trim()).filter(o=>o.length>0).map(o=>Number(o)).filter(o=>Number.isInteger(o)&&o>0)}function H(n,t){let o=n.positional??[],e=[],r=0;for(let s of o){if(s.variadic){let d=t.slice(r);if(s.required&&d.length===0)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);for(let i of d)e.push(J(s,i));return e}let c=t[r];if(c===void 0){if(s.required)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);e.push(void 0)}else e.push(J(s,c));r++}return e}function J(n,t){let o=t;if(n.upper&&(o=o.toUpperCase()),n.enum&&!n.enum.includes(o))throw new p(`<${n.name}> \u975E\u6CD5\u503C\u300C${t}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return o}function m(n,t,o){let e=j(n,t);if(!e)throw new p(`\u672A\u77E5\u547D\u4EE4: ${t.join(" ")}`);return Promise.resolve(e.fn.apply(e.parent,o))}function vn(n,t){let o=new Map;for(let r of n.options??[])o.set(r.flag,r);let e=o.size>0;for(let[r,s]of Object.entries(t)){if(B(r))continue;let c=o.get(r);if(!c){if(e)throw new p(`\u672A\u77E5\u9009\u9879 --${r}`,`\u8FD0\u884C \`stock-sdk ${n.path.join(" ")} --help\` \u67E5\u770B\u53EF\u7528\u9009\u9879`);continue}if(s===!0&&c.type!=="boolean"&&c.type!=="number[]")throw new p(`--${r} \u7F3A\u5C11\u503C`);if(c.type!=="number[]"){let d=S(s);if(c.upper&&typeof d=="string"&&(d=d.toUpperCase()),d!==s&&(t[r]=d),c.type==="enum"&&c.enum){let i=typeof d=="string"?d:String(d);if(!c.enum.includes(i))throw new p(`--${r} \u975E\u6CD5\u503C\u300C${i}\u300D`,`\u53EF\u9009: ${c.enum.join(" / ")}`)}if(c.type==="number"&&d!==!0&&Number.isNaN(Number(d)))throw new p(`--${r} \u9700\u8981\u6570\u503C\uFF0C\u5F97\u5230\u300C${String(d)}\u300D`)}}for(let r of n.options??[])if(r.required&&t[r.flag]===void 0)throw new p(`\u7F3A\u5C11\u5FC5\u586B\u9009\u9879 --${r.flag}`,r.desc)}function _n(n,t){let o=n.positional??[];for(let e=0;e<o.length;e++){let r=o[e],s=t[e];if(s===void 0||!r.enum)continue;let c=r.upper?s.toUpperCase():s;if(!r.enum.includes(c))throw new p(`<${r.name}> \u975E\u6CD5\u503C\u300C${s}\u300D`,`\u53EF\u9009: ${r.enum.join(" / ")}`)}}function Rn(n,t){let o=t.limit;if(o===void 0||o===!0||!Array.isArray(n))return n;let e=Number(S(o));return!Number.isNaN(e)&&e>=1?n.slice(0,e):n}function W(n,t,o){vn(t,o.options),_n(t,o.positional);let e=t.invoke?t.invoke(n,o):Nn(n,t,o);return Promise.resolve(e).then(r=>Rn(r,o.options))}function Nn(n,t,o){let e=An(t,o.options);switch(t.argShape){case"none":return m(n,t.path,[]);case"codes[]":return z(o.positional,t),m(n,t.path,[o.positional]);case"codes+options":return z(o.positional,t),m(n,t.path,[o.positional,e]);case"symbol+options":{let r=H(t,o.positional);return m(n,t.path,[...r,e])}case"options":return m(n,t.path,[e]);case"positional":return m(n,t.path,H(t,o.positional));default:throw new p(`\u4E0D\u652F\u6301\u7684\u547D\u4EE4\u5F62\u6001: ${t.argShape}`)}}function z(n,t){if(n.length===0)throw new p(`\u547D\u4EE4 "${t.path.join(" ")}" \u9700\u8981\u81F3\u5C11\u4E00\u4E2A\u4EE3\u7801\u53C2\u6570`)}function Z(n,t,o){if(t==="json")return o?JSON.stringify(n,null,2):JSON.stringify(n);let e=Mn(n);return e.length===0?"":t==="csv"?Dn(e):jn(e)}function nn(n){return n==null||Array.isArray(n)&&n.length===0}function Mn(n){return Array.isArray(n)?n.map(t=>Y(t)?t:{value:t}):Y(n)?[n]:n==null?[]:[{value:n}]}function Y(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function tn(n){let t=[],o=new Set;for(let e of n)for(let r of Object.keys(e))o.has(r)||(o.add(r),t.push(r));return t}function on(n){return n==null?"":typeof n=="object"?JSON.stringify(n):String(n)}function A(n){let t=0;for(let o of n){let e=o.codePointAt(0)??0;t+=In(e)?2:1}return t}function In(n){return n>=4352&&n<=4447||n>=11904&&n<=42191||n>=44032&&n<=55203||n>=63744&&n<=64255||n>=65072&&n<=65103||n>=65280&&n<=65376||n>=65504&&n<=65510||n>=131072&&n<=262141}function Q(n,t,o){let e=Math.max(0,t-A(n)),r=" ".repeat(e);return o?r+n:n+r}function jn(n){let t=tn(n),o=n.map(i=>t.map(a=>on(i[a]))),e=t.map((i,a)=>o.every(u=>u[a]===""||Tn(u[a]))),r=t.map((i,a)=>Math.max(A(i),...o.map(u=>A(u[a])))),s=t.map((i,a)=>Q(i,r[a],e[a])).join(" "),c=r.map(i=>"-".repeat(i)).join(" "),d=o.map(i=>i.map((a,u)=>Q(a,r[u],e[u])).join(" ")).join(`
|
|
4
4
|
`);return[s,c,d].join(`
|
|
5
5
|
`)}function Tn(n){return n!==""&&!Number.isNaN(Number(n))}function Dn(n){let t=tn(n),o=[t.map(X).join(",")];for(let e of n)o.push(t.map(r=>X(on(e[r]))).join(","));return o.join(`
|
|
@@ -7,7 +7,7 @@ ${n.hint}`:"";return{text:`stock-sdk: ${o}${r}`}}let e=w(n);return t==="json"?{t
|
|
|
7
7
|
`)}return i}},{path:["kline","cn"],alias:["kline"],summary:"K\u7EBF(--market a/hk/us\uFF1B--limit \u622A\u65AD)",argShape:"symbol+options",positional:P,options:[qn,rn,sn,an,un,v],invoke:async(n,t)=>{let o=_(t,"kline"),e=cn(t.options.market)??pn(o),r=fn(t);return m(n,["kline",e==="hk"?"hk":e==="us"?"us":"cn"],[o,r])}},{path:["kline","cnMinute"],alias:["minute"],summary:"\u5206\u949FK\u7EBF/\u5206\u65F6(--period 1/5/15/30/60\uFF1B--market\uFF1B\u6E2F/\u7F8E --ndays)",argShape:"symbol+options",positional:P,options:[Kn,rn,sn,an,un,v,Ln],invoke:async(n,t)=>{let o=_(t,"minute"),e=cn(t.options.market)??pn(o),r=fn(t),s=e==="hk"?"hkMinute":e==="us"?"usMinute":"cnMinute";if(t.options.ndays!==void 0){if(s==="cnMinute")throw new p("--ndays \u4EC5\u652F\u6301\u6E2F/\u7F8E\u80A1\u5206\u65F6","\u793A\u4F8B: stock-sdk minute 00700 --ndays 5");r.ndays=Number(t.options.ndays)}return m(n,["kline",s],[o,r])}},{path:["kline","withIndicators"],alias:["indicators"],summary:"\u5E26\u6307\u6807K\u7EBF(--ma 5,10,20 --macd --kdj --rsi --boll ...\uFF1B--market)",argShape:"symbol+options",positional:P,options:Fn,invoke:ln},{path:["search"],alias:["search"],summary:"\u641C\u7D22\u80A1\u7968/\u6307\u6570/\u57FA\u91D1(--limit \u622A\u65AD)",argShape:"positional",positional:[{name:"keyword",required:!0}],options:[v],invoke:async(n,t)=>{let o=t.positional[0];if(!o)throw new p("\u7F3A\u5C11\u641C\u7D22\u5173\u952E\u8BCD","\u7528\u6CD5: stock-sdk search <keyword>");return n.search(o)}},{path:["quotes","timeline"],alias:["timeline"],summary:"\u5F53\u65E5\u5206\u65F6",argShape:"positional",positional:Un,invoke:async(n,t)=>{let o=t.positional[0];if(!o)throw new p("\u7F3A\u5C11\u80A1\u7968\u4EE3\u7801","\u7528\u6CD5: stock-sdk timeline <code>");return n.quotes.timeline(o)}},{path:["codes","cn"],alias:["codes"],summary:"\u4EE3\u7801\u5217\u8868(market: a/hk/us/fund\uFF1B--simple\uFF1B--board sh/sz/bj/kc/cy)",argShape:"positional",positional:[{name:"market",required:!0,enum:["a","hk","us","fund"]}],options:[{flag:"simple",type:"boolean",desc:"\u53BB\u524D\u7F00"},{flag:"board",field:"market",type:"string",desc:"\u677F\u5757 sh/sz/bj/kc/cy(\u4EC5A\u80A1)"}],invoke:async(n,t)=>{let o=t.positional[0],e={};if(t.options.simple===!0&&(e.simple=!0),t.options.board!==void 0){if(o!=="a")throw new p("--board \u4EC5\u652F\u6301 A \u80A1(market=a)","\u53EF\u9009: sh / sz / bj / kc / cy");e.market=t.options.board}switch(o){case"a":return m(n,["codes","cn"],[e]);case"us":return m(n,["codes","us"],[e]);case"hk":return n.codes.hk();case"fund":return n.codes.fund();default:throw new p(`\u672A\u77E5\u5E02\u573A: ${o}`,"\u53EF\u9009: a / hk / us / fund")}}},{path:["calendar","marketStatus"],alias:["status"],summary:"\u5E02\u573A\u72B6\u6001(a/hk/us\uFF0C\u9ED8\u8BA4 a)",argShape:"positional",positional:[{name:"market",upper:!0,enum:T}],invoke:async(n,t)=>{let o=t.positional[0],e=o?o.toUpperCase():"A";return n.calendar.marketStatus(e)}},{path:["marketEvent","ztPool"],alias:["ztpool"],summary:"\u6DA8\u505C\u80A1\u6C60 zt/yesterday/strong/sub_new/broken/dt(--date)",argShape:"positional",positional:[{name:"type",enum:D}],options:[{flag:"date",type:"string",desc:"\u4EA4\u6613\u65E5 YYYYMMDD"}],invoke:async(n,t)=>{let o=t.positional[0],e=t.options.date;return n.marketEvent.ztPool(o,e)}},{path:["call"],alias:["call"],summary:"\u539F\u59CB\u76F4\u901A\uFF1A\u8C03\u7528\u4EFB\u610F\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5\uFF08--args \u4F20 JSON \u5B9E\u53C2\u6570\u7EC4\uFF09",argShape:"positional",positional:[{name:"method",required:!0}],options:[{flag:"args",type:"string",desc:`JSON \u5B9E\u53C2\u6570\u7EC4\uFF0C\u5982 '[["sh600519"]]'`}],invoke:(n,t)=>{let o=t.positional[0];if(!o)throw new p("call \u7F3A\u5C11\u65B9\u6CD5\u8DEF\u5F84","\u7528\u6CD5: stock-sdk call <ns.method> --args '[...]'");let e=[],r=t.options.args;if(typeof r=="string")try{let c=JSON.parse(r);e=Array.isArray(c)?c:[c]}catch{throw new p("--args \u4E0D\u662F\u5408\u6CD5 JSON",`\u793A\u4F8B: --args '[["sh600519"]]'`)}if(!new Set(Bn()).has(o))throw new p(`\u672A\u77E5\u65B9\u6CD5: ${o}`,"\u5F62\u5982 quotes.cn / kline.cn(\u4EC5\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5,\u89C1 stock-sdk --help)");return m(n,o.split("."),e)}}],hn="mcp",zn=[...y,...k];function Bn(){return g.map(n=>n.path.join("."))}function _(n,t){let o=n.positional[0];if(!o)throw new p("\u7F3A\u5C11\u4EE3\u7801\u53C2\u6570",`\u7528\u6CD5: stock-sdk ${t} <symbol>`);return o}function kn(){let n=new Set(["help","h","version","V","quiet","q","pretty"]);for(let t of zn)for(let o of t.options??[])o.type==="boolean"&&n.add(o.flag);for(let t of C)n.add(t);return n}function gn(n){if(n.length===0)return null;for(let o=Math.min(3,n.length);o>=2;o--){let e=n.slice(0,o).join("."),r=k.find(s=>s.path.join(".")===e);if(r)return{spec:r,rest:n.slice(o)}}for(let o of y)if(o.alias?.includes(n[0]))return{spec:o,rest:n.slice(1)};let t=k.find(o=>o.path.join(".")===n[0]);return t?{spec:t,rest:n.slice(1)}:null}function Sn(){let n=["stock-sdk \u2014\u2014 \u80A1\u7968\u884C\u60C5\u547D\u4EE4\u884C\uFF08\u57FA\u4E8E stock-sdk v2 \u547D\u540D\u7A7A\u95F4 API\uFF09","","\u7528\u6CD5:"," stock-sdk <command> [args] [--flags]"," stock-sdk <namespace> <method> [args] [--flags] # \u76F4\u8FBE\u4EFB\u610F\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5","","\u5E38\u7528\u547D\u4EE4:"];for(let o of y){let e=o.alias?.[0]??o.path.join(" ");n.push(` ${e.padEnd(12)} ${o.summary}`)}n.push(" mcp \u542F\u52A8 MCP server (stdio)"),n.push(""),n.push("\u547D\u540D\u7A7A\u95F4\uFF08stock-sdk <ns> <method> ...\uFF09:");let t=[...new Set(k.map(o=>o.path[0]))];return n.push(" "+t.join(" / ")),n.push(""),n.push("\u5168\u5C40\u9009\u9879:"),n.push(" -f, --format json|table|csv \u8F93\u51FA\u683C\u5F0F (\u9ED8\u8BA4 json)"),n.push(" --pretty JSON \u7F29\u8FDB\u7F8E\u5316"),n.push(" --timeout <ms> \u8BF7\u6C42\u8D85\u65F6"),n.push(" -q, --quiet \u9759\u9ED8(\u53EA\u8F93\u51FA\u6570\u636E)"),n.push(" -h, --help \u663E\u793A\u5E2E\u52A9"),n.push(" -V, --version \u663E\u793A\u7248\u672C"),n.push(""),n.push("\u793A\u4F8B:"),n.push(" stock-sdk quote 600519 000858 00700"),n.push(" stock-sdk kline 600519 --period weekly --adjust hfq --limit 30"),n.push(" stock-sdk indicators 600519 --ma 5,10,20 --macd"),n.push(" stock-sdk board industry list --format table"),n.push(" stock-sdk options etf dailyKline 10004336"),n.push(""),n.push("\u8FD0\u884C `stock-sdk <command> --help` \u67E5\u770B\u5355\u6761\u547D\u4EE4\u7528\u6CD5\u3002"),n.join(`
|
|
8
8
|
`)}function yn(n){let t=n.alias?.[0]??n.path.join(" "),o=[`${t} \u2014\u2014 ${n.summary}`,""],e=(n.positional??[]).map(r=>{let s=r.required?`<${r.name}>`:`[${r.name}]`;return r.variadic?`${s}...`:s}).join(" ");if(o.push(`\u7528\u6CD5: stock-sdk ${t}${e?" "+e:""} [--flags]`),n.options?.length){o.push(""),o.push("\u9009\u9879:");for(let r of n.options){let s=r.enum?` (${r.enum.join("/")})`:"";o.push(` --${r.flag.padEnd(12)} ${r.desc}${s}`)}}return o.join(`
|
|
9
9
|
`)}function wn(n,t=new Set){let o=[],e={},r=!1,s=(i,a)=>{let u=e[i];if(u===void 0){e[i]=a;return}if(typeof a!="string"){e[i]=a;return}Array.isArray(u)?u.push(a):typeof u=="string"?e[i]=[u,a]:e[i]=a},c=i=>i!==void 0&&(i==="-"||!i.startsWith("-")||/^-\d/.test(i)),d=(i,a)=>{if(t.has(i))return s(i,!0),a;let u=n[a+1];return c(u)?(s(i,u),a+1):(s(i,!0),a)};for(let i=0;i<n.length;i++){let a=n[i];if(r){o.push(a);continue}if(a==="--"){r=!0;continue}if(a.startsWith("--")&&a.length>2){let u=a.slice(2),f=u.indexOf("=");f>=0?s(u.slice(0,f),u.slice(f+1)):i=d(u,i)}else if(a.startsWith("-")&&a.length>1&&!Wn(a)){let u=a.slice(1),f=u.indexOf("=");f>=0?s(u.slice(0,f),u.slice(f+1)):i=d(u,i)}else o.push(a)}return{positional:o,options:e}}function Wn(n){return/^-\d/.test(n)}var Yn=kn();process.stdout.on("error",n=>{n.code==="EPIPE"&&process.exit(0),process.stderr.write(`stock-sdk: stdout error: ${n.message}
|
|
10
|
-
`)});function Qn(){return"2.
|
|
10
|
+
`)});function Qn(){return"2.3.0"}function Xn(n){let t=n.format??n.f,o=t==="table"||t==="csv"?t:"json",e;if(typeof n.timeout=="string"||typeof n.timeout=="number"){let r=Number(n.timeout);!Number.isNaN(r)&&r>0&&(e=r)}return{format:o,pretty:n.pretty===!0,quiet:n.quiet===!0||n.q===!0,help:n.help===!0||n.h===!0,version:n.version===!0||n.V===!0,timeout:e}}async function Zn(){try{return(await import("./mcp.js")).startMcpServer(),0}catch(n){let t=n instanceof Error?n.message:String(n);return process.stderr.write(`stock-sdk: \u65E0\u6CD5\u542F\u52A8 MCP server: ${t}
|
|
11
11
|
`),1}}async function nt(n){let t="json";try{let o=wn(n,Yn),e=Xn(o.options);if(t=e.format,e.version)return process.stdout.write(Qn()+`
|
|
12
12
|
`),0;if(o.positional.length===0)return process.stdout.write(Sn()+`
|
|
13
13
|
`),0;if(o.positional[0]===hn)return e.help?(process.stdout.write(`stock-sdk mcp \u2014\u2014 \u542F\u52A8 MCP server (stdio transport)
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkSR7FGCVZcjs = require('./chunk-SR7FGCVZ.cjs');var _chunkC4CA7QBBcjs = require('./chunk-C4CA7QBB.cjs');var _chunkWCBK5KYAcjs = require('./chunk-WCBK5KYA.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkSR7FGCVZcjs = require('./chunk-SR7FGCVZ.cjs');var _chunkC4CA7QBBcjs = require('./chunk-C4CA7QBB.cjs');var _chunkWCBK5KYAcjs = require('./chunk-WCBK5KYA.cjs');var _chunkLMUFSVKQcjs = require('./chunk-LMUFSVKQ.cjs');var _chunkZESMWMHPcjs = require('./chunk-ZESMWMHP.cjs');var _chunkT5CH7H3Xcjs = require('./chunk-T5CH7H3X.cjs');var _chunkTVIEKKDQcjs = require('./chunk-TVIEKKDQ.cjs');var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');require('./chunk-4VDLQK6F.cjs');var me={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},de={sh:"CN",sz:"CN",hk:"HK",us:"US"},he={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},ke={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function Se(t){return t==="sh"||t==="sz"||t==="hk"||t==="us"||t==="global"}function ye(t){switch(t.market){case"CN":return t.exchange==="SSE"?"sh":t.exchange==="SZSE"?"sz":"unknown";case"HK":return"hk";case"US":return"us";case"GLOBAL":return"global";default:return"unknown"}}function Oe(t){let e=t.code.trim(),o=t.market.trim().toLowerCase(),s=_nullishCoalesce(me[t.market], () => (o)),r=Se(s)?s:void 0;if(r==="global")return{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:"global"};let c=r===void 0||r==="us"?e.replace(/^us(?=[A-Za-z.]+$)/i,""):e;try{let n=_chunkT5CH7H3Xcjs.e.call(void 0, c,r?{market:de[r]}:void 0);if(n.assetType!=="stock")return{code:e,market:"unknown"};let a=_nullishCoalesce(r, () => (ye(n)));return a==="unknown"?{code:e,market:"unknown"}:{code:n.market==="US"?n.code.toUpperCase():n.code,market:a}}catch (e2){return{code:e,market:"unknown"}}}function fe(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Ce(t){let{code:e,market:o}=t;return(o==="sh"||o==="sz")&&fe(e,o)?`https://quote.eastmoney.com/zs${e}.html`:o==="sh"||o==="sz"?`https://quote.eastmoney.com/${o}${e}.html`:o==="hk"?`https://quote.eastmoney.com/hk/${e}.html`:o==="us"?`https://quote.eastmoney.com/us/${e}.html`:o==="global"?`https://quote.eastmoney.com/gb/zs${_nullishCoalesce(ke[e], () => (e))}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function Me(t){let{code:e,market:o}=t;return o==="sh"||o==="sz"?`https://xueqiu.com/S/${o.toUpperCase()}${e}`:o==="hk"?`https://xueqiu.com/S/${e}`:o==="us"?`https://xueqiu.com/S/${e}`:o==="global"?`https://xueqiu.com/S/${_nullishCoalesce(he[e], () => (e))}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function ge(t){let e=Oe(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Ce(e)},{name:"\u96EA\u7403",url:Me(e)}]}exports.BROWSER_JSVARS_MUTEX_KEY = _chunkLMUFSVKQcjs.j; exports.FundService = _chunkLMUFSVKQcjs.s; exports.HttpError = _chunk4Q7UQ5Q3cjs.b; exports.INDICATOR_REGISTRY = _chunkZESMWMHPcjs.t; exports.MARKET_TZ = _chunkLMUFSVKQcjs.m; exports.MemoryCache = _chunkTVIEKKDQcjs.a; exports.MemoryCacheStore = _chunkWCBK5KYAcjs.a; exports.SdkError = _chunk4Q7UQ5Q3cjs.a; exports.StockSDK = _chunkLMUFSVKQcjs.t; exports.TradingCalendarService = _chunkLMUFSVKQcjs.r; exports.addIndicators = _chunkZESMWMHPcjs.x; exports.asyncPool = _chunkLMUFSVKQcjs.f; exports.backtest = _chunkC4CA7QBBcjs.b; exports.buildIndicatorContext = _chunkZESMWMHPcjs.s; exports.buildTimeMeta = _chunkLMUFSVKQcjs.o; exports.buildTimeMetaFromDateAndTime = _chunkLMUFSVKQcjs.p; exports.cacheThrough = _chunkWCBK5KYAcjs.b; exports.calcATR = _chunkZESMWMHPcjs.l; exports.calcBIAS = _chunkZESMWMHPcjs.j; exports.calcBOLL = _chunkZESMWMHPcjs.f; exports.calcCCI = _chunkZESMWMHPcjs.k; exports.calcChipDistribution = _chunkZESMWMHPcjs.r; exports.calcDMI = _chunkZESMWMHPcjs.o; exports.calcEMA = _chunkZESMWMHPcjs.b; exports.calcKC = _chunkZESMWMHPcjs.q; exports.calcKDJ = _chunkZESMWMHPcjs.g; exports.calcMA = _chunkZESMWMHPcjs.d; exports.calcMACD = _chunkZESMWMHPcjs.e; exports.calcOBV = _chunkZESMWMHPcjs.m; exports.calcROC = _chunkZESMWMHPcjs.n; exports.calcRSI = _chunkZESMWMHPcjs.h; exports.calcSAR = _chunkZESMWMHPcjs.p; exports.calcSMA = _chunkZESMWMHPcjs.a; exports.calcSignals = _chunkSR7FGCVZcjs.a; exports.calcWMA = _chunkZESMWMHPcjs.c; exports.calcWR = _chunkZESMWMHPcjs.i; exports.chunkArray = _chunkLMUFSVKQcjs.e; exports.createCacheKey = _chunkTVIEKKDQcjs.d; exports.decodeGBK = _chunkLMUFSVKQcjs.a; exports.default = _chunkLMUFSVKQcjs.u; exports.estimateIndicatorLookback = _chunkZESMWMHPcjs.w; exports.extractJsonFromJsonp = _chunkLMUFSVKQcjs.g; exports.fetchJsVars = _chunkLMUFSVKQcjs.k; exports.formatInTz = _chunkLMUFSVKQcjs.q; exports.generateSearchExternalLinks = ge; exports.getEnabledIndicatorKeys = _chunkZESMWMHPcjs.v; exports.getSdkErrorCode = _chunk4Q7UQ5Q3cjs.k; exports.getSharedCache = _chunkTVIEKKDQcjs.b; exports.jsonpRequest = _chunkLMUFSVKQcjs.h; exports.normalizeSymbol = _chunkT5CH7H3Xcjs.e; exports.parseJsVars = _chunkLMUFSVKQcjs.l; exports.parseMarketTime = _chunkLMUFSVKQcjs.n; exports.parseResponse = _chunkLMUFSVKQcjs.b; exports.safeNumber = _chunkLMUFSVKQcjs.c; exports.safeNumberOrNull = _chunkLMUFSVKQcjs.d; exports.screen = _chunkC4CA7QBBcjs.a; exports.toEastmoneySecid = _chunkT5CH7H3Xcjs.i; exports.toTencentSymbol = _chunkT5CH7H3Xcjs.h; exports.withScriptMutex = _chunkLMUFSVKQcjs.i;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-
|
|
2
|
-
export { A as AShareMarket,
|
|
1
|
+
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-6Qozazec.cjs';
|
|
2
|
+
export { A as AShareMarket, aT as BlockTradeDailyStatItem, D as BlockTradeDateOptions, aS as BlockTradeDetailItem, aR as BlockTradeMarketStatItem, aK as BoardChangeItem, am as CFFEXOptionQuote, x as CFFEXOptionQuotesOptions, aI as ChangeTypeCount, C as ChipDistributionRequestOptions, ad as ComexInventory, w as ComexInventoryOptions, a2 as ConceptBoard, a4 as ConceptBoardConstituent, a5 as ConceptBoardKline, q as ConceptBoardKlineOptions, a7 as ConceptBoardMinuteKline, r as ConceptBoardMinuteKlineOptions, a6 as ConceptBoardMinuteTimeline, a3 as ConceptBoardSpot, ap as DividendDetail, aP as DragonTigerBranchItem, J as DragonTigerDateOptions, aM as DragonTigerDetailItem, aO as DragonTigerInstitutionItem, aL as DragonTigerPeriod, aQ as DragonTigerSeatItem, aN as DragonTigerStockStatItem, al as ETFOptionCate, ak as ETFOptionExpireDay, aj as ETFOptionMonth, K as FullQuote, b6 as FundAssetAllocation, b5 as FundBondHolding, bc as FundBuySedemption, aZ as FundDividend, aY as FundDividendListOptions, a_ as FundDividendListResult, aW as FundDividendRank, b1 as FundEstimate, O as FundFlow, y as FundFlowOptions, ar as FundFlowRankItem, z as FundFlowRankOptions, ba as FundHolderStructure, b4 as FundHolding, b8 as FundManager, b0 as FundNavHistory, a$ as FundNavPoint, b9 as FundPerformanceEvaluation, b7 as FundPositionPoint, i as FundProfile, W as FundQuote, b3 as FundRankHistory, b2 as FundRankPoint, bf as FundSameType, be as FundSameTypePeer, bb as FundScaleChange, F as FundService, aX as FundSortDirection, bd as FundStageReturns, a8 as FuturesExchange, ac as FuturesInventory, v as FuturesInventoryOptions, ab as FuturesInventorySymbol, a9 as FuturesKline, s as FuturesKlineOptions, d as GetAShareCodeListOptions, G as GetAllAShareQuotesOptions, f as GetAllUSQuotesOptions, bk as GetHotThemesOptions, bm as GetThemeFundsOptions, bj as GetThemeListOptions, e as GetUSCodeListOptions, u as GlobalFuturesKlineOptions, aa as GlobalFuturesQuote, t as GlobalFuturesSpotOptions, k as HKKlineOptions, l as HKMinuteKlineOptions, Q as HKQuote, H as HistoryKlineOptions, bp as HotThemesResult, ae as IndexOptionProduct, aH as IndividualChangesDay, aJ as IndividualChangesHistory, c as IndividualChangesHistoryOptions, I as IndividualChangesOptions, aG as IndividualStockChangeItem, Y as IndustryBoard, _ as IndustryBoardConstituent, $ as IndustryBoardKline, o as IndustryBoardKlineOptions, a1 as IndustryBoardMinuteKline, p as IndustryBoardMinuteKlineOptions, a0 as IndustryBoardMinuteTimeline, Z as IndustryBoardSpot, aU as MarginAccountItem, aV as MarginTargetItem, at as MarketFundFlow, g as MarketStatus, M as MarketType, j as MinuteKlineOptions, au as NorthboundDirection, ay as NorthboundFlowSummary, aA as NorthboundHistoryItem, B as NorthboundHistoryOptions, az as NorthboundHoldingRankItem, N as NorthboundHoldingRankOptions, aB as NorthboundIndividualItem, av as NorthboundMarket, ax as NorthboundMinuteItem, aw as NorthboundRankPeriod, ah as OptionKline, an as OptionLHBItem, ai as OptionMinute, af as OptionTQuote, ag as OptionTQuoteResult, P as PanelLargeOrder, X as Quote, R as RequestClientOptions, ao as SearchResultType, as as SectorFundFlowItem, L as SimpleQuote, aF as StockChangeItem, aE as StockChangeType, aq as StockFundFlowDaily, S as StockSDK, h as SupportedMarket, bi as ThemeCategory, bn as ThemeFund, bq as ThemeFundItem, br as ThemeFundItemList, bo as ThemeFundListResult, bh as ThemeFundOrder, bl as ThemeFundRankSort, bg as ThemeFundSort, T as TradingCalendarService, m as USKlineOptions, U as USMarket, n as USMinuteKlineOptions, V as USQuote, aD as ZTPoolItem, aC as ZTPoolType, S as default } from './sdk-6Qozazec.cjs';
|
|
3
3
|
export { H as HttpError, P as ProviderName, a as ProviderRequestPolicy, b as RequestError, R as RetryOptions, S as SdkError, g as getSdkErrorCode } from './index-mlzPfoON.cjs';
|
|
4
4
|
export { CacheOptions, CacheStore, MaybePromise, MemoryCache, MemoryCacheStore, cacheThrough, createCacheKey, getSharedCache } from './cache.cjs';
|
|
5
|
-
export { e as ATROptions, A as AnyHistoryKline, d as BIASOptions, B as BOLLOptions, C as CCIOptions, D as DMIOptions, i as DMIResult, w as HKHistoryKline, x as HKMinuteKline, y as HKMinuteTimeline, H as HistoryKline, I as IndicatorOptions, k as KCOptions, l as KCResult, c as KDJOptions, K as KlineWithIndicators, b as MACDOptions, M as MAOptions, m as MARKET_TZ, n as MarketTz, t as MinuteKline, s as MinuteTimeline, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, R as RSIOptions, S as SAROptions, j as SARResult, T as TimeMeta, u as TodayTimeline, v as TodayTimelineResponse, U as USHistoryKline, z as USMinuteKline, E as USMinuteTimeline, W as WROptions, a as addIndicators, o as buildTimeMeta, q as buildTimeMetaFromDateAndTime, r as formatInTz, p as parseMarketTime } from './addIndicators-
|
|
6
|
-
export { INDICATOR_REGISTRY, IndicatorKey, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, estimateIndicatorLookback, getEnabledIndicatorKeys } from './indicators.cjs';
|
|
5
|
+
export { e as ATROptions, A as AnyHistoryKline, d as BIASOptions, B as BOLLOptions, C as CCIOptions, D as DMIOptions, i as DMIResult, w as HKHistoryKline, x as HKMinuteKline, y as HKMinuteTimeline, H as HistoryKline, I as IndicatorOptions, k as KCOptions, l as KCResult, c as KDJOptions, K as KlineWithIndicators, b as MACDOptions, M as MAOptions, m as MARKET_TZ, n as MarketTz, t as MinuteKline, s as MinuteTimeline, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, R as RSIOptions, S as SAROptions, j as SARResult, T as TimeMeta, u as TodayTimeline, v as TodayTimelineResponse, U as USHistoryKline, z as USMinuteKline, E as USMinuteTimeline, W as WROptions, a as addIndicators, o as buildTimeMeta, q as buildTimeMetaFromDateAndTime, r as formatInTz, p as parseMarketTime } from './addIndicators-_V3HEi0q.cjs';
|
|
7
6
|
export { A as AssetType, E as Exchange, M as Market, N as NormalizedSymbol, a as SymbolInput, S as SymbolRef, n as normalizeSymbol, b as toEastmoneySecid, t as toTencentSymbol } from './adapters-BiH4keVd.cjs';
|
|
7
|
+
export { INDICATOR_REGISTRY, IndicatorKey, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, estimateIndicatorLookback, getEnabledIndicatorKeys } from './indicators.cjs';
|
|
8
|
+
export { d as ChipDistributionItem, b as ChipDistributionOptions, a as ChipHistogram, C as ChipKlineLike, c as calcChipDistribution } from './chip-BbA23rr1.cjs';
|
|
8
9
|
export { Signal, SignalOptions, SignalType, calcSignals } from './signals.cjs';
|
|
9
10
|
export { BacktestOptions, BacktestReport, ScreenerBuilder, Strategy, StrategySignal, Trade, backtest, screen } from './screener.cjs';
|
|
10
11
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-
|
|
2
|
-
export { A as AShareMarket,
|
|
1
|
+
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-CtqVdrof.js';
|
|
2
|
+
export { A as AShareMarket, aT as BlockTradeDailyStatItem, D as BlockTradeDateOptions, aS as BlockTradeDetailItem, aR as BlockTradeMarketStatItem, aK as BoardChangeItem, am as CFFEXOptionQuote, x as CFFEXOptionQuotesOptions, aI as ChangeTypeCount, C as ChipDistributionRequestOptions, ad as ComexInventory, w as ComexInventoryOptions, a2 as ConceptBoard, a4 as ConceptBoardConstituent, a5 as ConceptBoardKline, q as ConceptBoardKlineOptions, a7 as ConceptBoardMinuteKline, r as ConceptBoardMinuteKlineOptions, a6 as ConceptBoardMinuteTimeline, a3 as ConceptBoardSpot, ap as DividendDetail, aP as DragonTigerBranchItem, J as DragonTigerDateOptions, aM as DragonTigerDetailItem, aO as DragonTigerInstitutionItem, aL as DragonTigerPeriod, aQ as DragonTigerSeatItem, aN as DragonTigerStockStatItem, al as ETFOptionCate, ak as ETFOptionExpireDay, aj as ETFOptionMonth, K as FullQuote, b6 as FundAssetAllocation, b5 as FundBondHolding, bc as FundBuySedemption, aZ as FundDividend, aY as FundDividendListOptions, a_ as FundDividendListResult, aW as FundDividendRank, b1 as FundEstimate, O as FundFlow, y as FundFlowOptions, ar as FundFlowRankItem, z as FundFlowRankOptions, ba as FundHolderStructure, b4 as FundHolding, b8 as FundManager, b0 as FundNavHistory, a$ as FundNavPoint, b9 as FundPerformanceEvaluation, b7 as FundPositionPoint, i as FundProfile, W as FundQuote, b3 as FundRankHistory, b2 as FundRankPoint, bf as FundSameType, be as FundSameTypePeer, bb as FundScaleChange, F as FundService, aX as FundSortDirection, bd as FundStageReturns, a8 as FuturesExchange, ac as FuturesInventory, v as FuturesInventoryOptions, ab as FuturesInventorySymbol, a9 as FuturesKline, s as FuturesKlineOptions, d as GetAShareCodeListOptions, G as GetAllAShareQuotesOptions, f as GetAllUSQuotesOptions, bk as GetHotThemesOptions, bm as GetThemeFundsOptions, bj as GetThemeListOptions, e as GetUSCodeListOptions, u as GlobalFuturesKlineOptions, aa as GlobalFuturesQuote, t as GlobalFuturesSpotOptions, k as HKKlineOptions, l as HKMinuteKlineOptions, Q as HKQuote, H as HistoryKlineOptions, bp as HotThemesResult, ae as IndexOptionProduct, aH as IndividualChangesDay, aJ as IndividualChangesHistory, c as IndividualChangesHistoryOptions, I as IndividualChangesOptions, aG as IndividualStockChangeItem, Y as IndustryBoard, _ as IndustryBoardConstituent, $ as IndustryBoardKline, o as IndustryBoardKlineOptions, a1 as IndustryBoardMinuteKline, p as IndustryBoardMinuteKlineOptions, a0 as IndustryBoardMinuteTimeline, Z as IndustryBoardSpot, aU as MarginAccountItem, aV as MarginTargetItem, at as MarketFundFlow, g as MarketStatus, M as MarketType, j as MinuteKlineOptions, au as NorthboundDirection, ay as NorthboundFlowSummary, aA as NorthboundHistoryItem, B as NorthboundHistoryOptions, az as NorthboundHoldingRankItem, N as NorthboundHoldingRankOptions, aB as NorthboundIndividualItem, av as NorthboundMarket, ax as NorthboundMinuteItem, aw as NorthboundRankPeriod, ah as OptionKline, an as OptionLHBItem, ai as OptionMinute, af as OptionTQuote, ag as OptionTQuoteResult, P as PanelLargeOrder, X as Quote, R as RequestClientOptions, ao as SearchResultType, as as SectorFundFlowItem, L as SimpleQuote, aF as StockChangeItem, aE as StockChangeType, aq as StockFundFlowDaily, S as StockSDK, h as SupportedMarket, bi as ThemeCategory, bn as ThemeFund, bq as ThemeFundItem, br as ThemeFundItemList, bo as ThemeFundListResult, bh as ThemeFundOrder, bl as ThemeFundRankSort, bg as ThemeFundSort, T as TradingCalendarService, m as USKlineOptions, U as USMarket, n as USMinuteKlineOptions, V as USQuote, aD as ZTPoolItem, aC as ZTPoolType, S as default } from './sdk-CtqVdrof.js';
|
|
3
3
|
export { H as HttpError, P as ProviderName, a as ProviderRequestPolicy, b as RequestError, R as RetryOptions, S as SdkError, g as getSdkErrorCode } from './index-mlzPfoON.js';
|
|
4
4
|
export { CacheOptions, CacheStore, MaybePromise, MemoryCache, MemoryCacheStore, cacheThrough, createCacheKey, getSharedCache } from './cache.js';
|
|
5
|
-
export { e as ATROptions, A as AnyHistoryKline, d as BIASOptions, B as BOLLOptions, C as CCIOptions, D as DMIOptions, i as DMIResult, w as HKHistoryKline, x as HKMinuteKline, y as HKMinuteTimeline, H as HistoryKline, I as IndicatorOptions, k as KCOptions, l as KCResult, c as KDJOptions, K as KlineWithIndicators, b as MACDOptions, M as MAOptions, m as MARKET_TZ, n as MarketTz, t as MinuteKline, s as MinuteTimeline, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, R as RSIOptions, S as SAROptions, j as SARResult, T as TimeMeta, u as TodayTimeline, v as TodayTimelineResponse, U as USHistoryKline, z as USMinuteKline, E as USMinuteTimeline, W as WROptions, a as addIndicators, o as buildTimeMeta, q as buildTimeMetaFromDateAndTime, r as formatInTz, p as parseMarketTime } from './addIndicators-
|
|
6
|
-
export { INDICATOR_REGISTRY, IndicatorKey, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, estimateIndicatorLookback, getEnabledIndicatorKeys } from './indicators.js';
|
|
5
|
+
export { e as ATROptions, A as AnyHistoryKline, d as BIASOptions, B as BOLLOptions, C as CCIOptions, D as DMIOptions, i as DMIResult, w as HKHistoryKline, x as HKMinuteKline, y as HKMinuteTimeline, H as HistoryKline, I as IndicatorOptions, k as KCOptions, l as KCResult, c as KDJOptions, K as KlineWithIndicators, b as MACDOptions, M as MAOptions, m as MARKET_TZ, n as MarketTz, t as MinuteKline, s as MinuteTimeline, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, R as RSIOptions, S as SAROptions, j as SARResult, T as TimeMeta, u as TodayTimeline, v as TodayTimelineResponse, U as USHistoryKline, z as USMinuteKline, E as USMinuteTimeline, W as WROptions, a as addIndicators, o as buildTimeMeta, q as buildTimeMetaFromDateAndTime, r as formatInTz, p as parseMarketTime } from './addIndicators-_V3HEi0q.js';
|
|
7
6
|
export { A as AssetType, E as Exchange, M as Market, N as NormalizedSymbol, a as SymbolInput, S as SymbolRef, n as normalizeSymbol, b as toEastmoneySecid, t as toTencentSymbol } from './adapters-BiH4keVd.js';
|
|
7
|
+
export { INDICATOR_REGISTRY, IndicatorKey, buildIndicatorContext, calcATR, calcBIAS, calcBOLL, calcCCI, calcDMI, calcEMA, calcKC, calcKDJ, calcMA, calcMACD, calcOBV, calcROC, calcRSI, calcSAR, calcSMA, calcWMA, calcWR, estimateIndicatorLookback, getEnabledIndicatorKeys } from './indicators.js';
|
|
8
|
+
export { d as ChipDistributionItem, b as ChipDistributionOptions, a as ChipHistogram, C as ChipKlineLike, c as calcChipDistribution } from './chip-BbA23rr1.js';
|
|
8
9
|
export { Signal, SignalOptions, SignalType, calcSignals } from './signals.js';
|
|
9
10
|
export { BacktestOptions, BacktestReport, ScreenerBuilder, Strategy, StrategySignal, Trade, backtest, screen } from './screener.js';
|
|
10
11
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ae}from"./chunk-LAT6L2TO.js";import{a as
|
|
1
|
+
import{a as ae}from"./chunk-LAT6L2TO.js";import{a as ce,b as pe}from"./chunk-LCX5Q36O.js";import{a as ue,b as le}from"./chunk-F3KZXCVO.js";import{a as p,b as u,c as l,d as m,e as S,f as y,g as M,h as g,i as R,j as x,k as I,l as b,m as A,n as T,o as K,p as N,q as E,r as re,s as ne,t as se,u as ie}from"./chunk-3ASJZ3YA.js";import{a as z,b as B,c as q,d as U,e as X,f as w,g as F,h as _,i as $,j as G,k as H,l as J,m as P,n as V,o as W,p as v,q as Q,r as Y,s as Z,t as j,v as ee,w as te,x as oe}from"./chunk-QGYIBFXP.js";import{e as i,h as D,i as L}from"./chunk-ZZ2IBUMV.js";import{a as O,b as f,d as C}from"./chunk-DU7MCVLJ.js";import{a as d,b as h,k}from"./chunk-UBIQBXQ7.js";import"./chunk-WOT6VMZA.js";var me={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},de={sh:"CN",sz:"CN",hk:"HK",us:"US"},he={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},ke={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function Se(t){return t==="sh"||t==="sz"||t==="hk"||t==="us"||t==="global"}function ye(t){switch(t.market){case"CN":return t.exchange==="SSE"?"sh":t.exchange==="SZSE"?"sz":"unknown";case"HK":return"hk";case"US":return"us";case"GLOBAL":return"global";default:return"unknown"}}function Oe(t){let e=t.code.trim(),o=t.market.trim().toLowerCase(),s=me[t.market]??o,r=Se(s)?s:void 0;if(r==="global")return{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:"global"};let c=r===void 0||r==="us"?e.replace(/^us(?=[A-Za-z.]+$)/i,""):e;try{let n=i(c,r?{market:de[r]}:void 0);if(n.assetType!=="stock")return{code:e,market:"unknown"};let a=r??ye(n);return a==="unknown"?{code:e,market:"unknown"}:{code:n.market==="US"?n.code.toUpperCase():n.code,market:a}}catch{return{code:e,market:"unknown"}}}function fe(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Ce(t){let{code:e,market:o}=t;return(o==="sh"||o==="sz")&&fe(e,o)?`https://quote.eastmoney.com/zs${e}.html`:o==="sh"||o==="sz"?`https://quote.eastmoney.com/${o}${e}.html`:o==="hk"?`https://quote.eastmoney.com/hk/${e}.html`:o==="us"?`https://quote.eastmoney.com/us/${e}.html`:o==="global"?`https://quote.eastmoney.com/gb/zs${ke[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function Me(t){let{code:e,market:o}=t;return o==="sh"||o==="sz"?`https://xueqiu.com/S/${o.toUpperCase()}${e}`:o==="hk"?`https://xueqiu.com/S/${e}`:o==="us"?`https://xueqiu.com/S/${e}`:o==="global"?`https://xueqiu.com/S/${he[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function ge(t){let e=Oe(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Ce(e)},{name:"\u96EA\u7403",url:Me(e)}]}export{x as BROWSER_JSVARS_MUTEX_KEY,ne as FundService,h as HttpError,j as INDICATOR_REGISTRY,A as MARKET_TZ,O as MemoryCache,ue as MemoryCacheStore,d as SdkError,se as StockSDK,re as TradingCalendarService,oe as addIndicators,y as asyncPool,pe as backtest,Z as buildIndicatorContext,K as buildTimeMeta,N as buildTimeMetaFromDateAndTime,le as cacheThrough,J as calcATR,G as calcBIAS,w as calcBOLL,H as calcCCI,Y as calcChipDistribution,W as calcDMI,B as calcEMA,Q as calcKC,F as calcKDJ,U as calcMA,X as calcMACD,P as calcOBV,V as calcROC,_ as calcRSI,v as calcSAR,z as calcSMA,ae as calcSignals,q as calcWMA,$ as calcWR,S as chunkArray,C as createCacheKey,p as decodeGBK,ie as default,te as estimateIndicatorLookback,M as extractJsonFromJsonp,I as fetchJsVars,E as formatInTz,ge as generateSearchExternalLinks,ee as getEnabledIndicatorKeys,k as getSdkErrorCode,f as getSharedCache,g as jsonpRequest,i as normalizeSymbol,b as parseJsVars,T as parseMarketTime,u as parseResponse,l as safeNumber,m as safeNumberOrNull,ce as screen,L as toEastmoneySecid,D as toTencentSymbol,R as withScriptMutex};
|
package/dist/indicators.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZESMWMHPcjs = require('./chunk-ZESMWMHP.cjs');require('./chunk-4VDLQK6F.cjs');exports.INDICATOR_REGISTRY = _chunkZESMWMHPcjs.t; exports.addIndicators = _chunkZESMWMHPcjs.x; exports.buildIndicatorContext = _chunkZESMWMHPcjs.s; exports.calcATR = _chunkZESMWMHPcjs.l; exports.calcBIAS = _chunkZESMWMHPcjs.j; exports.calcBOLL = _chunkZESMWMHPcjs.f; exports.calcCCI = _chunkZESMWMHPcjs.k; exports.calcChipDistribution = _chunkZESMWMHPcjs.r; exports.calcDMI = _chunkZESMWMHPcjs.o; exports.calcEMA = _chunkZESMWMHPcjs.b; exports.calcKC = _chunkZESMWMHPcjs.q; exports.calcKDJ = _chunkZESMWMHPcjs.g; exports.calcMA = _chunkZESMWMHPcjs.d; exports.calcMACD = _chunkZESMWMHPcjs.e; exports.calcOBV = _chunkZESMWMHPcjs.m; exports.calcROC = _chunkZESMWMHPcjs.n; exports.calcRSI = _chunkZESMWMHPcjs.h; exports.calcSAR = _chunkZESMWMHPcjs.p; exports.calcSMA = _chunkZESMWMHPcjs.a; exports.calcWMA = _chunkZESMWMHPcjs.c; exports.calcWR = _chunkZESMWMHPcjs.i; exports.estimateIndicatorLookback = _chunkZESMWMHPcjs.w; exports.getEnabledIndicatorKeys = _chunkZESMWMHPcjs.v; exports.hasCumulativeIndicator = _chunkZESMWMHPcjs.u;
|
package/dist/indicators.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { M as MAOptions, F as MAResult, b as MACDOptions, G as MACDResult, B as BOLLOptions, J as BOLLResult, L as OHLCV, c as KDJOptions, N as KDJResult, R as RSIOptions, P as RSIResult, W as WROptions, Q as WRResult, d as BIASOptions, V as BIASResult, C as CCIOptions, X as CCIResult, e as ATROptions, Y as ATRResult, I as IndicatorOptions, Z as PeriodsShorthand, A as AnyHistoryKline } from './addIndicators-
|
|
2
|
-
export { D as DMIOptions, i as DMIResult, k as KCOptions, l as KCResult, K as KlineWithIndicators, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, S as SAROptions, j as SARResult, a as addIndicators } from './addIndicators-
|
|
1
|
+
import { M as MAOptions, F as MAResult, b as MACDOptions, G as MACDResult, B as BOLLOptions, J as BOLLResult, L as OHLCV, c as KDJOptions, N as KDJResult, R as RSIOptions, P as RSIResult, W as WROptions, Q as WRResult, d as BIASOptions, V as BIASResult, C as CCIOptions, X as CCIResult, e as ATROptions, Y as ATRResult, I as IndicatorOptions, Z as PeriodsShorthand, A as AnyHistoryKline } from './addIndicators-_V3HEi0q.cjs';
|
|
2
|
+
export { D as DMIOptions, i as DMIResult, k as KCOptions, l as KCResult, K as KlineWithIndicators, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, S as SAROptions, j as SARResult, a as addIndicators } from './addIndicators-_V3HEi0q.cjs';
|
|
3
|
+
export { d as ChipDistributionItem, b as ChipDistributionOptions, a as ChipHistogram, C as ChipKlineLike, c as calcChipDistribution } from './chip-BbA23rr1.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 计算简单移动平均线 SMA
|
|
6
7
|
*
|
|
7
8
|
* F36: 旧实现逐 bar 重扫整窗(O(n×period),默认 7 周期 × 3000 bar ≈ 150 万次
|
|
8
9
|
* 内循环),改为 SlidingWindowSum 滑窗累计(O(n))。null 语义(窗口内任一
|
|
9
|
-
* null → 该位输出 null)与 round(·,
|
|
10
|
+
* null → 该位输出 null)与 round(·, 3) 舍入保持不变。
|
|
10
11
|
*/
|
|
11
|
-
declare function calcSMA(data: (number | null)[], period: number): (number | null)[];
|
|
12
|
+
declare function calcSMA(data: (number | null)[], period: number, decimals?: number): (number | null)[];
|
|
12
13
|
/**
|
|
13
14
|
* 计算指数移动平均线 EMA
|
|
14
15
|
* 使用前 N 天的 SMA 作为 EMA 初始值,避免首日偏差
|
|
@@ -16,14 +17,14 @@ declare function calcSMA(data: (number | null)[], period: number): (number | nul
|
|
|
16
17
|
* F36: 不改 —— EMA 本身是 O(n) 递推,仅种子 SMA 做一次性扫窗;
|
|
17
18
|
* 改写无收益且会扰动浮点结果。
|
|
18
19
|
*/
|
|
19
|
-
declare function calcEMA(data: (number | null)[], period: number): (number | null)[];
|
|
20
|
+
declare function calcEMA(data: (number | null)[], period: number, decimals?: number): (number | null)[];
|
|
20
21
|
/**
|
|
21
22
|
* 计算加权移动平均线 WMA
|
|
22
23
|
*
|
|
23
24
|
* F36: 不改 —— 权重随窗口内位置变化,rolling 化需要额外维护两条累计
|
|
24
25
|
* (Σx 与 Σw·x)且浮点误差放大,收益与正确性风险不成比例,保持逐窗实现。
|
|
25
26
|
*/
|
|
26
|
-
declare function calcWMA(data: (number | null)[], period: number): (number | null)[];
|
|
27
|
+
declare function calcWMA(data: (number | null)[], period: number, decimals?: number): (number | null)[];
|
|
27
28
|
/**
|
|
28
29
|
* 批量计算均线
|
|
29
30
|
*/
|
|
@@ -375,7 +376,7 @@ interface IndicatorDescriptor<K extends IndicatorKey = IndicatorKey> {
|
|
|
375
376
|
* 平滑/递推状态型指标(如 KDJ/RSI 的 Wilder 平滑、MACD 的 EMA 链):
|
|
376
377
|
* 每根值递推依赖前一根的内部状态,切片起点不同则状态不同 —— 消费方
|
|
377
378
|
* (indicatorService 的 refetch 切片)需按 15× 周期暖机让状态收敛到
|
|
378
|
-
* round(
|
|
379
|
+
* round(3) 之下。与 cumulative 同为「消费方策略由 registry 声明」的机制
|
|
379
380
|
* (R3-12):纯窗口型指标(SMA/BOLL/WR 等)只看固定窗口,无需暖机放大。
|
|
380
381
|
* ma 特殊:仅 type:'ema' 才递归,由 estimateLookback 的 emaBased 动态承担,
|
|
381
382
|
* 故 ma 不静态标记 recursive。
|
package/dist/indicators.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { M as MAOptions, F as MAResult, b as MACDOptions, G as MACDResult, B as BOLLOptions, J as BOLLResult, L as OHLCV, c as KDJOptions, N as KDJResult, R as RSIOptions, P as RSIResult, W as WROptions, Q as WRResult, d as BIASOptions, V as BIASResult, C as CCIOptions, X as CCIResult, e as ATROptions, Y as ATRResult, I as IndicatorOptions, Z as PeriodsShorthand, A as AnyHistoryKline } from './addIndicators-
|
|
2
|
-
export { D as DMIOptions, i as DMIResult, k as KCOptions, l as KCResult, K as KlineWithIndicators, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, S as SAROptions, j as SARResult, a as addIndicators } from './addIndicators-
|
|
1
|
+
import { M as MAOptions, F as MAResult, b as MACDOptions, G as MACDResult, B as BOLLOptions, J as BOLLResult, L as OHLCV, c as KDJOptions, N as KDJResult, R as RSIOptions, P as RSIResult, W as WROptions, Q as WRResult, d as BIASOptions, V as BIASResult, C as CCIOptions, X as CCIResult, e as ATROptions, Y as ATRResult, I as IndicatorOptions, Z as PeriodsShorthand, A as AnyHistoryKline } from './addIndicators-_V3HEi0q.js';
|
|
2
|
+
export { D as DMIOptions, i as DMIResult, k as KCOptions, l as KCResult, K as KlineWithIndicators, O as OBVOptions, f as OBVResult, g as ROCOptions, h as ROCResult, S as SAROptions, j as SARResult, a as addIndicators } from './addIndicators-_V3HEi0q.js';
|
|
3
|
+
export { d as ChipDistributionItem, b as ChipDistributionOptions, a as ChipHistogram, C as ChipKlineLike, c as calcChipDistribution } from './chip-BbA23rr1.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 计算简单移动平均线 SMA
|
|
6
7
|
*
|
|
7
8
|
* F36: 旧实现逐 bar 重扫整窗(O(n×period),默认 7 周期 × 3000 bar ≈ 150 万次
|
|
8
9
|
* 内循环),改为 SlidingWindowSum 滑窗累计(O(n))。null 语义(窗口内任一
|
|
9
|
-
* null → 该位输出 null)与 round(·,
|
|
10
|
+
* null → 该位输出 null)与 round(·, 3) 舍入保持不变。
|
|
10
11
|
*/
|
|
11
|
-
declare function calcSMA(data: (number | null)[], period: number): (number | null)[];
|
|
12
|
+
declare function calcSMA(data: (number | null)[], period: number, decimals?: number): (number | null)[];
|
|
12
13
|
/**
|
|
13
14
|
* 计算指数移动平均线 EMA
|
|
14
15
|
* 使用前 N 天的 SMA 作为 EMA 初始值,避免首日偏差
|
|
@@ -16,14 +17,14 @@ declare function calcSMA(data: (number | null)[], period: number): (number | nul
|
|
|
16
17
|
* F36: 不改 —— EMA 本身是 O(n) 递推,仅种子 SMA 做一次性扫窗;
|
|
17
18
|
* 改写无收益且会扰动浮点结果。
|
|
18
19
|
*/
|
|
19
|
-
declare function calcEMA(data: (number | null)[], period: number): (number | null)[];
|
|
20
|
+
declare function calcEMA(data: (number | null)[], period: number, decimals?: number): (number | null)[];
|
|
20
21
|
/**
|
|
21
22
|
* 计算加权移动平均线 WMA
|
|
22
23
|
*
|
|
23
24
|
* F36: 不改 —— 权重随窗口内位置变化,rolling 化需要额外维护两条累计
|
|
24
25
|
* (Σx 与 Σw·x)且浮点误差放大,收益与正确性风险不成比例,保持逐窗实现。
|
|
25
26
|
*/
|
|
26
|
-
declare function calcWMA(data: (number | null)[], period: number): (number | null)[];
|
|
27
|
+
declare function calcWMA(data: (number | null)[], period: number, decimals?: number): (number | null)[];
|
|
27
28
|
/**
|
|
28
29
|
* 批量计算均线
|
|
29
30
|
*/
|
|
@@ -375,7 +376,7 @@ interface IndicatorDescriptor<K extends IndicatorKey = IndicatorKey> {
|
|
|
375
376
|
* 平滑/递推状态型指标(如 KDJ/RSI 的 Wilder 平滑、MACD 的 EMA 链):
|
|
376
377
|
* 每根值递推依赖前一根的内部状态,切片起点不同则状态不同 —— 消费方
|
|
377
378
|
* (indicatorService 的 refetch 切片)需按 15× 周期暖机让状态收敛到
|
|
378
|
-
* round(
|
|
379
|
+
* round(3) 之下。与 cumulative 同为「消费方策略由 registry 声明」的机制
|
|
379
380
|
* (R3-12):纯窗口型指标(SMA/BOLL/WR 等)只看固定窗口,无需暖机放大。
|
|
380
381
|
* ma 特殊:仅 type:'ema' 才递归,由 estimateLookback 的 emaBased 动态承担,
|
|
381
382
|
* 故 ma 不静态标记 recursive。
|
package/dist/indicators.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x}from"./chunk-QGYIBFXP.js";import"./chunk-WOT6VMZA.js";export{t as INDICATOR_REGISTRY,x as addIndicators,s as buildIndicatorContext,l as calcATR,j as calcBIAS,f as calcBOLL,k as calcCCI,r as calcChipDistribution,o as calcDMI,b as calcEMA,q as calcKC,g as calcKDJ,d as calcMA,e as calcMACD,m as calcOBV,n as calcROC,h as calcRSI,p as calcSAR,a as calcSMA,c as calcWMA,i as calcWR,w as estimateIndicatorLookback,v as getEnabledIndicatorKeys,u as hasCumulativeIndicator};
|
package/dist/mcp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
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 _chunk6IFA2HGDcjs = require('./chunk-6IFA2HGD.cjs');var _chunkLMUFSVKQcjs = require('./chunk-LMUFSVKQ.cjs');require('./chunk-ZESMWMHP.cjs');require('./chunk-T5CH7H3X.cjs');require('./chunk-TVIEKKDQ.cjs');var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');require('./chunk-4VDLQK6F.cjs');var v=["2025-11-25","2025-06-18"],X=v[0],R={name:"stock-sdk",version:"2.3.0"},K=-32700,S=-32600,$=-32601,u=-32602,Y=-32603;function L(e){return typeof e=="string"&&v.includes(e)?e:X}function p(...e){process.stderr.write(e.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ")+`
|
|
2
2
|
`)}function l(e){process.stdout.write(JSON.stringify(e)+`
|
|
3
3
|
`)}var k=1e6;function q(e){let o="",t=!1;process.stdin.setEncoding("utf8"),process.stdin.on("data",r=>{o+=r;let n=o.indexOf(`
|
|
4
4
|
`);for(;n>=0;){let i=o.slice(0,n);o=o.slice(n+1),t?(t=!1,l({jsonrpc:"2.0",id:null,error:{code:S,message:`Message too large (limit ${k} bytes)`}})):i.trim()&&e(i),n=o.indexOf(`
|
|
5
|
-
`)}!t&&o.length>k?(p(`[stock-sdk mcp] \u8F93\u5165\u8D85\u957F\uFF08${o.length} bytes \u65E0\u6362\u884C\uFF0C\u8D85 ${k} \u4E0A\u9650\uFF09\uFF0C\u4E22\u5F03\u81F3\u4E0B\u4E00\u6362\u884C`),t=!0,o=""):t&&(o="")}),process.stdin.on("error",r=>p("[stock-sdk mcp] stdin error:",r.message)),process.stdout.on("error",r=>{r.code==="EPIPE"?(p("[stock-sdk mcp] stdout EPIPE\uFF08client \u65AD\u5F00\uFF09\uFF0C\u9000\u51FA"),process.exit(0)):p("[stock-sdk mcp] stdout error:",r.message)})}var H={string:"string",enum:"string",number:"integer",boolean:"boolean"};function _(e){return _nullishCoalesce(_nullishCoalesce(e.jsonKey, () => (e.field)), () => (e.flag))}function z(e){return _optionalChain([e, 'access', _2 => _2.enum, 'optionalAccess', _3 => _3.map, 'call', _4 => _4(o=>_nullishCoalesce(_optionalChain([e, 'access', _5 => _5.map, 'optionalAccess', _6 => _6[o]]), () => (o)))])}function u(e){let o=H[e.type];if(!o)throw new Error(`\u53C2\u6570 --${e.flag} \u7684\u7C7B\u578B ${e.type} \u4E0D\u80FD\u6D3E\u751F MCP schema\uFF08\u8BF7\u6807\u8BB0 mcp:false\uFF09`);let t={type:o},r=z(e);r&&(t.enum=r),e.default!==void 0&&(t.default=e.default);let n=_nullishCoalesce(e.mcpDesc, () => (e.desc));return n&&(t.description=n),t}function Q(e){let o={type:"string"};return e.enum&&(o.enum=e.enum),e.default!==void 0&&(o.default=e.default),e.desc&&(o.description=e.desc),o}var G={type:"array",items:{type:"string"},description:"\u4EE3\u7801\u6570\u7EC4\uFF0C\u5E26\u4E0D\u5E26\u4EA4\u6613\u6240\u524D\u7F00\u5747\u53EF\uFF0C\u5982 ['sh600519','000001','600036']"};function V(e){return(_nullishCoalesce(e.params, () => ([]))).filter(o=>o.mcp!==!1)}function Z(e){let o={},t=[];(e.argShape==="codes[]"||e.argShape==="codes+options")&&(o.codes=G,t.push("codes"));for(let r of _nullishCoalesce(e.positional, () => ([])))o[r.name]=Q(r),r.required&&t.push(r.name);for(let r of V(e))o[_(r)]=u(r),r.required&&t.push(_(r));return{type:"object",properties:o,required:t.length>0?t:void 0,additionalProperties:!1}}function ee(e,o){let t=_chunkLNFNYJHTcjs.a.call(void 0, e,o);if(!t)throw new Error(`SDK \u4E0A\u4E0D\u5B58\u5728\u65B9\u6CD5: ${o.join(".")}`);return r=>t.fn.apply(t.parent,r)}function oe(e){let o=_nullishCoalesce(e.positional, () => ([])),t=V(e);return(r,n)=>{let i=ee(r,e.path),c=o.map(a=>n[a.name]),s={};for(let a of t)s[_nullishCoalesce(a.field, () => (a.flag))]=n[_(a)];switch(e.argShape){case"none":return i([]);case"codes[]":return i([n.codes]);case"codes+options":return i([n.codes,s]);case"symbol+options":return i([...c,s]);case"options":return i([s]);case"positional":return i(c);default:throw new Error(`\u4E0D\u652F\u6301\u7684 argShape: ${e.argShape}`)}}}function U(e){if(e.mcp===!1||!e.toolName)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u672A\u58F0\u660E MCP \u5DE5\u5177\uFF0C\u4E0D\u80FD\u6D3E\u751F ToolDef`);if(e.mcpCustom)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u7684 MCP \u5DE5\u5177\u4E3A\u624B\u5199\u5B9E\u73B0\uFF0C\u4E0D\u80FD\u81EA\u52A8\u6D3E\u751F`);return{name:e.toolName,description:_nullishCoalesce(e.mcpDesc, () => (e.summary)),inputSchema:Z(e),tier:_nullishCoalesce(e.tier, () => ("full")),invoke:oe(e)}}var te=["ma","macd","boll","kdj","rsi","wr","bias","cci","atr","obv","roc","dmi","sar","kc"],g=_chunkLNFNYJHTcjs.n.call(void 0, "kline.withIndicators"),W={name:g.toolName,tier:_nullishCoalesce(g.tier, () => ("full")),description:_nullishCoalesce(g.mcpDesc, () => (g.summary)),inputSchema:{type:"object",properties:{symbol:{type:"string",description:"\u80A1\u7968\u4EE3\u7801\uFF08A \u80A1 / \u6E2F\u80A1 / \u7F8E\u80A1\uFF09"},market:u(_chunkLNFNYJHTcjs.j),period:u(_chunkLNFNYJHTcjs.e),adjust:u(_chunkLNFNYJHTcjs.d),startDate:{...u(_chunkLNFNYJHTcjs.g),description:"\u8D77\u59CB\u65E5\u671F YYYYMMDD \u6216 YYYY-MM-DD"},endDate:{...u(_chunkLNFNYJHTcjs.h),description:"\u7ED3\u675F\u65E5\u671F YYYYMMDD \u6216 YYYY-MM-DD"},indicators:{type:"object",description:"\u6307\u6807\u914D\u7F6E\u5BF9\u8C61\uFF0C\u952E\u53D6\u81EA "+te.join(" / ")+"\uFF1B\u503C\u4E3A true\uFF08\u9ED8\u8BA4\u53C2\u6570\uFF09\u6216\u914D\u7F6E\u5BF9\u8C61",properties:{ma:{description:"MA \u5747\u7EBF\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods: [5,10,20], type: sma|ema|wma }"},macd:{description:"MACD\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { short, long, signal }"},boll:{description:"\u5E03\u6797\u5E26\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, stdDev }"},kdj:{description:"KDJ\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, kPeriod, dPeriod }"},rsi:{description:"RSI\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods }"},wr:{description:"\u5A01\u5EC9\u6307\u6807 WR\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods }"},bias:{description:"BIAS \u4E56\u79BB\u7387\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods }"},cci:{description:"CCI\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period }"},atr:{description:"ATR \u771F\u5B9E\u6CE2\u5E45\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period }"},obv:{description:"OBV\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { maPeriod }"},roc:{description:"ROC\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, signalPeriod }"},dmi:{description:"DMI / ADX\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, adxPeriod }"},sar:{description:"SAR \u629B\u7269\u7EBF\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { afStart, afIncrement, afMax }"},kc:{description:"Keltner \u901A\u9053 KC\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { emaPeriod, atrPeriod, multiplier }"}}}},required:["symbol"],additionalProperties:!1},invoke:(e,o)=>e.kline.withIndicators(o.symbol,{market:o.market,period:o.period,adjust:o.adjust,startDate:o.startDate,endDate:o.endDate,indicators:o.indicators})};var re={"kline.withIndicators":W},h=_chunkLNFNYJHTcjs.m.filter(e=>e.mcp!==!1).map(e=>{if(e.mcpCustom){let o=re[e.path.join(".")];if(!o)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u6807\u8BB0\u4E86 mcpCustom \u4F46\u672A\u6CE8\u518C\u624B\u5199\u5DE5\u5177`);return o}return U(e)}),_e=new Map(h.map(e=>[e.name,e]));function B(e){if(Array.isArray(e)){let o=new Set(e);return h.filter(t=>o.has(t.name))}return e==="full"?h:h.filter(o=>o.tier==="core")}var O=200,ne=8e4;function se(e){return Array.isArray(e)&&e.length>O?{total:e.length,truncated:!0,note:`\u7ED3\u679C\u8FC7\u5927\uFF0C\u4EC5\u8FD4\u56DE\u524D ${O} \u6761\uFF1B\u8BF7\u7528\u65E5\u671F / \u5206\u9875 / \u5E02\u573A\u7B49\u53C2\u6570\u7F29\u5C0F\u8303\u56F4`,sample:e.slice(0,O)}:e}function F(e){let o=_nullishCoalesce(JSON.stringify(se(e)), () => ("null"));return o.length>ne?{content:[{type:"text",text:JSON.stringify({truncated:!0,reason:"oversized",approxKB:Math.round(o.length/1024),note:"\u7ED3\u679C\u4F53\u79EF\u8FC7\u5927\uFF0C\u5DF2\u7701\u7565\u6570\u636E\u4F53\uFF1B\u8BF7\u7528\u66F4\u5C0F\u7684\u65E5\u671F / \u5206\u9875 / \u8303\u56F4\u53C2\u6570\uFF0C\u6216\u76F4\u63A5\u7528 SDK \u83B7\u53D6\u5B8C\u6574\u6570\u636E"})}],_meta:{truncated:!0,approxChars:o.length}}:{content:[{type:"text",text:o}]}}function E(e){let o=_chunk4Q7UQ5Q3cjs.i.call(void 0, e)?e.code:"UNKNOWN",t=e instanceof Error?e.message:String(e),r=_chunk4Q7UQ5Q3cjs.i.call(void 0, e)?{code:e.code,provider:e.provider,url:e.url,status:e.status,details:e.details}:{code:o};return{content:[{type:"text",text:`Error[${o}]: ${t}`}],isError:!0,_meta:r}}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ie(e,o){switch(o){case"array":return Array.isArray(e);case"string":return typeof e=="string";case"integer":return Number.isInteger(e);case"number":return typeof e=="number";case"boolean":return typeof e=="boolean";case"object":return f(e);default:return!0}}function ce(e,o){if(e.additionalProperties===!1){let t=new Set(Object.keys(e.properties));for(let r of Object.keys(o))if(!t.has(r))return`\u672A\u77E5\u53C2\u6570 "${r}"`}for(let t of _nullishCoalesce(e.required, () => ([])))if(o[t]===void 0||o[t]===null)return`\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 "${t}"`;for(let[t,r]of Object.entries(e.properties)){let n=o[t];if(n!==void 0){if(r.type&&!ie(n,r.type))return`\u53C2\u6570 "${t}" \u7C7B\u578B\u5E94\u4E3A ${r.type}`;if(r.enum&&!r.enum.includes(n))return`\u53C2\u6570 "${t}" \u53D6\u503C\u975E\u6CD5\u300C${String(n)}\u300D\uFF0C\u53EF\u9009: ${r.enum.join(" / ")}`}}return null}async function ae(e,o){let t=_nullishCoalesce(e.id, () => (null)),r=e.id!==void 0&&e.id!==null,n=s=>({jsonrpc:"2.0",id:t,result:s}),i=(s,a)=>({jsonrpc:"2.0",id:t,error:{code:s,message:a}});if(e.jsonrpc!=="2.0"||typeof e.method!="string"||e.method.length===0)return r?i(S,"Invalid Request"):null;let c=e.params;switch(e.method){case"initialize":{let s=f(c)?c.protocolVersion:void 0;return n({protocolVersion:L(s),capabilities:{tools:{}},serverInfo:R})}case"notifications/initialized":case"notifications/cancelled":return null;case"ping":return n({});case"tools/list":return n({tools:o.tools.map(s=>({name:s.name,description:s.description,inputSchema:s.inputSchema}))});case"tools/call":{if(!f(c))return i(d,"params must be an object");let s=c.name;if(typeof s!="string")return i(d,"params.name must be a string");let a=o.toolMap.get(s);if(!a)return i(d,`Unknown tool: ${s}`);let m=c.arguments;if(m!==void 0&&!f(m))return i(d,"params.arguments must be an object");let D=f(m)?m:{},P=ce(a.inputSchema,D);if(P)return n(E(new (0, _chunk4Q7UQ5Q3cjs.e)(P)));try{let y=await a.invoke(o.sdk,D);return n(F(y))}catch(y){return n(E(y))}}default:return r?i($,`Unknown method: ${e.method}`):null}}function pe(e){if(e)return e;let o=process.env.STOCK_SDK_MCP_TOOLS;if(!o)return"core";if(o==="core"||o==="full")return o;let t=o.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:"core"}function ue(e){if(e)return e;let o=process.env.STOCK_SDK_MCP_TIMEOUT,t=o?Number(o):void 0;return t&&!Number.isNaN(t)&&t>0?{timeout:t}:{}}function be(e={}){let o=new (0, _chunkRHTNYDO2cjs.t)(ue(e.sdk)),t=B(pe(e.tools)),r={sdk:o,tools:t,toolMap:new Map(t.map(i=>[i.name,i]))};p(`[stock-sdk mcp] ready \xB7 ${t.length} tools \xB7 ${R.name}@${R.version}`),q(i=>{n(i)}),process.stdin.on("end",()=>p("[stock-sdk mcp] stdin closed, exiting"));async function n(i){let c;try{c=JSON.parse(i)}catch (e2){l({jsonrpc:"2.0",id:null,error:{code:K,message:"Parse error"}});return}try{let s=await ae(c,r);s&&l(s)}catch(s){p("[stock-sdk mcp] internal error:",_nullishCoalesce(_optionalChain([s, 'optionalAccess', _7 => _7.message]), () => (String(s)))),c.id!==void 0&&c.id!==null&&l({jsonrpc:"2.0",id:c.id,error:{code:Y,message:String(_nullishCoalesce(_optionalChain([s, 'optionalAccess', _8 => _8.message]), () => (s)))}})}}}exports.dispatchMessage = ae; exports.startMcpServer = be;
|
|
5
|
+
`)}!t&&o.length>k?(p(`[stock-sdk mcp] \u8F93\u5165\u8D85\u957F\uFF08${o.length} bytes \u65E0\u6362\u884C\uFF0C\u8D85 ${k} \u4E0A\u9650\uFF09\uFF0C\u4E22\u5F03\u81F3\u4E0B\u4E00\u6362\u884C`),t=!0,o=""):t&&(o="")}),process.stdin.on("error",r=>p("[stock-sdk mcp] stdin error:",r.message)),process.stdout.on("error",r=>{r.code==="EPIPE"?(p("[stock-sdk mcp] stdout EPIPE\uFF08client \u65AD\u5F00\uFF09\uFF0C\u9000\u51FA"),process.exit(0)):p("[stock-sdk mcp] stdout error:",r.message)})}var H={string:"string",enum:"string",number:"integer",boolean:"boolean"};function _(e){return _nullishCoalesce(_nullishCoalesce(e.jsonKey, () => (e.field)), () => (e.flag))}function z(e){return _optionalChain([e, 'access', _2 => _2.enum, 'optionalAccess', _3 => _3.map, 'call', _4 => _4(o=>_nullishCoalesce(_optionalChain([e, 'access', _5 => _5.map, 'optionalAccess', _6 => _6[o]]), () => (o)))])}function d(e){let o=H[e.type];if(!o)throw new Error(`\u53C2\u6570 --${e.flag} \u7684\u7C7B\u578B ${e.type} \u4E0D\u80FD\u6D3E\u751F MCP schema\uFF08\u8BF7\u6807\u8BB0 mcp:false\uFF09`);let t={type:o},r=z(e);r&&(t.enum=r),e.default!==void 0&&(t.default=e.default);let n=_nullishCoalesce(e.mcpDesc, () => (e.desc));return n&&(t.description=n),t}function Q(e){let o={type:"string"};return e.enum&&(o.enum=e.enum),e.default!==void 0&&(o.default=e.default),e.desc&&(o.description=e.desc),o}var G={type:"array",items:{type:"string"},description:"\u4EE3\u7801\u6570\u7EC4\uFF0C\u5E26\u4E0D\u5E26\u4EA4\u6613\u6240\u524D\u7F00\u5747\u53EF\uFF0C\u5982 ['sh600519','000001','600036']"};function V(e){return(_nullishCoalesce(e.params, () => ([]))).filter(o=>o.mcp!==!1)}function Z(e){let o={},t=[];(e.argShape==="codes[]"||e.argShape==="codes+options")&&(o.codes=G,t.push("codes"));for(let r of _nullishCoalesce(e.positional, () => ([])))o[r.name]=Q(r),r.required&&t.push(r.name);for(let r of V(e))o[_(r)]=d(r),r.required&&t.push(_(r));return{type:"object",properties:o,required:t.length>0?t:void 0,additionalProperties:!1}}function ee(e,o){let t=_chunk6IFA2HGDcjs.a.call(void 0, e,o);if(!t)throw new Error(`SDK \u4E0A\u4E0D\u5B58\u5728\u65B9\u6CD5: ${o.join(".")}`);return r=>t.fn.apply(t.parent,r)}function oe(e){let o=_nullishCoalesce(e.positional, () => ([])),t=V(e);return(r,n)=>{let i=ee(r,e.path),c=o.map(a=>n[a.name]),s={};for(let a of t)s[_nullishCoalesce(a.field, () => (a.flag))]=n[_(a)];switch(e.argShape){case"none":return i([]);case"codes[]":return i([n.codes]);case"codes+options":return i([n.codes,s]);case"symbol+options":return i([...c,s]);case"options":return i([s]);case"positional":return i(c);default:throw new Error(`\u4E0D\u652F\u6301\u7684 argShape: ${e.argShape}`)}}}function U(e){if(e.mcp===!1||!e.toolName)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u672A\u58F0\u660E MCP \u5DE5\u5177\uFF0C\u4E0D\u80FD\u6D3E\u751F ToolDef`);if(e.mcpCustom)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u7684 MCP \u5DE5\u5177\u4E3A\u624B\u5199\u5B9E\u73B0\uFF0C\u4E0D\u80FD\u81EA\u52A8\u6D3E\u751F`);return{name:e.toolName,description:_nullishCoalesce(e.mcpDesc, () => (e.summary)),inputSchema:Z(e),tier:_nullishCoalesce(e.tier, () => ("full")),invoke:oe(e)}}var te=["ma","macd","boll","kdj","rsi","wr","bias","cci","atr","obv","roc","dmi","sar","kc"],g=_chunk6IFA2HGDcjs.n.call(void 0, "kline.withIndicators"),W={name:g.toolName,tier:_nullishCoalesce(g.tier, () => ("full")),description:_nullishCoalesce(g.mcpDesc, () => (g.summary)),inputSchema:{type:"object",properties:{symbol:{type:"string",description:"\u80A1\u7968\u4EE3\u7801\uFF08A \u80A1 / \u6E2F\u80A1 / \u7F8E\u80A1\uFF09"},market:d(_chunk6IFA2HGDcjs.j),period:d(_chunk6IFA2HGDcjs.e),adjust:d(_chunk6IFA2HGDcjs.d),startDate:{...d(_chunk6IFA2HGDcjs.g),description:"\u8D77\u59CB\u65E5\u671F YYYYMMDD \u6216 YYYY-MM-DD"},endDate:{...d(_chunk6IFA2HGDcjs.h),description:"\u7ED3\u675F\u65E5\u671F YYYYMMDD \u6216 YYYY-MM-DD"},indicators:{type:"object",description:"\u6307\u6807\u914D\u7F6E\u5BF9\u8C61\uFF0C\u952E\u53D6\u81EA "+te.join(" / ")+"\uFF1B\u503C\u4E3A true\uFF08\u9ED8\u8BA4\u53C2\u6570\uFF09\u6216\u914D\u7F6E\u5BF9\u8C61\u3002\u820D\u5165\u578B\u6307\u6807\u53EF\u4F20 decimals \u6307\u5B9A\u8F93\u51FA\u5C0F\u6570\u4F4D\uFF08\u9ED8\u8BA4 3\uFF09",properties:{ma:{description:"MA \u5747\u7EBF\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods: [5,10,20], type: sma|ema|wma, decimals }"},macd:{description:"MACD\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { short, long, signal, decimals }"},boll:{description:"\u5E03\u6797\u5E26\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, stdDev, decimals }"},kdj:{description:"KDJ\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, kPeriod, dPeriod, decimals }"},rsi:{description:"RSI\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods, decimals }"},wr:{description:"\u5A01\u5EC9\u6307\u6807 WR\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods, decimals }"},bias:{description:"BIAS \u4E56\u79BB\u7387\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { periods, decimals }"},cci:{description:"CCI\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, decimals }"},atr:{description:"ATR \u771F\u5B9E\u6CE2\u5E45\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, decimals }"},obv:{description:"OBV\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { maPeriod }"},roc:{description:"ROC\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, signalPeriod }"},dmi:{description:"DMI / ADX\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { period, adxPeriod }"},sar:{description:"SAR \u629B\u7269\u7EBF\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { afStart, afIncrement, afMax }"},kc:{description:"Keltner \u901A\u9053 KC\uFF0Ctrue \u6216\u914D\u7F6E\u5BF9\u8C61 { emaPeriod, atrPeriod, multiplier }"}}}},required:["symbol"],additionalProperties:!1},invoke:(e,o)=>e.kline.withIndicators(o.symbol,{market:o.market,period:o.period,adjust:o.adjust,startDate:o.startDate,endDate:o.endDate,indicators:o.indicators})};var re={"kline.withIndicators":W},h=_chunk6IFA2HGDcjs.m.filter(e=>e.mcp!==!1).map(e=>{if(e.mcpCustom){let o=re[e.path.join(".")];if(!o)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u6807\u8BB0\u4E86 mcpCustom \u4F46\u672A\u6CE8\u518C\u624B\u5199\u5DE5\u5177`);return o}return U(e)}),_e=new Map(h.map(e=>[e.name,e]));function B(e){if(Array.isArray(e)){let o=new Set(e);return h.filter(t=>o.has(t.name))}return e==="full"?h:h.filter(o=>o.tier==="core")}var O=200,ne=8e4;function se(e){return Array.isArray(e)&&e.length>O?{total:e.length,truncated:!0,note:`\u7ED3\u679C\u8FC7\u5927\uFF0C\u4EC5\u8FD4\u56DE\u524D ${O} \u6761\uFF1B\u8BF7\u7528\u65E5\u671F / \u5206\u9875 / \u5E02\u573A\u7B49\u53C2\u6570\u7F29\u5C0F\u8303\u56F4`,sample:e.slice(0,O)}:e}function F(e){let o=_nullishCoalesce(JSON.stringify(se(e)), () => ("null"));return o.length>ne?{content:[{type:"text",text:JSON.stringify({truncated:!0,reason:"oversized",approxKB:Math.round(o.length/1024),note:"\u7ED3\u679C\u4F53\u79EF\u8FC7\u5927\uFF0C\u5DF2\u7701\u7565\u6570\u636E\u4F53\uFF1B\u8BF7\u7528\u66F4\u5C0F\u7684\u65E5\u671F / \u5206\u9875 / \u8303\u56F4\u53C2\u6570\uFF0C\u6216\u76F4\u63A5\u7528 SDK \u83B7\u53D6\u5B8C\u6574\u6570\u636E"})}],_meta:{truncated:!0,approxChars:o.length}}:{content:[{type:"text",text:o}]}}function E(e){let o=_chunk4Q7UQ5Q3cjs.i.call(void 0, e)?e.code:"UNKNOWN",t=e instanceof Error?e.message:String(e),r=_chunk4Q7UQ5Q3cjs.i.call(void 0, e)?{code:e.code,provider:e.provider,url:e.url,status:e.status,details:e.details}:{code:o};return{content:[{type:"text",text:`Error[${o}]: ${t}`}],isError:!0,_meta:r}}function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ie(e,o){switch(o){case"array":return Array.isArray(e);case"string":return typeof e=="string";case"integer":return Number.isInteger(e);case"number":return typeof e=="number";case"boolean":return typeof e=="boolean";case"object":return m(e);default:return!0}}function ce(e,o){if(e.additionalProperties===!1){let t=new Set(Object.keys(e.properties));for(let r of Object.keys(o))if(!t.has(r))return`\u672A\u77E5\u53C2\u6570 "${r}"`}for(let t of _nullishCoalesce(e.required, () => ([])))if(o[t]===void 0||o[t]===null)return`\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 "${t}"`;for(let[t,r]of Object.entries(e.properties)){let n=o[t];if(n!==void 0){if(r.type&&!ie(n,r.type))return`\u53C2\u6570 "${t}" \u7C7B\u578B\u5E94\u4E3A ${r.type}`;if(r.enum&&!r.enum.includes(n))return`\u53C2\u6570 "${t}" \u53D6\u503C\u975E\u6CD5\u300C${String(n)}\u300D\uFF0C\u53EF\u9009: ${r.enum.join(" / ")}`}}return null}async function ae(e,o){let t=_nullishCoalesce(e.id, () => (null)),r=e.id!==void 0&&e.id!==null,n=s=>({jsonrpc:"2.0",id:t,result:s}),i=(s,a)=>({jsonrpc:"2.0",id:t,error:{code:s,message:a}});if(e.jsonrpc!=="2.0"||typeof e.method!="string"||e.method.length===0)return r?i(S,"Invalid Request"):null;let c=e.params;switch(e.method){case"initialize":{let s=m(c)?c.protocolVersion:void 0;return n({protocolVersion:L(s),capabilities:{tools:{}},serverInfo:R})}case"notifications/initialized":case"notifications/cancelled":return null;case"ping":return n({});case"tools/list":return n({tools:o.tools.map(s=>({name:s.name,description:s.description,inputSchema:s.inputSchema}))});case"tools/call":{if(!m(c))return i(u,"params must be an object");let s=c.name;if(typeof s!="string")return i(u,"params.name must be a string");let a=o.toolMap.get(s);if(!a)return i(u,`Unknown tool: ${s}`);let f=c.arguments;if(f!==void 0&&!m(f))return i(u,"params.arguments must be an object");let D=m(f)?f:{},P=ce(a.inputSchema,D);if(P)return n(E(new (0, _chunk4Q7UQ5Q3cjs.e)(P)));try{let y=await a.invoke(o.sdk,D);return n(F(y))}catch(y){return n(E(y))}}default:return r?i($,`Unknown method: ${e.method}`):null}}function pe(e){if(e)return e;let o=process.env.STOCK_SDK_MCP_TOOLS;if(!o)return"core";if(o==="core"||o==="full")return o;let t=o.split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t:"core"}function de(e){if(e)return e;let o=process.env.STOCK_SDK_MCP_TIMEOUT,t=o?Number(o):void 0;return t&&!Number.isNaN(t)&&t>0?{timeout:t}:{}}function be(e={}){let o=new (0, _chunkLMUFSVKQcjs.t)(de(e.sdk)),t=B(pe(e.tools)),r={sdk:o,tools:t,toolMap:new Map(t.map(i=>[i.name,i]))};p(`[stock-sdk mcp] ready \xB7 ${t.length} tools \xB7 ${R.name}@${R.version}`),q(i=>{n(i)}),process.stdin.on("end",()=>p("[stock-sdk mcp] stdin closed, exiting"));async function n(i){let c;try{c=JSON.parse(i)}catch (e2){l({jsonrpc:"2.0",id:null,error:{code:K,message:"Parse error"}});return}try{let s=await ae(c,r);s&&l(s)}catch(s){p("[stock-sdk mcp] internal error:",_nullishCoalesce(_optionalChain([s, 'optionalAccess', _7 => _7.message]), () => (String(s)))),c.id!==void 0&&c.id!==null&&l({jsonrpc:"2.0",id:c.id,error:{code:Y,message:String(_nullishCoalesce(_optionalChain([s, 'optionalAccess', _8 => _8.message]), () => (s)))}})}}}exports.dispatchMessage = ae; exports.startMcpServer = be;
|