openalgo-charts 1.0.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/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/index.d.ts +1621 -0
- package/dist/openalgo-charts.mjs +2 -0
- package/dist/openalgo-charts.mjs.map +1 -0
- package/dist/openalgo-charts.profile.mjs +2 -0
- package/dist/openalgo-charts.profile.mjs.map +1 -0
- package/dist/openalgo-charts.standalone.js +2 -0
- package/dist/openalgo-charts.standalone.js.map +1 -0
- package/dist/openalgo-charts.trade.mjs +2 -0
- package/dist/openalgo-charts.trade.mjs.map +1 -0
- package/dist/openalgo-charts.transform.mjs +2 -0
- package/dist/openalgo-charts.transform.mjs.map +1 -0
- package/dist/profile/index.d.ts +558 -0
- package/dist/trade/index.d.ts +680 -0
- package/dist/transform/index.d.ts +178 -0
- package/package.json +71 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={upColor:"#26a69a",downColor:"#ef5350",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350",borderVisible:!0,wickVisible:!0};function t(e,t){const o=Math.floor(e*t*.8);let r=Math.max(1,o);if(r>=2){r%2!=Math.max(1,Math.floor(t))%2&&(r-=1)}return Math.max(1,r)}function o(o,r,i,l,s,n=e){const a=t(l,s),h=Math.max(1,Math.floor(s));for(const{x:e,bar:t}of r){const r=t.close>=t.open,l=Math.round(e*s),c=Math.round(i(t.open)*s),u=Math.round(i(t.close)*s),b=Math.round(i(t.high)*s),f=Math.round(i(t.low)*s),m=n.widthScale?Math.max(.05,Math.min(1,n.widthScale(t))):1,d=1===m?a:Math.max(1,Math.round(a*m)),p=Math.floor(d/2);n.wickVisible&&(o.fillStyle=r?n.wickUpColor:n.wickDownColor,o.fillRect(l-Math.floor(h/2),b,h,Math.max(1,f-b)));const _=Math.min(c,u),x=Math.max(1,Math.abs(u-c)),w=r?n.upColor:n.downColor;n.hollow&&r?(o.strokeStyle=w,o.lineWidth=Math.max(1,h),o.strokeRect(l-p+.5,_+.5,d-1,x-1)):(o.fillStyle=w,o.fillRect(l-p,_,d,x),n.borderVisible&&d>=3&&!n.hollow&&(o.strokeStyle=r?n.borderUpColor:n.borderDownColor,o.lineWidth=1,o.strokeRect(l-p+.5,_+.5,d-1,x-1)))}}function r(e,t,o){const r=e.bar;return{cx:Math.round(e.x*o),yOpen:Math.round(t(r.open)*o),yClose:Math.round(t(r.close)*o),yHigh:Math.round(t(r.high)*o),yLow:Math.round(t(r.low)*o),up:r.close>=r.open}}function i(e,o,i,l,s,n,a=!1){const h=Math.max(1,Math.floor(t(l,s)/2)),c=Math.max(1,Math.floor(s));e.save();for(const t of o){const o=r(t,i,s);e.fillStyle=o.up?n.upColor??"#26a69a":n.downColor??"#ef5350",e.fillRect(o.cx-Math.floor(c/2),o.yHigh,c,Math.max(1,o.yLow-o.yHigh)),a||(e.fillRect(o.cx-h,o.yOpen,h,c),e.fillRect(o.cx,o.yClose,h,c))}e.restore()}const l=new WeakMap;function s(e,t,o,r){let i=l.get(e);void 0===i&&(i=new Map,l.set(e,i));const s=`${Math.round(t)}|${o}|${r}`;let n=i.get(s);return void 0===n&&(n=e.createLinearGradient(0,0,0,t),n.addColorStop(0,o),n.addColorStop(1,r),i.set(s,n)),n}function n(e,t,o=e=>e.close){return e.map(e=>({x:e.x,y:t(o(e.bar))}))}function a(e,t,o,r,i){const l=n(t,o),s=i.step?function(e){if(0===e.length)return[];const t=[{...e[0]}];for(let o=1;o<e.length;o++)t.push({x:e[o].x,y:e[o-1].y}),t.push({x:e[o].x,y:e[o].y});return t}(l):l;if(e.save(),e.strokeStyle=i.color??"#4f8cff",e.lineWidth=Math.max(1,Math.round((i.lineWidth??1.5)*r)),e.lineJoin="round",function(e,t,o){if(0===t.length)return;e.beginPath();let r=!1;for(const i of t)Number.isFinite(i.x)&&Number.isFinite(i.y)?r?e.lineTo(i.x*o,i.y*o):(e.moveTo(i.x*o,i.y*o),r=!0):r=!1;e.stroke()}(e,s,r),i.markers){const t=(i.markerRadius??2)*r;e.fillStyle=i.color??"#4f8cff";for(const o of l)Number.isFinite(o.x)&&Number.isFinite(o.y)&&(e.beginPath(),e.arc(o.x*r,o.y*r,t,0,2*Math.PI),e.fill())}e.restore()}const h={color:"#3a4666",base:0};function c(t,o,r={}){return{...e,upColor:t.upColor??o.upColor,downColor:t.downColor??o.downColor,borderUpColor:t.borderUpColor??o.upColor,borderDownColor:t.borderDownColor??o.downColor,wickUpColor:t.wickUpColor??o.wickUpColor,wickDownColor:t.wickDownColor??o.wickDownColor,borderVisible:t.borderVisible??e.borderVisible,wickVisible:t.wickVisible??e.wickVisible,...r}}const u=e=>({min:e.low,max:e.high}),b=e=>({min:e.close,max:e.close}),f=(e,t)=>{const o=t.base??0;return{min:Math.min(o,e.close),max:Math.max(o,e.close)}},m=new Map;function d(e,t){m.set(e,t)}const p=(e,t)=>({...e,upColor:e.upColor??t.upColor,downColor:e.downColor??t.downColor});function _(e){let t=-1/0;const o=[];for(const r of e){let e=r.time;e<=t&&(e=t+1),t=e,o.push(e===r.time?r:{...r,time:e})}return o}function x(e,t){e.reset();const o=[];for(const r of t)o.push(...e.push(r));return e.flush&&o.push(...e.flush()),_(o)}d("candlestick",{defaultStyle:{},isPriceSeries:!0,draw:(e,t,r,i,l,s,n)=>o(e,t,r,i,l,c(s,n.theme)),extents:u}),d("hollow-candle",{defaultStyle:{},isPriceSeries:!0,draw:(e,t,r,i,l,s,n)=>o(e,t,r,i,l,c(s,n.theme,{hollow:!0})),extents:u}),d("volume-candle",{defaultStyle:{},isPriceSeries:!0,draw:(e,t,r,i,l,s,n)=>{const a=n.maxVolume;o(e,t,r,i,l,c(s,n.theme,{widthScale:e=>a>0?(e.volume??0)/a:1}))},extents:u}),d("bar",{defaultStyle:{},isPriceSeries:!0,draw:(e,t,o,r,l,s,n)=>i(e,t,o,r,l,p(s,n.theme)),extents:u}),d("high-low",{defaultStyle:{},isPriceSeries:!0,draw:(e,t,o,r,l,s,n)=>i(e,t,o,r,l,p(s,n.theme),!0),extents:u}),d("line",{defaultStyle:{lineWidth:1.5},isPriceSeries:!0,draw:(e,t,o,r,i,l,s)=>a(e,t,o,i,{...l,color:l.color??s.theme.lineColor}),extents:b}),d("line-markers",{defaultStyle:{lineWidth:1.5,markers:!0},isPriceSeries:!0,draw:(e,t,o,r,i,l,s)=>a(e,t,o,i,{...l,color:l.color??s.theme.lineColor,markers:!0}),extents:b}),d("step",{defaultStyle:{lineWidth:1.5,step:!0},isPriceSeries:!0,draw:(e,t,o,r,i,l,s)=>a(e,t,o,i,{...l,color:l.color??s.theme.lineColor,step:!0}),extents:b}),d("area",{defaultStyle:{lineWidth:1.5},isPriceSeries:!0,draw:(e,t,o,r,i,l,h)=>function(e,t,o,r,i,l){const h=n(t,o);if(0===h.length)return;const c=i*r;e.save(),e.beginPath(),e.moveTo(h[0].x*r,c);for(const t of h)e.lineTo(t.x*r,t.y*r);e.lineTo(h[h.length-1].x*r,c),e.closePath(),e.fillStyle=s(e,c,l.areaTopColor??"rgba(79,140,255,0.40)",l.areaBottomColor??"rgba(79,140,255,0.00)"),e.fill(),e.restore(),a(e,t,o,r,{color:l.color??"#4f8cff",lineWidth:l.lineWidth??1.5})}(e,t,o,i,h.plotHeight,{...l,color:l.color??h.theme.lineColor,areaTopColor:l.areaTopColor??h.theme.areaTopColor,areaBottomColor:l.areaBottomColor??h.theme.areaBottomColor}),extents:b}),d("hlc-area",{defaultStyle:{lineWidth:1.5},isPriceSeries:!0,draw:(e,t,o,r,i,l,s)=>function(e,t,o,r,i){if(0===t.length)return;const l=n(t,o,e=>e.high),s=n(t,o,e=>e.low);e.save(),e.beginPath(),e.moveTo(l[0].x*r,l[0].y*r);for(const t of l)e.lineTo(t.x*r,t.y*r);for(let t=s.length-1;t>=0;t--)e.lineTo(s[t].x*r,s[t].y*r);e.closePath(),e.fillStyle=i.areaTopColor??"rgba(79,140,255,0.15)",e.fill(),e.restore(),a(e,t,o,r,{color:i.closeColor??"#4f8cff",lineWidth:i.lineWidth??1.5})}(e,t,o,i,{...l,closeColor:l.closeColor??s.theme.lineColor}),extents:u}),d("baseline",{defaultStyle:{baseValue:0,lineWidth:1.5},isPriceSeries:!0,draw:(e,t,o,r,i,l,a)=>function(e,t,o,r,i){const l=o(i.baseValue??0)*r,a=n(t,o);if(0===a.length)return;const h=a[0].x*r,c=a[a.length-1].x*r,u=()=>{e.beginPath(),e.moveTo(h,l);for(const t of a)e.lineTo(t.x*r,t.y*r);e.lineTo(c,l),e.closePath()},b=i.areaTopColor??"rgba(38,166,154,0.20)",f=i.areaBottomColor??"rgba(239,83,80,0.20)",m=1e5;e.save(),e.beginPath(),e.rect(h,l-m,c-h,m),e.clip(),u(),e.fillStyle=s(e,l,b,"rgba(0,0,0,0)"),e.fill(),e.restore(),e.save(),e.beginPath(),e.rect(h,l,c-h,m),e.clip(),u(),e.fillStyle=f,e.fill(),e.restore(),e.save();for(let t=1;t<a.length;t++){const o=a[t-1],s=a[t],n=(o.y+s.y)/2<=l/r;e.strokeStyle=n?i.topColor??"#26a69a":i.bottomColor??"#ef5350",e.lineWidth=Math.max(1,Math.round((i.lineWidth??1.5)*r)),e.beginPath(),e.moveTo(o.x*r,o.y*r),e.lineTo(s.x*r,s.y*r),e.stroke()}e.restore()}(e,t,o,i,{...l,topColor:l.topColor??a.theme.baselineTopLine,bottomColor:l.bottomColor??a.theme.baselineBottomLine,areaTopColor:l.areaTopColor??a.theme.baselineTopFill,areaBottomColor:l.areaBottomColor??a.theme.baselineBottomFill}),extents:(e,t)=>{const o=t.baseValue??0;return{min:Math.min(o,e.close),max:Math.max(o,e.close)}}}),d("column",{defaultStyle:{base:0},isPriceSeries:!1,draw:(e,o,i,l,s,n,a)=>function(e,o,i,l,s,n){const a=t(l,s),h=Math.floor(a/2),c=Math.round(i(n.base??0)*s);e.save();for(const t of o){const o=r(t,i,s);e.fillStyle=o.up?n.upColor??"#26a69a":n.downColor??"#ef5350";const l=Math.min(c,o.yClose);e.fillRect(o.cx-h,l,a,Math.max(1,Math.abs(c-o.yClose)))}e.restore()}(e,o,i,l,s,p(n,a.theme)),extents:f}),d("histogram",{defaultStyle:{base:0,color:"#3a4666"},isPriceSeries:!1,draw:(e,o,r,i,l,s)=>{!function(e,o,r,i,l,s=h){const n=t(i,l),a=Math.floor(n/2),c=Math.round(r(s.base)*l);e.fillStyle=s.color;for(const{x:t,bar:i}of o){const o=Math.round(t*l),s=Math.round(r(i.close)*l),h=Math.min(c,s),u=Math.max(1,Math.abs(c-s));e.fillRect(o-a,h,n,u)}}(e,o,r,i,l,{color:s.color??"#3a4666",base:s.base??0})},extents:f});class w{constructor(){Object.defineProperty(this,"_prevOpen",{enumerable:!0,configurable:!0,writable:!0,value:NaN}),Object.defineProperty(this,"_prevClose",{enumerable:!0,configurable:!0,writable:!0,value:NaN})}reset(){this._prevOpen=NaN,this._prevClose=NaN}push(e){const t=(e.open+e.high+e.low+e.close)/4,o=Number.isNaN(this._prevOpen)?(e.open+e.close)/2:(this._prevOpen+this._prevClose)/2,r=Math.max(e.high,o,t),i=Math.min(e.low,o,t);return this._prevOpen=o,this._prevClose=t,[{time:e.time,open:o,high:r,low:i,close:t,volume:e.volume}]}}class g{constructor(e){if(Object.defineProperty(this,"_box",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_edge",{enumerable:!0,configurable:!0,writable:!0,value:NaN}),e.boxSize<=0)throw new Error("openalgo-charts: Renko boxSize must be > 0");this._box=e.boxSize}reset(){this._edge=NaN}push(e){const t=e.close,o=[];if(Number.isNaN(this._edge))return this._edge=Math.floor(t/this._box)*this._box,o;for(;t>=this._edge+this._box;){const t=this._edge,r=this._edge+this._box;o.push({time:e.time,open:t,high:r,low:t,close:r}),this._edge=r}for(;t<=this._edge-this._box;){const t=this._edge,r=this._edge-this._box;o.push({time:e.time,open:t,high:t,low:r,close:r}),this._edge=r}return o}}class C{constructor(e){if(Object.defineProperty(this,"_range",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_cur",{enumerable:!0,configurable:!0,writable:!0,value:null}),e.range<=0)throw new Error("openalgo-charts: range must be > 0");this._range=e.range}reset(){this._cur=null}push(e){const t=e.close,o=[];return null===this._cur?this._cur={time:e.time,open:t,high:t,low:t,close:t}:(this._cur.high=Math.max(this._cur.high,t),this._cur.low=Math.min(this._cur.low,t),this._cur.close=t,this._cur.time=e.time),this._cur.high-this._cur.low>=this._range&&(o.push(this._cur),this._cur=null),o}flush(){if(null===this._cur)return[];const e=this._cur;return this._cur=null,[e]}}class v{constructor(e={lines:3}){Object.defineProperty(this,"_n",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_lines",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this._n=Math.max(1,e.lines)}reset(){this._lines=[]}push(e){const t=e.close;if(0===this._lines.length)return this._lines.push({open:t,close:t}),[];const o=this._lines.slice(-this._n);let r=-1/0,i=1/0;for(const e of o)r=Math.max(r,e.open,e.close),i=Math.min(i,e.open,e.close);const l=this._lines[this._lines.length-1];let s=null;return(t>r||t<i)&&(s={open:l.close,close:t}),null===s?[]:(this._lines.push(s),[{time:e.time,open:s.open,high:Math.max(s.open,s.close),low:Math.min(s.open,s.close),close:s.close}])}}class y{constructor(e){if(Object.defineProperty(this,"_box",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reversal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_dir",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_topBox",{enumerable:!0,configurable:!0,writable:!0,value:NaN}),Object.defineProperty(this,"_botBox",{enumerable:!0,configurable:!0,writable:!0,value:NaN}),Object.defineProperty(this,"_time",{enumerable:!0,configurable:!0,writable:!0,value:0}),e.boxSize<=0)throw new Error("openalgo-charts: P&F boxSize must be > 0");this._box=e.boxSize,this._reversal=Math.max(1,e.reversal)}reset(){this._dir=0,this._topBox=NaN,this._botBox=NaN,this._time=0}_column(){const e=this._topBox*this._box,t=this._botBox*this._box,o=this._dir>=0;return{time:this._time,open:o?t:e,close:o?e:t,high:e,low:t}}push(e){const t=Math.floor(e.close/this._box);if(Number.isNaN(this._topBox))return this._topBox=t,this._botBox=t,this._dir=0,this._time=e.time,[];const o=[];return this._dir>=0?t>this._topBox?(this._topBox=t,this._dir=1):this._topBox-t>=this._reversal&&(o.push(this._column()),this._dir=-1,this._topBox=this._topBox-1,this._botBox=t,this._time=e.time):t<this._botBox?this._botBox=t:t-this._botBox>=this._reversal&&(o.push(this._column()),this._dir=1,this._botBox=this._botBox+1,this._topBox=t,this._time=e.time),o}flush(){return Number.isNaN(this._topBox)?[]:[this._column()]}}function M(e,t,o){return{time:e,open:t,high:t,low:t,close:t,volume:o?1:0}}class S{constructor(e){if(Object.defineProperty(this,"_reversal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_dir",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_ext",{enumerable:!0,configurable:!0,writable:!0,value:NaN}),Object.defineProperty(this,"_prevShoulder",{enumerable:!0,configurable:!0,writable:!0,value:-1/0}),Object.defineProperty(this,"_prevWaist",{enumerable:!0,configurable:!0,writable:!0,value:1/0}),Object.defineProperty(this,"_thick",{enumerable:!0,configurable:!0,writable:!0,value:!1}),e.reversal<=0)throw new Error("openalgo-charts: Kagi reversal must be > 0");this._reversal=e.reversal}reset(){this._dir=0,this._ext=NaN,this._prevShoulder=-1/0,this._prevWaist=1/0,this._thick=!1}push(e){const t=e.close;if(Number.isNaN(this._ext))return this._ext=t,[];const o=[];return this._dir>=0?t>this._ext?(this._ext=t,t>this._prevShoulder&&(this._thick=!0)):this._ext-t>=this._reversal&&(o.push(M(e.time,this._ext,this._thick)),this._prevShoulder=this._ext,this._dir=-1,this._ext=t):t<this._ext?(this._ext=t,t<this._prevWaist&&(this._thick=!1)):t-this._ext>=this._reversal&&(o.push(M(e.time,this._ext,this._thick)),this._prevWaist=this._ext,this._dir=1,this._ext=t),o}flush(){return Number.isNaN(this._ext)?[]:[M(0,this._ext,this._thick)]}}const P="transform";let N=!1;function k(){N||(N=!0,d("point-figure",{defaultStyle:{},isPriceSeries:!0,draw:(e,t,o,r,i,l)=>function(e,t,o,r,i,l){const s=l.boxSize??0;if(s<=0)return;const n=Math.max(3,Math.floor(r*i*.7))/2;e.save(),e.lineWidth=Math.max(1,Math.floor(i));for(const{x:r,bar:a}of t){const t=a.close>=a.open;e.strokeStyle=t?l.upColor??"#26a69a":l.downColor??"#ef5350";const h=r*i;for(let r=a.low;r<a.high-1e-9;r+=s){const l=o(r+s)*i,a=o(r)*i,c=(l+a)/2;e.beginPath(),t?(e.moveTo(h-n,l),e.lineTo(h+n,a),e.moveTo(h+n,l),e.lineTo(h-n,a)):e.ellipse(h,c,n,Math.abs(a-l)/2,0,0,2*Math.PI),e.stroke()}}e.restore()}(e,t,o,r,i,l),extents:e=>({min:e.low,max:e.high})}),d("kagi",{defaultStyle:{thickColor:"#26a69a",thinColor:"#ef5350"},isPriceSeries:!0,draw:(e,t,o,r,i,l)=>function(e,t,o,r,i){if(t.length<2)return;const l=i.thickColor??"#26a69a",s=i.thinColor??"#ef5350",n=Math.max(2,Math.round(2.5*r)),a=Math.max(1,Math.round(r));e.save();for(let i=1;i<t.length;i++){const h=t[i-1],c=t[i],u=(c.bar.volume??0)>=1;e.strokeStyle=u?l:s,e.lineWidth=u?n:a;const b=h.x*r,f=c.x*r,m=o(h.bar.close)*r,d=o(c.bar.close)*r;e.beginPath(),e.moveTo(b,m),e.lineTo(f,m),e.lineTo(f,d),e.stroke()}e.restore()}(e,t,o,i,l),extents:e=>({min:e.close,max:e.close})}))}k();export{w as HeikinAshiTransform,S as KagiTransform,v as LineBreakTransform,y as PointFigureTransform,C as RangeBarsTransform,g as RenkoTransform,P as TRANSFORM_TIER,_ as ensureIncreasingTimes,k as registerTransformChartTypes,x as runTransform};
|
|
2
|
+
//# sourceMappingURL=openalgo-charts.transform.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openalgo-charts.transform.mjs","sources":["../src/render/candles.ts","../src/render/bars.ts","../src/render/gradient.ts","../src/render/line.ts","../src/render/histogram.ts","../src/model/chart-type-registry.ts","../src/transform/transform.ts","../src/transform/heikin-ashi.ts","../src/transform/renko.ts","../src/transform/range-bars.ts","../src/transform/line-break.ts","../src/transform/point-figure.ts","../src/transform/kagi.ts","../src/transform/index.ts","../src/render/point-figure.ts","../src/render/kagi.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["DEFAULT_CANDLE_STYLE","upColor","downColor","borderUpColor","borderDownColor","wickUpColor","wickDownColor","borderVisible","wickVisible","optimalBarWidth","barSpacing","dpr","raw","Math","floor","w","max","drawCandles","ctx","items","priceToY","style","bodyW","wickW","x","bar","up","close","open","cx","round","yOpen","yClose","yHigh","high","yLow","low","scale","widthScale","min","halfW","fillStyle","fillRect","top","bodyH","abs","color","hollow","strokeStyle","lineWidth","strokeRect","barGeometry","item","toY","b","drawBars","highLowOnly","tick","lw","save","g","restore","perCtx","WeakMap","verticalGradient","heightPx","topColor","bottomColor","m","get","undefined","Map","set","key","createLinearGradient","addColorStop","valuePoints","value","map","it","y","drawLine","base","pts","step","length","out","i","push","stepPoints","lineJoin","beginPath","drawing","p","Number","isFinite","lineTo","moveTo","stroke","strokePolyline","markers","r","markerRadius","arc","PI","fill","DEFAULT_HISTOGRAM_STYLE","candleStyle","s","theme","extra","hiLo","closeOnly","fromBase","registry","registerChartType","type","entry","ud","t","ensureIncreasingTimes","bars","prev","Infinity","time","runTransform","transform","reset","flush","defaultStyle","isPriceSeries","draw","bs","rc","extents","maxVolume","volume","_bs","lineColor","plotHeight","baseY","closePath","areaTopColor","areaBottomColor","drawArea","highs","lows","closeColor","drawHlcArea","baseValue","minX","maxX","buildArea","topFill","botFill","BIG","rect","clip","a","above","drawBaseline","baselineTopLine","baselineBottomLine","baselineTopFill","baselineBottomFill","half","drawColumns","valueToY","h","drawHistogram","HeikinAshiTransform","constructor","Object","defineProperty","this","NaN","_prevOpen","_prevClose","haClose","haOpen","isNaN","haHigh","haLow","RenkoTransform","options","boxSize","Error","_box","_edge","lo","hi","RangeBarsTransform","range","_range","_cur","c","LineBreakTransform","lines","_n","_lines","recent","slice","maxHigh","minLow","l","last","box","PointFigureTransform","_reversal","reversal","_dir","_topBox","_botBox","_time","_column","bot","vertex","price","thick","KagiTransform","_ext","_prevShoulder","_prevWaist","_thick","TRANSFORM_TIER","_registered","registerTransformChartTypes","level","yTop","yBot","cy","ellipse","drawPointFigure","thickColor","thinColor","thickW","thinW","cur","px","py","drawKagi"],"mappings":"AAqBO,MAAMA,EAAoC,CAC/CC,QAAS,UACTC,UAAW,UACXC,cAAe,UACfC,gBAAiB,UACjBC,YAAa,UACbC,cAAe,UACfC,eAAe,EACfC,aAAa,GAQC,SAAAC,EAAgBC,EAAoBC,GAClD,MAAMC,EAAMC,KAAKC,MAAMJ,EAAaC,EAAM,IAC1C,IAAII,EAAIF,KAAKG,IAAI,EAAGJ,GACpB,GAAIG,GAAK,EAAG,CAENA,EAAI,GADKF,KAAKG,IAAI,EAAGH,KAAKC,MAAMH,IACf,IAAGI,GAAK,GAE/B,OAAOF,KAAKG,IAAI,EAAGD,EACrB,CAYgB,SAAAE,EACdC,EACAC,EACAC,EACAV,EACAC,EACAU,EAAqBrB,GAErB,MAAMsB,EAAQb,EAAgBC,EAAYC,GACpCY,EAAQV,KAAKG,IAAI,EAAGH,KAAKC,MAAMH,IAErC,IAAK,MAAMa,EAAEA,EAACC,IAAEA,KAASN,EAAO,CAC9B,MAAMO,EAAKD,EAAIE,OAASF,EAAIG,KACtBC,EAAKhB,KAAKiB,MAAMN,EAAIb,GACpBoB,EAAQlB,KAAKiB,MAAMV,EAASK,EAAIG,MAAQjB,GACxCqB,EAASnB,KAAKiB,MAAMV,EAASK,EAAIE,OAAShB,GA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CtH,EAAI8B,YAAc0K,EAAQe,EAAaC,EACvCxN,EAAI+B,UAAYyK,EAAQiB,EAASC,EACjC,MAAME,EAAKpH,EAAKlG,EAAIb,EACdkB,EAAKgN,EAAIrN,EAAIb,EACboO,EAAK1L,EAAIqE,EAAKjG,IAAIE,OAAShB,EAC3B2N,EAAKjL,EAAIwL,EAAIpN,IAAIE,OAAShB,EAChCO,EAAIyE,YACJzE,EAAI+E,OAAO6I,EAAIC,GACf7N,EAAI8E,OAAOnE,EAAIkN,GACf7N,EAAI8E,OAAOnE,EAAIyM,GACfpN,EAAIgF,SAENhF,EAAI2C,SACN,CFR0CmL,CAASpL,EAAGzC,EAAOkC,EAAK1C,EAAKiG,GACnE0B,QAAU7G,IAAS,CAAEc,IAAKd,EAAIE,MAAOX,IAAKS,EAAIE,UAElD,CAEAuM"}
|
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile data model (ARCHITECTURE.md §6A, Family C). Price-bucketed
|
|
3
|
+
* distributions: volume-at-price, time-at-price (TPO), and bid/ask footprint.
|
|
4
|
+
*/
|
|
5
|
+
interface VolumeProfileResult {
|
|
6
|
+
/** Volume per price bucket, sorted high → low price. */
|
|
7
|
+
buckets: {
|
|
8
|
+
price: number;
|
|
9
|
+
volume: number;
|
|
10
|
+
}[];
|
|
11
|
+
/** Point of control: price bucket with the most volume. */
|
|
12
|
+
poc: number;
|
|
13
|
+
/** Value-area high / low (the price band holding `valueAreaPercent` of volume). */
|
|
14
|
+
vah: number;
|
|
15
|
+
val: number;
|
|
16
|
+
totalVolume: number;
|
|
17
|
+
}
|
|
18
|
+
interface TpoResult {
|
|
19
|
+
buckets: {
|
|
20
|
+
price: number;
|
|
21
|
+
count: number;
|
|
22
|
+
}[];
|
|
23
|
+
poc: number;
|
|
24
|
+
vah: number;
|
|
25
|
+
val: number;
|
|
26
|
+
/** Initial balance: price range of the first `ibPeriods` periods. */
|
|
27
|
+
ib: {
|
|
28
|
+
high: number;
|
|
29
|
+
low: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface FootprintCell {
|
|
33
|
+
price: number;
|
|
34
|
+
bidVol: number;
|
|
35
|
+
askVol: number;
|
|
36
|
+
}
|
|
37
|
+
interface FootprintBar {
|
|
38
|
+
time: number;
|
|
39
|
+
cells: FootprintCell[];
|
|
40
|
+
/** Net delta = Σ(askVol − bidVol). */
|
|
41
|
+
delta: number;
|
|
42
|
+
}
|
|
43
|
+
/** Bucket a price to the tick grid. */
|
|
44
|
+
declare function bucketPrice(price: number, step: number): number;
|
|
45
|
+
/** Inclusive list of bucket prices spanning [low, high]. */
|
|
46
|
+
declare function priceBuckets(low: number, high: number, step: number): number[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Internal time is always **UTC seconds** (integer). Feed adapters convert
|
|
50
|
+
* broker formats (IST strings, epoch ms) to this at the edge; see ARCHITECTURE.md §4.0.
|
|
51
|
+
*/
|
|
52
|
+
type UTCSeconds = number;
|
|
53
|
+
/** A single OHLC(V) bar. `volume` is optional (not all feeds carry it). */
|
|
54
|
+
interface Bar {
|
|
55
|
+
time: UTCSeconds;
|
|
56
|
+
open: number;
|
|
57
|
+
high: number;
|
|
58
|
+
low: number;
|
|
59
|
+
close: number;
|
|
60
|
+
volume?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Volume Profile (ARCHITECTURE.md §6A). Distributes each bar's volume across the
|
|
65
|
+
* price buckets it spans, then derives the Point of Control and Value Area.
|
|
66
|
+
* From OHLCV this is an approximation (uniform spread across the bar's range);
|
|
67
|
+
* exact profiles need tick data. Pure + testable.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
interface VolumeProfileOptions {
|
|
71
|
+
tickSize: number;
|
|
72
|
+
/** Fraction of total volume contained in the value area (default 0.7). */
|
|
73
|
+
valueAreaPercent: number;
|
|
74
|
+
}
|
|
75
|
+
declare function computeVolumeProfile(bars: readonly Bar[], tickSize: number, valueAreaPercent?: number): VolumeProfileResult;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Time Price Opportunity / Market Profile (ARCHITECTURE.md §6A). Buckets
|
|
79
|
+
* intraday bars into TPO periods and counts how many periods traded at each
|
|
80
|
+
* price. Derives POC, Value Area, and the Initial Balance (first periods'
|
|
81
|
+
* range). Derivable from OHLCV intraday bars. Pure + testable.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
declare function computeTpo(bars: readonly Bar[], periodBars: number, tickSize: number, valueAreaPercent?: number, ibPeriods?: number): TpoResult;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Market Profile / TPO (Time Price Opportunity) — ARCHITECTURE.md §6A, Family C.
|
|
88
|
+
*
|
|
89
|
+
* Groups bars into sessions (day / week / month / composite), splits each
|
|
90
|
+
* session into fixed-length time blocks ("periods", one letter each), and counts
|
|
91
|
+
* how many periods traded at each price. Derives the Point of Control, Value
|
|
92
|
+
* Area, Initial Balance, single prints, and poor highs/lows, plus volume at
|
|
93
|
+
* price. Pure and deterministic (no Date.now / Math.random), so it is fully
|
|
94
|
+
* unit-testable and derivable from intraday OHLCV bars alone.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
type MarketProfileSession = 'day' | 'week' | 'month' | 'composite';
|
|
98
|
+
interface MarketProfileOptions {
|
|
99
|
+
/** Price bucket size (the tick grid TPOs are counted on). */
|
|
100
|
+
tickSize: number;
|
|
101
|
+
/** Session grouping. `composite` builds one profile over all bars. */
|
|
102
|
+
session: MarketProfileSession;
|
|
103
|
+
/** TPO period length in minutes — one letter per period. */
|
|
104
|
+
blockMinutes: number;
|
|
105
|
+
/** Value-area fraction of total TPOs (0..1). */
|
|
106
|
+
valueAreaPercent: number;
|
|
107
|
+
/** Number of opening periods that form the Initial Balance. */
|
|
108
|
+
initialBalancePeriods: number;
|
|
109
|
+
}
|
|
110
|
+
declare const DEFAULT_MARKET_PROFILE_OPTIONS: MarketProfileOptions;
|
|
111
|
+
interface MarketProfileLevel {
|
|
112
|
+
price: number;
|
|
113
|
+
/** Distinct periods (TPOs) that traded at this price. */
|
|
114
|
+
count: number;
|
|
115
|
+
/** Period letters at this price, in period order (e.g. `"ABF"`). */
|
|
116
|
+
letters: string;
|
|
117
|
+
/** Volume traded at this price (each bar's volume split across its range). */
|
|
118
|
+
volume: number;
|
|
119
|
+
}
|
|
120
|
+
interface MarketProfileSessionResult {
|
|
121
|
+
/** UTC seconds of the session's first and last bar. */
|
|
122
|
+
startTime: number;
|
|
123
|
+
endTime: number;
|
|
124
|
+
/** Price levels, sorted high -> low. */
|
|
125
|
+
levels: MarketProfileLevel[];
|
|
126
|
+
/** Point of control (price with the most TPOs). */
|
|
127
|
+
poc: number;
|
|
128
|
+
/** Value-area high / low. */
|
|
129
|
+
vah: number;
|
|
130
|
+
val: number;
|
|
131
|
+
/** Number of periods (letters) in the session. */
|
|
132
|
+
periods: number;
|
|
133
|
+
/** Initial balance — price range of the opening `initialBalancePeriods`. */
|
|
134
|
+
initialBalance: {
|
|
135
|
+
high: number;
|
|
136
|
+
low: number;
|
|
137
|
+
};
|
|
138
|
+
/** Prices that printed a single TPO away from the session extremes. */
|
|
139
|
+
singlePrints: number[];
|
|
140
|
+
/** True when the session high / low printed more than one TPO (weak extreme). */
|
|
141
|
+
poorHigh: boolean;
|
|
142
|
+
poorLow: boolean;
|
|
143
|
+
/** Total traded volume in the session. */
|
|
144
|
+
totalVolume: number;
|
|
145
|
+
}
|
|
146
|
+
interface MarketProfileResult {
|
|
147
|
+
sessions: MarketProfileSessionResult[];
|
|
148
|
+
options: MarketProfileOptions;
|
|
149
|
+
}
|
|
150
|
+
/** Period index -> TPO letter (`A`-`Z`, then `a`-`z`, then wraps). */
|
|
151
|
+
declare function tpoLetter(period: number): string;
|
|
152
|
+
declare function computeMarketProfile(bars: readonly Bar[], options?: Partial<MarketProfileOptions>): MarketProfileResult;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Footprint & order flow (ARCHITECTURE.md §6A, Family C). Per-candle bid/ask
|
|
156
|
+
* volume at each price, delta, and imbalance — plus cumulative delta and
|
|
157
|
+
* stacked-imbalance detection across bars.
|
|
158
|
+
*
|
|
159
|
+
* DATA DEPENDENCY (honest): this needs trade-by-trade data classified bid/ask
|
|
160
|
+
* (was each print at the bid or the ask?). OpenAlgo serves live depth + tick LTP
|
|
161
|
+
* but does not store historical classified trades by default, so footprint is
|
|
162
|
+
* either live-session-only or needs a tick-recorder backend. The computation
|
|
163
|
+
* here is pure and broker-agnostic; feeding it is the integration step.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
interface ClassifiedTrade {
|
|
167
|
+
price: number;
|
|
168
|
+
qty: number;
|
|
169
|
+
/** Whether the print hit the bid (sell-initiated) or the ask (buy-initiated). */
|
|
170
|
+
side: 'bid' | 'ask';
|
|
171
|
+
}
|
|
172
|
+
/** Build one bar's footprint from its classified trades. */
|
|
173
|
+
declare function computeFootprint(time: number, trades: readonly ClassifiedTrade[], tickSize: number): FootprintBar;
|
|
174
|
+
interface Imbalance {
|
|
175
|
+
price: number;
|
|
176
|
+
side: 'buy' | 'sell';
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Diagonal imbalances: buy when ask volume at price P dominates bid volume at
|
|
180
|
+
* P−1 tick by `ratio`; sell when bid at P dominates ask at P+1 tick.
|
|
181
|
+
*/
|
|
182
|
+
declare function diagonalImbalances(cells: readonly FootprintCell[], ratio?: number): Imbalance[];
|
|
183
|
+
/** Running cumulative delta across a sequence of footprint bars. */
|
|
184
|
+
declare function cumulativeDelta(bars: readonly FootprintBar[]): number[];
|
|
185
|
+
interface StackedImbalance {
|
|
186
|
+
startPrice: number;
|
|
187
|
+
endPrice: number;
|
|
188
|
+
side: 'buy' | 'sell';
|
|
189
|
+
count: number;
|
|
190
|
+
}
|
|
191
|
+
/** Runs of `minStack`+ consecutive same-side diagonal imbalances. */
|
|
192
|
+
declare function stackedImbalances(cells: readonly FootprintCell[], ratio?: number, minStack?: number): StackedImbalance[];
|
|
193
|
+
|
|
194
|
+
interface LogicalRange {
|
|
195
|
+
from: number;
|
|
196
|
+
to: number;
|
|
197
|
+
}
|
|
198
|
+
interface TimeScaleOptions {
|
|
199
|
+
barSpacing: number;
|
|
200
|
+
minBarSpacing: number;
|
|
201
|
+
maxBarSpacing: number;
|
|
202
|
+
/** Empty bars of space kept to the right of the latest bar. */
|
|
203
|
+
rightOffset: number;
|
|
204
|
+
}
|
|
205
|
+
declare class TimeScale {
|
|
206
|
+
private _barSpacing;
|
|
207
|
+
private _rightOffset;
|
|
208
|
+
private readonly _minBarSpacing;
|
|
209
|
+
private readonly _maxBarSpacing;
|
|
210
|
+
private _width;
|
|
211
|
+
private _baseIndex;
|
|
212
|
+
constructor(options?: Partial<TimeScaleOptions>);
|
|
213
|
+
setWidth(width: number): void;
|
|
214
|
+
get width(): number;
|
|
215
|
+
get barSpacing(): number;
|
|
216
|
+
setBarSpacing(value: number): void;
|
|
217
|
+
get rightOffset(): number;
|
|
218
|
+
setRightOffset(value: number): void;
|
|
219
|
+
/** Logical index of the latest bar; the right edge anchors to baseIndex+rightOffset. */
|
|
220
|
+
setBaseIndex(index: number): void;
|
|
221
|
+
private _rightEdgeIndex;
|
|
222
|
+
/** Logical index → x (media px), bar center. */
|
|
223
|
+
indexToX(index: number): number;
|
|
224
|
+
/** x (media px) → fractional logical index. */
|
|
225
|
+
xToIndex(x: number): number;
|
|
226
|
+
/** Currently visible logical index range (fractional, unclamped to data). */
|
|
227
|
+
visibleRange(): LogicalRange;
|
|
228
|
+
/**
|
|
229
|
+
* Pan by a pixel delta. Positive `dx` drags chart content to the right
|
|
230
|
+
* (revealing older bars), matching a natural left-button drag.
|
|
231
|
+
*/
|
|
232
|
+
scrollByPixels(dx: number): void;
|
|
233
|
+
/**
|
|
234
|
+
* Zoom around an anchor x (the cursor): change bar spacing by `factor`
|
|
235
|
+
* while keeping whatever logical index sits under `focusX` pinned there.
|
|
236
|
+
* `factor` > 1 zooms in (wider bars).
|
|
237
|
+
*/
|
|
238
|
+
zoomAtX(focusX: number, factor: number): void;
|
|
239
|
+
/** Choose bar spacing so `barCount` bars fit the width, anchored at the right edge. */
|
|
240
|
+
fitContent(barCount: number): void;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface PriceRange {
|
|
244
|
+
min: number;
|
|
245
|
+
max: number;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Price-scale mode. `linear` and `logarithmic` are full coordinate transforms;
|
|
249
|
+
* `percentage`/`indexed-to-100` (rebase to a baseline) and overlay scales are
|
|
250
|
+
* not yet implemented — see END_TO_END_AUDIT.md / README known limitations.
|
|
251
|
+
*/
|
|
252
|
+
type PriceScaleMode = 'linear' | 'logarithmic';
|
|
253
|
+
interface PriceScaleOptions {
|
|
254
|
+
/** Fraction of pane height kept empty at top/bottom (default 0.1 each). */
|
|
255
|
+
marginTop: number;
|
|
256
|
+
marginBottom: number;
|
|
257
|
+
/** Instrument tick size (minMove), e.g. 0.05. 0 → infer from range. */
|
|
258
|
+
minMove: number;
|
|
259
|
+
/** Linear or logarithmic price↔y mapping. */
|
|
260
|
+
mode: PriceScaleMode;
|
|
261
|
+
/** Flip the axis (price increases downward) — for spread/short views. */
|
|
262
|
+
inverted: boolean;
|
|
263
|
+
}
|
|
264
|
+
declare class PriceScale {
|
|
265
|
+
private _options;
|
|
266
|
+
private _height;
|
|
267
|
+
private _min;
|
|
268
|
+
private _max;
|
|
269
|
+
private _autoScale;
|
|
270
|
+
constructor(options?: Partial<PriceScaleOptions>);
|
|
271
|
+
get options(): PriceScaleOptions;
|
|
272
|
+
setHeight(height: number): void;
|
|
273
|
+
get height(): number;
|
|
274
|
+
setPriceRange(range: PriceRange): void;
|
|
275
|
+
priceRange(): PriceRange;
|
|
276
|
+
/** Whether the range tracks the data (true) or has been set manually (false). */
|
|
277
|
+
get autoScale(): boolean;
|
|
278
|
+
setAutoScale(on: boolean): void;
|
|
279
|
+
/**
|
|
280
|
+
* Manually scale the visible range around its centre. `factor` > 1 widens the
|
|
281
|
+
* range (compress / zoom out), < 1 narrows it (expand / zoom in). Switches the
|
|
282
|
+
* scale to manual mode so autoscale stops overriding it.
|
|
283
|
+
*/
|
|
284
|
+
scaleAroundCenter(factor: number): void;
|
|
285
|
+
/**
|
|
286
|
+
* Pan the visible range vertically by `dy` media px (dragging the plot up/down).
|
|
287
|
+
* Works in transformed space so it's correct for log scales, and respects
|
|
288
|
+
* `inverted`. Switches to manual mode so autoscale stops overriding it.
|
|
289
|
+
*/
|
|
290
|
+
panByPixels(dy: number): void;
|
|
291
|
+
/** Recompute the visible range from data extremes + configured margins. */
|
|
292
|
+
autoscale(low: number, high: number): void;
|
|
293
|
+
/** Coordinate transform for the active mode (identity for linear, log10 for log). */
|
|
294
|
+
private _t;
|
|
295
|
+
private _tInv;
|
|
296
|
+
/** Price → y (media px). Higher price → smaller y (top of pane), unless inverted. */
|
|
297
|
+
priceToY(price: number): number;
|
|
298
|
+
/** y (media px) → price. */
|
|
299
|
+
yToPrice(y: number): number;
|
|
300
|
+
/** Decimal precision implied by minMove (or the visible range if unset). */
|
|
301
|
+
precision(): number;
|
|
302
|
+
/** Snap a price to the instrument tick size (no-op if minMove is 0). */
|
|
303
|
+
snapToTick(price: number): number;
|
|
304
|
+
/** Format a price for axis/label display. */
|
|
305
|
+
format(price: number): string;
|
|
306
|
+
/** Clamp a y to the pane (used by crosshair/order dragging). */
|
|
307
|
+
clampY(y: number): number;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Shared data layer (ARCHITECTURE.md §4.1). One per chart. Merges all series by
|
|
312
|
+
* time onto a single logical-index space (0..N-1) so price + volume + indicator
|
|
313
|
+
* panes stay aligned, and so non-trading gaps collapse (an absent time simply
|
|
314
|
+
* has no logical index). Per-series rows are addressable by that shared index.
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
type SeriesId = number;
|
|
318
|
+
interface IndexedBar {
|
|
319
|
+
index: number;
|
|
320
|
+
bar: Bar;
|
|
321
|
+
}
|
|
322
|
+
declare class DataLayer {
|
|
323
|
+
private readonly _series;
|
|
324
|
+
private _sortedTimes;
|
|
325
|
+
private readonly _indexByTime;
|
|
326
|
+
private _nextId;
|
|
327
|
+
/** Register a new series; returns its id. */
|
|
328
|
+
createSeries(): SeriesId;
|
|
329
|
+
removeSeries(id: SeriesId): void;
|
|
330
|
+
/** Bulk-load (full replace) one series' data, then re-merge the time axis. */
|
|
331
|
+
setSeriesData(id: SeriesId, bars: readonly Bar[]): void;
|
|
332
|
+
/**
|
|
333
|
+
* Upsert bars into a series by time (used for history paging / backfill /
|
|
334
|
+
* out-of-order corrections — ARCHITECTURE.md §4.2). Existing times are
|
|
335
|
+
* replaced; new times are inserted; the result stays time-sorted.
|
|
336
|
+
*
|
|
337
|
+
* Prepending older bars shifts every existing logical index up by the
|
|
338
|
+
* inserted count — callers preserve the viewport by re-reading `baseIndex`
|
|
339
|
+
* (the invariant `rightEdge − index` is unchanged, so visible bars don't move).
|
|
340
|
+
*/
|
|
341
|
+
addBars(id: SeriesId, bars: readonly Bar[]): void;
|
|
342
|
+
/**
|
|
343
|
+
* Apply a single live bar (ARCHITECTURE.md §4.2 hot path). Returns the kind of
|
|
344
|
+
* change so the chart auto-scrolls only on a genuine right-edge append:
|
|
345
|
+
* - `'append'` → newer than the last bar (advances baseIndex)
|
|
346
|
+
* - `'replace'` → same time as the last bar (intra-bar tick) or an existing time
|
|
347
|
+
* - `'insert'` → an older time inserted into history (late / out-of-order)
|
|
348
|
+
*/
|
|
349
|
+
update(id: SeriesId, bar: Bar): 'append' | 'replace' | 'insert';
|
|
350
|
+
private _appendTime;
|
|
351
|
+
/** Number of logical indices (distinct time points across all series). */
|
|
352
|
+
get length(): number;
|
|
353
|
+
/** Logical index of the latest real bar (length - 1), or -1 if empty. */
|
|
354
|
+
get baseIndex(): number;
|
|
355
|
+
indexToTime(index: number): number | undefined;
|
|
356
|
+
timeToIndex(time: number): number | undefined;
|
|
357
|
+
/** All bars of a series paired with their shared logical index. */
|
|
358
|
+
indexedBars(id: SeriesId): IndexedBar[];
|
|
359
|
+
/** Bars of a series whose logical index lies within [fromIndex, toIndex]. */
|
|
360
|
+
visibleBars(id: SeriesId, fromIndex: number, toIndex: number): IndexedBar[];
|
|
361
|
+
private _rebuild;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Chart theme (palette). A single object drives chart chrome (background, grid,
|
|
366
|
+
* axes, crosshair), series defaults (up/down, line, area gradient, last price),
|
|
367
|
+
* and the trade layer (buy/sell, profit/loss). Renderers read theme colors when
|
|
368
|
+
* a per-series style field is absent, so one theme restyles the whole chart.
|
|
369
|
+
*/
|
|
370
|
+
interface ChartTheme {
|
|
371
|
+
background: string;
|
|
372
|
+
grid: string;
|
|
373
|
+
axisText: string;
|
|
374
|
+
axisLine: string;
|
|
375
|
+
crosshair: string;
|
|
376
|
+
upColor: string;
|
|
377
|
+
downColor: string;
|
|
378
|
+
wickUpColor: string;
|
|
379
|
+
wickDownColor: string;
|
|
380
|
+
lineColor: string;
|
|
381
|
+
areaTopColor: string;
|
|
382
|
+
areaBottomColor: string;
|
|
383
|
+
baselineTopLine: string;
|
|
384
|
+
baselineTopFill: string;
|
|
385
|
+
baselineBottomLine: string;
|
|
386
|
+
baselineBottomFill: string;
|
|
387
|
+
lastPriceUp: string;
|
|
388
|
+
lastPriceDown: string;
|
|
389
|
+
lastPriceText: string;
|
|
390
|
+
buy: string;
|
|
391
|
+
sell: string;
|
|
392
|
+
profit: string;
|
|
393
|
+
loss: string;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Primitive / plugin API (ARCHITECTURE.md §8). The extension point that keeps
|
|
398
|
+
* the core small and powers markers, events, indicators, and the trade layer.
|
|
399
|
+
* A primitive draws on a pane, optionally contributes to autoscale, and
|
|
400
|
+
* optionally hit-tests for hover/drag.
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
type ZOrder = 'bottom' | 'normal' | 'top';
|
|
404
|
+
interface PrimitiveRenderContext {
|
|
405
|
+
timeScale: TimeScale;
|
|
406
|
+
priceScale: PriceScale;
|
|
407
|
+
dataLayer: DataLayer;
|
|
408
|
+
plotWidth: number;
|
|
409
|
+
plotHeight: number;
|
|
410
|
+
priceAxisWidth: number;
|
|
411
|
+
dpr: number;
|
|
412
|
+
theme: ChartTheme;
|
|
413
|
+
}
|
|
414
|
+
interface PrimitiveHit {
|
|
415
|
+
externalId: string;
|
|
416
|
+
zOrder: ZOrder;
|
|
417
|
+
/** Pixel distance from the cursor (smaller wins ties before z-order). */
|
|
418
|
+
distance: number;
|
|
419
|
+
cursor?: string;
|
|
420
|
+
}
|
|
421
|
+
/** Injected when a primitive is attached; lets it request a repaint. */
|
|
422
|
+
interface PrimitiveHost {
|
|
423
|
+
requestUpdate(): void;
|
|
424
|
+
}
|
|
425
|
+
interface IPrimitive {
|
|
426
|
+
/** Layer order vs series: 'bottom' (behind), 'normal' (over), 'top' (overlay). */
|
|
427
|
+
zOrder(): ZOrder;
|
|
428
|
+
draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
|
|
429
|
+
/** Optional: expand the pane's autoscale range so this primitive isn't clipped. */
|
|
430
|
+
autoscaleInfo?(): {
|
|
431
|
+
min: number;
|
|
432
|
+
max: number;
|
|
433
|
+
} | null;
|
|
434
|
+
/** Optional: topmost hit under (x,y) in media px (relative to the pane plot). */
|
|
435
|
+
hitTest?(x: number, y: number, rc: PrimitiveRenderContext): PrimitiveHit | null;
|
|
436
|
+
attached?(host: PrimitiveHost): void;
|
|
437
|
+
detached?(): void;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Profile renderers (ARCHITECTURE.md §6A). HorizontalProfile draws volume-at-
|
|
442
|
+
* price / TPO-count bars sideways with POC + Value-Area lines; Footprint draws
|
|
443
|
+
* per-candle bid×ask cells colored by delta. Both are pane primitives (drawn
|
|
444
|
+
* behind/over the candles) — profiles overlay the existing price range, so they
|
|
445
|
+
* do not drive autoscale.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
interface ProfileLevel {
|
|
449
|
+
price: number;
|
|
450
|
+
value: number;
|
|
451
|
+
}
|
|
452
|
+
interface HorizontalProfileOptions {
|
|
453
|
+
buckets: ProfileLevel[];
|
|
454
|
+
poc: number;
|
|
455
|
+
vah: number;
|
|
456
|
+
val: number;
|
|
457
|
+
/** Strip width in media px. */
|
|
458
|
+
width: number;
|
|
459
|
+
side: 'left' | 'right';
|
|
460
|
+
barColor: string;
|
|
461
|
+
vaColor: string;
|
|
462
|
+
}
|
|
463
|
+
declare class HorizontalProfile implements IPrimitive {
|
|
464
|
+
private _opts;
|
|
465
|
+
private _host;
|
|
466
|
+
constructor(opts: HorizontalProfileOptions);
|
|
467
|
+
attached(host: PrimitiveHost): void;
|
|
468
|
+
detached(): void;
|
|
469
|
+
zOrder(): ZOrder;
|
|
470
|
+
autoscaleInfo(): null;
|
|
471
|
+
setData(opts: HorizontalProfileOptions): void;
|
|
472
|
+
draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
|
|
473
|
+
}
|
|
474
|
+
interface FootprintOptions {
|
|
475
|
+
/** Full bar width (bid half + ask half), media px. */
|
|
476
|
+
cellWidth: number;
|
|
477
|
+
/** Diagonal-imbalance ratio for the outline boxes. */
|
|
478
|
+
imbalanceRatio: number;
|
|
479
|
+
/** Price step → row height. Inferred from cell spacing when omitted. */
|
|
480
|
+
tickSize?: number;
|
|
481
|
+
/** Cell text size, media px (default 10). */
|
|
482
|
+
font?: number;
|
|
483
|
+
/** Draw the per-bar delta + volume footer band (default true). */
|
|
484
|
+
footer?: boolean;
|
|
485
|
+
}
|
|
486
|
+
declare class Footprint implements IPrimitive {
|
|
487
|
+
private _bars;
|
|
488
|
+
private _opts;
|
|
489
|
+
private _host;
|
|
490
|
+
constructor(opts?: Partial<FootprintOptions>);
|
|
491
|
+
attached(host: PrimitiveHost): void;
|
|
492
|
+
detached(): void;
|
|
493
|
+
zOrder(): ZOrder;
|
|
494
|
+
autoscaleInfo(): null;
|
|
495
|
+
setBars(bars: FootprintBar[]): void;
|
|
496
|
+
/** Row height in device px from the tick size (option, else the min cell gap). */
|
|
497
|
+
private _rowHeight;
|
|
498
|
+
draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Tick aggregation (ARCHITECTURE.md §10.2). Aggregates raw trade ticks into
|
|
503
|
+
* bars on a chosen timeframe — clock interval, tick count, or traded volume.
|
|
504
|
+
* Incremental and deterministic, so it works live and is unit-testable.
|
|
505
|
+
*
|
|
506
|
+
* This is the foundation for tick / volume timeframes and (with classified
|
|
507
|
+
* bid/ask ticks) for the footprint aggregator. Tick-count and volume bars need
|
|
508
|
+
* real trade ticks — OHLCV alone can't produce them.
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
type TickTimeframe = {
|
|
512
|
+
mode: 'interval';
|
|
513
|
+
seconds: number;
|
|
514
|
+
anchorSec?: number;
|
|
515
|
+
} | {
|
|
516
|
+
mode: 'ticks';
|
|
517
|
+
count: number;
|
|
518
|
+
} | {
|
|
519
|
+
mode: 'volume';
|
|
520
|
+
perBar: number;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Streaming footprint aggregator (ARCHITECTURE.md §6A, §9.4). Ingests classified
|
|
525
|
+
* trade ticks (price, qty, bid/ask) and aggregates them into footprint bars on a
|
|
526
|
+
* timeframe (interval / tick-count / volume) — the live orderflow pipeline.
|
|
527
|
+
* Incremental: the current bar updates per tick; a new bar opens at the boundary.
|
|
528
|
+
*
|
|
529
|
+
* Requires classified bid/ask trade ticks. OpenAlgo doesn't store these by
|
|
530
|
+
* default, so feed it from a live WS classifier or a tick-recorder backend.
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
interface FootprintTick extends ClassifiedTrade {
|
|
534
|
+
time: number;
|
|
535
|
+
}
|
|
536
|
+
interface FootprintUpdate {
|
|
537
|
+
bar: FootprintBar;
|
|
538
|
+
isNew: boolean;
|
|
539
|
+
}
|
|
540
|
+
declare class FootprintAggregator {
|
|
541
|
+
private readonly _tf;
|
|
542
|
+
private readonly _tickSize;
|
|
543
|
+
private _time;
|
|
544
|
+
private _cells;
|
|
545
|
+
private _delta;
|
|
546
|
+
private _count;
|
|
547
|
+
private _volume;
|
|
548
|
+
private _open;
|
|
549
|
+
constructor(tf: TickTimeframe, tickSize: number);
|
|
550
|
+
private _snapshot;
|
|
551
|
+
current(): FootprintBar | null;
|
|
552
|
+
private _intervalKey;
|
|
553
|
+
onTick(tick: FootprintTick): FootprintUpdate;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
declare const PROFILE_TIER: "profile";
|
|
557
|
+
|
|
558
|
+
export { type ClassifiedTrade, DEFAULT_MARKET_PROFILE_OPTIONS, Footprint, FootprintAggregator, type FootprintBar, type FootprintCell, type FootprintOptions, type FootprintTick, type FootprintUpdate, HorizontalProfile, type HorizontalProfileOptions, type Imbalance, type MarketProfileLevel, type MarketProfileOptions, type MarketProfileResult, type MarketProfileSession, type MarketProfileSessionResult, PROFILE_TIER, type ProfileLevel, type StackedImbalance, type TpoResult, type VolumeProfileOptions, type VolumeProfileResult, bucketPrice, computeFootprint, computeMarketProfile, computeTpo, computeVolumeProfile, cumulativeDelta, diagonalImbalances, priceBuckets, stackedImbalances, tpoLetter };
|