@tradecanvas/commons 1.4.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/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 +659 -126
- package/dist/index.js.map +1 -1
- package/dist/types/a11y.d.ts +18 -0
- package/dist/types/a11y.d.ts.map +1 -0
- package/dist/types/chart.d.ts +113 -2
- package/dist/types/chart.d.ts.map +1 -1
- package/dist/types/drawing.d.ts +85 -1
- package/dist/types/drawing.d.ts.map +1 -1
- package/dist/types/events.d.ts +150 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/execution.d.ts +20 -1
- package/dist/types/execution.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/indicator.d.ts +81 -0
- package/dist/types/indicator.d.ts.map +1 -1
- package/dist/types/layout.d.ts +8 -0
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/news.d.ts +18 -0
- package/dist/types/news.d.ts.map +1 -0
- package/dist/types/ohlc.d.ts +11 -1
- package/dist/types/ohlc.d.ts.map +1 -1
- package/dist/types/quote.d.ts +40 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/realtime.d.ts +50 -0
- package/dist/types/realtime.d.ts.map +1 -1
- package/dist/types/rendering.d.ts +11 -0
- package/dist/types/rendering.d.ts.map +1 -1
- package/dist/types/symbol.d.ts +42 -0
- package/dist/types/symbol.d.ts.map +1 -0
- package/dist/types/theme.d.ts +6 -0
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/types/trading.d.ts +33 -2
- package/dist/types/trading.d.ts.map +1 -1
- package/dist/utils/chartTypeOptions.d.ts +9 -0
- package/dist/utils/chartTypeOptions.d.ts.map +1 -0
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/drawingOptions.d.ts +8 -0
- package/dist/utils/drawingOptions.d.ts.map +1 -0
- package/dist/utils/drawingStyle.d.ts +9 -0
- package/dist/utils/drawingStyle.d.ts.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/marketStatus.d.ts +16 -0
- package/dist/utils/marketStatus.d.ts.map +1 -0
- package/dist/utils/precision.d.ts +18 -0
- package/dist/utils/precision.d.ts.map +1 -1
- package/dist/utils/priceSource.d.ts +15 -0
- package/dist/utils/priceSource.d.ts.map +1 -0
- package/dist/utils/resample.d.ts +13 -0
- package/dist/utils/resample.d.ts.map +1 -0
- package/dist/utils/symbols.d.ts +13 -0
- package/dist/utils/symbols.d.ts.map +1 -0
- package/dist/utils/time.d.ts +29 -8
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/timezone.d.ts +28 -0
- package/dist/utils/timezone.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marketStatus.d.ts","sourceRoot":"","sources":["../../src/utils/marketStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAOD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CA4C3F"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PriceScaleMode } from '../types/rendering.js';
|
|
2
|
+
import { PriceFormatter, PriceFraction } from '../types/chart.js';
|
|
2
3
|
export declare function formatPrice(value: number, precision?: number, locale?: string): string;
|
|
3
4
|
/**
|
|
4
5
|
* Decimals the price axis uses for a visible price range: one more than its
|
|
@@ -17,6 +18,23 @@ export declare function autoPricePrecision(min: number, max: number): number;
|
|
|
17
18
|
* Falls back to a plain price when a baseline is required but missing/zero.
|
|
18
19
|
*/
|
|
19
20
|
export declare function formatPriceScaleLabel(price: number, mode: PriceScaleMode, baseline: number | undefined, precision?: number, locale?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* `value` in fractions of a point: whole points, an apostrophe, then the
|
|
23
|
+
* fraction's numerator padded to the denominator's digits (`101'16` for
|
|
24
|
+
* 101.5 in 32nds). A `subDenominator` of 2 or 4 adds the half or quarter of
|
|
25
|
+
* that fraction as one more digit, as futures quote it (`101'165`, `110'162`,
|
|
26
|
+
* `110'167`). Rounds to the nearest step. A denominator that isn't a whole
|
|
27
|
+
* number above 1 gives plain digits.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatFraction(value: number, denominator: number, subDenominator?: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* The smallest step a fraction format prints (a 32nd; a quarter of one with
|
|
32
|
+
* `subDenominator` 4), or null for a denominator it can't print (it falls
|
|
33
|
+
* back to plain digits then).
|
|
34
|
+
*/
|
|
35
|
+
export declare function fractionTick(fraction: PriceFraction): number | null;
|
|
36
|
+
/** The formatter a `priceFormat` option stands for: its function, its fraction's, or null for decimals. */
|
|
37
|
+
export declare function priceFormatterFor(format: PriceFormatter | PriceFraction | null | undefined): PriceFormatter | null;
|
|
20
38
|
export declare function formatVolume(value: number): string;
|
|
21
39
|
export declare function detectPrecision(values: number[]): number;
|
|
22
40
|
//# sourceMappingURL=precision.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../src/utils/precision.ts"],"names":[],"mappings":"AAwBA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAI,EAAE,MAAM,SAAU,GAAG,MAAM,CAElF;AAED;;;;;GA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@
|
|
|
1
|
+
import { OHLCBar } from '../types/ohlc.js';
|
|
2
|
+
/** The price an indicator can be computed from. */
|
|
3
|
+
export declare const PRICE_SOURCES: readonly ["close", "open", "high", "low", "hl2", "hlc3", "ohlc4", "hlcc4"];
|
|
4
|
+
export type PriceSource = (typeof PRICE_SOURCES)[number];
|
|
5
|
+
export declare function isPriceSource(value: unknown): value is PriceSource;
|
|
6
|
+
/** A bar's price by source: `hl2` = (high + low) / 2, `hlc3`, `ohlc4`, `hlcc4` = (h + l + 2c) / 4. */
|
|
7
|
+
export declare function sourcePrice(bar: OHLCBar, source: PriceSource): number;
|
|
8
|
+
/** A source that is another indicator's line: `ind:<instanceId>:<key>`. */
|
|
9
|
+
export declare function indicatorSource(instanceId: string, key: string): string;
|
|
10
|
+
/** The indicator line a source refers to, or null for a price source or anything else. */
|
|
11
|
+
export declare function parseIndicatorSource(value: unknown): {
|
|
12
|
+
instanceId: string;
|
|
13
|
+
key: string;
|
|
14
|
+
} | null;
|
|
15
|
+
//# sourceMappingURL=priceSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priceSource.d.ts","sourceRoot":"","sources":["../../src/utils/priceSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,mDAAmD;AACnD,eAAO,MAAM,aAAa,4EAA6E,CAAC;AAExG,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAWrE;AAID,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAI/F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OHLCBar, TimeFrame } from '../types/ohlc.js';
|
|
2
|
+
/**
|
|
3
|
+
* Aggregate bars (ascending, times in ms) into a coarser timeframe: per
|
|
4
|
+
* bucket (see `timeframeBucketStart`) the first open, the extremes, the last
|
|
5
|
+
* close and the summed volume. The input bars are not changed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resampleBars(bars: readonly OHLCBar[], target: TimeFrame, weekStartsOn?: 0 | 1): OHLCBar[];
|
|
8
|
+
/**
|
|
9
|
+
* The coarsest of `supported` that builds `target` from whole bars (e.g. 7m
|
|
10
|
+
* from 1m, 90m from 30m, a quarter from months), or null when none does.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pickBaseTimeframe(target: TimeFrame, supported: readonly TimeFrame[]): TimeFrame | null;
|
|
13
|
+
//# sourceMappingURL=resample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resample.d.ts","sourceRoot":"","sources":["../../src/utils/resample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAiB,MAAM,kBAAkB,CAAC;AAK1E;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,GAAE,CAAC,GAAG,CAAK,GAAG,OAAO,EAAE,CAgB5G;AAqBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,GAAG,IAAI,CAYtG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SymbolInfo } from '../types/symbol.js';
|
|
2
|
+
/**
|
|
3
|
+
* Symbols matching `query`, best first: an exact ticker, then tickers that
|
|
4
|
+
* start with it, then names that contain it. `boost` adds to a match's score
|
|
5
|
+
* (say, for the quote currencies most traded). An empty query keeps the order
|
|
6
|
+
* given. At most `limit` results.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rankSymbols(symbols: readonly SymbolInfo[], query: string, limit?: number, boost?: (info: SymbolInfo) => number): SymbolInfo[];
|
|
9
|
+
/** Decimals in a price step: `'0.01000000'` → 2, `'1'` → 0, `1e-8` → 8. */
|
|
10
|
+
export declare function stepDecimals(step: number | string): number;
|
|
11
|
+
/** `'09:30'` → 570 (`'24:00'`, a day's end, → 1440), or null for anything that isn't a time of day. */
|
|
12
|
+
export declare function sessionMinute(time: string): number | null;
|
|
13
|
+
//# sourceMappingURL=symbols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbols.d.ts","sourceRoot":"","sources":["../../src/utils/symbols.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWrD;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,KAAK,EAAE,MAAM,EACb,KAAK,SAAK,EACV,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,GACnC,UAAU,EAAE,CAad;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAQ1D;AAED,uGAAuG;AACvG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOzD"}
|
package/dist/utils/time.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import { TimeFrame } from '../types/ohlc.js';
|
|
1
|
+
import { TimeFrame, TimeFrameUnit } from '../types/ohlc.js';
|
|
2
|
+
import { TimeZoneSetting } from './timezone.js';
|
|
3
|
+
/** A timeframe's count and unit, or null when `value` isn't one (`'7m'` → 7 minutes). */
|
|
4
|
+
export declare function parseTimeframe(value: string): {
|
|
5
|
+
count: number;
|
|
6
|
+
unit: TimeFrameUnit;
|
|
7
|
+
} | null;
|
|
8
|
+
/** The trades per bar of a tick timeframe (`'100T'` → 100), or null for any other. */
|
|
9
|
+
export declare function tickBarCount(timeframe: string): number | null;
|
|
10
|
+
export declare function isTimeFrame(value: string): value is TimeFrame;
|
|
11
|
+
/** Length of a timeframe in milliseconds (approximate for months); NaN for a non-timeframe. */
|
|
2
12
|
export declare function timeframeToMs(tf: TimeFrame): number;
|
|
3
13
|
export declare function formatTimestamp(timestamp: number, tf: TimeFrame): string;
|
|
4
14
|
export declare function alignToTimeframe(timestamp: number, tf: TimeFrame): number;
|
|
@@ -10,21 +20,32 @@ export interface TimeParts {
|
|
|
10
20
|
minutes: number;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
|
-
* Calendar parts of a timestamp in
|
|
14
|
-
* (`
|
|
23
|
+
* Calendar parts of a timestamp in a display timezone: an IANA zone
|
|
24
|
+
* (`'America/New_York'`, daylight saving time included), a fixed UTC offset in
|
|
25
|
+
* minutes (e.g. -300 for EST) or the browser's zone (`null`).
|
|
15
26
|
*/
|
|
16
|
-
export declare function timeParts(timeMs: number,
|
|
27
|
+
export declare function timeParts(timeMs: number, tz: TimeZoneSetting): TimeParts;
|
|
17
28
|
/**
|
|
18
29
|
* A bar with no time-of-day component (a daily, weekly, monthly or yearly candle — always anchored
|
|
19
30
|
* to a calendar-day boundary, so hours/minutes read 00:00) needs the YEAR in its label instead: a
|
|
20
31
|
* bare `month/day` is ambiguous across years, and `00:00` tells a trader nothing. Detected from the
|
|
21
32
|
* parts themselves rather than a separate timeframe parameter, so every caller that formats a bar's
|
|
22
|
-
* time gets the same rule for free.
|
|
23
|
-
*
|
|
33
|
+
* time gets the same rule for free. It can't tell an hourly bar at midnight from a daily one:
|
|
34
|
+
* callers that have the series ask `barsAreDaily` first and fall back to this.
|
|
24
35
|
*/
|
|
25
36
|
export declare function isDateOnly(parts: Pick<TimeParts, 'hours' | 'minutes'>): boolean;
|
|
26
|
-
/**
|
|
27
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Whether bars are a day apart or more (daily, weekly, monthly): their labels
|
|
39
|
+
* then carry a date and no time of day, while an hourly bar at midnight keeps
|
|
40
|
+
* its time. Read from the smallest gap among the first bars, so a weekend or
|
|
41
|
+
* a missing session doesn't make an intraday series look daily. Undefined for
|
|
42
|
+
* fewer than two bars.
|
|
43
|
+
*/
|
|
44
|
+
export declare function barsAreDaily(data: ArrayLike<{
|
|
45
|
+
time: number;
|
|
46
|
+
}>): boolean | undefined;
|
|
47
|
+
/** A short label like `UTC-5` or `UTC+5:30` for the offset in force at `atMs` (default: now). */
|
|
48
|
+
export declare function tzLabel(tz: TimeZoneSetting, atMs?: number): string;
|
|
28
49
|
/**
|
|
29
50
|
* Start of the bucket a timestamp falls into for a given timeframe.
|
|
30
51
|
*
|
package/dist/utils/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AA2C/D,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAK3F;AAKD,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D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in minutes east of UTC (`-300`), or null for the browser's own zone.
|
|
4
|
+
*/
|
|
5
|
+
export type TimeZoneSetting = string | number | null;
|
|
6
|
+
/** Whether `zone` is a time zone this browser knows (an IANA name such as `'Europe/London'`). */
|
|
7
|
+
export declare function isValidTimeZone(zone: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The zone's offset from UTC, in minutes east, at `timeMs` — daylight saving
|
|
10
|
+
* time included. Throws a RangeError for a zone the browser doesn't know.
|
|
11
|
+
*/
|
|
12
|
+
export declare function zoneOffsetMinutes(zone: string, timeMs: number): number;
|
|
13
|
+
/** Minutes east of UTC at `timeMs` for any display timezone. */
|
|
14
|
+
export declare function offsetAt(tz: TimeZoneSetting, timeMs: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* The instant whose wall clock in `tz` reads `wallMs` (a wall-clock time
|
|
17
|
+
* written as if it were UTC, e.g. `Date.UTC(2026, 0, 15, 9, 30)`). A time
|
|
18
|
+
* that occurs twice (clocks going back) is its first occurrence; a time a
|
|
19
|
+
* spring-forward skips moves forward by the jump (02:30 → 03:30).
|
|
20
|
+
*/
|
|
21
|
+
export declare function wallToUtc(wallMs: number, tz: TimeZoneSetting): number;
|
|
22
|
+
/**
|
|
23
|
+
* `Intl.DateTimeFormat#format` for dates in a display timezone, cached per
|
|
24
|
+
* locale, options and zone (building a format costs ~40µs). A fixed offset
|
|
25
|
+
* is applied by shifting the instant and formatting it as UTC.
|
|
26
|
+
*/
|
|
27
|
+
export declare function zonedDateFormatter(locale: string, options: Intl.DateTimeFormatOptions, tz: TimeZoneSetting): (ms: number) => string;
|
|
28
|
+
//# sourceMappingURL=timezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AA6CrD,iGAAiG;AACjG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQrD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAetE;AA4CD,gEAAgE;AAChE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,GAAG,MAAM,CAQrE;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,qBAAqB,EACnC,EAAE,EAAE,eAAe,GAClB,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAgBxB"}
|