stock-sdk 2.2.2 → 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 +7 -2
- 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/chip-BbA23rr1.d.cts +113 -0
- package/dist/chip-BbA23rr1.d.ts +113 -0
- 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 +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +1 -1
- package/dist/indicators.cjs +1 -1
- package/dist/indicators.d.cts +1 -0
- package/dist/indicators.d.ts +1 -0
- package/dist/indicators.js +1 -1
- package/dist/mcp.cjs +83 -5
- package/dist/mcp.d.cts +29 -2
- package/dist/mcp.d.ts +29 -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-CmYFd7V2.d.ts → sdk-DGgSDZRx.d.ts} +200 -21
- package/dist/{sdk-BOfyUDzu.d.cts → sdk-RzQ-drS4.d.cts} +200 -21
- 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-3VUFYFFD.js +0 -1
- package/dist/chunk-6ZSZEHZW.js +0 -1
- package/dist/chunk-C4CA7QBB.cjs +0 -1
- package/dist/chunk-DU7MCVLJ.js +0 -1
- package/dist/chunk-EDUJJOAJ.js +0 -1
- package/dist/chunk-F3KZXCVO.js +0 -1
- package/dist/chunk-JP3ZPNWP.cjs +0 -1
- package/dist/chunk-KKGWFS2M.cjs +0 -1
- package/dist/chunk-LCX5Q36O.js +0 -1
- package/dist/chunk-T5CH7H3X.cjs +0 -1
- package/dist/chunk-TVIEKKDQ.cjs +0 -1
- package/dist/chunk-USK6JHLG.cjs +0 -1
- package/dist/chunk-WCBK5KYA.cjs +0 -1
- package/dist/chunk-ZZ2IBUMV.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }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');var _chunk4VDLQK6Fcjs = require('./chunk-4VDLQK6F.cjs');function bt(t){return new TextDecoder("gbk").decode(t)}function Nt(t){let e=t.split(";").map(r=>r.trim()).filter(Boolean),n=[];for(let r of e){let o=r.indexOf("=");if(o<0)continue;let i=r.slice(0,o).trim();i.startsWith("v_")&&(i=i.slice(2));let s=r.slice(o+1).trim();s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1));let a=s.split("~");n.push({key:i,fields:a})}return n}function Mt(t){let e=t.trim();return e===""||e==="-"||e==="--"}function S(t){if(!t||t==="")return 0;let e=parseFloat(t);return Number.isNaN(e)?0:e}function D(t){if(!t||Mt(t))return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function h(t){if(!t||Mt(t))return null;let e=parseFloat(t);return Number.isNaN(e)?null:e}function u(t){return t==null?null:h(String(t))}function _(t){if(t==null)return null;if(typeof t=="number")return Number.isFinite(t)?t:null;if(Mt(t))return null;let e=Number(t);return Number.isFinite(e)?e:null}var Ii=new Set(["daily","weekly","monthly"]),bi=new Set(["1","5","15","30","60"]),Ni=new Set(["","qfq","hfq"]);function te(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`${e} must be a positive integer`,{argument:e,value:t})}function j(t){if(!Ii.has(t))throw new (0, _chunk4Q7UQ5Q3cjs.e)("period must be one of: daily, weekly, monthly",{argument:"period",value:t})}function kt(t){if(!bi.has(t))throw new (0, _chunk4Q7UQ5Q3cjs.e)("period must be one of: 1, 5, 15, 30, 60",{argument:"period",value:t})}function ie(t){if(!Ni.has(t))throw new (0, _chunk4Q7UQ5Q3cjs.e)("adjust must be one of: '', 'qfq', 'hfq'",{argument:"adjust",value:t})}function rt(t){if(t!=="north"&&t!=="south")throw new (0, _chunk4Q7UQ5Q3cjs.e)("direction must be one of: 'north', 'south'",{argument:"direction",value:t})}function Ae(t,e){te(e,"chunkSize");let n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}async function se(t,e,n=!1){if(te(e,"concurrency"),t.length===0)return[];let r=n?new Array(t.length):[],o=0,i=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let s=o++;if(s>=t.length)return;let a=await t[s]();n?r[s]=a:r.push(a)}});return await Promise.all(i),r}function Q(t){return{daily:"101",weekly:"102",monthly:"103"}[t]}function ae(t){return{"":"0",qfq:"1",hfq:"2"}[t]}var Mi=typeof document<"u"&&typeof window<"u",ki=0;function lr(){return`__stock_sdk_jsonp_${Date.now()}_${ki++}`}function ot(t){let e=t,n=e.indexOf("*/");n!==-1&&(e=e.slice(n+2).trim());let r=e.indexOf("(");if(r===-1)throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:"Invalid JSONP response: no opening parenthesis found"});let o=e.lastIndexOf(")");if(o===-1||o<=r)throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:"Invalid JSONP response: no closing parenthesis found"});let i=e.slice(r+1,o);try{return JSON.parse(i)}catch(s){throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:"Invalid JSONP response: payload is not valid JSON",cause:s})}}function Li(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e;return new Promise((i,s)=>{let a=lr(),l;if(o==="path")l=t.replace("{callback}",a);else{let f=t.includes("?")?"&":"?";l=`${t}${f}${r}=${a}`}let c=document.createElement("script"),d=!1,m=window,p=()=>{c.parentNode&&c.parentNode.removeChild(c),delete m[a]},g=setTimeout(()=>{d||(d=!0,p(),s(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`JSONP request timed out after ${n}ms: ${t}`,url:t,details:{timeout:n}})))},n);m[a]=f=>{d||(d=!0,clearTimeout(g),p(),i(f))},c.onerror=()=>{d||(d=!0,clearTimeout(g),p(),s(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`JSONP script load failed: ${t}`,url:t})))},c.src=l,document.head.appendChild(c)})}async function Fi(t,e){let{timeout:n=15e3,callbackParam:r="callback",callbackMode:o="query"}=e,i=lr(),s;if(o==="path")s=t.replace("{callback}",i);else{let c=t.includes("?")?"&":"?";s=`${t}${c}${r}=${i}`}let a=new AbortController,l=setTimeout(()=>a.abort(),n);try{let c=await fetch(s,{signal:a.signal});if(!c.ok)throw new (0, _chunk4Q7UQ5Q3cjs.b)(c.status,c.statusText,t);let d=await c.text();return ot(d)}catch(c){throw c instanceof DOMException&&c.name==="AbortError"?new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`JSONP request timed out after ${n}ms: ${t}`,url:t,details:{timeout:n}}):c instanceof _chunk4Q7UQ5Q3cjs.a?c:new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`JSONP request failed: ${c instanceof Error?c.message:String(c)}`,url:t,cause:c})}finally{clearTimeout(l)}}function x(t,e={}){return Mi?Li(t,e):Fi(t,e)}var cr=new Map;async function Oe(t,e){let r=(_nullishCoalesce(cr.get(t), () => (Promise.resolve()))).then(e,e);return cr.set(t,r.then(()=>{},()=>{})),r}function wi(){return typeof document<"u"&&typeof window<"u"}var vi=15e3,Ui= exports.j ="jsVars";async function ce(t,e,n={}){let r=_nullishCoalesce(n.timeout, () => (vi));return wi()?Oe(_nullishCoalesce(n.mutexKey, () => (Ui)),()=>xi(t,e,r)):Ki(t,e,r,n.headers,n.client)}function Lt(t,e){let n={};for(let r of e){let o=Bi(t,r);o!==void 0&&(n[r]=o)}return n}function xi(t,e,n){return new Promise((r,o)=>{let i=window,s=document.createElement("script"),a=!1,l=()=>{for(let m of e)try{i[m]=void 0}catch (e2){}};l();let c=()=>{s.parentNode&&s.parentNode.removeChild(s)},d=setTimeout(()=>{a||(a=!0,s.onload=l,s.onerror=null,c(),o(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`fetchJsVars timed out after ${n}ms: ${t}`,url:t,details:{timeout:n}})))},n);s.onload=()=>{if(a)return;a=!0,clearTimeout(d);let m={};for(let p of e){p in i&&i[p]!==void 0&&(m[p]=i[p]);try{delete i[p]}catch (e3){try{i[p]=void 0}catch (e4){}}}c(),r(m)},s.onerror=()=>{a||(a=!0,clearTimeout(d),c(),o(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`fetchJsVars script load failed: ${t}`,url:t})))},s.src=t,document.head.appendChild(s)})}async function Ki(t,e,n,r,o){if(o){let a=await o.get(t,{responseType:"text"});return Lt(a,e)}let i=new AbortController,s=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{signal:i.signal,headers:r});if(!a.ok)throw new (0, _chunk4Q7UQ5Q3cjs.b)(a.status,a.statusText,t);let l=await a.text();return Lt(l,e)}catch(a){throw a instanceof DOMException&&a.name==="AbortError"?new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`fetchJsVars timed out after ${n}ms: ${t}`,url:t,details:{timeout:n}}):a instanceof _chunk4Q7UQ5Q3cjs.a?a:new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`fetchJsVars failed: ${a instanceof Error?a.message:String(a)}`,url:t,cause:a})}finally{clearTimeout(s)}}function Bi(t,e){let r=new RegExp(`(?:^|[^\\w$])(?:var|let|const)\\s+${qi(e)}\\s*=\\s*`,"m").exec(t);if(!r)return;let o=r.index+r[0].length,i=zi(t,o),s=t.slice(o,i).trim();try{return JSON.parse(s)}catch (e5){try{return JSON.parse(Hi(s))}catch (e6){return}}}function Hi(t){let e="",n=null;for(let r=0;r<t.length;r++){let o=t[r];if(n==='"'){e+=o,o==="\\"&&r+1<t.length?e+=t[++r]:o==='"'&&(n=null);continue}if(n==="'"){if(o==="\\"&&r+1<t.length){let i=t[++r];e+=i==="'"?"'":"\\"+i;continue}if(o==="'"){e+='"',n=null;continue}e+=o==='"'?'\\"':o;continue}if(o==='"'){n='"',e+=o;continue}if(o==="'"){n="'",e+='"';continue}e+=o}return e}function qi(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zi(t,e){let n=0,r=null;for(let o=e;o<t.length;o++){let i=t[o];if(r){if(i==="\\"){o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"){r=i;continue}if(i==="["||i==="{"||i==="("){n++;continue}if(i==="]"||i==="}"||i===")"){n--;continue}if(i===";"&&n===0)return o}return t.length}var C={CN:"Asia/Shanghai",HK:"Asia/Hong_Kong",US:"America/New_York"};function $i(t){if(!t)return null;let e=t.trim();if(!e)return null;let n=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/.exec(e);if(n)return{year:+n[1],month:+n[2],day:+n[3],hour:+n[4],minute:+n[5],second:n[6]?+n[6]:0};let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return r?{year:+r[1],month:+r[2],day:+r[3],hour:0,minute:0,second:0}:/^\d{14}$/.test(e)?{year:+e.slice(0,4),month:+e.slice(4,6),day:+e.slice(6,8),hour:+e.slice(8,10),minute:+e.slice(10,12),second:+e.slice(12,14)}:/^\d{8}$/.test(e)?{year:+e.slice(0,4),month:+e.slice(4,6),day:+e.slice(6,8),hour:0,minute:0,second:0}:null}var Yi={wallParts:{locale:"en-US",keyPrefix:"en-US|",options:{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}},svDisplay:{locale:"sv-SE",keyPrefix:"sv-SE|",options:{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}},dateOnly:{locale:"en-CA",keyPrefix:"en-CA|",options:{year:"numeric",month:"2-digit",day:"2-digit"}}},dr=new Map;function Ft(t,e){let n=Yi[t],r=n.keyPrefix+e,o=dr.get(r);return o||(o=new Intl.DateTimeFormat(n.locale,{timeZone:e,...n.options}),dr.set(r,o)),o}function De(t,e){let r=Ft("wallParts",e).formatToParts(new Date(t)),o={};for(let s of r)s.type!=="literal"&&(o[s.type]=s.value);let i=parseInt(_nullishCoalesce(o.hour, () => ("0")),10);return i===24&&(i=0),Date.UTC(parseInt(_nullishCoalesce(o.year, () => ("0")),10),parseInt(_nullishCoalesce(o.month, () => ("1")),10)-1,parseInt(_nullishCoalesce(o.day, () => ("1")),10),i,parseInt(_nullishCoalesce(o.minute, () => ("0")),10),parseInt(_nullishCoalesce(o.second, () => ("0")),10))}var pr=new Map;function mr(t,e){return De(t,e)-t}function ji(t,e){let n=`${t}|${e}`,r=pr.get(n);if(r===void 0){let o=mr(Date.UTC(e,0,1,12),t);for(let i=1;i<12;i++)if(mr(Date.UTC(e,i,1,12),t)!==o){o=null;break}r=o,pr.set(n,r)}return r}function gr(t,e){if(!(t.month===1&&t.day<=2||t.month===12&&t.day>=30)){let s=ji(e,t.year);if(s!==null)return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)-s}let r=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second),o=2*r-De(r,e);if(De(o,e)===r)return o;let i=r-De(o,e)+o;return De(i,e)===r?i:o}function Qi(t,e){let n=(t||"").trim(),r=_nullishCoalesce(/^(\d{4})-(\d{2})-(\d{2})$/.exec(n), () => (/^(\d{4})(\d{2})(\d{2})$/.exec(n)));if(!r)return null;let o=/^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec((e||"").trim());return o?{year:+r[1],month:+r[2],day:+r[3],hour:+o[1],minute:+o[2],second:o[3]?+o[3]:0}:null}function Te(t,e){let n=$i(t);return n?gr(n,e):NaN}function pe(t){return Number.isNaN(t)?null:t}function w(t,e){return{timestamp:pe(Te(t,e)),tz:e}}function ne(t,e){let[n,r,o]=t.split("-").map(Number);return new Date(Date.UTC(n,r-1,o+e)).toISOString().slice(0,10)}function wt(t,e,n){let r=Qi(t,e);return r?{timestamp:pe(gr(r,n)),tz:n}:{timestamp:null,tz:n}}function vt(t,e){if(t==null||!Number.isFinite(t))return"";let n=Ft("svDisplay",e).format(new Date(t)),r=n.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/);if(!r)return n;let o=r[2]==="24"?"00":r[2];return`${r[1]} ${o}:${r[3]}`}function K(t,e=Date.now()){return Ft("dateOnly",t).format(new Date(e))}var Ut="https://qt.gtimg.cn",xt="https://web.ifzq.gtimg.cn/appstock/app/minute/query",Kt="https://assets.linkdiary.cn/shares/zh_a_list.json",Bt="https://assets.linkdiary.cn/shares/us_list.json",Ht="https://assets.linkdiary.cn/shares/hk_list.json",it="https://assets.linkdiary.cn/shares/fund_list",qt="https://assets.linkdiary.cn/shares/trade-data-list.txt",st="https://push2his.eastmoney.com/api/qt/stock/kline/get",zt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",at="https://33.push2his.eastmoney.com/api/qt/stock/kline/get",Pe="https://63.push2his.eastmoney.com/api/qt/stock/kline/get",$t="https://33.push2his.eastmoney.com/api/qt/stock/trends2/get",Yt="https://63.push2his.eastmoney.com/api/qt/stock/trends2/get",jt="https://17.push2.eastmoney.com/api/qt/clist/get",Qt="https://91.push2.eastmoney.com/api/qt/stock/get",Gt="https://29.push2.eastmoney.com/api/qt/clist/get",Wt="https://7.push2his.eastmoney.com/api/qt/stock/kline/get",Vt="https://push2his.eastmoney.com/api/qt/stock/trends2/get",Zt="https://79.push2.eastmoney.com/api/qt/clist/get",Xt="https://91.push2.eastmoney.com/api/qt/stock/get",Jt="https://29.push2.eastmoney.com/api/qt/clist/get",en="https://91.push2his.eastmoney.com/api/qt/stock/kline/get",tn="https://push2his.eastmoney.com/api/qt/stock/trends2/get",nn="https://datacenter-web.eastmoney.com/api/data/v1/get",Ie="https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get",rn="https://push2.eastmoney.com/api/qt/clist/get",on="https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get",Se="https://push2ex.eastmoney.com",F="7eea3edcaed734bea9cbfc24409ed989",G="b2884a393a59ad64002292a3e90d46a5",be="https://push2his.eastmoney.com/api/qt/stock/kline/get",sn="https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE",Ne="58b2fa8f54638b60b87d69b31969089c",an={SHFE:113,DCE:114,CZCE:115,INE:142,CFFEX:220,GFEX:225},Re={cu:"SHFE",al:"SHFE",zn:"SHFE",pb:"SHFE",au:"SHFE",ag:"SHFE",rb:"SHFE",wr:"SHFE",fu:"SHFE",ru:"SHFE",bu:"SHFE",hc:"SHFE",ni:"SHFE",sn:"SHFE",sp:"SHFE",ss:"SHFE",ao:"SHFE",br:"SHFE",c:"DCE",a:"DCE",b:"DCE",m:"DCE",y:"DCE",p:"DCE",l:"DCE",v:"DCE",j:"DCE",jm:"DCE",i:"DCE",jd:"DCE",pp:"DCE",cs:"DCE",eg:"DCE",eb:"DCE",pg:"DCE",lh:"DCE",WH:"CZCE",CF:"CZCE",SR:"CZCE",TA:"CZCE",OI:"CZCE",MA:"CZCE",FG:"CZCE",RM:"CZCE",SF:"CZCE",SM:"CZCE",ZC:"CZCE",AP:"CZCE",CJ:"CZCE",UR:"CZCE",SA:"CZCE",PF:"CZCE",PK:"CZCE",PX:"CZCE",SH:"CZCE",sc:"INE",nr:"INE",lu:"INE",bc:"INE",ec:"INE",IF:"CFFEX",IC:"CFFEX",IH:"CFFEX",IM:"CFFEX",TS:"CFFEX",TF:"CFFEX",T:"CFFEX",TL:"CFFEX",si:"GFEX",lc:"GFEX",ps:"GFEX",pt:"GFEX",pd:"GFEX"},ut={HG:101,GC:101,SI:101,QI:101,QO:101,MGC:101,CL:102,NG:102,RB:102,HO:102,PA:102,PL:102,ZW:103,ZM:103,ZS:103,ZC:103,ZL:103,ZR:103,YM:103,NQ:103,ES:103,SB:108,CT:108,LCPT:109,LZNT:109,LALT:109},Me="https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData",ke="https://stock.finance.sina.com.cn/futures/api/jsonp.php/{callback}/FutureOptionAllService.getOptionDayline",un="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName",lt="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay",ln="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline",cn="https://stock.finance.sina.com.cn/futures/api/jsonp_v2.php/{callback}/StockOptionDaylineService.getSymbolInfo",dn="https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine",pn="https://futsseapi.eastmoney.com/list/option/221",mn="https://datacenter-web.eastmoney.com/api/data/get";var ct={au:{product:"au_o",exchange:"shfe"},ag:{product:"ag_o",exchange:"shfe"},cu:{product:"cu_o",exchange:"shfe"},al:{product:"al_o",exchange:"shfe"},zn:{product:"zn_o",exchange:"shfe"},ru:{product:"ru_o",exchange:"shfe"},sc:{product:"sc_o",exchange:"ine"},m:{product:"m_o",exchange:"dce"},c:{product:"c_o",exchange:"dce"},i:{product:"i_o",exchange:"dce"},p:{product:"p_o",exchange:"dce"},pp:{product:"pp_o",exchange:"dce"},l:{product:"l_o",exchange:"dce"},v:{product:"v_o",exchange:"dce"},pg:{product:"pg_o",exchange:"dce"},y:{product:"y_o",exchange:"dce"},a:{product:"a_o",exchange:"dce"},b:{product:"b_o",exchange:"dce"},eg:{product:"eg_o",exchange:"dce"},eb:{product:"eb_o",exchange:"dce"},SR:{product:"SR_o",exchange:"czce"},CF:{product:"CF_o",exchange:"czce"},TA:{product:"TA_o",exchange:"czce"},MA:{product:"MA_o",exchange:"czce"},RM:{product:"RM_o",exchange:"czce"},OI:{product:"OI_o",exchange:"czce"},PK:{product:"PK_o",exchange:"czce"},PF:{product:"PF_o",exchange:"czce"},SA:{product:"SA_o",exchange:"czce"},UR:{product:"UR_o",exchange:"czce"}},gn=3e4,Le=500,Fe=500,we=7,fn=3,yn=1e3,hn=3e4,Tn=2,Sn=[408,429,500,502,503,504];var dt=class{constructor(e={}){this.acquireChain=Promise.resolve();let n=_nullishCoalesce(e.requestsPerSecond, () => (5));this.maxTokens=_nullishCoalesce(e.maxBurst, () => (n)),this.tokens=this.maxTokens,this.refillRate=n/1e3,this.lastRefillTime=Date.now()}refill(){let e=Date.now(),r=(e-this.lastRefillTime)*this.refillRate;this.tokens=Math.min(this.maxTokens,this.tokens+r),this.lastRefillTime=e}tryAcquire(){return this.refill(),this.tokens>=1?(this.tokens-=1,!0):!1}getWaitTime(){if(this.refill(),this.tokens>=1)return 0;let e=1-this.tokens;return Math.ceil(e/this.refillRate)}async acquire(){let e=this.acquireChain,n;this.acquireChain=new Promise(r=>{n=r});try{await e;let r=this.getWaitTime();r>0&&await this.sleep(r),this.refill(),this.tokens-=1}finally{n()}}sleep(e){return new Promise(n=>setTimeout(n,e))}getAvailableTokens(){return this.refill(),this.tokens}};var fr=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"],Rn=0;function Gi(){return typeof window<"u"&&typeof window.document<"u"}function yr(){if(Gi())return;let t=fr[Rn];return Rn=(Rn+1)%fr.length,t}var Ee=class extends _chunk4Q7UQ5Q3cjs.a{constructor(e="Circuit breaker is OPEN"){super({code:"CIRCUIT_OPEN",message:e}),this.name="CircuitBreakerError"}},pt=class{constructor(e={}){this.state="CLOSED";this.failureCount=0;this.lastFailureTime=0;this.halfOpenSuccessCount=0;this.halfOpenProbeStartedAt=[];this.failureThreshold=_nullishCoalesce(e.failureThreshold, () => (5)),this.resetTimeout=_nullishCoalesce(e.resetTimeout, () => (3e4)),this.halfOpenRequests=_nullishCoalesce(e.halfOpenRequests, () => (1)),this.probeRecycleTimeout=_nullishCoalesce(e.probeRecycleTimeout, () => (Math.max(this.resetTimeout*4,12e4))),this.onStateChange=e.onStateChange}getState(){return this.checkStateTransition(),this.state}canRequest(){switch(this.checkStateTransition(),this.state){case"CLOSED":return!0;case"OPEN":return!1;case"HALF_OPEN":{let e=Date.now();for(;this.halfOpenProbeStartedAt.length>0&&e-this.halfOpenProbeStartedAt[0]>=this.probeRecycleTimeout;)this.halfOpenProbeStartedAt.shift();return this.halfOpenProbeStartedAt.length+this.halfOpenSuccessCount>=this.halfOpenRequests?!1:(this.halfOpenProbeStartedAt.push(e),!0)}}}releaseProbe(){this.state==="HALF_OPEN"&&this.halfOpenProbeStartedAt.shift()}recordSuccess(){this.checkStateTransition(),this.state==="HALF_OPEN"?(this.halfOpenProbeStartedAt.shift(),this.halfOpenSuccessCount++,this.halfOpenSuccessCount>=this.halfOpenRequests&&this.transitionTo("CLOSED")):this.state==="CLOSED"&&(this.failureCount=0)}recordFailure(){this.lastFailureTime=Date.now(),this.state==="HALF_OPEN"?(this.halfOpenProbeStartedAt.shift(),this.transitionTo("OPEN")):this.state==="CLOSED"&&(this.failureCount++,this.failureCount>=this.failureThreshold&&this.transitionTo("OPEN"))}checkStateTransition(){this.state==="OPEN"&&Date.now()-this.lastFailureTime>=this.resetTimeout&&this.transitionTo("HALF_OPEN")}transitionTo(e){if(this.state===e)return;let n=this.state;this.state=e,e==="CLOSED"?(this.failureCount=0,this.halfOpenSuccessCount=0,this.halfOpenProbeStartedAt=[]):e==="HALF_OPEN"&&(this.halfOpenSuccessCount=0,this.halfOpenProbeStartedAt=[]),_optionalChain([this, 'access', _2 => _2.onStateChange, 'optionalCall', _3 => _3(n,e)])}reset(){this.transitionTo("CLOSED"),this.failureCount=0,this.halfOpenSuccessCount=0,this.halfOpenProbeStartedAt=[],this.lastFailureTime=0}async execute(e){if(!this.canRequest())throw new Ee;try{let n=await e();return this.recordSuccess(),n}catch(n){throw this.recordFailure(),n}}getStats(){return{state:this.getState(),failureCount:this.failureCount,lastFailureTime:this.lastFailureTime,halfOpenSuccessCount:this.halfOpenSuccessCount}}};var Wi=3e4,Vi=1,hr=["push2his.eastmoney.com","7.push2his.eastmoney.com","33.push2his.eastmoney.com","63.push2his.eastmoney.com","91.push2his.eastmoney.com"],Tr=["17.push2.eastmoney.com","29.push2.eastmoney.com","79.push2.eastmoney.com","91.push2.eastmoney.com"];function Zi(t,e){return e!=="eastmoney"?[t]:t.includes("push2his.eastmoney.com")?hr:t.includes("push2.eastmoney.com")?Tr:[t]}function Xi(t){return Array.from(new Set(t))}var mt=class{constructor(e=Wi,n=Vi){this.cooldownMs=e;this.failureThreshold=n;this.states=new Map}getCandidateUrls(e,n){let r;try{r=new URL(e)}catch (e7){return[e]}let o=Date.now(),i=Zi(r.hostname,n);if(i.length<=1)return[e];let s=i.filter(c=>{let d=this.states.get(c);return!d||d.cooldownUntil<=o}),a=i.filter(c=>{let d=this.states.get(c);return d&&d.cooldownUntil>o});return Xi([...s.includes(r.hostname)?[r.hostname]:[],...s.filter(c=>c!==r.hostname),...a.includes(r.hostname)?[r.hostname]:[],...a.filter(c=>c!==r.hostname)]).map(c=>{let d=new URL(e);return d.hostname=c,d.toString()})}recordSuccess(e){let n=this.safeGetHost(e);if(!n)return;let r=this.getState(n);r.failureCount=0,r.cooldownUntil=0,r.successCount++,r.lastErrorCode=void 0}recordFailure(e,n){let r=this.safeGetHost(e);if(!r)return;let o=this.getState(r);o.failureCount++,o.lastFailureAt=Date.now(),o.lastErrorCode=_chunk4Q7UQ5Q3cjs.k.call(void 0, n),o.failureCount>=this.failureThreshold&&(o.cooldownUntil=Date.now()+this.cooldownMs)}shouldFallback(e){let n=_chunk4Q7UQ5Q3cjs.k.call(void 0, e);return n==="NETWORK_ERROR"||n==="TIMEOUT"||n==="PARSE_ERROR"?!0:e instanceof _chunk4Q7UQ5Q3cjs.b?e.status===408||e.status===429||e.status>=500:!1}getStats(e){let n=Array.from(this.states.values()).map(o=>({...o}));if(!e)return n;if(e!=="eastmoney")return[];let r=new Set([...hr,...Tr]);return n.filter(o=>r.has(o.host))}safeGetHost(e){try{return new URL(e).hostname}catch (e8){return null}}getState(e){let n=this.states.get(e);if(n)return n;let r={host:e,failureCount:0,successCount:0,cooldownUntil:0,lastFailureAt:0};return this.states.set(e,r),r}};function Ji(t){return{maxRetries:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _4 => _4.maxRetries]), () => (fn)),baseDelay:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _5 => _5.baseDelay]), () => (yn)),maxDelay:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _6 => _6.maxDelay]), () => (hn)),backoffMultiplier:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _7 => _7.backoffMultiplier]), () => (Tn)),retryableStatusCodes:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _8 => _8.retryableStatusCodes]), () => (Sn)),retryOnNetworkError:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _9 => _9.retryOnNetworkError]), () => (!0)),retryOnTimeout:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _10 => _10.retryOnTimeout]), () => (!0)),onRetry:_optionalChain([t, 'optionalAccess', _11 => _11.onRetry])}}function es(t,e){let n={..._nullishCoalesce(t, () => ({}))};return e&&(Object.keys(n).some(o=>o.toLowerCase()==="user-agent")||(n["User-Agent"]=e)),n}function Sr(t,e){return e?{timeout:_nullishCoalesce(e.timeout, () => (t.timeout)),retry:e.retry?{..._nullishCoalesce(t.retry, () => ({})),...e.retry}:t.retry?{...t.retry}:void 0,headers:{..._nullishCoalesce(t.headers, () => ({})),..._nullishCoalesce(e.headers, () => ({}))},userAgent:_nullishCoalesce(e.userAgent, () => (t.userAgent)),rateLimit:e.rateLimit?{..._nullishCoalesce(t.rateLimit, () => ({})),...e.rateLimit}:t.rateLimit?{...t.rateLimit}:void 0,rotateUserAgent:_nullishCoalesce(e.rotateUserAgent, () => (t.rotateUserAgent)),circuitBreaker:e.circuitBreaker?{..._nullishCoalesce(t.circuitBreaker, () => ({})),...e.circuitBreaker}:t.circuitBreaker?{...t.circuitBreaker}:void 0}:{...t,headers:{..._nullishCoalesce(t.headers, () => ({}))},retry:t.retry?{...t.retry}:void 0,rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function En(t={}){return{timeout:_nullishCoalesce(t.timeout, () => (gn)),retry:Ji(t.retry),headers:es(t.headers,t.userAgent),rotateUserAgent:_nullishCoalesce(t.rotateUserAgent, () => (!1)),rateLimit:t.rateLimit?{...t.rateLimit}:void 0,circuitBreaker:t.circuitBreaker?{...t.circuitBreaker}:void 0}}function Rr(t,e){if(e)return e;try{let n=new URL(t).hostname;if(n.includes("eastmoney.com"))return"eastmoney";if(n.includes("gtimg.cn"))return"tencent";if(n.includes("sina.com.cn"))return"sina";if(n.includes("linkdiary.cn"))return"linkdiary"}catch (e9){return"unknown"}return"unknown"}function Er(t){if(t instanceof DOMException&&t.name==="AbortError")return!0;if(t instanceof Error){if(t.name==="AbortError")return!0;let e=t.cause;if((e instanceof Error||e instanceof DOMException)&&e.name==="AbortError")return!0}return!1}var _n=()=>{};function ts(t){let e=t.filter(a=>!!a);if(e.length===0)return{signal:void 0,cleanup:_n};if(e.length===1)return{signal:e[0],cleanup:_n};let n=AbortSignal.any;if(typeof n=="function")return{signal:n(e),cleanup:_n};let r=new AbortController,o=a=>{r.signal.aborted||r.abort(a)},i=[];for(let a of e){if(a.aborted){o(a.reason);break}let l=()=>o(a.reason);a.addEventListener("abort",l,{once:!0}),i.push({s:a,handler:l})}let s=()=>{for(let{s:a,handler:l}of i)a.removeEventListener("abort",l)};return{signal:r.signal,cleanup:s}}async function ns(t,e){if(!t)return e;if(Promise.resolve(e).catch(()=>{}),t.aborted)return Promise.race([e,Promise.reject(t.reason)]);let n,r=new Promise((o,i)=>{n=()=>i(t.reason),t.addEventListener("abort",n,{once:!0})});try{return await Promise.race([e,r])}finally{t.removeEventListener("abort",n)}}var ve=class{constructor(e={}){this.baseUrl=_nullishCoalesce(e.baseUrl, () => (Ut));let n={timeout:e.timeout,retry:e.retry,headers:e.headers,userAgent:e.userAgent,rateLimit:e.rateLimit,rotateUserAgent:e.rotateUserAgent,circuitBreaker:e.circuitBreaker};this.defaultPolicy=En(n),this.providerPolicies={},this.runtimeStates=new Map,this.fallbackManager=new mt,this.fetchImpl=e.fetchImpl,this.clientSignal=e.signal,this.hooks=e.hooks;for(let[r,o]of Object.entries(_nullishCoalesce(e.providerPolicies, () => ({})))){let i=Sr(n,o);this.providerPolicies[r]=En(i)}}getProviderState(e){let n=this.runtimeStates.get(e);if(n)return n;let r=_nullishCoalesce(this.providerPolicies[e], () => (this.defaultPolicy)),o={policy:r,rateLimiter:r.rateLimit?new dt(r.rateLimit):null,circuitBreaker:r.circuitBreaker?new pt(r.circuitBreaker):null};return this.runtimeStates.set(e,o),o}getTimeout(){return this.defaultPolicy.timeout}getHostHealth(e){return this.fallbackManager.getStats(e)}safe(e){try{e()}catch (e10){}}toSdkError(e){return e instanceof _chunk4Q7UQ5Q3cjs.a?e:new (0, _chunk4Q7UQ5Q3cjs.a)({code:_nullishCoalesce(_chunk4Q7UQ5Q3cjs.k.call(void 0, e), () => ("NETWORK_ERROR")),message:e.message,provider:e.provider,url:e.url,status:e.status,details:e.details,cause:e})}calculateDelay(e,n){return Math.min(n.baseDelay*Math.pow(n.backoffMultiplier,e),n.maxDelay)+Math.random()*100}sleep(e){return new Promise(n=>setTimeout(n,e))}shouldRetry(e,n,r){if(n>=r.maxRetries)return!1;let o=_chunk4Q7UQ5Q3cjs.k.call(void 0, e);return o==="ABORTED"?!1:o==="TIMEOUT"?r.retryOnTimeout:o==="NETWORK_ERROR"?r.retryOnNetworkError:e instanceof _chunk4Q7UQ5Q3cjs.b?r.retryableStatusCodes.includes(e.status):!1}async executeWithRetry(e,n,r,o=0){try{return await e(o)}catch(i){let s=_chunk4Q7UQ5Q3cjs.l.call(void 0, i,r),a={provider:r.provider,url:r.url,timeout:r.timeout,attempt:o,responseType:r.responseType};if(this.safe(()=>_optionalChain([this, 'access', _12 => _12.hooks, 'optionalAccess', _13 => _13.onError, 'optionalCall', _14 => _14(a,this.toSdkError(s))])),this.safe(()=>_optionalChain([this, 'access', _15 => _15.hooks, 'optionalAccess', _16 => _16.trace, 'optionalCall', _17 => _17("error",a)])),this.shouldRetry(s,o,n)){let l=this.calculateDelay(o,n);return n.onRetry&&n.onRetry(o+1,s,l),this.safe(()=>_optionalChain([this, 'access', _18 => _18.hooks, 'optionalAccess', _19 => _19.onRetry, 'optionalCall', _20 => _20(a,this.toSdkError(s),l)])),this.safe(()=>_optionalChain([this, 'access', _21 => _21.hooks, 'optionalAccess', _22 => _22.trace, 'optionalCall', _23 => _23("retry",a)])),await this.sleep(l),this.executeWithRetry(e,n,r,o+1)}throw s}}async performRequest(e,n,r,o="text",i={},s=0){n.rateLimiter&&await n.rateLimiter.acquire();let a=new AbortController,l=new DOMException(`Request timed out after ${n.policy.timeout}ms`,"AbortError"),c=setTimeout(()=>a.abort(l),n.policy.timeout),{signal:d,cleanup:m}=ts([a.signal,i.signal,this.clientSignal]),p=_nullishCoalesce(_nullishCoalesce(i.fetchImpl, () => (this.fetchImpl)), () => (globalThis.fetch)),g={...n.policy.headers};if(n.policy.rotateUserAgent){let T=yr();if(T){for(let A of Object.keys(g))A.toLowerCase()==="user-agent"&&delete g[A];g["User-Agent"]=T}}let f={provider:r,url:e,timeout:n.policy.timeout,attempt:s,responseType:o};this.safe(()=>_optionalChain([this, 'access', _24 => _24.hooks, 'optionalAccess', _25 => _25.onRequest, 'optionalCall', _26 => _26(f)])),this.safe(()=>_optionalChain([this, 'access', _27 => _27.hooks, 'optionalAccess', _28 => _28.trace, 'optionalCall', _29 => _29("request",f)]));let R=Date.now();try{let T=await ns(d,p(e,{signal:d,headers:g}));if(this.safe(()=>_optionalChain([this, 'access', _30 => _30.hooks, 'optionalAccess', _31 => _31.onResponse, 'optionalCall', _32 => _32(f,{status:T.status,durationMs:Date.now()-R})])),this.safe(()=>_optionalChain([this, 'access', _33 => _33.hooks, 'optionalAccess', _34 => _34.trace, 'optionalCall', _35 => _35("response",f)])),!T.ok)throw new (0, _chunk4Q7UQ5Q3cjs.b)(T.status,T.statusText,e,r);switch(o){case"json":try{return await T.json()}catch(A){throw new (0, _chunk4Q7UQ5Q3cjs.a)({code:"PARSE_ERROR",message:`Failed to parse JSON response from ${e}`,provider:r,url:e,cause:A})}case"arraybuffer":return await T.arrayBuffer();default:return await T.text()}}catch(T){let A=O=>_optionalChain([O, 'optionalAccess', _36 => _36.aborted])?T===O.reason?!0:T instanceof Error&&T.cause===O.reason:!1;if(!A(a.signal)){let O=_optionalChain([i, 'access', _37 => _37.signal, 'optionalAccess', _38 => _38.aborted])||_optionalChain([this, 'access', _39 => _39.clientSignal, 'optionalAccess', _40 => _40.aborted]);if(A(i.signal)||A(this.clientSignal)||O&&Er(T))throw new (0, _chunk4Q7UQ5Q3cjs.h)("Request aborted by external signal",r,e);if(a.signal.aborted&&Er(T))throw l}throw T}finally{clearTimeout(c),m()}}async get(e,n={}){let r=Rr(e,n.provider),o=this.getProviderState(r);if(o.circuitBreaker&&!o.circuitBreaker.canRequest())throw new Ee("Circuit breaker is OPEN, request rejected");let i={fetchImpl:n.fetchImpl,signal:n.signal},s=this.fallbackManager.getCandidateUrls(e,r),a;for(let l=0;l<s.length;l++){let c=s[l],d=l===0?o.policy.retry:{...o.policy.retry,maxRetries:0};try{let m=await this.executeWithRetry(p=>this.performRequest(c,o,r,n.responseType,i,p),d,{provider:r,url:c,timeout:o.policy.timeout,responseType:n.responseType});return _optionalChain([o, 'access', _41 => _41.circuitBreaker, 'optionalAccess', _42 => _42.recordSuccess, 'call', _43 => _43()]),this.fallbackManager.recordSuccess(c),m}catch(m){let p=_chunk4Q7UQ5Q3cjs.l.call(void 0, m,{provider:r,url:c,timeout:o.policy.timeout});a=p;let g=_chunk4Q7UQ5Q3cjs.k.call(void 0, p)==="ABORTED";if(g?_optionalChain([o, 'access', _44 => _44.circuitBreaker, 'optionalAccess', _45 => _45.releaseProbe, 'call', _46 => _46()]):this.fallbackManager.recordFailure(c,p),l<s.length-1&&this.fallbackManager.shouldFallback(p)){this.safe(()=>_optionalChain([this, 'access', _47 => _47.hooks, 'optionalAccess', _48 => _48.trace, 'optionalCall', _49 => _49("fallback",{provider:r,url:c,timeout:o.policy.timeout,attempt:0,responseType:n.responseType})]));continue}throw g||_optionalChain([o, 'access', _50 => _50.circuitBreaker, 'optionalAccess', _51 => _51.recordFailure, 'call', _52 => _52()]),this.toSdkError(p)}}throw _optionalChain([o, 'access', _53 => _53.circuitBreaker, 'optionalAccess', _54 => _54.recordFailure, 'call', _55 => _55()]),a?this.toSdkError(a):new Ee("Request failed without a concrete error")}async getTencentQuote(e){let n=`${this.baseUrl}/?q=${encodeURIComponent(e)}`,r=await this.get(n,{responseType:"arraybuffer",provider:"tencent"}),o=bt(r);return Nt(o)}};var B=(t,e)=>t*60+e,rs={A:{tz:C.CN,open:[[B(9,30),B(11,30)],[B(13,0),B(15,0)]],lunchBreak:[B(11,30),B(13,0)],tradingWeekdays:[1,2,3,4,5]},HK:{tz:C.HK,open:[[B(9,30),B(12,0)],[B(13,0),B(16,0)]],lunchBreak:[B(12,0),B(13,0)],tradingWeekdays:[1,2,3,4,5]},US:{tz:C.US,open:[[B(9,30),B(16,0)]],tradingWeekdays:[1,2,3,4,5]}};function Cn(t,e){if(t==null)return K(e);if(t instanceof Date)return K(e,t.getTime());let n=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(n))return n;if(/^\d{8}$/.test(n))return`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`;let r=new Date(n);if(!Number.isNaN(r.getTime()))return K(e,r.getTime());throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Unsupported date input: ${JSON.stringify(t)}. Expected 'YYYY-MM-DD', 'YYYYMMDD', or Date.`)}function os(t,e){let n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,weekday:"short",hour:"2-digit",minute:"2-digit"}),r={};for(let l of n.formatToParts(t))l.type!=="literal"&&(r[l.type]=l.value);let o=parseInt(_nullishCoalesce(r.hour, () => ("0")),10);o===24&&(o=0);let i=parseInt(_nullishCoalesce(r.minute, () => ("0")),10),a=_nullishCoalesce({Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6,Sun:7}[_nullishCoalesce(r.weekday, () => (""))], () => (0));return{minutes:o*60+i,weekday:a}}function An(t,e){let n=0,r=t.length;for(;n<r;){let o=n+r>>>1;t[o]<e?n=o+1:r=o}return n}var Ue=class{constructor(e){this.quoteService=e}async isTradingDay(e){let n=Cn(e,C.CN),r=await this.quoteService.getTradingCalendar(),o=An(r,n);return o<r.length&&r[o]===n}async nextTradingDay(e){let n=Cn(e,C.CN),r=await this.quoteService.getTradingCalendar(),o=An(r,n);if(o<r.length&&r[o]===n&&(o+=1),o>=r.length)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`nextTradingDay: ${n} \u4E4B\u540E\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5927\u65E5\u671F ${_nullishCoalesce(r[r.length-1], () => ("N/A"))})`);return r[o]}async prevTradingDay(e){let n=Cn(e,C.CN),r=await this.quoteService.getTradingCalendar(),i=An(r,n)-1;if(i<0)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`prevTradingDay: ${n} \u4E4B\u524D\u6CA1\u6709\u53EF\u7528\u4EA4\u6613\u65E5 (\u65E5\u5386\u6700\u5C0F\u65E5\u671F ${_nullishCoalesce(r[0], () => ("N/A"))})`);return r[i]}getMarketStatus(e="A",n=new Date){let r=rs[e],{minutes:o,weekday:i}=os(n,r.tz);if(!r.tradingWeekdays.includes(i))return"closed";let s=r.open[0][0],a=r.open[r.open.length-1][1];if(o<s)return"pre_market";if(o>=a)return"after_hours";for(let[l,c]of r.open)if(o>=l&&o<c)return"open";return r.lunchBreak&&o>=r.lunchBreak[0]&&o<r.lunchBreak[1]?"lunch_break":"closed"}};var M={};_chunk4VDLQK6Fcjs.a.call(void 0, M,{FULL_QUOTE_MIN_FIELDS:()=>On,FUND_FLOW_MIN_FIELDS:()=>Nn,FUND_QUOTE_MIN_FIELDS:()=>bn,HK_QUOTE_MIN_FIELDS:()=>Pn,PANEL_LARGE_ORDER_MIN_FIELDS:()=>Mn,SIMPLE_QUOTE_MIN_FIELDS:()=>Dn,US_QUOTE_MIN_FIELDS:()=>In,filterTencentRows:()=>q,getAShareCodeList:()=>br,getAllHKQuotesByCodes:()=>kr,getAllQuotesByCodes:()=>Mr,getAllUSQuotesByCodes:()=>Lr,getFullQuotes:()=>gt,getFundCodeList:()=>Fr,getFundFlow:()=>Ar,getFundQuotes:()=>Dr,getHKCodeList:()=>Nr,getHKQuotes:()=>ft,getPanelLargeOrder:()=>Or,getSimpleQuotes:()=>Cr,getTodayTimeline:()=>Pr,getTradingCalendar:()=>wr,getUSCodeList:()=>ht,getUSQuotes:()=>yt,parseFullQuote:()=>kn,parseFundFlow:()=>Fn,parseFundQuote:()=>xn,parseHKQuote:()=>vn,parsePanelLargeOrder:()=>wn,parseSimpleQuote:()=>Ln,parseUSQuote:()=>Un,search:()=>Ur});function _r(t,e){let n=t.replace(/^\./,""),r=n?_chunkUSZUOBM2cjs.d.call(void 0, n):void 0;return r&&r.market===e?{code:r.code,assetType:"index"}:{code:t,assetType:"stock"}}var On=38,Dn=8,Pn=38,In=38,bn=9,Nn=14,Mn=4;function q(t,e,n){return t.filter(r=>e.has(r.key)&&r.fields&&r.fields.length>=n&&r.fields[0]!=="")}function kn(t){let e=[];for(let i=0;i<5;i++)e.push({price:S(t[9+i*2]),volume:S(t[10+i*2])});let n=[];for(let i=0;i<5;i++)n.push({price:S(t[19+i*2]),volume:S(t[20+i*2])});let r=_nullishCoalesce(t[30], () => ("")),o=w(r,C.CN);return{marketId:_nullishCoalesce(t[0], () => ("")),name:_nullishCoalesce(t[1], () => ("")),code:_nullishCoalesce(t[2], () => ("")),price:S(t[3]),prevClose:S(t[4]),open:S(t[5]),volume:S(t[6]),outerVolume:S(t[7]),innerVolume:S(t[8]),bid:e,ask:n,time:r,timestamp:o.timestamp,tz:o.tz,change:S(t[31]),changePercent:S(t[32]),high:S(t[33]),low:S(t[34]),volume2:S(t[36]),amount:S(t[37]),turnoverRate:D(t[38]),pe:D(t[39]),amplitude:D(t[43]),circulatingMarketCap:D(t[44]),totalMarketCap:D(t[45]),pb:D(t[46]),limitUp:D(t[47]),limitDown:D(t[48]),volumeRatio:D(t[49]),avgPrice:D(t[51]),peStatic:D(t[52]),peDynamic:D(t[53]),high52w:D(t[67]),low52w:D(t[68]),circulatingShares:D(t[72]),totalShares:D(t[73]),market:"CN",assetType:"stock",source:"tencent"}}function Ln(t){return{marketId:_nullishCoalesce(t[0], () => ("")),name:_nullishCoalesce(t[1], () => ("")),code:_nullishCoalesce(t[2], () => ("")),price:S(t[3]),change:S(t[4]),changePercent:S(t[5]),volume:S(t[6]),amount:S(t[7]),marketCap:D(t[9]),marketType:_nullishCoalesce(t[10], () => ("")),market:"CN",assetType:"stock",source:"tencent"}}function Fn(t){let e=_nullishCoalesce(t[13], () => ("")),n=w(e,C.CN);return{code:_nullishCoalesce(t[0], () => ("")),mainInflow:S(t[1]),mainOutflow:S(t[2]),mainNet:S(t[3]),mainNetRatio:S(t[4]),retailInflow:S(t[5]),retailOutflow:S(t[6]),retailNet:S(t[7]),retailNetRatio:S(t[8]),totalFlow:S(t[9]),name:_nullishCoalesce(t[12], () => ("")),date:e,timestamp:n.timestamp,tz:n.tz}}function wn(t){return{buyLargeRatio:S(t[0]),buySmallRatio:S(t[1]),sellLargeRatio:S(t[2]),sellSmallRatio:S(t[3])}}function vn(t){let e=_nullishCoalesce(t[30], () => ("")),n=w(e,C.HK),r=_r(_nullishCoalesce(t[2], () => ("")),"HK");return{marketId:_nullishCoalesce(t[0], () => ("")),name:_nullishCoalesce(t[1], () => ("")),code:r.code,price:S(t[3]),prevClose:S(t[4]),open:S(t[5]),volume:S(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:S(t[31]),changePercent:S(t[32]),high:S(t[33]),low:S(t[34]),amount:S(t[37]),lotSize:D(t[40]),circulatingMarketCap:D(t[44]),totalMarketCap:D(t[45]),currency:/^[A-Z]{3}$/.test(_nullishCoalesce(t[t.length-3], () => ("")))?t[t.length-3]:"",market:"HK",assetType:r.assetType,source:"tencent"}}function Un(t){let e=_nullishCoalesce(t[30], () => ("")),n=w(e,C.US),r=_r(_nullishCoalesce(t[2], () => ("")),"US");return{marketId:_nullishCoalesce(t[0], () => ("")),name:_nullishCoalesce(t[1], () => ("")),code:r.code,price:S(t[3]),prevClose:S(t[4]),open:S(t[5]),volume:S(t[6]),time:e,timestamp:n.timestamp,tz:n.tz,change:S(t[31]),changePercent:S(t[32]),high:S(t[33]),low:S(t[34]),amount:S(t[37]),turnoverRate:D(t[38]),pe:D(t[39]),amplitude:D(t[43]),totalMarketCap:D(t[45]),pb:D(t[47]),high52w:D(t[48]),low52w:D(t[49]),market:"US",assetType:r.assetType,source:"tencent"}}function xn(t){let e=_nullishCoalesce(t[8], () => ("")),n=w(e,C.CN);return{code:_nullishCoalesce(t[0], () => ("")),name:_nullishCoalesce(t[1], () => ("")),nav:S(t[5]),accNav:S(t[6]),change:S(t[7]),navDate:e,timestamp:n.timestamp,tz:n.tz,market:"CN",assetType:"fund",source:"tencent"}}async function gt(t,e){if(!e||e.length===0)return[];let{keys:n}=_chunkUSZUOBM2cjs.l.call(void 0, e,"CN");if(n.length===0)return[];let r=await t.getTencentQuote(n.join(",")),o=new Set(n);return q(r,o,On).map(i=>kn(i.fields))}async function Cr(t,e){if(!e||e.length===0)return[];let{keys:n}=_chunkUSZUOBM2cjs.l.call(void 0, e,"CN");if(n.length===0)return[];let r=n.map(s=>`s_${s}`),o=await t.getTencentQuote(r.join(",")),i=new Set(r);return q(o,i,Dn).map(s=>Ln(s.fields))}async function Ar(t,e){if(!e||e.length===0)return[];let{keys:n}=_chunkUSZUOBM2cjs.l.call(void 0, e,"CN");if(n.length===0)return[];let r=n.map(s=>`ff_${s}`),o=await t.getTencentQuote(r.join(",")),i=new Set(r);return q(o,i,Nn).map(s=>Fn(s.fields))}async function Or(t,e){if(!e||e.length===0)return[];let{keys:n}=_chunkUSZUOBM2cjs.l.call(void 0, e,"CN");if(n.length===0)return[];let r=n.map(s=>`s_pk${s}`),o=await t.getTencentQuote(r.join(",")),i=new Set(r);return q(o,i,Mn).map(s=>wn(s.fields))}async function ft(t,e){if(!e||e.length===0)return[];let{keys:n}=_chunkUSZUOBM2cjs.l.call(void 0, e,"HK");if(n.length===0)return[];let r=await t.getTencentQuote(n.join(",")),o=new Set(n);return q(r,o,Pn).map(i=>vn(i.fields))}async function yt(t,e){if(!e||e.length===0)return[];let{keys:n}=_chunkUSZUOBM2cjs.l.call(void 0, e,"US");if(n.length===0)return[];let r=await t.getTencentQuote(n.join(",")),o=new Set(n);return q(r,o,In).map(i=>Un(i.fields))}async function Dr(t,e){if(!e||e.length===0)return[];let n=e.map(i=>`jj${i}`),r=await t.getTencentQuote(n.join(",")),o=new Set(n);return q(r,o,bn).map(i=>xn(i.fields))}async function Pr(t,e){let n=`${xt}?code=${encodeURIComponent(e)}`,r=await t.get(n,{responseType:"json",provider:"tencent"});if(r.code!==0)throw new (0, _chunk4Q7UQ5Q3cjs.g)(r.msg||"API error","tencent",n);let o=_optionalChain([r, 'access', _56 => _56.data, 'optionalAccess', _57 => _57[e]]);if(!o){let p=w("",C.CN);return{code:e,date:"",timestamp:p.timestamp,tz:p.tz,preClose:0,data:[]}}let i=_nullishCoalesce(_optionalChain([o, 'access', _58 => _58.data, 'optionalAccess', _59 => _59.data]), () => ([])),s=_nullishCoalesce(_optionalChain([o, 'access', _60 => _60.data, 'optionalAccess', _61 => _61.date]), () => ("")),a=_nullishCoalesce(_optionalChain([o, 'access', _62 => _62.qt, 'optionalAccess', _63 => _63[e]]), () => ([])),l=parseFloat(_nullishCoalesce(a[4], () => ("")))||0,c=!1;for(let p of i){let g=p.split(" "),f=parseFloat(g[1])||0,R=parseInt(g[2],10)||0,T=parseFloat(g[3])||0;if(R>0&&f>0){T/R>f*50&&(c=!0);break}}let d=i.map(p=>{let g=p.split(" "),f=g[0],R=`${f.slice(0,2)}:${f.slice(2,4)}`,T=parseInt(g[2],10)||0,A=parseFloat(g[3])||0,O=c?T*100:T,L=O>0?A/O:0,re=wt(s,R,C.CN);return{time:R,timestamp:re.timestamp,tz:re.tz,price:parseFloat(g[1])||0,volume:O,amount:A,avgPrice:Math.round(L*100)/100}}),m=w(s,C.CN);return{code:e,date:s,timestamp:m.timestamp,tz:m.tz,preClose:l,data:d}}var Ir={defaultTTL:360*60*1e3,maxSize:16};async function Kn(t,e,n){return _chunk6MCPZDKNcjs.e.call(void 0, t,"tencent:code-lists",Ir).getOrFetch(e,async()=>{let o=await t.get(n,{responseType:"json"}),i=_optionalChain([o, 'optionalAccess', _64 => _64.list]);if(_optionalChain([o, 'optionalAccess', _65 => _65.success])===!1||!Array.isArray(i)||i.length===0)throw new (0, _chunk4Q7UQ5Q3cjs.c)(`\u4EE3\u7801\u5217\u8868\u63A5\u53E3\u8FD4\u56DE\u7A7A\u6570\u636E: ${e}`,"tencent",n);return i})}function is(t,e){let n=t.replace(/^(sh|sz|bj)/,"");switch(e){case"sh":return n.startsWith("6");case"sz":return n.startsWith("0")||n.startsWith("3");case"bj":return n.startsWith("4")||n.startsWith("8")||n.startsWith("92");case"kc":return n.startsWith("688");case"cy":return n.startsWith("30");default:return!0}}async function br(t,e){let n=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _66 => _66.simple]), () => (!1)),r=_optionalChain([e, 'optionalAccess', _67 => _67.market]),i=await Kn(t,"a-share:full",Kt);return r&&(i=i.filter(s=>is(s,r))),n?i.map(s=>s.replace(/^(sh|sz|bj)/,"")):i.slice()}async function ht(t,e){let n=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _68 => _68.simple]), () => (!1)),r=_optionalChain([e, 'optionalAccess', _69 => _69.market]),i=(await Kn(t,"us:full",Bt)).slice();if(r){let s=`${_chunkUSZUOBM2cjs.h[r]}.`;i=i.filter(a=>a.startsWith(s))}return n?i.map(s=>s.replace(/^\d{3}\./,"")):i}async function Nr(t){return(await Kn(t,"hk:full",Ht)).slice()}async function Mr(t,e,n={}){let{batchSize:r=Le,concurrency:o=we,onProgress:i}=n;te(r,"batchSize"),te(o,"concurrency");let s=Math.min(r,Fe),a=Ae(e,s),l=a.length,c=0,d=a.map(p=>async()=>{let g=await gt(t,p);return c++,i&&i(c,l),g});return(await se(d,o,!0)).flat()}async function kr(t,e,n={}){let{batchSize:r=Le,concurrency:o=we,onProgress:i}=n;te(r,"batchSize"),te(o,"concurrency");let s=Math.min(r,Fe),a=Ae(e,s),l=a.length,c=0,d=a.map(p=>async()=>{let g=await ft(t,p);return c++,i&&i(c,l),g});return(await se(d,o,!0)).flat()}async function Lr(t,e,n={}){let{batchSize:r=Le,concurrency:o=we,onProgress:i}=n;te(r,"batchSize"),te(o,"concurrency");let s=Math.min(r,Fe),a=Ae(e,s),l=a.length,c=0,d=a.map(p=>async()=>{let g=await yt(t,p);return c++,i&&i(c,l),g});return(await se(d,o,!0)).flat()}async function Fr(t){return(await _chunk6MCPZDKNcjs.e.call(void 0, t,"tencent:code-lists",Ir).getOrFetch("fund:full",async()=>{let i=(await _asyncNullishCoalesce(await t.get(it,{responseType:"text"}), async () => (""))).split(",").slice(1).filter(s=>s.trim());if(i.length===0)throw new (0, _chunk4Q7UQ5Q3cjs.c)("\u57FA\u91D1\u4EE3\u7801\u5217\u8868\u63A5\u53E3\u8FD4\u56DE\u7A7A\u6570\u636E","tencent",it);return i})).slice()}var ss={defaultTTL:720*60*1e3,maxSize:4};async function wr(t){return(await _chunk6MCPZDKNcjs.e.call(void 0, t,"tencent:trade-calendar",ss).getOrFetch("a-share",async()=>{let o=(await _asyncNullishCoalesce(await t.get(qt), async () => (""))).trim().split(",").map(i=>i.trim()).filter(i=>i.length>0);if(o.length===0)throw new (0, _chunk4Q7UQ5Q3cjs.c)("\u4EA4\u6613\u65E5\u5386\u63A5\u53E3\u8FD4\u56DE\u7A7A\u6570\u636E","tencent",qt);return o})).slice()}var vr="https://smartbox.gtimg.cn/s3/",as="jsVars:v_hint";function us(t){return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function ls(t){let e=t.toUpperCase();return e.startsWith("QDII")||e.startsWith("ETF")||e.startsWith("LOF")||e.startsWith("KJ")||e.startsWith("JJ")||e.includes("FUND")?"fund":e.startsWith("GP")||e.includes("STOCK")?"stock":e==="ZS"||e.includes("INDEX")?"index":e.startsWith("ZQ")||e.includes("BOND")?"bond":e.startsWith("QH")||e.includes("FUTURE")?"futures":e.startsWith("QZ")||e.includes("OPTION")?"option":"other"}function cs(t){return!t||t==="N"?[]:t.split("^").filter(Boolean).map(n=>{let r=n.split("~"),o=r[0]||"",i=r[1]||"",s=us(r[2]||""),a=r[4]||"";return{code:o+i,name:s,market:o,type:a,category:ls(a)}})}async function ds(t){let e=`${vr}?v=2&t=all&q=${encodeURIComponent(t)}`,n=await ce(e,["v_hint"],{mutexKey:as});return typeof n.v_hint=="string"?n.v_hint:""}async function ps(t,e){let n=`${vr}?v=2&t=all&q=${encodeURIComponent(e)}`,o=(await t.get(n)).match(/v_hint="([^"]*)"/);return o?o[1]:""}function ms(){return typeof window<"u"&&typeof document<"u"}async function Ur(t,e){if(!e||!e.trim())return[];let n;return ms()?n=await ds(e):n=await ps(t,e),cs(n)}var y={};_chunk4VDLQK6Fcjs.a.call(void 0, y,{assertCnStockSymbol:()=>Xn,extractVariety:()=>Gn,fetchDatacenter:()=>qn,fetchDatacenterList:()=>P,getBlockTradeDailyStat:()=>ci,getBlockTradeDetail:()=>li,getBlockTradeMarketStat:()=>ui,getBoardChanges:()=>ei,getCFFEXOptionQuotes:()=>Oo,getComexInventory:()=>No,getConceptConstituents:()=>lo,getConceptKline:()=>co,getConceptList:()=>ao,getConceptMinuteKline:()=>po,getConceptSpot:()=>uo,getDividendDetail:()=>mo,getDragonTigerBranchRank:()=>ii,getDragonTigerDetail:()=>ni,getDragonTigerInstitution:()=>oi,getDragonTigerStockSeatDetail:()=>si,getDragonTigerStockStats:()=>ri,getFundDividendList:()=>go,getFundEstimate:()=>yo,getFundFlowRank:()=>Uo,getFundNavHistory:()=>fo,getFundProfile:()=>Ro,getFundRankHistory:()=>ho,getFuturesHistoryKline:()=>_o,getFuturesInventory:()=>bo,getFuturesInventorySymbols:()=>Io,getFuturesMarketCode:()=>Wn,getGlobalFuturesKline:()=>Ao,getGlobalFuturesSpot:()=>Co,getHKHistoryKline:()=>qr,getHKMinuteKline:()=>zr,getHistoryKline:()=>Br,getHotThemes:()=>gi,getIndividualFundFlow:()=>wo,getIndividualStockChanges:()=>Jo,getIndustryConstituents:()=>oo,getIndustryKline:()=>io,getIndustryList:()=>no,getIndustryMinuteKline:()=>so,getIndustrySpot:()=>ro,getMarginAccountInfo:()=>di,getMarginTargetList:()=>pi,getMarketFundFlow:()=>vo,getMinuteKline:()=>Hr,getNorthboundFlowSummary:()=>qo,getNorthboundHistory:()=>$o,getNorthboundHoldingRank:()=>zo,getNorthboundIndividual:()=>Yo,getNorthboundMinute:()=>Ho,getOptionLHB:()=>Do,getSectorFundFlowHistory:()=>Ko,getSectorFundFlowRank:()=>xo,getStockChanges:()=>Xo,getThemeFunds:()=>fi,getThemeList:()=>mi,getUSHistoryKline:()=>Qr,getUSMinuteKline:()=>Gr,getZTPool:()=>Zo});async function xe(t,e,n,r){let o=[],i=Number.isFinite(n)?Math.max(1,Math.floor(n)):1;for(let s=t;s<=e;s+=i){let a=[];for(let c=s;c<=Math.min(s+i-1,e);c++)a.push(c);let l=await se(a.map(c=>()=>r(c)),i,!0);for(let c of l)if(c===null||(o.push(c.value),c.terminal))return o}return o}function b(t){return/^\d{8}$/.test(t)?`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`:t}function xr(t,e){let n=i=>b(i.replace("T"," ").trim()).slice(0,16),r=n(t),o=n(e);return o.length===10&&(o+=" 23:59"),{start:r,end:o}}function Kr(t,e,n=0){let r=s=>{if(!s)return;let a=/^(\d{4})-?(\d{2})-?(\d{2})/.exec(s.trim());return a?`${a[1]}${a[2]}${a[3]}`:void 0},o=_nullishCoalesce(r(t), () => ("0")),i=r(e);return i!==void 0&&n>0&&(i=ne(`${i.slice(0,4)}-${i.slice(4,6)}-${i.slice(6,8)}`,n).replace(/-/g,"")),{beg:o,end:_nullishCoalesce(i, () => ("20500000"))}}async function Bn(t,e,n,r,o=100,i){let s=async f=>{let R=new URLSearchParams({...n,pn:String(f),pz:String(o),fields:r}),T=`${e}?${R.toString()}`,O=await _asyncOptionalChain([(await t.get(T,{responseType:"json"})), 'optionalAccess', async _70 => _70.data]);return!O||!Array.isArray(O.diff)?null:{total:O.total,diff:O.diff}},a=[],l=await s(1);if(!l||l.diff.length===0)return a;let c=_nullishCoalesce(l.total, () => (0)),d=f=>{a.push(...f.map((R,T)=>i(R,a.length+T+1)))};d(l.diff);let m=o>0?Math.ceil(c/o):1;if(m<=1||a.length>=c)return a;let p=await xe(2,m,3,async f=>{let R=await s(f);return!R||R.diff.length===0?null:{value:R.diff}});for(let f of p)d(f);if(p.length===m-1){let f=m+1;for(;a.length<c;){let R=await s(f);if(!R||R.diff.length===0)break;d(R.diff),f++}}return a}function $(t){let[e,n,r,o,i,s,a,l,c,d,m]=t.split(",");return{date:e,open:h(n),close:h(r),high:h(o),low:h(i),volume:h(s),amount:h(a),amplitude:h(l),changePercent:h(c),change:h(d),turnoverRate:h(m)}}async function H(t,e,n){let r=`${e}?${n.toString()}`,o=await t.get(r,{responseType:"json"});return{klines:_optionalChain([o, 'optionalAccess', _71 => _71.data, 'optionalAccess', _72 => _72.klines])||[],name:_optionalChain([o, 'optionalAccess', _73 => _73.data, 'optionalAccess', _74 => _74.name]),code:_optionalChain([o, 'optionalAccess', _75 => _75.data, 'optionalAccess', _76 => _76.code])}}function gs(t){let[e,n,r,o,i,s,a,l]=t.split(",");return{time:e,open:h(n),close:h(r),high:h(o),low:h(i),volume:h(s),amount:h(a),avgPrice:h(l)}}function Tt(t,e){let n=r=>{let o=Te(r,C.CN);return{time:vt(o,t)||r,timestamp:pe(o)}};return{mapTrendRow:({time:r,...o},i)=>({...n(r),tz:t,...o,currency:e,code:i.code}),mapKlineRow:({date:r,...o},i)=>({...n(r),tz:t,...o,currency:e,code:i.code})}}function de(t){return async function(n,r,o={}){let i=_nullishCoalesce(o.period, () => (t.defaultPeriod));kt(i),t.fqt==="option"&&ie(_nullishCoalesce(o.adjust, () => ("qfq")));let s=t.resolveTarget(r),a=t.window,l=p=>{if(a.mode==="full")return p;let{start:g,end:f}=xr(_nullishCoalesce(o.startDate, () => ("1979-09-01 09:32:00")),_nullishCoalesce(o.endDate, () => ("2222-01-01 09:32:00")));return p.filter(R=>R.time>=g&&R.time<=f)};if(i==="1"){let p=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",fields2:"f51,f52,f53,f54,f55,f56,f57,f58",...t.includeUt?{ut:F}:{},ndays:t.ndays==="option"?String(_nullishCoalesce(o.ndays, () => (1))):t.ndays.fixed,iscr:"0",secid:s.secid}),g=`${t.trendsUrl}?${p.toString()}`,R=await _asyncOptionalChain([(await n.get(g,{responseType:"json"})), 'optionalAccess', async _77 => _77.data, 'optionalAccess', async _78 => _78.trends]);return!Array.isArray(R)||R.length===0?[]:l(R.map(T=>t.mapTrendRow(gs(T),s)))}let c=a.mode==="filter"?Kr(o.startDate,o.endDate,_nullishCoalesce(a.endExtraDays, () => (0))):{beg:a.beg,end:a.end},d=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",...t.includeUt?{ut:F}:{},klt:i,fqt:t.fqt==="option"?ae(_nullishCoalesce(o.adjust, () => ("qfq"))):t.fqt.fixed,secid:s.secid,beg:c.beg,end:c.end,..._nullishCoalesce(t.extraKlineParams, () => ({}))}),{klines:m}=await H(n,t.klineUrl,d);return!Array.isArray(m)||m.length===0?[]:l(m.map(p=>t.mapKlineRow($(p),s)))}}async function Br(t,e,n={}){let{period:r="daily",adjust:o="qfq",startDate:i="19700101",endDate:s="20500101"}=n;j(r),ie(o);let a=_chunkUSZUOBM2cjs.f.call(void 0, e,{market:"CN"}),l=_chunkUSZUOBM2cjs.j.call(void 0, a),c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f116",ut:F,klt:Q(r),fqt:ae(o),secid:l,beg:i,end:s}),d=st,{klines:m}=await H(t,d,c);return m.length===0?[]:m.map(p=>{let g=$(p),f=w(g.date,C.CN);return{...g,timestamp:f.timestamp,tz:f.tz,code:a.code}})}var fs=de({trendsUrl:zt,klineUrl:st,resolveTarget:t=>{let e=_chunkUSZUOBM2cjs.f.call(void 0, t,{market:"CN"});return{secid:_chunkUSZUOBM2cjs.j.call(void 0, e),code:e.code}},defaultPeriod:"1",ndays:{fixed:"5"},fqt:"option",includeUt:!0,window:{mode:"filter"},mapTrendRow:({time:t,...e})=>{let n=w(t,C.CN);return{time:t,timestamp:n.timestamp,tz:n.tz,...e}},mapKlineRow:t=>{let e=w(t.date,C.CN);return{...t,time:t.date,timestamp:e.timestamp,tz:e.tz}}});async function Hr(t,e,n={}){return fs(t,e,n)}function Hn(t,e){return new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",ut:F,klt:e.klt,fqt:e.fqt,secid:t,beg:_nullishCoalesce(e.beg, () => ("19700101")),end:_nullishCoalesce(e.end, () => ("20500101")),lmt:e.lmt})}function St(t){return async function(n,r,o={}){let{period:i="daily",adjust:s="qfq",startDate:a="19700101",endDate:l="20500101"}=o;j(i),ie(s);let c=t.normalizeSymbol(r),d=Hn(c.secid,{klt:Q(i),fqt:ae(s),lmt:"1000000",beg:a,end:l}),{klines:m,name:p,code:g}=await H(n,t.url,d);if(m.length===0)return[];let f=t.resolveResultMeta?t.resolveResultMeta(r,c,{code:g,name:p}):{code:g||c.fallbackCode,name:p||""};return m.map(R=>{let T=$(R),A=w(T.date,t.tz),O={...T,timestamp:A.timestamp,tz:A.tz,code:f.code,name:f.name};return t.enrichItem(O)})}}var ys=St({url:at,tz:C.HK,normalizeSymbol:t=>{let e=_chunkUSZUOBM2cjs.f.call(void 0, t,{market:"HK"});return{secid:_chunkUSZUOBM2cjs.j.call(void 0, e),fallbackCode:e.code}},enrichItem:t=>({...t,currency:"HKD",lotSize:null})});async function qr(t,e,n={}){return ys(t,e,n)}var hs=de({trendsUrl:$t,klineUrl:at,resolveTarget:t=>{let e=_chunkUSZUOBM2cjs.f.call(void 0, t,{market:"HK"});return{secid:_chunkUSZUOBM2cjs.j.call(void 0, e),code:e.code}},defaultPeriod:"1",ndays:"option",fqt:"option",includeUt:!0,window:{mode:"filter"},...Tt(C.HK,"HKD")});async function zr(t,e,n={}){return hs(t,e,n)}var $r="__NOT_FOUND__",Ts=10080*60*1e3,Ss=3600*1e3,Rs=[_chunkUSZUOBM2cjs.h.NASDAQ,_chunkUSZUOBM2cjs.h.NYSE,_chunkUSZUOBM2cjs.h.AMEX];function Es(t){return _chunk6MCPZDKNcjs.e.call(void 0, t,"eastmoney:us-secid",{maxSize:4096})}async function Yr(t,e){if(/^\d{2,3}\./.test(e))return e;let n=_chunkUSZUOBM2cjs.f.call(void 0, e,{market:"US"});if(n.assetType==="index")return _chunkUSZUOBM2cjs.j.call(void 0, n);let r=n.code,o=Es(t);if(o.get(r)===$r)throw new (0, _chunk4Q7UQ5Q3cjs.d)(`\u7F8E\u80A1\u4EE3\u7801\u4E0D\u5B58\u5728\u6216\u4E0D\u652F\u6301: ${r}`,"eastmoney");return o.getOrFetch(r,()=>_s(t,r,o),Ts)}async function _s(t,e,n){let r=!1;try{let o=await ht(t);r=!0;let i=o.find(s=>s.slice(s.indexOf(".")+1)===e);if(i)return i}catch (e11){}for(let o of Rs){let i=`${o}.${e}`;if((await H(t,Pe,Hn(i,{klt:"101",fqt:"0",lmt:"1"}))).klines.length>0)return i}throw r&&n.set(e,$r,Ss),new (0, _chunk4Q7UQ5Q3cjs.d)(`\u7F8E\u80A1\u4EE3\u7801\u4E0D\u5B58\u5728\u6216\u4E0D\u652F\u6301: ${e}`,"eastmoney")}function jr(t,e){return _nullishCoalesce(_optionalChain([_chunkUSZUOBM2cjs.e.call(void 0, t), 'optionalAccess', _79 => _79.code]), () => (e))}var Cs=St({url:Pe,tz:C.US,normalizeSymbol:t=>({secid:t,fallbackCode:t.split(".")[1]||t}),resolveResultMeta:(t,e,n)=>({code:jr(e.secid,n.code||e.fallbackCode),name:n.name||""}),enrichItem:t=>({...t,currency:"USD"})});async function Qr(t,e,n={}){let r=await Yr(t,e);return Cs(t,r,n)}var As=de({trendsUrl:Yt,klineUrl:Pe,resolveTarget:t=>({secid:t,code:jr(t,t.split(".")[1]||t)}),defaultPeriod:"1",ndays:"option",fqt:"option",includeUt:!0,window:{mode:"filter",endExtraDays:1},...Tt(C.US,"USD")});async function Gr(t,e,n={}){let r=await Yr(t,e);return As(t,r,n)}var Os={defaultTTL:3600*1e3,maxSize:4};function Vr(t){return{async getCode(e,n,r){if(n.startsWith("BK"))return n;let s=(await _chunk6MCPZDKNcjs.e.call(void 0, e,`eastmoney:board-code-map:${t.type}`,Os).getOrFetch("name-code-map",async()=>{let a=await r(e);if(a.length===0)throw new (0, _chunk4Q7UQ5Q3cjs.c)(`${t.errorPrefix}: \u677F\u5757\u5217\u8868\u63A5\u53E3\u8FD4\u56DE\u7A7A\u6570\u636E`,"eastmoney");return Object.fromEntries(a.map(l=>[l.name,l.code]))}))[n];if(!s)throw new (0, _chunk4Q7UQ5Q3cjs.d)(`${t.errorPrefix}: ${n}`,"eastmoney");return s}}}async function Zr(t,e){let n={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:e.type==="concept"?"f12":"f3",fs:e.fsFilter},r=e.type==="concept"?"f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136":"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",o=await Bn(t,e.listUrl,n,r,100,(i,s)=>({rank:s,name:String(_nullishCoalesce(i.f14, () => (""))),code:String(_nullishCoalesce(i.f12, () => (""))),price:u(i.f2),change:u(i.f4),changePercent:u(i.f3),totalMarketCap:u(i.f20),turnoverRate:u(i.f8),riseCount:u(i.f104),fallCount:u(i.f105),leadingStock:i.f128?String(i.f128):null,leadingStockChangePercent:u(i.f136)}));return o.sort((i,s)=>(_nullishCoalesce(s.changePercent, () => (0)))-(_nullishCoalesce(i.changePercent, () => (0)))),o.forEach((i,s)=>{i.rank=s+1}),o}async function Xr(t,e,n){let r=new URLSearchParams({fields:"f43,f44,f45,f46,f47,f48,f170,f171,f168,f169",mpi:"1000",invt:"2",fltt:"1",secid:`90.${e}`}),o=`${n}?${r.toString()}`,s=await _asyncOptionalChain([(await t.get(o,{responseType:"json"})), 'optionalAccess', async _80 => _80.data]);return s?[{key:"f43",name:"\u6700\u65B0",divide:!0},{key:"f44",name:"\u6700\u9AD8",divide:!0},{key:"f45",name:"\u6700\u4F4E",divide:!0},{key:"f46",name:"\u5F00\u76D8",divide:!0},{key:"f47",name:"\u6210\u4EA4\u91CF",divide:!1},{key:"f48",name:"\u6210\u4EA4\u989D",divide:!1},{key:"f170",name:"\u6DA8\u8DCC\u5E45",divide:!0},{key:"f171",name:"\u632F\u5E45",divide:!0},{key:"f168",name:"\u6362\u624B\u7387",divide:!0},{key:"f169",name:"\u6DA8\u8DCC\u989D",divide:!0}].map(({key:l,name:c,divide:d})=>{let m=s[l],p=null;return typeof m=="number"&&!isNaN(m)&&(p=d?m/100:m),{item:c,value:p}}):[]}async function Jr(t,e,n){let r={po:"1",np:"1",ut:"bd1d9ddb04089700cf9c27f6f7426281",fltt:"2",invt:"2",fid:"f3",fs:`b:${e} f:!50`};return Bn(t,n,r,"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",100,(i,s)=>({rank:s,code:String(_nullishCoalesce(i.f12, () => (""))),name:String(_nullishCoalesce(i.f14, () => (""))),price:u(i.f2),changePercent:u(i.f3),change:u(i.f4),volume:u(i.f5),amount:u(i.f6),amplitude:u(i.f7),high:u(i.f15),low:u(i.f16),open:u(i.f17),prevClose:u(i.f18),turnoverRate:u(i.f8),pe:u(i.f9),pb:u(i.f23)}))}async function eo(t,e,n,r={}){let{period:o="daily",adjust:i="",startDate:s="19700101",endDate:a="20500101"}=r;j(o),ie(i);let l=new URLSearchParams({secid:`90.${e}`,fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",klt:Q(o),fqt:ae(i),beg:s,end:a,smplmt:"10000",lmt:"1000000"}),{klines:c}=await H(t,n,l);return c.length===0?[]:c.map(d=>$(d))}var Wr=new Map;async function to(t,e,n,r,o={}){let i=`${n}|${r}`,s=Wr.get(i);return s||(s=de({trendsUrl:r,klineUrl:n,resolveTarget:a=>({secid:`90.${a}`,code:a}),defaultPeriod:"5",ndays:{fixed:"1"},fqt:{fixed:"1"},includeUt:!1,window:{mode:"full",beg:"0",end:"20500101"},extraKlineParams:{smplmt:"10000",lmt:"1000000"},mapTrendRow:({avgPrice:a,...l})=>({...l,price:a}),mapKlineRow:a=>({time:a.date,open:a.open,close:a.close,high:a.high,low:a.low,changePercent:a.changePercent,change:a.change,volume:a.volume,amount:a.amount,amplitude:a.amplitude,turnoverRate:a.turnoverRate})}),Wr.set(i,s)),s(t,e,o)}function Rt(t){let e=Vr(t);async function n(o){return Zr(o,t)}async function r(o,i){return e.getCode(o,i,n)}return{async getList(o){return n(o)},async getSpot(o,i){let s=await r(o,i);return Xr(o,s,t.spotUrl)},async getConstituents(o,i){let s=await r(o,i);return Jr(o,s,t.consUrl)},async getKline(o,i,s={}){let a=await r(o,i);return eo(o,a,t.klineUrl,s)},async getMinuteKline(o,i,s={}){let a=await r(o,i);return to(o,a,t.klineUrl,t.trendsUrl,s)}}}var Ds={type:"industry",fsFilter:"m:90 t:2 f:!50",listUrl:jt,spotUrl:Qt,consUrl:Gt,klineUrl:Wt,trendsUrl:Vt,errorPrefix:"\u672A\u627E\u5230\u884C\u4E1A\u677F\u5757"},Ke=Rt(Ds);async function no(t){return Ke.getList(t)}async function ro(t,e){return Ke.getSpot(t,e)}async function oo(t,e){return Ke.getConstituents(t,e)}async function io(t,e,n={}){return Ke.getKline(t,e,n)}async function so(t,e,n={}){return Ke.getMinuteKline(t,e,n)}var Ps={type:"concept",fsFilter:"m:90 t:3 f:!50",listUrl:Zt,spotUrl:Xt,consUrl:Jt,klineUrl:en,trendsUrl:tn,errorPrefix:"\u672A\u627E\u5230\u6982\u5FF5\u677F\u5757"},Be=Rt(Ps);async function ao(t){return Be.getList(t)}async function uo(t,e){return Be.getSpot(t,e)}async function lo(t,e){return Be.getConstituents(t,e)}async function co(t,e,n={}){return Be.getKline(t,e,n)}async function po(t,e,n={}){return Be.getMinuteKline(t,e,n)}async function qn(t,e,n){let{reportName:r,columns:o="ALL",filter:i,sortColumns:s,sortTypes:a,pageSize:l=500,startPage:c=1,fetchAllPages:d=!0,maxPages:m=1e3,concurrency:p=3,quoteColumns:g,quoteType:f,extraParams:R}=e,T=async Z=>{let U=new URLSearchParams({reportName:r,columns:o,pageSize:String(l),pageNumber:String(Z),source:"WEB",client:"WEB"});if(i&&U.set("filter",i),s&&U.set("sortColumns",s),a&&U.set("sortTypes",a),g&&U.set("quoteColumns",g),f&&U.set("quoteType",f),R)for(let[Di,Pi]of Object.entries(R))U.set(Di,Pi);let _t=`${nn}?${U.toString()}`,Ct=await _asyncOptionalChain([(await t.get(_t,{responseType:"json"})), 'optionalAccess', async _81 => _81.result]);return!Ct||!Array.isArray(Ct.data)?null:Ct},A=[],O=await T(c);if(!O)return{data:[],total:0,pages:1};let L=_nullishCoalesce(O.pages, () => (1)),re=_nullishCoalesce(O.count, () => (O.data.length)),_e=Z=>{A.push(...Z.map((U,_t)=>n(U,A.length+_t)))};if(_e(O.data),!d||L<=c)return{data:A,total:re,pages:L};let ge=Math.min(L,c+m-1),V=await xe(c+1,ge,p,async Z=>{let U=await T(Z);return U===null?null:{value:U.data}});for(let Z of V)_e(Z);let oe=V.length===ge-c;return ge<L&&oe&&console.warn(`[stock-sdk] fetchDatacenter("${r}") truncated at maxPages=${m} (server reports ${L} pages). Pass a larger \`maxPages\` to fetch the full dataset.`),{data:A,total:re,pages:L}}async function P(t,e,n){return(await qn(t,e,n)).data}function v(t){if(t==null)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}function me(t){if(!t)return null;let e=t.match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function Is(t){return{code:_nullishCoalesce(t.SECURITY_CODE, () => ("")),name:_nullishCoalesce(t.SECURITY_NAME_ABBR, () => ("")),reportDate:me(t.REPORT_DATE),planNoticeDate:me(t.PLAN_NOTICE_DATE),disclosureDate:me(_nullishCoalesce(t.PUBLISH_DATE, () => (t.PLAN_NOTICE_DATE))),assignTransferRatio:_nullishCoalesce(t.BONUS_IT_RATIO, () => (null)),bonusRatio:_nullishCoalesce(t.BONUS_RATIO, () => (null)),transferRatio:_nullishCoalesce(t.IT_RATIO, () => (null)),dividendPretax:_nullishCoalesce(t.PRETAX_BONUS_RMB, () => (null)),dividendDesc:_nullishCoalesce(t.IMPL_PLAN_PROFILE, () => (null)),dividendYield:_nullishCoalesce(t.DIVIDENT_RATIO, () => (null)),eps:_nullishCoalesce(t.BASIC_EPS, () => (null)),bps:_nullishCoalesce(t.BVPS, () => (null)),capitalReserve:_nullishCoalesce(t.PER_CAPITAL_RESERVE, () => (null)),unassignedProfit:_nullishCoalesce(t.PER_UNASSIGN_PROFIT, () => (null)),netProfitYoy:_nullishCoalesce(t.PNP_YOY_RATIO, () => (null)),totalShares:_nullishCoalesce(t.TOTAL_SHARES, () => (null)),equityRecordDate:me(t.EQUITY_RECORD_DATE),exDividendDate:me(t.EX_DIVIDEND_DATE),payDate:me(t.PAY_DATE),assignProgress:_nullishCoalesce(t.ASSIGN_PROGRESS, () => (null)),noticeDate:me(t.NOTICE_DATE)}}async function mo(t,e){let n=_chunkUSZUOBM2cjs.k.call(void 0, _chunkUSZUOBM2cjs.f.call(void 0, e,{market:"CN"}));return P(t,{reportName:"RPT_SHAREBONUS_DET",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:500,filter:`(SECURITY_CODE="${n}")`},r=>Is(r))}var bs="https://fund.eastmoney.com/Data/funddataIndex_Interface.aspx",Yn="https://fund.eastmoney.com/pingzhongdata",Ns="https://fundgz.1234567.com.cn/js";function Ms(){return typeof document<"u"&&typeof window<"u"}var ks=1e4;function Ls(){return Number(K(C.CN).slice(0,4))}function Fs(t,e){let n=new URLSearchParams({dt:"8",page:String(e),rank:_nullishCoalesce(t.rank, () => ("FSRQ")),sort:_nullishCoalesce(t.sort, () => ("desc")),gs:"",ftype:_nullishCoalesce(t.fundType, () => ("")),year:String(_nullishCoalesce(t.year, () => (Ls())))});return`${bs}?${n.toString()}`}function zn(t){if(!t)return null;let e=t.trim().match(/^(\d{4}-\d{2}-\d{2})/);return e?e[1]:null}function ws(t){return{code:_nullishCoalesce(t[0], () => ("")),name:_nullishCoalesce(t[1], () => ("")),equityRecordDate:zn(t[2]),exDividendDate:zn(t[3]),dividendPerShare:_(t[4]),payDate:zn(t[5]),dividendType:_optionalChain([t, 'access', _82 => _82[6], 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()])?t[6].trim():null}}async function $n(t,e,n){let r=Fs(e,n),o=await ce(r,["pageinfo","jjfh_data"],{client:t}),i=_nullishCoalesce(o.pageinfo, () => ([0,0,n])),[s=0,a=0,l=n]=i;return{items:(_nullishCoalesce(o.jjfh_data, () => ([]))).map(ws),totalPages:s,pageSize:a,currentPage:l}}async function go(t,e={}){if(e.page==="all"){let o=await $n(t,e,1),i=o.items;for(let s=2;s<=o.totalPages;s++){let a=await $n(t,e,s);i=i.concat(a.items)}return e.code&&(i=i.filter(s=>s.code===e.code)),{items:i,totalPages:o.totalPages,pageSize:o.pageSize,currentPage:-1}}let n=_nullishCoalesce(e.page, () => (1)),r=await $n(t,e,n);return e.code?{...r,items:r.items.filter(o=>o.code===e.code)}:r}function He(t){return typeof t=="number"&&Number.isFinite(t)}function jn(t){return K(C.CN,t)}function Qn(t){return pe(Te(t,C.CN))}function W(t,e){return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _85 => _85.find, 'call', _86 => _86(n=>n.name===e), 'optionalAccess', _87 => _87.data]), () => ([]))}async function fo(t,e){let n=`${Yn}/${encodeURIComponent(e)}.js`,r=await ce(n,["fS_code","fS_name","Data_netWorthTrend","Data_ACWorthTrend"],{client:t}),o=_nullishCoalesce(r.Data_netWorthTrend, () => ([])),i=new Map;for(let a of _nullishCoalesce(r.Data_ACWorthTrend, () => ([])))Array.isArray(a)&&a.length>=2&&He(a[0])&&i.set(a[0],_(a[1]));let s=o.filter(a=>a&&He(a.x)).map(a=>({date:jn(a.x),timestamp:a.x,nav:_(a.y),accNav:_nullishCoalesce(i.get(a.x), () => (null)),dailyReturn:_(a.equityReturn),unitMoney:_nullishCoalesce(a.unitMoney, () => (""))}));return{code:_nullishCoalesce(r.fS_code, () => (e)),name:_nullishCoalesce(r.fS_name, () => (null)),items:s}}function vs(t,e,n=ks){let r=`${Ns}/${encodeURIComponent(e)}.js?rt=${Date.now()}`;return Ms()?Oe("fundgz:jsonpgz",()=>Us(r,n)):xs(t,r)}function Us(t,e){return new Promise((n,r)=>{let o=document.createElement("script"),i=window,s=i.jsonpgz,a=!1,l=()=>{if(o.parentNode&&o.parentNode.removeChild(o),s===void 0)try{delete i.jsonpgz}catch (e12){}else i.jsonpgz=s},c=setTimeout(()=>{a||(a=!0,l(),r(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"TIMEOUT",message:`fundgz JSONP timed out after ${e}ms: ${t}`,url:t,details:{timeout:e}})))},e);i.jsonpgz=d=>{a||(a=!0,clearTimeout(c),l(),n(_nullishCoalesce(d, () => ({}))))},o.onerror=()=>{a||(a=!0,clearTimeout(c),l(),r(new (0, _chunk4Q7UQ5Q3cjs.a)({code:"NETWORK_ERROR",message:`fundgz JSONP script load failed: ${t}`,url:t})))},o.src=t,document.head.appendChild(o)})}async function xs(t,e){let r=(await t.get(e,{responseType:"text",provider:"eastmoney"})).trim();if(!r)return{};try{return ot(r)}catch (e13){return{}}}async function yo(t,e){let n=await vs(t,e);return{code:_nullishCoalesce(n.fundcode, () => (e)),name:_nullishCoalesce(n.name, () => (null)),navDate:_optionalChain([n, 'access', _88 => _88.jzrq, 'optionalAccess', _89 => _89.trim, 'call', _90 => _90()])?n.jzrq.trim():null,nav:_(n.dwjz),estimatedNav:_(n.gsz),estimatedChangePercent:_(n.gszzl),estimateTime:_optionalChain([n, 'access', _91 => _91.gztime, 'optionalAccess', _92 => _92.trim, 'call', _93 => _93()])?n.gztime.trim():null}}async function ho(t,e){let n=`${Yn}/${encodeURIComponent(e)}.js`,r=await ce(n,["fS_code","fS_name","Data_rateInSimilarType","Data_rateInSimilarPersent"],{client:t}),o=_nullishCoalesce(r.Data_rateInSimilarType, () => ([])),i=new Map;for(let a of _nullishCoalesce(r.Data_rateInSimilarPersent, () => ([])))Array.isArray(a)&&a.length>=2&&He(a[0])&&i.set(a[0],_(a[1]));let s=o.filter(a=>a&&He(a.x)).map(a=>({date:jn(a.x),timestamp:a.x,rank:_(a.y),total:_(a.sc),percentile:_nullishCoalesce(i.get(a.x), () => (null))}));return{code:_nullishCoalesce(r.fS_code, () => (e)),name:_nullishCoalesce(r.fS_name, () => (null)),items:s}}function To(t){let e=t.indexOf(".");return e<0?{code:t,marketId:""}:{marketId:t.slice(0,e),code:t.slice(e+1)}}function Ks(t){return t?t.map(e=>e.trim()).filter(Boolean).map(To):[]}function Bs(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).map(To):[]}function Hs(t){if(!_optionalChain([t, 'optionalAccess', _94 => _94.categories, 'optionalAccess', _95 => _95.length])||!_optionalChain([t, 'optionalAccess', _96 => _96.series]))return[];let e=W(t.series,"\u80A1\u7968\u5360\u51C0\u6BD4"),n=W(t.series,"\u503A\u5238\u5360\u51C0\u6BD4"),r=W(t.series,"\u73B0\u91D1\u5360\u51C0\u6BD4"),o=W(t.series,"\u5176\u4ED6\u5360\u51C0\u6BD4"),i=W(t.series,"\u51C0\u8D44\u4EA7");return t.categories.map((s,a)=>({date:s,timestamp:Qn(s),stockRatio:_nullishCoalesce(e[a], () => (0)),bondRatio:_nullishCoalesce(n[a], () => (0)),cashRatio:_nullishCoalesce(r[a], () => (0)),otherRatio:_nullishCoalesce(o[a], () => (0)),netAsset:_nullishCoalesce(i[a], () => (0))}))}function qs(t){return t?t.filter(e=>He(e[0])).map(([e,n])=>({date:jn(e),timestamp:e,position:n})):[]}function zs(t){return t?t.map(e=>{let n=_optionalChain([e, 'optionalAccess', _97 => _97.star]);return{id:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _98 => _98.id]), () => ("")),name:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _99 => _99.name]), () => ("")),avatarUrl:_optionalChain([e, 'optionalAccess', _100 => _100.pic, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()])||null,star:typeof n=="number"&&Number.isFinite(n)?n:null,workTime:_optionalChain([e, 'optionalAccess', _103 => _103.workTime, 'optionalAccess', _104 => _104.trim, 'call', _105 => _105()])||null,fundSize:_optionalChain([e, 'optionalAccess', _106 => _106.fundSize, 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()])||null,power:So(_optionalChain([e, 'optionalAccess', _109 => _109.power]))}}):[]}function So(t){return _optionalChain([t, 'optionalAccess', _110 => _110.categories, 'optionalAccess', _111 => _111.length])?{overall:_nullishCoalesce(_(t.avr), () => (0)),categories:t.categories,scores:_nullishCoalesce(t.data, () => ([])),descriptions:_nullishCoalesce(t.dsc, () => ([]))}:null}function $s(t){if(!_optionalChain([t, 'optionalAccess', _112 => _112.categories, 'optionalAccess', _113 => _113.length])||!_optionalChain([t, 'optionalAccess', _114 => _114.series]))return[];let e=W(t.series,"\u673A\u6784\u6301\u6709\u6BD4\u4F8B"),n=W(t.series,"\u4E2A\u4EBA\u6301\u6709\u6BD4\u4F8B"),r=W(t.series,"\u5185\u90E8\u6301\u6709\u6BD4\u4F8B");return t.categories.map((o,i)=>({date:o,timestamp:Qn(o),institutionRatio:_nullishCoalesce(e[i], () => (0)),individualRatio:_nullishCoalesce(n[i], () => (0)),internalRatio:_nullishCoalesce(r[i], () => (0))}))}function Ys(t){return!_optionalChain([t, 'optionalAccess', _115 => _115.categories, 'optionalAccess', _116 => _116.length])||!_optionalChain([t, 'optionalAccess', _117 => _117.series])?[]:t.categories.map((e,n)=>({date:e,scale:_nullishCoalesce(_optionalChain([t, 'access', _118 => _118.series, 'optionalAccess', _119 => _119[n], 'optionalAccess', _120 => _120.y]), () => (0)),mom:_nullishCoalesce(_optionalChain([t, 'access', _121 => _121.series, 'optionalAccess', _122 => _122[n], 'optionalAccess', _123 => _123.mom]), () => (""))}))}function js(t){if(!_optionalChain([t, 'optionalAccess', _124 => _124.categories, 'optionalAccess', _125 => _125.length])||!_optionalChain([t, 'optionalAccess', _126 => _126.series]))return[];let e=W(t.series,"\u671F\u95F4\u7533\u8D2D"),n=W(t.series,"\u671F\u95F4\u8D4E\u56DE"),r=W(t.series,"\u603B\u4EFD\u989D");return t.categories.map((o,i)=>({date:o,timestamp:Qn(o),buy:_nullishCoalesce(e[i], () => (0)),sell:_nullishCoalesce(n[i], () => (0)),total:_nullishCoalesce(r[i], () => (0))}))}function Qs(t){return{oneMonth:_(t.syl_1y),threeMonth:_(t.syl_3y),sixMonth:_(t.syl_6y),oneYear:_(t.syl_1n)}}function Gs(t){if(typeof t!="string")return null;let e=t.indexOf("_");if(e<0)return null;let n=t.slice(0,e);if(!n)return null;let r=t.lastIndexOf("_");return r>e?{code:n,name:t.slice(e+1,r),value:_(t.slice(r+1))}:{code:n,name:t.slice(e+1),value:null}}function Ws(t){if(!_optionalChain([t, 'optionalAccess', _127 => _127.length]))return null;let e=t.map(n=>(Array.isArray(n)?n:[]).map(Gs).filter(r=>r!==null)).filter(n=>n.length>0);return e.length?{groups:e}:null}async function Ro(t,e){let n=`${Yn}/${encodeURIComponent(e)}.js`,r=await ce(n,["fS_code","fS_name","fund_sourceRate","fund_Rate","fund_minsg","stockCodesNew","zqCodesNew","Data_assetAllocation","Data_fundSharesPositions","Data_currentFundManager","Data_performanceEvaluation","Data_holderStructure","Data_fluctuationScale","Data_buySedemption","syl_1y","syl_3y","syl_6y","syl_1n","swithSameType"],{client:t});return{code:_nullishCoalesce(r.fS_code, () => (e)),name:_nullishCoalesce(r.fS_name, () => (null)),sourceRate:_(r.fund_sourceRate),rate:_(r.fund_Rate),minSubscription:_(r.fund_minsg),holdings:Ks(r.stockCodesNew),bondHoldings:Bs(r.zqCodesNew),assetAllocation:Hs(r.Data_assetAllocation),positions:qs(r.Data_fundSharesPositions),managers:zs(r.Data_currentFundManager),performance:So(r.Data_performanceEvaluation),holderStructure:$s(r.Data_holderStructure),scaleChanges:Ys(r.Data_fluctuationScale),buySedemption:js(r.Data_buySedemption),stageReturns:Qs(r),sameType:Ws(r.swithSameType)}}function Gn(t){let e=t.match(/^([a-zA-Z]+)/);if(!e)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid futures symbol: "${t}". Expected format: variety + contract (e.g., rb2605, RBM, IF2604)`);return e[1]}function Eo(t){return _nullishCoalesce(_nullishCoalesce(Re[t], () => (Re[t.toLowerCase()])), () => (Re[t.toUpperCase()]))}function Wn(t){let e=Eo(t);if(!e&&t.length>1&&t.endsWith("M")&&(e=Eo(t.slice(0,-1))),!e){let r=Object.keys(Re).join(", ");throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Unknown futures variety: "${t}". Supported varieties: ${r}`)}let n=an[e];if(n===void 0)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`No market code found for exchange: ${e}`);return n}function Vs(t){let e=$(t),n=t.split(",");return{...e,openInterest:n.length>12?h(n[12]):null}}async function _o(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;j(r);let s=Gn(e),l=`${Wn(s)}.${e}`,c=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:F,klt:Q(r),fqt:"0",secid:l,beg:o,end:i}),{klines:d,name:m,code:p}=await H(t,be,c);return d.length===0?[]:d.map(g=>({...Vs(g),code:p||e,name:m||""}))}async function Co(t,e={}){let n=_nullishCoalesce(e.pageSize, () => (20)),r=[],o=0,i=0,s=1e3;do{let a=new URLSearchParams({orderBy:"dm",sort:"desc",pageSize:String(n),pageIndex:String(o),token:Ne,field:"dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",blockName:"callback"}),l=`${sn}?${a.toString()}`,c=await t.get(l,{responseType:"json"});if(!c||!Array.isArray(c.list))break;o===0&&(i=_nullishCoalesce(c.total, () => (0)));let d=c.list.map(Zs);if(r.push(...d),d.length===0)break;o++}while(r.length<i&&o<s);return r}function Zs(t){return{code:t.dm||"",name:t.name||"",price:h(String(t.p)),change:h(String(t.zde)),changePercent:h(String(t.zdf)),open:h(String(t.o)),high:h(String(t.h)),low:h(String(t.l)),prevSettle:h(String(t.zjsj)),volume:h(String(t.vol)),buyVolume:h(String(t.wp)),sellVolume:h(String(t.np)),openInterest:h(String(t.ccl))}}function Xs(t){let e=$(t),n=t.split(",");return{...e,openInterest:n.length>12?h(n[12]):null}}function Js(t){let e=t.match(/^([A-Z]+)/);if(!e)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid global futures symbol: "${t}". Expected format like HG00Y, CL2507`);return e[1]}async function Ao(t,e,n={}){let{period:r="daily",startDate:o="19700101",endDate:i="20500101"}=n;j(r);let s=n.marketCode;if(s===void 0){let p=Js(e);if(s=ut[p],s===void 0){let g=Object.keys(ut).join(", ");throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Unknown global futures variety: "${p}". Supported: ${g}. Or specify marketCode manually via options.`)}}let a=`${s}.${e}`,l=new URLSearchParams({fields1:"f1,f2,f3,f4,f5,f6",fields2:"f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",ut:F,klt:Q(r),fqt:"0",secid:a,beg:o,end:i}),{klines:c,name:d,code:m}=await H(t,be,l);return c.length===0?[]:c.map(p=>({...Xs(p),code:m||e,name:d||""}))}async function Oo(t,e={}){let{pageSize:n=2e4}=e,r=new URLSearchParams({orderBy:"zdf",sort:"desc",pageSize:String(n),pageIndex:"0",token:Ne,field:"dm,sc,name,p,zsjd,zde,zdf,f152,vol,cje,ccl,xqj,syr,rz,zjsj,o"}),o=`${pn}?${r.toString()}`,s=await _asyncOptionalChain([(await t.get(o,{responseType:"json"})), 'optionalAccess', async _128 => _128.list]);return Array.isArray(s)?s.map(a=>({code:String(_nullishCoalesce(a.dm, () => (""))),name:String(_nullishCoalesce(a.name, () => (""))),price:u(a.p),change:u(a.zde),changePercent:u(a.zdf),volume:u(a.vol),amount:u(a.cje),openInterest:u(a.ccl),strikePrice:u(a.xqj),remainDays:u(a.syr),dailyChange:u(a.rz),prevSettle:u(a.zjsj),open:u(a.o)})):[]}async function Do(t,e,n){let r=new URLSearchParams({type:"RPT_IF_BILLBOARD_TD",sty:"ALL",p:"1",ps:"200",source:"IFBILLBOARD",client:"WEB",ut:G,filter:`(SECURITY_CODE="${e}")(TRADE_DATE='${n}')`}),o=`${mn}?${r.toString()}`,s=await _asyncOptionalChain([(await t.get(o,{responseType:"json"})), 'optionalAccess', async _129 => _129.result, 'optionalAccess', async _130 => _130.data]);if(!Array.isArray(s))return[];function a(l){if(!l)return"";let c=String(l),d=c.match(/^(\d{4}-\d{2}-\d{2})/);return d?d[1]:c}return s.map(l=>({tradeType:String(_nullishCoalesce(l.TRADE_TYPE, () => (""))),date:a(l.TRADE_DATE),symbol:String(_nullishCoalesce(l.SECURITY_CODE, () => (""))),targetName:String(_nullishCoalesce(l.TARGET_NAME, () => (""))),memberName:String(_nullishCoalesce(l.MEMBER_NAME_ABBR, () => (""))),rank:_nullishCoalesce(u(l.MEMBER_RANK), () => (0)),sellVolume:u(l.SELL_VOLUME),sellVolumeChange:u(l.SELL_VOLUME_CHANGE),netSellVolume:u(l.NET_SELL_VOLUME),sellVolumeRatio:u(l.SELL_VOLUME_RATIO),buyVolume:u(l.BUY_VOLUME),buyVolumeChange:u(l.BUY_VOLUME_CHANGE),netBuyVolume:u(l.NET_BUY_VOLUME),buyVolumeRatio:u(l.BUY_VOLUME_RATIO),sellPosition:u(l.SELL_POSITION),sellPositionChange:u(l.SELL_POSITION_CHANGE),netSellPosition:u(l.NET_SELL_POSITION),sellPositionRatio:u(l.SELL_POSITION_RATIO),buyPosition:u(l.BUY_POSITION),buyPositionChange:u(l.BUY_POSITION_CHANGE),netBuyPosition:u(l.NET_BUY_POSITION),buyPositionRatio:u(l.BUY_POSITION_RATIO)}))}var ea={gold:"EMI00069026",silver:"EMI00069027"};function Po(t){if(!t)return"";let e=String(t),n=e.match(/^(\d{4}-\d{2}-\d{2})/);return n?n[1]:e}async function Io(t){return P(t,{reportName:"RPT_FUTU_POSITIONCODE",columns:"TRADE_MARKET_CODE,TRADE_CODE,TRADE_TYPE",filter:'(IS_MAINCODE="1")',pageSize:500,fetchAllPages:!1},e=>({code:String(_nullishCoalesce(e.TRADE_CODE, () => (""))),name:String(_nullishCoalesce(e.TRADE_TYPE, () => (""))),marketCode:String(_nullishCoalesce(e.TRADE_MARKET_CODE, () => ("")))}))}async function bo(t,e,n={}){let{startDate:r="2020-10-28",pageSize:o=500}=n,i=e.toUpperCase();return P(t,{reportName:"RPT_FUTU_STOCKDATA",columns:"SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",filter:`(SECURITY_CODE="${i}")(TRADE_DATE>='${b(r)}')`,pageSize:o,sortColumns:"TRADE_DATE",sortTypes:"-1"},s=>({code:String(_nullishCoalesce(s.SECURITY_CODE, () => (e))),date:Po(s.TRADE_DATE),inventory:u(s.ON_WARRANT_NUM),change:u(s.ADDCHANGE)}))}async function No(t,e,n={}){let r=ea[e];if(!r)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid COMEX symbol: "${e}". Must be "gold" or "silver".`);let{pageSize:o=500}=n,i={gold:"\u9EC4\u91D1",silver:"\u767D\u94F6"};return P(t,{reportName:"RPT_FUTUOPT_GOLDSIL",sortColumns:"REPORT_DATE",sortTypes:"-1",pageSize:o,filter:`(INDICATOR_ID1="${r}")(@STORAGE_TON<>"NULL")`},s=>({date:Po(s.REPORT_DATE),name:_nullishCoalesce(i[e], () => (e)),storageTon:u(s.STORAGE_TON),storageOunce:u(s.STORAGE_OUNCE)}))}var Mo={daily:"101",weekly:"102",monthly:"103"},Vn="f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65";function ko(t){let e=t.split(",");return{date:_nullishCoalesce(e[0], () => ("")),mainNetInflow:h(e[1]),smallNetInflow:h(e[2]),mediumNetInflow:h(e[3]),largeNetInflow:h(e[4]),superLargeNetInflow:h(e[5]),mainNetInflowPercent:h(e[6]),smallNetInflowPercent:h(e[7]),mediumNetInflowPercent:h(e[8]),largeNetInflowPercent:h(e[9]),superLargeNetInflowPercent:h(e[10]),close:h(e[11]),changePercent:h(e[12])}}function ta(t){let e=t.split(",");return{date:_nullishCoalesce(e[0], () => ("")),mainNetInflow:h(e[1]),smallNetInflow:h(e[2]),mediumNetInflow:h(e[3]),largeNetInflow:h(e[4]),superLargeNetInflow:h(e[5]),mainNetInflowPercent:h(e[6]),smallNetInflowPercent:h(e[7]),mediumNetInflowPercent:h(e[8]),largeNetInflowPercent:h(e[9]),superLargeNetInflowPercent:h(e[10]),shClose:h(e[11]),shChangePercent:h(e[12]),szClose:h(e[13]),szChangePercent:h(e[14])}}var Lo={today:{fid:"f62",fields:"f12,f14,f2,f3,f62,f184,f66,f69,f72,f75,f78,f81,f84,f87,f124",changePercentField:"f3",mainNet:"f62",mainPct:"f184",superLargeNet:"f66",superLargePct:"f69",largeNet:"f72",largePct:"f75",mediumNet:"f78",mediumPct:"f81",smallNet:"f84",smallPct:"f87"},"3day":{fid:"f267",fields:"f12,f14,f2,f127,f267,f268,f269,f270,f271,f272,f273,f274,f275,f276,f124",changePercentField:"f127",mainNet:"f267",mainPct:"f268",superLargeNet:"f269",superLargePct:"f270",largeNet:"f271",largePct:"f272",mediumNet:"f273",mediumPct:"f274",smallNet:"f275",smallPct:"f276"},"5day":{fid:"f164",fields:"f12,f14,f2,f109,f164,f165,f166,f167,f168,f169,f170,f171,f172,f173,f124",changePercentField:"f109",mainNet:"f164",mainPct:"f165",superLargeNet:"f166",superLargePct:"f167",largeNet:"f168",largePct:"f169",mediumNet:"f170",mediumPct:"f171",smallNet:"f172",smallPct:"f173"},"10day":{fid:"f174",fields:"f12,f14,f2,f160,f174,f175,f176,f177,f178,f179,f180,f181,f182,f183,f124",changePercentField:"f160",mainNet:"f174",mainPct:"f175",superLargeNet:"f176",superLargePct:"f177",largeNet:"f178",largePct:"f179",mediumNet:"f180",mediumPct:"f181",smallNet:"f182",smallPct:"f183"}},na={industry:"m:90+t:2",concept:"m:90+t:3",region:"m:90+t:1"},ra="m:0+t:6+f:!2,m:0+t:13+f:!2,m:0+t:80+f:!2,m:1+t:2+f:!2,m:1+t:23+f:!2,m:0+t:7+f:!2,m:1+t:3+f:!2";async function Fo(t,e,n=100,r=1e3,o=3){let i=async g=>{let f=new URLSearchParams({...e,pn:String(g),pz:String(n)}),R=`${rn}?${f.toString()}`,A=await _asyncOptionalChain([(await t.get(R,{responseType:"json"})), 'optionalAccess', async _131 => _131.data]);return!A||!Array.isArray(A.diff)?null:{total:A.total,diff:A.diff}},s=[],a=await i(1);if(!a)return s;let l=_nullishCoalesce(a.total, () => (0));if(s.push(...a.diff),s.length>=l||a.diff.length<n)return s;let c=n>0?Math.ceil(l/n):1,d=Math.min(c,r),m=await xe(2,d,o,async g=>{let f=await i(g);return!f||f.diff.length===0?null:{value:f.diff,terminal:f.diff.length<n}});for(let g of m)s.push(...g);let p=m.length===d-1;return c>r&&p&&s.length<l&&console.warn(`[stock-sdk] fetchClistAllPages truncated at maxPages=${r} (server reports total=${l}, fetched=${s.length}). Pass a larger \`maxPages\` to fetch the full dataset.`),s}async function wo(t,e,n={}){let{period:r="daily"}=n,o=Mo[r];if(!o)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid period: ${r}. Must be daily/weekly/monthly.`);let i;try{i=_chunkUSZUOBM2cjs.f.call(void 0, e,{market:"CN"})}catch(m){let p=e.includes(".")?e.slice(e.indexOf(".")+1):e;throw m instanceof _chunk4Q7UQ5Q3cjs.f&&_chunkUSZUOBM2cjs.d.call(void 0, p)?new (0, _chunk4Q7UQ5Q3cjs.e)(`Individual fund flow is not available for index symbols: ${e}`):m}if(i.assetType==="index"&&_chunkUSZUOBM2cjs.d.call(void 0, i.code))throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Individual fund flow is not available for index symbols: ${e}`);let s=_chunkUSZUOBM2cjs.j.call(void 0, i),a=new URLSearchParams({lmt:"0",klt:o,secid:s,fields1:"f1,f2,f3,f7",fields2:Vn,ut:G}),l=`${Ie}?${a.toString()}`,d=await _asyncOptionalChain([(await t.get(l,{responseType:"json"})), 'optionalAccess', async _132 => _132.data, 'optionalAccess', async _133 => _133.klines]);return!Array.isArray(d)||d.length===0?[]:d.map(ko)}async function vo(t){let e=new URLSearchParams({lmt:"0",klt:"101",secid:"1.000001",secid2:"0.399001",fields1:"f1,f2,f3,f7",fields2:Vn,ut:G}),n=`${Ie}?${e.toString()}`,o=await _asyncOptionalChain([(await t.get(n,{responseType:"json"})), 'optionalAccess', async _134 => _134.data, 'optionalAccess', async _135 => _135.klines]);return!Array.isArray(o)||o.length===0?[]:o.map(ta)}async function Uo(t,e={}){let{indicator:n="today"}=e,r=Lo[n];if(!r)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid indicator: ${n}.`);let o={fid:r.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:G,fs:ra,fields:r.fields};return(await Fo(t,o,100)).map(s=>({code:String(_nullishCoalesce(s.f12, () => (""))),name:String(_nullishCoalesce(s.f14, () => (""))),price:u(s.f2),changePercent:u(s[r.changePercentField]),mainNetInflow:u(s[r.mainNet]),mainNetInflowPercent:u(s[r.mainPct]),superLargeNetInflow:u(s[r.superLargeNet]),superLargeNetInflowPercent:u(s[r.superLargePct]),largeNetInflow:u(s[r.largeNet]),largeNetInflowPercent:u(s[r.largePct]),mediumNetInflow:u(s[r.mediumNet]),mediumNetInflowPercent:u(s[r.mediumPct]),smallNetInflow:u(s[r.smallNet]),smallNetInflowPercent:u(s[r.smallPct])}))}async function xo(t,e={}){let{indicator:n="today",sectorType:r="industry"}=e,o=Lo[n];if(!o)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid indicator: ${n}.`);let i=na[r];if(!i)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid sectorType: ${r}.`);let s=`${o.fields},f204,f205`,a={fid:o.fid,po:"1",np:"1",fltt:"2",invt:"2",ut:G,fs:i,fields:s};return(await Fo(t,a,100)).map(c=>({code:String(_nullishCoalesce(c.f12, () => (""))),name:String(_nullishCoalesce(c.f14, () => (""))),changePercent:u(c[o.changePercentField]),mainNetInflow:u(c[o.mainNet]),mainNetInflowPercent:u(c[o.mainPct]),superLargeNetInflow:u(c[o.superLargeNet]),largeNetInflow:u(c[o.largeNet]),mediumNetInflow:u(c[o.mediumNet]),smallNetInflow:u(c[o.smallNet]),topStockCode:c.f204?String(c.f204):void 0,topStockName:c.f205?String(c.f205):void 0}))}async function Ko(t,e,n={}){let{period:r="daily"}=n,o=Mo[r];if(!o)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid period: ${r}. Must be daily/weekly/monthly.`);let i=e.includes(".")?e:`90.${e}`,s=new URLSearchParams({lmt:"0",klt:o,secid:i,fields1:"f1,f2,f3,f7",fields2:Vn,ut:G}),a=`${Ie}?${s.toString()}`,c=await _asyncOptionalChain([(await t.get(a,{responseType:"json"})), 'optionalAccess', async _136 => _136.data, 'optionalAccess', async _137 => _137.klines]);return!Array.isArray(c)||c.length===0?[]:c.map(ko)}var oa={today:"1","3day":"3","5day":"5","10day":"10",month:"M",quarter:"Q",year:"Y"},ia={shanghai:"001",shenzhen:"003"};function Bo(t,e){let n=t.split(",");return{date:e,time:_nullishCoalesce(n[0], () => ("")),shanghaiNetInflow:h(n[1]),shenzhenNetInflow:h(n[3]),totalNetInflow:h(n[5])}}async function Ho(t,e="north"){rt(e);let n=new URLSearchParams({fields1:"f1,f2,f3,f4",fields2:"f51,f54,f52,f58,f53,f62,f56,f57,f60,f61",ut:G}),r=`${on}?${n.toString()}`,i=await _asyncOptionalChain([(await t.get(r,{responseType:"json"})), 'optionalAccess', async _138 => _138.data]);if(!i)return[];if(e==="south"){let l=_nullishCoalesce(i.n2s, () => ([])),c=_nullishCoalesce(i.n2sDate, () => (""));return l.map(d=>Bo(d,b(c)))}let s=_nullishCoalesce(i.s2n, () => ([])),a=_nullishCoalesce(i.s2nDate, () => (""));return s.map(l=>Bo(l,b(a)))}async function qo(t){return P(t,{reportName:"RPT_MUTUAL_QUOTA",columns:"TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,INDEX_CODE,INDEX_NAME,BOARD_CODE",quoteColumns:"status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE",quoteType:"0",sortColumns:"MUTUAL_TYPE",sortTypes:"1",pageSize:2e3,fetchAllPages:!1},e=>({date:v(e.TRADE_DATE),type:String(_nullishCoalesce(e.MUTUAL_TYPE, () => (""))),boardName:String(_nullishCoalesce(e.MUTUAL_TYPE_NAME, () => (""))),direction:String(_nullishCoalesce(e.FUNDS_DIRECTION, () => (""))),status:String(_nullishCoalesce(e.status, () => (""))),netBuyAmount:u(e.netBuyAmt),netInflow:u(e.dayNetAmtIn),remainAmount:u(e.dayAmtRemain),upCount:u(e.f104),flatCount:u(e.f106),downCount:u(e.f105),indexCode:String(_nullishCoalesce(e.INDEX_CODE, () => (""))),indexName:String(_nullishCoalesce(e.INDEX_NAME, () => (""))),indexChangePercent:u(e.INDEX_f3)}))}async function zo(t,e={}){let{market:n="all",period:r="5day",date:o}=e,i=oa[r];if(!i)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid period: ${r}.`);let s=[`(INTERVAL_TYPE="${i}")`];return o&&s.push(`(TRADE_DATE='${o}')`),n!=="all"&&s.push(`(MUTUAL_TYPE="${ia[n]}")`),P(t,{reportName:"RPT_MUTUAL_STOCK_NORTHSTA",columns:"ALL",sortColumns:"ADD_MARKET_CAP",sortTypes:"-1",pageSize:500,filter:s.join("")},a=>({date:v(a.TRADE_DATE),code:String(_nullishCoalesce(a.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(_nullishCoalesce(a.SECURITY_NAME, () => (a.SECURITY_NAME_ABBR)), () => (""))),close:u(a.CLOSE_PRICE),changePercent:u(a.CHANGE_RATE),holdShares:u(a.HOLD_SHARES),holdMarketValue:u(a.HOLD_MARKET_CAP),holdRatioFloat:u(a.HOLD_RATIO),holdRatioTotal:u(a.A_SHARES_RATIO),addShares:u(a.ADD_SHARES),addMarketValue:u(a.ADD_MARKET_CAP),addMarketValuePercent:u(a.ADD_MARKET_CAP_PROPORTION),sector:String(_nullishCoalesce(a.BOARD_NAME, () => ("")))}))}async function $o(t,e="north",n={}){rt(e);let{startDate:r,endDate:o}=n,i=[e==="north"?'(BOARD_TYPE="1")':'(BOARD_TYPE="0")'];return r&&i.push(`(TRADE_DATE>='${b(r)}')`),o&&i.push(`(TRADE_DATE<='${b(o)}')`),P(t,{reportName:"RPT_MUTUAL_DEAL_HISTORY",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:i.join("")},s=>({date:v(s.TRADE_DATE),netBuyAmount:u(s.NET_DEAL_AMT),buyAmount:u(s.BUY_AMT),sellAmount:u(s.SELL_AMT),accNetBuyAmount:u(s.ACCUM_DEAL_AMT),netInflow:u(s.FUND_INFLOW),remainAmount:u(s.QUOTA_BALANCE),topStockCode:s.LEAD_STOCKS_CODE?String(s.LEAD_STOCKS_CODE):null,topStockName:s.LEAD_STOCKS_NAME?String(s.LEAD_STOCKS_NAME):null,topStockChangePercent:u(s.LS_CHANGE_RATE)}))}async function Yo(t,e,n={}){let r=_chunkUSZUOBM2cjs.k.call(void 0, _chunkUSZUOBM2cjs.f.call(void 0, e,{market:"CN"})),{startDate:o,endDate:i}=n,s=[`(SECURITY_CODE="${r}")`];return o&&s.push(`(TRADE_DATE>='${b(o)}')`),i&&s.push(`(TRADE_DATE<='${b(i)}')`),P(t,{reportName:"RPT_MUTUAL_HOLDSTOCKNORTH_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500,filter:s.join("")},a=>({date:v(a.TRADE_DATE),holdShares:u(a.HOLD_SHARES),holdMarketValue:u(a.HOLD_MARKET_CAP),holdRatioFloat:u(a.HOLD_RATIO),holdRatioTotal:u(a.A_SHARES_RATIO),close:u(a.CLOSE_PRICE),changePercent:u(a.CHANGE_RATE)}))}var sa={zt:{path:"/getTopicZTPool",sort:"fbt:asc"},yesterday:{path:"/getYesterdayZTPool",sort:"zs:desc"},strong:{path:"/getTopicQSPool",sort:"zdp:desc"},sub_new:{path:"/getTopicCXPool",sort:"ods:asc"},broken:{path:"/getTopicZBPool",sort:"fbt:asc"},dt:{path:"/getTopicDTPool",sort:"fund:asc"}},Zn={rocket_launch:"8201",quick_rebound:"8202",large_buy:"8193",limit_up_seal:"4",limit_down_open:"32",big_buy_order:"64",auction_up:"8207",high_open_5d:"8209",gap_up:"8211",high_60d:"8213",surge_60d:"8215",accelerate_down:"8204",high_dive:"8203",large_sell:"8194",limit_down_seal:"8",limit_up_open:"16",big_sell_order:"128",auction_down:"8208",low_open_5d:"8210",gap_down:"8212",low_60d:"8214",drop_60d:"8216"},Qo=Object.fromEntries(Object.entries(Zn).map(([t,e])=>[e,t])),Go={8201:"\u706B\u7BAD\u53D1\u5C04",8202:"\u5FEB\u901F\u53CD\u5F39",8193:"\u5927\u7B14\u4E70\u5165",4:"\u5C01\u6DA8\u505C\u677F",32:"\u6253\u5F00\u8DCC\u505C\u677F",64:"\u6709\u5927\u4E70\u76D8",8207:"\u7ADE\u4EF7\u4E0A\u6DA8",8209:"\u9AD8\u5F005\u65E5\u7EBF",8211:"\u5411\u4E0A\u7F3A\u53E3",8213:"60\u65E5\u65B0\u9AD8",8215:"60\u65E5\u5927\u5E45\u4E0A\u6DA8",8204:"\u52A0\u901F\u4E0B\u8DCC",8203:"\u9AD8\u53F0\u8DF3\u6C34",8194:"\u5927\u7B14\u5356\u51FA",8:"\u5C01\u8DCC\u505C\u677F",16:"\u6253\u5F00\u6DA8\u505C\u677F",128:"\u6709\u5927\u5356\u76D8",8208:"\u7ADE\u4EF7\u4E0B\u8DCC",8210:"\u4F4E\u5F005\u65E5\u7EBF",8212:"\u5411\u4E0B\u7F3A\u53E3",8214:"60\u65E5\u65B0\u4F4E",8216:"60\u65E5\u5927\u5E45\u4E0B\u8DCC"};function Et(t){if(t==null)return"";let e=String(t).padStart(6,"0");return`${e.slice(0,2)}:${e.slice(2,4)}:${e.slice(4,6)}`}function aa(t){if(!t||typeof t!="object")return"";let e=t;return`${_nullishCoalesce(e.days, () => (""))}/${_nullishCoalesce(e.ct, () => (""))}`}function ua(t){let e=u(t.p),n=u(t.tp);return{code:String(_nullishCoalesce(_nullishCoalesce(t.c, () => (t.m)), () => (""))),name:String(_nullishCoalesce(t.n, () => (""))),price:e!==null?e/1e3:null,changePercent:u(t.zdp),limitPrice:n!==null?n/1e3:null,amount:u(_nullishCoalesce(t.amount, () => (t.zb))),floatMarketValue:u(t.ltsz),totalMarketValue:u(t.tshare),turnoverRate:u(t.hs),continuousBoardCount:u(t.lbc),firstBoardTime:t.fbt!==void 0&&t.fbt!==null?Et(t.fbt):null,lastBoardTime:t.lbt!==void 0&&t.lbt!==null?Et(t.lbt):null,boardAmount:u(t.fund),sealAmount:u(t.fund),failedCount:u(t.zbc),industry:String(_nullishCoalesce(t.hybk, () => (""))),ztStatistics:aa(t.zttj),amplitude:u(t.zf),speed:u(t.zs)}}function Wo(t){if(t)return/^\d{8}$/.test(t)?t:t.replace(/-/g,"")}function Vo(){return K(C.CN).replace(/-/g,"")}async function Zo(t,e="zt",n){let r=sa[e];if(!r)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid ZTPool type: ${e}.`);let o=_nullishCoalesce(Wo(n), () => (Vo())),i=new URLSearchParams({ut:F,dpt:"wz.ztzt",Pageindex:"0",pagesize:"10000",sort:r.sort,date:o}),s=`${Se}${r.path}?${i.toString()}`,l=await _asyncOptionalChain([(await t.get(s,{responseType:"json"})), 'optionalAccess', async _139 => _139.data, 'optionalAccess', async _140 => _140.pool]);return!Array.isArray(l)||l.length===0?[]:l.map(ua)}var jo=5e3,la=10;async function Xo(t,e="large_buy"){let n=e==="all"?Object.keys(Zn):Array.isArray(e)?e:[e];if(n.length===0)throw new (0, _chunk4Q7UQ5Q3cjs.e)("StockChangeType \u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A\u3002");let r=n.map(a=>{let l=Zn[a];if(!l)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid StockChangeType: ${a}.`);return l}),o=r.length===1?r[0]:"",i=[],s=null;for(let a=0;a<la;a++){let l=new URLSearchParams({pageindex:String(a),pagesize:String(jo),ut:F,dpt:"wzchanges"}),c=`${Se}/getAllStockChanges?type=${r.join(",")}&${l.toString()}`,d=await t.get(c,{responseType:"json"}),m=u(_optionalChain([d, 'optionalAccess', _141 => _141.data, 'optionalAccess', _142 => _142.tc]));m!==null&&(s=m);let p=_optionalChain([d, 'optionalAccess', _143 => _143.data, 'optionalAccess', _144 => _144.allstock]);if(!Array.isArray(p)||p.length===0)break;for(let g of p){let f=String(_nullishCoalesce(g.t, () => (o)));i.push({time:Et(g.tm),code:String(_nullishCoalesce(g.c, () => (""))),name:String(_nullishCoalesce(g.n, () => (""))),typeCode:f,changeType:_nullishCoalesce(Qo[f], () => ("unknown")),changeTypeLabel:_nullishCoalesce(Go[f], () => ("")),info:String(_nullishCoalesce(g.i, () => ("")))})}if(p.length<jo||s!==null&&i.length>=s)break}return i}function Xn(t){let e=_chunkUSZUOBM2cjs.f.call(void 0, t,{market:"CN"});if(e.assetType!=="stock")throw new (0, _chunk4Q7UQ5Q3cjs.e)(`\u4E2A\u80A1\u76D8\u53E3\u5F02\u52A8\u4EC5\u652F\u6301 A \u80A1\u4E2A\u80A1,\u6536\u5230 assetType='${e.assetType}'(symbol=${t})`,{argument:"symbol",value:t,assetType:e.assetType});return e}async function Jo(t,e,n){let r=Xn(e),[o,i]=_chunkUSZUOBM2cjs.j.call(void 0, r).split("."),s=_nullishCoalesce(Wo(n), () => (Vo())),a=b(s),l=new URLSearchParams({ut:F,dpt:"wzchanges",code:i,market:o,date:s}),c=`${Se}/getStockChanges?${l.toString()}`,m=await _asyncOptionalChain([(await t.get(c,{responseType:"json"})), 'optionalAccess', async _145 => _145.data]);if(!m)return{date:a,available:!1,code:r.code,name:"",changes:[]};let g=(Array.isArray(m.data)?m.data:[]).map(T=>{let A=String(_nullishCoalesce(T.t, () => (""))),O=u(T.p);return{time:Et(T.tm),typeCode:A,changeType:_nullishCoalesce(Qo[A], () => ("unknown")),changeTypeLabel:_nullishCoalesce(Go[A], () => ("")),price:O!==null?O/1e3:null,changePercent:u(T.u),info:String(_nullishCoalesce(T.i, () => (""))),v:u(T.v)}}),f=String(_nullishCoalesce(m.d, () => ("")));return{date:/^\d{8}$/.test(f)?b(f):a,available:!0,code:String(_nullishCoalesce(m.c, () => (r.code))),name:String(_nullishCoalesce(m.n, () => (""))),changes:g}}async function ei(t){let e=new URLSearchParams({ut:F,dpt:"wzchanges",pageindex:"0",pagesize:"5000"}),n=`${Se}/getAllBKChanges?${e.toString()}`,o=await _asyncOptionalChain([(await t.get(n,{responseType:"json"})), 'optionalAccess', async _146 => _146.data, 'optionalAccess', async _147 => _147.allbk]);return!Array.isArray(o)||o.length===0?[]:o.map(i=>{let s=_nullishCoalesce(i.ms, () => ({})),a=s.m===0?"\u5927\u7B14\u4E70\u5165":s.m===1?"\u5927\u7B14\u5356\u51FA":"",l={},c=_nullishCoalesce(i.bkdf, () => (i.bkdfdis));if(c&&typeof c=="object")for(let[d,m]of Object.entries(c))l[d]=Number(m)||0;return{name:String(_nullishCoalesce(i.bkn, () => (""))),changePercent:u(i.bkz),mainNetInflow:u(i.bkj),totalChangeCount:u(i.bkc),topStockCode:String(_nullishCoalesce(s.c, () => (""))),topStockName:String(_nullishCoalesce(s.n, () => (""))),topStockDirection:a,changeTypeDistribution:l}})}var ti={"1month":"01","3month":"02","6month":"03","1year":"04"};async function ni(t,e){let n=b(e.startDate),r=b(e.endDate);return P(t,{reportName:"RPT_DAILYBILLBOARD_DETAILSNEW",columns:"SECURITY_CODE,SECUCODE,SECURITY_NAME_ABBR,TRADE_DATE,EXPLAIN,CLOSE_PRICE,CHANGE_RATE,BILLBOARD_NET_AMT,BILLBOARD_BUY_AMT,BILLBOARD_SELL_AMT,BILLBOARD_DEAL_AMT,ACCUM_AMOUNT,DEAL_NET_RATIO,DEAL_AMOUNT_RATIO,TURNOVERRATE,FREE_MARKET_CAP,EXPLANATION,D1_CLOSE_ADJCHRATE,D2_CLOSE_ADJCHRATE,D5_CLOSE_ADJCHRATE,D10_CLOSE_ADJCHRATE",sortColumns:"SECURITY_CODE,TRADE_DATE",sortTypes:"1,-1",pageSize:5e3,filter:`(TRADE_DATE<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(_nullishCoalesce(o.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(o.SECURITY_NAME_ABBR, () => (""))),date:v(o.TRADE_DATE),close:u(o.CLOSE_PRICE),changePercent:u(o.CHANGE_RATE),netBuyAmount:u(o.BILLBOARD_NET_AMT),buyAmount:u(o.BILLBOARD_BUY_AMT),sellAmount:u(o.BILLBOARD_SELL_AMT),dealAmount:u(o.BILLBOARD_DEAL_AMT),totalAmount:u(o.ACCUM_AMOUNT),netBuyRatio:u(o.DEAL_NET_RATIO),dealAmountRatio:u(o.DEAL_AMOUNT_RATIO),turnoverRate:u(o.TURNOVERRATE),floatMarketValue:u(o.FREE_MARKET_CAP),reason:String(_nullishCoalesce(_nullishCoalesce(o.EXPLANATION, () => (o.EXPLAIN)), () => (""))),afterChange1d:u(o.D1_CLOSE_ADJCHRATE),afterChange2d:u(o.D2_CLOSE_ADJCHRATE),afterChange5d:u(o.D5_CLOSE_ADJCHRATE),afterChange10d:u(o.D10_CLOSE_ADJCHRATE)}))}async function ri(t,e="1month"){let n=ti[e];if(!n)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid period: ${e}.`);return P(t,{reportName:"RPT_BILLBOARD_TRADEALL",columns:"ALL",sortColumns:"BILLBOARD_TIMES,LATEST_TDATE,SECURITY_CODE",sortTypes:"-1,-1,1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(_nullishCoalesce(r.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(r.SECURITY_NAME_ABBR, () => (""))),latestDate:v(r.LATEST_TDATE),close:u(r.CLOSE_PRICE),changePercent:u(r.CHANGE_RATE),count:u(r.BILLBOARD_TIMES),totalBuyAmount:u(r.BILLBOARD_BUY_AMT),totalSellAmount:u(r.BILLBOARD_SELL_AMT),totalNetAmount:u(r.BILLBOARD_NET_AMT),totalDealAmount:u(r.BILLBOARD_DEAL_AMT),buyOrgCount:u(r.ORG_BUY_TIMES),sellOrgCount:u(r.ORG_SELL_TIMES)}))}async function oi(t,e){let n=b(e.startDate),r=b(e.endDate);return P(t,{reportName:"RPT_ORGANIZATION_TRADE_DETAILS",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:`(TRADE_DATE<='${r}')(TRADE_DATE>='${n}')`},o=>({code:String(_nullishCoalesce(o.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(o.SECURITY_NAME_ABBR, () => (""))),date:v(o.TRADE_DATE),close:u(o.CLOSE_PRICE),changePercent:u(o.CHANGE_RATE),buyOrgCount:u(o.BUY_TIMES),sellOrgCount:u(o.SELL_TIMES),orgBuyAmount:u(o.BUY_AMT),orgSellAmount:u(o.SELL_AMT),orgNetAmount:u(o.NET_AMT)}))}async function ii(t,e="1month"){let n=ti[e];if(!n)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Invalid period: ${e}.`);return P(t,{reportName:"RPT_BILLBOARD_TRADEDETAILS",columns:"ALL",sortColumns:"TOTAL_BUYER_SALESTIMES",sortTypes:"-1",pageSize:5e3,filter:`(STATISTICS_CYCLE="${n}")`},r=>({code:String(_nullishCoalesce(r.OPERATEDEPT_CODE, () => (""))),name:String(_nullishCoalesce(r.OPERATEDEPT_NAME, () => (""))),totalBuyAmount:u(_nullishCoalesce(r.TOTAL_BUYAMT, () => (r.BUY_AMT))),totalSellAmount:u(_nullishCoalesce(r.TOTAL_SELLAMT, () => (r.SELL_AMT))),buyCount:u(_nullishCoalesce(r.TOTAL_BUYER_SALESTIMES, () => (r.BUY_TIMES))),sellCount:u(_nullishCoalesce(r.TOTAL_SELLER_SALESTIMES, () => (r.SELL_TIMES))),totalCount:u(r.TOTAL_TIMES)}))}async function si(t,e,n){let r=_chunkUSZUOBM2cjs.k.call(void 0, _chunkUSZUOBM2cjs.f.call(void 0, e,{market:"CN"})),o=b(n),i=`(SECURITY_CODE="${r}")(TRADE_DATE='${o}')`,[s,a]=await Promise.all([P(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSBUY",columns:"ALL",sortColumns:"BUY_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:_nullishCoalesce(u(l.RANK), () => (c+1)),branchName:String(_nullishCoalesce(l.OPERATEDEPT_NAME, () => (""))),buyAmount:u(_nullishCoalesce(l.BUY_AMT_REAL, () => (l.BUY_AMT))),buyAmountRatio:u(_nullishCoalesce(l.BUY_RATIO_TOTAL, () => (l.BUY_AMT_RATIO))),sellAmount:u(_nullishCoalesce(l.SELL_AMT_REAL, () => (l.SELL_AMT))),sellAmountRatio:u(_nullishCoalesce(l.SELL_RATIO_TOTAL, () => (l.SELL_AMT_RATIO))),netAmount:u(l.NET_AMT),side:"buy"})),P(t,{reportName:"RPT_BILLBOARD_DAILYDETAILSSELL",columns:"ALL",sortColumns:"SELL_AMT_REAL",sortTypes:"-1",pageSize:100,filter:i},(l,c)=>({rank:_nullishCoalesce(u(l.RANK), () => (c+1)),branchName:String(_nullishCoalesce(l.OPERATEDEPT_NAME, () => (""))),buyAmount:u(_nullishCoalesce(l.BUY_AMT_REAL, () => (l.BUY_AMT))),buyAmountRatio:u(_nullishCoalesce(l.BUY_RATIO_TOTAL, () => (l.BUY_AMT_RATIO))),sellAmount:u(_nullishCoalesce(l.SELL_AMT_REAL, () => (l.SELL_AMT))),sellAmountRatio:u(_nullishCoalesce(l.SELL_RATIO_TOTAL, () => (l.SELL_AMT_RATIO))),netAmount:u(l.NET_AMT),side:"sell"}))]);return[...s,...a]}function ai(t){if(!t)return"";let e=t.startDate?b(t.startDate):void 0,n=t.endDate?b(t.endDate):void 0,r=[];return e&&r.push(`(TRADE_DATE>='${e}')`),n&&r.push(`(TRADE_DATE<='${n}')`),r.join("")}async function ui(t){return P(t,{reportName:"PRT_BLOCKTRADE_MARKET_STA",columns:"ALL",sortColumns:"TRADE_DATE",sortTypes:"-1",pageSize:500},e=>({date:v(e.TRADE_DATE),shClose:u(_nullishCoalesce(e.CLOSE_PRICE, () => (e.SH_CLOSE_PRICE))),shChangePercent:u(_nullishCoalesce(e.CHANGE_RATE, () => (e.SH_CHANGE_RATE))),totalAmount:u(_nullishCoalesce(e.TURNOVER, () => (e.TOTAL_AMOUNT))),premiumAmount:u(_nullishCoalesce(e.PREMIUM_TURNOVER, () => (e.PREMIUM_AMOUNT))),premiumRatio:u(e.PREMIUM_RATIO),discountAmount:u(_nullishCoalesce(e.DISCOUNT_TURNOVER, () => (e.DISCOUNT_AMOUNT))),discountRatio:u(e.DISCOUNT_RATIO)}))}async function li(t,e={}){let n=ai(e);return P(t,{reportName:"RPT_BLOCK_TRADE_DETAIL",columns:"ALL",sortColumns:"TRADE_DATE,SECURITY_CODE",sortTypes:"-1,1",pageSize:5e3,filter:n||void 0},r=>({code:String(_nullishCoalesce(r.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(r.SECURITY_NAME_ABBR, () => (""))),date:v(r.TRADE_DATE),close:u(r.CLOSE_PRICE),changePercent:u(r.CHANGE_RATE),dealPrice:u(_nullishCoalesce(r.DEAL_PRICE, () => (r.PRICE))),dealVolume:u(_nullishCoalesce(r.DEAL_VOLUME, () => (r.VOLUME))),dealAmount:u(_nullishCoalesce(r.DEAL_AMT, () => (r.TURNOVER))),premiumRate:u(_nullishCoalesce(r.PREMIUM_RATIO, () => (r.PREMIUM_RATE))),buyBranch:String(_nullishCoalesce(_nullishCoalesce(r.BUYER_DEPT, () => (r.BUYER_OPERATEDEPT_NAME)), () => (""))),sellBranch:String(_nullishCoalesce(_nullishCoalesce(r.SELLER_DEPT, () => (r.SELLER_OPERATEDEPT_NAME)), () => ("")))}))}async function ci(t,e={}){let n=ai(e);return P(t,{reportName:"RPT_BLOCK_TRADE_STA",columns:"ALL",sortColumns:"TRADE_DATE,DEAL_AMT",sortTypes:"-1,-1",pageSize:5e3,filter:n||void 0},r=>({code:String(_nullishCoalesce(r.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(r.SECURITY_NAME_ABBR, () => (""))),date:v(r.TRADE_DATE),changePercent:u(r.CHANGE_RATE),close:u(r.CLOSE_PRICE),dealCount:u(_nullishCoalesce(r.DEAL_NUM, () => (r.DEAL_COUNT))),dealTotalAmount:u(_nullishCoalesce(r.DEAL_AMT, () => (r.TOTAL_AMOUNT))),dealTotalVolume:u(_nullishCoalesce(r.DEAL_VOLUME, () => (r.TOTAL_VOLUME))),premiumAmount:u(_nullishCoalesce(r.PREMIUM_AMT, () => (r.PREMIUM_AMOUNT))),discountAmount:u(_nullishCoalesce(r.DISCOUNT_AMT, () => (r.DISCOUNT_AMOUNT)))}))}async function di(t){return P(t,{reportName:"RPTA_WEB_MARGIN_DAILYTRADE",columns:"ALL",sortColumns:"STATISTICS_DATE",sortTypes:"-1",pageSize:500},e=>({date:v(_nullishCoalesce(e.STATISTICS_DATE, () => (e.TRADE_DATE))),finBalance:u(e.FIN_BALANCE),loanBalance:u(e.LOAN_BALANCE),finBuyAmount:u(e.FIN_BUY_AMT),loanSellAmount:u(e.LOAN_SELL_AMT),investorCount:u(_nullishCoalesce(e.OPERATE_INVESTOR_NUM, () => (e.INVESTOR_NUM))),liabilityInvestorCount:u(e.MARGIN_INVESTOR_NUM),totalGuarantee:u(e.TOTAL_GUARANTEE),avgGuaranteeRatio:u(e.AVG_GUARANTEE_RATIO)}))}async function pi(t,e){let n=e?`(TRADE_DATE='${b(e)}')`:void 0;return P(t,{reportName:"RPT_MARGIN_TRADE_DETAIL",columns:"ALL",sortColumns:"FIN_BALANCE",sortTypes:"-1",pageSize:5e3,filter:n},r=>({code:String(_nullishCoalesce(r.SECURITY_CODE, () => (""))),name:String(_nullishCoalesce(r.SECURITY_NAME_ABBR, () => (""))),date:v(r.TRADE_DATE),finBalance:u(r.FIN_BALANCE),finBuyAmount:u(r.FIN_BUY_AMT),finRepayAmount:u(r.FIN_REPAY_AMT),loanBalance:u(r.LOAN_BALANCE),loanSellVolume:u(r.LOAN_SELL_VOLUME),loanRepayVolume:u(r.LOAN_REPAY_VOLUME)}))}var Jn="https://fundmobapi.eastmoney.com/FundMNewApi",er={plat:"Android",appType:"ttjj",product:"EFund",Version:"1",deviceid:"stock-sdk"};async function mi(t,e={}){let n=_nullishCoalesce(e.sort, () => ("ZDF")),r=_nullishCoalesce(e.order, () => ("desc")),o=_nullishCoalesce(e.category, () => ("2")),i=_nullishCoalesce(e.pageSize, () => (20)),s=_nullishCoalesce(e.page, () => (1)),a=new URLSearchParams({...er,RankItems:n,RankVectors:r,category:o,pageSize:String(i),page:String(s)}),l=`${Jn}/FundMNSubjectList?${a.toString()}`,c=await t.get(l,{provider:"eastmoney",responseType:"json"}),d=_nullishCoalesce(c.Data, () => ([])),m=_nullishCoalesce(c.pageinfo, () => ({totalPages:0,pageSize:i,page:s}));return{items:d.map(g=>({code:_nullishCoalesce(g.code, () => ("")),name:_nullishCoalesce(g.name, () => ("")),dailyChange:_(g.ZDF),weeklyReturn:_(g.SYL_W),monthlyReturn:_(g.SYL_M),quarterlyReturn:_(g.SYL_3M),halfYearReturn:_(g.SYL_6M),yearlyReturn:_(g.SYL_Y),threeYearReturn:_(g.SYL_3Y),fiveYearReturn:_(g.SYL_5Y),type:g.isIndustry===1?"\u884C\u4E1A":g.isIndustry===0?"\u6982\u5FF5":"\u884C\u4E1A"})),totalPages:_nullishCoalesce(m.totalPages, () => (0)),pageSize:_nullishCoalesce(m.pageSize, () => (i)),currentPage:_nullishCoalesce(m.page, () => (s))}}async function gi(t,e={}){let n=_nullishCoalesce(e.sort, () => ("ZDF")),r=_nullishCoalesce(e.order, () => ("desc")),o=_nullishCoalesce(e.category, () => ("2")),i=_nullishCoalesce(e.limit, () => (20)),s=new URLSearchParams({...er,RankItems:n,RankVectors:r,category:o,limit:String(i)}),a=`${Jn}/FundThemeList?${s.toString()}`;return(await _asyncNullishCoalesce((await t.get(a,{provider:"eastmoney",responseType:"json"})).Data, async () => ([]))).map(d=>({code:_nullishCoalesce(d.code, () => ("")),name:_nullishCoalesce(d.name, () => ("")),dailyChange:_(d.ZDF),weeklyReturn:_(d.SYL_W),monthlyReturn:_(d.SYL_M),quarterlyReturn:_(d.SYL_3M),halfYearReturn:_(d.SYL_6M),yearlyReturn:_(d.SYL_Y),threeYearReturn:_(d.SYL_3Y),fiveYearReturn:_(d.SYL_5Y),type:d.isIndustry===1?"\u884C\u4E1A":d.isIndustry===0?"\u6982\u5FF5":"\u884C\u4E1A"}))}async function fi(t,e,n={}){let r=_nullishCoalesce(n.sortColumn, () => ("SYL_1N")),o=_nullishCoalesce(n.sort, () => ("desc")),i=_nullishCoalesce(n.page, () => (1)),s=_nullishCoalesce(n.pageSize, () => (20)),a=_nullishCoalesce(n.fundType, () => ("")),l=new URLSearchParams({...er,TOPICAL:e,SortColumn:r,Sort:o,pageIndex:String(i),pageSize:String(s),FundType:a}),c=`${Jn}/FundMNRank?${l.toString()}`,d=await t.get(c,{provider:"eastmoney",responseType:"json"}),m=_nullishCoalesce(d.Data, () => ([])),p=_nullishCoalesce(d.fundinfo, () => ({total:0,pagesize:s,pageindex:i}));return{items:m.map(f=>({code:_nullishCoalesce(f.fscode, () => ("")),name:_nullishCoalesce(f.abname, () => ("")),fundType:_nullishCoalesce(f.ftype, () => ("")),dailyChange:_(f.ZDF),weeklyReturn:_(f.SYL_Z),monthlyReturn:_(f.SYL_Y),quarterlyReturn:_(f.SYL_3Y),yearlyReturn:_(f.SYL_1N),nav:_(f.dwjz),themeCode:e})),total:_nullishCoalesce(p.total, () => (0)),pageIndex:_nullishCoalesce(p.pageindex, () => (i)),pageSize:_nullishCoalesce(p.pagesize, () => (s))}}var Y={};_chunk4VDLQK6Fcjs.a.call(void 0, Y,{getCommodityOptionKline:()=>Oi,getCommodityOptionSpot:()=>Ai,getETFOption5DayMinute:()=>Ci,getETFOptionDailyKline:()=>_i,getETFOptionExpireDay:()=>Si,getETFOptionMinute:()=>Ei,getETFOptionMonths:()=>Ti,getIndexOptionKline:()=>hi,getIndexOptionSpot:()=>yi});function ca(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:u(t[7]),symbol:_nullishCoalesce(t[8], () => (""))}}function da(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:null,symbol:_nullishCoalesce(t[7], () => (""))}}async function yi(t,e){let n=`${Me}?type=futures&product=${t}&exchange=cffex&pinzhong=${e}`,r=await x(n),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _148 => _148.result, 'optionalAccess', _149 => _149.data, 'optionalAccess', _150 => _150.up]), () => ([])),i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _151 => _151.result, 'optionalAccess', _152 => _152.data, 'optionalAccess', _153 => _153.down]), () => ([]));return{calls:o.map(ca),puts:i.map(da)}}async function hi(t){let e=`${ke}?symbol=${t}`,n=await x(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:u(r.o),high:u(r.h),low:u(r.l),close:u(r.c),volume:u(r.v)})):[]}async function Ti(t){let e=`${un}?exchange=null&cate=${encodeURIComponent(t)}`,r=await _asyncOptionalChain([(await x(e)), 'optionalAccess', async _154 => _154.result, 'optionalAccess', async _155 => _155.data]),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _156 => _156.contractMonth]), () => ([]));return{months:o.length>1?o.slice(1):o,stockId:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _157 => _157.stockId]), () => ("")),cateId:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _158 => _158.cateId]), () => ("")),cateList:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _159 => _159.cateList]), () => ([]))}}async function Si(t,e){let n=`${lt}?exchange=null&cate=${encodeURIComponent(t)}&date=${e}`,r=await x(n),o=_optionalChain([r, 'optionalAccess', _160 => _160.result, 'optionalAccess', _161 => _161.data, 'optionalAccess', _162 => _162.remainderDays]);if(typeof o=="number"&&o<0){let s=`${lt}?exchange=null&cate=${encodeURIComponent("XD"+t)}&date=${e}`;r=await x(s)}let i=_optionalChain([r, 'optionalAccess', _163 => _163.result, 'optionalAccess', _164 => _164.data]);return{expireDay:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _165 => _165.expireDay]), () => ("")),remainderDays:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _166 => _166.remainderDays]), () => (0)),stockId:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _167 => _167.stockId]), () => ("")),name:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _168 => _168.other, 'optionalAccess', _169 => _169.name]), () => (""))}}function Ri(t){let e="";return t.map(n=>(n.d&&(e=n.d),{time:n.i,date:e,price:u(n.p),volume:u(n.v),openInterest:u(n.t),avgPrice:u(n.a)}))}async function Ei(t){let e=`CON_OP_${t}`,n=`${ln}?symbol=${e}`,o=await _asyncOptionalChain([(await x(n)), 'optionalAccess', async _170 => _170.result, 'optionalAccess', async _171 => _171.data]);return Array.isArray(o)?Ri(o):[]}async function _i(t){let e=`CON_OP_${t}`,n=`${cn}?symbol=${e}`,r=await x(n,{callbackMode:"path"});return Array.isArray(r)?r.map(o=>({date:o.d,open:u(o.o),high:u(o.h),low:u(o.l),close:u(o.c),volume:u(o.v)})):[]}async function Ci(t){let e=`CON_OP_${t}`,n=`${dn}?symbol=${e}`,o=await _asyncOptionalChain([(await x(n)), 'optionalAccess', async _172 => _172.result, 'optionalAccess', async _173 => _173.data]);if(!Array.isArray(o))return[];let i=[];for(let s of o)Array.isArray(s)&&i.push(...Ri(s));return i}function pa(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:u(t[7]),symbol:_nullishCoalesce(t[8], () => (""))}}function ma(t){return{buyVolume:u(t[0]),buyPrice:u(t[1]),price:u(t[2]),askPrice:u(t[3]),askVolume:u(t[4]),openInterest:u(t[5]),change:u(t[6]),strikePrice:null,symbol:_nullishCoalesce(t[7], () => (""))}}async function Ai(t,e){let n=ct[t];if(!n)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`Unknown commodity option variety: "${t}". Available: ${Object.keys(ct).join(", ")}`);let r=`${Me}?type=futures&product=${n.product}&exchange=${n.exchange}&pinzhong=${e}`,o=await x(r),i=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _174 => _174.result, 'optionalAccess', _175 => _175.data, 'optionalAccess', _176 => _176.up]), () => ([])),s=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _177 => _177.result, 'optionalAccess', _178 => _178.data, 'optionalAccess', _179 => _179.down]), () => ([]));return{calls:i.map(pa),puts:s.map(ma)}}async function Oi(t){let e=`${ke}?symbol=${t}`,n=await x(e,{callbackMode:"path"});return Array.isArray(n)?n.map(r=>({date:r.d,open:u(r.o),high:u(r.h),low:u(r.l),close:u(r.c),volume:u(r.v)})):[]}var N=class{constructor(e){this.client=e}};var qe=class extends N{constructor(n){super(n);this.theme=new tr(this.client)}getFundDividendList(n){return y.getFundDividendList(this.client,n)}getFundNavHistory(n){return y.getFundNavHistory(this.client,n)}getFundEstimate(n){return y.getFundEstimate(this.client,n)}getFundRankHistory(n){return y.getFundRankHistory(this.client,n)}getFundProfile(n){return y.getFundProfile(this.client,n)}},tr=class{constructor(e){this.client=e}getThemeList(e){return y.getThemeList(this.client,e)}getThemeFunds(e,n){return y.getThemeFunds(this.client,e,n)}};var ze=class extends N{constructor(e){super(e)}getFullQuotes(e){return M.getFullQuotes(this.client,e)}getSimpleQuotes(e){return M.getSimpleQuotes(this.client,e)}getHKQuotes(e){return M.getHKQuotes(this.client,e)}getUSQuotes(e){return M.getUSQuotes(this.client,e)}getFundQuotes(e){return M.getFundQuotes(this.client,e)}getFundFlow(e){return M.getFundFlow(this.client,e)}getPanelLargeOrder(e){return M.getPanelLargeOrder(this.client,e)}getTodayTimeline(e){return M.getTodayTimeline(this.client,e)}search(e){return M.search(this.client,e)}getAShareCodeList(e){return M.getAShareCodeList(this.client,e)}getUSCodeList(e){return M.getUSCodeList(this.client,e)}getHKCodeList(){return M.getHKCodeList(this.client)}getFundCodeList(){return M.getFundCodeList(this.client)}async getAllAShareQuotes(e={}){let{market:n,...r}=e,o=await this.getAShareCodeList({market:n});return M.getAllQuotesByCodes(this.client,o,r)}async getAllHKShareQuotes(e={}){let n=await this.getHKCodeList();return M.getAllHKQuotesByCodes(this.client,n,e)}async getAllUSShareQuotes(e={}){let{market:n,...r}=e,o=await this.getUSCodeList({simple:!0,market:n});return M.getAllUSQuotesByCodes(this.client,o,r)}getAllQuotesByCodes(e,n={}){return M.getAllQuotesByCodes(this.client,e,n)}batchRaw(e){return this.client.getTencentQuote(e)}getTradingCalendar(){return M.getTradingCalendar(this.client)}getDividendDetail(e){return y.getDividendDetail(this.client,e)}};var $e=class extends N{constructor(e){super(e)}getIndustryList(){return y.getIndustryList(this.client)}getIndustrySpot(e){return y.getIndustrySpot(this.client,e)}getIndustryConstituents(e){return y.getIndustryConstituents(this.client,e)}getIndustryKline(e,n){return y.getIndustryKline(this.client,e,n)}getIndustryMinuteKline(e,n){return y.getIndustryMinuteKline(this.client,e,n)}getConceptList(){return y.getConceptList(this.client)}getConceptSpot(e){return y.getConceptSpot(this.client,e)}getConceptConstituents(e){return y.getConceptConstituents(this.client,e)}getConceptKline(e,n){return y.getConceptKline(this.client,e,n)}getConceptMinuteKline(e,n){return y.getConceptMinuteKline(this.client,e,n)}};var Ye=class extends N{constructor(e){super(e)}getHistoryKline(e,n){return y.getHistoryKline(this.client,e,n)}getMinuteKline(e,n){return y.getMinuteKline(this.client,e,n)}getHKHistoryKline(e,n){return y.getHKHistoryKline(this.client,e,n)}getHKMinuteKline(e,n){return y.getHKMinuteKline(this.client,e,n)}getUSHistoryKline(e,n){return y.getUSHistoryKline(this.client,e,n)}getUSMinuteKline(e,n){return y.getUSMinuteKline(this.client,e,n)}};var je=class extends N{constructor(e){super(e)}getFuturesKline(e,n){return y.getFuturesHistoryKline(this.client,e,n)}getGlobalFuturesSpot(e){return y.getGlobalFuturesSpot(this.client,e)}getGlobalFuturesKline(e,n){return y.getGlobalFuturesKline(this.client,e,n)}getFuturesInventorySymbols(){return y.getFuturesInventorySymbols(this.client)}getFuturesInventory(e,n){return y.getFuturesInventory(this.client,e,n)}getComexInventory(e,n){return y.getComexInventory(this.client,e,n)}};var Qe=class extends N{constructor(e){super(e)}getIndexOptionSpot(e,n){return Y.getIndexOptionSpot(e,n)}getIndexOptionKline(e){return Y.getIndexOptionKline(e)}getCFFEXOptionQuotes(e){return y.getCFFEXOptionQuotes(this.client,e)}getETFOptionMonths(e){return Y.getETFOptionMonths(e)}getETFOptionExpireDay(e,n){return Y.getETFOptionExpireDay(e,n)}getETFOptionMinute(e){return Y.getETFOptionMinute(e)}getETFOptionDailyKline(e){return Y.getETFOptionDailyKline(e)}getETFOption5DayMinute(e){return Y.getETFOption5DayMinute(e)}getCommodityOptionSpot(e,n){return Y.getCommodityOptionSpot(e,n)}getCommodityOptionKline(e){return Y.getCommodityOptionKline(e)}getOptionLHB(e,n){return y.getOptionLHB(this.client,e,n)}};var ga=500,fa=15,Ge=class{constructor(e,n){this.klineService=e;this.quoteService=n}detectMarket(e){let n=_chunkUSZUOBM2cjs.g.call(void 0, e);if(n==="GLOBAL")throw new (0, _chunk4Q7UQ5Q3cjs.e)(`No kline route for GLOBAL-market symbol '${e}'; use the US kline API with a raw secid instead (e.g. kline.us('100.GDAXI'))`);return n==="HK"?"HK":n==="US"?"US":"A"}calcActualStartDate(e,n,r=1.5){let o=this.toCompactDate(e),i=Math.ceil(n*r),s=new Date(parseInt(o.slice(0,4)),parseInt(o.slice(4,6))-1,parseInt(o.slice(6,8)));s.setDate(s.getDate()-i);let a=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),c=String(s.getDate()).padStart(2,"0");return`${a}${l}${c}`}calcActualStartDateByCalendar(e,n,r){if(!r||r.length===0)return;let o=r.findIndex(s=>s>=e);o===-1&&(o=r.length-1);let i=Math.max(0,o-n);return this.toCompactDate(r[i])}tryNormalizeDate(e){let n=e.trim();return/^\d{4}-\d{2}-\d{2}/.test(n)?n.slice(0,10):/^\d{8}$/.test(n)?`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`:null}normalizeUserDate(e){let n=this.tryNormalizeDate(e);if(n===null)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`\u65E5\u671F\u683C\u5F0F\u5E94\u4E3A 'YYYY-MM-DD' \u6216 'YYYYMMDD',\u5F97\u5230 '${e}'`,{argument:"date",value:e});return n}normalizeRowDate(e){return _nullishCoalesce(this.tryNormalizeDate(e), () => (e))}toCompactDate(e){return e.replace(/-/g,"")}async getKlineWithIndicators(e,n={}){let{indicators:r={}}=n,o=n.startDate?this.normalizeUserDate(n.startDate):void 0,i=n.endDate?this.normalizeUserDate(n.endDate):void 0,s=_nullishCoalesce(n.market, () => (this.detectMarket(e))),{requiredBars:a,maxRecursiveLookback:l}=_chunkR7M3BHS4cjs.w.call(void 0, r),c={A:1.5,HK:1.46,US:1.45},d,m=_nullishCoalesce(n.period, () => ("daily")),p=m==="weekly"?7.5:m==="monthly"?31.5:c[s],g=m==="weekly"?5:m==="monthly"?21:1;if(o)if(s==="A")try{let L=await this.quoteService.getTradingCalendar();d=_nullishCoalesce(this.calcActualStartDateByCalendar(o,a*g,L), () => (this.calcActualStartDate(o,a,p)))}catch (e14){d=this.calcActualStartDate(o,a,p)}else d=this.calcActualStartDate(o,a,p);let f={period:n.period,adjust:n.adjust,startDate:d,endDate:i?this.toCompactDate(i):void 0},R;switch(s){case"HK":R=await this.klineService.getHKHistoryKline(e,f);break;case"US":R=await this.klineService.getUSHistoryKline(e,f);break;default:R=await this.klineService.getHistoryKline(e,f)}let T=30+(m==="weekly"?7:m==="monthly"?31:0),A=R.length===0||d===void 0||this.normalizeRowDate(R[0].date)<=ne(this.normalizeRowDate(d),T),O=!1;if(o&&R.length<a&&A)switch(O=!0,s){case"HK":R=await this.klineService.getHKHistoryKline(e,{...f,startDate:void 0});break;case"US":R=await this.klineService.getUSHistoryKline(e,{...f,startDate:void 0});break;default:R=await this.klineService.getHistoryKline(e,{...f,startDate:void 0})}if(o){let L=R.findIndex(V=>this.normalizeRowDate(V.date)>=o);if(L===-1)return[];let re=R,_e=L;if(O&&!_chunkR7M3BHS4cjs.u.call(void 0, r)){let V=l>0?Math.max(a,ga,fa*l):a,oe=Math.max(0,L-V);re=R.slice(oe),_e=L-oe}let ge=Number.isInteger(n.leadingBars)&&n.leadingBars>0?n.leadingBars:0;if(ge>0){let V=_chunkR7M3BHS4cjs.x.call(void 0, re,r),oe=Math.max(0,_e-ge),Z=V.slice(oe);return i===void 0?Z:Z.filter(U=>this.normalizeRowDate(U.date)<=i)}return _chunkR7M3BHS4cjs.x.call(void 0, re,r).filter(V=>{let oe=this.normalizeRowDate(V.date);return oe>=o&&(i===void 0||oe<=i)})}return _chunkR7M3BHS4cjs.x.call(void 0, R,r)}async getKlineSignals(e,n={}){let r=_nullishCoalesce(n.maFast, () => (5)),o=_nullishCoalesce(n.maSlow, () => (20));if(!Number.isInteger(r)||!Number.isInteger(o)||r<=0||o<=0)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`maFast / maSlow \u5FC5\u987B\u4E3A\u6B63\u6574\u6570\uFF0C\u5F97\u5230 fast=${r} slow=${o}`,{maFast:r,maSlow:o});if(r>=o)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`maFast(${r}) \u5FC5\u987B\u5C0F\u4E8E maSlow(${o})\uFF0C\u5426\u5219\u65E0\u6CD5\u5B9A\u4E49\u91D1\u53C9/\u6B7B\u53C9`,{maFast:r,maSlow:o});let i=n.startDate?this.normalizeUserDate(n.startDate):void 0,s=await this.getKlineWithIndicators(e,{market:n.market,period:n.period,adjust:n.adjust,startDate:n.startDate,endDate:n.endDate,leadingBars:i?1:0,indicators:{ma:{periods:[r,o]},macd:!0,kdj:!0,rsi:{periods:[6]},boll:!0,sar:!0}}),l=_chunkSR7FGCVZcjs.a.call(void 0, s,{ma:{fast:r,slow:o},macd:!0,kdj:{},rsi:{period:6},boll:!0,sar:!0}).map(c=>{let d=s[c.index];return{type:c.type,date:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _180 => _180.date]), () => ("")),timestamp:c.at,close:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _181 => _181.close]), () => (null)),...c.detail!==void 0?{detail:c.detail}:{}}});return i?l.filter(c=>this.normalizeRowDate(c.date)>=i):l}};var ya=1.5,ha=30,We=class{constructor(e){this.klineService=e}getChipDistribution(e,n={}){return this.compute("A",e,n)}getHKChipDistribution(e,n={}){return this.compute("HK",e,n)}getUSChipDistribution(e,n={}){return this.compute("US",e,n)}async compute(e,n,r){let{days:o=90,range:i=120,adjust:s,includeHistogram:a,decimals:l}=r;if(!Number.isInteger(o)||o<1)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`days \u5E94\u4E3A\u6B63\u6574\u6570,\u5F97\u5230 ${JSON.stringify(o)}`,{argument:"days",value:o});if(!Number.isInteger(i)||i<0)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`range \u5E94\u4E3A\u975E\u8D1F\u6574\u6570(0 = \u5168\u91CF\u7D2F\u8BA1),\u5F97\u5230 ${JSON.stringify(i)}`,{argument:"range",value:i});let c=await this.fetchDailyKlines(e,n,s,o,i);return c.length===0?[]:_chunkR7M3BHS4cjs.r.call(void 0, c,{range:i,tail:o,includeHistogram:a,decimals:l})}async fetchDailyKlines(e,n,r,o,i){let s=f=>{let R={period:"daily",adjust:r,startDate:f};switch(e){case"HK":return this.klineService.getHKHistoryKline(n,R);case"US":return this.klineService.getUSHistoryKline(n,R);default:return this.klineService.getHistoryKline(n,R)}};if(i===0)return s(void 0);let a={A:C.CN,HK:C.HK,US:C.US},l=o+i,c=K(a[e]),d=ne(c,-Math.ceil(l*ya)),m=d.replace(/-/g,""),p=await s(m),g=p.length===0||p[0].date<=ne(d,ha);return p.length<l&&g&&(p=await s(void 0)),p}};var Ve=class extends N{constructor(e){super(e)}getIndividualFundFlow(e,n){return y.getIndividualFundFlow(this.client,e,n)}getMarketFundFlow(){return y.getMarketFundFlow(this.client)}getFundFlowRank(e){return y.getFundFlowRank(this.client,e)}getSectorFundFlowRank(e){return y.getSectorFundFlowRank(this.client,e)}getSectorFundFlowHistory(e,n){return y.getSectorFundFlowHistory(this.client,e,n)}};var Ze=class extends N{constructor(e){super(e)}getNorthboundMinute(e){return y.getNorthboundMinute(this.client,e)}getNorthboundFlowSummary(){return y.getNorthboundFlowSummary(this.client)}getNorthboundHoldingRank(e){return y.getNorthboundHoldingRank(this.client,e)}getNorthboundHistory(e,n){return y.getNorthboundHistory(this.client,e,n)}getNorthboundIndividual(e,n){return y.getNorthboundIndividual(this.client,e,n)}};var Ta=4,Xe=class extends N{constructor(n,r){super(n);this.quoteService=r}getZTPool(n,r){return y.getZTPool(this.client,n,r)}getStockChanges(n){return y.getStockChanges(this.client,n)}getBoardChanges(){return y.getBoardChanges(this.client)}async getIndividualChanges(n,r={}){return(await y.getIndividualStockChanges(this.client,n,r.date)).changes}async getIndividualChangesHistory(n,r={}){let{days:o=7}=r;if(!Number.isInteger(o)||o<1||o>60)throw new (0, _chunk4Q7UQ5Q3cjs.e)(`days \u5E94\u4E3A 1~60 \u7684\u6574\u6570,\u5F97\u5230 ${JSON.stringify(o)}`,{argument:"days",value:o});let i=y.assertCnStockSymbol(n),s=K(C.CN),a=ne(s,-(o-1)),c=(await this.quoteService.getTradingCalendar()).filter(T=>T>=a&&T<=s),m=(await se(c.map(T=>()=>y.getIndividualStockChanges(this.client,n,T)),Ta,!0)).map((T,A)=>T.date===c[A]?T:{date:c[A],available:!1,code:T.code,name:"",changes:[]}),p=m.filter(T=>T.available),g=Object.create(null);for(let T of p)for(let A of T.changes){let O=A.typeCode||"unknown",L=_nullishCoalesce(g[O], () => ((g[O]={count:0,label:A.changeTypeLabel})));L.count+=1}let f=p.find(T=>T.name),R=_nullishCoalesce(_optionalChain([m, 'access', _182 => _182[0], 'optionalAccess', _183 => _183.code]), () => (i.code));return{code:_nullishCoalesce(_optionalChain([f, 'optionalAccess', _184 => _184.code]), () => (R)),name:_nullishCoalesce(_optionalChain([f, 'optionalAccess', _185 => _185.name]), () => ("")),requestedDays:o,coverage:{from:a,to:s,availableFrom:_nullishCoalesce(_optionalChain([p, 'access', _186 => _186[0], 'optionalAccess', _187 => _187.date]), () => (null))},days:m,stats:g}}};var Je=class extends N{constructor(e){super(e)}getDragonTigerDetail(e){return y.getDragonTigerDetail(this.client,e)}getDragonTigerStockStats(e){return y.getDragonTigerStockStats(this.client,e)}getDragonTigerInstitution(e){return y.getDragonTigerInstitution(this.client,e)}getDragonTigerBranchRank(e){return y.getDragonTigerBranchRank(this.client,e)}getDragonTigerStockSeatDetail(e,n){return y.getDragonTigerStockSeatDetail(this.client,e,n)}};var et=class extends N{constructor(e){super(e)}getBlockTradeMarketStat(){return y.getBlockTradeMarketStat(this.client)}getBlockTradeDetail(e){return y.getBlockTradeDetail(this.client,e)}getBlockTradeDailyStat(e){return y.getBlockTradeDailyStat(this.client,e)}getMarginAccountInfo(){return y.getMarginAccountInfo(this.client)}getMarginTargetList(e){return y.getMarginTargetList(this.client,e)}};var nr=class{constructor(e={}){this._ns={};this.client=new ve(e),this.quoteService=new ze(this.client),this.boardService=new $e(this.client),this.klineService=new Ye(this.client),this.futuresService=new je(this.client),this.optionsService=new Qe(this.client),this.indicatorService=new Ge(this.klineService,this.quoteService),this.chipService=new We(this.klineService),this.fundFlowService=new Ve(this.client),this.northboundService=new Ze(this.client),this.marketEventService=new Xe(this.client,this.quoteService),this.dragonTigerService=new Je(this.client),this.dataService=new et(this.client),this.tradingCalendarService=new Ue(this.quoteService),this.fundService=new qe(this.client)}clearCaches(){_chunk6MCPZDKNcjs.f.call(void 0, this.client)}memoNs(e,n){let r=this._ns[e];return r===void 0&&(r=n(),this._ns[e]=r),r}get quotes(){return this.memoNs("quotes",()=>{let e=this.quoteService;return{cn:e.getFullQuotes.bind(e),cnSimple:e.getSimpleQuotes.bind(e),hk:e.getHKQuotes.bind(e),us:e.getUSQuotes.bind(e),fund:e.getFundQuotes.bind(e),fundFlow:e.getFundFlow.bind(e),largeOrder:e.getPanelLargeOrder.bind(e),timeline:e.getTodayTimeline.bind(e)}})}get codes(){return this.memoNs("codes",()=>{let e=this.quoteService;return{cn:e.getAShareCodeList.bind(e),us:e.getUSCodeList.bind(e),hk:e.getHKCodeList.bind(e),fund:e.getFundCodeList.bind(e)}})}get batch(){return this.memoNs("batch",()=>{let e=this.quoteService;return{cn:e.getAllAShareQuotes.bind(e),hk:e.getAllHKShareQuotes.bind(e),us:e.getAllUSShareQuotes.bind(e),byCodes:e.getAllQuotesByCodes.bind(e),raw:e.batchRaw.bind(e)}})}get kline(){return this.memoNs("kline",()=>{let e=this.klineService,n=this.indicatorService;return{cn:e.getHistoryKline.bind(e),cnMinute:e.getMinuteKline.bind(e),hk:e.getHKHistoryKline.bind(e),hkMinute:e.getHKMinuteKline.bind(e),us:e.getUSHistoryKline.bind(e),usMinute:e.getUSMinuteKline.bind(e),withIndicators:n.getKlineWithIndicators.bind(n),signals:n.getKlineSignals.bind(n)}})}get chips(){return this.memoNs("chips",()=>{let e=this.chipService;return{cn:e.getChipDistribution.bind(e),hk:e.getHKChipDistribution.bind(e),us:e.getUSChipDistribution.bind(e)}})}get board(){return this.memoNs("board",()=>{let e=this.boardService;return{industry:{list:e.getIndustryList.bind(e),spot:e.getIndustrySpot.bind(e),constituents:e.getIndustryConstituents.bind(e),kline:e.getIndustryKline.bind(e),minuteKline:e.getIndustryMinuteKline.bind(e)},concept:{list:e.getConceptList.bind(e),spot:e.getConceptSpot.bind(e),constituents:e.getConceptConstituents.bind(e),kline:e.getConceptKline.bind(e),minuteKline:e.getConceptMinuteKline.bind(e)}}})}get options(){return this.memoNs("options",()=>{let e=this.optionsService;return{index:{spot:e.getIndexOptionSpot.bind(e),kline:e.getIndexOptionKline.bind(e)},etf:{months:e.getETFOptionMonths.bind(e),expireDay:e.getETFOptionExpireDay.bind(e),minute:e.getETFOptionMinute.bind(e),dailyKline:e.getETFOptionDailyKline.bind(e),fiveDayMinute:e.getETFOption5DayMinute.bind(e)},commodity:{spot:e.getCommodityOptionSpot.bind(e),kline:e.getCommodityOptionKline.bind(e)},cffex:{quotes:e.getCFFEXOptionQuotes.bind(e)},lhb:e.getOptionLHB.bind(e)}})}get futures(){return this.memoNs("futures",()=>{let e=this.futuresService;return{kline:e.getFuturesKline.bind(e),globalSpot:e.getGlobalFuturesSpot.bind(e),globalKline:e.getGlobalFuturesKline.bind(e),inventorySymbols:e.getFuturesInventorySymbols.bind(e),inventory:e.getFuturesInventory.bind(e),comexInventory:e.getComexInventory.bind(e)}})}get fundFlow(){return this.memoNs("fundFlow",()=>{let e=this.fundFlowService;return{individual:e.getIndividualFundFlow.bind(e),market:e.getMarketFundFlow.bind(e),rank:e.getFundFlowRank.bind(e),sectorRank:e.getSectorFundFlowRank.bind(e),sectorHistory:e.getSectorFundFlowHistory.bind(e)}})}get northbound(){return this.memoNs("northbound",()=>{let e=this.northboundService;return{minute:e.getNorthboundMinute.bind(e),summary:e.getNorthboundFlowSummary.bind(e),holdingRank:e.getNorthboundHoldingRank.bind(e),history:e.getNorthboundHistory.bind(e),individual:e.getNorthboundIndividual.bind(e)}})}get marketEvent(){return this.memoNs("marketEvent",()=>{let e=this.marketEventService;return{ztPool:e.getZTPool.bind(e),stockChanges:e.getStockChanges.bind(e),boardChanges:e.getBoardChanges.bind(e),individualChanges:e.getIndividualChanges.bind(e),individualChangesHistory:e.getIndividualChangesHistory.bind(e)}})}get dragonTiger(){return this.memoNs("dragonTiger",()=>{let e=this.dragonTigerService;return{detail:e.getDragonTigerDetail.bind(e),stockStats:e.getDragonTigerStockStats.bind(e),institution:e.getDragonTigerInstitution.bind(e),branchRank:e.getDragonTigerBranchRank.bind(e),seatDetail:e.getDragonTigerStockSeatDetail.bind(e)}})}get blockTrade(){return this.memoNs("blockTrade",()=>{let e=this.dataService;return{marketStat:e.getBlockTradeMarketStat.bind(e),detail:e.getBlockTradeDetail.bind(e),dailyStat:e.getBlockTradeDailyStat.bind(e)}})}get margin(){return this.memoNs("margin",()=>{let e=this.dataService;return{accountInfo:e.getMarginAccountInfo.bind(e),targetList:e.getMarginTargetList.bind(e)}})}get fund(){return this.memoNs("fund",()=>{let e=this.fundService;return{dividendList:e.getFundDividendList.bind(e),navHistory:e.getFundNavHistory.bind(e),estimate:e.getFundEstimate.bind(e),rankHistory:e.getFundRankHistory.bind(e),profile:e.getFundProfile.bind(e),theme:e.theme}})}get calendar(){return this.memoNs("calendar",()=>{let e=this.tradingCalendarService;return{isTradingDay:e.isTradingDay.bind(e),nextTradingDay:e.nextTradingDay.bind(e),prevTradingDay:e.prevTradingDay.bind(e),marketStatus:e.getMarketStatus.bind(e)}})}get reference(){return this.memoNs("reference",()=>{let e=this.quoteService;return{dividendDetail:e.getDividendDetail.bind(e),tradingCalendar:e.getTradingCalendar.bind(e)}})}search(e){return this.quoteService.search(e)}},tm= exports.u =nr;exports.a = bt; exports.b = Nt; exports.c = S; exports.d = D; exports.e = Ae; exports.f = se; exports.g = ot; exports.h = x; exports.i = Oe; exports.j = Ui; exports.k = ce; exports.l = Lt; exports.m = C; exports.n = Te; exports.o = w; exports.p = wt; exports.q = vt; exports.r = Ue; exports.s = qe; exports.t = nr; exports.u = tm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as u,f as x}from"./chunk-UBIQBXQ7.js";function I(e){if(e.startsWith("92")||/^[48]/.test(e))return"BSE";let t=e[0];return t==="6"||t==="5"||t==="9"?"SSE":"SZSE"}var y={SHFE:{market:"CN",exchange:"SHFE"},DCE:{market:"CN",exchange:"DCE"},CZCE:{market:"CN",exchange:"CZCE"},INE:{market:"CN",exchange:"INE"},CFFEX:{market:"CN",exchange:"CFFEX"},GFEX:{market:"CN",exchange:"GFEX"},COMEX:{market:"GLOBAL",exchange:"COMEX"},NYMEX:{market:"GLOBAL",exchange:"NYMEX"},CBOT:{market:"GLOBAL",exchange:"CBOT"},LME:{market:"GLOBAL",exchange:"LME"}};function A(e){let t=e.match(/^([A-Za-z]+)/);return(t?t[1]:e).toUpperCase()}var H={market:"CN",exchange:"CSI",secidPrefix:"2"},D=[/^93\d{4}$/,/^H\d{5}$/],U={HSHCI:{market:"HK",exchange:"HSI",secidPrefix:"124"},HSI:{market:"HK",exchange:"HSI",secidPrefix:"100",tencent:"hkHSI",collision:!0},HSCEI:{market:"HK",exchange:"HSI",secidPrefix:"100",tencent:"hkHSCEI",collision:!0},HSTECH:{market:"HK",exchange:"HSI",tencent:"hkHSTECH",collision:!0},DJI:{market:"US",exchange:"US",secidPrefix:"100",eastmoneyCode:"DJIA",tencent:"usDJI",collision:!0},INX:{market:"US",exchange:"US",secidPrefix:"100",eastmoneyCode:"SPX",tencent:"usINX",collision:!0},IXIC:{market:"US",exchange:"US",secidPrefix:"100",eastmoneyCode:"NDX",tencent:"usIXIC",collision:!0},GDAXI:{market:"GLOBAL",exchange:"DAX",secidPrefix:"100"}},R=[[H.exchange,H.market],...Object.values(U).map(e=>[e.exchange,e.market])];function E(e){let t=e.toUpperCase();if(D.some(i=>i.test(t)))return{...H,code:t};let c=U[t];return c?{...c,code:t}:void 0}function V(e){let t=e.indexOf(".");if(t<=0)return;let c=e.slice(0,t),i=e.slice(t+1).toUpperCase();for(let[n,d]of Object.entries(U))if(d.secidPrefix===c&&(d.eastmoneyCode??n)===i)return{...d,code:n}}var N={sh:{market:"CN",exchange:"SSE"},sz:{market:"CN",exchange:"SZSE"},bj:{market:"CN",exchange:"BSE"},hk:{market:"HK",exchange:"HKEX"},us:{market:"US",exchange:"US"}},L=Object.keys(N),K={0:{market:"CN",exchange:"SZSE"},1:{market:"CN",exchange:"SSE"},116:{market:"HK",exchange:"HKEX"},105:{market:"US",exchange:"NASDAQ"},106:{market:"US",exchange:"NYSE"},107:{market:"US",exchange:"AMEX"}},F={0:["SZSE","BSE"]},Z={SSE:"CN",SZSE:"CN",BSE:"CN",HKEX:"HK",NASDAQ:"US",NYSE:"US",AMEX:"US",US:"US",...Object.fromEntries(R),...Object.fromEntries(Object.values(y).map(e=>[e.exchange,e.market]))};function _(e,t,c,i){let n=i??[t.exchange],d=e.toLowerCase();for(let a of L){if(!d.startsWith(a)||e.length<=a.length)continue;let m=e.slice(a.length);if(!/^\d+$/.test(m))continue;let f=N[a];if(f.market!==t.market||!n.includes(f.exchange))throw new x(`${c} (prefix '${a}' conflicts with resolved ${t.market}/${t.exchange})`);return{code:m,exchange:f.exchange}}return{code:e,exchange:t.exchange}}function b(e,t){let c=typeof e=="string"?{code:e}:{...e},i=typeof e=="string"?e:e.code,n=String(c.code??"").trim(),d=c.market??t?.market,a=c.assetType??t?.assetType,m=c.exchange??t?.exchange;if(!n)throw new x(String(i));let f=(r,o,s,S,T,h={})=>{if(d&&d!==r)throw new x(`${i} (market hint '${d}' conflicts with resolved market ${r})`);if(m){let l=Z[m];if(l&&l!==r)throw new x(`${i} (exchange hint '${m}' belongs to market ${l}, conflicts with resolved market ${r})`);if(h.exchange&&m!==o)throw new x(`${i} (exchange hint '${m}' conflicts with resolved exchange ${o})`)}if(a&&a!==S){if(h.assetType)throw new x(`${i} (assetType hint '${a}' conflicts with resolved assetType ${S})`);if(a==="board"||a==="futures")throw new x(`${i} (assetType hint '${a}' conflicts with a ${S}-shaped code)`)}return{market:r,exchange:m??o,assetType:a??S,code:s,variety:T,input:i}},w=r=>f(r.market,r.exchange,r.code,"index",void 0,{exchange:!0,assetType:!0}),X=(r,o)=>o==="HK"&&/^\d+$/.test(r)?r.padStart(5,"0"):o==="US"?r.toUpperCase():r;if(n.includes(".")){let r=n.indexOf("."),o=n.slice(0,r),s=n.slice(r+1),S=o.toUpperCase(),T=s.toUpperCase(),h=E(s);if(h&&h.secidPrefix===o)return w(h);if(/^\d+$/.test(o)&&K[o]){let g=K[o],p=F[o],C=_(s,g,i,p),M=C.exchange,O=!0;if(p&&C.code===s&&/^\d+$/.test(C.code)){let P=I(C.code);p.includes(P)&&(M=P),O=!1}return f(g.market,M,X(C.code,g.market),"stock",void 0,{exchange:O})}let l=s.toLowerCase(),k=Object.prototype.hasOwnProperty.call(N,l)?N[l]:void 0;if(k){if(k.market==="CN"||k.market==="HK"){let p=E(o);if(p&&!p.collision)throw new x(`${i} (special index code '${p.code}' conflicts with exchange suffix '${s}'; use bare '${p.code}' or secid '${p.secidPrefix}.${p.code}')`)}let g=_(o,k,i);return f(k.market,g.exchange,X(g.code,k.market),"stock",void 0,{exchange:g.exchange!=="US"})}if(y[S]){let g=y[S];return f(g.market,g.exchange,T,"futures",A(s),{exchange:!0,assetType:!0})}if(o==="90")return f("CN","SSE",s,"board",void 0,{exchange:!0,assetType:!0})}let G=n.toLowerCase();for(let r of L)if(G.startsWith(r)&&n.length>r.length){let o=n.slice(r.length),s=N[r],S=n.startsWith(r)&&(/^[A-Z][A-Za-z0-9.\-]*$/.test(o)||/^[a-z]{3,}$/.test(o));if(s.market==="CN"?/^\d+$/.test(o):/^\d+$/.test(o)||S){let h=E(o);if(h&&h.collision&&h.market===s.market&&a!=="stock")return w(h);if((s.market==="CN"||s.market==="HK")&&h&&!h.collision)throw new x(`${i} (special index code '${h.code}' conflicts with exchange prefix '${r}'; use bare '${h.code}' or secid '${h.secidPrefix}.${h.code}')`);let l=s.market==="HK"?o.toUpperCase().padStart(5,"0"):s.market==="US"?o.toUpperCase():o;return f(s.market,s.exchange,l,"stock",void 0,{exchange:s.exchange!=="US"})}}let $=E(n);if($&&(!$.collision||d===$.market&&a!=="stock"))return w($);if(/^\d+$/.test(n))return d==="US"?f("US","US",n,"stock"):d==="CN"?f("CN",I(n),n,"stock"):d==="HK"||n.length===5||n.length===4?f("HK","HKEX",n.padStart(5,"0"),"stock",void 0,{exchange:!0}):f("CN",I(n),n,"stock");if((a==="futures"||d==="GLOBAL")&&/[A-Za-z]/.test(n)){let r=m;if(!r&&d==="GLOBAL")throw new x(`${i} (GLOBAL futures require an explicit exchange, e.g. { exchange: 'COMEX' })`);let o=r?y[String(r).toUpperCase()]?.market:void 0;return f(d??o??"CN",r??"SHFE",n.toUpperCase(),"futures",A(n),{assetType:!0})}if(/^[A-Za-z][A-Za-z.\-]*$/.test(n))return f("US","US",n.toUpperCase(),"stock");throw new x(String(i))}function j(e){try{return b(e).market}catch{return}}var B={SSE:"1",SZSE:"0",BSE:"0",HKEX:"116",NASDAQ:"105",NYSE:"106",AMEX:"107",US:"105"},v={SSE:"sh",SZSE:"sz",BSE:"bj"};function z(e){if(e.assetType==="board"||e.assetType==="futures"||e.assetType==="option")throw new u(`Tencent quote symbol does not support assetType '${e.assetType}'`,{assetType:e.assetType,code:e.code});if(e.assetType==="index"){let t=E(e.code);if(t?.tencent&&t.exchange===e.exchange)return t.tencent}switch(e.market){case"CN":{let t=v[e.exchange];if(!t)throw new u(`Cannot map to Tencent symbol: unsupported CN exchange '${e.exchange}'`,{exchange:e.exchange,code:e.code});return`${t}${e.code}`}case"HK":if(!/^\d+$/.test(e.code))throw new u(`Cannot map to Tencent symbol: HK code '${e.code}' is not numeric`,{market:e.market,code:e.code});return`hk${e.code.padStart(5,"0")}`;case"US":return`us${e.code}`;default:throw new u(`Cannot map to Tencent symbol: unsupported market '${e.market}'`,{market:e.market,code:e.code})}}function q(e){if(e.assetType==="board")return`90.${e.code}`;if(e.assetType==="futures"||e.assetType==="option")throw new u(`Eastmoney secid for assetType '${e.assetType}' uses a separate scheme; use the dedicated futures/options provider instead of toEastmoneySecid`,{assetType:e.assetType,exchange:e.exchange,code:e.code});if(e.assetType==="index"){let c=E(e.code);if(c&&c.exchange===e.exchange){if(c.secidPrefix)return`${c.secidPrefix}.${c.eastmoneyCode??c.code}`;throw new u(`Eastmoney has no quote for special index '${c.code}' (Tencent-only); use quotes.hk/quotes.us instead of kline for this index`,{code:c.code,exchange:c.exchange})}}if(e.market==="HK")return`116.${e.code.padStart(5,"0")}`;let t=B[e.exchange];if(!t)throw new u(`Cannot map to Eastmoney secid: unsupported exchange '${e.exchange}' (market=${e.market})`,{exchange:e.exchange,market:e.market,code:e.code});return`${t}.${e.code}`}function Y(e){return e.code}function W(e,t){let c=[],i=[],n=new Set;for(let d of e)try{let a=z(b(d,{market:t}));n.has(a)||(n.add(a),c.push(a))}catch(a){i.push({code:d,reason:a instanceof Error?a.message:String(a)})}return{keys:c,invalid:i}}export{I as a,y as b,A as c,E as d,V as e,b as f,j as g,B as h,z as i,q as j,Y as k,W as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6MCPZDKNcjs = require('./chunk-6MCPZDKN.cjs');var d=class{constructor(e){this.cache=new (0, _chunk6MCPZDKNcjs.a)(e)}get(e){return this.cache.get(e)}set(e,r,a){this.cache.set(e,r,a)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}},l=new WeakMap;async function f(n,e,r,a){let c=await n.get(e);if(c!==void 0)return c;let t=l.get(n);t||(t=new Map,l.set(n,t));let o=t.get(e);if(o)return o;let s=(async()=>{let i=await r();return i!==void 0&&await n.set(e,i,a),i})().finally(()=>{t.delete(e)});return t.set(e,s),s}exports.a = d; exports.b = f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var a=class{constructor(e={}){this.cache=new Map;this.inflight=new Map;this.defaultTTL=_nullishCoalesce(e.defaultTTL, () => (0)),this.maxSize=_nullishCoalesce(e.maxSize, () => (1e3))}get(e){let t=this.cache.get(e);if(t){if(t.expireAt>0&&Date.now()>t.expireAt){this.cache.delete(e);return}return t.lastAccess=Date.now(),t.value}}set(e,t,i){this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictLRU();let r=_nullishCoalesce(i, () => (this.defaultTTL)),c=Date.now();this.cache.set(e,{value:t,expireAt:r>0?c+r:0,lastAccess:c})}has(e){return this.get(e)!==void 0}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.inflight.clear()}get size(){return this.cache.size}cleanup(){let e=Date.now(),t=0;for(let[i,r]of this.cache)r.expireAt>0&&e>r.expireAt&&(this.cache.delete(i),t++);return t}evictLRU(){let e=null,t=1/0;for(let[i,r]of this.cache)r.lastAccess<t&&(t=r.lastAccess,e=i);e!==null&&this.cache.delete(e)}matchesOptions(e){return(_nullishCoalesce(e.defaultTTL, () => (this.defaultTTL)))===this.defaultTTL&&(_nullishCoalesce(e.maxSize, () => (this.maxSize)))===this.maxSize}configure(e){if(e.defaultTTL!==void 0&&(this.defaultTTL=e.defaultTTL),e.maxSize!==void 0){this.maxSize=e.maxSize;let t=this.cache.size;for(;this.cache.size>this.maxSize&&t-- >0;)this.evictLRU()}}async getOrFetch(e,t,i){let r=this.get(e);if(r!==void 0)return r;let c=this.inflight.get(e);if(c)return c;let o=t().then(u=>(this.set(e,u,i),u)).finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,o),o}},s=new Map,l=new Set;function f(n,e){let t=s.get(n);if(t)return e!==void 0&&!t.matchesOptions(e)&&!l.has(n)&&(l.add(n),console.warn(`[stock-sdk] getSharedCache("${n}") \u5DF2\u5B58\u5728\uFF0C\u672C\u6B21\u4F20\u5165\u7684 options \u4E0D\u751F\u6548\uFF1B\u5982\u9700\u8C03\u6574\u8BF7\u7528 configureSharedCache("${n}", options)`)),t;let i=new a(e);return s.set(n,i),i}function d(n,e){let t=s.get(n);return t?(t.configure(e),!0):!1}function g(){for(let n of s.values())n.clear()}var h=new WeakMap;function T(n,e,t){let i=h.get(n);i||(i=new Map,h.set(n,i));let r=i.get(e);return r||(r=new a(t),i.set(e,r)),r}function m(n){h.delete(n)}function p(...n){return n.map(e=>e==null?"\u2205":String(e)).join(":")}exports.a = a; exports.b = f; exports.c = d; exports.d = g; exports.e = T; exports.f = m; exports.g = p;
|