@tradecanvas/commons 1.7.0 → 1.10.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 +21 -21
- package/README.md +67 -67
- package/dist/constants/themes.d.ts +19 -0
- package/dist/constants/themes.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +268 -230
- package/dist/index.js.map +1 -1
- package/dist/types/chart.d.ts +10 -0
- package/dist/types/chart.d.ts.map +1 -1
- package/dist/types/events.d.ts +12 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/time.d.ts +12 -2
- package/dist/utils/time.d.ts.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 TradeCanvas Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TradeCanvas Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# @tradecanvas/commons
|
|
2
|
-
|
|
3
|
-
Shared types, utilities, constants, themes, i18n, and market presets for the [@tradecanvas/chart](https://www.npmjs.com/package/@tradecanvas/chart) library.
|
|
4
|
-
|
|
5
|
-
**[Live Demo](https://bonguynvan.github.io/tradecanvas/)** | **[GitHub](https://github.com/bonguynvan/tradecanvas)** | **[Documentation](https://bonguynvan.github.io/tradecanvas/docs/getting-started/)**
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
You don't need to install this package directly. It's included as a dependency of `@tradecanvas/chart`.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @tradecanvas/chart
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## What's Inside
|
|
16
|
-
|
|
17
|
-
### Types
|
|
18
|
-
|
|
19
|
-
All TypeScript interfaces and types used across the library:
|
|
20
|
-
|
|
21
|
-
- `OHLCBar`, `DataSeries`, `TimeFrame` -- data format
|
|
22
|
-
- `ChartOptions`, `ChartType`, `FeaturesConfig` -- chart configuration
|
|
23
|
-
- `Theme`, `ThemeName` -- theming
|
|
24
|
-
- `IndicatorPlugin`, `IndicatorDescriptor`, `IndicatorConfig` -- indicators
|
|
25
|
-
- `DrawingToolType`, `DrawingState`, `DrawingStyle` -- drawing tools
|
|
26
|
-
- `TradingPosition`, `TradingOrder`, `TradingConfig` -- trading overlay
|
|
27
|
-
- `DataAdapter`, `StreamConfig`, `ConnectionState` -- real-time streaming
|
|
28
|
-
- `ChartEventType`, `ChartEvent` -- events
|
|
29
|
-
- `MarketConfig`, `TradingSession` -- market configuration
|
|
30
|
-
|
|
31
|
-
### Themes
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { DARK_THEME, LIGHT_THEME } from '@tradecanvas/commons'
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
19 customizable properties: `background`, `text`, `candleUp`, `candleDown`, `grid`, `crosshair`, `volumeUp`, `volumeDown`, and more.
|
|
38
|
-
|
|
39
|
-
### Constants
|
|
40
|
-
|
|
41
|
-
- Default chart options and feature flags
|
|
42
|
-
- Market presets: `MARKET_HOSE`, `MARKET_HNX`, `MARKET_UPCOM`, `MARKET_CRYPTO`, `MARKET_NYSE`
|
|
43
|
-
- Vietnamese stock market color schemes
|
|
44
|
-
|
|
45
|
-
### Utilities
|
|
46
|
-
|
|
47
|
-
- `computePriceRange()` -- compute visible price range from OHLC data
|
|
48
|
-
- `timeframeToMs()` -- convert timeframe string to milliseconds
|
|
49
|
-
- `formatNumber()`, `formatVND()`, `formatVolumeLoc()` -- number formatting
|
|
50
|
-
- Color, math, precision, and data manipulation helpers
|
|
51
|
-
|
|
52
|
-
### i18n
|
|
53
|
-
|
|
54
|
-
Built-in locales: English (`en`), Vietnamese (`vi`). Extensible via `registerLocale()`.
|
|
55
|
-
|
|
56
|
-
## Direct Usage
|
|
57
|
-
|
|
58
|
-
If you need just the types or utilities without the full chart:
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
import type { OHLCBar, TimeFrame, ChartType } from '@tradecanvas/commons'
|
|
62
|
-
import { DARK_THEME, computePriceRange, timeframeToMs } from '@tradecanvas/commons'
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## License
|
|
66
|
-
|
|
67
|
-
[MIT](https://github.com/bonguynvan/tradecanvas/blob/main/LICENSE)
|
|
1
|
+
# @tradecanvas/commons
|
|
2
|
+
|
|
3
|
+
Shared types, utilities, constants, themes, i18n, and market presets for the [@tradecanvas/chart](https://www.npmjs.com/package/@tradecanvas/chart) library.
|
|
4
|
+
|
|
5
|
+
**[Live Demo](https://bonguynvan.github.io/tradecanvas/)** | **[GitHub](https://github.com/bonguynvan/tradecanvas)** | **[Documentation](https://bonguynvan.github.io/tradecanvas/docs/getting-started/)**
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
You don't need to install this package directly. It's included as a dependency of `@tradecanvas/chart`.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @tradecanvas/chart
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What's Inside
|
|
16
|
+
|
|
17
|
+
### Types
|
|
18
|
+
|
|
19
|
+
All TypeScript interfaces and types used across the library:
|
|
20
|
+
|
|
21
|
+
- `OHLCBar`, `DataSeries`, `TimeFrame` -- data format
|
|
22
|
+
- `ChartOptions`, `ChartType`, `FeaturesConfig` -- chart configuration
|
|
23
|
+
- `Theme`, `ThemeName` -- theming
|
|
24
|
+
- `IndicatorPlugin`, `IndicatorDescriptor`, `IndicatorConfig` -- indicators
|
|
25
|
+
- `DrawingToolType`, `DrawingState`, `DrawingStyle` -- drawing tools
|
|
26
|
+
- `TradingPosition`, `TradingOrder`, `TradingConfig` -- trading overlay
|
|
27
|
+
- `DataAdapter`, `StreamConfig`, `ConnectionState` -- real-time streaming
|
|
28
|
+
- `ChartEventType`, `ChartEvent` -- events
|
|
29
|
+
- `MarketConfig`, `TradingSession` -- market configuration
|
|
30
|
+
|
|
31
|
+
### Themes
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { DARK_THEME, LIGHT_THEME } from '@tradecanvas/commons'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
19 customizable properties: `background`, `text`, `candleUp`, `candleDown`, `grid`, `crosshair`, `volumeUp`, `volumeDown`, and more.
|
|
38
|
+
|
|
39
|
+
### Constants
|
|
40
|
+
|
|
41
|
+
- Default chart options and feature flags
|
|
42
|
+
- Market presets: `MARKET_HOSE`, `MARKET_HNX`, `MARKET_UPCOM`, `MARKET_CRYPTO`, `MARKET_NYSE`
|
|
43
|
+
- Vietnamese stock market color schemes
|
|
44
|
+
|
|
45
|
+
### Utilities
|
|
46
|
+
|
|
47
|
+
- `computePriceRange()` -- compute visible price range from OHLC data
|
|
48
|
+
- `timeframeToMs()` -- convert timeframe string to milliseconds
|
|
49
|
+
- `formatNumber()`, `formatVND()`, `formatVolumeLoc()` -- number formatting
|
|
50
|
+
- Color, math, precision, and data manipulation helpers
|
|
51
|
+
|
|
52
|
+
### i18n
|
|
53
|
+
|
|
54
|
+
Built-in locales: English (`en`), Vietnamese (`vi`). Extensible via `registerLocale()`.
|
|
55
|
+
|
|
56
|
+
## Direct Usage
|
|
57
|
+
|
|
58
|
+
If you need just the types or utilities without the full chart:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import type { OHLCBar, TimeFrame, ChartType } from '@tradecanvas/commons'
|
|
62
|
+
import { DARK_THEME, computePriceRange, timeframeToMs } from '@tradecanvas/commons'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
[MIT](https://github.com/bonguynvan/tradecanvas/blob/main/LICENSE)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Theme } from '../types/theme.js';
|
|
2
|
+
/** The chart's own type: the system UI face, so text matches the page around it. */
|
|
3
|
+
export declare const DEFAULT_FONT_FAMILY = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif";
|
|
2
4
|
/**
|
|
3
5
|
* TradeCanvas palette. Themes pick their own candle colours for their
|
|
4
6
|
* background; everything drawn on top of either theme (indicators, orders,
|
|
@@ -26,9 +28,26 @@ export declare const TC_PALETTE: {
|
|
|
26
28
|
/** Ink ground of the dark theme. */
|
|
27
29
|
readonly ink: "#0c1016";
|
|
28
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* How strongly volume bars show: the candle colour at this opacity, so they
|
|
33
|
+
* read as a backdrop under the candles rather than a second chart.
|
|
34
|
+
*/
|
|
35
|
+
export declare const VOLUME_ALPHA = 0.22;
|
|
36
|
+
/** The volume bar colour for a candle colour. */
|
|
37
|
+
export declare function volumeColor(candleColor: string): string;
|
|
29
38
|
/** Order in which overlay indicators are coloured when no colour is given. */
|
|
30
39
|
export declare const TC_SERIES_COLORS: readonly string[];
|
|
31
40
|
export declare const DARK_THEME: Theme;
|
|
32
41
|
export declare const LIGHT_THEME: Theme;
|
|
33
42
|
export declare const DARK_TERMINAL: Theme;
|
|
43
|
+
/**
|
|
44
|
+
* The volume bars' colours for `theme`: its own `volumeUp` / `volumeDown`,
|
|
45
|
+
* except that a theme spread from a preset with new candle colours (and the
|
|
46
|
+
* preset's volume left in place) gets volume in its candles' colours, as the
|
|
47
|
+
* bars have always followed the candles.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveVolumeColors(theme: Pick<Theme, 'candleUp' | 'candleDown' | 'volumeUp' | 'volumeDown'>): {
|
|
50
|
+
up: string;
|
|
51
|
+
down: string;
|
|
52
|
+
};
|
|
34
53
|
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/constants/themes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/constants/themes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,wEAAsE,CAAC;AASvG;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;IACrB,4DAA4D;;IAE5D,mDAAmD;;IAEnD,oDAAoD;;IAEpD,4EAA4E;;IAE5E,sCAAsC;;;;;IAKtC,kCAAkC;;IAElC,oCAAoC;;CAE5B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEvD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAM7C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAoBxB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAoBzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAyB3B,CAAC;AAKF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAO3I"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=function(e){return e[e.Background=0]=`Background`,e[e.Main=1]=`Main`,e[e.Panel=2]=`Panel`,e[e.Overlay=3]=`Overlay`,e[e.UI=4]=`UI`,e[e.Hover=5]=`Hover`,e}({}),t={color:`#4c8dff`,lineWidth:1,lineStyle:`solid`,fillColor:`rgba(76, 141, 255, 0.1)`,fillOpacity:.1,fontSize:12},n={enabled:!0,orderColors:{buy:`#1fa874`,sell:`#e8505b`},positionColors:{profit:`#1fa874`,loss:`#e8505b`,entry:`#4c8dff`},depthOverlay:{enabled:!1,bidColor:`rgba(31, 168, 116,0.15)`,askColor:`rgba(232, 80, 91,0.15)`,maxWidth:100},contextMenu:{enabled:!0},lineButtons:{cancel:!0,close:!0,reverse:!0,removeStops:!0},fillMarks:!0,pricePrecision:2,dragThreshold:3},r={longColor:`#1fa874`,shortColor:`#e8505b`,neutralColor:`#9E9E9E`,arrowSize:12,showLabel:!0,showConfidence:!0},i={profitColor:`#1fa874`,lossColor:`#e8505b`,activeColor:`#4c8dff`,fillOpacity:.12,borderWidth:1,showLabel:!0,showPnl:!0},a={enabled:!0,maxRetries:1/0,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2},o={historyLimit:500,autoScroll:!0,showCurrentPriceLine:!0,aggregateTicks:!1},s=[`change`,`changePercent`,`open`,`high`,`low`,`prevClose`,`volume`,`bid`,`ask`,`time`];function c(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.symbol==`string`?t.symbol.trim():``;if(!n||n.length>64||!l(t.last))return null;let r={symbol:n,last:t.last};for(let e of s){let n=t[e];l(n)&&(r[e]=n)}let i=r.prevClose??r.open;if(r.change===void 0&&i!==void 0&&(r.change=r.last-i),r.changePercent===void 0&&r.change!==void 0){let e=r.last-r.change;e!==0&&(r.changePercent=r.change/e*100)}return r}function l(e){return typeof e==`number`&&Number.isFinite(e)}var u=300,d=1e3,f=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n?n.slice(0,t):void 0},ee=e=>{if(typeof e==`string`)try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.href:void 0}catch{return}};function te(e,t=20){if(!Array.isArray(e))return[];let n=[];for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,r=f(e.title,u);if(!r||typeof e.time!=`number`||!Number.isFinite(e.time))continue;let i={title:r,time:e.time},a=ee(e.url);a&&(i.url=a);let o=f(e.source,u);o&&(i.source=o);let s=f(e.summary,d);s&&(i.summary=s);let c=f(e.id,u);c&&(i.id=c),n.push(i)}return n.sort((e,t)=>t.time-e.time).slice(0,Math.max(0,t))}function ne(e,t,n){return Math.max(t,Math.min(n,e))}function re(e,t,n){return e+(t-e)*n}function ie(e,t,n){return e===t?0:(n-e)/(t-e)}function ae(e,t){return Math.round(e/t)*t}function p(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function m(e,t,n){return p(p(t-e,!1)/(n-1),!0)}function h(e){return e>0xe8d4a51000?e:e*1e3}function oe(e){return{time:h(e.time??e.t??0),open:e.open??e.o??0,high:e.high??e.h??0,low:e.low??e.l??0,close:e.close??e.c??0,volume:e.volume??e.v??0}}function se(e,t,n){let r=Math.max(0,t),i=Math.min(e.length,n+1);return e.slice(r,i)}function ce(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1;if(e[i].time<t)n=i+1;else if(e[i].time>t)r=i-1;else return i}return n}function le(e,t,n,r=.05){if(e.length===0)return{min:0,max:1};let i=Math.max(0,t),a=Math.min(e.length-1,n),o=1/0,s=-1/0;for(let t=i;t<=a;t++)e[t].low<o&&(o=e[t].low),e[t].high>s&&(s=e[t].high);if(o===1/0)return{min:0,max:1};let c=s-o||1;return{min:o-c*r,max:s+c*r}}function ue(e,t){return{...e,high:Math.max(e.high,t.price),low:Math.min(e.low,t.price),close:t.price,volume:e.volume+(t.volume??0),time:t.time}}function g(e,t=1){return`rgba(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)}, ${t})`}function de(e,t){if(e.startsWith(`#`))return g(e,t);let n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return n?`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t})`:e}function fe(e,t,n){let r=e=>(e=e.replace(`#`,``),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}),i=r(e),a=r(t);return`rgb(${Math.round(i.r+(a.r-i.r)*n)},${Math.round(i.g+(a.g-i.g)*n)},${Math.round(i.b+(a.b-i.b)*n)})`}var _=6e4,v=1440*_,y=15*_,pe=8192,b=7*v,me=4096,he=new Set([`UTC`,`Etc/UTC`,`GMT`,`Etc/GMT`,`UCT`,`Etc/UCT`,`Universal`,`Etc/Universal`,`Zulu`,`Etc/Zulu`]),ge=new Map,x=new Map,_e=new Map;function ve(e){let t=ge.get(e);return t||(t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),ge.set(e,t)),t}function ye(e){if(!e)return!1;try{return ve(e),!0}catch{return!1}}function S(e,t){if(!Number.isFinite(t)||he.has(e))return 0;let n=_e.get(e);n||(n=new Map,_e.set(e,n));let r=Math.floor(t/b),i=n.get(r);return i||(i=be(e,r*b),n.size>=me&&n.clear(),n.set(r,i)),t<i.change?i.before:i.after}function be(e,t){let n=C(e,t),r=t+b-y,i=C(e,r);if(i===n)return{before:n,change:1/0,after:i};let a=t;for(;r-a>y;){let t=a+Math.floor((r-a)/y/2)*y;C(e,t)===n?a=t:r=t}return{before:n,change:r,after:i}}function C(e,t){let n=Math.floor(t/y),r=`${e}|${n}`,i=x.get(r);if(i!==void 0)return i;let a=n*y,o=1970,s=1,c=1,l=0,u=0,d=0;for(let t of ve(e).formatToParts(new Date(a))){let e=Number(t.value);switch(t.type){case`year`:o=e;break;case`month`:s=e;break;case`day`:c=e;break;case`hour`:l=e%24;break;case`minute`:u=e;break;case`second`:d=e;break}}let f=Math.round((Date.UTC(o,s-1,c,l,u,d)-a)/_);return x.size>=pe&&x.clear(),x.set(r,f),f}function w(e,t){return e===null?-new Date(t).getTimezoneOffset():typeof e==`number`?e:S(e,t)}function xe(e,t){let n=e-w(t,e-v)*_;if(n+w(t,n)*_===e)return n;let r=e-w(t,e+v)*_;return r+w(t,r)*_===e?r:n}var T=new Map;function Se(e,t,n){let r=`${e}|${JSON.stringify(t)}|${n===null?`local`:typeof n==`number`?`fixed:${n}`:n}`,i=T.get(r);if(i)return i;let a=n===null?void 0:typeof n==`number`?`UTC`:n,o;try{o=new Intl.DateTimeFormat(e,{...t,timeZone:a})}catch{o=new Intl.DateTimeFormat(`en-US`,{...t,timeZone:a})}let s=typeof n==`number`?n*_:0;return i=e=>o.format(new Date(e+s)),T.set(r,i),i}var Ce={"1s":1e3,"5s":5e3,"15s":15e3,"30s":3e4,"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"45m":27e5,"1h":36e5,"2h":72e5,"3h":108e5,"4h":144e5,"6h":216e5,"8h":288e5,"12h":432e5,"1d":864e5,"2d":1728e5,"3d":2592e5,"1w":6048e5,"2w":12096e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"12M":31536e6},E={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,M:2592e6},we=/^([1-9]\d*)([smhdwM])$/;function D(e){let t=we.exec(e);if(!t)return null;let n=Number(t[1]);return Number.isSafeInteger(n)?{count:n,unit:t[2]}:null}var Te=1e6;function Ee(e){let t=/^([1-9]\d*)T$/.exec(e);if(!t)return null;let n=Number(t[1]);return Number.isSafeInteger(n)&&n<=Te?n:null}function De(e){return D(e)!==null}function O(e){let t=Ce[e];if(t!==void 0)return t;let n=D(e);return n?n.count*E[n.unit]:NaN}function Oe(e,t){let n=new Date(e),r=O(t);return r>=864e5?n.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):r>=36e5?n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function ke(e,t){let n=O(t);return Math.floor(e/n)*n}function Ae(e,t){if(t===null){let t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hours:t.getHours(),minutes:t.getMinutes()}}let n=new Date(e+w(t,e)*6e4);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hours:n.getUTCHours(),minutes:n.getUTCMinutes()}}function je(e){return e.hours===0&&e.minutes===0}function Me(e,t=Date.now()){let n=w(e,t),r=n>=0?`+`:`-`,i=Math.abs(n),a=Math.floor(i/60),o=i%60;return o===0?`UTC${r}${a}`:`UTC${r}${a}:${String(o).padStart(2,`0`)}`}var k=Date.UTC(1970,0,5);function A(e,t,n=1){let{count:r,unit:i}=D(t)??{count:1,unit:`m`};if(i===`s`||i===`m`||i===`h`||i===`d`){let t=r*E[i];return Math.floor(e/t)*t}let a=new Date(e);if(i===`w`){let e=E.d,t=(a.getUTCDay()-n+7)%7,i=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()-t);if(r<=1)return i;let o=Math.floor((i-k)/(7*e));return k+Math.floor(o/r)*r*7*e}let o=a.getUTCFullYear()*12+a.getUTCMonth(),s=Math.floor(o/r)*r;return Date.UTC(Math.floor(s/12),s%12,1)}var Ne=64,j=new Map;function Pe(e,t){let n=`${e}|${t}`,r=j.get(n);return r||(j.size>=Ne&&j.clear(),r=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t}),j.set(n,r)),r}function M(e,t=2,n=`en-US`){return Pe(n,t).format(e)}function Fe(e,t){if(!(t>e)||!Number.isFinite(e)||!Number.isFinite(t))return 2;let n=m(e,t,8);return n>0&&n<1?Math.ceil(-Math.log10(n))+1:2}function Ie(e,t,n,r=2,i=`en-US`){if((t===`percentage`||t===`indexedTo100`)&&n&&n!==0){if(t===`percentage`){let t=(e/n-1)*100;return`${t>0?`+`:``}${t.toFixed(2)}%`}return M(e/n*100,2,i)}return M(e,r,i)}function N(e,t,n=1){let r=Number.isInteger(n)&&n>1?n:1;if(!Number.isFinite(e)||!Number.isInteger(t)||t<2)return String(e);let i=t*r,a=Math.round(Math.abs(e)*i),o=Math.floor(a/i),s=a-o*i,c=Math.floor(s/r),l=String(t-1).length,u=r>1?String(Math.floor((s-c*r)/r*10)):``;return`${e<0&&a>0?`-`:``}${o}'${String(c).padStart(l,`0`)}${u}`}function P(e){if(!Number.isInteger(e.denominator)||e.denominator<2)return null;let t=Number.isInteger(e.subDenominator)&&(e.subDenominator??0)>1?e.subDenominator:1;return 1/(e.denominator*t)}function Le(e){return e?typeof e==`function`?e:P(e)===null?null:t=>N(t,e.denominator,e.subDenominator):null}function Re(e){return e>=1e9?(e/1e9).toFixed(2)+`B`:e>=1e6?(e/1e6).toFixed(2)+`M`:e>=1e3?(e/1e3).toFixed(2)+`K`:e.toFixed(0)}function ze(e){let t=0;for(let n of e){let e=n.toString(),r=e.indexOf(`.`);r>=0&&(t=Math.max(t,e.length-r-1))}return Math.min(t,8)}var F=[`close`,`open`,`high`,`low`,`hl2`,`hlc3`,`ohlc4`,`hlcc4`];function Be(e){return typeof e==`string`&&F.includes(e)}function Ve(e,t){switch(t){case`open`:return e.open;case`high`:return e.high;case`low`:return e.low;case`hl2`:return(e.high+e.low)/2;case`hlc3`:return(e.high+e.low+e.close)/3;case`ohlc4`:return(e.open+e.high+e.low+e.close)/4;case`hlcc4`:return(e.high+e.low+2*e.close)/4;default:return e.close}}var He=/^ind:([^:]+):(.+)$/;function Ue(e,t){return`ind:${e}:${t}`}function We(e){if(typeof e!=`string`)return null;let t=He.exec(e);return t?{instanceId:t[1],key:t[2]}:null}var Ge=864e5;function Ke(e,t,n=1){let r=[],i=null;for(let a of e){let e=A(a.time,t,n);i===null||e!==i.time?(i={time:e,open:a.open,high:a.high,low:a.low,close:a.close,volume:a.volume},r.push(i)):(a.high>i.high&&(i.high=a.high),a.low<i.low&&(i.low=a.low),i.close=a.close,i.volume+=a.volume)}return r}var I=e=>e===`s`||e===`m`||e===`h`||e===`d`;function qe(e,t){let n=D(e),r=D(t);if(!n||!r)return!1;let i=O(e);return n.unit===`d`&&n.count>1?!1:I(r.unit)?I(n.unit)&&O(t)%i===0:n.unit===r.unit?r.count%n.count===0:I(n.unit)&&Ge%i===0}function Je(e,t){let n=null,r=0;for(let i of t){if(!qe(i,e))continue;let t=O(i);t>r&&(n=i,r=t)}return n}function L(e,t){if(!e)return 0;if(e===t)return 1e3;if(e.startsWith(t))return 600-Math.min(100,e.length-t.length);let n=e.indexOf(t);return n>=0?300-Math.min(100,n):0}function Ye(e,t,n=50,r){let i=t.trim().toUpperCase();if(!i)return e.slice(0,n);let a=[];for(let t of e){let e=Math.max(L(t.symbol.toUpperCase(),i),L((t.description??``).toUpperCase(),i)*.8);e>0&&a.push({info:t,score:e+(r?.(t)??0)})}return a.sort((e,t)=>t.score-e.score||e.info.symbol.localeCompare(t.info.symbol)),a.slice(0,n).map(e=>e.info)}function Xe(e){let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t)||t<=0)return 0;for(let e=0;e<=12;e++){let n=t*10**e;if(Math.abs(n-Math.round(n))<1e-9*Math.max(1,n))return e}return 12}function R(e){let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n===24&&r===0?1440:n<24&&r<60?n*60+r:null}var z=864e5,B=6e4,Ze=8;function Qe(e,t){let n=e?.timezone,r=(e?.sessions??[]).flatMap(e=>{let t=R(e.start),n=R(e.end);return t===null||n===null||t===n?[]:[{start:t,end:n,days:Array.isArray(e.days)?e.days:null}]});if(!n||!ye(n)||r.length===0||!Number.isFinite(t))return{state:`always`,next:null};let i=S(n,t)*B,a=Math.floor((t+i)/z)*z,o=e=>e-S(n,e-S(n,e-i)*B)*B,s=[];for(let e=-1;e<=Ze;e++){let t=a+e*z,n=(Math.floor(t/z)+4)%7;for(let e of r){if(e.days&&!e.days.includes(n))continue;let r=t+e.start*B,i=(e.end>e.start?t:t+z)+e.end*B;s.push([o(r),o(i)])}}s.sort((e,t)=>e[0]-t[0]);let c=[];for(let[e,t]of s){let n=c[c.length-1];n&&e<=n[1]?c[c.length-1]=[n[0],Math.max(n[1],t)]:c.push([e,t])}let l=c.find(([e,n])=>e<=t&&t<n);if(l)return{state:`open`,next:l[1]};let u=c.find(([e])=>e>t);return{state:`closed`,next:u?u[0]:null}}var $e=48,et=2e3,tt=1e4;function nt(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(t.length>=$e)break;if(typeof n!=`object`||!n)continue;let{value:e,visible:r,color:i}=n;if(typeof e!=`number`||!Number.isFinite(e)||Math.abs(e)>tt||r!==void 0&&typeof r!=`boolean`)continue;let a={value:e,visible:r??!0};typeof i==`string`&&i&&(a.color=i),t.push(a)}return t}function V(e,t){switch(e.kind){case`boolean`:return typeof t==`boolean`?t:void 0;case`number`:return typeof t!=`number`||!Number.isFinite(t)?void 0:Math.min(e.max??1/0,Math.max(e.min??-1/0,t));case`choice`:return typeof t==`string`&&e.choices.some(e=>e.value===t)?t:void 0;case`levels`:return nt(t);case`text`:return typeof t==`string`?t.slice(0,et):void 0}}function rt(e,t){if(!e||typeof t!=`object`||!t)return{};let n={};for(let[r,i]of Object.entries(t)){let t=e[r];if(!t)continue;let a=V(t,i);a!==void 0&&(n[r]=a)}return n}function it(e){return Array.isArray(e)?e.map(e=>({...e})):e}function at(e,t,n){let r=e?.[n];return r?it((t&&n in t?V(r,t[n]):void 0)??r.default):t?.[n]}function ot(e,t){let n={};for(let r of Object.keys(e??{}))n[r]=at(e,t,r);return n}var st=[`solid`,`dashed`,`dotted`],ct=64,lt=2e3,ut=20,dt=200;function H(e,t,n){return typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):void 0}function ft(e){return typeof e==`string`&&e.length>0&&e.length<=ct?e:void 0}function pt(e){if(typeof e!=`object`||!e)return{};let t=e,n={},r=ft(t.color);r!==void 0&&(n.color=r);let i=H(t.lineWidth,.5,ut);i!==void 0&&(n.lineWidth=i),st.includes(t.lineStyle)&&(n.lineStyle=t.lineStyle);let a=ft(t.fillColor);a!==void 0&&(n.fillColor=a);let o=H(t.fillOpacity,0,1);o!==void 0&&(n.fillOpacity=o);let s=H(t.fontSize,6,dt);return s!==void 0&&(n.fontSize=s),typeof t.text==`string`&&(n.text=t.text.slice(0,lt)),n}var U=e=>typeof e==`number`&&Number.isFinite(e)&&e>0,W=(e,t,n)=>typeof e==`number`&&Number.isInteger(e)&&e>=t&&e<=n,G=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function mt(e){if(!G(e))return{};let t={};if(G(e.renko)){let{boxSize:n,atrPeriod:r}=e.renko;t.renko={...U(n)||n===`atr`?{boxSize:n}:{},...W(r,1,500)?{atrPeriod:r}:{}}}if(G(e.lineBreak)){let{lines:n}=e.lineBreak;t.lineBreak=W(n,1,10)?{lines:n}:{}}if(G(e.kagi)){let{reversal:n,reversalType:r}=e.kagi;t.kagi={...U(n)?{reversal:n}:{},...r===`percent`||r===`price`?{reversalType:r}:{}}}if(G(e.pointAndFigure)){let{boxSize:n,reversal:r}=e.pointAndFigure;t.pointAndFigure={...U(n)||n===`auto`?{boxSize:n}:{},...W(r,1,10)?{reversal:r}:{}}}if(G(e.rangeBars)){let{range:n}=e.rangeBars;t.rangeBars=U(n)||n===`auto`?{range:n}:{}}return t}var ht={autoScale:!0,rightMargin:5,minBarSpacing:2,maxBarSpacing:30,grid:{visible:!0,hLineStyle:`solid`,vLineStyle:`solid`},crosshair:{mode:`magnet`}},gt=[`1s`,`1m`,`3m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`6h`,`8h`,`12h`,`1d`,`3d`,`1w`,`1M`],_t=[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`1d`,`1w`,`1M`,`3M`,`6M`,`12M`],vt=[`1m`,`5m`,`15m`,`30m`,`1h`,`4h`,`1d`,`1w`,`1M`],yt=[`1m`,`5m`,`15m`,`1h`,`4h`,`1d`,`1w`],bt=8,xt=2,St=70,Ct=30,wt=60,Tt=120,Et={family:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,sizeSmall:10,sizeMedium:12,sizeLarge:14},K={amber:`#f2a93b`,up:`#1fa874`,down:`#e8505b`,ochre:`#c98316`,blue:`#4c8dff`,violet:`#a57cff`,cyan:`#1398a8`,rose:`#e25592`,neutral:`#7d8696`,ink:`#0c1016`},Dt=[K.blue,K.ochre,K.violet,K.cyan,K.rose],Ot={name:`dark`,background:K.ink,text:`#d9dde4`,textSecondary:`#7d8696`,grid:`#161b23`,crosshair:`#8a93a3`,candleUp:`#3ccf91`,candleDown:`#f0616d`,candleUpWick:`#3ccf91`,candleDownWick:`#f0616d`,lineColor:K.amber,areaTopColor:`rgba(242, 169, 59, 0.32)`,areaBottomColor:`rgba(242, 169, 59, 0.0)`,volumeUp:`rgba(60, 207, 145, 0.28)`,volumeDown:`rgba(240, 97, 109, 0.28)`,axisLine:`#1f2630`,axisLabel:`#c3c9d3`,axisLabelBackground:`#1f2630`,font:Et},kt={name:`light`,background:`#ffffff`,text:`#0f131a`,textSecondary:`#6b7380`,grid:`#eef0f3`,crosshair:`#8a93a3`,candleUp:`#16a36a`,candleDown:`#d9414f`,candleUpWick:`#16a36a`,candleDownWick:`#d9414f`,lineColor:`#c77a0a`,areaTopColor:`rgba(199, 122, 10, 0.24)`,areaBottomColor:`rgba(199, 122, 10, 0.0)`,volumeUp:`rgba(22, 163, 106, 0.25)`,volumeDown:`rgba(217, 65, 79, 0.25)`,axisLine:`#dde1e7`,axisLabel:`#3f4754`,axisLabelBackground:`#eef0f3`,font:Et},At={name:`terminal`,background:`#0E0E0E`,text:`#C0C0C0`,textSecondary:`#8A8A8A`,grid:`#1A1A1A`,crosshair:`#666666`,candleUp:`#00FF87`,candleDown:`#FF3B4D`,candleUpWick:`#00FF87`,candleDownWick:`#FF3B4D`,lineColor:`#3D8BFD`,areaTopColor:`rgba(61, 139, 253, 0.3)`,areaBottomColor:`rgba(61, 139, 253, 0.0)`,volumeUp:`rgba(0, 255, 135, 0.2)`,volumeDown:`rgba(255, 59, 77, 0.2)`,axisLine:`#1A1A1A`,axisLabel:`#8A8A8A`,axisLabelBackground:`#1A1A1A`,font:{family:`'Roboto Mono', 'JetBrains Mono', 'SF Mono', Consolas, monospace`,sizeSmall:10,sizeMedium:12,sizeLarge:14}},q={candlestick:`Candlestick`,line:`Line`,area:`Area`,bar:`OHLC Bar`,price:`Price`,volume:`Volume`,time:`Time`,open:`Open`,high:`High`,low:`Low`,close:`Close`,sma:`SMA`,ema:`EMA`,bollingerBands:`Bollinger Bands`,vwap:`VWAP`,ichimoku:`Ichimoku Cloud`,parabolicSAR:`Parabolic SAR`,supertrend:`Supertrend`,keltnerChannel:`Keltner Channel`,donchianChannel:`Donchian Channel`,rsi:`RSI`,macd:`MACD`,stochastic:`Stochastic`,atr:`ATR`,adx:`ADX`,obv:`OBV`,williamsR:`Williams %R`,cci:`CCI`,mfi:`MFI`,aroon:`Aroon`,roc:`ROC`,tsi:`TSI`,cmf:`CMF`,stddev:`Std Dev`,volumeProfile:`Volume Profile`,accumulationDistribution:`A/D Line`,vroc:`VROC`,trendLine:`Trend Line`,horizontalLine:`Horizontal Line`,verticalLine:`Vertical Line`,ray:`Ray`,extendedLine:`Extended Line`,parallelChannel:`Parallel Channel`,regressionChannel:`Regression Channel`,fibRetracement:`Fibonacci Retracement`,fibExtension:`Fibonacci Extension`,rectangle:`Rectangle`,ellipse:`Ellipse`,triangle:`Triangle`,pitchfork:`Andrews' Pitchfork`,elliottWave:`Elliott Wave`,priceRange:`Price Range`,dateRange:`Date Range`,measure:`Measure`,textTool:`Text`,arrow:`Arrow`,clearAll:`Clear All`,buy:`Buy`,sell:`Sell`,buyLimit:`Buy Limit`,sellLimit:`Sell Limit`,buyStop:`Buy Stop`,sellStop:`Sell Stop`,stopLoss:`Stop Loss`,takeProfit:`Take Profit`,market:`Market`,limit:`Limit`,stop:`Stop`,cancel:`Cancel`,modify:`Modify`,quantity:`Qty`,pnl:`P&L`,activeOrders:`Active Orders`,positions:`Positions`,noOrders:`No active orders`,noPositions:`No open positions`,placeOrder:`Place Order`,rightClickToTrade:`Right-click chart to place orders`,ceiling:`Ceiling`,floor:`Floor`,reference:`Reference`,session:`Session`,preOpen:`Pre-Open`,continuous:`Continuous`,preClose:`Pre-Close`,closed:`Closed`,settings:`Settings`,theme:`Theme`,darkTheme:`Dark`,lightTheme:`Light`,tools:`Tools`,indicators:`Indicators`,overlays:`Overlays`,panels:`Panels`,orders:`Orders`,autoScale:`Auto Scale`,crosshair:`Crosshair`,grid:`Grid`,loading:`Loading...`,error:`Error`,numberDecimalSeparator:`.`,numberGroupSeparator:`,`},J={candlestick:`Nến`,line:`Đường`,area:`Vùng`,bar:`Thanh OHLC`,price:`Giá`,volume:`Khối lượng`,time:`Thời gian`,open:`Mở`,high:`Cao`,low:`Thấp`,close:`Đóng`,sma:`SMA`,ema:`EMA`,bollingerBands:`Dải Bollinger`,vwap:`VWAP`,ichimoku:`Mây Ichimoku`,parabolicSAR:`Parabolic SAR`,supertrend:`Supertrend`,keltnerChannel:`Kênh Keltner`,donchianChannel:`Kênh Donchian`,rsi:`RSI`,macd:`MACD`,stochastic:`Stochastic`,atr:`ATR`,adx:`ADX`,obv:`OBV`,williamsR:`Williams %R`,cci:`CCI`,mfi:`MFI`,aroon:`Aroon`,roc:`ROC`,tsi:`TSI`,cmf:`CMF`,stddev:`Độ lệch chuẩn`,volumeProfile:`Phân bổ KL`,accumulationDistribution:`Tích lũy/Phân phối`,vroc:`VROC`,trendLine:`Đường xu hướng`,horizontalLine:`Đường ngang`,verticalLine:`Đường dọc`,ray:`Tia`,extendedLine:`Đường kéo dài`,parallelChannel:`Kênh song song`,regressionChannel:`Kênh hồi quy`,fibRetracement:`Fibonacci thoái lui`,fibExtension:`Fibonacci mở rộng`,rectangle:`Hình chữ nhật`,ellipse:`Hình elip`,triangle:`Tam giác`,pitchfork:`Chĩa ba Andrews`,elliottWave:`Sóng Elliott`,priceRange:`Khoảng giá`,dateRange:`Khoảng thời gian`,measure:`Đo lường`,textTool:`Chữ`,arrow:`Mũi tên`,clearAll:`Xóa tất cả`,buy:`Mua`,sell:`Bán`,buyLimit:`Mua giới hạn`,sellLimit:`Bán giới hạn`,buyStop:`Mua chặn`,sellStop:`Bán chặn`,stopLoss:`Cắt lỗ`,takeProfit:`Chốt lời`,market:`Thị trường`,limit:`Giới hạn`,stop:`Dừng`,cancel:`Hủy`,modify:`Sửa`,quantity:`KL`,pnl:`Lãi/Lỗ`,activeOrders:`Lệnh chờ`,positions:`Vị thế`,noOrders:`Không có lệnh chờ`,noPositions:`Không có vị thế mở`,placeOrder:`Đặt lệnh`,rightClickToTrade:`Nhấp chuột phải để đặt lệnh`,ceiling:`Trần`,floor:`Sàn`,reference:`Tham chiếu`,session:`Phiên`,preOpen:`Trước giờ mở`,continuous:`Liên tục`,preClose:`Trước giờ đóng`,closed:`Đóng cửa`,settings:`Cài đặt`,theme:`Giao diện`,darkTheme:`Tối`,lightTheme:`Sáng`,tools:`Công cụ`,indicators:`Chỉ báo`,overlays:`Phủ lên`,panels:`Bảng`,orders:`Lệnh`,autoScale:`Tự co giãn`,crosshair:`Chữ thập`,grid:`Lưới`,loading:`Đang tải...`,error:`Lỗi`,numberDecimalSeparator:`,`,numberGroupSeparator:`.`},Y=new Map([[`en`,q],[`vi`,J]]),X=`en`,jt=q;function Mt(e){X=e,jt=Y.get(e)??q}function Nt(){return X}function Pt(e){return jt[e]??q[e]??e}function Ft(e,t){Y.set(e,t)}function It(e){return Y.get(e??X)??q}function Z(e,t=2,n){let r=Y.get(n??X)??q,i=r.numberDecimalSeparator,a=r.numberGroupSeparator,[o,s]=e.toFixed(t).split(`.`),c=o.startsWith(`-`),l=c?o.slice(1):o,u=``;for(let e=l.length-1,t=0;e>=0;e--,t++)t>0&&t%3==0&&(u=a+u),u=l[e]+u;return c&&(u=`-`+u),s?u+i+s:u}function Lt(e){return Z(e,0,`vi`)}function Rt(e,t){return e>=1e9?Z(e/1e9,2,t??X)+`B`:e>=1e6?Z(e/1e6,2,t??X)+`M`:e>=1e3?Z(e/1e3,2,t??X)+`K`:Z(e,0,t??X)}var Q={up:`#FF0000`,down:`#0000FF`,unchanged:`#FFD700`,ceiling:`#FF00FF`,floor:`#00FFFF`,reference:`#FFD700`},zt=[{name:`ATO`,startTime:`09:00`,endTime:`09:15`,type:`preOpen`},{name:`Phiên 1`,startTime:`09:15`,endTime:`11:30`,type:`continuous`},{name:`Nghỉ trưa`,startTime:`11:30`,endTime:`13:00`,type:`closed`},{name:`Phiên 2`,startTime:`13:00`,endTime:`14:30`,type:`continuous`},{name:`ATC`,startTime:`14:30`,endTime:`14:45`,type:`preClose`}],$=[{name:`Phiên 1`,startTime:`09:00`,endTime:`11:30`,type:`continuous`},{name:`Nghỉ trưa`,startTime:`11:30`,endTime:`13:00`,type:`closed`},{name:`Phiên 2`,startTime:`13:00`,endTime:`14:30`,type:`continuous`},{name:`ATC`,startTime:`14:30`,endTime:`14:45`,type:`preClose`}],Bt={type:`stock`,exchange:`HOSE`,currency:`VND`,pricePrecision:2,volumeUnit:10,priceStep:.05,priceLimits:{enabled:!0,ceilingPercent:7,floorPercent:7},sessions:zt,colorScheme:Q},Vt={type:`stock`,exchange:`HNX`,currency:`VND`,pricePrecision:1,volumeUnit:100,priceStep:.1,priceLimits:{enabled:!0,ceilingPercent:10,floorPercent:10},sessions:$,colorScheme:Q},Ht={type:`stock`,exchange:`UPCOM`,currency:`VND`,pricePrecision:1,volumeUnit:100,priceStep:.1,priceLimits:{enabled:!0,ceilingPercent:15,floorPercent:15},sessions:$,colorScheme:Q},Ut={type:`crypto`,currency:`USDT`,pricePrecision:2,priceLimits:{enabled:!1}},Wt={type:`stock`,exchange:`NYSE`,currency:`USD`,pricePrecision:2,priceStep:.01,priceLimits:{enabled:!1},sessions:[{name:`Pre-Market`,startTime:`04:00`,endTime:`09:30`,type:`preOpen`},{name:`Regular`,startTime:`09:30`,endTime:`16:00`,type:`continuous`},{name:`After-Hours`,startTime:`16:00`,endTime:`20:00`,type:`preClose`}]};function Gt(e){return{...e,candleUp:Q.up,candleDown:Q.down,candleUpWick:Q.up,candleDownWick:Q.down,volumeUp:`rgba(255, 0, 0, 0.3)`,volumeDown:`rgba(0, 0, 255, 0.3)`}}function Kt(e,t){if(!t.priceLimits?.enabled||!t.priceLimits.ceilingPercent)return null;let n=t.priceLimits.ceilingPercent/100,r=(t.priceLimits.floorPercent??t.priceLimits.ceilingPercent)/100;return{ceiling:e*(1+n),floor:e*(1-r),reference:e}}function qt(e){let t=new Date,n=`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`;for(let t of e)if(n>=t.startTime&&n<t.endTime)return t;return null}exports.DARK_TERMINAL=At,exports.DARK_THEME=Ot,exports.DEFAULT_BAR_SPACING=xt,exports.DEFAULT_BAR_WIDTH=bt,exports.DEFAULT_CHART_OPTIONS=ht,exports.DEFAULT_DRAWING_STYLE=t,exports.DEFAULT_PANEL_HEIGHT=Tt,exports.DEFAULT_RECONNECT=a,exports.DEFAULT_SIGNAL_STYLE=r,exports.DEFAULT_STREAM_CONFIG=o,exports.DEFAULT_TIMEFRAME_FAVORITES=yt,exports.DEFAULT_TRADE_ZONE_STYLE=i,exports.DEFAULT_TRADING_CONFIG=n,exports.HNX_SESSIONS=$,exports.HOSE_SESSIONS=zt,exports.LIGHT_THEME=kt,exports.LayerType=e,exports.MARKET_CRYPTO=Ut,exports.MARKET_HNX=Vt,exports.MARKET_HOSE=Bt,exports.MARKET_NYSE=Wt,exports.MARKET_UPCOM=Ht,exports.MIN_PANEL_HEIGHT=wt,exports.PRICE_AXIS_WIDTH=St,exports.PRICE_SOURCES=F,exports.TC_PALETTE=K,exports.TC_SERIES_COLORS=Dt,exports.TIMEFRAMES_CRYPTO=gt,exports.TIMEFRAMES_FOREX=vt,exports.TIMEFRAMES_STOCK=_t,exports.TIME_AXIS_HEIGHT=Ct,exports.VN_COLORS=Q,exports.alignToTimeframe=ke,exports.autoPricePrecision=Fe,exports.clamp=ne,exports.computePriceLimits=Kt,exports.computePriceRange=le,exports.computeTickStep=m,exports.createVNTheme=Gt,exports.detectPrecision=ze,exports.drawingOption=at,exports.en=q,exports.findBarIndex=ce,exports.formatFraction=N,exports.formatNumber=Z,exports.formatPrice=M,exports.formatPriceScaleLabel=Ie,exports.formatTimestamp=Oe,exports.formatVND=Lt,exports.formatVolume=Re,exports.formatVolumeLoc=Rt,exports.fractionTick=P,exports.getCurrentSession=qt,exports.getLocale=Nt,exports.getLocaleStrings=It,exports.hexToRgba=g,exports.indicatorSource=Ue,exports.inverseLerp=ie,exports.isDateOnly=je,exports.isPriceSource=Be,exports.isTimeFrame=De,exports.isValidTimeZone=ye,exports.lerp=re,exports.lerpColor=fe,exports.marketStatus=Qe,exports.mergeBar=ue,exports.niceNumber=p,exports.normalizeBar=oe,exports.normalizeBarTime=h,exports.offsetAt=w,exports.parseIndicatorSource=We,exports.parseTimeframe=D,exports.pickBaseTimeframe=Je,exports.priceFormatterFor=Le,exports.rankSymbols=Ye,exports.readChartTypeOptions=mt,exports.readNews=te,exports.readQuote=c,exports.registerLocale=Ft,exports.resampleBars=Ke,exports.resolveDrawingOptions=ot,exports.roundToStep=ae,exports.sanitizeDrawingOptions=rt,exports.sanitizeDrawingStyle=pt,exports.sessionMinute=R,exports.setLocale=Mt,exports.sliceVisibleData=se,exports.sourcePrice=Ve,exports.stepDecimals=Xe,exports.t=Pt,exports.tickBarCount=Ee,exports.timeParts=Ae,exports.timeframeBucketStart=A,exports.timeframeToMs=O,exports.tzLabel=Me,exports.vi=J,exports.wallToUtc=xe,exports.withAlpha=de,exports.zoneOffsetMinutes=S,exports.zonedDateFormatter=Se;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=function(e){return e[e.Background=0]=`Background`,e[e.Main=1]=`Main`,e[e.Panel=2]=`Panel`,e[e.Overlay=3]=`Overlay`,e[e.UI=4]=`UI`,e[e.Hover=5]=`Hover`,e}({}),t={color:`#4c8dff`,lineWidth:1,lineStyle:`solid`,fillColor:`rgba(76, 141, 255, 0.1)`,fillOpacity:.1,fontSize:12},n={enabled:!0,orderColors:{buy:`#1fa874`,sell:`#e8505b`},positionColors:{profit:`#1fa874`,loss:`#e8505b`,entry:`#4c8dff`},depthOverlay:{enabled:!1,bidColor:`rgba(31, 168, 116,0.15)`,askColor:`rgba(232, 80, 91,0.15)`,maxWidth:100},contextMenu:{enabled:!0},lineButtons:{cancel:!0,close:!0,reverse:!0,removeStops:!0},fillMarks:!0,pricePrecision:2,dragThreshold:3},r={longColor:`#1fa874`,shortColor:`#e8505b`,neutralColor:`#9E9E9E`,arrowSize:12,showLabel:!0,showConfidence:!0},i={profitColor:`#1fa874`,lossColor:`#e8505b`,activeColor:`#4c8dff`,fillOpacity:.12,borderWidth:1,showLabel:!0,showPnl:!0},a={enabled:!0,maxRetries:1/0,baseDelay:1e3,maxDelay:3e4,backoffMultiplier:2},o={historyLimit:500,autoScroll:!0,showCurrentPriceLine:!0,aggregateTicks:!1},s=[`change`,`changePercent`,`open`,`high`,`low`,`prevClose`,`volume`,`bid`,`ask`,`time`];function c(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.symbol==`string`?t.symbol.trim():``;if(!n||n.length>64||!l(t.last))return null;let r={symbol:n,last:t.last};for(let e of s){let n=t[e];l(n)&&(r[e]=n)}let i=r.prevClose??r.open;if(r.change===void 0&&i!==void 0&&(r.change=r.last-i),r.changePercent===void 0&&r.change!==void 0){let e=r.last-r.change;e!==0&&(r.changePercent=r.change/e*100)}return r}function l(e){return typeof e==`number`&&Number.isFinite(e)}var u=300,d=1e3,f=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n?n.slice(0,t):void 0},ee=e=>{if(typeof e==`string`)try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.href:void 0}catch{return}};function te(e,t=20){if(!Array.isArray(e))return[];let n=[];for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,r=f(e.title,u);if(!r||typeof e.time!=`number`||!Number.isFinite(e.time))continue;let i={title:r,time:e.time},a=ee(e.url);a&&(i.url=a);let o=f(e.source,u);o&&(i.source=o);let s=f(e.summary,d);s&&(i.summary=s);let c=f(e.id,u);c&&(i.id=c),n.push(i)}return n.sort((e,t)=>t.time-e.time).slice(0,Math.max(0,t))}function ne(e,t,n){return Math.max(t,Math.min(n,e))}function re(e,t,n){return e+(t-e)*n}function ie(e,t,n){return e===t?0:(n-e)/(t-e)}function ae(e,t){return Math.round(e/t)*t}function p(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function oe(e,t,n){return p(p(t-e,!1)/(n-1),!0)}function se(e){return e>0xe8d4a51000?e:e*1e3}function ce(e){return{time:se(e.time??e.t??0),open:e.open??e.o??0,high:e.high??e.h??0,low:e.low??e.l??0,close:e.close??e.c??0,volume:e.volume??e.v??0}}function le(e,t,n){let r=Math.max(0,t),i=Math.min(e.length,n+1);return e.slice(r,i)}function ue(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1;if(e[i].time<t)n=i+1;else if(e[i].time>t)r=i-1;else return i}return n}function de(e,t,n,r=.05){if(e.length===0)return{min:0,max:1};let i=Math.max(0,t),a=Math.min(e.length-1,n),o=1/0,s=-1/0;for(let t=i;t<=a;t++)e[t].low<o&&(o=e[t].low),e[t].high>s&&(s=e[t].high);if(o===1/0)return{min:0,max:1};let c=s-o||1;return{min:o-c*r,max:s+c*r}}function fe(e,t){return{...e,high:Math.max(e.high,t.price),low:Math.min(e.low,t.price),close:t.price,volume:e.volume+(t.volume??0),time:t.time}}function pe(e,t=1){let n=e.slice(1);return(n.length===3||n.length===4)&&(n=[...n.slice(0,3)].map(e=>e+e).join(``)),`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${t})`}function me(e,t){let n=e.trim();if(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(n))return pe(n,t);let r=n.match(/^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)/i);return r?`rgba(${r[1]}, ${r[2]}, ${r[3]}, ${t})`:e}function he(e,t,n){let r=e=>(e=e.replace(`#`,``),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}),i=r(e),a=r(t);return`rgb(${Math.round(i.r+(a.r-i.r)*n)},${Math.round(i.g+(a.g-i.g)*n)},${Math.round(i.b+(a.b-i.b)*n)})`}var m=6e4,h=1440*m,g=15*m,ge=8192,_=7*h,_e=4096,ve=new Set([`UTC`,`Etc/UTC`,`GMT`,`Etc/GMT`,`UCT`,`Etc/UCT`,`Universal`,`Etc/Universal`,`Zulu`,`Etc/Zulu`]),ye=new Map,v=new Map,y=new Map;function be(e){let t=ye.get(e);return t||(t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),ye.set(e,t)),t}function xe(e){if(!e)return!1;try{return be(e),!0}catch{return!1}}function b(e,t){if(!Number.isFinite(t)||ve.has(e))return 0;let n=y.get(e);n||(n=new Map,y.set(e,n));let r=Math.floor(t/_),i=n.get(r);return i||(i=Se(e,r*_),n.size>=_e&&n.clear(),n.set(r,i)),t<i.change?i.before:i.after}function Se(e,t){let n=x(e,t),r=t+_-g,i=x(e,r);if(i===n)return{before:n,change:1/0,after:i};let a=t;for(;r-a>g;){let t=a+Math.floor((r-a)/g/2)*g;x(e,t)===n?a=t:r=t}return{before:n,change:r,after:i}}function x(e,t){let n=Math.floor(t/g),r=`${e}|${n}`,i=v.get(r);if(i!==void 0)return i;let a=n*g,o=1970,s=1,c=1,l=0,u=0,d=0;for(let t of be(e).formatToParts(new Date(a))){let e=Number(t.value);switch(t.type){case`year`:o=e;break;case`month`:s=e;break;case`day`:c=e;break;case`hour`:l=e%24;break;case`minute`:u=e;break;case`second`:d=e;break}}let f=Math.round((Date.UTC(o,s-1,c,l,u,d)-a)/m);return v.size>=ge&&v.clear(),v.set(r,f),f}function S(e,t){return e===null?-new Date(t).getTimezoneOffset():typeof e==`number`?e:b(e,t)}function Ce(e,t){let n=e-S(t,e-h)*m;if(n+S(t,n)*m===e)return n;let r=e-S(t,e+h)*m;return r+S(t,r)*m===e?r:n}var C=new Map;function we(e,t,n){let r=`${e}|${JSON.stringify(t)}|${n===null?`local`:typeof n==`number`?`fixed:${n}`:n}`,i=C.get(r);if(i)return i;let a=n===null?void 0:typeof n==`number`?`UTC`:n,o;try{o=new Intl.DateTimeFormat(e,{...t,timeZone:a})}catch{o=new Intl.DateTimeFormat(`en-US`,{...t,timeZone:a})}let s=typeof n==`number`?n*m:0;return i=e=>o.format(new Date(e+s)),C.set(r,i),i}var Te={"1s":1e3,"5s":5e3,"15s":15e3,"30s":3e4,"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"45m":27e5,"1h":36e5,"2h":72e5,"3h":108e5,"4h":144e5,"6h":216e5,"8h":288e5,"12h":432e5,"1d":864e5,"2d":1728e5,"3d":2592e5,"1w":6048e5,"2w":12096e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"12M":31536e6},w={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,M:2592e6},Ee=/^([1-9]\d*)([smhdwM])$/;function T(e){let t=Ee.exec(e);if(!t)return null;let n=Number(t[1]);return Number.isSafeInteger(n)?{count:n,unit:t[2]}:null}var De=1e6;function Oe(e){let t=/^([1-9]\d*)T$/.exec(e);if(!t)return null;let n=Number(t[1]);return Number.isSafeInteger(n)&&n<=De?n:null}function ke(e){return T(e)!==null}function E(e){let t=Te[e];if(t!==void 0)return t;let n=T(e);return n?n.count*w[n.unit]:NaN}function Ae(e,t){let n=new Date(e),r=E(t);return r>=864e5?n.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):r>=36e5?n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function je(e,t){let n=E(t);return Math.floor(e/n)*n}function Me(e,t){if(t===null){let t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hours:t.getHours(),minutes:t.getMinutes()}}let n=new Date(e+S(t,e)*6e4);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hours:n.getUTCHours(),minutes:n.getUTCMinutes()}}function Ne(e){return e.hours===0&&e.minutes===0}var Pe=20*36e5;function Fe(e){let t=Math.min(e.length,64);if(t<2)return;let n=e=>e>0xe8d4a51000?e:e*1e3,r=1/0;for(let i=1;i<t;i++){let t=Math.abs(n(e[i].time)-n(e[i-1].time));t>0&&t<r&&(r=t)}return r===1/0?void 0:r>=Pe}function Ie(e,t=Date.now()){let n=S(e,t),r=n>=0?`+`:`-`,i=Math.abs(n),a=Math.floor(i/60),o=i%60;return o===0?`UTC${r}${a}`:`UTC${r}${a}:${String(o).padStart(2,`0`)}`}var D=Date.UTC(1970,0,5);function O(e,t,n=1){let{count:r,unit:i}=T(t)??{count:1,unit:`m`};if(i===`s`||i===`m`||i===`h`||i===`d`){let t=r*w[i];return Math.floor(e/t)*t}let a=new Date(e);if(i===`w`){let e=w.d,t=(a.getUTCDay()-n+7)%7,i=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()-t);if(r<=1)return i;let o=Math.floor((i-D)/(7*e));return D+Math.floor(o/r)*r*7*e}let o=a.getUTCFullYear()*12+a.getUTCMonth(),s=Math.floor(o/r)*r;return Date.UTC(Math.floor(s/12),s%12,1)}var Le=64,k=new Map;function Re(e,t){let n=`${e}|${t}`,r=k.get(n);return r||(k.size>=Le&&k.clear(),r=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t}),k.set(n,r)),r}function A(e,t=2,n=`en-US`){return Re(n,t).format(e)}function ze(e,t){if(!(t>e)||!Number.isFinite(e)||!Number.isFinite(t))return 2;let n=oe(e,t,8);return n>0&&n<1?Math.ceil(-Math.log10(n))+1:2}function Be(e,t,n,r=2,i=`en-US`){if((t===`percentage`||t===`indexedTo100`)&&n&&n!==0){if(t===`percentage`){let t=(e/n-1)*100;return`${t>0?`+`:``}${t.toFixed(2)}%`}return A(e/n*100,2,i)}return A(e,r,i)}function Ve(e,t,n=1){let r=Number.isInteger(n)&&n>1?n:1;if(!Number.isFinite(e)||!Number.isInteger(t)||t<2)return String(e);let i=t*r,a=Math.round(Math.abs(e)*i),o=Math.floor(a/i),s=a-o*i,c=Math.floor(s/r),l=String(t-1).length,u=r>1?String(Math.floor((s-c*r)/r*10)):``;return`${e<0&&a>0?`-`:``}${o}'${String(c).padStart(l,`0`)}${u}`}function He(e){if(!Number.isInteger(e.denominator)||e.denominator<2)return null;let t=Number.isInteger(e.subDenominator)&&(e.subDenominator??0)>1?e.subDenominator:1;return 1/(e.denominator*t)}function Ue(e){return e?typeof e==`function`?e:He(e)===null?null:t=>Ve(t,e.denominator,e.subDenominator):null}function We(e){return e>=1e9?(e/1e9).toFixed(2)+`B`:e>=1e6?(e/1e6).toFixed(2)+`M`:e>=1e3?(e/1e3).toFixed(2)+`K`:e.toFixed(0)}function Ge(e){let t=0;for(let n of e){let e=n.toString(),r=e.indexOf(`.`);r>=0&&(t=Math.max(t,e.length-r-1))}return Math.min(t,8)}var Ke=[`close`,`open`,`high`,`low`,`hl2`,`hlc3`,`ohlc4`,`hlcc4`];function qe(e){return typeof e==`string`&&Ke.includes(e)}function Je(e,t){switch(t){case`open`:return e.open;case`high`:return e.high;case`low`:return e.low;case`hl2`:return(e.high+e.low)/2;case`hlc3`:return(e.high+e.low+e.close)/3;case`ohlc4`:return(e.open+e.high+e.low+e.close)/4;case`hlcc4`:return(e.high+e.low+2*e.close)/4;default:return e.close}}var Ye=/^ind:([^:]+):(.+)$/;function Xe(e,t){return`ind:${e}:${t}`}function Ze(e){if(typeof e!=`string`)return null;let t=Ye.exec(e);return t?{instanceId:t[1],key:t[2]}:null}var Qe=864e5;function $e(e,t,n=1){let r=[],i=null;for(let a of e){let e=O(a.time,t,n);i===null||e!==i.time?(i={time:e,open:a.open,high:a.high,low:a.low,close:a.close,volume:a.volume},r.push(i)):(a.high>i.high&&(i.high=a.high),a.low<i.low&&(i.low=a.low),i.close=a.close,i.volume+=a.volume)}return r}var j=e=>e===`s`||e===`m`||e===`h`||e===`d`;function et(e,t){let n=T(e),r=T(t);if(!n||!r)return!1;let i=E(e);return n.unit===`d`&&n.count>1?!1:j(r.unit)?j(n.unit)&&E(t)%i===0:n.unit===r.unit?r.count%n.count===0:j(n.unit)&&Qe%i===0}function tt(e,t){let n=null,r=0;for(let i of t){if(!et(i,e))continue;let t=E(i);t>r&&(n=i,r=t)}return n}function nt(e,t){if(!e)return 0;if(e===t)return 1e3;if(e.startsWith(t))return 600-Math.min(100,e.length-t.length);let n=e.indexOf(t);return n>=0?300-Math.min(100,n):0}function rt(e,t,n=50,r){let i=t.trim().toUpperCase();if(!i)return e.slice(0,n);let a=[];for(let t of e){let e=Math.max(nt(t.symbol.toUpperCase(),i),nt((t.description??``).toUpperCase(),i)*.8);e>0&&a.push({info:t,score:e+(r?.(t)??0)})}return a.sort((e,t)=>t.score-e.score||e.info.symbol.localeCompare(t.info.symbol)),a.slice(0,n).map(e=>e.info)}function it(e){let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t)||t<=0)return 0;for(let e=0;e<=12;e++){let n=t*10**e;if(Math.abs(n-Math.round(n))<1e-9*Math.max(1,n))return e}return 12}function M(e){let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n===24&&r===0?1440:n<24&&r<60?n*60+r:null}var N=864e5,P=6e4,at=8;function ot(e,t){let n=e?.timezone,r=(e?.sessions??[]).flatMap(e=>{let t=M(e.start),n=M(e.end);return t===null||n===null||t===n?[]:[{start:t,end:n,days:Array.isArray(e.days)?e.days:null}]});if(!n||!xe(n)||r.length===0||!Number.isFinite(t))return{state:`always`,next:null};let i=b(n,t)*P,a=Math.floor((t+i)/N)*N,o=e=>e-b(n,e-b(n,e-i)*P)*P,s=[];for(let e=-1;e<=at;e++){let t=a+e*N,n=(Math.floor(t/N)+4)%7;for(let e of r){if(e.days&&!e.days.includes(n))continue;let r=t+e.start*P,i=(e.end>e.start?t:t+N)+e.end*P;s.push([o(r),o(i)])}}s.sort((e,t)=>e[0]-t[0]);let c=[];for(let[e,t]of s){let n=c[c.length-1];n&&e<=n[1]?c[c.length-1]=[n[0],Math.max(n[1],t)]:c.push([e,t])}let l=c.find(([e,n])=>e<=t&&t<n);if(l)return{state:`open`,next:l[1]};let u=c.find(([e])=>e>t);return{state:`closed`,next:u?u[0]:null}}var st=48,ct=2e3,lt=1e4;function ut(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(t.length>=st)break;if(typeof n!=`object`||!n)continue;let{value:e,visible:r,color:i}=n;if(typeof e!=`number`||!Number.isFinite(e)||Math.abs(e)>lt||r!==void 0&&typeof r!=`boolean`)continue;let a={value:e,visible:r??!0};typeof i==`string`&&i&&(a.color=i),t.push(a)}return t}function dt(e,t){switch(e.kind){case`boolean`:return typeof t==`boolean`?t:void 0;case`number`:return typeof t!=`number`||!Number.isFinite(t)?void 0:Math.min(e.max??1/0,Math.max(e.min??-1/0,t));case`choice`:return typeof t==`string`&&e.choices.some(e=>e.value===t)?t:void 0;case`levels`:return ut(t);case`text`:return typeof t==`string`?t.slice(0,ct):void 0}}function ft(e,t){if(!e||typeof t!=`object`||!t)return{};let n={};for(let[r,i]of Object.entries(t)){let t=e[r];if(!t)continue;let a=dt(t,i);a!==void 0&&(n[r]=a)}return n}function pt(e){return Array.isArray(e)?e.map(e=>({...e})):e}function mt(e,t,n){let r=e?.[n];return r?pt((t&&n in t?dt(r,t[n]):void 0)??r.default):t?.[n]}function ht(e,t){let n={};for(let r of Object.keys(e??{}))n[r]=mt(e,t,r);return n}var gt=[`solid`,`dashed`,`dotted`],_t=64,vt=2e3,yt=20,bt=200;function F(e,t,n){return typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):void 0}function xt(e){return typeof e==`string`&&e.length>0&&e.length<=_t?e:void 0}function St(e){if(typeof e!=`object`||!e)return{};let t=e,n={},r=xt(t.color);r!==void 0&&(n.color=r);let i=F(t.lineWidth,.5,yt);i!==void 0&&(n.lineWidth=i),gt.includes(t.lineStyle)&&(n.lineStyle=t.lineStyle);let a=xt(t.fillColor);a!==void 0&&(n.fillColor=a);let o=F(t.fillOpacity,0,1);o!==void 0&&(n.fillOpacity=o);let s=F(t.fontSize,6,bt);return s!==void 0&&(n.fontSize=s),typeof t.text==`string`&&(n.text=t.text.slice(0,vt)),n}var I=e=>typeof e==`number`&&Number.isFinite(e)&&e>0,L=(e,t,n)=>typeof e==`number`&&Number.isInteger(e)&&e>=t&&e<=n,R=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Ct(e){if(!R(e))return{};let t={};if(R(e.renko)){let{boxSize:n,atrPeriod:r}=e.renko;t.renko={...I(n)||n===`atr`?{boxSize:n}:{},...L(r,1,500)?{atrPeriod:r}:{}}}if(R(e.lineBreak)){let{lines:n}=e.lineBreak;t.lineBreak=L(n,1,10)?{lines:n}:{}}if(R(e.kagi)){let{reversal:n,reversalType:r}=e.kagi;t.kagi={...I(n)?{reversal:n}:{},...r===`percent`||r===`price`?{reversalType:r}:{}}}if(R(e.pointAndFigure)){let{boxSize:n,reversal:r}=e.pointAndFigure;t.pointAndFigure={...I(n)||n===`auto`?{boxSize:n}:{},...L(r,1,10)?{reversal:r}:{}}}if(R(e.rangeBars)){let{range:n}=e.rangeBars;t.rangeBars=I(n)||n===`auto`?{range:n}:{}}return t}var wt={autoScale:!0,rightMargin:5,minBarSpacing:2,maxBarSpacing:30,grid:{visible:!0,hLineStyle:`solid`,vLineStyle:`solid`},crosshair:{mode:`magnet`}},Tt=[`1s`,`1m`,`3m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`6h`,`8h`,`12h`,`1d`,`3d`,`1w`,`1M`],Et=[`1m`,`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`1d`,`1w`,`1M`,`3M`,`6M`,`12M`],Dt=[`1m`,`5m`,`15m`,`30m`,`1h`,`4h`,`1d`,`1w`,`1M`],Ot=[`1m`,`5m`,`15m`,`1h`,`4h`,`1d`,`1w`],kt=8,At=2,jt=70,Mt=30,Nt=60,Pt=120,z=`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,B={family:z,sizeSmall:10,sizeMedium:12,sizeLarge:14},V={amber:`#f2a93b`,up:`#1fa874`,down:`#e8505b`,ochre:`#c98316`,blue:`#4c8dff`,violet:`#a57cff`,cyan:`#1398a8`,rose:`#e25592`,neutral:`#7d8696`,ink:`#0c1016`},Ft=.22;function H(e){return me(e,Ft)}var U=`#2eb88a`,W=`#e85a67`,It=[V.blue,V.ochre,V.violet,V.cyan,V.rose],G={name:`dark`,background:V.ink,text:`#d9dde4`,textSecondary:`#7d8696`,grid:`#161b23`,crosshair:`#8a93a3`,candleUp:U,candleDown:W,candleUpWick:U,candleDownWick:W,lineColor:V.amber,areaTopColor:`rgba(242, 169, 59, 0.32)`,areaBottomColor:`rgba(242, 169, 59, 0.0)`,volumeUp:H(U),volumeDown:H(W),axisLine:`#1f2630`,axisLabel:`#9aa3b2`,axisLabelBackground:`#1f2630`,font:B},K={name:`light`,background:`#ffffff`,text:`#0f131a`,textSecondary:`#6b7380`,grid:`#eef0f3`,crosshair:`#8a93a3`,candleUp:`#16a36a`,candleDown:`#d9414f`,candleUpWick:`#16a36a`,candleDownWick:`#d9414f`,lineColor:`#c77a0a`,areaTopColor:`rgba(199, 122, 10, 0.24)`,areaBottomColor:`rgba(199, 122, 10, 0.0)`,volumeUp:H(`#16a36a`),volumeDown:H(`#d9414f`),axisLine:`#dde1e7`,axisLabel:`#5b6472`,axisLabelBackground:`#eef0f3`,font:B},q={name:`terminal`,background:`#0E0E0E`,text:`#C0C0C0`,textSecondary:`#8A8A8A`,grid:`#1A1A1A`,crosshair:`#666666`,candleUp:`#00FF87`,candleDown:`#FF3B4D`,candleUpWick:`#00FF87`,candleDownWick:`#FF3B4D`,lineColor:`#3D8BFD`,areaTopColor:`rgba(61, 139, 253, 0.3)`,areaBottomColor:`rgba(61, 139, 253, 0.0)`,volumeUp:`rgba(0, 255, 135, 0.2)`,volumeDown:`rgba(255, 59, 77, 0.2)`,axisLine:`#1A1A1A`,axisLabel:`#8A8A8A`,axisLabelBackground:`#1A1A1A`,font:{family:`'Roboto Mono', 'JetBrains Mono', 'SF Mono', Consolas, monospace`,sizeSmall:10,sizeMedium:12,sizeLarge:14}},Lt=new Set([G.volumeUp,G.volumeDown,K.volumeUp,K.volumeDown,q.volumeUp,q.volumeDown]);function Rt(e){let t=(e,t)=>{if(!Lt.has(e))return e;let n=H(t);return n===t?e:n};return{up:t(e.volumeUp,e.candleUp),down:t(e.volumeDown,e.candleDown)}}var J={candlestick:`Candlestick`,line:`Line`,area:`Area`,bar:`OHLC Bar`,price:`Price`,volume:`Volume`,time:`Time`,open:`Open`,high:`High`,low:`Low`,close:`Close`,sma:`SMA`,ema:`EMA`,bollingerBands:`Bollinger Bands`,vwap:`VWAP`,ichimoku:`Ichimoku Cloud`,parabolicSAR:`Parabolic SAR`,supertrend:`Supertrend`,keltnerChannel:`Keltner Channel`,donchianChannel:`Donchian Channel`,rsi:`RSI`,macd:`MACD`,stochastic:`Stochastic`,atr:`ATR`,adx:`ADX`,obv:`OBV`,williamsR:`Williams %R`,cci:`CCI`,mfi:`MFI`,aroon:`Aroon`,roc:`ROC`,tsi:`TSI`,cmf:`CMF`,stddev:`Std Dev`,volumeProfile:`Volume Profile`,accumulationDistribution:`A/D Line`,vroc:`VROC`,trendLine:`Trend Line`,horizontalLine:`Horizontal Line`,verticalLine:`Vertical Line`,ray:`Ray`,extendedLine:`Extended Line`,parallelChannel:`Parallel Channel`,regressionChannel:`Regression Channel`,fibRetracement:`Fibonacci Retracement`,fibExtension:`Fibonacci Extension`,rectangle:`Rectangle`,ellipse:`Ellipse`,triangle:`Triangle`,pitchfork:`Andrews' Pitchfork`,elliottWave:`Elliott Wave`,priceRange:`Price Range`,dateRange:`Date Range`,measure:`Measure`,textTool:`Text`,arrow:`Arrow`,clearAll:`Clear All`,buy:`Buy`,sell:`Sell`,buyLimit:`Buy Limit`,sellLimit:`Sell Limit`,buyStop:`Buy Stop`,sellStop:`Sell Stop`,stopLoss:`Stop Loss`,takeProfit:`Take Profit`,market:`Market`,limit:`Limit`,stop:`Stop`,cancel:`Cancel`,modify:`Modify`,quantity:`Qty`,pnl:`P&L`,activeOrders:`Active Orders`,positions:`Positions`,noOrders:`No active orders`,noPositions:`No open positions`,placeOrder:`Place Order`,rightClickToTrade:`Right-click chart to place orders`,ceiling:`Ceiling`,floor:`Floor`,reference:`Reference`,session:`Session`,preOpen:`Pre-Open`,continuous:`Continuous`,preClose:`Pre-Close`,closed:`Closed`,settings:`Settings`,theme:`Theme`,darkTheme:`Dark`,lightTheme:`Light`,tools:`Tools`,indicators:`Indicators`,overlays:`Overlays`,panels:`Panels`,orders:`Orders`,autoScale:`Auto Scale`,crosshair:`Crosshair`,grid:`Grid`,loading:`Loading...`,error:`Error`,numberDecimalSeparator:`.`,numberGroupSeparator:`,`},zt={candlestick:`Nến`,line:`Đường`,area:`Vùng`,bar:`Thanh OHLC`,price:`Giá`,volume:`Khối lượng`,time:`Thời gian`,open:`Mở`,high:`Cao`,low:`Thấp`,close:`Đóng`,sma:`SMA`,ema:`EMA`,bollingerBands:`Dải Bollinger`,vwap:`VWAP`,ichimoku:`Mây Ichimoku`,parabolicSAR:`Parabolic SAR`,supertrend:`Supertrend`,keltnerChannel:`Kênh Keltner`,donchianChannel:`Kênh Donchian`,rsi:`RSI`,macd:`MACD`,stochastic:`Stochastic`,atr:`ATR`,adx:`ADX`,obv:`OBV`,williamsR:`Williams %R`,cci:`CCI`,mfi:`MFI`,aroon:`Aroon`,roc:`ROC`,tsi:`TSI`,cmf:`CMF`,stddev:`Độ lệch chuẩn`,volumeProfile:`Phân bổ KL`,accumulationDistribution:`Tích lũy/Phân phối`,vroc:`VROC`,trendLine:`Đường xu hướng`,horizontalLine:`Đường ngang`,verticalLine:`Đường dọc`,ray:`Tia`,extendedLine:`Đường kéo dài`,parallelChannel:`Kênh song song`,regressionChannel:`Kênh hồi quy`,fibRetracement:`Fibonacci thoái lui`,fibExtension:`Fibonacci mở rộng`,rectangle:`Hình chữ nhật`,ellipse:`Hình elip`,triangle:`Tam giác`,pitchfork:`Chĩa ba Andrews`,elliottWave:`Sóng Elliott`,priceRange:`Khoảng giá`,dateRange:`Khoảng thời gian`,measure:`Đo lường`,textTool:`Chữ`,arrow:`Mũi tên`,clearAll:`Xóa tất cả`,buy:`Mua`,sell:`Bán`,buyLimit:`Mua giới hạn`,sellLimit:`Bán giới hạn`,buyStop:`Mua chặn`,sellStop:`Bán chặn`,stopLoss:`Cắt lỗ`,takeProfit:`Chốt lời`,market:`Thị trường`,limit:`Giới hạn`,stop:`Dừng`,cancel:`Hủy`,modify:`Sửa`,quantity:`KL`,pnl:`Lãi/Lỗ`,activeOrders:`Lệnh chờ`,positions:`Vị thế`,noOrders:`Không có lệnh chờ`,noPositions:`Không có vị thế mở`,placeOrder:`Đặt lệnh`,rightClickToTrade:`Nhấp chuột phải để đặt lệnh`,ceiling:`Trần`,floor:`Sàn`,reference:`Tham chiếu`,session:`Phiên`,preOpen:`Trước giờ mở`,continuous:`Liên tục`,preClose:`Trước giờ đóng`,closed:`Đóng cửa`,settings:`Cài đặt`,theme:`Giao diện`,darkTheme:`Tối`,lightTheme:`Sáng`,tools:`Công cụ`,indicators:`Chỉ báo`,overlays:`Phủ lên`,panels:`Bảng`,orders:`Lệnh`,autoScale:`Tự co giãn`,crosshair:`Chữ thập`,grid:`Lưới`,loading:`Đang tải...`,error:`Lỗi`,numberDecimalSeparator:`,`,numberGroupSeparator:`.`},Y=new Map([[`en`,J],[`vi`,zt]]),X=`en`,Bt=J;function Vt(e){X=e,Bt=Y.get(e)??J}function Ht(){return X}function Ut(e){return Bt[e]??J[e]??e}function Wt(e,t){Y.set(e,t)}function Gt(e){return Y.get(e??X)??J}function Z(e,t=2,n){let r=Y.get(n??X)??J,i=r.numberDecimalSeparator,a=r.numberGroupSeparator,[o,s]=e.toFixed(t).split(`.`),c=o.startsWith(`-`),l=c?o.slice(1):o,u=``;for(let e=l.length-1,t=0;e>=0;e--,t++)t>0&&t%3==0&&(u=a+u),u=l[e]+u;return c&&(u=`-`+u),s?u+i+s:u}function Kt(e){return Z(e,0,`vi`)}function qt(e,t){return e>=1e9?Z(e/1e9,2,t??X)+`B`:e>=1e6?Z(e/1e6,2,t??X)+`M`:e>=1e3?Z(e/1e3,2,t??X)+`K`:Z(e,0,t??X)}var Q={up:`#FF0000`,down:`#0000FF`,unchanged:`#FFD700`,ceiling:`#FF00FF`,floor:`#00FFFF`,reference:`#FFD700`},Jt=[{name:`ATO`,startTime:`09:00`,endTime:`09:15`,type:`preOpen`},{name:`Phiên 1`,startTime:`09:15`,endTime:`11:30`,type:`continuous`},{name:`Nghỉ trưa`,startTime:`11:30`,endTime:`13:00`,type:`closed`},{name:`Phiên 2`,startTime:`13:00`,endTime:`14:30`,type:`continuous`},{name:`ATC`,startTime:`14:30`,endTime:`14:45`,type:`preClose`}],$=[{name:`Phiên 1`,startTime:`09:00`,endTime:`11:30`,type:`continuous`},{name:`Nghỉ trưa`,startTime:`11:30`,endTime:`13:00`,type:`closed`},{name:`Phiên 2`,startTime:`13:00`,endTime:`14:30`,type:`continuous`},{name:`ATC`,startTime:`14:30`,endTime:`14:45`,type:`preClose`}],Yt={type:`stock`,exchange:`HOSE`,currency:`VND`,pricePrecision:2,volumeUnit:10,priceStep:.05,priceLimits:{enabled:!0,ceilingPercent:7,floorPercent:7},sessions:Jt,colorScheme:Q},Xt={type:`stock`,exchange:`HNX`,currency:`VND`,pricePrecision:1,volumeUnit:100,priceStep:.1,priceLimits:{enabled:!0,ceilingPercent:10,floorPercent:10},sessions:$,colorScheme:Q},Zt={type:`stock`,exchange:`UPCOM`,currency:`VND`,pricePrecision:1,volumeUnit:100,priceStep:.1,priceLimits:{enabled:!0,ceilingPercent:15,floorPercent:15},sessions:$,colorScheme:Q},Qt={type:`crypto`,currency:`USDT`,pricePrecision:2,priceLimits:{enabled:!1}},$t={type:`stock`,exchange:`NYSE`,currency:`USD`,pricePrecision:2,priceStep:.01,priceLimits:{enabled:!1},sessions:[{name:`Pre-Market`,startTime:`04:00`,endTime:`09:30`,type:`preOpen`},{name:`Regular`,startTime:`09:30`,endTime:`16:00`,type:`continuous`},{name:`After-Hours`,startTime:`16:00`,endTime:`20:00`,type:`preClose`}]};function en(e){return{...e,candleUp:Q.up,candleDown:Q.down,candleUpWick:Q.up,candleDownWick:Q.down,volumeUp:`rgba(255, 0, 0, 0.3)`,volumeDown:`rgba(0, 0, 255, 0.3)`}}function tn(e,t){if(!t.priceLimits?.enabled||!t.priceLimits.ceilingPercent)return null;let n=t.priceLimits.ceilingPercent/100,r=(t.priceLimits.floorPercent??t.priceLimits.ceilingPercent)/100;return{ceiling:e*(1+n),floor:e*(1-r),reference:e}}function nn(e){let t=new Date,n=`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`;for(let t of e)if(n>=t.startTime&&n<t.endTime)return t;return null}exports.DARK_TERMINAL=q,exports.DARK_THEME=G,exports.DEFAULT_BAR_SPACING=At,exports.DEFAULT_BAR_WIDTH=kt,exports.DEFAULT_CHART_OPTIONS=wt,exports.DEFAULT_DRAWING_STYLE=t,exports.DEFAULT_FONT_FAMILY=z,exports.DEFAULT_PANEL_HEIGHT=Pt,exports.DEFAULT_RECONNECT=a,exports.DEFAULT_SIGNAL_STYLE=r,exports.DEFAULT_STREAM_CONFIG=o,exports.DEFAULT_TIMEFRAME_FAVORITES=Ot,exports.DEFAULT_TRADE_ZONE_STYLE=i,exports.DEFAULT_TRADING_CONFIG=n,exports.HNX_SESSIONS=$,exports.HOSE_SESSIONS=Jt,exports.LIGHT_THEME=K,exports.LayerType=e,exports.MARKET_CRYPTO=Qt,exports.MARKET_HNX=Xt,exports.MARKET_HOSE=Yt,exports.MARKET_NYSE=$t,exports.MARKET_UPCOM=Zt,exports.MIN_PANEL_HEIGHT=Nt,exports.PRICE_AXIS_WIDTH=jt,exports.PRICE_SOURCES=Ke,exports.TC_PALETTE=V,exports.TC_SERIES_COLORS=It,exports.TIMEFRAMES_CRYPTO=Tt,exports.TIMEFRAMES_FOREX=Dt,exports.TIMEFRAMES_STOCK=Et,exports.TIME_AXIS_HEIGHT=Mt,exports.VN_COLORS=Q,exports.VOLUME_ALPHA=Ft,exports.alignToTimeframe=je,exports.autoPricePrecision=ze,exports.barsAreDaily=Fe,exports.clamp=ne,exports.computePriceLimits=tn,exports.computePriceRange=de,exports.computeTickStep=oe,exports.createVNTheme=en,exports.detectPrecision=Ge,exports.drawingOption=mt,exports.en=J,exports.findBarIndex=ue,exports.formatFraction=Ve,exports.formatNumber=Z,exports.formatPrice=A,exports.formatPriceScaleLabel=Be,exports.formatTimestamp=Ae,exports.formatVND=Kt,exports.formatVolume=We,exports.formatVolumeLoc=qt,exports.fractionTick=He,exports.getCurrentSession=nn,exports.getLocale=Ht,exports.getLocaleStrings=Gt,exports.hexToRgba=pe,exports.indicatorSource=Xe,exports.inverseLerp=ie,exports.isDateOnly=Ne,exports.isPriceSource=qe,exports.isTimeFrame=ke,exports.isValidTimeZone=xe,exports.lerp=re,exports.lerpColor=he,exports.marketStatus=ot,exports.mergeBar=fe,exports.niceNumber=p,exports.normalizeBar=ce,exports.normalizeBarTime=se,exports.offsetAt=S,exports.parseIndicatorSource=Ze,exports.parseTimeframe=T,exports.pickBaseTimeframe=tt,exports.priceFormatterFor=Ue,exports.rankSymbols=rt,exports.readChartTypeOptions=Ct,exports.readNews=te,exports.readQuote=c,exports.registerLocale=Wt,exports.resampleBars=$e,exports.resolveDrawingOptions=ht,exports.resolveVolumeColors=Rt,exports.roundToStep=ae,exports.sanitizeDrawingOptions=ft,exports.sanitizeDrawingStyle=St,exports.sessionMinute=M,exports.setLocale=Vt,exports.sliceVisibleData=le,exports.sourcePrice=Je,exports.stepDecimals=it,exports.t=Ut,exports.tickBarCount=Oe,exports.timeParts=Me,exports.timeframeBucketStart=O,exports.timeframeToMs=E,exports.tzLabel=Ie,exports.vi=zt,exports.volumeColor=H,exports.wallToUtc=Ce,exports.withAlpha=me,exports.zoneOffsetMinutes=b,exports.zonedDateFormatter=we;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|