@tradecanvas/commons 1.51.0 → 1.53.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/icons/iconSet.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +440 -391
- package/dist/index.js.map +1 -1
- package/dist/types/builtInIndicators.d.ts +4 -1
- package/dist/types/builtInIndicators.d.ts.map +1 -1
- package/dist/types/chart.d.ts +36 -5
- package/dist/types/chart.d.ts.map +1 -1
- package/dist/types/drawing.d.ts +5 -2
- package/dist/types/drawing.d.ts.map +1 -1
- package/dist/types/events.d.ts +60 -4
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/indicator.d.ts +16 -0
- package/dist/types/indicator.d.ts.map +1 -1
- package/dist/types/realtime.d.ts +4 -1
- package/dist/types/realtime.d.ts.map +1 -1
- package/dist/types/rendering.d.ts +7 -0
- package/dist/types/rendering.d.ts.map +1 -1
- package/dist/types/symbol.d.ts +5 -1
- package/dist/types/symbol.d.ts.map +1 -1
- package/dist/utils/precision.d.ts +7 -5
- package/dist/utils/precision.d.ts.map +1 -1
- package/dist/utils/resample.d.ts +11 -2
- package/dist/utils/resample.d.ts.map +1 -1
- package/dist/utils/time.d.ts +41 -5
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/timezone.d.ts +2 -0
- package/dist/utils/timezone.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/utils/resample.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { OHLCBar, TimeFrame } from '../types/ohlc.js';
|
|
2
|
+
import { BucketOptions } from './time.js';
|
|
2
3
|
/**
|
|
3
4
|
* Aggregate bars (ascending, times in ms) into a coarser timeframe: per
|
|
4
5
|
* bucket (see `timeframeBucketStart`) the first open, the extremes, the last
|
|
5
6
|
* close and the summed volume. The input bars are not changed.
|
|
7
|
+
*
|
|
8
|
+
* With a `timeZone`, days, weeks, months and the hour frames that divide a
|
|
9
|
+
* day start at its midnight. Daily-or-longer bars stamped at 00:00 UTC are
|
|
10
|
+
* read as the dates they name (unless `dates` says otherwise), so a Monday
|
|
11
|
+
* stays in its own week west of UTC, and the weeks keep 00:00 UTC stamps.
|
|
6
12
|
*/
|
|
7
|
-
export declare function resampleBars(bars: readonly OHLCBar[], target: TimeFrame,
|
|
13
|
+
export declare function resampleBars(bars: readonly OHLCBar[], target: TimeFrame, options?: 0 | 1 | BucketOptions): OHLCBar[];
|
|
8
14
|
/**
|
|
9
15
|
* The coarsest of `supported` that builds `target` from whole bars (e.g. 7m
|
|
10
16
|
* from 1m, 90m from 30m, a quarter from months), or null when none does.
|
|
17
|
+
* With a `timeZone`, a target whose buckets start at its midnight (days,
|
|
18
|
+
* weeks, months, 2h to 12h) takes only bars that line up with it: 1h for
|
|
19
|
+
* Ho Chi Minh City's days, not 4h.
|
|
11
20
|
*/
|
|
12
|
-
export declare function pickBaseTimeframe(target: TimeFrame, supported: readonly TimeFrame[]): TimeFrame | null;
|
|
21
|
+
export declare function pickBaseTimeframe(target: TimeFrame, supported: readonly TimeFrame[], options?: Pick<BucketOptions, 'timeZone'>): TimeFrame | null;
|
|
13
22
|
//# sourceMappingURL=resample.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAC1E,OAAO,EAA2F,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAMxI;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,CAAC,GAAG,CAAC,GAAG,aAAiB,GAAG,OAAO,EAAE,CAiBvH;AAwCD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,SAAS,EAAE,EAC/B,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAM,GAC5C,SAAS,GAAG,IAAI,CAelB"}
|
package/dist/utils/time.d.ts
CHANGED
|
@@ -47,13 +47,49 @@ export declare function barsAreDaily(data: ArrayLike<{
|
|
|
47
47
|
}>): boolean | undefined;
|
|
48
48
|
/** A short label like `UTC-5` or `UTC+5:30` for the offset in force at `atMs` (default: now). */
|
|
49
49
|
export declare function tzLabel(tz: TimeZoneSetting, atMs?: number): string;
|
|
50
|
+
/** Where the buckets of `timeframeBucketStart` (and `resampleBars`) start. */
|
|
51
|
+
export interface BucketOptions {
|
|
52
|
+
/** The day weeks start on: 0 Sunday, 1 Monday (the default). */
|
|
53
|
+
weekStartsOn?: 0 | 1;
|
|
54
|
+
/**
|
|
55
|
+
* The zone whose midnight days start at: an IANA name such as
|
|
56
|
+
* `'Asia/Ho_Chi_Minh'` (daylight saving time included), or minutes east of
|
|
57
|
+
* UTC. Days, weeks, months and the hour frames that divide a day (2h, 3h,
|
|
58
|
+
* 4h, 6h, 8h, 12h) follow it; 1h and shorter frames keep their epoch floor,
|
|
59
|
+
* so the hour a fall-back night repeats stays two bars. Left out, UTC's.
|
|
60
|
+
*/
|
|
61
|
+
timeZone?: string | number;
|
|
62
|
+
/**
|
|
63
|
+
* The times are bars a day long or more: one stamped at 00:00 UTC is the
|
|
64
|
+
* date it names, and keeps that date's UTC bucket and stamp. Other times
|
|
65
|
+
* are instants in `timeZone`.
|
|
66
|
+
*/
|
|
67
|
+
dates?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** Whether `timeframeBucketStart` starts the buckets of `tf` at a zone's midnight when given one. */
|
|
70
|
+
export declare function timeframeFollowsDays(tf: TimeFrame): boolean;
|
|
71
|
+
/** Whether bars of `tf` are a day long or more (days, weeks, months), which feeds often stamp by date. */
|
|
72
|
+
export declare function timeframeSpansDays(tf: TimeFrame): boolean;
|
|
50
73
|
/**
|
|
51
74
|
* Start of the bucket a timestamp falls into for a given timeframe.
|
|
52
75
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* and
|
|
56
|
-
*
|
|
76
|
+
* Minutes and hours floor to multiples of the frame since the Unix epoch.
|
|
77
|
+
* Days, weeks (from Monday, or `weekStartsOn`), months, quarters and years
|
|
78
|
+
* start at midnight, and the hour frames that divide a day (2h to 12h) count
|
|
79
|
+
* from it: UTC's, or `timeZone`'s when given (a day the clocks change is 23
|
|
80
|
+
* or 25 hours long, its 4h bucket 3 or 5). A 3M frame starts on quarters, a
|
|
81
|
+
* 12M one on 1 January. The third argument may also be the day weeks start
|
|
82
|
+
* on alone. Throws a RangeError for a zone the browser doesn't know.
|
|
83
|
+
*/
|
|
84
|
+
export declare function timeframeBucketStart(timestamp: number, tf: TimeFrame, options?: 0 | 1 | BucketOptions): number;
|
|
85
|
+
/**
|
|
86
|
+
* The zone a bar a day long or more is dated in, whatever zone the chart
|
|
87
|
+
* shows (`tz`): UTC for one stamped at 00:00 UTC, the date it names; its
|
|
88
|
+
* exchange's zone (`exchangeZone`) for one stamped at the exchange's
|
|
89
|
+
* midnight, as the days a chart builds are; else `tz`, so a bar stamped at
|
|
90
|
+
* the browser's midnight still reads its own date there.
|
|
57
91
|
*/
|
|
58
|
-
export declare function
|
|
92
|
+
export declare function barDateZone(timeMs: number, tz: TimeZoneSetting, exchangeZone?: string | null): TimeZoneSetting;
|
|
93
|
+
/** The calendar parts a bar a day long or more is labelled with: its date, in the zone `barDateZone` gives. */
|
|
94
|
+
export declare function barDateParts(timeMs: number, tz: TimeZoneSetting, exchangeZone?: string | null): TimeParts;
|
|
59
95
|
//# sourceMappingURL=time.d.ts.map
|
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,EAAkB,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,
|
|
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,EAAsC,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AA4CzF,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;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS,CAE7D;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAKnD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,CAUxE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,CAGzE;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EA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EzG"}
|
package/dist/utils/timezone.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare function isValidTimeZone(zone: string): boolean;
|
|
|
10
10
|
* time included. Throws a RangeError for a zone the browser doesn't know.
|
|
11
11
|
*/
|
|
12
12
|
export declare function zoneOffsetMinutes(zone: string, timeMs: number): number;
|
|
13
|
+
/** Whether `tz` keeps UTC's clock all year: a name of UTC itself, or an offset of 0. */
|
|
14
|
+
export declare function isUtcTimeZone(tz: TimeZoneSetting): boolean;
|
|
13
15
|
/** Minutes east of UTC at `timeMs` for any display timezone. */
|
|
14
16
|
export declare function offsetAt(tz: TimeZoneSetting, timeMs: number): number;
|
|
15
17
|
/**
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts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