kline-charts-react 0.0.1 → 0.0.3

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.
@@ -0,0 +1 @@
1
+ "use strict";var qe=Object.defineProperty;var Ue=(e,t,n)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>Ue(e,typeof t!="symbol"?t+"":t,n);const j=require("react"),Ye=require("stock-sdk"),We=require("echarts/core"),X=require("echarts/charts"),O=require("echarts/components"),Je=require("echarts/renderers"),x=require("react/jsx-runtime");function Ze(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ye=Ze(We);function z(e,t){const n=[];let i=0,u=0;for(let r=0;r<e.length;r++){const c=e[r];if(c!=null&&(i+=c,u++),r>=t){const o=e[r-t];o!=null&&(i-=o,u--)}r>=t-1&&u===t?n.push(i/t):n.push(null)}return n}function T(e,t){const n=[],i=2/(t+1);let u=null;for(let r=0;r<e.length;r++){const c=e[r];if(c==null){n.push(u);continue}u===null?u=c:u=c*i+u*(1-i),n.push(u)}return n}function we(e,t){const n=[],i=Array.from({length:t},(r,c)=>c+1),u=i.reduce((r,c)=>r+c,0);for(let r=0;r<e.length;r++){if(r<t-1){n.push(null);continue}let c=0,o=0;for(let l=0;l<t;l++){const s=e[r-t+1+l],a=i[l];s!=null&&a!==void 0&&(c+=s*a,o++)}o===t?n.push(c/u):n.push(null)}return n}function Ie(e,t={}){const{periods:n=[5,10,20,30,60],type:i="sma"}=t,u={};for(const c of n){const o=`ma${c}`;switch(i){case"ema":u[o]=T(e,c);break;case"wma":u[o]=we(e,c);break;default:u[o]=z(e,c)}}const r=[];for(let c=0;c<e.length;c++){const o={};for(const l of Object.keys(u)){const s=u[l];o[l]=s!==void 0?s[c]??null:null}r.push(o)}return r}function Ce(e,t={}){const{short:n=12,long:i=26,signal:u=9}=t,r=T(e,n),c=T(e,i),o=[];for(let a=0;a<e.length;a++){const d=r[a],f=c[a];d!=null&&f!==null&&f!==void 0?o.push(d-f):o.push(null)}const l=T(o,u),s=[];for(let a=0;a<e.length;a++){const d=o[a]??null,f=l[a]??null;s.push({dif:d,dea:f,macd:d!==null&&f!==null?(d-f)*2:null})}return s}function Ae(e,t={}){const{period:n=20,stdDev:i=2}=t,u=z(e,n),r=[];for(let c=0;c<e.length;c++){const o=u[c];if(o==null||c<n-1){r.push({mid:null,upper:null,lower:null,bandwidth:null});continue}let l=0,s=0;for(let a=c-n+1;a<=c;a++){const d=e[a];d!=null&&(l+=Math.pow(d-o,2),s++)}if(s===n){const a=Math.sqrt(l/n),d=o+i*a,f=o-i*a;r.push({mid:o,upper:d,lower:f,bandwidth:o!==0?(d-f)/o*100:null})}else r.push({mid:o,upper:null,lower:null,bandwidth:null})}return r}function Se(e,t={}){const{period:n=9,kPeriod:i=3,dPeriod:u=3}=t,r=[];let c=50,o=50;for(let l=0;l<e.length;l++){if(l<n-1){r.push({k:null,d:null,j:null});continue}let s=-1/0,a=1/0;for(let I=l-n+1;I<=l;I++){const v=e[I];v!==void 0&&v.high!==null&&v.high!==void 0&&(s=Math.max(s,v.high)),v!==void 0&&v.low!==null&&v.low!==void 0&&(a=Math.min(a,v.low))}const d=e[l],f=d!==void 0?d.close:null;if(f==null||s===-1/0||a===1/0){r.push({k:null,d:null,j:null});continue}const g=s===a?50:(f-a)/(s-a)*100,w=(c*(i-1)+g)/i,y=(o*(u-1)+w)/u,h=3*w-2*y;r.push({k:w,d:y,j:h}),c=w,o=y}return r}function je(e,t={}){const{periods:n=[6,12,24]}=t,i={};for(const r of n){const c=`rsi${r}`,o=[];let l=0,s=0;for(let a=0;a<e.length;a++){const d=e[a],f=e[a-1];if(a===0||d===null||d===void 0||f===null||f===void 0){o.push(null);continue}const g=d-f,w=g>0?g:0,y=g<0?-g:0;if(a<r)l+=w,s+=y,o.push(null);else if(a===r){l=(l+w)/r,s=(s+y)/r;const h=s===0?100:l/s;o.push(100-100/(1+h))}else{l=(l*(r-1)+w)/r,s=(s*(r-1)+y)/r;const h=s===0?100:l/s;o.push(100-100/(1+h))}}i[c]=o}const u=[];for(let r=0;r<e.length;r++){const c={};for(const o of Object.keys(i)){const l=i[o];c[o]=l!==void 0?l[r]??null:null}u.push(c)}return u}function ke(e,t={}){const{periods:n=[6,10]}=t,i={};for(const r of n){const c=`wr${r}`,o=[];for(let l=0;l<e.length;l++){if(l<r-1){o.push(null);continue}let s=-1/0,a=1/0;for(let g=l-r+1;g<=l;g++){const w=e[g];w!==void 0&&w.high!==null&&w.high!==void 0&&(s=Math.max(s,w.high)),w!==void 0&&w.low!==null&&w.low!==void 0&&(a=Math.min(a,w.low))}const d=e[l],f=d!==void 0?d.close:null;f==null||s===a?o.push(null):o.push((s-f)/(s-a)*-100)}i[c]=o}const u=[];for(let r=0;r<e.length;r++){const c={};for(const o of Object.keys(i)){const l=i[o];c[o]=l!==void 0?l[r]??null:null}u.push(c)}return u}function Me(e,t={}){const{periods:n=[6,12,24]}=t,i={};for(const r of n){const c=`bias${r}`,o=z(e,r),l=[];for(let s=0;s<e.length;s++){const a=e[s],d=o[s];a==null||d===null||d===void 0||d===0?l.push(null):l.push((a-d)/d*100)}i[c]=l}const u=[];for(let r=0;r<e.length;r++){const c={};for(const o of Object.keys(i)){const l=i[o];c[o]=l!==void 0?l[r]??null:null}u.push(c)}return u}function $e(e,t={}){const{period:n=14}=t,i=e.map(c=>c.high===null||c.low===null||c.close===null?null:(c.high+c.low+c.close)/3),u=z(i,n),r=[];for(let c=0;c<e.length;c++){const o=i[c],l=u[c];if(c<n-1||o===null||o===void 0||l===null||l===void 0){r.push({cci:null});continue}let s=0,a=0;for(let f=c-n+1;f<=c;f++){const g=i[f];g!=null&&(s+=Math.abs(g-l),a++)}const d=a>0?s/a:0;d===0?r.push({cci:0}):r.push({cci:(o-l)/(.015*d)})}return r}function me(e,t={}){const{period:n=14}=t,i=[],u=[];for(let r=0;r<e.length;r++){const c=e[r];if(c===void 0||c.high===null||c.low===null||c.close===null){u.push(null),i.push({tr:null,atr:null});continue}let o;if(r===0)o=c.high-c.low;else{const l=e[r-1],s=l!==void 0?l.close:null;s==null?o=c.high-c.low:o=Math.max(c.high-c.low,Math.abs(c.high-s),Math.abs(c.low-s))}if(u.push(o),r<n-1)i.push({tr:o,atr:null});else if(r===n-1){let l=0;for(let s=0;s<n;s++)l+=u[s]??0;i.push({tr:o,atr:l/n})}else{const l=i[r-1],s=l!==void 0?l.atr:null;s==null?i.push({tr:o,atr:null}):i.push({tr:o,atr:(s*(n-1)+o)/n})}}return i}function De(e,t={}){const{maPeriod:n=30}=t,i=[];let u=0;for(let o=0;o<e.length;o++){const l=e[o];if(l===void 0||l.close===null||l.volume===null||l.volume===void 0){i.push({obv:null,obvMa:null});continue}if(o===0)u=l.volume;else{const s=e[o-1],a=s!==void 0?s.close:null;a==null?u=l.volume:l.close>a?u+=l.volume:l.close<a&&(u-=l.volume)}i.push({obv:u,obvMa:null})}const r=i.map(o=>o.obv),c=z(r,n);for(let o=0;o<i.length;o++){const l=i[o];l!==void 0&&(l.obvMa=c[o]??null)}return i}function _e(e,t={}){const{period:n=12,signalPeriod:i=6}=t,u=[];for(let o=0;o<e.length;o++){const l=e[o],s=e[o-n];o<n||l===null||l===void 0||s===null||s===void 0||s===0?u.push(null):u.push((l-s)/s*100)}const r=T(u,i),c=[];for(let o=0;o<e.length;o++)c.push({roc:u[o]??null,signal:r[o]??null});return c}function Ne(e,t={}){const{period:n=14,adxPeriod:i=14}=t,u=[],r=[],c=[],o=[];for(let l=0;l<e.length;l++){const s=e[l];if(s===void 0||s.high===null||s.low===null||s.close===null){u.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let a;if(l===0)a=s.high-s.low;else{const m=e[l-1],C=m!==void 0?m.close:null;C==null?a=s.high-s.low:a=Math.max(s.high-s.low,Math.abs(s.high-C),Math.abs(s.low-C))}if(r.push(a),l===0)c.push(0),o.push(0);else{const m=e[l-1];if(m===void 0||m.high===null||m.low===null)c.push(0),o.push(0);else{const C=s.high-m.high,A=m.low-s.low,S=C>A&&C>0?C:0,_=A>C&&A>0?A:0;c.push(S),o.push(_)}}if(l<n-1){u.push({pdi:null,mdi:null,adx:null,adxr:null});continue}let d=0,f=0,g=0;for(let m=l-n+1;m<=l;m++)d+=r[m]??0,f+=c[m]??0,g+=o[m]??0;const w=d>0?f/d*100:0,y=d>0?g/d*100:0,h=w+y,I=h>0?Math.abs(w-y)/h*100:0;let v=null;if(l>=n-1+i-1){let m=0;for(let C=l-i+1;C<=l;C++){if(u[C]===void 0)continue;let S=0,_=0,J=0;for(let D=C-n+1;D<=C;D++)S+=r[D]??0,_+=c[D]??0,J+=o[D]??0;const Z=S>0?_/S*100:0,G=S>0?J/S*100:0,$=Z+G,ne=$>0?Math.abs(Z-G)/$*100:0;m+=ne}m+=I,v=m/i}let p=null;if(v!==null&&l>=n-1+i-1+i){const m=u[l-i];m!==void 0&&m.adx!==null&&(p=(v+m.adx)/2)}u.push({pdi:w,mdi:y,adx:v,adxr:p})}return u}function Re(e,t={}){var a,d;const{afStart:n=.02,afIncrement:i=.02,afMax:u=.2}=t,r=[];if(e.length===0)return r;let c=1,o=((a=e[0])==null?void 0:a.low)??0,l=((d=e[0])==null?void 0:d.high)??0,s=n;for(let f=0;f<e.length;f++){const g=e[f];if(g===void 0||g.high===null||g.low===null){r.push({sar:null,trend:null,ep:null,af:null});continue}if(f===0){r.push({sar:g.low,trend:1,ep:g.high,af:n}),o=g.low,l=g.high,c=1,s=n;continue}const w=o;if(o=w+s*(l-w),c===1){const y=e[f-1],h=e[f-2];y!==void 0&&y.low!==null&&(o=Math.min(o,y.low)),h!==void 0&&h.low!==null&&(o=Math.min(o,h.low)),g.low<o?(c=-1,o=l,l=g.low,s=n):g.high>l&&(l=g.high,s=Math.min(s+i,u))}else{const y=e[f-1],h=e[f-2];y!==void 0&&y.high!==null&&(o=Math.max(o,y.high)),h!==void 0&&h.high!==null&&(o=Math.max(o,h.high)),g.high>o?(c=1,o=l,l=g.high,s=n):g.low<l&&(l=g.low,s=Math.min(s+i,u))}r.push({sar:o,trend:c,ep:l,af:s})}return r}function Le(e,t={}){var s;const{emaPeriod:n=20,atrPeriod:i=10,multiplier:u=2}=t,r=e.map(a=>a.close),c=T(r,n),o=me(e,{period:i}),l=[];for(let a=0;a<e.length;a++){const d=c[a],f=(s=o[a])==null?void 0:s.atr;if(d==null||f===null||f===void 0){l.push({mid:null,upper:null,lower:null,width:null});continue}const g=d+u*f,w=d-u*f,y=d!==0?(g-w)/d*100:null;l.push({mid:d,upper:g,lower:w,width:y})}return l}const Ge={enabled:!0,ttl:300*1e3,maxSize:100};function Xe(e){switch(e){case"timeline":case"timeline5":return 30*1e3;case"1":case"5":case"15":case"30":case"60":return 120*1e3;case"daily":case"weekly":case"monthly":default:return 600*1e3}}class W{constructor(t={}){le(this,"cache",new Map);le(this,"config");this.config={...Ge,...t}}static buildKey(t){return Object.entries(t).filter(([,n])=>n!==void 0).sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>`${n}:${String(i)}`).join("|")}get(t){if(!this.config.enabled)return;const n=this.cache.get(t);if(!n)return;const i=n.ttl??this.config.ttl;if(Date.now()-n.timestamp>i){this.cache.delete(t);return}return n.data}set(t,n,i){if(this.config.enabled){if(this.cache.size>=this.config.maxSize&&(this.cleanup(),this.cache.size>=this.config.maxSize)){const u=this.cache.keys().next().value;u&&this.cache.delete(u)}this.cache.set(t,{data:n,timestamp:Date.now(),ttl:i})}}cleanup(){const t=Date.now();for(const[n,i]of this.cache.entries()){const u=i.ttl??this.config.ttl;t-i.timestamp>u&&this.cache.delete(n)}}delete(t){return this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}new W;const oe=new W,ie=new W,se=new Map,re=new Map,Qe=150;function et(e){const t=new Ye.StockSDK(e);return{getKline:async n=>{const{symbol:i,market:u,period:r,adjust:c}=n;if(r==="timeline"){const s=await t.getTodayTimeline(i);return s.data.map(a=>({date:`${s.date.slice(0,4)}-${s.date.slice(4,6)}-${s.date.slice(6,8)} ${a.time}`,open:a.price,close:a.price,high:a.price,low:a.price,volume:a.volume,amount:a.amount}))}if(r==="timeline5"){const s=new Date,a=new Date;a.setDate(a.getDate()-7);const d=g=>{const w=g.getFullYear(),y=String(g.getMonth()+1).padStart(2,"0"),h=String(g.getDate()).padStart(2,"0");return`${w}-${y}-${h}`};return(await t.getMinuteKline(i,{period:"1",startDate:d(a),endDate:d(s)})).map(g=>({date:"time"in g?g.time:"",open:g.open,close:g.close,high:g.high,low:g.low,volume:g.volume,amount:g.amount}))}if(["1","5","15","30","60"].includes(r)){let a=(await t.getMinuteKline(i,{period:r,adjust:c||"qfq"})).map(d=>({date:"time"in d?d.time:"",open:d.open,close:d.close,high:d.high,low:d.low,volume:d.volume,amount:d.amount,changePercent:"changePercent"in d?d.changePercent:void 0,change:"change"in d?d.change:void 0,amplitude:"amplitude"in d?d.amplitude:void 0,turnoverRate:"turnoverRate"in d?d.turnoverRate:void 0}));if(r==="1"&&a.length>0){const d=a[a.length-1].date.split(" ")[0];a=a.filter(f=>f.date.startsWith(d))}return a}const l={daily:"daily",weekly:"weekly",monthly:"monthly"}[r]??"daily";switch(u){case"HK":return await t.getHKHistoryKline(i,{period:l,adjust:c||"qfq"});case"US":return await t.getUSHistoryKline(i,{period:l,adjust:c||"qfq"});default:return await t.getHistoryKline(i,{period:l,adjust:c||"qfq"})}},getTimeline:async n=>(await t.getTodayTimeline(n.symbol)).data}}function xe(e){return W.buildKey(e)}function ce(e){return W.buildKey({...e,type:"timeline"})}function tt(e,t,n={}){if(e.length===0)return[];const i=e.map(p=>p.close),u=e.map(p=>({open:p.open,high:p.high,low:p.low,close:p.close,volume:p.volume})),r=t.includes("ma")?Ie(i,typeof n.ma=="object"?n.ma:{}):null,c=t.includes("macd")?Ce(i,typeof n.macd=="object"?n.macd:{}):null,o=t.includes("boll")?Ae(i,typeof n.boll=="object"?n.boll:{}):null,l=t.includes("kdj")?Se(u,typeof n.kdj=="object"?n.kdj:{}):null,s=t.includes("rsi")?je(i,typeof n.rsi=="object"?n.rsi:{}):null,a=t.includes("wr")?ke(u,typeof n.wr=="object"?n.wr:{}):null,d=t.includes("bias")?Me(i,typeof n.bias=="object"?n.bias:{}):null,f=t.includes("cci")?$e(u,typeof n.cci=="object"?n.cci:{}):null,g=t.includes("atr")?me(u,typeof n.atr=="object"?n.atr:{}):null,w=t.includes("obv")?De(u,typeof n.obv=="object"?n.obv:{}):null,y=t.includes("roc")?_e(i,typeof n.roc=="object"?n.roc:{}):null,h=t.includes("dmi")?Ne(u,typeof n.dmi=="object"?n.dmi:{}):null,I=t.includes("sar")?Re(u,typeof n.sar=="object"?n.sar:{}):null,v=t.includes("kc")?Le(u,typeof n.kc=="object"?n.kc:{}):null;return e.map((p,m)=>({...p,ma:r==null?void 0:r[m],macd:c==null?void 0:c[m],boll:o==null?void 0:o[m],kdj:l==null?void 0:l[m],rsi:s==null?void 0:s[m],wr:a==null?void 0:a[m],bias:d==null?void 0:d[m],cci:f==null?void 0:f[m],atr:g==null?void 0:g[m],obv:w==null?void 0:w[m],roc:y==null?void 0:y[m],dmi:h==null?void 0:h[m],sar:I==null?void 0:I[m],kc:v==null?void 0:v[m]}))}function nt(e){const{symbol:t,market:n,period:i,adjust:u,dataProvider:r,sdkOptions:c,requestOptions:o,indicatorOptions:l,indicators:s=["ma","volume","macd"]}=e,[a,d]=j.useState([]),[f,g]=j.useState({key:"",data:[]}),[w,y]=j.useState(!1),[h,I]=j.useState(null),v=j.useRef(null),p=j.useRef(null),m=j.useRef(null),C=j.useRef(0);j.useEffect(()=>{r||(m.current=null)},[r,c]);const A=j.useCallback(()=>r||(m.current||(m.current=et(c)),m.current),[r,c]),S=j.useCallback(async()=>{(o==null?void 0:o.abortOnChange)!==!1&&v.current&&v.current.abort();const $=new AbortController,ne=++C.current;v.current=$;const D=(o==null?void 0:o.dedupe)!==!1,fe=()=>ne===C.current&&!$.signal.aborted;y(!0),I(null);try{const P=A(),V=xe({symbol:t,market:n,period:i,adjust:u}),L=ce({symbol:t,market:n}),pe=Xe(i);let B=D?oe.get(V):void 0;if(!B){const N=D?se.get(V):void 0;if(N)try{B=await N}catch{}else{const F=P.getKline({symbol:t,market:n,period:i,adjust:u},$.signal);se.set(V,F);try{B=await F}finally{se.delete(V)}}}if(!fe()||!B)return;if(oe.set(V,B,pe),d(B),i==="timeline"&&P.getTimeline){let N=D?ie.get(L):void 0;if(!N){g({key:L,data:[]});const F=D?re.get(L):void 0;if(F)try{N=await F}catch{}else{const ge=P.getTimeline({symbol:t,market:n},$.signal);re.set(L,ge);try{N=await ge}finally{re.delete(L)}}}fe()&&N&&(ie.set(L,N,pe),g({key:L,data:N}))}}catch(P){if(P.name==="AbortError")return;I(P)}finally{$.signal.aborted||y(!1)}},[t,n,i,u,A,o]),_=j.useCallback(async()=>{const $=xe({symbol:t,market:n,period:i,adjust:u});oe.delete($),i==="timeline"&&(ie.delete(ce({symbol:t,market:n})),g({key:"",data:[]})),await S()},[t,n,i,u,S]);j.useEffect(()=>{p.current&&clearTimeout(p.current);const $=(o==null?void 0:o.debounceMs)??Qe;return p.current=setTimeout(S,$),()=>{p.current&&clearTimeout(p.current),v.current&&v.current.abort()}},[t,n,i,u,S,o==null?void 0:o.debounceMs]);const J=j.useMemo(()=>tt(a,s,l),[a,s,l]),Z=i==="timeline"?ce({symbol:t,market:n}):"",G=f.key===Z?f.data:[];return{data:J,timelineData:G,loading:w,error:h,refresh:_}}ye.use([X.CandlestickChart,X.LineChart,X.BarChart,X.ScatterChart,O.TitleComponent,O.TooltipComponent,O.GridComponent,O.DataZoomComponent,O.LegendComponent,O.AxisPointerComponent,Je.CanvasRenderer]);function lt(){const e=j.useRef(null),t=j.useRef(null);j.useEffect(()=>{if(!e.current)return;t.current=ye.init(e.current);const l=new ResizeObserver(()=>{var s;(s=t.current)==null||s.resize()});return l.observe(e.current),()=>{var s;l.disconnect(),(s=t.current)==null||s.dispose(),t.current=null}},[]);const n=j.useCallback((l,s,a=!1)=>{var f;let d;typeof s=="boolean"?d={notMerge:s,lazyUpdate:a}:d=s??{},(f=t.current)==null||f.setOption(l,d)},[]),i=j.useCallback(()=>{var l;(l=t.current)==null||l.resize()},[]),u=j.useCallback(()=>{var l;(l=t.current)==null||l.dispose(),t.current=null},[]),r=j.useCallback(l=>t.current?t.current.getDataURL({type:(l==null?void 0:l.type)??"png",pixelRatio:(l==null?void 0:l.pixelRatio)??2,backgroundColor:(l==null?void 0:l.backgroundColor)??"#fff"}):"",[]),c=j.useCallback(()=>t.current,[]),o=j.useCallback((l,s)=>{const a=t.current;return a?(a.on(l,s),()=>{a.off(l,s)}):()=>{}},[]);return{chartRef:e,setOption:n,resize:i,dispose:u,getInstance:c,getDataURL:r,bindEvent:o}}const ot={start:70,end:100},be=50;function it(e,t){return e.start===t.start&&e.end===t.end}function st(e=ot){const[t,n]=j.useState({history:[e],index:0}),i=t.history[t.index]??e,u=j.useCallback(l=>{n(s=>{const a=s.history[s.index];if(a&&it(a,l))return s;let d=s.history.slice(0,s.index+1);return d=[...d,l],d.length>be&&(d=d.slice(d.length-be)),{history:d,index:d.length-1}})},[]),r=j.useCallback(()=>{let l=null;return n(s=>{if(s.index===0)return s;const a=s.index-1;return l=s.history[a]??null,{...s,index:a}}),l},[]),c=j.useCallback(()=>{let l=null;return n(s=>{if(s.index>=s.history.length-1)return s;const a=s.index+1;return l=s.history[a]??null,{...s,index:a}}),l},[]),o=j.useCallback((l=e)=>{n({history:[l],index:0})},[e]);return{canUndo:t.index>0,canRedo:t.index<t.history.length-1,currentState:i,pushState:u,undo:r,redo:c,reset:o}}function te(e,t){const n=(e??[]).filter(i=>Number.isFinite(i)&&i>0).map(i=>Math.floor(i));return n.length===0?t:Array.from(new Set(n)).sort((i,u)=>i-u)}function rt(e){return te(typeof e=="object"?e.periods:void 0,[5,10,20,30,60])}function ct(e){return te(typeof e=="object"?e.periods:void 0,[6,12,24])}function ut(e){return te(typeof e=="object"?e.periods:void 0,[6,10])}function at(e){return te(typeof e=="object"?e.periods:void 0,[6,12,24])}function ve(e){const t=e.match(/(\d+)$/);return t?Number(t[1]):Number.POSITIVE_INFINITY}function q(e,t){return e?Object.keys(e).filter(n=>n.startsWith(t)).sort((n,i)=>ve(n)-ve(i)).map(n=>[n,e[n]]):[]}function U(e){return e.replace(/^[a-z]+/,t=>t.toUpperCase())}function Te(e,t=2){return e==null||isNaN(e)?"--":e.toLocaleString("zh-CN",{minimumFractionDigits:t,maximumFractionDigits:t})}function b(e){return Te(e,2)}function Pe(e){return e==null||isNaN(e)?"--":`${e>0?"+":""}${e.toFixed(2)}%`}function Be(e){return e==null||isNaN(e)?"--":`${e>0?"+":""}${e.toFixed(2)}`}function Y(e,t){return Number.isInteger(e)?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function R(e){return e==null||isNaN(e)?"--":e>=1e8?`${Y(e/1e8,2)}亿`:e>=1e4?`${Y(e/1e4,2)}万`:e.toFixed(0)}function Oe(e){return e==null||isNaN(e)?"--":e>=1e8?`${Y(e/1e8,2)}亿`:e>=1e4?`${Y(e/1e4,2)}万`:Y(e,2)}function dt(e,t="YYYY-MM-DD"){const n=typeof e=="string"?new Date(e):e;if(isNaN(n.getTime()))return e;const i=n.getFullYear(),u=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),o=String(n.getMinutes()).padStart(2,"0");return t.replace("YYYY",String(i)).replace("MM",u).replace("DD",r).replace("HH",c).replace("mm",o)}function Q(e,t,n){const i=q(t,n);return i.length===0?null:`${e}: ${i.map(([u,r])=>`${U(u)} ${b(r)}`).join(" / ")}`}function Ke(e){const t=[`<div style="font-weight:bold;margin-bottom:4px">${e.date}</div>`,`<div>开盘: <span style="font-weight:500">${b(e.open)}</span></div>`,`<div>最高: <span style="font-weight:500">${b(e.high)}</span></div>`,`<div>最低: <span style="font-weight:500">${b(e.low)}</span></div>`,`<div>收盘: <span style="font-weight:500">${b(e.close)}</span></div>`];if(e.change!==void 0&&e.changePercent!==void 0){const u=e.change!==null&&e.change>0?"#f5222d":e.change!==null&&e.change<0?"#52c41a":"inherit";t.push(`<div>涨跌: <span style="color:${u};font-weight:500">${Be(e.change)} (${Pe(e.changePercent)})</span></div>`)}e.volume!==void 0&&t.push(`<div>成交量: ${R(e.volume)}</div>`),e.amount!==void 0&&t.push(`<div>成交额: ${Oe(e.amount)}</div>`),e.turnoverRate!==void 0&&e.turnoverRate!==null&&t.push(`<div>换手率: ${e.turnoverRate.toFixed(2)}%</div>`),e.amplitude!==void 0&&e.amplitude!==null&&t.push(`<div>振幅: ${e.amplitude.toFixed(2)}%</div>`);const n=e.indicators??[];let i=!1;if(n.includes("ma")&&e.ma){const u=Q("MA",e.ma,"ma");u&&(i?t.push(`<div>${u}</div>`):(t.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">${u}</div>`),i=!0))}if(n.includes("boll")&&e.boll&&(i?t.push(`<div>BOLL: 上 ${b(e.boll.upper)} 中 ${b(e.boll.mid)} 下 ${b(e.boll.lower)}</div>`):(t.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">BOLL: 上 ${b(e.boll.upper)} 中 ${b(e.boll.mid)} 下 ${b(e.boll.lower)}</div>`),i=!0)),n.includes("sar")&&e.sar){const u=e.sar.trend===1?"↑":"↓";i?t.push(`<div>SAR: ${b(e.sar.sar)} ${u}</div>`):(t.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">SAR: ${b(e.sar.sar)} ${u}</div>`),i=!0)}if(n.includes("kc")&&e.kc&&(i?t.push(`<div>KC: 上 ${b(e.kc.upper)} 中 ${b(e.kc.mid)} 下 ${b(e.kc.lower)}</div>`):(t.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">KC: 上 ${b(e.kc.upper)} 中 ${b(e.kc.mid)} 下 ${b(e.kc.lower)}</div>`),i=!0)),n.includes("macd")&&e.macd&&(i?t.push(`<div>MACD: DIF ${b(e.macd.dif)} DEA ${b(e.macd.dea)} MACD ${b(e.macd.macd)}</div>`):(t.push(`<div style="margin-top:4px;border-top:1px solid #eee;padding-top:4px">MACD: DIF ${b(e.macd.dif)} DEA ${b(e.macd.dea)} MACD ${b(e.macd.macd)}</div>`),i=!0)),n.includes("kdj")&&e.kdj&&t.push(`<div>KDJ: K ${b(e.kdj.k)} D ${b(e.kdj.d)} J ${b(e.kdj.j)}</div>`),n.includes("rsi")&&e.rsi){const u=Q("RSI",e.rsi,"rsi");u&&t.push(`<div>${u}</div>`)}if(n.includes("wr")&&e.wr){const u=Q("WR",e.wr,"wr");u&&t.push(`<div>${u}</div>`)}if(n.includes("bias")&&e.bias){const u=Q("BIAS",e.bias,"bias");u&&t.push(`<div>${u}</div>`)}return n.includes("cci")&&e.cci&&t.push(`<div>CCI: ${b(e.cci.cci)}</div>`),n.includes("atr")&&e.atr&&t.push(`<div>ATR: ${b(e.atr.atr)}</div>`),n.includes("obv")&&e.obv&&t.push(`<div>OBV: ${R(e.obv.obv)} MA ${R(e.obv.obvMa)}</div>`),n.includes("roc")&&e.roc&&t.push(`<div>ROC: ${b(e.roc.roc)} SIGNAL ${b(e.roc.signal)}</div>`),n.includes("dmi")&&e.dmi&&t.push(`<div>DMI: +DI ${b(e.dmi.pdi)} -DI ${b(e.dmi.mdi)} ADX ${b(e.dmi.adx)}</div>`),t.join("")}const ue=["ma","boll","sar","kc"],Ee="kline-zoom-inside",ze="kline-zoom-slider";function H(e,t){return Number.isInteger(e)?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function ht(e,t){return t.includes("volume")?R(e):Math.abs(e)>=100||Math.abs(e)>=10||Math.abs(e)>=1||Math.abs(e)>=.01?H(e,2):H(e,4)}function Ve(e,t={}){const n=Math.min(Math.max(t.maxSubPanes??3,0),3),i=e.filter(s=>!ue.includes(s));if(n===0)return[{id:"main",height:"95%",indicators:ue.filter(s=>e.includes(s))}];const u=i.length,r=Math.min(u,n),o=r===0?{main:"95%",sub:"0%"}:r===1?{main:"78%",sub:"18%"}:r===2?{main:"65%",sub:"15%"}:{main:"55%",sub:"13%"},l=[{id:"main",height:o.main,indicators:ue.filter(s=>e.includes(s))}];return i.slice(0,n).forEach((s,a)=>{l.push({id:`sub_${s}_${a}`,height:o.sub,indicators:[s]})}),l}const ae={gap:25,topMargin:50,bottomMargin:55,leftMargin:60,rightMargin:60};function Fe(e,t){const n=[],{gap:i,topMargin:u,bottomMargin:r}=ae,c=t-u-r-(e.length-1)*i;let o=0;const l=[];for(const f of e)if(typeof f.height=="string"&&f.height.endsWith("%")){const g=parseFloat(f.height)/100;l.push(g),o+=g}else typeof f.height=="number"?(l.push(f.height/c),o+=f.height/c):l.push(0);const s=l.filter(f=>f===0).length;if(s>0&&o<1){const f=(1-o)/s;for(let g=0;g<l.length;g++)l[g]===0&&(l[g]=f)}const a=l.reduce((f,g)=>f+g,0);for(let f=0;f<l.length;f++)l[f]=l[f]/a*c;let d=u;for(let f=0;f<e.length;f++)n.push({id:e[f].id,left:ae.leftMargin,right:ae.rightMargin,top:d,height:l[f]}),d+=l[f]+i;return n}function mt(e){const{data:t,theme:n,indicators:i,panes:u=Ve(i),containerHeight:r=500,indicatorOptions:c}=e,o=rt(c==null?void 0:c.ma),l=ct(c==null?void 0:c.rsi),s=ut(c==null?void 0:c.wr),a=at(c==null?void 0:c.bias);if(t.length===0)return{title:{text:"暂无数据",left:"center",top:"center",textStyle:{color:n.textColorSecondary}}};const d=Fe(u,r),f=t.map(h=>h.date),g=t.map(h=>h.close),w={animation:!1,backgroundColor:n.backgroundColor,title:{text:"",show:!1},tooltip:{trigger:"axis",axisPointer:{type:"cross",crossStyle:{color:n.crosshairColor},lineStyle:{color:n.crosshairColor,type:"dashed"}},backgroundColor:n.tooltipBgColor,borderColor:n.tooltipBorderColor,textStyle:{color:n.textColor,fontSize:12},formatter:h=>{if(!Array.isArray(h)||h.length===0)return"";const I=h[0].dataIndex,v=t[I];return v?Ke({date:v.date,open:v.open,high:v.high,low:v.low,close:v.close,volume:v.volume,amount:v.amount,change:v.change,changePercent:v.changePercent,turnoverRate:v.turnoverRate,amplitude:v.amplitude,indicators:i,ma:v.ma,boll:v.boll,sar:v.sar,kc:v.kc,macd:v.macd,kdj:v.kdj,rsi:v.rsi,wr:v.wr,bias:v.bias,cci:v.cci,atr:v.atr,obv:v.obv,roc:v.roc,dmi:v.dmi}):""}},axisPointer:{link:[{xAxisIndex:"all"}]},grid:d.map(h=>({left:h.left,right:h.right,top:h.top,height:h.height})),xAxis:d.map((h,I)=>({type:"category",data:f,gridIndex:I,axisLine:{lineStyle:{color:n.gridLineColor}},axisTick:{show:!1},axisLabel:{show:I===d.length-1,color:n.textColorSecondary,fontSize:11},splitLine:{show:!1},boundaryGap:!0,min:"dataMin",max:"dataMax"})),yAxis:d.map((h,I)=>({type:"value",gridIndex:I,position:"right",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:n.textColorSecondary,fontSize:11,formatter:v=>ht(v,h.id)},splitLine:{lineStyle:{color:n.splitLineColor,type:"dashed"}},splitNumber:h.id==="main"?3:2,scale:h.id!=="volume"&&!h.id.includes("volume")})),dataZoom:[{id:Ee,type:"inside",xAxisIndex:d.map((h,I)=>I),minValueSpan:10},{id:ze,type:"slider",xAxisIndex:d.map((h,I)=>I),bottom:8,height:20,borderColor:n.gridLineColor,fillerColor:"rgba(24,144,255,0.1)",handleStyle:{color:n.activeColor},textStyle:{color:n.textColorSecondary}}],series:[]},y=[];for(let h=0;h<u.length;h++){const I=u[h];if(d[h].id==="main"&&y.push({type:"candlestick",name:"K线",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>[p.open,p.close,p.low,p.high]),itemStyle:{color:n.upColor,color0:n.downColor,borderColor:n.upColor,borderColor0:n.downColor}}),I.indicators.includes("ma")&&o.forEach((p,m)=>{const C=`ma${p}`,A=t.map(S=>{var _;return((_=S.ma)==null?void 0:_[C])??null});y.push({type:"line",name:`MA${p}`,xAxisIndex:h,yAxisIndex:h,data:A,smooth:!0,symbol:"none",lineStyle:{width:1,color:n.maColors[m]??n.maColors[0]}})}),I.indicators.includes("boll")){const[p,m,C]=n.bollColors;y.push({type:"line",name:"BOLL上轨",xAxisIndex:h,yAxisIndex:h,data:t.map(A=>{var S;return((S=A.boll)==null?void 0:S.upper)??null}),smooth:!0,symbol:"none",lineStyle:{width:1,color:p}},{type:"line",name:"BOLL中轨",xAxisIndex:h,yAxisIndex:h,data:t.map(A=>{var S;return((S=A.boll)==null?void 0:S.mid)??null}),smooth:!0,symbol:"none",lineStyle:{width:1,color:m}},{type:"line",name:"BOLL下轨",xAxisIndex:h,yAxisIndex:h,data:t.map(A=>{var S;return((S=A.boll)==null?void 0:S.lower)??null}),smooth:!0,symbol:"none",lineStyle:{width:1,color:C}})}if(I.indicators.includes("volume")&&y.push({type:"bar",name:"成交量",xAxisIndex:h,yAxisIndex:h,data:t.map((p,m)=>{const C=m>0?g[m-1]:p.open,A=(p.close??0)>=(C??0);return{value:p.volume,itemStyle:{color:A?n.volumeUpColor:n.volumeDownColor}}})}),I.indicators.includes("macd")&&y.push({type:"bar",name:"MACD",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m,C;return{value:((m=p.macd)==null?void 0:m.macd)??null,itemStyle:{color:(((C=p.macd)==null?void 0:C.macd)??0)>=0?n.upColor:n.downColor}}})},{type:"line",name:"DIF",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.macd)==null?void 0:m.dif)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}},{type:"line",name:"DEA",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.macd)==null?void 0:m.dea)??null}),symbol:"none",lineStyle:{width:1,color:"#faad14"}}),I.indicators.includes("kdj")&&y.push({type:"line",name:"K",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.kdj)==null?void 0:m.k)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}},{type:"line",name:"D",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.kdj)==null?void 0:m.d)??null}),symbol:"none",lineStyle:{width:1,color:"#faad14"}},{type:"line",name:"J",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.kdj)==null?void 0:m.j)??null}),symbol:"none",lineStyle:{width:1,color:"#722ed1"}}),I.indicators.includes("rsi")&&l.forEach((p,m)=>{y.push({type:"line",name:`RSI${p}`,xAxisIndex:h,yAxisIndex:h,data:t.map(C=>{var A;return((A=C.rsi)==null?void 0:A[`rsi${p}`])??null}),symbol:"none",lineStyle:{width:1,color:n.maColors[m]??"#1890ff"}})}),I.indicators.includes("wr")&&s.forEach((p,m)=>{y.push({type:"line",name:`WR${p}`,xAxisIndex:h,yAxisIndex:h,data:t.map(C=>{var A;return((A=C.wr)==null?void 0:A[`wr${p}`])??null}),symbol:"none",lineStyle:{width:1,color:n.maColors[m]??"#1890ff"}})}),I.indicators.includes("bias")&&a.forEach((p,m)=>{y.push({type:"line",name:`BIAS${p}`,xAxisIndex:h,yAxisIndex:h,data:t.map(C=>{var A;return((A=C.bias)==null?void 0:A[`bias${p}`])??null}),symbol:"none",lineStyle:{width:1,color:n.maColors[m]??"#1890ff"}})}),I.indicators.includes("cci")&&y.push({type:"line",name:"CCI",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.cci)==null?void 0:m.cci)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}}),I.indicators.includes("atr")&&y.push({type:"line",name:"ATR",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.atr)==null?void 0:m.atr)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}}),I.indicators.includes("obv")&&y.push({type:"line",name:"OBV",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.obv)==null?void 0:m.obv)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}},{type:"line",name:"OBV_MA",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.obv)==null?void 0:m.obvMa)??null}),symbol:"none",lineStyle:{width:1,color:"#faad14"}}),I.indicators.includes("roc")&&y.push({type:"line",name:"ROC",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.roc)==null?void 0:m.roc)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}},{type:"line",name:"ROC_MA",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.roc)==null?void 0:m.signal)??null}),symbol:"none",lineStyle:{width:1,color:"#faad14"}}),I.indicators.includes("dmi")&&y.push({type:"line",name:"+DI",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.dmi)==null?void 0:m.pdi)??null}),symbol:"none",lineStyle:{width:1,color:n.upColor}},{type:"line",name:"-DI",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.dmi)==null?void 0:m.mdi)??null}),symbol:"none",lineStyle:{width:1,color:n.downColor}},{type:"line",name:"ADX",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.dmi)==null?void 0:m.adx)??null}),symbol:"none",lineStyle:{width:1,color:"#1890ff"}},{type:"line",name:"ADXR",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m;return((m=p.dmi)==null?void 0:m.adxr)??null}),symbol:"none",lineStyle:{width:1,color:"#722ed1",type:"dashed"}}),I.indicators.includes("sar")&&y.push({type:"scatter",name:"SAR",xAxisIndex:h,yAxisIndex:h,data:t.map(p=>{var m,C;return{value:((m=p.sar)==null?void 0:m.sar)??null,itemStyle:{color:((C=p.sar)==null?void 0:C.trend)===1?n.upColor:n.downColor}}}),symbol:"circle",symbolSize:4}),I.indicators.includes("kc")){const[p,m,C]=n.kcColors;y.push({type:"line",name:"KC上轨",xAxisIndex:h,yAxisIndex:h,data:t.map(A=>{var S;return((S=A.kc)==null?void 0:S.upper)??null}),smooth:!0,symbol:"none",lineStyle:{width:1,color:p}},{type:"line",name:"KC中轨",xAxisIndex:h,yAxisIndex:h,data:t.map(A=>{var S;return((S=A.kc)==null?void 0:S.mid)??null}),smooth:!0,symbol:"none",lineStyle:{width:1,color:m}},{type:"line",name:"KC下轨",xAxisIndex:h,yAxisIndex:h,data:t.map(A=>{var S;return((S=A.kc)==null?void 0:S.lower)??null}),smooth:!0,symbol:"none",lineStyle:{width:1,color:C}})}}return w.series=y,w}function ft(e,t,n="safeMerge"){if(!t)return e;if(n==="replace")return t;const i={...e};for(const u of Object.keys(t)){const r=t[u];r!==void 0&&(Array.isArray(r)?i[u]=r:typeof r=="object"&&r!==null?i[u]={...i[u],...r}:i[u]=r)}return i}const pt="_container_119o2_1",gt="_spinner_119o2_11",xt="_dot_119o2_16",bt="_text_119o2_43",K={container:pt,spinner:gt,dot:xt,text:bt};function vt({text:e="加载中..."}){return x.jsxs("div",{className:K.container,children:[x.jsxs("div",{className:K.spinner,children:[x.jsx("div",{className:K.dot}),x.jsx("div",{className:K.dot}),x.jsx("div",{className:K.dot})]}),x.jsx("span",{className:K.text,children:e})]})}const yt="_container_1xu4v_1",wt="_group_1xu4v_10",It="_button_1xu4v_15",Ct="_active_1xu4v_30",ee={container:yt,group:wt,button:It,active:Ct},At=[{label:"分时",periods:[{value:"timeline",label:"分时"},{value:"timeline5",label:"五日"}]},{label:"周期",periods:[{value:"daily",label:"日K"},{value:"weekly",label:"周K"},{value:"monthly",label:"月K"}]},{label:"分钟",periods:[{value:"1",label:"1分"},{value:"5",label:"5分"},{value:"15",label:"15分"},{value:"30",label:"30分"},{value:"60",label:"60分"}]}];function St({value:e,onChange:t}){return x.jsx("div",{className:ee.container,children:At.map(n=>x.jsx("div",{className:ee.group,children:n.periods.map(i=>x.jsx("button",{type:"button",className:`${ee.button} ${e===i.value?ee.active:""}`,onClick:()=>t(i.value),children:i.label},i.value))},n.label))})}const jt="_container_1fbmi_1",kt="_button_1fbmi_11",Mt="_active_1fbmi_27",$t="_divider_1fbmi_33",E={container:jt,button:kt,active:Mt,divider:$t},He=[{value:"ma",label:"MA",group:"main"},{value:"boll",label:"BOLL",group:"main"},{value:"sar",label:"SAR",group:"main"},{value:"kc",label:"KC",group:"main"}],Dt=[{value:"volume",label:"成交量",group:"sub"},{value:"macd",label:"MACD",group:"sub"},{value:"kdj",label:"KDJ",group:"sub"},{value:"rsi",label:"RSI",group:"sub"},{value:"wr",label:"WR",group:"sub"},{value:"bias",label:"BIAS",group:"sub"},{value:"cci",label:"CCI",group:"sub"},{value:"atr",label:"ATR",group:"sub"},{value:"obv",label:"OBV",group:"sub"},{value:"roc",label:"ROC",group:"sub"},{value:"dmi",label:"DMI",group:"sub"}];function de(e){return He.find(n=>n.value===e)?"main":"sub"}function _t({value:e,onChange:t,maxSubPanes:n=3,maxMainIndicators:i=2}){const u=r=>{const c=de(r);if(e.includes(r))t(e.filter(o=>o!==r));else if(c==="main"){const o=e.filter(l=>de(l)==="main");if(o.length>=i){const l=o[o.length-1],s=e.filter(a=>a!==l);t([...s,r])}else t([...e,r])}else{const o=e.filter(l=>de(l)==="sub");if(o.length>=n){const l=o[o.length-1],s=e.filter(a=>a!==l);t([...s,r])}else t([...e,r])}};return x.jsxs("div",{className:E.container,children:[He.map(r=>x.jsx("button",{type:"button",className:`${E.button} ${e.includes(r.value)?E.active:""}`,onClick:()=>u(r.value),children:r.label},r.value)),x.jsx("div",{className:E.divider}),Dt.map(r=>x.jsx("button",{type:"button",className:`${E.button} ${e.includes(r.value)?E.active:""}`,onClick:()=>u(r.value),children:r.label},r.value))]})}const Nt="_container_2tswg_1",Rt="_group_2tswg_10",Lt="_divider_2tswg_16",Tt="_spacer_2tswg_23",Pt="_iconButton_2tswg_27",Bt="_textButton_2tswg_51",Ot="_active_2tswg_67",k={container:Nt,group:Rt,divider:Lt,spacer:Tt,iconButton:Pt,textButton:Bt,active:Ot},Kt=[{value:"",label:"不复权"},{value:"qfq",label:"前复权"},{value:"hfq",label:"后复权"}];function Et({adjust:e,onAdjustChange:t,canUndo:n,canRedo:i,onUndo:u,onRedo:r,onZoomIn:c,onZoomOut:o,onPanLeft:l,onPanRight:s,onReset:a,onFullscreen:d}){return x.jsxs("div",{className:k.container,children:[x.jsxs("div",{className:k.group,children:[x.jsx("button",{type:"button",className:k.iconButton,onClick:u,disabled:!n,title:"撤销",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"})})}),x.jsx("button",{type:"button",className:k.iconButton,onClick:r,disabled:!i,title:"重做",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"})})})]}),x.jsx("div",{className:k.divider}),x.jsxs("div",{className:k.group,children:[x.jsx("button",{type:"button",className:k.iconButton,onClick:c,title:"放大",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})})}),x.jsx("button",{type:"button",className:k.iconButton,onClick:o,title:"缩小",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M19 13H5v-2h14v2z"})})})]}),x.jsx("div",{className:k.divider}),x.jsxs("div",{className:k.group,children:[x.jsx("button",{type:"button",className:k.iconButton,onClick:l,title:"向左",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),x.jsx("button",{type:"button",className:k.iconButton,onClick:s,title:"向右",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})})]}),x.jsx("div",{className:k.divider}),x.jsx("div",{className:k.group,children:x.jsx("button",{type:"button",className:k.textButton,onClick:a,title:"重置",children:"重置"})}),x.jsx("div",{className:k.spacer}),x.jsx("div",{className:k.group,children:Kt.map(f=>x.jsx("button",{type:"button",className:`${k.textButton} ${e===f.value?k.active:""}`,onClick:()=>t(f.value),children:f.label},f.value))}),d&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:k.divider}),x.jsx("button",{type:"button",className:k.iconButton,onClick:d,title:"全屏",children:x.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:x.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})})})]})]})}const zt="_container_1vdme_1",Vt="_group_1vdme_11",Ft="_item_1vdme_18",M={container:zt,group:Vt,item:Ft};function Ht({data:e,indicators:t,hoverIndex:n,theme:i}){const u=i.maColors,r=i.bollColors,c=i.kcColors,o=j.useMemo(()=>{const f=n??e.length-1,g=e[f];return g||null},[e,n]);if(!o)return null;const l=t.includes("ma"),s=t.includes("boll"),a=t.includes("sar"),d=t.includes("kc");return!l&&!s&&!a&&!d?null:x.jsxs("div",{className:M.container,children:[l&&o.ma&&x.jsx("div",{className:M.group,children:q(o.ma,"ma").map(([f,g],w)=>{const y=u[w]??"#999";return x.jsxs("span",{className:M.item,style:{color:y},children:[U(f),": ",b(g)]},f)})}),s&&o.boll&&x.jsxs("div",{className:M.group,children:[x.jsxs("span",{className:M.item,style:{color:r[0]},children:["UPPER: ",b(o.boll.upper)]}),x.jsxs("span",{className:M.item,style:{color:r[1]},children:["MID: ",b(o.boll.mid)]}),x.jsxs("span",{className:M.item,style:{color:r[2]},children:["LOWER: ",b(o.boll.lower)]})]}),a&&o.sar&&x.jsx("div",{className:M.group,children:x.jsxs("span",{className:M.item,style:{color:o.sar.trend===1?i.upColor:i.downColor},children:["SAR: ",b(o.sar.sar)," ",o.sar.trend===1?"↑":"↓"]})}),d&&o.kc&&x.jsxs("div",{className:M.group,children:[x.jsxs("span",{className:M.item,style:{color:c[0]},children:["KC上: ",b(o.kc.upper)]}),x.jsxs("span",{className:M.item,style:{color:c[1]},children:["KC中: ",b(o.kc.mid)]}),x.jsxs("span",{className:M.item,style:{color:c[2]},children:["KC下: ",b(o.kc.lower)]})]})]})}const qt="_title_p093j_1",Ut="_label_p093j_16",Yt="_value_p093j_21",he={title:qt,label:Ut,value:Yt},Wt={ma:"MA",boll:"BOLL",sar:"SAR",kc:"KC",volume:"成交量",macd:"MACD",kdj:"KDJ",rsi:"RSI",wr:"WR",bias:"BIAS",cci:"CCI",atr:"ATR",obv:"OBV",roc:"ROC",dmi:"DMI"};function Jt(e,t){if(!t)return"";switch(e){case"volume":return`VOL: ${R(t.volume)}`;case"macd":return t.macd?`DIF: ${b(t.macd.dif)} DEA: ${b(t.macd.dea)} MACD: ${b(t.macd.macd)}`:"";case"kdj":return t.kdj?`K: ${b(t.kdj.k)} D: ${b(t.kdj.d)} J: ${b(t.kdj.j)}`:"";case"rsi":return t.rsi?q(t.rsi,"rsi").map(([n,i])=>`${U(n)}: ${b(i)}`).join(" "):"";case"wr":return t.wr?q(t.wr,"wr").map(([n,i])=>`${U(n)}: ${b(i)}`).join(" "):"";case"bias":return t.bias?q(t.bias,"bias").map(([n,i])=>`${U(n)}: ${b(i)}`).join(" "):"";case"cci":return t.cci?`CCI: ${b(t.cci.cci)}`:"";case"atr":return t.atr?`ATR: ${b(t.atr.atr)}`:"";case"obv":return t.obv?`OBV: ${R(t.obv.obv)} MA: ${R(t.obv.obvMa)}`:"";case"roc":return t.roc?`ROC: ${b(t.roc.roc)} SIGNAL: ${b(t.roc.signal)}`:"";case"dmi":return t.dmi?`+DI: ${b(t.dmi.pdi)} -DI: ${b(t.dmi.mdi)} ADX: ${b(t.dmi.adx)}`:"";case"sar":return t.sar?`SAR: ${b(t.sar.sar)} ${t.sar.trend===1?"↑":"↓"}`:"";case"kc":return t.kc?`上: ${b(t.kc.upper)} 中: ${b(t.kc.mid)} 下: ${b(t.kc.lower)}`:"";default:return""}}function Zt(e,t){return Fe(e,t).map(i=>({top:i.top,height:i.height}))}function Gt({panes:e,data:t,hoverIndex:n,containerHeight:i}){const u=n??t.length-1,r=t[u],c=j.useMemo(()=>Zt(e,i),[e,i]),o=e.slice(1),l=c.slice(1);return o.length===0?null:x.jsx(x.Fragment,{children:o.map((s,a)=>{if(s.indicators.length===0)return null;const d=s.indicators.map(w=>Wt[w]||w.toUpperCase()).join(" / "),f=s.indicators.map(w=>Jt(w,r)).filter(Boolean).join(" | "),g=l[a];return x.jsxs("div",{className:he.title,style:{top:(g==null?void 0:g.top)??0},children:[x.jsx("span",{className:he.label,children:d}),f&&x.jsx("span",{className:he.value,children:f})]},s.id)})})}exports.DATA_ZOOM_INSIDE_ID=Ee;exports.DATA_ZOOM_SLIDER_ID=ze;exports.IndicatorDisplay=Ht;exports.IndicatorSelector=_t;exports.Loading=vt;exports.PeriodSelector=St;exports.SubPaneTitle=Gt;exports.Toolbar=Et;exports.buildOption=mt;exports.calcATR=me;exports.calcBIAS=Me;exports.calcBOLL=Ae;exports.calcCCI=$e;exports.calcDMI=Ne;exports.calcEMA=T;exports.calcKC=Le;exports.calcKDJ=Se;exports.calcMA=Ie;exports.calcMACD=Ce;exports.calcOBV=De;exports.calcROC=_e;exports.calcRSI=je;exports.calcSAR=Re;exports.calcSMA=z;exports.calcWMA=we;exports.calcWR=ke;exports.formatAmount=Oe;exports.formatChange=Be;exports.formatDate=dt;exports.formatKlineTooltip=Ke;exports.formatNumber=Te;exports.formatPercent=Pe;exports.formatPrice=b;exports.formatVolume=R;exports.getDefaultPanes=Ve;exports.mergeOption=ft;exports.useEcharts=lt;exports.useKlineData=nt;exports.useZoomHistory=st;
@@ -1,12 +1,13 @@
1
- import { KlineWithIndicators, IndicatorType } from '../../types';
1
+ import { KlineWithIndicators, IndicatorType, ThemeConfig } from '../../types';
2
2
  interface IndicatorDisplayProps {
3
3
  data: KlineWithIndicators[];
4
4
  indicators: IndicatorType[];
5
5
  hoverIndex?: number | null;
6
+ theme: ThemeConfig;
6
7
  }
7
8
  /**
8
9
  * 主图指标数值显示组件
9
10
  * 支持 MA、BOLL、SAR、KC 指标
10
11
  */
11
- export declare function IndicatorDisplay({ data, indicators, hoverIndex }: IndicatorDisplayProps): import("react/jsx-runtime").JSX.Element | null;
12
+ export declare function IndicatorDisplay({ data, indicators, hoverIndex, theme }: IndicatorDisplayProps): import("react/jsx-runtime").JSX.Element | null;
12
13
  export {};
@@ -8,10 +8,10 @@ interface SetOptionOpts {
8
8
  }
9
9
  interface UseEchartsResult {
10
10
  chartRef: React.RefObject<HTMLDivElement | null>;
11
- chartInstance: EChartsInstance | null;
12
11
  setOption: (option: EChartsOption, opts?: boolean | SetOptionOpts, lazyUpdate?: boolean) => void;
13
12
  resize: () => void;
14
13
  dispose: () => void;
14
+ getInstance: () => EChartsInstance | null;
15
15
  getDataURL: (opts?: {
16
16
  type?: 'png' | 'jpeg';
17
17
  pixelRatio?: number;
@@ -1,4 +1,4 @@
1
- import { KlineWithIndicators, TimelineData, PeriodType, MarketType, AdjustType, KLineDataProvider, SDKOptions, RequestOptions, IndicatorOptions } from '../types';
1
+ import { KlineWithIndicators, TimelineData, PeriodType, MarketType, AdjustType, IndicatorType, KLineDataProvider, SDKOptions, RequestOptions, IndicatorOptions } from '../types';
2
2
  interface UseKlineDataParams {
3
3
  symbol: string;
4
4
  market: MarketType;
@@ -8,7 +8,7 @@ interface UseKlineDataParams {
8
8
  sdkOptions?: SDKOptions;
9
9
  requestOptions?: RequestOptions;
10
10
  indicatorOptions?: IndicatorOptions;
11
- indicators?: string[];
11
+ indicators?: IndicatorType[];
12
12
  }
13
13
  interface UseKlineDataResult {
14
14
  data: KlineWithIndicators[];