oakscriptjs 0.6.0 → 0.7.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/color/index.d.ts +15 -15
- package/dist/color/index.d.ts.map +1 -1
- package/dist/compare/index.d.ts +8 -0
- package/dist/compare/index.d.ts.map +1 -0
- package/dist/index.cjs +101 -79
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +101 -79
- package/dist/runtime/series.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/script/index.cjs +123 -69
- package/dist/script/index.d.ts +20 -15
- package/dist/script/index.d.ts.map +1 -1
- package/dist/script/index.mjs +123 -69
- package/dist/ta/index.d.ts.map +1 -1
- package/dist/types/metadata.d.ts +7 -0
- package/dist/types/metadata.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/color/index.d.ts
CHANGED
|
@@ -6,23 +6,23 @@ export declare function r(clr: color): int;
|
|
|
6
6
|
export declare function g(clr: color): int;
|
|
7
7
|
export declare function b(clr: color): int;
|
|
8
8
|
export declare function t(clr: color): float;
|
|
9
|
-
export declare const aqua = "#
|
|
10
|
-
export declare const black = "#
|
|
11
|
-
export declare const blue = "#
|
|
12
|
-
export declare const fuchsia = "#
|
|
13
|
-
export declare const gray = "#
|
|
14
|
-
export declare const green = "#
|
|
15
|
-
export declare const lime = "#
|
|
16
|
-
export declare const maroon = "#
|
|
17
|
-
export declare const navy = "#
|
|
9
|
+
export declare const aqua = "#00BCD4";
|
|
10
|
+
export declare const black = "#363A45";
|
|
11
|
+
export declare const blue = "#2962FF";
|
|
12
|
+
export declare const fuchsia = "#E040FB";
|
|
13
|
+
export declare const gray = "#787B86";
|
|
14
|
+
export declare const green = "#4CAF50";
|
|
15
|
+
export declare const lime = "#00E676";
|
|
16
|
+
export declare const maroon = "#880E4F";
|
|
17
|
+
export declare const navy = "#311B92";
|
|
18
18
|
export declare const olive = "#808000";
|
|
19
|
-
export declare const orange = "#
|
|
20
|
-
export declare const purple = "#
|
|
21
|
-
export declare const red = "#
|
|
22
|
-
export declare const silver = "#
|
|
23
|
-
export declare const teal = "#
|
|
19
|
+
export declare const orange = "#FF9800";
|
|
20
|
+
export declare const purple = "#9C27B0";
|
|
21
|
+
export declare const red = "#F23645";
|
|
22
|
+
export declare const silver = "#B2B5BE";
|
|
23
|
+
export declare const teal = "#089981";
|
|
24
24
|
export declare const white = "#FFFFFF";
|
|
25
|
-
export declare const yellow = "#
|
|
25
|
+
export declare const yellow = "#FDD835";
|
|
26
26
|
export declare function from_gradient(value: float, bottom_value: float, top_value: float, bottom_color: color, top_color: color): color;
|
|
27
27
|
export { new_color as new };
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA0B5E,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,KAAK,CAUtG;AAyBD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,KAAK,CASlE;AAwBD,wBAAgB,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,GAAG,KAAK,CAIvE;AAiBD,wBAAgB,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAEjC;AAiBD,wBAAgB,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAEjC;AAiBD,wBAAgB,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAEjC;AAqBD,wBA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AAMhC,eAAO,MAAM,MAAM,YAAY,CAAC;AAMhC,eAAO,MAAM,GAAG,YAAY,CAAC;AAM7B,eAAO,MAAM,MAAM,YAAY,CAAC;AAMhC,eAAO,MAAM,IAAI,YAAY,CAAC;AAM9B,eAAO,MAAM,KAAK,YAAY,CAAC;AAM/B,eAAO,MAAM,MAAM,YAAY,CAAC;AAmChC,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,KAAK,GACf,KAAK,CAqBP;AAqBD,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const EPSILON = 1e-10;
|
|
2
|
+
export declare function eq(a: number, b: number): boolean;
|
|
3
|
+
export declare function ne(a: number, b: number): boolean;
|
|
4
|
+
export declare function lt(a: number, b: number): boolean;
|
|
5
|
+
export declare function le(a: number, b: number): boolean;
|
|
6
|
+
export declare function gt(a: number, b: number): boolean;
|
|
7
|
+
export declare function ge(a: number, b: number): boolean;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compare/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO,QAAQ,CAAC;AAK7B,wBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD;AAGD,wBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD;AAGD,wBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD;AAGD,wBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD;AAGD,wBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD;AAGD,wBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
clearPlots: () => clearPlots,
|
|
42
42
|
color: () => color_exports,
|
|
43
43
|
color_from_hex: () => from_hex,
|
|
44
|
+
compare: () => compare_exports,
|
|
44
45
|
cos: () => cos,
|
|
45
46
|
createPlot: () => createPlot,
|
|
46
47
|
crossover: () => crossover2,
|
|
@@ -249,8 +250,8 @@ function rsi(source, length2) {
|
|
|
249
250
|
for (let i = 1; i < source.length; i++) {
|
|
250
251
|
changes.push(source[i] - source[i - 1]);
|
|
251
252
|
}
|
|
252
|
-
const gains = changes.map((c) => c > 0 ? c : 0);
|
|
253
|
-
const losses = changes.map((c) => c < 0 ? -c : 0);
|
|
253
|
+
const gains = changes.map((c) => Number.isNaN(c) ? NaN : c > 0 ? c : 0);
|
|
254
|
+
const losses = changes.map((c) => Number.isNaN(c) ? NaN : c < 0 ? -c : 0);
|
|
254
255
|
const avgGains = rma(gains, length2);
|
|
255
256
|
const avgLosses = rma(losses, length2);
|
|
256
257
|
result.push(NaN);
|
|
@@ -477,8 +478,10 @@ function rma(source, length2) {
|
|
|
477
478
|
const val = source[i];
|
|
478
479
|
if (val !== void 0 && !isNaN(val)) {
|
|
479
480
|
rmaValue = alpha * val + (1 - alpha) * rmaValue;
|
|
481
|
+
result.push(rmaValue);
|
|
482
|
+
} else {
|
|
483
|
+
result.push(NaN);
|
|
480
484
|
}
|
|
481
|
-
result.push(rmaValue);
|
|
482
485
|
}
|
|
483
486
|
}
|
|
484
487
|
return result;
|
|
@@ -1939,6 +1942,38 @@ __export(math_exports, {
|
|
|
1939
1942
|
toradians: () => toradians
|
|
1940
1943
|
});
|
|
1941
1944
|
|
|
1945
|
+
// src/compare/index.ts
|
|
1946
|
+
var compare_exports = {};
|
|
1947
|
+
__export(compare_exports, {
|
|
1948
|
+
EPSILON: () => EPSILON,
|
|
1949
|
+
eq: () => eq,
|
|
1950
|
+
ge: () => ge,
|
|
1951
|
+
gt: () => gt,
|
|
1952
|
+
le: () => le,
|
|
1953
|
+
lt: () => lt,
|
|
1954
|
+
ne: () => ne
|
|
1955
|
+
});
|
|
1956
|
+
var EPSILON = 1e-10;
|
|
1957
|
+
var valid = (a, b2) => !Number.isNaN(a) && !Number.isNaN(b2);
|
|
1958
|
+
function eq(a, b2) {
|
|
1959
|
+
return valid(a, b2) && Math.abs(a - b2) <= EPSILON;
|
|
1960
|
+
}
|
|
1961
|
+
function ne(a, b2) {
|
|
1962
|
+
return valid(a, b2) && Math.abs(a - b2) > EPSILON;
|
|
1963
|
+
}
|
|
1964
|
+
function lt(a, b2) {
|
|
1965
|
+
return valid(a, b2) && b2 - a > EPSILON;
|
|
1966
|
+
}
|
|
1967
|
+
function le(a, b2) {
|
|
1968
|
+
return valid(a, b2) && a - b2 <= EPSILON;
|
|
1969
|
+
}
|
|
1970
|
+
function gt(a, b2) {
|
|
1971
|
+
return valid(a, b2) && a - b2 > EPSILON;
|
|
1972
|
+
}
|
|
1973
|
+
function ge(a, b2) {
|
|
1974
|
+
return valid(a, b2) && b2 - a <= EPSILON;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1942
1977
|
// src/runtime/series.ts
|
|
1943
1978
|
var BarData = class _BarData {
|
|
1944
1979
|
_bars;
|
|
@@ -2187,7 +2222,7 @@ var Series = class _Series {
|
|
|
2187
2222
|
});
|
|
2188
2223
|
}
|
|
2189
2224
|
// ============================================
|
|
2190
|
-
// Comparison Operations
|
|
2225
|
+
// Comparison Operations (PineScript operators: tolerance 1e-10, false with na; see src/compare)
|
|
2191
2226
|
// ============================================
|
|
2192
2227
|
/**
|
|
2193
2228
|
* Greater than comparison
|
|
@@ -2198,7 +2233,7 @@ var Series = class _Series {
|
|
|
2198
2233
|
return new _Series(this.dataSource, (bar, i, data) => {
|
|
2199
2234
|
const a = this.extractor(bar, i, data);
|
|
2200
2235
|
const b2 = typeof other === "number" ? other : other.extractor(bar, i, data);
|
|
2201
|
-
return a
|
|
2236
|
+
return gt(a, b2) ? 1 : 0;
|
|
2202
2237
|
});
|
|
2203
2238
|
}
|
|
2204
2239
|
/**
|
|
@@ -2210,7 +2245,7 @@ var Series = class _Series {
|
|
|
2210
2245
|
return new _Series(this.dataSource, (bar, i, data) => {
|
|
2211
2246
|
const a = this.extractor(bar, i, data);
|
|
2212
2247
|
const b2 = typeof other === "number" ? other : other.extractor(bar, i, data);
|
|
2213
|
-
return a
|
|
2248
|
+
return ge(a, b2) ? 1 : 0;
|
|
2214
2249
|
});
|
|
2215
2250
|
}
|
|
2216
2251
|
/**
|
|
@@ -2222,7 +2257,7 @@ var Series = class _Series {
|
|
|
2222
2257
|
return new _Series(this.dataSource, (bar, i, data) => {
|
|
2223
2258
|
const a = this.extractor(bar, i, data);
|
|
2224
2259
|
const b2 = typeof other === "number" ? other : other.extractor(bar, i, data);
|
|
2225
|
-
return a
|
|
2260
|
+
return lt(a, b2) ? 1 : 0;
|
|
2226
2261
|
});
|
|
2227
2262
|
}
|
|
2228
2263
|
/**
|
|
@@ -2234,7 +2269,7 @@ var Series = class _Series {
|
|
|
2234
2269
|
return new _Series(this.dataSource, (bar, i, data) => {
|
|
2235
2270
|
const a = this.extractor(bar, i, data);
|
|
2236
2271
|
const b2 = typeof other === "number" ? other : other.extractor(bar, i, data);
|
|
2237
|
-
return a
|
|
2272
|
+
return le(a, b2) ? 1 : 0;
|
|
2238
2273
|
});
|
|
2239
2274
|
}
|
|
2240
2275
|
/**
|
|
@@ -2246,7 +2281,7 @@ var Series = class _Series {
|
|
|
2246
2281
|
return new _Series(this.dataSource, (bar, i, data) => {
|
|
2247
2282
|
const a = this.extractor(bar, i, data);
|
|
2248
2283
|
const b2 = typeof other === "number" ? other : other.extractor(bar, i, data);
|
|
2249
|
-
return a
|
|
2284
|
+
return eq(a, b2) ? 1 : 0;
|
|
2250
2285
|
});
|
|
2251
2286
|
}
|
|
2252
2287
|
/**
|
|
@@ -2258,7 +2293,7 @@ var Series = class _Series {
|
|
|
2258
2293
|
return new _Series(this.dataSource, (bar, i, data) => {
|
|
2259
2294
|
const a = this.extractor(bar, i, data);
|
|
2260
2295
|
const b2 = typeof other === "number" ? other : other.extractor(bar, i, data);
|
|
2261
|
-
return a
|
|
2296
|
+
return ne(a, b2) ? 1 : 0;
|
|
2262
2297
|
});
|
|
2263
2298
|
}
|
|
2264
2299
|
// ============================================
|
|
@@ -3918,6 +3953,13 @@ function t(clr) {
|
|
|
3918
3953
|
}
|
|
3919
3954
|
function parseColor(clr) {
|
|
3920
3955
|
if (typeof clr === "string") {
|
|
3956
|
+
const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(clr.trim());
|
|
3957
|
+
if (hex) {
|
|
3958
|
+
let digits = hex[1];
|
|
3959
|
+
if (digits.length <= 4) digits = [...digits].map((c) => c + c).join("");
|
|
3960
|
+
const byte = (k) => parseInt(digits.slice(k, k + 2), 16);
|
|
3961
|
+
return { r: byte(0), g: byte(2), b: byte(4), t: digits.length === 8 ? (1 - byte(6) / 255) * 100 : 0 };
|
|
3962
|
+
}
|
|
3921
3963
|
const match2 = clr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
|
|
3922
3964
|
if (match2) {
|
|
3923
3965
|
return {
|
|
@@ -3930,63 +3972,43 @@ function parseColor(clr) {
|
|
|
3930
3972
|
}
|
|
3931
3973
|
return { r: 0, g: 0, b: 0, t: 0 };
|
|
3932
3974
|
}
|
|
3933
|
-
var aqua = "#
|
|
3934
|
-
var black = "#
|
|
3935
|
-
var blue = "#
|
|
3936
|
-
var fuchsia = "#
|
|
3937
|
-
var gray = "#
|
|
3938
|
-
var green = "#
|
|
3939
|
-
var lime = "#
|
|
3940
|
-
var maroon = "#
|
|
3941
|
-
var navy = "#
|
|
3975
|
+
var aqua = "#00BCD4";
|
|
3976
|
+
var black = "#363A45";
|
|
3977
|
+
var blue = "#2962FF";
|
|
3978
|
+
var fuchsia = "#E040FB";
|
|
3979
|
+
var gray = "#787B86";
|
|
3980
|
+
var green = "#4CAF50";
|
|
3981
|
+
var lime = "#00E676";
|
|
3982
|
+
var maroon = "#880E4F";
|
|
3983
|
+
var navy = "#311B92";
|
|
3942
3984
|
var olive = "#808000";
|
|
3943
|
-
var orange = "#
|
|
3944
|
-
var purple = "#
|
|
3945
|
-
var red = "#
|
|
3946
|
-
var silver = "#
|
|
3947
|
-
var teal = "#
|
|
3985
|
+
var orange = "#FF9800";
|
|
3986
|
+
var purple = "#9C27B0";
|
|
3987
|
+
var red = "#F23645";
|
|
3988
|
+
var silver = "#B2B5BE";
|
|
3989
|
+
var teal = "#089981";
|
|
3948
3990
|
var white = "#FFFFFF";
|
|
3949
|
-
var yellow = "#
|
|
3991
|
+
var yellow = "#FDD835";
|
|
3950
3992
|
function from_gradient(value, bottom_value, top_value, bottom_color, top_color) {
|
|
3951
|
-
const
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
const match2 = col3.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
|
|
3961
|
-
if (match2) {
|
|
3962
|
-
return [
|
|
3963
|
-
parseInt(match2[1]),
|
|
3964
|
-
parseInt(match2[2]),
|
|
3965
|
-
parseInt(match2[3]),
|
|
3966
|
-
match2[4] ? parseFloat(match2[4]) : 1
|
|
3967
|
-
];
|
|
3968
|
-
}
|
|
3969
|
-
}
|
|
3970
|
-
return [0, 0, 0, 1];
|
|
3993
|
+
const transparent = "rgba(0, 0, 0, 0)";
|
|
3994
|
+
if ([value, bottom_value, top_value].some((v) => v === null || v === void 0 || Number.isNaN(v)) || bottom_value === top_value) {
|
|
3995
|
+
return transparent;
|
|
3996
|
+
}
|
|
3997
|
+
const k = value <= bottom_value ? 0 : value >= top_value ? 1 : (value - bottom_value) / (top_value - bottom_value);
|
|
3998
|
+
const rgba = (c) => {
|
|
3999
|
+
if (c === null || c === void 0) return { r: 0, g: 0, b: 0, a: 0 };
|
|
4000
|
+
const p = parseColor(c);
|
|
4001
|
+
return { r: p.r, g: p.g, b: p.b, a: Math.round((1 - p.t / 100) * 255) };
|
|
3971
4002
|
};
|
|
3972
|
-
const
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
}
|
|
3982
|
-
const r3 = Math.round(r1 + (r2 - r1) * t2);
|
|
3983
|
-
const g3 = Math.round(g1 + (g2 - g1) * t2);
|
|
3984
|
-
const b3 = Math.round(b1 + (b2 - b1) * t2);
|
|
3985
|
-
const a = a1 + (a2 - a1) * t2;
|
|
3986
|
-
if (a === 1) {
|
|
3987
|
-
return `rgb(${r3}, ${g3}, ${b3})`;
|
|
3988
|
-
}
|
|
3989
|
-
return `rgba(${r3}, ${g3}, ${b3}, ${a})`;
|
|
4003
|
+
const c1 = rgba(bottom_color);
|
|
4004
|
+
const c2 = rgba(top_color);
|
|
4005
|
+
const w1 = c1.a * (1 - k);
|
|
4006
|
+
const w2 = c2.a * k;
|
|
4007
|
+
const a = w1 + w2;
|
|
4008
|
+
if (a === 0) return transparent;
|
|
4009
|
+
const mix = (x1, x2) => Math.floor((x1 * w1 + x2 * w2) / a);
|
|
4010
|
+
const [r2, g2, b2] = [mix(c1.r, c2.r), mix(c1.g, c2.g), mix(c1.b, c2.b)];
|
|
4011
|
+
return a === 255 ? `rgb(${r2}, ${g2}, ${b2})` : `rgba(${r2}, ${g2}, ${b2}, ${a / 255})`;
|
|
3990
4012
|
}
|
|
3991
4013
|
|
|
3992
4014
|
// src/time/index.ts
|
|
@@ -4880,7 +4902,7 @@ function is_stochastic(id) {
|
|
|
4880
4902
|
}
|
|
4881
4903
|
return true;
|
|
4882
4904
|
}
|
|
4883
|
-
var
|
|
4905
|
+
var EPSILON2 = 1e-10;
|
|
4884
4906
|
function createIdentity(n) {
|
|
4885
4907
|
const m = new_matrix(n, n, 0);
|
|
4886
4908
|
for (let i = 0; i < n; i++) {
|
|
@@ -5007,7 +5029,7 @@ function det(id) {
|
|
|
5007
5029
|
swapCount++;
|
|
5008
5030
|
}
|
|
5009
5031
|
const pivot2 = a[col3][col3];
|
|
5010
|
-
if (Math.abs(pivot2) <
|
|
5032
|
+
if (Math.abs(pivot2) < EPSILON2) {
|
|
5011
5033
|
return 0;
|
|
5012
5034
|
}
|
|
5013
5035
|
determinant *= pivot2;
|
|
@@ -5058,7 +5080,7 @@ function inv(id) {
|
|
|
5058
5080
|
aug[maxRow] = temp;
|
|
5059
5081
|
}
|
|
5060
5082
|
const pivot2 = aug[col3][col3];
|
|
5061
|
-
if (Math.abs(pivot2) <
|
|
5083
|
+
if (Math.abs(pivot2) < EPSILON2) {
|
|
5062
5084
|
return null;
|
|
5063
5085
|
}
|
|
5064
5086
|
for (let j = 0; j < 2 * n; j++) {
|
|
@@ -5141,7 +5163,7 @@ function rank(id) {
|
|
|
5141
5163
|
maxRow = row2;
|
|
5142
5164
|
}
|
|
5143
5165
|
}
|
|
5144
|
-
if (maxVal <
|
|
5166
|
+
if (maxVal < EPSILON2) {
|
|
5145
5167
|
continue;
|
|
5146
5168
|
}
|
|
5147
5169
|
if (maxRow !== r2) {
|
|
@@ -5198,7 +5220,7 @@ function toHessenberg(m) {
|
|
|
5198
5220
|
for (let i = k + 1; i < n; i++) {
|
|
5199
5221
|
maxVal = Math.max(maxVal, Math.abs(h[i][k]));
|
|
5200
5222
|
}
|
|
5201
|
-
if (maxVal <
|
|
5223
|
+
if (maxVal < EPSILON2) continue;
|
|
5202
5224
|
let sigma = 0;
|
|
5203
5225
|
for (let i = k + 1; i < n; i++) {
|
|
5204
5226
|
sigma += h[i][k] * h[i][k];
|
|
@@ -5214,7 +5236,7 @@ function toHessenberg(m) {
|
|
|
5214
5236
|
for (let i = k + 1; i < n; i++) {
|
|
5215
5237
|
uTu += u[i] * u[i];
|
|
5216
5238
|
}
|
|
5217
|
-
if (uTu <
|
|
5239
|
+
if (uTu < EPSILON2) continue;
|
|
5218
5240
|
for (let j = k; j < n; j++) {
|
|
5219
5241
|
let dot = 0;
|
|
5220
5242
|
for (let i = k + 1; i < n; i++) {
|
|
@@ -5246,7 +5268,7 @@ function qrAlgorithm(h, maxIter) {
|
|
|
5246
5268
|
for (let iter = 0; iter < maxIter && remaining > 1; iter++) {
|
|
5247
5269
|
let converged = false;
|
|
5248
5270
|
for (let i = remaining - 1; i >= 1; i--) {
|
|
5249
|
-
if (Math.abs(a[i][i - 1]) <
|
|
5271
|
+
if (Math.abs(a[i][i - 1]) < EPSILON2 * (Math.abs(a[i - 1][i - 1]) + Math.abs(a[i][i]))) {
|
|
5250
5272
|
a[i][i - 1] = 0;
|
|
5251
5273
|
if (i === remaining - 1) {
|
|
5252
5274
|
eigenvals.push(a[remaining - 1][remaining - 1]);
|
|
@@ -5265,8 +5287,8 @@ function qrAlgorithm(h, maxIter) {
|
|
|
5265
5287
|
let z = a[1][0];
|
|
5266
5288
|
for (let k = 0; k < remaining - 1; k++) {
|
|
5267
5289
|
let r2 = Math.sqrt(x * x + z * z);
|
|
5268
|
-
if (r2 <
|
|
5269
|
-
r2 =
|
|
5290
|
+
if (r2 < EPSILON2) {
|
|
5291
|
+
r2 = EPSILON2;
|
|
5270
5292
|
}
|
|
5271
5293
|
const c = x / r2;
|
|
5272
5294
|
const s = z / r2;
|
|
@@ -5327,8 +5349,8 @@ function inverseIteration(m, lambda) {
|
|
|
5327
5349
|
(row2, i) => row2.map((val, j) => i === j ? val - lambda : val)
|
|
5328
5350
|
);
|
|
5329
5351
|
for (let i = 0; i < n; i++) {
|
|
5330
|
-
if (Math.abs(shifted[i][i]) <
|
|
5331
|
-
shifted[i][i] =
|
|
5352
|
+
if (Math.abs(shifted[i][i]) < EPSILON2) {
|
|
5353
|
+
shifted[i][i] = EPSILON2;
|
|
5332
5354
|
}
|
|
5333
5355
|
}
|
|
5334
5356
|
let v = new Array(n).fill(1);
|
|
@@ -5339,7 +5361,7 @@ function inverseIteration(m, lambda) {
|
|
|
5339
5361
|
norm += w[i] * w[i];
|
|
5340
5362
|
}
|
|
5341
5363
|
norm = Math.sqrt(norm);
|
|
5342
|
-
if (norm <
|
|
5364
|
+
if (norm < EPSILON2) {
|
|
5343
5365
|
return v;
|
|
5344
5366
|
}
|
|
5345
5367
|
const newV = [];
|
|
@@ -5351,7 +5373,7 @@ function inverseIteration(m, lambda) {
|
|
|
5351
5373
|
diff2 += Math.abs(Math.abs(newV[i]) - Math.abs(v[i]));
|
|
5352
5374
|
}
|
|
5353
5375
|
v = newV;
|
|
5354
|
-
if (diff2 <
|
|
5376
|
+
if (diff2 < EPSILON2) {
|
|
5355
5377
|
break;
|
|
5356
5378
|
}
|
|
5357
5379
|
}
|
|
@@ -5376,7 +5398,7 @@ function solveLinearSystem(a, b2) {
|
|
|
5376
5398
|
aug[maxRow] = temp;
|
|
5377
5399
|
}
|
|
5378
5400
|
const pivot2 = aug[col3][col3];
|
|
5379
|
-
if (Math.abs(pivot2) <
|
|
5401
|
+
if (Math.abs(pivot2) < EPSILON2) {
|
|
5380
5402
|
continue;
|
|
5381
5403
|
}
|
|
5382
5404
|
for (let row2 = col3 + 1; row2 < n; row2++) {
|
|
@@ -5393,7 +5415,7 @@ function solveLinearSystem(a, b2) {
|
|
|
5393
5415
|
sum4 -= aug[i][j] * x[j];
|
|
5394
5416
|
}
|
|
5395
5417
|
const diag = aug[i][i];
|
|
5396
|
-
x[i] = Math.abs(diag) <
|
|
5418
|
+
x[i] = Math.abs(diag) < EPSILON2 ? 0 : sum4 / diag;
|
|
5397
5419
|
}
|
|
5398
5420
|
return x;
|
|
5399
5421
|
}
|
|
@@ -7816,7 +7838,7 @@ var SimpleInputAdapter = class {
|
|
|
7816
7838
|
};
|
|
7817
7839
|
|
|
7818
7840
|
// src/index.ts
|
|
7819
|
-
var VERSION = "0.
|
|
7841
|
+
var VERSION = "0.7.0";
|
|
7820
7842
|
var info2 = {
|
|
7821
7843
|
name: "OakScriptJS",
|
|
7822
7844
|
version: VERSION,
|
package/dist/index.d.ts
CHANGED
|
@@ -16,12 +16,13 @@ import * as linefill from './linefill';
|
|
|
16
16
|
import * as chartPoint from './chartpoint';
|
|
17
17
|
import * as polyline from './polyline';
|
|
18
18
|
import * as text from './text';
|
|
19
|
-
|
|
19
|
+
import * as compare from './compare';
|
|
20
|
+
export { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, text, compare };
|
|
20
21
|
export { Series, BarData } from './runtime/series';
|
|
21
22
|
export type { SeriesExtractor } from './runtime/series';
|
|
22
23
|
import * as ta from './ta-series';
|
|
23
24
|
export { ta };
|
|
24
|
-
export type { PlotOptions, HLineOptions, FillOptions, InputMetadata, PlotMetadata, IndicatorMetadata, TimeValue, PlotData, HLineData, FillData, IndicatorResult, IndicatorFactory, PlotStyle, LineStyle, PlotDisplay, InputType } from './types/metadata';
|
|
25
|
+
export type { PlotOptions, HLineOptions, FillOptions, InputMetadata, PlotMetadata, IndicatorMetadata, TimeValue, PlotData, HLineData, FillData, FillGradient, IndicatorResult, IndicatorFactory, PlotStyle, LineStyle, PlotDisplay, InputType } from './types/metadata';
|
|
25
26
|
export { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series';
|
|
26
27
|
export { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math';
|
|
27
28
|
export { rgb, from_hex as color_from_hex, new_color } from './color';
|
|
@@ -36,7 +37,7 @@ export { input_int, input_float, input_bool, input_string, input_source, input_t
|
|
|
36
37
|
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, } from './runtime/types';
|
|
37
38
|
export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter';
|
|
38
39
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter';
|
|
39
|
-
export declare const VERSION = "0.
|
|
40
|
+
export declare const VERSION = "0.7.0";
|
|
40
41
|
export declare const info: {
|
|
41
42
|
name: string;
|
|
42
43
|
version: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AAGjC,OAAO,KAAK,MAAM,MAAM,MAAM,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","s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