stock-sdk 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/{adapters-BiH4keVd.d.cts → adapters-CZUNRbxi.d.cts} +29 -1
- package/dist/{adapters-BiH4keVd.d.ts → adapters-CZUNRbxi.d.ts} +29 -1
- package/dist/cache.cjs +1 -1
- package/dist/cache.d.cts +35 -3
- package/dist/cache.d.ts +35 -3
- package/dist/cache.js +1 -1
- package/dist/chunk-46ECBWOQ.cjs +1 -0
- package/dist/chunk-4RN7AVFQ.js +1 -0
- package/dist/chunk-6FZNYDNN.cjs +1 -0
- package/dist/chunk-6MCPZDKN.cjs +1 -0
- package/dist/chunk-H5FDXQRK.js +1 -0
- package/dist/chunk-HKREKO2F.js +1 -0
- package/dist/chunk-LDYRNH4X.cjs +1 -0
- package/dist/chunk-OPCBE3NR.js +1 -0
- package/dist/chunk-R7M3BHS4.cjs +1 -0
- package/dist/chunk-SMCYQ6NL.js +1 -0
- package/dist/chunk-USZUOBM2.cjs +1 -0
- package/dist/chunk-VKXPLWPL.js +1 -0
- package/dist/chunk-W625VPPB.js +1 -0
- package/dist/chunk-WJOFTWZL.cjs +1 -0
- package/dist/cli.cjs +16 -16
- package/dist/cli.js +16 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +23 -7
- package/dist/index.d.ts +23 -7
- package/dist/index.js +1 -1
- package/dist/indicators.cjs +1 -1
- package/dist/indicators.js +1 -1
- package/dist/mcp.cjs +83 -5
- package/dist/mcp.d.cts +28 -2
- package/dist/mcp.d.ts +28 -2
- package/dist/mcp.js +83 -5
- package/dist/screener.cjs +1 -1
- package/dist/screener.d.cts +51 -16
- package/dist/screener.d.ts +51 -16
- package/dist/screener.js +1 -1
- package/dist/{sdk-CtqVdrof.d.ts → sdk-DGgSDZRx.d.ts} +67 -16
- package/dist/{sdk-6Qozazec.d.cts → sdk-RzQ-drS4.d.cts} +67 -16
- package/dist/signals.d.cts +3 -42
- package/dist/signals.d.ts +3 -42
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.d.cts +2 -2
- package/dist/symbols.d.ts +2 -2
- package/dist/symbols.js +1 -1
- package/dist/types-7n5rSHbd.d.cts +42 -0
- package/dist/types-7n5rSHbd.d.ts +42 -0
- package/package.json +2 -1
- package/dist/chunk-3ASJZ3YA.js +0 -1
- package/dist/chunk-6IFA2HGD.cjs +0 -1
- package/dist/chunk-C4CA7QBB.cjs +0 -1
- package/dist/chunk-DU7MCVLJ.js +0 -1
- package/dist/chunk-F3KZXCVO.js +0 -1
- package/dist/chunk-IWHFCLJM.js +0 -1
- package/dist/chunk-LCX5Q36O.js +0 -1
- package/dist/chunk-LMUFSVKQ.cjs +0 -1
- package/dist/chunk-QGYIBFXP.js +0 -1
- package/dist/chunk-T5CH7H3X.cjs +0 -1
- package/dist/chunk-TVIEKKDQ.cjs +0 -1
- package/dist/chunk-WCBK5KYA.cjs +0 -1
- package/dist/chunk-ZESMWMHP.cjs +0 -1
- package/dist/chunk-ZZ2IBUMV.js +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
${n.hint}`:"";return{text:`stock-sdk: ${
|
|
2
|
+
import{a as T,b as D,c as $,d as q,e as K,f as L,g as U,h as x,i as F,k as V,l as C,m as g}from"./chunk-HKREKO2F.js";import{t as j}from"./chunk-H5FDXQRK.js";import"./chunk-W625VPPB.js";import{d as M,f as O,g as b,i as I}from"./chunk-4RN7AVFQ.js";import"./chunk-LAT6L2TO.js";import"./chunk-SMCYQ6NL.js";import{f as N,k as w}from"./chunk-UBIQBXQ7.js";import"./chunk-WOT6VMZA.js";var p=class extends Error{constructor(t,e){super(t),this.name="CliUsageError",this.hint=e}},bn={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 G(n){if(n instanceof p)return 2;let t=w(n);return bn[t]??1}function H(n,t){let e=n instanceof Error?n.message:String(n);if(n instanceof p){if(t==="json")return{text:JSON.stringify({error:{code:"USAGE",message:e}})};let r=n.hint?`
|
|
3
|
+
${n.hint}`:"";return{text:`stock-sdk: ${e}${r}`}}let o=w(n);return t==="json"?{text:JSON.stringify({error:{code:o,message:e}})}:{text:`stock-sdk: ${o}: ${e}`}}var Cn={start:"startDate",end:"endDate"},En=new Set(["format","f","pretty","quiet","q","help","h","version","V","timeout"]),An=new Set(["limit"]);function W(n){return En.has(n)||An.has(n)}function Pn(n,t){let e={},o=new Map;for(let r of n.options??[])o.set(r.flag,r);for(let[r,s]of Object.entries(t)){if(W(r))continue;let c=o.get(r);if(!c){if(s===!0)continue;e[Cn[r]??r]=s;continue}e[c.field??c.flag]=vn(c,s)}for(let r of n.options??[]){let s=r.field??r.flag;e[s]===void 0&&r.default!==void 0&&(e[s]=r.default)}return e}function vn(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 e=S(t),o=typeof e=="boolean"?e:String(e);if(n.upper&&typeof o=="string"&&(o=o.toUpperCase()),n.type==="enum"&&n.enum&&typeof o=="string"&&!n.enum.includes(o))throw new p(`--${n.flag} \u975E\u6CD5\u503C\u300C${o}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return n.map&&typeof o=="string"&&o in n.map&&(o=n.map[o]),o}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(e=>e.trim()).filter(e=>e.length>0).map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>0)}function J(n,t){let e=n.positional??[],o=[],r=0;for(let s of e){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)o.push(z(s,i));return o}let c=t[r];if(c===void 0){if(s.required)throw new p(`\u7F3A\u5C11\u53C2\u6570 <${s.name}>`);o.push(void 0)}else o.push(z(s,c));r++}return o}function z(n,t){let e=t;if(n.upper&&(e=e.toUpperCase()),n.enum&&!n.enum.includes(e))throw new p(`<${n.name}> \u975E\u6CD5\u503C\u300C${t}\u300D`,`\u53EF\u9009: ${n.enum.join(" / ")}`);return e}function m(n,t,e){let o=T(n,t);if(!o)throw new p(`\u672A\u77E5\u547D\u4EE4: ${t.join(" ")}`);return Promise.resolve(o.fn.apply(o.parent,e))}function _n(n,t){let e=new Map;for(let r of n.options??[])e.set(r.flag,r);let o=e.size>0;for(let[r,s]of Object.entries(t)){if(W(r))continue;let c=e.get(r);if(!c){if(o)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 Rn(n,t){let e=n.positional??[];for(let o=0;o<e.length;o++){let r=e[o],s=t[o];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 Nn(n,t){let e=t.limit;if(e===void 0||e===!0||!Array.isArray(n))return n;let o=Number(S(e));return!Number.isNaN(o)&&o>=1?n.slice(0,o):n}function Y(n,t,e){_n(t,e.options),Rn(t,e.positional);let o=t.invoke?t.invoke(n,e):Mn(n,t,e);return Promise.resolve(o).then(r=>Nn(r,e.options))}function Mn(n,t,e){let o=Pn(t,e.options);switch(t.argShape){case"none":return m(n,t.path,[]);case"codes[]":return B(e.positional,t),m(n,t.path,[e.positional]);case"codes+options":return B(e.positional,t),m(n,t.path,[e.positional,o]);case"symbol+options":{let r=J(t,e.positional);return m(n,t.path,[...r,o])}case"options":return m(n,t.path,[o]);case"positional":return m(n,t.path,J(t,e.positional));default:throw new p(`\u4E0D\u652F\u6301\u7684\u547D\u4EE4\u5F62\u6001: ${t.argShape}`)}}function B(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 nn(n,t,e){if(t==="json")return e?JSON.stringify(n,null,2):JSON.stringify(n);let o=In(n);return o.length===0?"":t==="csv"?$n(o):Tn(o)}function tn(n){return n==null||Array.isArray(n)&&n.length===0}function In(n){return Array.isArray(n)?n.map(t=>Q(t)?t:{value:t}):Q(n)?[n]:n==null?[]:[{value:n}]}function Q(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function en(n){let t=[],e=new Set;for(let o of n)for(let r of Object.keys(o))e.has(r)||(e.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 e of n){let o=e.codePointAt(0)??0;t+=jn(o)?2:1}return t}function jn(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 X(n,t,e){let o=Math.max(0,t-A(n)),r=" ".repeat(o);return e?r+n:n+r}function Tn(n){let t=en(n),e=n.map(i=>t.map(a=>on(i[a]))),o=t.map((i,a)=>e.every(u=>u[a]===""||Dn(u[a]))),r=t.map((i,a)=>Math.max(A(i),...e.map(u=>A(u[a])))),s=t.map((i,a)=>X(i,r[a],o[a])).join(" "),c=r.map(i=>"-".repeat(i)).join(" "),d=e.map(i=>i.map((a,u)=>X(a,r[u],o[u])).join(" ")).join(`
|
|
4
4
|
`);return[s,c,d].join(`
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
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:[
|
|
8
|
-
`)}function
|
|
9
|
-
`)}function
|
|
10
|
-
`)});function
|
|
11
|
-
`),1}}async function
|
|
12
|
-
`),0;if(
|
|
13
|
-
`),0;if(
|
|
5
|
+
`)}function Dn(n){return n!==""&&!Number.isNaN(Number(n))}function $n(n){let t=en(n),e=[t.map(Z).join(",")];for(let o of n)e.push(t.map(r=>Z(on(o[r]))).join(","));return e.join(`
|
|
6
|
+
`)}function Z(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 qn(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 rn(n,t){let e=(n.params??[]).filter(o=>o.cli!==!1).map(h);return{path:n.path,summary:n.summary,argShape:n.argShape,positional:n.positional?.map(qn),options:e.length>0?e:void 0,invoke:t}}var Kn=h(K),Ln=h(L),sn=h(q),an=h(U),un=h(x),Un=h(F),P=[{name:"symbol",required:!0}],xn=[{name:"code",required:!0}],ln={"kline.withIndicators":(n,t)=>hn(n,t),"northbound.minute":(n,t)=>m(n,["northbound","minute"],[fn(t)]),"northbound.history":(n,t)=>{let e={};return t.options.start!==void 0&&(e.startDate=t.options.start),t.options.end!==void 0&&(e.endDate=t.options.end),m(n,["northbound","history"],[fn(t),e])}};{let n=new Set(g.map(t=>t.path.join(".")));for(let t of Object.keys(ln))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=g.map(n=>rn(n,ln[n.path.join(".")]));function Fn(n){return k.find(t=>t.path.join(".")===n)?.options??[]}var Vn=Fn("kline.withIndicators"),pn={flag:"market",type:"enum",enum:["a","hk","us"],desc:"\u5E02\u573A a/hk/us(\u9ED8\u8BA4\u6309\u4EE3\u7801\u81EA\u52A8\u8BC6\u522B)"},Gn={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 cn(n){let t=b(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 Hn(n){return n==="hk"?"HK":n==="us"?"US":"CN"}function dn(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 Jn(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 fn(n){let t=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 mn(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 zn(n){let t={};for(let e of V){let o=n[e];if(o===void 0)continue;if(o===!0){t[e]={};continue}let r=E(o);r.length>0&&(t[e]={periods:r})}for(let e of C){let o=n[e];o!==void 0&&(o===!0||o==="true"||o==="1"||o==="yes")&&(t[e]=!0)}return t}function hn(n,t){let e=_(t,"indicators"),o={};return t.options.period!==void 0&&(o.period=t.options.period),t.options.adjust!==void 0&&(o.adjust=t.options.adjust==="none"?"":t.options.adjust),t.options.start!==void 0&&(o.startDate=t.options.start),t.options.end!==void 0&&(o.endDate=t.options.end),t.options.market!==void 0&&(o.market=t.options.market),o.indicators=zn(t.options),m(n,["kline","withIndicators"],[e,o])}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:[Gn,{flag:"full",type:"boolean",desc:"A\u80A1\u5168\u91CF\u4E94\u6863\u884C\u60C5"}],invoke:async(n,t)=>{let e=t.positional;if(e.length===0)throw new p("\u7F3A\u5C11\u80A1\u7968\u4EE3\u7801","\u7528\u6CD5: stock-sdk quote <code...>");let o=Jn(t.options.market),r=t.options.full===!0,s={a:[],hk:[],us:[],fund:[]};for(let u of e){if(o==="fund"){s.fund.push(u);continue}let f=o??"a";try{let l=o?O(u,{market:Hn(o)}):O(u);o||(f=l.market==="HK"?"hk":l.market==="US"?"us":"a");let R=l.assetType==="index"?M(l.code):void 0;if(R&&!R.tencent)throw new p(`\u7279\u6B8A\u6307\u6570 ${l.code} \u65E0\u884C\u60C5\u63A5\u53E3`,`\u884C\u60C5\u6E90(\u817E\u8BAF)\u4E0D\u8986\u76D6\u8BE5\u7279\u6B8A\u6307\u6570;K \u7EBF\u8BF7\u7528: stock-sdk kline ${l.code}`);s[f].push(f==="a"?I(l):l.code)}catch(l){if(l instanceof p||o&&l instanceof N&&b(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:[Kn,sn,an,un,pn,v],invoke:async(n,t)=>{let e=_(t,"kline"),o=dn(t.options.market)??cn(e),r=mn(t);return m(n,["kline",o==="hk"?"hk":o==="us"?"us":"cn"],[e,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:[Ln,sn,an,un,pn,v,Un],invoke:async(n,t)=>{let e=_(t,"minute"),o=dn(t.options.market)??cn(e),r=mn(t),s=o==="hk"?"hkMinute":o==="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],[e,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:Vn,invoke:hn},{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 e=t.positional[0];if(!e)throw new p("\u7F3A\u5C11\u641C\u7D22\u5173\u952E\u8BCD","\u7528\u6CD5: stock-sdk search <keyword>");return n.search(e)}},{path:["quotes","timeline"],alias:["timeline"],summary:"\u5F53\u65E5\u5206\u65F6",argShape:"positional",positional:xn,invoke:async(n,t)=>{let e=t.positional[0];if(!e)throw new p("\u7F3A\u5C11\u80A1\u7968\u4EE3\u7801","\u7528\u6CD5: stock-sdk timeline <code>");return n.quotes.timeline(e)}},{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 e=t.positional[0],o={};if(t.options.simple===!0&&(o.simple=!0),t.options.board!==void 0){if(e!=="a")throw new p("--board \u4EC5\u652F\u6301 A \u80A1(market=a)","\u53EF\u9009: sh / sz / bj / kc / cy");o.market=t.options.board}switch(e){case"a":return m(n,["codes","cn"],[o]);case"us":return m(n,["codes","us"],[o]);case"hk":return n.codes.hk();case"fund":return n.codes.fund();default:throw new p(`\u672A\u77E5\u5E02\u573A: ${e}`,"\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:D}],invoke:async(n,t)=>{let e=t.positional[0],o=e?e.toUpperCase():"A";return n.calendar.marketStatus(o)}},{path:["marketEvent","ztPool"],alias:["ztpool"],summary:"\u6DA8\u505C\u80A1\u6C60 zt/yesterday/strong/sub_new/broken/dt(--date)",argShape:"positional",positional:[{name:"type",enum:$}],options:[{flag:"date",type:"string",desc:"\u4EA4\u6613\u65E5 YYYYMMDD"}],invoke:async(n,t)=>{let e=t.positional[0],o=t.options.date;return n.marketEvent.ztPool(e,o)}},{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 e=t.positional[0];if(!e)throw new p("call \u7F3A\u5C11\u65B9\u6CD5\u8DEF\u5F84","\u7528\u6CD5: stock-sdk call <ns.method> --args '[...]'");let o=[],r=t.options.args;if(typeof r=="string")try{let c=JSON.parse(r);o=Array.isArray(c)?c:[c]}catch{throw new p("--args \u4E0D\u662F\u5408\u6CD5 JSON",`\u793A\u4F8B: --args '[["sh600519"]]'`)}if(!new Set(Wn()).has(e))throw new p(`\u672A\u77E5\u65B9\u6CD5: ${e}`,"\u5F62\u5982 quotes.cn / kline.cn(\u4EC5\u547D\u540D\u7A7A\u95F4\u65B9\u6CD5,\u89C1 stock-sdk --help)");return m(n,e.split("."),o)}}],kn="mcp",Bn=[...y,...k];function Wn(){return g.map(n=>n.path.join("."))}function _(n,t){let e=n.positional[0];if(!e)throw new p("\u7F3A\u5C11\u4EE3\u7801\u53C2\u6570",`\u7528\u6CD5: stock-sdk ${t} <symbol>`);return e}function gn(){let n=new Set(["help","h","version","V","quiet","q","pretty"]);for(let t of Bn)for(let e of t.options??[])e.type==="boolean"&&n.add(e.flag);for(let t of C)n.add(t);return n}function Sn(n){if(n.length===0)return null;for(let e=Math.min(3,n.length);e>=2;e--){let o=n.slice(0,e).join("."),r=k.find(s=>s.path.join(".")===o);if(r)return{spec:r,rest:n.slice(e)}}for(let e of y)if(e.alias?.includes(n[0]))return{spec:e,rest:n.slice(1)};let t=k.find(e=>e.path.join(".")===n[0]);return t?{spec:t,rest:n.slice(1)}:null}function yn(){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 e of y){let o=e.alias?.[0]??e.path.join(" ");n.push(` ${o.padEnd(12)} ${e.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(e=>e.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
|
+
`)}function wn(n){let t=n.alias?.[0]??n.path.join(" "),e=[`${t} \u2014\u2014 ${n.summary}`,""],o=(n.positional??[]).map(r=>{let s=r.required?`<${r.name}>`:`[${r.name}]`;return r.variadic?`${s}...`:s}).join(" ");if(e.push(`\u7528\u6CD5: stock-sdk ${t}${o?" "+o:""} [--flags]`),n.options?.length){e.push(""),e.push("\u9009\u9879:");for(let r of n.options){let s=r.enum?` (${r.enum.join("/")})`:"";e.push(` --${r.flag.padEnd(12)} ${r.desc}${s}`)}}return e.join(`
|
|
9
|
+
`)}function On(n,t=new Set){let e=[],o={},r=!1,s=(i,a)=>{let u=o[i];if(u===void 0){o[i]=a;return}if(typeof a!="string"){o[i]=a;return}Array.isArray(u)?u.push(a):typeof u=="string"?o[i]=[u,a]:o[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){e.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&&!Yn(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 e.push(a)}return{positional:e,options:o}}function Yn(n){return/^-\d/.test(n)}var Qn=gn();process.stdout.on("error",n=>{n.code==="EPIPE"&&process.exit(0),process.stderr.write(`stock-sdk: stdout error: ${n.message}
|
|
10
|
+
`)});function Xn(){return"2.4.0"}function Zn(n){let t=n.format??n.f,e=t==="table"||t==="csv"?t:"json",o;if(typeof n.timeout=="string"||typeof n.timeout=="number"){let r=Number(n.timeout);!Number.isNaN(r)&&r>0&&(o=r)}return{format:e,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:o}}async function nt(){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
|
+
`),1}}async function tt(n){let t="json";try{let e=On(n,Qn),o=Zn(e.options);if(t=o.format,o.version)return process.stdout.write(Xn()+`
|
|
12
|
+
`),0;if(e.positional.length===0)return process.stdout.write(yn()+`
|
|
13
|
+
`),0;if(e.positional[0]===kn)return o.help?(process.stdout.write(`stock-sdk mcp \u2014\u2014 \u542F\u52A8 MCP server (stdio transport)
|
|
14
14
|
|
|
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
|
-
`),0):await
|
|
18
|
-
`),0;let s=new
|
|
19
|
-
`);let i=
|
|
20
|
-
`),0}catch(
|
|
21
|
-
`),
|
|
17
|
+
`),0):await nt();let r=Sn(e.positional);if(!r)throw new p(`\u672A\u77E5\u547D\u4EE4 "${e.positional.join(" ")}"`,"\u8FD0\u884C `stock-sdk --help` \u67E5\u770B\u53EF\u7528\u547D\u4EE4");if(o.help)return process.stdout.write(wn(r.spec)+`
|
|
18
|
+
`),0;let s=new j(o.timeout!==void 0?{timeout:o.timeout}:{}),c={positional:r.rest,options:e.options},d=await Y(s,r.spec,c);tn(d)&&!o.quiet&&process.stderr.write(`stock-sdk: \u65E0\u6570\u636E
|
|
19
|
+
`);let i=nn(d,o.format,o.pretty);return i.length>0&&process.stdout.write(i+`
|
|
20
|
+
`),0}catch(e){let o=H(e,t);return process.stderr.write(o.text+`
|
|
21
|
+
`),G(e)}}tt(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}
|
|
22
22
|
`),process.exitCode=1});
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkLDYRNH4Xcjs = require('./chunk-LDYRNH4X.cjs');var _chunk6FZNYDNNcjs = require('./chunk-6FZNYDNN.cjs');var _chunk46ECBWOQcjs = require('./chunk-46ECBWOQ.cjs');var _chunkR7M3BHS4cjs = require('./chunk-R7M3BHS4.cjs');var _chunkUSZUOBM2cjs = require('./chunk-USZUOBM2.cjs');var _chunkSR7FGCVZcjs = require('./chunk-SR7FGCVZ.cjs');var _chunk6MCPZDKNcjs = require('./chunk-6MCPZDKN.cjs');var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');require('./chunk-4VDLQK6F.cjs');var de={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},he={sh:"CN",sz:"CN",hk:"HK",us:"US"},ke={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},Se={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function ye(t){return t==="sh"||t==="sz"||t==="hk"||t==="us"||t==="global"}function Oe(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 fe(t){let e=t.code.trim(),o=t.market.trim().toLowerCase(),n=_nullishCoalesce(de[t.market], () => (o)),s=ye(n)?n:void 0;if(s==="global")return{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:"global"};try{let r=_chunkUSZUOBM2cjs.f.call(void 0, e,s?{market:he[s]}:void 0);if(r.assetType!=="stock")return{code:e,market:"unknown"};let a=_nullishCoalesce(s, () => (Oe(r)));return a==="unknown"?{code:e,market:"unknown"}:{code:r.market==="US"?r.code.toUpperCase():r.code,market:a}}catch (e2){return{code:e,market:"unknown"}}}function Ce(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Me(t){let{code:e,market:o}=t;return(o==="sh"||o==="sz")&&Ce(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(Se[e], () => (e))}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function ge(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(ke[e], () => (e))}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function Re(t){let e=fe(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Me(e)},{name:"\u96EA\u7403",url:ge(e)}]}exports.BROWSER_JSVARS_MUTEX_KEY = _chunk46ECBWOQcjs.j; exports.FundService = _chunk46ECBWOQcjs.s; exports.HttpError = _chunk4Q7UQ5Q3cjs.b; exports.INDICATOR_REGISTRY = _chunkR7M3BHS4cjs.t; exports.MARKET_TZ = _chunk46ECBWOQcjs.m; exports.MemoryCache = _chunk6MCPZDKNcjs.a; exports.MemoryCacheStore = _chunk6FZNYDNNcjs.a; exports.SdkError = _chunk4Q7UQ5Q3cjs.a; exports.StockSDK = _chunk46ECBWOQcjs.t; exports.TradingCalendarService = _chunk46ECBWOQcjs.r; exports.addIndicators = _chunkR7M3BHS4cjs.x; exports.asyncPool = _chunk46ECBWOQcjs.f; exports.backtest = _chunkLDYRNH4Xcjs.b; exports.buildIndicatorContext = _chunkR7M3BHS4cjs.s; exports.buildTimeMeta = _chunk46ECBWOQcjs.o; exports.buildTimeMetaFromDateAndTime = _chunk46ECBWOQcjs.p; exports.cacheThrough = _chunk6FZNYDNNcjs.b; exports.calcATR = _chunkR7M3BHS4cjs.l; exports.calcBIAS = _chunkR7M3BHS4cjs.j; exports.calcBOLL = _chunkR7M3BHS4cjs.f; exports.calcCCI = _chunkR7M3BHS4cjs.k; exports.calcChipDistribution = _chunkR7M3BHS4cjs.r; exports.calcDMI = _chunkR7M3BHS4cjs.o; exports.calcEMA = _chunkR7M3BHS4cjs.b; exports.calcKC = _chunkR7M3BHS4cjs.q; exports.calcKDJ = _chunkR7M3BHS4cjs.g; exports.calcMA = _chunkR7M3BHS4cjs.d; exports.calcMACD = _chunkR7M3BHS4cjs.e; exports.calcOBV = _chunkR7M3BHS4cjs.m; exports.calcROC = _chunkR7M3BHS4cjs.n; exports.calcRSI = _chunkR7M3BHS4cjs.h; exports.calcSAR = _chunkR7M3BHS4cjs.p; exports.calcSMA = _chunkR7M3BHS4cjs.a; exports.calcSignals = _chunkSR7FGCVZcjs.a; exports.calcWMA = _chunkR7M3BHS4cjs.c; exports.calcWR = _chunkR7M3BHS4cjs.i; exports.chunkArray = _chunk46ECBWOQcjs.e; exports.clearClientScopedCaches = _chunk6MCPZDKNcjs.f; exports.configureSharedCache = _chunk6MCPZDKNcjs.c; exports.createCacheKey = _chunk6MCPZDKNcjs.g; exports.decodeGBK = _chunk46ECBWOQcjs.a; exports.default = _chunk46ECBWOQcjs.u; exports.estimateIndicatorLookback = _chunkR7M3BHS4cjs.w; exports.extractJsonFromJsonp = _chunk46ECBWOQcjs.g; exports.fetchJsVars = _chunk46ECBWOQcjs.k; exports.formatInTz = _chunk46ECBWOQcjs.q; exports.generateSearchExternalLinks = Re; exports.getEnabledIndicatorKeys = _chunkR7M3BHS4cjs.v; exports.getSdkErrorCode = _chunk4Q7UQ5Q3cjs.k; exports.getSharedCache = _chunk6MCPZDKNcjs.b; exports.jsonpRequest = _chunk46ECBWOQcjs.h; exports.normalizeSymbol = _chunkUSZUOBM2cjs.f; exports.parseJsVars = _chunk46ECBWOQcjs.l; exports.parseMarketTime = _chunk46ECBWOQcjs.n; exports.parseResponse = _chunk46ECBWOQcjs.b; exports.safeNumber = _chunk46ECBWOQcjs.c; exports.safeNumberOrNull = _chunk46ECBWOQcjs.d; exports.screen = _chunkLDYRNH4Xcjs.a; exports.toEastmoneySecid = _chunkUSZUOBM2cjs.j; exports.toTencentSymbol = _chunkUSZUOBM2cjs.i; exports.withScriptMutex = _chunk46ECBWOQcjs.i;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-
|
|
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-
|
|
1
|
+
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-RzQ-drS4.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-RzQ-drS4.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
|
-
export { CacheOptions, CacheStore, MaybePromise, MemoryCache, MemoryCacheStore, cacheThrough, createCacheKey, getSharedCache } from './cache.cjs';
|
|
4
|
+
export { CacheOptions, CacheStore, MaybePromise, MemoryCache, MemoryCacheStore, cacheThrough, clearClientScopedCaches, configureSharedCache, createCacheKey, getSharedCache } from './cache.cjs';
|
|
5
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';
|
|
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-
|
|
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-CZUNRbxi.cjs';
|
|
7
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
8
|
export { d as ChipDistributionItem, b as ChipDistributionOptions, a as ChipHistogram, C as ChipKlineLike, c as calcChipDistribution } from './chip-BbA23rr1.cjs';
|
|
9
|
-
export {
|
|
9
|
+
export { calcSignals } from './signals.cjs';
|
|
10
10
|
export { BacktestOptions, BacktestReport, ScreenerBuilder, Strategy, StrategySignal, Trade, backtest, screen } from './screener.cjs';
|
|
11
|
+
export { a as Signal, S as SignalOptions, b as SignalType } from './types-7n5rSHbd.cjs';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* 响应解析器
|
|
@@ -100,13 +101,16 @@ declare function jsonpRequest<T = unknown>(url: string, options?: JsonpOptions):
|
|
|
100
101
|
*/
|
|
101
102
|
|
|
102
103
|
/**
|
|
103
|
-
*
|
|
104
|
+
* 浏览器端 fetchJsVars 默认共享的 mutex 键。
|
|
104
105
|
*
|
|
105
106
|
* 用全局键(而非按变量名集合算 key)的原因:不同接口的变量名集合常有交集
|
|
106
107
|
* (如 pingzhongdata 的 `fS_code` / `fS_name` 同时被多个接口写入)。按集合
|
|
107
108
|
* 分组的 key 会让"集合不同但有交集"的并发请求互相覆盖全局变量。
|
|
108
109
|
*
|
|
109
|
-
*
|
|
110
|
+
* 代价:默认下任意两个浏览器 fetchJsVars 调用都串行。变量集合与基金系
|
|
111
|
+
* **确定不相交**的数据源(如 smartbox 的 `v_hint`)可用 `options.mutexKey`
|
|
112
|
+
* 声明专属队列,避免被基金大文件下载排队拖慢(R7-5)——同 key 仍串行,
|
|
113
|
+
* 保住自身并发安全。
|
|
110
114
|
*
|
|
111
115
|
* Node 端不走 mutex,不受影响。
|
|
112
116
|
*/
|
|
@@ -116,6 +120,11 @@ interface FetchJsVarsOptions {
|
|
|
116
120
|
timeout?: number;
|
|
117
121
|
/** 额外的 fetch headers(仅 Node 端裸 fetch 路径生效;client 路径请通过 client 配置) */
|
|
118
122
|
headers?: Record<string, string>;
|
|
123
|
+
/**
|
|
124
|
+
* 浏览器端注入互斥队列的 key,默认 {@link BROWSER_JSVARS_MUTEX_KEY}(全局串行)。
|
|
125
|
+
* 仅当变量名集合与其它数据源**确定不相交**时才可指定专属 key。
|
|
126
|
+
*/
|
|
127
|
+
mutexKey?: string;
|
|
119
128
|
/**
|
|
120
129
|
* 可选的 SDK 请求客户端。
|
|
121
130
|
* - 传入:Node 端走 `client.get<string>(url, { responseType: 'text' })`,享受 SDK 重试 /
|
|
@@ -199,6 +208,13 @@ interface DatacenterQuery {
|
|
|
199
208
|
* 命中此上限时会在 console 输出 warning 提示,避免数据被静默截断。
|
|
200
209
|
*/
|
|
201
210
|
maxPages?: number;
|
|
211
|
+
/**
|
|
212
|
+
* 翻页并发波次大小(R7-14),默认 3;设 1 退化为严格串行。
|
|
213
|
+
*
|
|
214
|
+
* ⚠️ 默认部署没有 RateLimiter(仅用户显式配置时创建),并发请求直接
|
|
215
|
+
* 打上游,故默认值保守;配置了限速的用户墙钟收益受限速地板约束。
|
|
216
|
+
*/
|
|
217
|
+
concurrency?: number;
|
|
202
218
|
/** 额外的 quoteColumns 参数(用于行情字段聚合) */
|
|
203
219
|
quoteColumns?: string;
|
|
204
220
|
/** 额外的 quoteType 参数 */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-
|
|
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-
|
|
1
|
+
import { a as RequestClient, b as SearchResult, E as ExternalLink } from './sdk-DGgSDZRx.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-DGgSDZRx.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
|
-
export { CacheOptions, CacheStore, MaybePromise, MemoryCache, MemoryCacheStore, cacheThrough, createCacheKey, getSharedCache } from './cache.js';
|
|
4
|
+
export { CacheOptions, CacheStore, MaybePromise, MemoryCache, MemoryCacheStore, cacheThrough, clearClientScopedCaches, configureSharedCache, createCacheKey, getSharedCache } from './cache.js';
|
|
5
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';
|
|
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-
|
|
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-CZUNRbxi.js';
|
|
7
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
8
|
export { d as ChipDistributionItem, b as ChipDistributionOptions, a as ChipHistogram, C as ChipKlineLike, c as calcChipDistribution } from './chip-BbA23rr1.js';
|
|
9
|
-
export {
|
|
9
|
+
export { calcSignals } from './signals.js';
|
|
10
10
|
export { BacktestOptions, BacktestReport, ScreenerBuilder, Strategy, StrategySignal, Trade, backtest, screen } from './screener.js';
|
|
11
|
+
export { a as Signal, S as SignalOptions, b as SignalType } from './types-7n5rSHbd.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* 响应解析器
|
|
@@ -100,13 +101,16 @@ declare function jsonpRequest<T = unknown>(url: string, options?: JsonpOptions):
|
|
|
100
101
|
*/
|
|
101
102
|
|
|
102
103
|
/**
|
|
103
|
-
*
|
|
104
|
+
* 浏览器端 fetchJsVars 默认共享的 mutex 键。
|
|
104
105
|
*
|
|
105
106
|
* 用全局键(而非按变量名集合算 key)的原因:不同接口的变量名集合常有交集
|
|
106
107
|
* (如 pingzhongdata 的 `fS_code` / `fS_name` 同时被多个接口写入)。按集合
|
|
107
108
|
* 分组的 key 会让"集合不同但有交集"的并发请求互相覆盖全局变量。
|
|
108
109
|
*
|
|
109
|
-
*
|
|
110
|
+
* 代价:默认下任意两个浏览器 fetchJsVars 调用都串行。变量集合与基金系
|
|
111
|
+
* **确定不相交**的数据源(如 smartbox 的 `v_hint`)可用 `options.mutexKey`
|
|
112
|
+
* 声明专属队列,避免被基金大文件下载排队拖慢(R7-5)——同 key 仍串行,
|
|
113
|
+
* 保住自身并发安全。
|
|
110
114
|
*
|
|
111
115
|
* Node 端不走 mutex,不受影响。
|
|
112
116
|
*/
|
|
@@ -116,6 +120,11 @@ interface FetchJsVarsOptions {
|
|
|
116
120
|
timeout?: number;
|
|
117
121
|
/** 额外的 fetch headers(仅 Node 端裸 fetch 路径生效;client 路径请通过 client 配置) */
|
|
118
122
|
headers?: Record<string, string>;
|
|
123
|
+
/**
|
|
124
|
+
* 浏览器端注入互斥队列的 key,默认 {@link BROWSER_JSVARS_MUTEX_KEY}(全局串行)。
|
|
125
|
+
* 仅当变量名集合与其它数据源**确定不相交**时才可指定专属 key。
|
|
126
|
+
*/
|
|
127
|
+
mutexKey?: string;
|
|
119
128
|
/**
|
|
120
129
|
* 可选的 SDK 请求客户端。
|
|
121
130
|
* - 传入:Node 端走 `client.get<string>(url, { responseType: 'text' })`,享受 SDK 重试 /
|
|
@@ -199,6 +208,13 @@ interface DatacenterQuery {
|
|
|
199
208
|
* 命中此上限时会在 console 输出 warning 提示,避免数据被静默截断。
|
|
200
209
|
*/
|
|
201
210
|
maxPages?: number;
|
|
211
|
+
/**
|
|
212
|
+
* 翻页并发波次大小(R7-14),默认 3;设 1 退化为严格串行。
|
|
213
|
+
*
|
|
214
|
+
* ⚠️ 默认部署没有 RateLimiter(仅用户显式配置时创建),并发请求直接
|
|
215
|
+
* 打上游,故默认值保守;配置了限速的用户墙钟收益受限速地板约束。
|
|
216
|
+
*/
|
|
217
|
+
concurrency?: number;
|
|
202
218
|
/** 额外的 quoteColumns 参数(用于行情字段聚合) */
|
|
203
219
|
quoteColumns?: string;
|
|
204
220
|
/** 额外的 quoteType 参数 */
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as pe,b as ue}from"./chunk-OPCBE3NR.js";import{a as le,b as me}from"./chunk-VKXPLWPL.js";import{a as c,b as p,c as u,d as l,e as k,f as S,g,h as R,i as x,j as I,k as b,l as T,m as A,n as K,o as N,p as E,q as D,r as se,s as ie,t as ae,u as ce}from"./chunk-H5FDXQRK.js";import{a as B,b as q,c as U,d as X,e as w,f as F,g as _,h as $,i as G,j as H,k as J,l as P,m as V,n as W,o as v,p as Q,q as Y,r as Z,s as j,t as ee,v as te,w as oe,x as re}from"./chunk-W625VPPB.js";import{f as i,i as L,j as z}from"./chunk-4RN7AVFQ.js";import{a as ne}from"./chunk-LAT6L2TO.js";import{a as y,b as O,c as f,f as C,g as M}from"./chunk-SMCYQ6NL.js";import{a as m,b as d,k as h}from"./chunk-UBIQBXQ7.js";import"./chunk-WOT6VMZA.js";var de={0:"sz",1:"sh",100:"global",105:"us",116:"hk"},he={sh:"CN",sz:"CN",hk:"HK",us:"US"},ke={IXIC:".IXIC",NDX:".NDX",NDX100:".NDX"},Se={IXIC:"NDX",NDX:"NDX",NDX100:"NDX"};function ye(t){return t==="sh"||t==="sz"||t==="hk"||t==="us"||t==="global"}function Oe(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 fe(t){let e=t.code.trim(),o=t.market.trim().toLowerCase(),n=de[t.market]??o,s=ye(n)?n:void 0;if(s==="global")return{code:e.replace(/^\d{3}\./,"").toUpperCase(),market:"global"};try{let r=i(e,s?{market:he[s]}:void 0);if(r.assetType!=="stock")return{code:e,market:"unknown"};let a=s??Oe(r);return a==="unknown"?{code:e,market:"unknown"}:{code:r.market==="US"?r.code.toUpperCase():r.code,market:a}}catch{return{code:e,market:"unknown"}}}function Ce(t,e){return e==="sh"&&t.startsWith("000")||e==="sz"&&t.startsWith("399")}function Me(t){let{code:e,market:o}=t;return(o==="sh"||o==="sz")&&Ce(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${Se[e]??e}.html`:`https://so.eastmoney.com/web/s?keyword=${encodeURIComponent(e)}`}function ge(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/${ke[e]??e}`:`https://xueqiu.com/k?q=${encodeURIComponent(e)}`}function Re(t){let e=fe(t);return[{name:"\u4E1C\u65B9\u8D22\u5BCC",url:Me(e)},{name:"\u96EA\u7403",url:ge(e)}]}export{I as BROWSER_JSVARS_MUTEX_KEY,ie as FundService,d as HttpError,ee as INDICATOR_REGISTRY,A as MARKET_TZ,y as MemoryCache,le as MemoryCacheStore,m as SdkError,ae as StockSDK,se as TradingCalendarService,re as addIndicators,S as asyncPool,ue as backtest,j as buildIndicatorContext,N as buildTimeMeta,E as buildTimeMetaFromDateAndTime,me as cacheThrough,P as calcATR,H as calcBIAS,F as calcBOLL,J as calcCCI,Z as calcChipDistribution,v as calcDMI,q as calcEMA,Y as calcKC,_ as calcKDJ,X as calcMA,w as calcMACD,V as calcOBV,W as calcROC,$ as calcRSI,Q as calcSAR,B as calcSMA,ne as calcSignals,U as calcWMA,G as calcWR,k as chunkArray,C as clearClientScopedCaches,f as configureSharedCache,M as createCacheKey,c as decodeGBK,ce as default,oe as estimateIndicatorLookback,g as extractJsonFromJsonp,b as fetchJsVars,D as formatInTz,Re as generateSearchExternalLinks,te as getEnabledIndicatorKeys,h as getSdkErrorCode,O as getSharedCache,R as jsonpRequest,i as normalizeSymbol,T as parseJsVars,K as parseMarketTime,p as parseResponse,u as safeNumber,l as safeNumberOrNull,pe as screen,z as toEastmoneySecid,L as toTencentSymbol,x 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 _chunkR7M3BHS4cjs = require('./chunk-R7M3BHS4.cjs');require('./chunk-4VDLQK6F.cjs');exports.INDICATOR_REGISTRY = _chunkR7M3BHS4cjs.t; exports.addIndicators = _chunkR7M3BHS4cjs.x; exports.buildIndicatorContext = _chunkR7M3BHS4cjs.s; exports.calcATR = _chunkR7M3BHS4cjs.l; exports.calcBIAS = _chunkR7M3BHS4cjs.j; exports.calcBOLL = _chunkR7M3BHS4cjs.f; exports.calcCCI = _chunkR7M3BHS4cjs.k; exports.calcChipDistribution = _chunkR7M3BHS4cjs.r; exports.calcDMI = _chunkR7M3BHS4cjs.o; exports.calcEMA = _chunkR7M3BHS4cjs.b; exports.calcKC = _chunkR7M3BHS4cjs.q; exports.calcKDJ = _chunkR7M3BHS4cjs.g; exports.calcMA = _chunkR7M3BHS4cjs.d; exports.calcMACD = _chunkR7M3BHS4cjs.e; exports.calcOBV = _chunkR7M3BHS4cjs.m; exports.calcROC = _chunkR7M3BHS4cjs.n; exports.calcRSI = _chunkR7M3BHS4cjs.h; exports.calcSAR = _chunkR7M3BHS4cjs.p; exports.calcSMA = _chunkR7M3BHS4cjs.a; exports.calcWMA = _chunkR7M3BHS4cjs.c; exports.calcWR = _chunkR7M3BHS4cjs.i; exports.estimateIndicatorLookback = _chunkR7M3BHS4cjs.w; exports.getEnabledIndicatorKeys = _chunkR7M3BHS4cjs.v; exports.hasCumulativeIndicator = _chunkR7M3BHS4cjs.u;
|
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,x}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-W625VPPB.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,83 @@
|
|
|
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
|
|
2
|
-
`)}function
|
|
3
|
-
`)}var
|
|
4
|
-
`);for(;n>=0;){let
|
|
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;
|
|
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 _chunkWJOFTWZLcjs = require('./chunk-WJOFTWZL.cjs');var _chunk46ECBWOQcjs = require('./chunk-46ECBWOQ.cjs');require('./chunk-R7M3BHS4.cjs');require('./chunk-USZUOBM2.cjs');require('./chunk-SR7FGCVZ.cjs');require('./chunk-6MCPZDKN.cjs');var _chunk4Q7UQ5Q3cjs = require('./chunk-4Q7UQ5Q3.cjs');require('./chunk-4VDLQK6F.cjs');var L=["2025-11-25","2025-06-18"],ie=L[0],w={name:"stock-sdk",version:"2.4.0"},Y=-32700,S=-32600,V=-32601,m=-32602,F=-32603;function z(e){return typeof e=="string"&&L.includes(e)?e:ie}function f(...e){process.stderr.write(e.map(t=>typeof t=="string"?t:JSON.stringify(t)).join(" ")+`
|
|
2
|
+
`)}function y(e){process.stdout.write(JSON.stringify(e)+`
|
|
3
|
+
`)}var D=1e6;function U(e){let t="",r=!1;process.stdin.setEncoding("utf8"),process.stdin.on("data",o=>{t+=o;let n=t.indexOf(`
|
|
4
|
+
`);for(;n>=0;){let s=t.slice(0,n);t=t.slice(n+1),r?(r=!1,y({jsonrpc:"2.0",id:null,error:{code:S,message:`Message too large (limit ${D} bytes)`}})):s.trim()&&e(s),n=t.indexOf(`
|
|
5
|
+
`)}!r&&t.length>D?(f(`[stock-sdk mcp] \u8F93\u5165\u8D85\u957F\uFF08${t.length} bytes \u65E0\u6362\u884C\uFF0C\u8D85 ${D} \u4E0A\u9650\uFF09\uFF0C\u4E22\u5F03\u81F3\u4E0B\u4E00\u6362\u884C`),r=!0,t=""):r&&(t="")}),process.stdin.on("error",o=>f("[stock-sdk mcp] stdin error:",o.message)),process.stdout.on("error",o=>{o.code==="EPIPE"?(f("[stock-sdk mcp] stdout EPIPE\uFF08client \u65AD\u5F00\uFF09\uFF0C\u9000\u51FA"),process.exit(0)):f("[stock-sdk mcp] stdout error:",o.message)})}function O(e,t){if(e)return Array.isArray(e)&&e.length===0?"core":e;let r=process.env[t];if(!r)return"core";let o=r.trim().toLowerCase();if(o==="core"||o==="full")return o;let n=r.split(",").map(s=>s.trim()).filter(Boolean);return n.length>0?n:"core"}function b(e,t){if(Array.isArray(t)){let r=new Set(t);return e.filter(o=>r.has(o.name))}return t==="full"?[...e]:e.filter(r=>r.tier==="core")}var se={string:"string",enum:"string",number:"integer",boolean:"boolean"};function A(e){return _nullishCoalesce(_nullishCoalesce(e.jsonKey, () => (e.field)), () => (e.flag))}function ae(e){return _optionalChain([e, 'access', _2 => _2.enum, 'optionalAccess', _3 => _3.map, 'call', _4 => _4(t=>_nullishCoalesce(_optionalChain([e, 'access', _5 => _5.map, 'optionalAccess', _6 => _6[t]]), () => (t)))])}function _(e){let t=se[e.type];if(!t)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 r={type:t},o=ae(e);o&&(r.enum=o),e.default!==void 0&&(r.default=e.default);let n=_nullishCoalesce(e.mcpDesc, () => (e.desc));return n&&(r.description=n),r}function ce(e){let t={type:"string"};return e.enum&&(t.enum=e.enum),e.default!==void 0&&(t.default=e.default),e.desc&&(t.description=e.desc),t}var B={type:"array",items:{type:"string"},description:"\u4EE3\u7801\u6570\u7EC4\uFF0C\u5E26\u4E0D\u5E26\u4EA4\u6613\u6240\u524D\u7F00\u5747\u53EF\uFF08A \u80A1 '600036'/'sh600519'\uFF1B\u6E2F\u80A1 '00700'/'hk00700'\uFF1B\u7F8E\u80A1 'AAPL'/'usAAPL'\uFF09\u3002A \u80A1\u6307\u6570\u9700\u5E26\u524D\u7F00\uFF08\u5982 'sh000001'\uFF09\uFF1B\u65E0\u6CD5\u8BC6\u522B\u6216\u8BE5\u6570\u636E\u6E90\u4E0D\u8986\u76D6\u7684\u4EE3\u7801\uFF08\u5982\u4E2D\u8BC1\u7279\u6B8A\u6307\u6570\uFF09\u4F1A\u88AB\u8DF3\u8FC7\u800C\u975E\u62A5\u9519"};function W(e){return(_nullishCoalesce(e.params, () => ([]))).filter(t=>t.mcp!==!1)}function le(e){let t={},r=[];(e.argShape==="codes[]"||e.argShape==="codes+options")&&(t.codes=e.codesDesc?{...B,description:e.codesDesc}:B,r.push("codes"));for(let o of _nullishCoalesce(e.positional, () => ([])))t[o.name]=ce(o),o.required&&r.push(o.name);for(let o of W(e))t[A(o)]=_(o),o.required&&r.push(A(o));return{type:"object",properties:t,required:r.length>0?r:void 0,additionalProperties:!1}}function de(e,t){let r=_chunkWJOFTWZLcjs.a.call(void 0, e,t);if(!r)throw new Error(`SDK \u4E0A\u4E0D\u5B58\u5728\u65B9\u6CD5: ${t.join(".")}`);return o=>r.fn.apply(r.parent,o)}function ue(e){let t=_nullishCoalesce(e.positional, () => ([])),r=W(e);return(o,n)=>{let s=de(o,e.path),u=t.map(c=>n[c.name]),i={};for(let c of r)i[_nullishCoalesce(c.field, () => (c.flag))]=n[A(c)];switch(e.argShape){case"none":return s([]);case"codes[]":return s([n.codes]);case"codes+options":return s([n.codes,i]);case"symbol+options":return s([...u,i]);case"options":return s([i]);case"positional":return s(u);default:throw new Error(`\u4E0D\u652F\u6301\u7684 argShape: ${e.argShape}`)}}}function X(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:le(e),tier:_nullishCoalesce(e.tier, () => ("full")),invoke:ue(e)}}var pe=["ma","macd","boll","kdj","rsi","wr","bias","cci","atr","obv","roc","dmi","sar","kc"],R=_chunkWJOFTWZLcjs.n.call(void 0, "kline.withIndicators"),H={name:R.toolName,tier:_nullishCoalesce(R.tier, () => ("full")),description:_nullishCoalesce(R.mcpDesc, () => (R.summary)),inputSchema:{type:"object",properties:{symbol:{type:"string",description:"\u80A1\u7968\u4EE3\u7801\u3002A \u80A1 / \u6E2F\u80A1\u88F8\u7801\u5373\u53EF\uFF08600519 / 00700\uFF09\uFF1B\u7F8E\u80A1\u652F\u6301\u88F8 ticker\uFF08AAPL\uFF09\u6216 secid\uFF08105.AAPL\uFF09"},market:_(_chunkWJOFTWZLcjs.j),period:_(_chunkWJOFTWZLcjs.e),adjust:_(_chunkWJOFTWZLcjs.d),startDate:{..._(_chunkWJOFTWZLcjs.g),description:"\u8D77\u59CB\u65E5\u671F YYYYMMDD \u6216 YYYY-MM-DD"},endDate:{..._(_chunkWJOFTWZLcjs.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 "+pe.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,t)=>e.kline.withIndicators(t.symbol,{market:t.market,period:t.period,adjust:t.adjust,startDate:t.startDate,endDate:t.endDate,indicators:t.indicators})};var me={"kline.withIndicators":H},Q=_chunkWJOFTWZLcjs.m.filter(e=>e.mcp!==!1).map(e=>{if(e.mcpCustom){let t=me[e.path.join(".")];if(!t)throw new Error(`\u65B9\u6CD5 ${e.path.join(".")} \u6807\u8BB0\u4E86 mcpCustom \u4F46\u672A\u6CE8\u518C\u624B\u5199\u5DE5\u5177`);return t}return X(e)}),Je=new Map(Q.map(e=>[e.name,e]));function G(e){return b(Q,e)}var Z=[{name:"analyze_stock",title:"Analyze stock (technical)",description:"Full technical analysis of one symbol: klines + indicators + signals, summarized.",tier:"core",args:[{name:"symbol",description:"Stock code, e.g. sh600519 / 600519 / 00700 / AAPL",required:!0},{name:"period",description:"Kline period: daily / weekly / monthly (default daily)",default:"daily"}],usesTools:["search","get_kline_with_indicators","get_kline_signals"],render:e=>`You are a rigorous equity technical-analysis assistant. Perform a complete technical analysis of ${e.symbol}.
|
|
6
|
+
|
|
7
|
+
[Data \u2014 call these read-only tools as needed; never fabricate data]
|
|
8
|
+
1. If ${e.symbol} might not be a canonical code, confirm it with \`search\` first.
|
|
9
|
+
2. Use \`get_kline_with_indicators\` to fetch ${e.period} klines with MA(5/10/20/60), MACD, BOLL, KDJ and RSI overlaid.
|
|
10
|
+
3. Use \`get_kline_signals\` to detect golden/death crosses, overbought/oversold, BOLL breakouts and SAR reversals.
|
|
11
|
+
|
|
12
|
+
[Analysis]
|
|
13
|
+
- Trend: MA alignment, price-vs-MA relationship, MACD direction.
|
|
14
|
+
- Momentum: KDJ / RSI overbought/oversold, any divergence.
|
|
15
|
+
- Key levels: BOLL upper/lower bands, recent support/resistance.
|
|
16
|
+
- Signals: list recent valid signals (type + date) and judge reliability \u2014 corroborate with price/volume, don't just name them.
|
|
17
|
+
|
|
18
|
+
[Output]
|
|
19
|
+
Give (1) a one-line verdict (bullish / bearish / range-bound); (2) per-dimension points (trend / momentum / signals / risk); (3) an explicit note that this is technical analysis of public market data and not investment advice.`},{name:"screen_stocks",title:"Screen stocks",description:"Build a candidate shortlist over a chosen universe by natural-language criteria, coarse-filtering before per-symbol indicator work.",tier:"core",args:[{name:"criteria",description:'Screening criteria in natural language, e.g. "MACD golden cross and turnover > 5%"',required:!0},{name:"scope",description:"Universe to screen: an industry/concept board name, or the whole market (default)",default:"the whole A-share market"}],usesTools:["get_industry_constituents","get_concept_constituents","get_fund_flow_rank","get_a_share_quotes","get_kline_with_indicators","get_kline_signals"],render:e=>`You are a disciplined equity screening assistant. Build a candidate shortlist from ${e.scope} that matches: ${e.criteria}.
|
|
20
|
+
|
|
21
|
+
[Workflow \u2014 read-only tools; mind the cost of scanning many symbols]
|
|
22
|
+
1. Resolve the universe:
|
|
23
|
+
- If ${e.scope} names an industry board, call \`get_industry_constituents\`; if a concept board, call \`get_concept_constituents\` to list its members.
|
|
24
|
+
- If it is the whole market, start from \`get_fund_flow_rank\` (whole-market main-force net-inflow ranking, top ~200) as a manageable candidate pool.
|
|
25
|
+
2. Coarse-filter FIRST on cheap fields: call \`get_a_share_quotes\` on the universe and screen by change% / turnover / volume-ratio / market cap \u2014 narrow to a small subset BEFORE any per-symbol indicator work.
|
|
26
|
+
3. Confirm on the subset only: for each surviving candidate call \`get_kline_with_indicators\` and \`get_kline_signals\` to check the technical part of the criteria (e.g. MACD golden cross, RSI not overbought).
|
|
27
|
+
|
|
28
|
+
[Output]
|
|
29
|
+
Return a ranked shortlist \u2014 code, name, why it matched (the specific criteria met), and any caveat. State how many symbols you scanned vs. shortlisted. Never run per-symbol klines across thousands of names; always coarse-filter first.`},{name:"market_overview",title:"Market overview",description:"Today's A-share snapshot: market status, limit-up breadth, northbound flow, main-force money direction.",tier:"core",args:[],usesTools:["get_market_status","get_zt_pool","get_northbound_flow_summary","get_fund_flow_rank"],render:()=>`You are a market briefing assistant. Give a concise snapshot of today's A-share market.
|
|
30
|
+
|
|
31
|
+
[Data \u2014 read-only]
|
|
32
|
+
1. \`get_market_status\` \u2014 is the market pre-open / open / lunch break / after-hours / closed (tells you how live the read is).
|
|
33
|
+
2. \`get_zt_pool\` \u2014 the limit-up pool (breadth and risk appetite; also prior-day limit-ups for follow-through).
|
|
34
|
+
3. \`get_northbound_flow_summary\` \u2014 northbound / southbound money direction.
|
|
35
|
+
4. \`get_fund_flow_rank\` \u2014 where main-force money is flowing (leaders by net inflow).
|
|
36
|
+
|
|
37
|
+
[Output]
|
|
38
|
+
A short brief: (1) market status line; (2) risk appetite read from limit-up breadth; (3) capital direction (northbound + main-force leaders); (4) a one-line takeaway. Note this is a single snapshot, not continuous monitoring.`},{name:"monitor_watchlist",title:"Monitor watchlist",description:"Single-shot check of a watchlist: batch quotes, then drill into names that crossed a threshold.",tier:"core",args:[{name:"symbols",description:'Comma-separated stock codes to monitor, e.g. "600519,000858,300750"',required:!0}],usesTools:["get_a_share_quotes","get_today_timeline","get_individual_fund_flow","get_kline_signals"],render:e=>`You are a watchlist monitoring assistant. Check the current state of these symbols: ${e.symbols}.
|
|
39
|
+
|
|
40
|
+
[Data \u2014 read-only]
|
|
41
|
+
1. \`get_a_share_quotes\` \u2014 batch real-time quotes for all of ${e.symbols} at once (price, change%, turnover, volume-ratio, bid/ask).
|
|
42
|
+
2. For any name that looks active (big move / volume spike), dig in:
|
|
43
|
+
- \`get_today_timeline\` \u2014 the intraday path, to tell a steady move from a one-off spike.
|
|
44
|
+
- \`get_individual_fund_flow\` \u2014 whether main-force money is flowing in or out.
|
|
45
|
+
- \`get_kline_signals\` \u2014 any fresh technical signal (cross / breakout) on the daily.
|
|
46
|
+
|
|
47
|
+
[Output]
|
|
48
|
+
One line per symbol (price, change%, notable flag). Then call out the 1\u20133 names that crossed a threshold (big move / volume / main-force inflow / new signal) with a short why. This is a single snapshot \u2014 for continuous watching, re-run this skill on a schedule from your client.`},{name:"analyze_capital_flow",title:"Analyze capital flow",description:"Smart-money / main-force read for one stock or the broad market: fund flow + dragon-tiger + block trades + margin + northbound.",tier:"full",args:[{name:"symbol",description:"Optional stock code to focus on; omit for a market-wide read",required:!1}],usesTools:["get_individual_fund_flow","get_market_fund_flow","get_dragon_tiger_detail","get_dragon_tiger_seat_detail","get_block_trade_detail","get_margin_account_info","get_northbound_individual"],render:e=>`You are a capital-flow / smart-money analyst. Focus: ${e.symbol?`stock ${e.symbol}`:"the broad market"}.
|
|
49
|
+
|
|
50
|
+
[Data \u2014 read-only; pick what fits the focus]
|
|
51
|
+
- \`get_individual_fund_flow\` \u2014 per-stock main / large / medium / small net inflow (history).
|
|
52
|
+
- \`get_market_fund_flow\` \u2014 market-wide main-force flow.
|
|
53
|
+
- \`get_dragon_tiger_detail\` \u2014 dragon-tiger board: which stocks made it and when.
|
|
54
|
+
- \`get_dragon_tiger_seat_detail\` \u2014 which seats (institutions / hot-money desks) traded.
|
|
55
|
+
- \`get_block_trade_detail\` \u2014 block trades (discount/premium, buyer/seller side).
|
|
56
|
+
- \`get_margin_account_info\` \u2014 margin balance trend (leverage appetite).
|
|
57
|
+
- \`get_northbound_individual\` \u2014 northbound per-stock holdings change.
|
|
58
|
+
|
|
59
|
+
For a specific stock, lean on get_individual_fund_flow + get_dragon_tiger_detail / get_dragon_tiger_seat_detail + get_block_trade_detail + get_northbound_individual + get_margin_account_info.
|
|
60
|
+
For a market-wide read, lean on get_market_fund_flow + get_margin_account_info + the northbound picture.
|
|
61
|
+
|
|
62
|
+
[Output]
|
|
63
|
+
Read main-force intent \u2014 accumulation vs. distribution \u2014 corroborated across at least two independent flow sources (don't over-read a single day). List the concrete evidence per source, then a net judgment and key caveats.`},{name:"analyze_fund",title:"Analyze fund",description:"Mutual-fund review: profile + NAV history + category ranking + intraday estimate.",tier:"full",args:[{name:"fundCode",description:"6-digit fund code, e.g. 110022",required:!0}],usesTools:["get_fund_profile","get_fund_nav_history","get_fund_rank_history","get_fund_estimate"],render:e=>`You are a mutual-fund analyst. Assess fund ${e.fundCode}.
|
|
64
|
+
|
|
65
|
+
[Data \u2014 read-only]
|
|
66
|
+
1. \`get_fund_profile\` \u2014 type, manager, size, strategy.
|
|
67
|
+
2. \`get_fund_nav_history\` \u2014 historical NAV trend: cumulative return, drawdown, volatility.
|
|
68
|
+
3. \`get_fund_rank_history\` \u2014 same-category ranking percentile over time (consistency vs. one-off).
|
|
69
|
+
4. \`get_fund_estimate\` \u2014 today's intraday NAV estimate (note: QDII / non-trading days / niche funds may return null or stale estimates \u2014 say so rather than guess).
|
|
70
|
+
|
|
71
|
+
[Output]
|
|
72
|
+
A structured review: (1) what it is (type / manager / size); (2) performance (returns across horizons, worst drawdown, volatility); (3) ranking percentile and whether it's consistent; (4) today's estimate with its caveat; (5) a balanced takeaway on strengths / risks. Public data only, not investment advice.`},{name:"diagnose_stock",title:"Diagnose stock (multi-factor)",description:"Cross-dimension diagnosis of one stock: technicals + capital + chips, scored and combined.",tier:"full",args:[{name:"symbol",description:"Stock code to diagnose, e.g. sh600519",required:!0}],usesTools:["get_kline_with_indicators","get_kline_signals","get_individual_fund_flow","get_dragon_tiger_stock_stats","get_chip_distribution"],render:e=>`You are a multi-factor stock diagnostician. Diagnose ${e.symbol} across technicals, capital and chips.
|
|
73
|
+
|
|
74
|
+
[Data \u2014 read-only]
|
|
75
|
+
- Technicals: \`get_kline_with_indicators\` (trend / momentum) + \`get_kline_signals\` (crosses / breakouts).
|
|
76
|
+
- Capital: \`get_individual_fund_flow\` (main-force in/out) + \`get_dragon_tiger_stock_stats\` (dragon-tiger frequency / stats).
|
|
77
|
+
- Chips: \`get_chip_distribution\` (profit ratio, 90/70 cost range, concentration).
|
|
78
|
+
|
|
79
|
+
[Output]
|
|
80
|
+
Score each dimension (technical / capital / chips) as bullish / neutral / bearish with the evidence, then a combined read and the key risks. Be explicit where dimensions disagree. Public-data technical analysis, not investment advice.`}];var fe=`
|
|
81
|
+
|
|
82
|
+
IMPORTANT: Respond in the same language the user is using.
|
|
83
|
+
Read and analyze only \u2014 never place orders or move funds. If data is missing or a source returns nothing, say so honestly; do not fabricate numbers.`;function ee(e){return{name:e.name,title:e.title,description:e.description,tier:e.tier,arguments:e.args.map(t=>({name:t.name,description:t.description,required:t.required===!0})),usesTools:e.usesTools,render:t=>{let r={};for(let o of e.args){let n=t[o.name];if(n==null||n===""){if(o.required)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 "${o.name}"`,{argument:o.name});o.default!==void 0&&(r[o.name]=o.default)}else r[o.name]=typeof n=="string"?n:String(n)}return e.render(r)+fe}}}var te=Z.map(ee),Fe=new Map(te.map(e=>[e.name,e]));function re(e){return b(te,e)}var M=200,ge=8e4;function he(e){return Array.isArray(e)&&e.length>M?{total:e.length,truncated:!0,note:`\u7ED3\u679C\u8FC7\u5927\uFF0C\u4EC5\u8FD4\u56DE\u524D ${M} \u6761\uFF1B\u8BF7\u7528\u65E5\u671F / \u5206\u9875 / \u5E02\u573A\u7B49\u53C2\u6570\u7F29\u5C0F\u8303\u56F4`,sample:e.slice(0,M)}:e}function oe(e){let t=_nullishCoalesce(JSON.stringify(he(e)), () => ("null"));return t.length>ge?{content:[{type:"text",text:JSON.stringify({truncated:!0,reason:"oversized",approxKB:Math.round(t.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:t.length}}:{content:[{type:"text",text:t}]}}function E(e){let t=_chunk4Q7UQ5Q3cjs.i.call(void 0, e)?e.code:"UNKNOWN",r=e instanceof Error?e.message:String(e),o=_chunk4Q7UQ5Q3cjs.i.call(void 0, e)?{code:e.code,provider:e.provider,url:e.url,status:e.status,details:e.details}:{code:t};return{content:[{type:"text",text:`Error[${t}]: ${r}`}],isError:!0,_meta:o}}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _e(e,t){switch(t){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 g(e);default:return!0}}function ye(e,t){if(e.additionalProperties===!1){let r=new Set(Object.keys(e.properties));for(let o of Object.keys(t))if(!r.has(o))return`\u672A\u77E5\u53C2\u6570 "${o}"`}for(let r of _nullishCoalesce(e.required, () => ([])))if(t[r]===void 0||t[r]===null)return`\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 "${r}"`;for(let[r,o]of Object.entries(e.properties)){let n=t[r];if(n!==void 0){if(o.type&&!_e(n,o.type))return`\u53C2\u6570 "${r}" \u7C7B\u578B\u5E94\u4E3A ${o.type}`;if(o.enum&&!o.enum.includes(n))return`\u53C2\u6570 "${r}" \u53D6\u503C\u975E\u6CD5\u300C${String(n)}\u300D\uFF0C\u53EF\u9009: ${o.enum.join(" / ")}`}}return null}async function ke(e,t){let r=_nullishCoalesce(e.id, () => (null)),o=e.id!==void 0&&e.id!==null,n=i=>({jsonrpc:"2.0",id:r,result:i}),s=(i,c)=>({jsonrpc:"2.0",id:r,error:{code:i,message:c}});if(e.jsonrpc!=="2.0"||typeof e.method!="string"||e.method.length===0)return o?s(S,"Invalid Request"):null;let u=e.params;switch(e.method){case"initialize":{let i=g(u)?u.protocolVersion:void 0;return n({protocolVersion:z(i),capabilities:{tools:{},prompts:{}},serverInfo:w})}case"notifications/initialized":case"notifications/cancelled":return null;case"ping":return n({});case"tools/list":return n({tools:t.tools.map(i=>({name:i.name,description:i.description,inputSchema:i.inputSchema}))});case"tools/call":{if(!g(u))return s(m,"params must be an object");let i=u.name;if(typeof i!="string")return s(m,"params.name must be a string");let c=t.toolMap.get(i);if(!c)return s(m,`Unknown tool: ${i}`);let d=u.arguments;if(d!==void 0&&!g(d))return s(m,"params.arguments must be an object");let h=g(d)?d:{},a=ye(c.inputSchema,h);if(a)return n(E(new (0, _chunk4Q7UQ5Q3cjs.e)(a)));try{let l=await c.invoke(t.sdk,h);return n(oe(l))}catch(l){return n(E(l))}}case"prompts/list":return n({prompts:t.prompts.map(i=>({name:i.name,title:i.title,description:i.description,arguments:i.arguments}))});case"prompts/get":{if(!g(u))return s(m,"params must be an object");let i=u.name;if(typeof i!="string")return s(m,"params.name must be a string");let c=t.promptMap.get(i);if(!c)return s(m,`Unknown prompt: ${i}`);let d=u.arguments;if(d!==void 0&&!g(d))return s(m,"params.arguments must be an object");let h=g(d)?d:{};try{let a=c.render(h),l=_optionalChain([c, 'access', _7 => _7.arguments, 'access', _8 => _8[0], 'optionalAccess', _9 => _9.name]),p=l?h[l]:void 0;return n({description:p?`${c.title} \xB7 ${p}`:c.title,messages:[{role:"user",content:{type:"text",text:a}}]})}catch(a){return s(m,_nullishCoalesce(_optionalChain([a, 'optionalAccess', _10 => _10.message]), () => ("invalid prompt arguments")))}}default:return o?s(V,`Unknown method: ${e.method}`):null}}function we(e){return O(e,"STOCK_SDK_MCP_TOOLS")}function Se(e){return O(e,"STOCK_SDK_MCP_PROMPTS")}function be(e){if(e)return e;let t=process.env.STOCK_SDK_MCP_TIMEOUT,r=t?Number(t):void 0;return r&&!Number.isNaN(r)&&r>0?{timeout:r}:{}}function rt(e={}){let t=new (0, _chunk46ECBWOQcjs.t)(be(e.sdk)),r=we(e.tools),o=Se(e.prompts),n=G(r),s=re(o),u={sdk:t,tools:n,toolMap:new Map(n.map(a=>[a.name,a])),prompts:s,promptMap:new Map(s.map(a=>[a.name,a]))};f(`[stock-sdk mcp] ready \xB7 ${n.length} tools \xB7 ${s.length} prompts \xB7 ${w.name}@${w.version}`);let i=(a,l,p)=>{if(!Array.isArray(l))return;let ne=new Set(p.map(P=>P.name)),T=l.filter(P=>!ne.has(P));T.length>0&&f(`[stock-sdk mcp] \u26A0 ${a} \u540D\u5355\u4E2D\u6709 ${T.length} \u4E2A\u672A\u77E5\u540D\uFF08\u5DF2\u5FFD\u7565\uFF09\uFF1A${T.join(", ")}`)};i("\u5DE5\u5177",r,n),i("\u6280\u80FD",o,s);let c=new Set(n.map(a=>a.name)),d=new Set;for(let a of s)for(let l of a.usesTools)c.has(l)||d.add(l);d.size>0&&f(`[stock-sdk mcp] \u26A0 \u5DF2\u542F\u7528\u7684\u6280\u80FD\u5F15\u7528\u4E86 ${d.size} \u4E2A\u4E0D\u5728\u5F53\u524D\u5DE5\u5177\u96C6\u5185\u7684\u5DE5\u5177\uFF1A${[...d].join(", ")}\u3002\u8FD9\u4E9B\u6280\u80FD\u7F16\u6392\u5230\u8BE5\u6B65\u4F1A\u5931\u8D25 \u2014\u2014 \u8BF7\u8BBE STOCK_SDK_MCP_TOOLS=full\uFF08\u6216\u628A\u8FD9\u4E9B\u5DE5\u5177\u52A0\u8FDB\u540D\u5355\uFF09\u3002`),U(a=>{h(a)}),process.stdin.on("end",()=>f("[stock-sdk mcp] stdin closed, exiting"));async function h(a){let l;try{l=JSON.parse(a)}catch (e2){y({jsonrpc:"2.0",id:null,error:{code:Y,message:"Parse error"}});return}try{let p=await ke(l,u);p&&y(p)}catch(p){f("[stock-sdk mcp] internal error:",_nullishCoalesce(_optionalChain([p, 'optionalAccess', _11 => _11.message]), () => (String(p)))),l.id!==void 0&&l.id!==null&&y({jsonrpc:"2.0",id:l.id,error:{code:F,message:String(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _12 => _12.message]), () => (p)))}})}}}exports.dispatchMessage = ke; exports.startMcpServer = rt;
|