oakscriptjs 0.23.0 → 0.25.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/README.md +25 -1
- package/bin/oakscript.mjs +10 -3
- package/dist/cjs/box/index.d.ts +348 -289
- package/dist/cjs/box/index.d.ts.map +1 -1
- package/dist/cjs/box/index.js.map +2 -2
- package/dist/cjs/check/node.d.ts.map +1 -1
- package/dist/cjs/check/node.js +1 -0
- package/dist/cjs/check/node.js.map +2 -2
- package/dist/cjs/check/preview.d.ts +31 -0
- package/dist/cjs/check/preview.d.ts.map +1 -0
- package/dist/cjs/check/preview.js +303 -0
- package/dist/cjs/check/preview.js.map +7 -0
- package/dist/cjs/color/index.d.ts +11 -11
- package/dist/cjs/color/index.js.map +1 -1
- package/dist/cjs/color/parse.d.ts +2 -0
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +6 -0
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/compare/index.d.ts +76 -12
- package/dist/cjs/compare/index.d.ts.map +1 -1
- package/dist/cjs/compare/index.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +28 -5
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +14 -0
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts +265 -187
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js +1 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/line/index.d.ts +247 -207
- package/dist/cjs/line/index.d.ts.map +1 -1
- package/dist/cjs/line/index.js.map +2 -2
- package/dist/cjs/linefill/index.d.ts +61 -89
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/math/index.d.ts +49 -40
- package/dist/cjs/math/index.d.ts.map +1 -1
- package/dist/cjs/math/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +57 -78
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/runtime/input-active.d.ts +2 -2
- package/dist/cjs/runtime/input-active.js.map +1 -1
- package/dist/cjs/runtime/series.d.ts +241 -161
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +223 -127
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/api/alert.d.ts +37 -0
- package/dist/cjs/script/api/alert.d.ts.map +1 -0
- package/dist/cjs/script/api/alert.js +17 -0
- package/dist/cjs/script/api/alert.js.map +7 -0
- package/dist/cjs/script/api/calc.d.ts +232 -0
- package/dist/cjs/script/api/calc.d.ts.map +1 -0
- package/dist/cjs/script/api/calc.js +17 -0
- package/dist/cjs/script/api/calc.js.map +7 -0
- package/dist/cjs/script/api/color.d.ts +213 -0
- package/dist/cjs/script/api/color.d.ts.map +1 -0
- package/dist/cjs/script/api/color.js +17 -0
- package/dist/cjs/script/api/color.js.map +7 -0
- package/dist/cjs/script/api/context.d.ts +764 -0
- package/dist/cjs/script/api/context.d.ts.map +1 -0
- package/dist/cjs/script/api/context.js +17 -0
- package/dist/cjs/script/api/context.js.map +7 -0
- package/dist/cjs/script/api/log.d.ts +58 -0
- package/dist/cjs/script/api/log.d.ts.map +1 -0
- package/dist/cjs/script/api/log.js +17 -0
- package/dist/cjs/script/api/log.js.map +7 -0
- package/dist/cjs/script/api/strategy.d.ts +391 -0
- package/dist/cjs/script/api/strategy.d.ts.map +1 -0
- package/dist/cjs/script/api/strategy.js +17 -0
- package/dist/cjs/script/api/strategy.js.map +7 -0
- package/dist/cjs/script/api/ta.d.ts +1012 -0
- package/dist/cjs/script/api/ta.d.ts.map +1 -0
- package/dist/cjs/script/api/ta.js +17 -0
- package/dist/cjs/script/api/ta.js.map +7 -0
- package/dist/cjs/script/api/table.d.ts +479 -0
- package/dist/cjs/script/api/table.d.ts.map +1 -0
- package/dist/cjs/script/api/table.js +17 -0
- package/dist/cjs/script/api/table.js.map +7 -0
- package/dist/cjs/script/constants.d.ts +228 -83
- package/dist/cjs/script/constants.d.ts.map +1 -1
- package/dist/cjs/script/constants.js +87 -0
- package/dist/cjs/script/constants.js.map +2 -2
- package/dist/cjs/script/define.d.ts +94 -0
- package/dist/cjs/script/define.d.ts.map +1 -0
- package/dist/cjs/script/define.js +127 -0
- package/dist/cjs/script/define.js.map +7 -0
- package/dist/cjs/script/drawing-args.d.ts.map +1 -1
- package/dist/cjs/script/drawing-args.js +1 -1
- package/dist/cjs/script/drawing-args.js.map +2 -2
- package/dist/cjs/script/formula.d.ts +53 -0
- package/dist/cjs/script/formula.d.ts.map +1 -0
- package/dist/cjs/script/formula.js +402 -0
- package/dist/cjs/script/formula.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +10 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/index.d.ts +1065 -1006
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +532 -61
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/script/json.d.ts +117 -0
- package/dist/cjs/script/json.d.ts.map +1 -0
- package/dist/cjs/script/json.js +321 -0
- package/dist/cjs/script/json.js.map +7 -0
- package/dist/cjs/security/other.d.ts +8 -3
- package/dist/cjs/security/other.d.ts.map +1 -1
- package/dist/cjs/security/other.js +23 -6
- package/dist/cjs/security/other.js.map +2 -2
- package/dist/cjs/str/index.d.ts +50 -75
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +2 -2
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +102 -1
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +2 -2
- package/dist/cjs/table/index.d.ts +330 -49
- package/dist/cjs/table/index.d.ts.map +1 -1
- package/dist/cjs/table/index.js +55 -27
- package/dist/cjs/table/index.js.map +2 -2
- package/dist/cjs/text/index.d.ts +12 -14
- package/dist/cjs/text/index.d.ts.map +1 -1
- package/dist/cjs/text/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +15 -8
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +12 -3
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/esm/box/index.d.ts +348 -289
- package/dist/esm/box/index.d.ts.map +1 -1
- package/dist/esm/box/index.js +276 -276
- package/dist/esm/box/index.js.map +1 -1
- package/dist/esm/check/node.d.ts.map +1 -1
- package/dist/esm/check/node.js +1 -0
- package/dist/esm/check/node.js.map +1 -1
- package/dist/esm/check/preview.d.ts +31 -0
- package/dist/esm/check/preview.d.ts.map +1 -0
- package/dist/esm/check/preview.js +296 -0
- package/dist/esm/check/preview.js.map +1 -0
- package/dist/esm/color/index.d.ts +11 -11
- package/dist/esm/color/index.js +11 -11
- package/dist/esm/color/parse.d.ts +2 -0
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +7 -0
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/compare/index.d.ts +76 -12
- package/dist/esm/compare/index.d.ts.map +1 -1
- package/dist/esm/compare/index.js +76 -12
- package/dist/esm/compare/index.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +28 -5
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +39 -3
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts +265 -187
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js +207 -177
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/line/index.d.ts +247 -207
- package/dist/esm/line/index.d.ts.map +1 -1
- package/dist/esm/line/index.js +202 -194
- package/dist/esm/line/index.js.map +1 -1
- package/dist/esm/linefill/index.d.ts +61 -89
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +61 -89
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/math/index.d.ts +49 -40
- package/dist/esm/math/index.d.ts.map +1 -1
- package/dist/esm/math/index.js +22 -9
- package/dist/esm/math/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +57 -78
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +57 -78
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/runtime/input-active.d.ts +2 -2
- package/dist/esm/runtime/input-active.js +2 -2
- package/dist/esm/runtime/series.d.ts +241 -161
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +241 -161
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/api/alert.d.ts +37 -0
- package/dist/esm/script/api/alert.d.ts.map +1 -0
- package/dist/esm/script/api/alert.js +7 -0
- package/dist/esm/script/api/alert.js.map +1 -0
- package/dist/esm/script/api/calc.d.ts +232 -0
- package/dist/esm/script/api/calc.d.ts.map +1 -0
- package/dist/esm/script/api/calc.js +6 -0
- package/dist/esm/script/api/calc.js.map +1 -0
- package/dist/esm/script/api/color.d.ts +213 -0
- package/dist/esm/script/api/color.d.ts.map +1 -0
- package/dist/esm/script/api/color.js +6 -0
- package/dist/esm/script/api/color.js.map +1 -0
- package/dist/esm/script/api/context.d.ts +764 -0
- package/dist/esm/script/api/context.d.ts.map +1 -0
- package/dist/esm/script/api/context.js +7 -0
- package/dist/esm/script/api/context.js.map +1 -0
- package/dist/esm/script/api/log.d.ts +58 -0
- package/dist/esm/script/api/log.d.ts.map +1 -0
- package/dist/esm/script/api/log.js +6 -0
- package/dist/esm/script/api/log.js.map +1 -0
- package/dist/esm/script/api/strategy.d.ts +391 -0
- package/dist/esm/script/api/strategy.d.ts.map +1 -0
- package/dist/esm/script/api/strategy.js +7 -0
- package/dist/esm/script/api/strategy.js.map +1 -0
- package/dist/esm/script/api/ta.d.ts +1012 -0
- package/dist/esm/script/api/ta.d.ts.map +1 -0
- package/dist/esm/script/api/ta.js +6 -0
- package/dist/esm/script/api/ta.js.map +1 -0
- package/dist/esm/script/api/table.d.ts +479 -0
- package/dist/esm/script/api/table.d.ts.map +1 -0
- package/dist/esm/script/api/table.js +7 -0
- package/dist/esm/script/api/table.js.map +1 -0
- package/dist/esm/script/constants.d.ts +228 -83
- package/dist/esm/script/constants.d.ts.map +1 -1
- package/dist/esm/script/constants.js +110 -24
- package/dist/esm/script/constants.js.map +1 -1
- package/dist/esm/script/define.d.ts +94 -0
- package/dist/esm/script/define.d.ts.map +1 -0
- package/dist/esm/script/define.js +136 -0
- package/dist/esm/script/define.js.map +1 -0
- package/dist/esm/script/drawing-args.d.ts.map +1 -1
- package/dist/esm/script/drawing-args.js +2 -1
- package/dist/esm/script/drawing-args.js.map +1 -1
- package/dist/esm/script/formula.d.ts +53 -0
- package/dist/esm/script/formula.d.ts.map +1 -0
- package/dist/esm/script/formula.js +408 -0
- package/dist/esm/script/formula.js.map +1 -0
- package/dist/esm/script/globals.d.ts +10 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/index.d.ts +1065 -1006
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +1099 -153
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/script/json.d.ts +117 -0
- package/dist/esm/script/json.d.ts.map +1 -0
- package/dist/esm/script/json.js +375 -0
- package/dist/esm/script/json.js.map +1 -0
- package/dist/esm/security/other.d.ts +8 -3
- package/dist/esm/security/other.d.ts.map +1 -1
- package/dist/esm/security/other.js +45 -10
- package/dist/esm/security/other.js.map +1 -1
- package/dist/esm/str/index.d.ts +50 -75
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +51 -76
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +102 -1
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/strategy/index.js +1 -1
- package/dist/esm/strategy/index.js.map +1 -1
- package/dist/esm/table/index.d.ts +330 -49
- package/dist/esm/table/index.d.ts.map +1 -1
- package/dist/esm/table/index.js +372 -61
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/text/index.d.ts +12 -14
- package/dist/esm/text/index.d.ts.map +1 -1
- package/dist/esm/text/index.js +12 -14
- package/dist/esm/text/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +15 -8
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +15 -8
- package/dist/esm/types/index.js.map +1 -1
- package/docs/first-indicator.md +152 -0
- package/docs/guide.md +1185 -0
- package/docs/inventory.md +772 -0
- package/docs/no-code.md +207 -0
- package/docs/recipes.md +202 -0
- package/package.json +2 -1
- package/skills/oakscript/SKILL.md +8 -0
- package/skills/oakscript/reference/errors.md +3 -2
- package/skills/oakscript/reference/timeframes-symbols.md +4 -0
- package/src/box/index.ts +348 -289
- package/src/check/node.ts +1 -0
- package/src/check/preview.ts +307 -0
- package/src/color/index.ts +11 -11
- package/src/color/parse.ts +7 -0
- package/src/compare/index.ts +76 -12
- package/src/drawing/registry.ts +44 -5
- package/src/index.ts +1 -1
- package/src/label/index.ts +267 -189
- package/src/line/index.ts +248 -208
- package/src/linefill/index.ts +61 -89
- package/src/math/index.ts +51 -42
- package/src/polyline/index.ts +57 -78
- package/src/runtime/input-active.ts +2 -2
- package/src/runtime/series.ts +243 -163
- package/src/script/api/alert.ts +43 -0
- package/src/script/api/calc.ts +250 -0
- package/src/script/api/color.ts +245 -0
- package/src/script/api/context.ts +944 -0
- package/src/script/api/log.ts +60 -0
- package/src/script/api/strategy.ts +410 -0
- package/src/script/api/ta.ts +1115 -0
- package/src/script/api/table.ts +538 -0
- package/src/script/constants.ts +229 -25
- package/src/script/define.ts +221 -0
- package/src/script/drawing-args.ts +2 -1
- package/src/script/formula.ts +438 -0
- package/src/script/globals.ts +10 -0
- package/src/script/index.ts +1520 -241
- package/src/script/json.ts +457 -0
- package/src/security/other.ts +43 -9
- package/src/str/index.ts +51 -76
- package/src/strategy/index.ts +102 -1
- package/src/table/index.ts +388 -62
- package/src/text/index.ts +12 -14
- package/src/types/index.ts +15 -8
package/dist/esm/str/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { formatDate } from './dateformat.js';
|
|
|
18
18
|
* @returns The number of characters in the string
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
-
* ```
|
|
21
|
+
* ```js
|
|
22
22
|
* str.length("Hello") // Returns: 5
|
|
23
23
|
* str.length("") // Returns: 0
|
|
24
24
|
* ```
|
|
@@ -63,7 +63,7 @@ export function length(str) {
|
|
|
63
63
|
* "NaNT" for `format.volume`), except `format.mintick`, which gives "Infinity" / "-Infinity"
|
|
64
64
|
*
|
|
65
65
|
* @example
|
|
66
|
-
* ```
|
|
66
|
+
* ```js
|
|
67
67
|
* str.tostring(123) // "123"
|
|
68
68
|
* str.tostring(1.5, "#.##") // "1.5"
|
|
69
69
|
* str.tostring(0.5, "#.00") // ".50"
|
|
@@ -140,7 +140,7 @@ export function tostring(value, format, mintick, pricescale) {
|
|
|
140
140
|
* (no-break space U+00A0, U+3000) give na
|
|
141
141
|
*
|
|
142
142
|
* @example
|
|
143
|
-
* ```
|
|
143
|
+
* ```js
|
|
144
144
|
* str.tonumber("123") // Returns: 123
|
|
145
145
|
* str.tonumber("45.67") // Returns: 45.67
|
|
146
146
|
* str.tonumber("abc") // Returns: null
|
|
@@ -176,7 +176,7 @@ export function tonumber(str) {
|
|
|
176
176
|
* - Indices beyond string length return empty string
|
|
177
177
|
*
|
|
178
178
|
* @example
|
|
179
|
-
* ```
|
|
179
|
+
* ```js
|
|
180
180
|
* str.substring("hello world", 0, 5) // Returns: "hello"
|
|
181
181
|
* str.substring("hello world", 6) // Returns: "world"
|
|
182
182
|
* str.substring("test", 1, 3) // Returns: "es"
|
|
@@ -194,7 +194,7 @@ export function substring(str, begin, end) {
|
|
|
194
194
|
* @returns The uppercase string
|
|
195
195
|
*
|
|
196
196
|
* @example
|
|
197
|
-
* ```
|
|
197
|
+
* ```js
|
|
198
198
|
* str.upper("hello") // Returns: "HELLO"
|
|
199
199
|
* str.upper("Hello World") // Returns: "HELLO WORLD"
|
|
200
200
|
* str.upper("test123") // Returns: "TEST123"
|
|
@@ -210,7 +210,7 @@ export function upper(str) {
|
|
|
210
210
|
* @returns The lowercase string
|
|
211
211
|
*
|
|
212
212
|
* @example
|
|
213
|
-
* ```
|
|
213
|
+
* ```js
|
|
214
214
|
* str.lower("HELLO") // Returns: "hello"
|
|
215
215
|
* str.lower("Hello World") // Returns: "hello world"
|
|
216
216
|
* str.lower("TEST123") // Returns: "test123"
|
|
@@ -231,7 +231,7 @@ export function lower(str) {
|
|
|
231
231
|
* - Empty string is contained in any string
|
|
232
232
|
*
|
|
233
233
|
* @example
|
|
234
|
-
* ```
|
|
234
|
+
* ```js
|
|
235
235
|
* str.contains("hello world", "world") // Returns: true
|
|
236
236
|
* str.contains("hello world", "World") // Returns: false (case-sensitive)
|
|
237
237
|
* str.contains("test", "xyz") // Returns: false
|
|
@@ -253,7 +253,7 @@ export function contains(source, str) {
|
|
|
253
253
|
* - Returns na (NaN) if substring is not found, as in PineScript
|
|
254
254
|
*
|
|
255
255
|
* @example
|
|
256
|
-
* ```
|
|
256
|
+
* ```js
|
|
257
257
|
* str.pos("hello world", "world") // Returns: 6
|
|
258
258
|
* str.pos("hello world", "o") // Returns: 4 (first occurrence)
|
|
259
259
|
* str.pos("hello", "xyz") // Returns: NaN (na)
|
|
@@ -281,7 +281,7 @@ export function pos(source, str) {
|
|
|
281
281
|
* - fewer than N + 1 occurrences (or a negative N) leave the source unchanged
|
|
282
282
|
*
|
|
283
283
|
* @example
|
|
284
|
-
* ```
|
|
284
|
+
* ```js
|
|
285
285
|
* str.replace("hello world hello", "hello", "hi") // Returns: "hi world hello"
|
|
286
286
|
* str.replace("hello world hello", "hello", "hi", 1) // Returns: "hello world hi"
|
|
287
287
|
* str.replace("test", "xyz", "abc") // Returns: "test"
|
|
@@ -320,7 +320,7 @@ export function replace(source, target, replacement, occurrence = 0) {
|
|
|
320
320
|
* - This matches PineScript's `str.replace_all()` behavior
|
|
321
321
|
*
|
|
322
322
|
* @example
|
|
323
|
-
* ```
|
|
323
|
+
* ```js
|
|
324
324
|
* str.replace_all("hello world hello", "hello", "hi") // Returns: "hi world hi"
|
|
325
325
|
* str.replace_all("a-b-c", "-", "_") // Returns: "a_b_c"
|
|
326
326
|
* str.replace_all("test", "x", "y") // Returns: "test" (no match)
|
|
@@ -342,7 +342,7 @@ export function replace_all(source, target, replacement) {
|
|
|
342
342
|
* - Consecutive separators create empty strings in result
|
|
343
343
|
*
|
|
344
344
|
* @example
|
|
345
|
-
* ```
|
|
345
|
+
* ```js
|
|
346
346
|
* str.split("a,b,c", ",") // Returns: ["a", "b", "c"]
|
|
347
347
|
* str.split("hello", "") // Returns: ["h", "e", "l", "l", "o"]
|
|
348
348
|
* str.split("a,,b", ",") // Returns: ["a", "", "b"]
|
|
@@ -359,7 +359,7 @@ export function split(str, separator) {
|
|
|
359
359
|
* @returns The concatenated string
|
|
360
360
|
*
|
|
361
361
|
* @example
|
|
362
|
-
* ```
|
|
362
|
+
* ```js
|
|
363
363
|
* str.concat("hello", " ", "world") // Returns: "hello world"
|
|
364
364
|
* str.concat("a", "b", "c") // Returns: "abc"
|
|
365
365
|
* str.concat("test") // Returns: "test"
|
|
@@ -369,27 +369,29 @@ export function concat(...strings) {
|
|
|
369
369
|
return strings.join('');
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
|
-
*
|
|
372
|
+
* Builds a text from a pattern and values: each `{0}`, `{1}`... is replaced by the argument at that position, e.g.
|
|
373
|
+
* `str.format("Close {0}, change {1,number,percent}", c.close, 0.025)`. Use it for labels and messages.
|
|
373
374
|
*
|
|
374
|
-
* @param
|
|
375
|
-
*
|
|
376
|
-
*
|
|
375
|
+
* @param pattern - The text with placeholders: `{0}` (a number shows as "#,##0.###"), `{1,number,#.##}` (number
|
|
376
|
+
* pattern), `{0,number,percent}`, `{0,number,integer}`, `{0,date,yyyy-MM-dd}` (a time in milliseconds); '...' in
|
|
377
|
+
* single quotes is kept as it is, '' is a quote
|
|
378
|
+
* @param args - The values of the placeholders, in order: numbers, texts, booleans, arrays
|
|
379
|
+
* @returns The text with the values in place
|
|
377
380
|
*
|
|
378
381
|
* @remarks
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
* Dates are formatted in UTC here; PineScript uses the exchange time zone.
|
|
382
|
+
* - numbers in `{n}` use "#,##0.###" (1234.5678 gives "1,234.568"); number patterns round half to even on the
|
|
383
|
+
* exact value (16 decimals at most from 1e-3 up); an array gives "[a, b]"
|
|
384
|
+
* - a missing argument leaves `{n}` in the text
|
|
385
|
+
* - dates are written in the exchange time zone of the symbol in a script, in UTC when called outside a script
|
|
384
386
|
*
|
|
385
387
|
* @example
|
|
386
|
-
* ```
|
|
387
|
-
* str.format(
|
|
388
|
-
* str.format(
|
|
388
|
+
* ```js
|
|
389
|
+
* str.format("Close: {0,number,#.##}", 101.456) // Returns: "Close: 101.46"
|
|
390
|
+
* str.format("{0} and {1}", "a", 2) // Returns: "a and 2"
|
|
389
391
|
* ```
|
|
390
392
|
*/
|
|
391
|
-
export function format(
|
|
392
|
-
return formatMessage(
|
|
393
|
+
export function format(pattern, ...args) {
|
|
394
|
+
return formatMessage(pattern, args, 'Etc/UTC');
|
|
393
395
|
}
|
|
394
396
|
/**
|
|
395
397
|
* Checks if a string starts with a specific prefix.
|
|
@@ -403,7 +405,7 @@ export function format(formatStr, ...args) {
|
|
|
403
405
|
* - Empty string prefix always returns true
|
|
404
406
|
*
|
|
405
407
|
* @example
|
|
406
|
-
* ```
|
|
408
|
+
* ```js
|
|
407
409
|
* str.startswith("hello world", "hello") // Returns: true
|
|
408
410
|
* str.startswith("hello world", "Hello") // Returns: false (case-sensitive)
|
|
409
411
|
* str.startswith("test", "testing") // Returns: false
|
|
@@ -424,7 +426,7 @@ export function startswith(source, str) {
|
|
|
424
426
|
* - Empty string suffix always returns true
|
|
425
427
|
*
|
|
426
428
|
* @example
|
|
427
|
-
* ```
|
|
429
|
+
* ```js
|
|
428
430
|
* str.endswith("hello world", "world") // Returns: true
|
|
429
431
|
* str.endswith("hello world", "World") // Returns: false (case-sensitive)
|
|
430
432
|
* str.endswith("testing", "test") // Returns: false
|
|
@@ -445,7 +447,7 @@ export function endswith(source, str) {
|
|
|
445
447
|
* - Unicode characters may span multiple code units
|
|
446
448
|
*
|
|
447
449
|
* @example
|
|
448
|
-
* ```
|
|
450
|
+
* ```js
|
|
449
451
|
* str.charAt("hello", 0) // Returns: "h"
|
|
450
452
|
* str.charAt("hello", 4) // Returns: "o"
|
|
451
453
|
* str.charAt("hello", 10) // Returns: ""
|
|
@@ -465,7 +467,7 @@ export function charAt(str, pos) {
|
|
|
465
467
|
* - Preserves internal whitespace
|
|
466
468
|
*
|
|
467
469
|
* @example
|
|
468
|
-
* ```
|
|
470
|
+
* ```js
|
|
469
471
|
* str.trim(" hello ") // Returns: "hello"
|
|
470
472
|
* str.trim(" hello world ") // Returns: "hello world"
|
|
471
473
|
* str.trim("\thello\n") // Returns: "hello"
|
|
@@ -485,7 +487,7 @@ export function trim(str) {
|
|
|
485
487
|
* - Preserves trailing and internal whitespace
|
|
486
488
|
*
|
|
487
489
|
* @example
|
|
488
|
-
* ```
|
|
490
|
+
* ```js
|
|
489
491
|
* str.trimLeft(" hello ") // Returns: "hello "
|
|
490
492
|
* str.trimLeft(" hello") // Returns: "hello"
|
|
491
493
|
* str.trimLeft("\thello") // Returns: "hello"
|
|
@@ -505,7 +507,7 @@ export function trimLeft(str) {
|
|
|
505
507
|
* - Preserves leading and internal whitespace
|
|
506
508
|
*
|
|
507
509
|
* @example
|
|
508
|
-
* ```
|
|
510
|
+
* ```js
|
|
509
511
|
* str.trimRight(" hello ") // Returns: " hello"
|
|
510
512
|
* str.trimRight("hello ") // Returns: "hello"
|
|
511
513
|
* str.trimRight("hello\t") // Returns: "hello"
|
|
@@ -526,7 +528,7 @@ export function trimRight(str) {
|
|
|
526
528
|
* - Uses JavaScript regex syntax
|
|
527
529
|
*
|
|
528
530
|
* @example
|
|
529
|
-
* ```
|
|
531
|
+
* ```js
|
|
530
532
|
* str.match("abc123def", "[0-9]+") // Returns: "123"
|
|
531
533
|
* str.match("abc", "[0-9]+") // Returns: null (na)
|
|
532
534
|
* ```
|
|
@@ -535,42 +537,6 @@ export function match(source, regex) {
|
|
|
535
537
|
const found = new RegExp(regex).exec(source);
|
|
536
538
|
return found && found[0] !== '' ? found[0] : null;
|
|
537
539
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Formats a timestamp as a string according to the specified format.
|
|
540
|
-
*
|
|
541
|
-
* @param time - Unix timestamp in milliseconds
|
|
542
|
-
* @param format - Format string using PineScript format specifiers
|
|
543
|
-
* @returns Formatted date/time string
|
|
544
|
-
*
|
|
545
|
-
* @remarks
|
|
546
|
-
* Supported format specifiers (case-sensitive):
|
|
547
|
-
* - `yyyy` - 4-digit year (e.g., "2024")
|
|
548
|
-
* - `yy` - 2-digit year (e.g., "24")
|
|
549
|
-
* - `MMMM` - Full month name (e.g., "January")
|
|
550
|
-
* - `MMM` - Abbreviated month name (e.g., "Jan")
|
|
551
|
-
* - `MM` - 2-digit month (01-12)
|
|
552
|
-
* - `M` - Month (1-12)
|
|
553
|
-
* - `dd` - 2-digit day (01-31)
|
|
554
|
-
* - `d` - Day (1-31)
|
|
555
|
-
* - `HH` - 2-digit hour (00-23)
|
|
556
|
-
* - `H` - Hour (0-23)
|
|
557
|
-
* - `hh` - 2-digit hour (01-12)
|
|
558
|
-
* - `h` - Hour (1-12)
|
|
559
|
-
* - `mm` - 2-digit minute (00-59)
|
|
560
|
-
* - `m` - Minute (0-59)
|
|
561
|
-
* - `ss` - 2-digit second (00-59)
|
|
562
|
-
* - `s` - Second (0-59)
|
|
563
|
-
* - `a` - AM/PM
|
|
564
|
-
*
|
|
565
|
-
* @example
|
|
566
|
-
* ```typescript
|
|
567
|
-
* const timestamp = 1609459200000; // Jan 1, 2021 00:00:00 UTC
|
|
568
|
-
* str.format_time(timestamp, "dd MMM yyyy") // Returns: "01 Jan 2021"
|
|
569
|
-
* str.format_time(timestamp, "yyyy-MM-dd HH:mm:ss") // Returns: "2021-01-01 00:00:00"
|
|
570
|
-
* str.format_time(timestamp, "MMM d, yyyy") // Returns: "Jan 1, 2021"
|
|
571
|
-
* str.format_time(timestamp, "hh:mm a") // Returns: "12:00 AM"
|
|
572
|
-
* ```
|
|
573
|
-
*/
|
|
574
540
|
/**
|
|
575
541
|
* Constructs a new string containing the source string repeated N times with an optional separator.
|
|
576
542
|
*
|
|
@@ -580,7 +546,7 @@ export function match(source, regex) {
|
|
|
580
546
|
* @returns The repeated string, or null (na) if source is na or count is 0 / negative / na, as in PineScript
|
|
581
547
|
*
|
|
582
548
|
* @example
|
|
583
|
-
* ```
|
|
549
|
+
* ```js
|
|
584
550
|
* str.repeat("ab", 3) // Returns: "ababab"
|
|
585
551
|
* str.repeat("?", 3, ",") // Returns: "?,?,?"
|
|
586
552
|
* str.repeat("hello", 0) // Returns: null (na)
|
|
@@ -595,17 +561,26 @@ export function repeat(source, count, separator = '') {
|
|
|
595
561
|
return Array(count).fill(source).join(separator);
|
|
596
562
|
}
|
|
597
563
|
/**
|
|
598
|
-
*
|
|
564
|
+
* Writes a time as a date text, e.g. "2024-03-15 09:30". Use it for labels, tables and log messages.
|
|
599
565
|
*
|
|
600
|
-
* @param time -
|
|
601
|
-
* @param format -
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
* @
|
|
566
|
+
* @param time - The time in milliseconds since 1 January 1970 UTC, e.g. `time` on a bar or `timenow`
|
|
567
|
+
* @param format - Date pattern: `yyyy` year, `MM` month number, `MMM` month name, `dd` day, `EEE` weekday,
|
|
568
|
+
* `HH` hour (00-23), `hh` hour (01-12) with `a` (AM/PM), `mm` minutes, `ss` seconds, `SSS` milliseconds,
|
|
569
|
+
* `Z` / `z` time zone; 'text' in single quotes is kept as it is. Default: "yyyy-MM-dd'T'HH:mm:ssZ"
|
|
570
|
+
* @param timezone - Time zone of the text: a UTC offset ("UTC-5", "GMT+2") or a zone name ("America/New_York").
|
|
571
|
+
* Default in a script: the exchange time zone of the symbol; called outside a script: "Etc/UTC"
|
|
572
|
+
* @returns The date text
|
|
605
573
|
*
|
|
606
574
|
* @remarks
|
|
607
575
|
* Letters: y, M, d, E, u, D, w,
|
|
608
576
|
* H, k, K, h, a, m, s, S, Z, z; 'text' is literal text.
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```js
|
|
580
|
+
* eachBar((c) => {
|
|
581
|
+
* if (c.i === c.n - 1) label.new(c.i, c.high, str.format_time(c.get(time), "yyyy-MM-dd HH:mm"));
|
|
582
|
+
* });
|
|
583
|
+
* ```
|
|
609
584
|
*/
|
|
610
585
|
export function format_time(time, format = "yyyy-MM-dd'T'HH:mm:ssZ", timezone = 'Etc/UTC') {
|
|
611
586
|
return formatDate(time, format, timezone);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,GAAkB;IACvC,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,QA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CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,WAAW,CAAC,IAAgB,EAAE,SAAwB,wBAAwB,EAAE,WAA0B,SAAS;IACjI,OAAO,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -44,115 +44,200 @@ export declare const STRATEGY_CONSTANTS: {
|
|
|
44
44
|
};
|
|
45
45
|
/** Arguments of the PineScript `strategy()` declaration, after `title`. */
|
|
46
46
|
export interface StrategyOptions {
|
|
47
|
+
/** Short name shown in the legend. Default: the title. */
|
|
47
48
|
shorttitle?: string;
|
|
49
|
+
/** true: drawn over the price chart; false: in its own pane. Default: false. */
|
|
48
50
|
overlay?: boolean;
|
|
51
|
+
/** Number format of the values: `format.price`, `format.volume`, `format.percent`... Default: the symbol's price format. */
|
|
49
52
|
format?: string;
|
|
53
|
+
/** Decimals shown for the values. Default: the symbol's. */
|
|
50
54
|
precision?: number;
|
|
55
|
+
/** Price scale the strategy uses: `scale.right`, `scale.left` or `scale.none`. */
|
|
51
56
|
scale?: string;
|
|
57
|
+
/** Most entries allowed in the same direction; 0 and 1 both allow one. Default: 0. */
|
|
52
58
|
pyramiding?: number;
|
|
59
|
+
/** true: runs the bar again after an order fills inside it, so new orders can be sent at once. Default: false. */
|
|
53
60
|
calc_on_order_fills?: boolean;
|
|
61
|
+
/** true: runs on every price update of the live bar, not only when it closes. Default: false. */
|
|
54
62
|
calc_on_every_tick?: boolean;
|
|
55
63
|
/** Runs the strategy on each tick of the history bars too (the reference app's "On history bar tick"). */
|
|
56
64
|
calc_on_every_history_tick?: boolean;
|
|
65
|
+
/** History length kept for the script's Series. Default: worked out from the script. */
|
|
57
66
|
max_bars_back?: number;
|
|
67
|
+
/** Ticks the price must go past a limit price before the limit order fills. Default: 0. */
|
|
58
68
|
backtest_fill_limits_assumption?: number;
|
|
69
|
+
/** Unit of `default_qty_value`: `strategy.fixed` (contracts / shares), `strategy.cash` or `strategy.percent_of_equity`. Default: `strategy.percent_of_equity`. */
|
|
59
70
|
default_qty_type?: StrategyQtyType;
|
|
71
|
+
/** Size of an order that gives no `qty`, in the unit of `default_qty_type`. Default: 100. */
|
|
60
72
|
default_qty_value?: number;
|
|
73
|
+
/** Money the account starts with, in the account currency. Default: 100000. */
|
|
61
74
|
initial_capital?: number;
|
|
62
75
|
/** Account currency; default: the symbol currency. */
|
|
63
76
|
currency?: string;
|
|
64
77
|
/** Ticks added to market and stop fills. */
|
|
65
78
|
slippage?: number;
|
|
79
|
+
/** How `commission_value` is read: `strategy.commission.percent` (of the order value), `.cash_per_contract` or `.cash_per_order`. Default: percent. */
|
|
66
80
|
commission_type?: StrategyCommissionType;
|
|
81
|
+
/** Commission per order, in the unit of `commission_type`. Default: 0. */
|
|
67
82
|
commission_value?: number;
|
|
83
|
+
/** true: orders fill at the close of the bar that sent them instead of the next bar's open. Default: false. */
|
|
68
84
|
process_orders_on_close?: boolean;
|
|
85
|
+
/** Which entry an exit closes first: "FIFO" (the oldest) or "ANY" (the one named by `from_entry`). Default: "FIFO". */
|
|
69
86
|
close_entries_rule?: 'FIFO' | 'ANY';
|
|
87
|
+
/** Share of a long position's value the account must hold, in percent (100: no leverage). Default: 100. */
|
|
70
88
|
margin_long?: number;
|
|
89
|
+
/** Share of a short position's value the account must hold, in percent. Default: 100. */
|
|
71
90
|
margin_short?: number;
|
|
91
|
+
/** true: outputs are drawn in the order the script writes them. Default: false. */
|
|
72
92
|
explicit_plot_zorder?: boolean;
|
|
93
|
+
/** Most `line` drawings kept on the chart (the oldest go). Default: 50. */
|
|
73
94
|
max_lines_count?: number;
|
|
95
|
+
/** Most labels kept on the chart (the oldest go). Default: 50. */
|
|
74
96
|
max_labels_count?: number;
|
|
97
|
+
/** Most boxes kept on the chart (the oldest go). Default: 50. */
|
|
75
98
|
max_boxes_count?: number;
|
|
99
|
+
/** Runs only on the last this many bars; 0 runs on all. Default: 0. */
|
|
76
100
|
calc_bars_count?: number;
|
|
101
|
+
/** Yearly risk-free rate, in percent, for the Sharpe and Sortino ratios. Default: 2. */
|
|
77
102
|
risk_free_rate?: number;
|
|
103
|
+
/** true: fills orders with the bars of a lower timeframe inside each bar, for more exact fills. Default: false. */
|
|
78
104
|
use_bar_magnifier?: boolean;
|
|
105
|
+
/** true: on synthetic charts (Heikin Ashi...) orders fill at the real prices. Default: false. */
|
|
79
106
|
fill_orders_on_standard_ohlc?: boolean;
|
|
107
|
+
/** Most polylines kept on the chart (the oldest go). Default: 50. */
|
|
80
108
|
max_polylines_count?: number;
|
|
81
109
|
}
|
|
82
110
|
/** Strategy properties passed to the engine: the declared values, else the PineScript defaults. */
|
|
83
111
|
export interface StrategyProperties {
|
|
112
|
+
/** Most entries in the same direction (0 and 1 allow one). */
|
|
84
113
|
pyramiding: number;
|
|
114
|
+
/** Runs the bar again after a fill inside it. */
|
|
85
115
|
calc_on_order_fills: boolean;
|
|
116
|
+
/** Runs on every price update of the live bar. */
|
|
86
117
|
calc_on_every_tick: boolean;
|
|
118
|
+
/** Runs on each price step of the history bars. */
|
|
87
119
|
calc_on_every_history_tick: boolean;
|
|
120
|
+
/** Ticks the price must pass a limit price by before it fills. */
|
|
88
121
|
backtest_fill_limits_assumption: number;
|
|
122
|
+
/** Unit of `default_qty_value`. */
|
|
89
123
|
default_qty_type: StrategyQtyType;
|
|
124
|
+
/** Size of an order that gives no `qty`. */
|
|
90
125
|
default_qty_value: number;
|
|
126
|
+
/** Money the account starts with. */
|
|
91
127
|
initial_capital: number;
|
|
92
128
|
/** undefined: the symbol currency. */
|
|
93
129
|
currency?: string;
|
|
130
|
+
/** Ticks added against you to market and stop fills. */
|
|
94
131
|
slippage: number;
|
|
132
|
+
/** How `commission_value` is read. */
|
|
95
133
|
commission_type: StrategyCommissionType;
|
|
134
|
+
/** Commission per order. */
|
|
96
135
|
commission_value: number;
|
|
136
|
+
/** Orders fill at the close of the bar that sent them. */
|
|
97
137
|
process_orders_on_close: boolean;
|
|
138
|
+
/** "FIFO": exits close the oldest entry first; "ANY": the entry they name. */
|
|
98
139
|
close_entries_rule: 'FIFO' | 'ANY';
|
|
140
|
+
/** Margin of long positions, in percent of their value. */
|
|
99
141
|
margin_long: number;
|
|
142
|
+
/** Margin of short positions, in percent of their value. */
|
|
100
143
|
margin_short: number;
|
|
144
|
+
/** Runs on the last this many bars; 0: all. */
|
|
101
145
|
calc_bars_count: number;
|
|
146
|
+
/** Yearly risk-free rate in percent (Sharpe, Sortino). */
|
|
102
147
|
risk_free_rate: number;
|
|
148
|
+
/** Fills orders with lower-timeframe bars. */
|
|
103
149
|
use_bar_magnifier: boolean;
|
|
150
|
+
/** Fills at real prices on synthetic charts. */
|
|
104
151
|
fill_orders_on_standard_ohlc: boolean;
|
|
105
152
|
}
|
|
106
|
-
/**
|
|
153
|
+
/** Default values of the `strategy()` options, used for every option a strategy leaves out. */
|
|
107
154
|
export declare const STRATEGY_DEFAULTS: StrategyProperties;
|
|
108
155
|
/** `strategy.entry()` / `strategy.order()` arguments after `id` and `direction`. */
|
|
109
156
|
export interface StrategyEntryOptions {
|
|
157
|
+
/** Contracts / shares to trade. Default: from `default_qty_type` and `default_qty_value`. */
|
|
110
158
|
qty?: number;
|
|
159
|
+
/** Limit price: the order fills at this price or better. Left out with `stop` too: a market order. */
|
|
111
160
|
limit?: number;
|
|
161
|
+
/** Stop price: the order fills once the price reaches it. With `limit`: a stop-limit order. */
|
|
112
162
|
stop?: number;
|
|
163
|
+
/** Name of a one-cancels-all group the order belongs to. */
|
|
113
164
|
oca_name?: string;
|
|
165
|
+
/** What a fill in the group does to the others: `strategy.oca.cancel`, `.reduce` or `.none`. Default: none. */
|
|
114
166
|
oca_type?: StrategyOcaType;
|
|
167
|
+
/** Text shown with the order's fill on the chart and in the trade list. */
|
|
115
168
|
comment?: string;
|
|
169
|
+
/** Text of the alert sent when the order fills. */
|
|
116
170
|
alert_message?: string;
|
|
171
|
+
/** true: the order's fill sends no alert. Default: false. */
|
|
117
172
|
disable_alert?: boolean;
|
|
118
173
|
}
|
|
119
174
|
/** `strategy.exit()` arguments after `id`. `profit`, `loss`, `trail_points` and `trail_offset` are in ticks. */
|
|
120
175
|
export interface StrategyExitOptions {
|
|
176
|
+
/** Id of the entry to exit. Default: every open entry. */
|
|
121
177
|
from_entry?: string;
|
|
178
|
+
/** Contracts / shares to exit. Default: the whole position (see `qty_percent`). */
|
|
122
179
|
qty?: number;
|
|
180
|
+
/** Share of the position to exit, in percent. Default: 100. */
|
|
123
181
|
qty_percent?: number;
|
|
182
|
+
/** Take-profit distance from the entry price, in ticks. */
|
|
124
183
|
profit?: number;
|
|
184
|
+
/** Take-profit price. */
|
|
125
185
|
limit?: number;
|
|
186
|
+
/** Stop-loss distance from the entry price, in ticks. */
|
|
126
187
|
loss?: number;
|
|
188
|
+
/** Stop-loss price. */
|
|
127
189
|
stop?: number;
|
|
190
|
+
/** Price at which the trailing stop starts. */
|
|
128
191
|
trail_price?: number;
|
|
192
|
+
/** Distance from the entry, in ticks, at which the trailing stop starts. */
|
|
129
193
|
trail_points?: number;
|
|
194
|
+
/** Distance the trailing stop keeps from the best price, in ticks. */
|
|
130
195
|
trail_offset?: number;
|
|
196
|
+
/** Name of the one-cancels-all group of the exit's orders. Default: one group per exit. */
|
|
131
197
|
oca_name?: string;
|
|
198
|
+
/** Text shown with the exit fill. */
|
|
132
199
|
comment?: string;
|
|
200
|
+
/** Text shown when the take-profit fills. Default: `comment`. */
|
|
133
201
|
comment_profit?: string;
|
|
202
|
+
/** Text shown when the stop-loss fills. Default: `comment`. */
|
|
134
203
|
comment_loss?: string;
|
|
204
|
+
/** Text shown when the trailing stop fills. Default: `comment`. */
|
|
135
205
|
comment_trailing?: string;
|
|
206
|
+
/** Text of the alert sent when the exit fills. */
|
|
136
207
|
alert_message?: string;
|
|
208
|
+
/** Alert text when the take-profit fills. Default: `alert_message`. */
|
|
137
209
|
alert_profit?: string;
|
|
210
|
+
/** Alert text when the stop-loss fills. Default: `alert_message`. */
|
|
138
211
|
alert_loss?: string;
|
|
212
|
+
/** Alert text when the trailing stop fills. Default: `alert_message`. */
|
|
139
213
|
alert_trailing?: string;
|
|
214
|
+
/** true: the exit sends no alert. Default: false. */
|
|
140
215
|
disable_alert?: boolean;
|
|
141
216
|
}
|
|
142
217
|
/** `strategy.close()` arguments after `id`. */
|
|
143
218
|
export interface StrategyCloseOptions {
|
|
219
|
+
/** Text shown with the closing fill. */
|
|
144
220
|
comment?: string;
|
|
221
|
+
/** Contracts / shares to close. Default: all of the entry. */
|
|
145
222
|
qty?: number;
|
|
223
|
+
/** Share to close, in percent. Default: 100. */
|
|
146
224
|
qty_percent?: number;
|
|
225
|
+
/** Text of the alert sent when it fills. */
|
|
147
226
|
alert_message?: string;
|
|
227
|
+
/** true: closes at the current bar's close instead of the next bar's open. Default: false. */
|
|
148
228
|
immediately?: boolean;
|
|
229
|
+
/** true: sends no alert. Default: false. */
|
|
149
230
|
disable_alert?: boolean;
|
|
150
231
|
}
|
|
151
232
|
/** `strategy.close_all()` arguments. */
|
|
152
233
|
export interface StrategyCloseAllOptions {
|
|
234
|
+
/** Text shown with the closing fill. */
|
|
153
235
|
comment?: string;
|
|
236
|
+
/** Text of the alert sent when it fills. */
|
|
154
237
|
alert_message?: string;
|
|
238
|
+
/** true: closes at the current bar's close instead of the next bar's open. Default: false. */
|
|
155
239
|
immediately?: boolean;
|
|
240
|
+
/** true: sends no alert. Default: false. */
|
|
156
241
|
disable_alert?: boolean;
|
|
157
242
|
}
|
|
158
243
|
/** A `strategy.risk.*` rule. */
|
|
@@ -187,25 +272,41 @@ export type StrategyRiskRule = {
|
|
|
187
272
|
* comments are undefined when the engine does not provide them.
|
|
188
273
|
*/
|
|
189
274
|
export interface StrategyTrade {
|
|
275
|
+
/** Id of the entry order. */
|
|
190
276
|
entry_id: string;
|
|
277
|
+
/** Price the entry filled at. */
|
|
191
278
|
entry_price: number;
|
|
279
|
+
/** Bar number of the entry (0 = first bar). */
|
|
192
280
|
entry_bar_index: number;
|
|
281
|
+
/** Time of the entry, in UNIX milliseconds. */
|
|
193
282
|
entry_time: number;
|
|
194
283
|
/** undefined when the order had no comment, or when the engine does not keep it apart from the id. */
|
|
195
284
|
entry_comment?: string;
|
|
196
285
|
/** Signed quantity: positive for a long trade, negative for a short trade. */
|
|
197
286
|
size: number;
|
|
287
|
+
/** Profit of the trade in the account currency (negative for a loss), after commission. */
|
|
198
288
|
profit: number;
|
|
289
|
+
/** Profit of the trade in percent of its entry value. */
|
|
199
290
|
profit_percent: number;
|
|
291
|
+
/** Commission paid for the trade. */
|
|
200
292
|
commission: number;
|
|
293
|
+
/** Largest open profit the trade reached, in the account currency. */
|
|
201
294
|
max_runup: number;
|
|
295
|
+
/** Largest open profit in percent. */
|
|
202
296
|
max_runup_percent: number;
|
|
297
|
+
/** Largest open loss the trade reached, in the account currency. */
|
|
203
298
|
max_drawdown: number;
|
|
299
|
+
/** Largest open loss in percent. */
|
|
204
300
|
max_drawdown_percent: number;
|
|
301
|
+
/** Id of the order that closed the trade. */
|
|
205
302
|
exit_id?: string;
|
|
303
|
+
/** Price the exit filled at. */
|
|
206
304
|
exit_price?: number;
|
|
305
|
+
/** Bar number of the exit. */
|
|
207
306
|
exit_bar_index?: number;
|
|
307
|
+
/** Time of the exit, in UNIX milliseconds. */
|
|
208
308
|
exit_time?: number;
|
|
309
|
+
/** Comment of the exit order. */
|
|
209
310
|
exit_comment?: string;
|
|
210
311
|
}
|
|
211
312
|
/** Numeric `strategy.*` variables. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/strategy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,m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: 'long', short: 'short' },
|
|
24
24
|
oca: { none: 'none', cancel: 'cancel', reduce: 'reduce' },
|
|
25
25
|
};
|
|
26
|
-
/**
|
|
26
|
+
/** Default values of the `strategy()` options, used for every option a strategy leaves out. */
|
|
27
27
|
export const STRATEGY_DEFAULTS = {
|
|
28
28
|
pyramiding: 0,
|
|
29
29
|
calc_on_order_fills: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strategy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,yCAAyC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,iBAAiB,EAAE,mBAAmB;IACtC,UAAU,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,gBAAgB,EAAE;IAC5G,SAAS,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;IACvD,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/strategy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,yCAAyC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,iBAAiB,EAAE,mBAAmB;IACtC,UAAU,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,gBAAgB,EAAE;IAC5G,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