oakscriptjs 0.15.4 → 0.17.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/cjs/drawing/registry.d.ts +44 -5
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +18 -9
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/script/index.d.ts +20 -0
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +11 -1
- package/dist/cjs/script/index.js.map +2 -2
- package/dist/esm/drawing/registry.d.ts +44 -5
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +58 -11
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/script/index.d.ts +20 -0
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +18 -2
- package/dist/esm/script/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/oakscript/reference/pine-differences.md +3 -3
- package/skills/oakscript/reference/timeframes-symbols.md +10 -0
- package/src/drawing/registry.ts +64 -14
- package/src/index.ts +6 -2
- package/src/script/index.ts +44 -2
package/dist/esm/script/index.js
CHANGED
|
@@ -2676,10 +2676,20 @@ function security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol
|
|
|
2676
2676
|
const mapped = values.map((v) => ranges.map(([from, to]) => v.slice(from, to)));
|
|
2677
2677
|
return (Array.isArray(result) ? mapped : mapped[0]);
|
|
2678
2678
|
}
|
|
2679
|
-
/**
|
|
2679
|
+
/**
|
|
2680
|
+
* PineScript `request.seed(source, symbol, expression, ignore_invalid_symbol)` (#205): `expression` on a seed data
|
|
2681
|
+
* series, on the chart timeframe. The series is the symbol `ChartContext.seedSymbol(source, symbol)` (default
|
|
2682
|
+
* `"<SOURCE>:<SYMBOL>"` upper-cased), read as `request.security(<that symbol>, "", expression)`.
|
|
2683
|
+
*/
|
|
2684
|
+
function seed(source, symbol, expression, ignore_invalid_symbol = false) {
|
|
2685
|
+
const ticker = chartCtx.seedSymbol?.(source, symbol) ?? `${source.toUpperCase()}:${symbol.toUpperCase()}`;
|
|
2686
|
+
return security(ticker, '', expression, barmerge.gaps_off, barmerge.lookahead_off, ignore_invalid_symbol);
|
|
2687
|
+
}
|
|
2688
|
+
/** PineScript `request.*`: `security` (issue #101, other symbols #179, lower timeframes #181), `security_lower_tf` and `seed` (#205). */
|
|
2680
2689
|
/** PineScript parameters of `request.security` / `request.security_lower_tf`, in their positional order. */
|
|
2681
2690
|
const SECURITY_PARAMETERS = ['symbol', 'timeframe', 'expression', 'gaps', 'lookahead', 'ignore_invalid_symbol', 'currency', 'calc_bars_count'];
|
|
2682
2691
|
const SECURITY_LOWER_TF_PARAMETERS = ['symbol', 'timeframe', 'expression', 'ignore_invalid_symbol', 'currency', 'ignore_invalid_timeframe', 'calc_bars_count'];
|
|
2692
|
+
const SEED_PARAMETERS = ['source', 'symbol', 'expression', 'ignore_invalid_symbol', 'calc_bars_count'];
|
|
2683
2693
|
/** `currency` and `calc_bars_count` change the values in PineScript: they throw instead of being ignored. */
|
|
2684
2694
|
function unsupportedSecurityArgs(name, currency, calcBarsCount) {
|
|
2685
2695
|
if (currency !== undefined && currency !== '' && currency !== 'NONE') {
|
|
@@ -2702,7 +2712,13 @@ function securityLowerTfCall(...args) {
|
|
|
2702
2712
|
throw new Error('request.security_lower_tf(): the ignore_invalid_timeframe argument is not supported.');
|
|
2703
2713
|
return security_lower_tf(a[0], a[1], a[2], a[3]);
|
|
2704
2714
|
}
|
|
2705
|
-
|
|
2715
|
+
/** `request.seed` with PineScript's named arguments. */
|
|
2716
|
+
function seedCall(...args) {
|
|
2717
|
+
const a = namedArguments('request.seed', SEED_PARAMETERS, args);
|
|
2718
|
+
unsupportedSecurityArgs('request.seed', undefined, a[4]);
|
|
2719
|
+
return seed(a[0], a[1], a[2], a[3]);
|
|
2720
|
+
}
|
|
2721
|
+
export const request = strictNamespace('request', { security: securityCall, security_lower_tf: securityLowerTfCall, seed: seedCall });
|
|
2706
2722
|
const loopBar = () => currentBar;
|
|
2707
2723
|
/** Wraps a drawing namespace and keeps its `all` getter (the live drawings in creation order). */
|
|
2708
2724
|
function drawings(name, members, all) {
|