oakscriptjs 0.15.1 → 0.15.3

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.
Files changed (103) hide show
  1. package/dist/cjs/callsite/index.d.ts.map +1 -1
  2. package/dist/cjs/callsite/index.js +61 -7
  3. package/dist/cjs/callsite/index.js.map +2 -2
  4. package/dist/cjs/drawing/registry.d.ts +31 -3
  5. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  6. package/dist/cjs/drawing/registry.js +188 -68
  7. package/dist/cjs/drawing/registry.js.map +2 -2
  8. package/dist/cjs/index.d.ts +1 -1
  9. package/dist/cjs/index.js +1 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/linefill/index.d.ts.map +1 -1
  12. package/dist/cjs/linefill/index.js +14 -5
  13. package/dist/cjs/linefill/index.js.map +2 -2
  14. package/dist/cjs/session/bars.d.ts +3 -0
  15. package/dist/cjs/session/bars.d.ts.map +1 -1
  16. package/dist/cjs/session/bars.js +10 -3
  17. package/dist/cjs/session/bars.js.map +2 -2
  18. package/dist/cjs/session/calendar.d.ts +19 -6
  19. package/dist/cjs/session/calendar.d.ts.map +1 -1
  20. package/dist/cjs/session/calendar.js +57 -18
  21. package/dist/cjs/session/calendar.js.map +2 -2
  22. package/dist/cjs/session/context.d.ts.map +1 -1
  23. package/dist/cjs/session/context.js +25 -8
  24. package/dist/cjs/session/context.js.map +2 -2
  25. package/dist/cjs/str/floatingdecimal.d.ts +3 -0
  26. package/dist/cjs/str/floatingdecimal.d.ts.map +1 -1
  27. package/dist/cjs/str/floatingdecimal.js +25 -12
  28. package/dist/cjs/str/floatingdecimal.js.map +2 -2
  29. package/dist/cjs/str/messageformat.d.ts.map +1 -1
  30. package/dist/cjs/str/messageformat.js +27 -8
  31. package/dist/cjs/str/messageformat.js.map +2 -2
  32. package/dist/cjs/str/numberformat.d.ts.map +1 -1
  33. package/dist/cjs/str/numberformat.js +9 -16
  34. package/dist/cjs/str/numberformat.js.map +3 -3
  35. package/dist/cjs/ta/index.d.ts.map +1 -1
  36. package/dist/cjs/ta/index.js +27 -0
  37. package/dist/cjs/ta/index.js.map +2 -2
  38. package/dist/cjs/ta/running-sum.d.ts +8 -1
  39. package/dist/cjs/ta/running-sum.d.ts.map +1 -1
  40. package/dist/cjs/ta/running-sum.js +13 -1
  41. package/dist/cjs/ta/running-sum.js.map +2 -2
  42. package/dist/cjs/time/timezone.d.ts +13 -1
  43. package/dist/cjs/time/timezone.d.ts.map +1 -1
  44. package/dist/cjs/time/timezone.js +64 -12
  45. package/dist/cjs/time/timezone.js.map +2 -2
  46. package/dist/esm/callsite/index.d.ts.map +1 -1
  47. package/dist/esm/callsite/index.js +76 -7
  48. package/dist/esm/callsite/index.js.map +1 -1
  49. package/dist/esm/drawing/registry.d.ts +31 -3
  50. package/dist/esm/drawing/registry.d.ts.map +1 -1
  51. package/dist/esm/drawing/registry.js +237 -80
  52. package/dist/esm/drawing/registry.js.map +1 -1
  53. package/dist/esm/index.d.ts +1 -1
  54. package/dist/esm/index.js +1 -1
  55. package/dist/esm/linefill/index.d.ts.map +1 -1
  56. package/dist/esm/linefill/index.js +17 -7
  57. package/dist/esm/linefill/index.js.map +1 -1
  58. package/dist/esm/session/bars.d.ts +3 -0
  59. package/dist/esm/session/bars.d.ts.map +1 -1
  60. package/dist/esm/session/bars.js +11 -3
  61. package/dist/esm/session/bars.js.map +1 -1
  62. package/dist/esm/session/calendar.d.ts +19 -6
  63. package/dist/esm/session/calendar.d.ts.map +1 -1
  64. package/dist/esm/session/calendar.js +74 -21
  65. package/dist/esm/session/calendar.js.map +1 -1
  66. package/dist/esm/session/context.d.ts.map +1 -1
  67. package/dist/esm/session/context.js +34 -9
  68. package/dist/esm/session/context.js.map +1 -1
  69. package/dist/esm/str/floatingdecimal.d.ts +3 -0
  70. package/dist/esm/str/floatingdecimal.d.ts.map +1 -1
  71. package/dist/esm/str/floatingdecimal.js +27 -11
  72. package/dist/esm/str/floatingdecimal.js.map +1 -1
  73. package/dist/esm/str/messageformat.d.ts.map +1 -1
  74. package/dist/esm/str/messageformat.js +35 -9
  75. package/dist/esm/str/messageformat.js.map +1 -1
  76. package/dist/esm/str/numberformat.d.ts.map +1 -1
  77. package/dist/esm/str/numberformat.js +12 -18
  78. package/dist/esm/str/numberformat.js.map +1 -1
  79. package/dist/esm/ta/index.d.ts.map +1 -1
  80. package/dist/esm/ta/index.js +35 -0
  81. package/dist/esm/ta/index.js.map +1 -1
  82. package/dist/esm/ta/running-sum.d.ts +8 -1
  83. package/dist/esm/ta/running-sum.d.ts.map +1 -1
  84. package/dist/esm/ta/running-sum.js +16 -1
  85. package/dist/esm/ta/running-sum.js.map +1 -1
  86. package/dist/esm/time/timezone.d.ts +13 -1
  87. package/dist/esm/time/timezone.d.ts.map +1 -1
  88. package/dist/esm/time/timezone.js +97 -16
  89. package/dist/esm/time/timezone.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/callsite/index.ts +65 -7
  92. package/src/drawing/registry.ts +249 -79
  93. package/src/index.ts +1 -1
  94. package/src/linefill/index.ts +16 -7
  95. package/src/session/bars.ts +11 -3
  96. package/src/session/calendar.ts +84 -21
  97. package/src/session/context.ts +36 -9
  98. package/src/str/floatingdecimal.ts +27 -11
  99. package/src/str/messageformat.ts +40 -9
  100. package/src/str/numberformat.ts +13 -17
  101. package/src/ta/index.ts +41 -0
  102. package/src/ta/running-sum.ts +13 -1
  103. package/src/time/timezone.ts +99 -16
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/linefill/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC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,KAAK,GAAG,QAAQ,CAIlE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAElD;AAGD;;GAEG;AACH,wBAAgB,GAAG,IAAI,QAAQ,EAAE,CAEhC;AAGD,OAAO,EAAE,YAAY,IAAI,GAAG,EAAE,CAAC;AAC/B,OAAO,EAAE,eAAe,IAAI,MAAM,EAAE,CAAC"}
@@ -32,13 +32,13 @@ var import_registry = require("../drawing/registry.js");
32
32
  function new_linefill(line1, line2, fillColor) {
33
33
  if (line1 === null || line1 === void 0 || line2 === null || line2 === void 0) return null;
34
34
  let found;
35
- for (const fill2 of (0, import_registry.all)("linefill")) {
35
+ for (const fill2 of (0, import_registry.liveFillsOf)(line1)) {
36
36
  const has = (l) => fill2.line1 === l || fill2.line2 === l;
37
- if (has(line1) && has(line2) && (!found || (touched.get(fill2) ?? 0) > (touched.get(found) ?? 0))) found = fill2;
37
+ if (has(line2) && (!found || Touched.get(fill2) > Touched.get(found))) found = fill2;
38
38
  }
39
39
  if (found) {
40
40
  found.color = fillColor;
41
- touched.set(found, ++touchCount);
41
+ Touched.set(found, ++touchCount);
42
42
  return found;
43
43
  }
44
44
  const fill = (0, import_registry.register)("linefill", {
@@ -46,10 +46,19 @@ function new_linefill(line1, line2, fillColor) {
46
46
  line2,
47
47
  color: fillColor
48
48
  });
49
- touched.set(fill, ++touchCount);
49
+ Touched.set(fill, ++touchCount);
50
50
  return fill;
51
51
  }
52
- const touched = /* @__PURE__ */ new WeakMap();
52
+ class Touched extends import_registry.Stamped {
53
+ #touch = 0;
54
+ static get(fill) {
55
+ return #touch in fill ? fill.#touch : 0;
56
+ }
57
+ static set(fill, order) {
58
+ if (!(#touch in fill)) new Touched(fill);
59
+ fill.#touch = order;
60
+ }
61
+ }
53
62
  let touchCount = 0;
54
63
  function get_line1(id) {
55
64
  return id.line1;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/linefill/index.ts"],
4
- "sourcesContent": ["/**\n * Linefill namespace\n * Functions for creating and manipulating linefill drawing objects.\n *\n * @remarks\n * Linefill objects fill the area between two lines with a color.\n * They have minimal computational value but automatically follow line movements\n * and provide a way to retrieve the underlying line references.\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { Linefill, Line, color } from '../types/index.js';\n\n/**\n * Creates a new linefill object that fills the area between two lines.\n *\n * @param line1 - First line object\n * @param line2 - Second line object\n * @param fillColor - Fill color (optional)\n * @returns New linefill object\n *\n * @remarks\n * - Automatically follows line movements (if lines are updated, fill updates too)\n * - Automatically deleted if either line is deleted\n * - One linefill per pair of lines, as in PineScript (#174): when both lines already belong to a live linefill\n * (`linefill.new(b, a)` after `linefill.new(a, b)`, or `linefill.new(a, a)` after either), that linefill is\n * returned with the new colour instead of a new one; with several, the one created or returned last\n * - If both lines extend in same direction, fill extends too\n * - Purely visual in PineScript, but getters allow retrieving line references\n *\n * @example\n * ```typescript\n * import { line, linefill } from 'oakscriptjs';\n *\n * // Create channel lines\n * const upperLine = line.new(0, 160, 50, 170, 'bar_index', 'right');\n * const lowerLine = line.new(0, 140, 50, 150, 'bar_index', 'right');\n *\n * // Fill channel with color\n * const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20'); // Transparent blue\n * ```\n */\nexport function new_linefill(line1: Line, line2: Line, fillColor?: color): Linefill {\n // PineScript: an na line gives an na linefill\n if (line1 === null || line1 === undefined || line2 === null || line2 === undefined) return null as unknown as Linefill;\n let found: Linefill | undefined;\n for (const fill of allDrawings('linefill')) {\n const has = (l: Line): boolean => fill.line1 === l || fill.line2 === l;\n if (has(line1) && has(line2) && (!found || (touched.get(fill) ?? 0) > (touched.get(found) ?? 0))) found = fill;\n }\n if (found) {\n found.color = fillColor;\n touched.set(found, ++touchCount);\n return found;\n }\n const fill = register('linefill', {\n line1,\n line2,\n color: fillColor\n });\n touched.set(fill, ++touchCount);\n return fill;\n}\n\n/** Order in which the linefills were created or returned by `linefill.new` (the last one wins a lookup). */\nconst touched = new WeakMap<Linefill, number>();\nlet touchCount = 0;\n\n/**\n * Returns the first line reference.\n *\n * @param id - Linefill object\n * @returns First line object\n *\n * @remarks\n * Can be used to retrieve and manipulate the first line.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n *\n * // Later, retrieve and update the first line\n * const line1 = linefill.get_line1(channelFill);\n * line.set_y2(line1, 175); // Update upper line's second point\n * ```\n */\nexport function get_line1(id: Linefill): Line {\n return id.line1;\n}\n\n/**\n * Returns the second line reference.\n *\n * @param id - Linefill object\n * @returns Second line object\n *\n * @remarks\n * Can be used to retrieve and manipulate the second line.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n *\n * // Later, retrieve and update the second line\n * const line2 = linefill.get_line2(channelFill);\n * line.set_y2(line2, 145); // Update lower line's second point\n * ```\n */\nexport function get_line2(id: Linefill): Line {\n return id.line2;\n}\n\n/**\n * Sets the fill color.\n *\n * @param id - Linefill object to modify\n * @param fillColor - New fill color\n * @returns Modified linefill object\n *\n * @remarks\n * Useful for dynamically changing channel colors based on conditions.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20');\n *\n * // Change color based on trend\n * if (bullish) {\n * linefill.set_color(channelFill, '#00FF0020'); // Green\n * } else {\n * linefill.set_color(channelFill, '#FF000020'); // Red\n * }\n * ```\n */\nexport function set_color(id: Linefill, fillColor: color): Linefill {\n if (isDeleted(id)) return id;\n id.color = fillColor;\n return id;\n}\n\n/**\n * Deletes the linefill object.\n *\n * @param id - Linefill object to delete\n *\n * @remarks\n * Removes the linefill from `linefill.all()`. As in PineScript, the deleted linefill is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n * linefill.delete(channelFill);\n * // linefill.all() no longer contains it\n * ```\n */\nexport function delete_linefill(id: Linefill): void {\n remove('linefill', id);\n}\n\n\n/**\n * All live linefills, in creation order (PineScript `linefill.all`). A new array.\n */\nexport function all(): Linefill[] {\n return allDrawings('linefill');\n}\n\n// Alias to match PineScript API\nexport { new_linefill as new };\nexport { delete_linefill as delete };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAgE;AAgCzD,SAAS,aAAa,OAAa,OAAa,WAA6B;AAElF,MAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,QAAQ,UAAU,OAAW,QAAO;AAC3F,MAAI;AACJ,aAAWA,aAAQ,gBAAAC,KAAY,UAAU,GAAG;AAC1C,UAAM,MAAM,CAAC,MAAqBD,MAAK,UAAU,KAAKA,MAAK,UAAU;AACrE,QAAI,IAAI,KAAK,KAAK,IAAI,KAAK,MAAM,CAAC,UAAU,QAAQ,IAAIA,KAAI,KAAK,MAAM,QAAQ,IAAI,KAAK,KAAK,IAAK,SAAQA;AAAA,EAC5G;AACA,MAAI,OAAO;AACT,UAAM,QAAQ;AACd,YAAQ,IAAI,OAAO,EAAE,UAAU;AAC/B,WAAO;AAAA,EACT;AACA,QAAM,WAAO,0BAAS,YAAY;AAAA,IAChC;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AACD,UAAQ,IAAI,MAAM,EAAE,UAAU;AAC9B,SAAO;AACT;AAGA,MAAM,UAAU,oBAAI,QAA0B;AAC9C,IAAI,aAAa;AAoBV,SAAS,UAAU,IAAoB;AAC5C,SAAO,GAAG;AACZ;AAoBO,SAAS,UAAU,IAAoB;AAC5C,SAAO,GAAG;AACZ;AAwBO,SAAS,UAAU,IAAc,WAA4B;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,QAAQ;AACX,SAAO;AACT;AAkBO,SAAS,gBAAgB,IAAoB;AAClD,8BAAO,YAAY,EAAE;AACvB;AAMO,SAAS,MAAkB;AAChC,aAAO,gBAAAC,KAAY,UAAU;AAC/B;",
4
+ "sourcesContent": ["/**\n * Linefill namespace\n * Functions for creating and manipulating linefill drawing objects.\n *\n * @remarks\n * Linefill objects fill the area between two lines with a color.\n * They have minimal computational value but automatically follow line movements\n * and provide a way to retrieve the underlying line references.\n *\n * @version 6\n */\n\nimport { Stamped, all as allDrawings, isDeleted, liveFillsOf, register, remove } from '../drawing/registry.js';\nimport type { Linefill, Line, color } from '../types/index.js';\n\n/**\n * Creates a new linefill object that fills the area between two lines.\n *\n * @param line1 - First line object\n * @param line2 - Second line object\n * @param fillColor - Fill color (optional)\n * @returns New linefill object\n *\n * @remarks\n * - Automatically follows line movements (if lines are updated, fill updates too)\n * - Automatically deleted if either line is deleted\n * - One linefill per pair of lines, as in PineScript (#174): when both lines already belong to a live linefill\n * (`linefill.new(b, a)` after `linefill.new(a, b)`, or `linefill.new(a, a)` after either), that linefill is\n * returned with the new colour instead of a new one; with several, the one created or returned last\n * - If both lines extend in same direction, fill extends too\n * - Purely visual in PineScript, but getters allow retrieving line references\n *\n * @example\n * ```typescript\n * import { line, linefill } from 'oakscriptjs';\n *\n * // Create channel lines\n * const upperLine = line.new(0, 160, 50, 170, 'bar_index', 'right');\n * const lowerLine = line.new(0, 140, 50, 150, 'bar_index', 'right');\n *\n * // Fill channel with color\n * const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20'); // Transparent blue\n * ```\n */\nexport function new_linefill(line1: Line, line2: Line, fillColor?: color): Linefill {\n // PineScript: an na line gives an na linefill\n if (line1 === null || line1 === undefined || line2 === null || line2 === undefined) return null as unknown as Linefill;\n let found: Linefill | undefined;\n for (const fill of liveFillsOf(line1)) {\n const has = (l: Line): boolean => fill.line1 === l || fill.line2 === l;\n if (has(line2) && (!found || Touched.get(fill) > Touched.get(found))) found = fill;\n }\n if (found) {\n found.color = fillColor;\n Touched.set(found, ++touchCount);\n return found;\n }\n const fill = register('linefill', {\n line1,\n line2,\n color: fillColor\n });\n Touched.set(fill, ++touchCount);\n return fill;\n}\n\n/** Order in which the linefills were created or returned by `linefill.new` (the last one wins a lookup); 0 before. */\nclass Touched extends Stamped {\n #touch = 0;\n static get(fill: Linefill): number {\n return #touch in fill ? fill.#touch : 0;\n }\n static set(fill: Linefill, order: number): void {\n if (!(#touch in fill)) new Touched(fill);\n (fill as unknown as Touched).#touch = order;\n }\n}\nlet touchCount = 0;\n\n/**\n * Returns the first line reference.\n *\n * @param id - Linefill object\n * @returns First line object\n *\n * @remarks\n * Can be used to retrieve and manipulate the first line.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n *\n * // Later, retrieve and update the first line\n * const line1 = linefill.get_line1(channelFill);\n * line.set_y2(line1, 175); // Update upper line's second point\n * ```\n */\nexport function get_line1(id: Linefill): Line {\n return id.line1;\n}\n\n/**\n * Returns the second line reference.\n *\n * @param id - Linefill object\n * @returns Second line object\n *\n * @remarks\n * Can be used to retrieve and manipulate the second line.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n *\n * // Later, retrieve and update the second line\n * const line2 = linefill.get_line2(channelFill);\n * line.set_y2(line2, 145); // Update lower line's second point\n * ```\n */\nexport function get_line2(id: Linefill): Line {\n return id.line2;\n}\n\n/**\n * Sets the fill color.\n *\n * @param id - Linefill object to modify\n * @param fillColor - New fill color\n * @returns Modified linefill object\n *\n * @remarks\n * Useful for dynamically changing channel colors based on conditions.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20');\n *\n * // Change color based on trend\n * if (bullish) {\n * linefill.set_color(channelFill, '#00FF0020'); // Green\n * } else {\n * linefill.set_color(channelFill, '#FF000020'); // Red\n * }\n * ```\n */\nexport function set_color(id: Linefill, fillColor: color): Linefill {\n if (isDeleted(id)) return id;\n id.color = fillColor;\n return id;\n}\n\n/**\n * Deletes the linefill object.\n *\n * @param id - Linefill object to delete\n *\n * @remarks\n * Removes the linefill from `linefill.all()`. As in PineScript, the deleted linefill is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n * linefill.delete(channelFill);\n * // linefill.all() no longer contains it\n * ```\n */\nexport function delete_linefill(id: Linefill): void {\n remove('linefill', id);\n}\n\n\n/**\n * All live linefills, in creation order (PineScript `linefill.all`). A new array.\n */\nexport function all(): Linefill[] {\n return allDrawings('linefill');\n}\n\n// Alias to match PineScript API\nexport { new_linefill as new };\nexport { delete_linefill as delete };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAsF;AAgC/E,SAAS,aAAa,OAAa,OAAa,WAA6B;AAElF,MAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,QAAQ,UAAU,OAAW,QAAO;AAC3F,MAAI;AACJ,aAAWA,aAAQ,6BAAY,KAAK,GAAG;AACrC,UAAM,MAAM,CAAC,MAAqBA,MAAK,UAAU,KAAKA,MAAK,UAAU;AACrE,QAAI,IAAI,KAAK,MAAM,CAAC,SAAS,QAAQ,IAAIA,KAAI,IAAI,QAAQ,IAAI,KAAK,GAAI,SAAQA;AAAA,EAChF;AACA,MAAI,OAAO;AACT,UAAM,QAAQ;AACd,YAAQ,IAAI,OAAO,EAAE,UAAU;AAC/B,WAAO;AAAA,EACT;AACA,QAAM,WAAO,0BAAS,YAAY;AAAA,IAChC;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AACD,UAAQ,IAAI,MAAM,EAAE,UAAU;AAC9B,SAAO;AACT;AAGA,MAAM,gBAAgB,wBAAQ;AAAA,EAC5B,SAAS;AAAA,EACT,OAAO,IAAI,MAAwB;AACjC,WAAO,UAAU,OAAO,KAAK,SAAS;AAAA,EACxC;AAAA,EACA,OAAO,IAAI,MAAgB,OAAqB;AAC9C,QAAI,EAAE,UAAU,MAAO,KAAI,QAAQ,IAAI;AACvC,IAAC,KAA4B,SAAS;AAAA,EACxC;AACF;AACA,IAAI,aAAa;AAoBV,SAAS,UAAU,IAAoB;AAC5C,SAAO,GAAG;AACZ;AAoBO,SAAS,UAAU,IAAoB;AAC5C,SAAO,GAAG;AACZ;AAwBO,SAAS,UAAU,IAAc,WAA4B;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,QAAQ;AACX,SAAO;AACT;AAkBO,SAAS,gBAAgB,IAAoB;AAClD,8BAAO,YAAY,EAAE;AACvB;AAMO,SAAS,MAAkB;AAChC,aAAO,gBAAAC,KAAY,UAAU;AAC/B;",
6
6
  "names": ["fill", "allDrawings"]
7
7
  }
@@ -26,6 +26,8 @@ export declare class SessionBars {
26
26
  readonly calendar: TradingCalendar;
27
27
  readonly chart: TimeframeInfo;
28
28
  private readonly yearDays;
29
+ /** Parsed timeframes: `timeOf` / `closeOf` run on every bar */
30
+ private readonly timeframes;
29
31
  constructor(calendar: TradingCalendar, chartTimeframe: string);
30
32
  /** Trading days of a calendar year, in order. */
31
33
  private tradingDaysOf;
@@ -34,6 +36,7 @@ export declare class SessionBars {
34
36
  * Periods restart each calendar year.
35
37
  */
36
38
  private periodRange;
39
+ private timeframe;
37
40
  private dayStart;
38
41
  private dayEnd;
39
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bars.d.ts","sourceRoot":"","sources":["../../../src/session/bars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EACL,eAAe,EAMf,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AAiBvB,+DAA+D;AAC/D,qBAAa,WAAW;IAMpB,QAAQ,CAAC,QAAQ,EAAE,eAAe;IALpC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC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,CA6CnG"}
@@ -42,6 +42,8 @@ class SessionBars {
42
42
  calendar;
43
43
  chart;
44
44
  yearDays = /* @__PURE__ */ new Map();
45
+ /** Parsed timeframes: `timeOf` / `closeOf` run on every bar */
46
+ timeframes = /* @__PURE__ */ new Map();
45
47
  /** Trading days of a calendar year, in order. */
46
48
  tradingDaysOf(year) {
47
49
  let days = this.yearDays.get(year);
@@ -83,6 +85,11 @@ class SessionBars {
83
85
  const lastMonth = Math.min(firstMonth + n - 1, 12);
84
86
  return [(0, import_calendar.monthStart)(year * 1e4 + firstMonth * 100 + 1), (0, import_calendar.monthEnd)(year * 1e4 + lastMonth * 100 + 1)];
85
87
  }
88
+ timeframe(timeframe) {
89
+ let tf = this.timeframes.get(timeframe);
90
+ if (!tf) this.timeframes.set(timeframe, tf = (0, import_timeframe.info)(timeframe));
91
+ return tf;
92
+ }
86
93
  dayStart(date) {
87
94
  return this.calendar.periods(date)[0][0];
88
95
  }
@@ -96,7 +103,7 @@ class SessionBars {
96
103
  * NaN on it (measured; `time("W")` keeps its value).
97
104
  */
98
105
  timeOf(time, timeframe) {
99
- const tf = (0, import_timeframe.info)(timeframe);
106
+ const tf = this.timeframe(timeframe);
100
107
  const at = this.calendar.locate(time);
101
108
  if (!at) return NaN;
102
109
  if (tf.isintraday) {
@@ -114,7 +121,7 @@ class SessionBars {
114
121
  }
115
122
  /** PineScript `time_close(tf)` for a bar that opens at `time`. */
116
123
  closeOf(time, timeframe) {
117
- const tf = (0, import_timeframe.info)(timeframe);
124
+ const tf = this.timeframe(timeframe);
118
125
  const at = this.calendar.locate(time);
119
126
  if (!at) return NaN;
120
127
  if (tf.isintraday) {
@@ -151,7 +158,7 @@ class SessionBars {
151
158
  * bar completes a higher-timeframe period (request.security).
152
159
  */
153
160
  periodEnd(time, timeframe) {
154
- const tf = (0, import_timeframe.info)(timeframe);
161
+ const tf = this.timeframe(timeframe);
155
162
  const at = this.calendar.locate(time);
156
163
  if (!at) return NaN;
157
164
  if (tf.isintraday) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/session/bars.ts"],
4
- "sourcesContent": ["/**\n * PineScript values that depend on the chart timeframe and the symbol session (issue #100):\n * `time(tf)`, `time_close(tf)`, `timeframe.change(tf)`, `time_tradingday`, `session.*`.\n * PineScript rules:\n *\n * - intraday periods are aligned on the start of the session period of the trading day: 240 minutes from\n * 09:30 gives 09:30, 13:30; `time(tf)` is the start of the period that contains the bar open\n * - \"D\" is the session start of the trading day; \"W\" / \"M\" the session start of the first trading day\n * of the week (Monday to Sunday) / month\n * - intraday closes are cut at the end of the session period; the \"D\" close is the session end\n * - on intraday charts the \"W\" / \"M\" (and \"nD\") close is the session start of the next period's first\n * trading day; on D / W / M charts it is the session end of the last trading day of the week / month\n * - on D / W / M charts, intraday timeframes give the chart bar's time, and the end of the session\n * period that contains the bar open as close\n * - `time_tradingday` is 00:00 UTC of the trading day (on W / M charts, of the last trading day)\n *\n * Multipliers above one day (issue #100 follow-up): periods restart each\n * calendar year. \"nD\" groups n trading days from the first trading day of the year; \"nW\" groups n weeks from\n * the first week whose Monday is in the year; \"nM\" groups n months from January. The last group of a year\n * can be shorter.\n */\n\nimport { info, in_seconds, type TimeframeInfo } from '../timeframe/index.js';\nimport {\n TradingCalendar,\n addDays,\n dateUtcMs,\n monthEnd,\n monthStart,\n weekStart,\n type DateNum,\n} from './calendar.js';\n\ntype Unit = 'D' | 'W' | 'M';\n\nfunction unitOf(tf: TimeframeInfo): { unit: Unit; n: number } {\n return { unit: tf.isdaily ? 'D' : tf.isweekly ? 'W' : 'M', n: tf.multiplier };\n}\n\nconst yearOf = (date: DateNum): number => Math.floor(date / 10000);\n\n/** Monday of the first week of `year` (the first Monday on or after 1 January). */\nconst firstMonday = (year: number): DateNum => {\n const jan1 = year * 10000 + 101;\n const monday = weekStart(jan1);\n return monday === jan1 ? jan1 : addDays(monday, 7);\n};\n\n/** Values of the bars of one chart, for a trading calendar. */\nexport class SessionBars {\n readonly chart: TimeframeInfo;\n\n private readonly yearDays = new Map<number, DateNum[]>();\n\n constructor(\n readonly calendar: TradingCalendar,\n chartTimeframe: string\n ) {\n this.chart = info(chartTimeframe);\n }\n\n /** Trading days of a calendar year, in order. */\n private tradingDaysOf(year: number): DateNum[] {\n let days = this.yearDays.get(year);\n if (!days) {\n days = [];\n for (let date = year * 10000 + 101; yearOf(date) === year; date = addDays(date, 1)) {\n if (this.calendar.isTradingDay(date)) days.push(date);\n }\n this.yearDays.set(year, days);\n }\n return days;\n }\n\n /**\n * Dates [from, to] of the `n`-`unit` period that contains `date` (for \"D\": its first and last trading days).\n * Periods restart each calendar year.\n */\n private periodRange(date: DateNum, unit: Unit, n: number): [DateNum, DateNum] {\n if (unit === 'D') {\n if (n === 1) return [date, date];\n const days = this.tradingDaysOf(yearOf(date));\n let k = days.findIndex((d) => d >= date);\n if (k === -1) return this.periodRange(yearOf(date) * 10000 + 10000 + 101, unit, n);\n k -= k % n;\n return [days[k]!, days[Math.min(k + n, days.length) - 1]!];\n }\n if (unit === 'W') {\n const monday = weekStart(date);\n const year = yearOf(monday);\n const first = firstMonday(year);\n const next = firstMonday(year + 1);\n const k = Math.round((dateUtcMs(monday) - dateUtcMs(first)) / (7 * 86_400_000));\n const from = addDays(first, (k - (k % n)) * 7);\n const to = addDays(from, n * 7 - 1);\n return [from, to < next ? to : addDays(next, -1)];\n }\n const year = yearOf(date);\n const month = Math.floor(date / 100) % 100;\n const firstMonth = month - ((month - 1) % n);\n const lastMonth = Math.min(firstMonth + n - 1, 12);\n return [monthStart(year * 10000 + firstMonth * 100 + 1), monthEnd(year * 10000 + lastMonth * 100 + 1)];\n }\n\n private dayStart(date: DateNum): number {\n return this.calendar.periods(date)[0]![0];\n }\n\n private dayEnd(date: DateNum): number {\n const p = this.calendar.periods(date);\n return p[p.length - 1]![1];\n }\n\n /**\n * PineScript `time(tf)` for a bar that opens at `time`; NaN when no trading day is found. An intraday bar that\n * opens after an early close has no day and no intraday period: `time(\"D\")`, `time(\"240\")` and `time(\"60\")` are\n * NaN on it (measured; `time(\"W\")` keeps its value).\n */\n timeOf(time: number, timeframe: string): number {\n const tf = info(timeframe);\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (tf.isintraday) {\n if (this.chart.isdwm) return time;\n // a bar after an early close has no intraday period either (#173)\n if (this.stray(time)) return NaN;\n const [start] = this.calendar.periods(at.date)[at.index]!;\n const ms = in_seconds(tf.period) * 1000;\n return start + Math.floor((time - start) / ms) * ms;\n }\n const { unit, n } = unitOf(tf);\n if (unit === 'D' && n === 1 && this.stray(time)) return NaN;\n const [from, to] = this.periodRange(at.date, unit, n);\n const first = this.calendar.firstTradingDay(from, to);\n return first === null ? NaN : this.dayStart(first);\n }\n\n /** PineScript `time_close(tf)` for a bar that opens at `time`. */\n closeOf(time: number, timeframe: string): number {\n const tf = info(timeframe);\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (tf.isintraday) {\n const [, end] = this.calendar.periods(at.date)[at.index]!;\n // on D / W / M charts: the end of the session period that contains the bar open\n if (this.chart.isdwm) return end;\n if (this.stray(time)) return NaN;\n return Math.min(this.timeOf(time, timeframe) + in_seconds(tf.period) * 1000, end);\n }\n const { unit, n } = unitOf(tf);\n if (unit === 'D' && n === 1 && this.stray(time)) return NaN;\n const [from, to] = this.periodRange(at.date, unit, n);\n // intraday charts: the start of the next period, except \"1D\" (the session end)\n if (this.chart.isintraday && (unit !== 'D' || n > 1)) {\n const [nextFrom, nextTo] = this.periodRange(addDays(to, 1), unit, n);\n const first = this.calendar.firstTradingDay(nextFrom, addDays(nextTo, 31));\n return first === null ? NaN : this.dayStart(first);\n }\n const last = this.calendar.lastTradingDay(from, to);\n return last === null ? NaN : this.dayEnd(last);\n }\n\n /** Trading day of a bar: on D / W / M charts the last trading day of the chart period. */\n tradingDay(time: number): DateNum | null {\n const at = this.calendar.locate(time);\n if (!at || this.stray(time)) return null;\n if (this.chart.isdwm) {\n const { unit, n } = unitOf(this.chart);\n const [from, to] = this.periodRange(at.date, unit, n);\n return this.calendar.lastTradingDay(from, to);\n }\n return at.date;\n }\n\n /**\n * End of the `timeframe` period that contains `time`: the intraday close, the session end of the day,\n * or the session end of the last trading day of the period. Used to know whether the last loaded\n * bar completes a higher-timeframe period (request.security).\n */\n periodEnd(time: number, timeframe: string): number {\n const tf = info(timeframe);\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (tf.isintraday) {\n const [, end] = this.calendar.periods(at.date)[at.index]!;\n return Math.min(this.timeOf(time, timeframe) + in_seconds(tf.period) * 1000, end);\n }\n const { unit, n } = unitOf(tf);\n const [from, to] = this.periodRange(at.date, unit, n);\n const last = this.calendar.lastTradingDay(from, to);\n return last === null ? NaN : this.dayEnd(last);\n }\n\n /** PineScript `time_tradingday`: 00:00 UTC of the trading day. */\n tradingDayTime(time: number): number {\n const day = this.tradingDay(time);\n return day === null ? NaN : dateUtcMs(day);\n }\n\n /**\n * Open time of the bar after the bar that opens at `time`, on the trading calendar: the next bar of the session\n * period, else the start of the next period or trading day; on D / W / M charts the session start of the first\n * trading day of the next chart period. NaN when none is found within 400 days.\n */\n nextBarTime(time: number): number {\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (!this.chart.isdwm) {\n const periods = this.calendar.periods(at.date);\n const [start, end] = periods[at.index]!;\n const ms = in_seconds(this.chart.period) * 1000;\n const next = start + (Math.floor((time - start) / ms) + 1) * ms;\n if (at.inside && next < end) return next;\n if (at.index + 1 < periods.length) return periods[at.index + 1]![0];\n const day = this.calendar.firstTradingDay(addDays(at.date, 1), addDays(at.date, 400));\n return day === null ? NaN : this.dayStart(day);\n }\n const { unit, n } = unitOf(this.chart);\n const [, to] = this.periodRange(at.date, unit, n);\n const day = this.calendar.firstTradingDay(addDays(to, 1), addDays(to, 400));\n return day === null ? NaN : this.dayStart(day);\n }\n\n /** An intraday bar that opens after an early close of its day (see TradingCalendar.afterEarlyClose). */\n stray(time: number): boolean {\n return !this.chart.isdwm && this.calendar.afterEarlyClose(time);\n }\n\n /** True when the bar at `time` is inside the session. */\n inside(time: number): boolean {\n return this.calendar.locate(time)?.inside ?? false;\n }\n\n /** Session start and end of the trading day of `time`, or null. */\n dayBounds(time: number): { date: DateNum; start: number; end: number } | null {\n const at = this.calendar.locate(time);\n return at ? { date: at.date, start: this.dayStart(at.date), end: this.dayEnd(at.date) } : null;\n }\n}\n\n/**\n * Periods of the chart bars that open after an early close, for `request.security` (#173): such a bar has no period\n * (`time(\"D\")` and `time(\"240\")` are na on it), but PineScript resamples it into the D / W / M bar of the bar before\n * it, and into an intraday bar of its own (opening at the bar's time). The bar before it still completes its period\n * (its day period is cut there). `intradayMs` is the duration of an intraday timeframe, null for D / W / M.\n * Changes `starts` and `dayPeriods` in place.\n */\nexport function strayPeriods(starts: number[], dayPeriods: number[], times: number[], bars: SessionBars, intradayMs: number | null): void {\n for (let i = 1; i < starts.length; i++) {\n if (!bars.stray(times[i]!)) continue;\n if (Number.isNaN(starts[i]!)) {\n // intraday: periods of `intradayMs` from the first such bar (\"240\": 18:30 and 20:30 are one bar)\n const run = Number.isNaN(dayPeriods[i - 1]!) && times[i]! < starts[i - 1]! + (intradayMs ?? 0);\n starts[i] = intradayMs === null || run ? starts[i - 1]! : times[i]!;\n }\n dayPeriods[i] = NaN;\n }\n}\n\n/** PineScript `session.*` flags of each bar. */\nexport interface SessionFlags {\n isfirstbar: boolean[];\n islastbar: boolean[];\n ismarket: boolean[];\n ispremarket: boolean[];\n ispostmarket: boolean[];\n isfirstbar_regular: boolean[];\n islastbar_regular: boolean[];\n}\n\n/**\n * `session.*` flags for bars that open at `times` (in order). `regular` gives the regular trading\n * hours when the bars include extended hours. PineScript rules: flags use the bar open\n * time; first and last bars are per session period (a trading day can have two periods, e.g. after a\n * futures holiday); pre / post market compare with the regular hours of the same trading day; on\n * D / W / M charts every bar is its own session (first, last, market, first and last regular).\n * The first loaded bar is a first bar only when no earlier bar of its period can exist (it opens less than one chart\n * period after the period start). A bar that opens after an early close is in the market hours (the usual hours of\n * its day) but is no last bar.\n */\nexport function sessionFlags(times: number[], bars: SessionBars, regular: SessionBars): SessionFlags {\n const n = times.length;\n const flag = () => new Array<boolean>(n).fill(false);\n const out: SessionFlags = {\n isfirstbar: flag(), islastbar: flag(), ismarket: flag(), ispremarket: flag(), ispostmarket: flag(),\n isfirstbar_regular: flag(), islastbar_regular: flag(),\n };\n const chart = bars.chart;\n let previousPeriod = '';\n let previousRegular = '';\n for (let i = 0; i < n; i++) {\n const t = times[i]!;\n if (chart.isdwm) {\n for (const k of ['isfirstbar', 'islastbar', 'ismarket', 'isfirstbar_regular', 'islastbar_regular'] as const) out[k][i] = true;\n continue;\n }\n const at = bars.calendar.locate(t);\n if (!at) {\n previousPeriod = previousRegular = '';\n continue;\n }\n const close = bars.closeOf(t, chart.period);\n const [, end] = bars.calendar.periods(at.date)[at.index]!;\n const period = `${at.date}/${at.index}`;\n const [start] = bars.calendar.periods(at.date)[at.index]!;\n const barMs = in_seconds(chart.period) * 1000;\n // the first loaded bar: a first bar only when no earlier bar of the period can exist\n out.isfirstbar[i] = i === 0 ? t - start < barMs : period !== previousPeriod;\n const stray = bars.stray(t);\n out.islastbar[i] = !stray && close >= end;\n const regularPeriods = regular.calendar.periods(at.date);\n const r = regularPeriods.findIndex(([s, e]) => s <= t && t < e);\n const market = r !== -1;\n out.ismarket[i] = market || regular.stray(t);\n if (!market && regularPeriods.length) {\n out.ispremarket[i] = t < regularPeriods[0]![0];\n out.ispostmarket[i] = t >= regularPeriods[regularPeriods.length - 1]![1];\n }\n const regularPeriod = market ? `${at.date}/${r}` : '';\n out.isfirstbar_regular[i] = market && (i === 0 ? t - regularPeriods[r]![0] < barMs : regularPeriod !== previousRegular);\n out.islastbar_regular[i] = market && close >= regularPeriods[r]![1];\n previousPeriod = period;\n previousRegular = regularPeriod;\n }\n return out;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,uBAA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B,CAAC,IAAI,WAAW,MAAM,IAAI,IAAI,eAAe,CAAC,EAAG,CAAC,IAAI,QAAQ,kBAAkB;AACvG,QAAI,kBAAkB,CAAC,IAAI,UAAU,SAAS,eAAe,CAAC,EAAG,CAAC;AAClE,qBAAiB;AACjB,sBAAkB;AAAA,EACpB;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["/**\n * PineScript values that depend on the chart timeframe and the symbol session (issue #100):\n * `time(tf)`, `time_close(tf)`, `timeframe.change(tf)`, `time_tradingday`, `session.*`.\n * PineScript rules:\n *\n * - intraday periods are aligned on the start of the session period of the trading day: 240 minutes from\n * 09:30 gives 09:30, 13:30; `time(tf)` is the start of the period that contains the bar open\n * - \"D\" is the session start of the trading day; \"W\" / \"M\" the session start of the first trading day\n * of the week (Monday to Sunday) / month\n * - intraday closes are cut at the end of the session period; the \"D\" close is the session end\n * - on intraday charts the \"W\" / \"M\" (and \"nD\") close is the session start of the next period's first\n * trading day; on D / W / M charts it is the session end of the last trading day of the week / month\n * - on D / W / M charts, intraday timeframes give the chart bar's time, and the end of the session\n * period that contains the bar open as close\n * - `time_tradingday` is 00:00 UTC of the trading day (on W / M charts, of the last trading day)\n *\n * Multipliers above one day (issue #100 follow-up): periods restart each\n * calendar year. \"nD\" groups n trading days from the first trading day of the year; \"nW\" groups n weeks from\n * the first week whose Monday is in the year; \"nM\" groups n months from January. The last group of a year\n * can be shorter.\n */\n\nimport { info, in_seconds, type TimeframeInfo } from '../timeframe/index.js';\nimport {\n TradingCalendar,\n addDays,\n dateUtcMs,\n monthEnd,\n monthStart,\n weekStart,\n type DateNum,\n} from './calendar.js';\n\ntype Unit = 'D' | 'W' | 'M';\n\nfunction unitOf(tf: TimeframeInfo): { unit: Unit; n: number } {\n return { unit: tf.isdaily ? 'D' : tf.isweekly ? 'W' : 'M', n: tf.multiplier };\n}\n\nconst yearOf = (date: DateNum): number => Math.floor(date / 10000);\n\n/** Monday of the first week of `year` (the first Monday on or after 1 January). */\nconst firstMonday = (year: number): DateNum => {\n const jan1 = year * 10000 + 101;\n const monday = weekStart(jan1);\n return monday === jan1 ? jan1 : addDays(monday, 7);\n};\n\n/** Values of the bars of one chart, for a trading calendar. */\nexport class SessionBars {\n readonly chart: TimeframeInfo;\n\n private readonly yearDays = new Map<number, DateNum[]>();\n /** Parsed timeframes: `timeOf` / `closeOf` run on every bar */\n private readonly timeframes = new Map<string, TimeframeInfo>();\n\n constructor(\n readonly calendar: TradingCalendar,\n chartTimeframe: string\n ) {\n this.chart = info(chartTimeframe);\n }\n\n /** Trading days of a calendar year, in order. */\n private tradingDaysOf(year: number): DateNum[] {\n let days = this.yearDays.get(year);\n if (!days) {\n days = [];\n for (let date = year * 10000 + 101; yearOf(date) === year; date = addDays(date, 1)) {\n if (this.calendar.isTradingDay(date)) days.push(date);\n }\n this.yearDays.set(year, days);\n }\n return days;\n }\n\n /**\n * Dates [from, to] of the `n`-`unit` period that contains `date` (for \"D\": its first and last trading days).\n * Periods restart each calendar year.\n */\n private periodRange(date: DateNum, unit: Unit, n: number): [DateNum, DateNum] {\n if (unit === 'D') {\n if (n === 1) return [date, date];\n const days = this.tradingDaysOf(yearOf(date));\n let k = days.findIndex((d) => d >= date);\n if (k === -1) return this.periodRange(yearOf(date) * 10000 + 10000 + 101, unit, n);\n k -= k % n;\n return [days[k]!, days[Math.min(k + n, days.length) - 1]!];\n }\n if (unit === 'W') {\n const monday = weekStart(date);\n const year = yearOf(monday);\n const first = firstMonday(year);\n const next = firstMonday(year + 1);\n const k = Math.round((dateUtcMs(monday) - dateUtcMs(first)) / (7 * 86_400_000));\n const from = addDays(first, (k - (k % n)) * 7);\n const to = addDays(from, n * 7 - 1);\n return [from, to < next ? to : addDays(next, -1)];\n }\n const year = yearOf(date);\n const month = Math.floor(date / 100) % 100;\n const firstMonth = month - ((month - 1) % n);\n const lastMonth = Math.min(firstMonth + n - 1, 12);\n return [monthStart(year * 10000 + firstMonth * 100 + 1), monthEnd(year * 10000 + lastMonth * 100 + 1)];\n }\n\n private timeframe(timeframe: string): TimeframeInfo {\n let tf = this.timeframes.get(timeframe);\n if (!tf) this.timeframes.set(timeframe, (tf = info(timeframe)));\n return tf;\n }\n\n private dayStart(date: DateNum): number {\n return this.calendar.periods(date)[0]![0];\n }\n\n private dayEnd(date: DateNum): number {\n const p = this.calendar.periods(date);\n return p[p.length - 1]![1];\n }\n\n /**\n * PineScript `time(tf)` for a bar that opens at `time`; NaN when no trading day is found. An intraday bar that\n * opens after an early close has no day and no intraday period: `time(\"D\")`, `time(\"240\")` and `time(\"60\")` are\n * NaN on it (measured; `time(\"W\")` keeps its value).\n */\n timeOf(time: number, timeframe: string): number {\n const tf = this.timeframe(timeframe);\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (tf.isintraday) {\n if (this.chart.isdwm) return time;\n // a bar after an early close has no intraday period either (#173)\n if (this.stray(time)) return NaN;\n const [start] = this.calendar.periods(at.date)[at.index]!;\n const ms = in_seconds(tf.period) * 1000;\n return start + Math.floor((time - start) / ms) * ms;\n }\n const { unit, n } = unitOf(tf);\n if (unit === 'D' && n === 1 && this.stray(time)) return NaN;\n const [from, to] = this.periodRange(at.date, unit, n);\n const first = this.calendar.firstTradingDay(from, to);\n return first === null ? NaN : this.dayStart(first);\n }\n\n /** PineScript `time_close(tf)` for a bar that opens at `time`. */\n closeOf(time: number, timeframe: string): number {\n const tf = this.timeframe(timeframe);\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (tf.isintraday) {\n const [, end] = this.calendar.periods(at.date)[at.index]!;\n // on D / W / M charts: the end of the session period that contains the bar open\n if (this.chart.isdwm) return end;\n if (this.stray(time)) return NaN;\n return Math.min(this.timeOf(time, timeframe) + in_seconds(tf.period) * 1000, end);\n }\n const { unit, n } = unitOf(tf);\n if (unit === 'D' && n === 1 && this.stray(time)) return NaN;\n const [from, to] = this.periodRange(at.date, unit, n);\n // intraday charts: the start of the next period, except \"1D\" (the session end)\n if (this.chart.isintraday && (unit !== 'D' || n > 1)) {\n const [nextFrom, nextTo] = this.periodRange(addDays(to, 1), unit, n);\n const first = this.calendar.firstTradingDay(nextFrom, addDays(nextTo, 31));\n return first === null ? NaN : this.dayStart(first);\n }\n const last = this.calendar.lastTradingDay(from, to);\n return last === null ? NaN : this.dayEnd(last);\n }\n\n /** Trading day of a bar: on D / W / M charts the last trading day of the chart period. */\n tradingDay(time: number): DateNum | null {\n const at = this.calendar.locate(time);\n if (!at || this.stray(time)) return null;\n if (this.chart.isdwm) {\n const { unit, n } = unitOf(this.chart);\n const [from, to] = this.periodRange(at.date, unit, n);\n return this.calendar.lastTradingDay(from, to);\n }\n return at.date;\n }\n\n /**\n * End of the `timeframe` period that contains `time`: the intraday close, the session end of the day,\n * or the session end of the last trading day of the period. Used to know whether the last loaded\n * bar completes a higher-timeframe period (request.security).\n */\n periodEnd(time: number, timeframe: string): number {\n const tf = this.timeframe(timeframe);\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (tf.isintraday) {\n const [, end] = this.calendar.periods(at.date)[at.index]!;\n return Math.min(this.timeOf(time, timeframe) + in_seconds(tf.period) * 1000, end);\n }\n const { unit, n } = unitOf(tf);\n const [from, to] = this.periodRange(at.date, unit, n);\n const last = this.calendar.lastTradingDay(from, to);\n return last === null ? NaN : this.dayEnd(last);\n }\n\n /** PineScript `time_tradingday`: 00:00 UTC of the trading day. */\n tradingDayTime(time: number): number {\n const day = this.tradingDay(time);\n return day === null ? NaN : dateUtcMs(day);\n }\n\n /**\n * Open time of the bar after the bar that opens at `time`, on the trading calendar: the next bar of the session\n * period, else the start of the next period or trading day; on D / W / M charts the session start of the first\n * trading day of the next chart period. NaN when none is found within 400 days.\n */\n nextBarTime(time: number): number {\n const at = this.calendar.locate(time);\n if (!at) return NaN;\n if (!this.chart.isdwm) {\n const periods = this.calendar.periods(at.date);\n const [start, end] = periods[at.index]!;\n const ms = in_seconds(this.chart.period) * 1000;\n const next = start + (Math.floor((time - start) / ms) + 1) * ms;\n if (at.inside && next < end) return next;\n if (at.index + 1 < periods.length) return periods[at.index + 1]![0];\n const day = this.calendar.firstTradingDay(addDays(at.date, 1), addDays(at.date, 400));\n return day === null ? NaN : this.dayStart(day);\n }\n const { unit, n } = unitOf(this.chart);\n const [, to] = this.periodRange(at.date, unit, n);\n const day = this.calendar.firstTradingDay(addDays(to, 1), addDays(to, 400));\n return day === null ? NaN : this.dayStart(day);\n }\n\n /** An intraday bar that opens after an early close of its day (see TradingCalendar.afterEarlyClose). */\n stray(time: number): boolean {\n return !this.chart.isdwm && this.calendar.afterEarlyClose(time);\n }\n\n /** True when the bar at `time` is inside the session. */\n inside(time: number): boolean {\n return this.calendar.locate(time)?.inside ?? false;\n }\n\n /** Session start and end of the trading day of `time`, or null. */\n dayBounds(time: number): { date: DateNum; start: number; end: number } | null {\n const at = this.calendar.locate(time);\n return at ? { date: at.date, start: this.dayStart(at.date), end: this.dayEnd(at.date) } : null;\n }\n}\n\n/**\n * Periods of the chart bars that open after an early close, for `request.security` (#173): such a bar has no period\n * (`time(\"D\")` and `time(\"240\")` are na on it), but PineScript resamples it into the D / W / M bar of the bar before\n * it, and into an intraday bar of its own (opening at the bar's time). The bar before it still completes its period\n * (its day period is cut there). `intradayMs` is the duration of an intraday timeframe, null for D / W / M.\n * Changes `starts` and `dayPeriods` in place.\n */\nexport function strayPeriods(starts: number[], dayPeriods: number[], times: number[], bars: SessionBars, intradayMs: number | null): void {\n for (let i = 1; i < starts.length; i++) {\n if (!bars.stray(times[i]!)) continue;\n if (Number.isNaN(starts[i]!)) {\n // intraday: periods of `intradayMs` from the first such bar (\"240\": 18:30 and 20:30 are one bar)\n const run = Number.isNaN(dayPeriods[i - 1]!) && times[i]! < starts[i - 1]! + (intradayMs ?? 0);\n starts[i] = intradayMs === null || run ? starts[i - 1]! : times[i]!;\n }\n dayPeriods[i] = NaN;\n }\n}\n\n/** PineScript `session.*` flags of each bar. */\nexport interface SessionFlags {\n isfirstbar: boolean[];\n islastbar: boolean[];\n ismarket: boolean[];\n ispremarket: boolean[];\n ispostmarket: boolean[];\n isfirstbar_regular: boolean[];\n islastbar_regular: boolean[];\n}\n\n/**\n * `session.*` flags for bars that open at `times` (in order). `regular` gives the regular trading\n * hours when the bars include extended hours. PineScript rules: flags use the bar open\n * time; first and last bars are per session period (a trading day can have two periods, e.g. after a\n * futures holiday); pre / post market compare with the regular hours of the same trading day; on\n * D / W / M charts every bar is its own session (first, last, market, first and last regular).\n * The first loaded bar is a first bar only when no earlier bar of its period can exist (it opens less than one chart\n * period after the period start). A bar that opens after an early close is in the market hours (the usual hours of\n * its day) but is no last bar.\n */\nexport function sessionFlags(times: number[], bars: SessionBars, regular: SessionBars): SessionFlags {\n const n = times.length;\n const flag = () => new Array<boolean>(n).fill(false);\n const out: SessionFlags = {\n isfirstbar: flag(), islastbar: flag(), ismarket: flag(), ispremarket: flag(), ispostmarket: flag(),\n isfirstbar_regular: flag(), islastbar_regular: flag(),\n };\n const chart = bars.chart;\n let previousPeriod = '';\n let previousRegular = '';\n for (let i = 0; i < n; i++) {\n const t = times[i]!;\n if (chart.isdwm) {\n for (const k of ['isfirstbar', 'islastbar', 'ismarket', 'isfirstbar_regular', 'islastbar_regular'] as const) out[k][i] = true;\n continue;\n }\n const at = bars.calendar.locate(t);\n if (!at) {\n previousPeriod = previousRegular = '';\n continue;\n }\n const close = bars.closeOf(t, chart.period);\n const [, end] = bars.calendar.periods(at.date)[at.index]!;\n const period = `${at.date}/${at.index}`;\n const [start] = bars.calendar.periods(at.date)[at.index]!;\n const barMs = in_seconds(chart.period) * 1000;\n // the first loaded bar: a first bar only when no earlier bar of the period can exist\n out.isfirstbar[i] = i === 0 ? t - start < barMs : period !== previousPeriod;\n const stray = bars.stray(t);\n out.islastbar[i] = !stray && close >= end;\n const regularPeriods = regular.calendar.periods(at.date);\n const r = regularPeriods.findIndex(([s, e]) => s <= t && t < e);\n const market = r !== -1;\n out.ismarket[i] = market || regular.stray(t);\n if (!market && regularPeriods.length) {\n out.ispremarket[i] = t < regularPeriods[0]![0];\n out.ispostmarket[i] = t >= regularPeriods[regularPeriods.length - 1]![1];\n }\n const regularPeriod = market ? `${at.date}/${r}` : '';\n out.isfirstbar_regular[i] = market && (i === 0 ? t - regularPeriods[r]![0] < barMs : regularPeriod !== previousRegular);\n out.islastbar_regular[i] = market && close >= regularPeriods[r]![1];\n previousPeriod = period;\n previousRegular = regularPeriod;\n }\n return out;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,uBAAqD;AACrD,sBAQO;AAIP,SAAS,OAAO,IAA8C;AAC5D,SAAO,EAAE,MAAM,GAAG,UAAU,MAAM,GAAG,WAAW,MAAM,KAAK,GAAG,GAAG,WAAW;AAC9E;AAEA,MAAM,SAAS,CAAC,SAA0B,KAAK,MAAM,OAAO,GAAK;AAGjE,MAAM,cAAc,CAAC,SAA0B;AAC7C,QAAM,OAAO,OAAO,MAAQ;AAC5B,QAAM,aAAS,2BAAU,IAAI;AAC7B,SAAO,WAAW,OAAO,WAAO,yBAAQ,QAAQ,CAAC;AACnD;AAGO,MAAM,YAAY;AAAA,EAOvB,YACW,UACT,gBACA;AAFS;AAGT,SAAK,YAAQ,uBAAK,cAAc;AAAA,EAClC;AAAA,EAJW;AAAA,EAPF;AAAA,EAEQ,WAAW,oBAAI,IAAuB;AAAA;AAAA,EAEtC,aAAa,oBAAI,IAA2B;AAAA;AAAA,EAUrD,cAAc,MAAyB;AAC7C,QAAI,OAAO,KAAK,SAAS,IAAI,IAAI;AACjC,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,eAAS,OAAO,OAAO,MAAQ,KAAK,OAAO,IAAI,MAAM,MAAM,WAAO,yBAAQ,MAAM,CAAC,GAAG;AAClF,YAAI,KAAK,SAAS,aAAa,IAAI,EAAG,MAAK,KAAK,IAAI;AAAA,MACtD;AACA,WAAK,SAAS,IAAI,MAAM,IAAI;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAAA;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AAQ,KAAK,MAAM,CAAC;AAC1B,QAAI,UAAU,CAAC,IAAI,CAAC,SAAS,SAAS;AACtC,UAAM,iBAAiB,QAAQ,SAAS,QAAQ,GAAG,IAAI;AACvD,UAAM,IAAI,eAAe,UAAU,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,CAAC;AAC9D,UAAM,SAAS,MAAM;AACrB,QAAI,SAAS,CAAC,IAAI,UAAU,QAAQ,MAAM,CAAC;AAC3C,QAAI,CAAC,UAAU,eAAe,QAAQ;AACpC,UAAI,YAAY,CAAC,IAAI,IAAI,eAAe,CAAC,EAAG,CAAC;AAC7C,UAAI,aAAa,CAAC,IAAI,KAAK,eAAe,eAAe,SAAS,CAAC,EAAG,CAAC;AAAA,IACzE;AACA,UAAM,gBAAgB,SAAS,GAAG,GAAG,IAAI,IAAI,CAAC,KAAK;AACnD,QAAI,mBAAmB,CAAC,IAAI,WAAW,MAAM,IAAI,IAAI,eAAe,CAAC,EAAG,CAAC,IAAI,QAAQ,kBAAkB;AACvG,QAAI,kBAAkB,CAAC,IAAI,UAAU,SAAS,eAAe,CAAC,EAAG,CAAC;AAClE,qBAAiB;AACjB,sBAAkB;AAAA,EACpB;AACA,SAAO;AACT;",
6
6
  "names": ["year", "day"]
7
7
  }
@@ -29,11 +29,18 @@ export interface SessionSpec {
29
29
  /** Date as YYYYMMDD. */
30
30
  export type DateNum = number;
31
31
  export declare const toDateNum: (y: number, m: number, d: number) => DateNum;
32
+ /** The date `n` (whole) days after `date`. */
32
33
  export declare const addDays: (date: DateNum, n: number) => DateNum;
33
- /** 1 = Sunday ... 7 = Saturday */
34
+ /** 1 = Sunday ... 7 = Saturday (01/01/1970 is a Thursday) */
34
35
  export declare const weekdayOf: (date: DateNum) => number;
35
36
  /** 00:00 UTC of the date, in ms (PineScript `time_tradingday`). */
36
37
  export declare const dateUtcMs: (date: DateNum) => number;
38
+ /** Trading day and period of a time (see `TradingCalendar.locate`). */
39
+ interface Located {
40
+ date: DateNum;
41
+ index: number;
42
+ inside: boolean;
43
+ }
37
44
  /** Session periods of every trading day of a symbol, as UNIX times (ms). */
38
45
  export declare class TradingCalendar {
39
46
  readonly timezone: string;
@@ -41,7 +48,12 @@ export declare class TradingCalendar {
41
48
  private readonly corrections;
42
49
  private readonly holidays;
43
50
  private readonly cache;
51
+ /** The date and periods of each day since 01/01/1970 that `search` looked at */
52
+ private readonly days;
44
53
  private readonly pine;
54
+ /** The last time located and its result: the functions of one bar locate the same time several times */
55
+ private lastTime;
56
+ private lastAt;
45
57
  /**
46
58
  * @param timezone - Time zone of the session hours (the exchange time zone)
47
59
  * @param spec - Session information (hours, corrections, holidays)
@@ -52,6 +64,8 @@ export declare class TradingCalendar {
52
64
  constructor(timezone: string, spec: SessionSpec, rule?: 'symbol' | 'pine', dayPlacement?: boolean);
53
65
  /** Session periods [start, end) of the trading day `date`; empty when the day has no session. */
54
66
  periods(date: DateNum): Array<[number, number]>;
67
+ /** The session version in force on `date` (the last one that starts on or before it). */
68
+ private versionOf;
55
69
  isTradingDay(date: DateNum): boolean;
56
70
  /**
57
71
  * True for a bar that opens after the session of its day was cut by a correction (an early close) but inside the
@@ -62,11 +76,9 @@ export declare class TradingCalendar {
62
76
  * Trading day and period of a time: the period that contains it, else the last period that started
63
77
  * before it. Null when no trading day is found near the time.
64
78
  */
65
- locate(time: number): {
66
- date: DateNum;
67
- index: number;
68
- inside: boolean;
69
- } | null;
79
+ locate(time: number): Located | null;
80
+ private search;
81
+ private dayAt;
70
82
  /** First trading day in [from, to] (dates), or null. */
71
83
  firstTradingDay(from: DateNum, to: DateNum): DateNum | null;
72
84
  /** Last trading day in [from, to] (dates), or null. */
@@ -78,4 +90,5 @@ export declare const weekStart: (date: DateNum) => DateNum;
78
90
  export declare const monthStart: (date: DateNum) => DateNum;
79
91
  /** Last day of the month of `date`. */
80
92
  export declare const monthEnd: (date: DateNum) => DateNum;
93
+ export {};
81
94
  //# sourceMappingURL=calendar.d.ts.map
@@ -1 +1 @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I;IASpC,OAAO,CAAC,MAAM;IAkBd,OAAO,CAAC,KAAK;IAUb,wDAAwD;IACxD,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;IAK3D,uDAAuD;IACvD,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;CAI3D;AAED,iEAAiE;AACjE,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,KAAG,OAAsD,CAAC;AACjG,wCAAwC;AACxC,eAAO,MAAM,UAAU,GAAI,MAAM,OAAO,KAAG,OAA2C,CAAC;AACvF,uCAAuC;AACvC,eAAO,MAAM,QAAQ,GAAI,MAAM,OAAO,KAAG,OAAiE,CAAC"}
@@ -32,12 +32,26 @@ var import_timezone = require("../time/timezone.js");
32
32
  var import_session = require("../time/session.js");
33
33
  const toDateNum = (y, m, d) => y * 1e4 + m * 100 + d;
34
34
  const utcOf = (date) => Date.UTC(Math.floor(date / 1e4), Math.floor(date / 100) % 100 - 1, date % 100);
35
- const fromUtc = (ms) => {
36
- const d = new Date(ms);
37
- return toDateNum(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
38
- };
39
- const addDays = (date, n) => fromUtc(utcOf(date) + n * 864e5);
40
- const weekdayOf = (date) => new Date(utcOf(date)).getUTCDay() + 1;
35
+ const MS_PER_DAY = 864e5;
36
+ const MAX_DAY = 1e8;
37
+ function dayOf(date) {
38
+ let y = Math.floor(date / 1e4);
39
+ const m = Math.floor(date / 100) % 100;
40
+ if (!(y >= 100 && m >= 1 && m <= 12)) return utcOf(date) / MS_PER_DAY;
41
+ if (m <= 2) y--;
42
+ const era = Math.floor(y / 400);
43
+ const yearOfEra = y - era * 400;
44
+ const dayOfYear = Math.floor((153 * (m > 2 ? m - 3 : m + 9) + 2) / 5) + date % 100 - 1;
45
+ const day = era * 146097 + yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear - 719468;
46
+ return Math.abs(day) <= MAX_DAY ? day : NaN;
47
+ }
48
+ function dateOf(day) {
49
+ if (!(Math.abs(day) <= MAX_DAY)) return NaN;
50
+ const { year, month, day: d } = (0, import_timezone.civilFromDays)(day);
51
+ return toDateNum(year, month, d);
52
+ }
53
+ const addDays = (date, n) => dateOf(dayOf(date) + n);
54
+ const weekdayOf = (date) => ((dayOf(date) + 4) % 7 + 7) % 7 + 1;
41
55
  const dateUtcMs = utcOf;
42
56
  function parseTime(token, spec) {
43
57
  const m = /^(\d{2})(\d{2})(?:F(\d*))?$/.exec(token.trim());
@@ -124,7 +138,12 @@ class TradingCalendar {
124
138
  corrections = /* @__PURE__ */ new Map();
125
139
  holidays;
126
140
  cache = /* @__PURE__ */ new Map();
141
+ /** The date and periods of each day since 01/01/1970 that `search` looked at */
142
+ days = /* @__PURE__ */ new Map();
127
143
  pine;
144
+ /** The last time located and its result: the functions of one bar locate the same time several times */
145
+ lastTime = NaN;
146
+ lastAt = null;
128
147
  /** Session periods [start, end) of the trading day `date`; empty when the day has no session. */
129
148
  periods(date) {
130
149
  let out = this.cache.get(date);
@@ -134,7 +153,7 @@ class TradingCalendar {
134
153
  if (correction !== void 0) {
135
154
  periods = correction ?? [];
136
155
  } else if (!this.holidays.has(date)) {
137
- const version = [...this.versions].reverse().find((v) => v.from <= date);
156
+ const version = this.versionOf(date);
138
157
  if (version.byDay) periods = version.byDay[weekdayOf(date)];
139
158
  else if (version.days[weekdayOf(date)]) periods = version.periods;
140
159
  }
@@ -149,6 +168,12 @@ class TradingCalendar {
149
168
  this.cache.set(date, out);
150
169
  return out;
151
170
  }
171
+ /** The session version in force on `date` (the last one that starts on or before it). */
172
+ versionOf(date) {
173
+ let k = this.versions.length - 1;
174
+ while (k >= 0 && !(this.versions[k].from <= date)) k--;
175
+ return this.versions[k];
176
+ }
152
177
  isTradingDay(date) {
153
178
  return this.periods(date).length > 0;
154
179
  }
@@ -159,7 +184,7 @@ class TradingCalendar {
159
184
  afterEarlyClose(time) {
160
185
  const at = this.locate(time);
161
186
  if (!at || at.inside || !this.corrections.get(at.date)) return false;
162
- const version = [...this.versions].reverse().find((v) => v.from <= at.date);
187
+ const version = this.versionOf(at.date);
163
188
  const usual = version.byDay ? version.byDay[weekdayOf(at.date)] : version.days[weekdayOf(at.date)] ? version.periods : [];
164
189
  const y = Math.floor(at.date / 1e4);
165
190
  const m = Math.floor(at.date / 100) % 100;
@@ -173,24 +198,38 @@ class TradingCalendar {
173
198
  * before it. Null when no trading day is found near the time.
174
199
  */
175
200
  locate(time) {
176
- const f = (0, import_timezone.zonedFields)(time, this.timezone);
177
- const local = toDateNum(f.year, f.month, f.day);
201
+ if (time !== this.lastTime) {
202
+ this.lastAt = this.search(time);
203
+ this.lastTime = time;
204
+ }
205
+ const at = this.lastAt;
206
+ return at && { date: at.date, index: at.index, inside: at.inside };
207
+ }
208
+ search(time) {
209
+ const wall = time + (0, import_timezone.zoneOffset)(time, this.timezone);
210
+ const local = dayOf(dateOf(Math.abs(wall) <= MAX_DAY * MS_PER_DAY ? Math.floor(Math.trunc(wall) / MS_PER_DAY) : NaN));
178
211
  for (let k = 0; k <= 5; k++) {
179
- const date = addDays(local, k);
180
- const index = this.periods(date).findIndex(([s, e]) => s <= time && time < e);
212
+ const { date, periods } = this.dayAt(local + k);
213
+ const index = periods.findIndex(([s, e]) => s <= time && time < e);
181
214
  if (index !== -1) return { date, index, inside: true };
182
215
  }
183
216
  for (let k = 5; k >= -7; k--) {
184
- const date = addDays(local, k);
185
- const periods = this.periods(date);
186
- let index = -1;
187
- periods.forEach(([s], i) => {
188
- if (s <= time) index = i;
189
- });
217
+ const { date, periods } = this.dayAt(local + k);
218
+ let index = periods.length - 1;
219
+ while (index >= 0 && !(periods[index][0] <= time)) index--;
190
220
  if (index !== -1) return { date, index, inside: false };
191
221
  }
192
222
  return null;
193
223
  }
224
+ dayAt(day) {
225
+ let at = this.days.get(day);
226
+ if (!at) {
227
+ const date = dateOf(day);
228
+ at = { date, periods: this.periods(date) };
229
+ this.days.set(day, at);
230
+ }
231
+ return at;
232
+ }
194
233
  /** First trading day in [from, to] (dates), or null. */
195
234
  firstTradingDay(from, to) {
196
235
  for (let date = from; date <= to; date = addDays(date, 1)) if (this.isTradingDay(date)) return date;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/session/calendar.ts"],
4
- "sourcesContent": ["/**\n * Trading calendar: the session periods of each trading day of a symbol, from the symbol session\n * information (issue #100).\n *\n * Session format (symbol session information, also PineScript session strings):\n * - periods \"HHMM-HHMM\", several separated by commas; \"24x7\" is the whole day, every day\n * - a period whose end is not after its start (\"1700-1600\", \"1700-1700\") starts the day before the\n * trading day: the session that opens Sunday 17:00 is Monday's\n * - \"HHMMF<n>\" moves a time <n> days before the trading day (\"1700F2-1200F1\"); \"F\" alone is one day (\"1700F-1900\":\n * 17:00 of the day before to 19:00)\n * - several sections joined by \"|\", each with its own days (\"1900-1900:3456|1700F-1900:2\": Monday opens on Sunday\n * 17:00, the other days at 19:00 of the day before)\n * - optional days after \":\" (1 = Sunday ... 7 = Saturday); without days a symbol session trades Monday to\n * Friday (\"24x7\": every day), and a PineScript session string follows PineScript's rules (one period:\n * every day; several periods: Monday to Friday)\n * - \"#YYYYMMDD/<session>\" changes the session from that date (\"0900-1746#20251201/0800-2200\")\n * - corrections (\"session-correction\"): \"<session>:<dates>;dayoff:<dates>\" replace the session of these\n * dates (early closes, days off); holidays (\"session_holidays\") are dates without session\n */\n\nimport { zonedFields, zonedToUnix } from '../time/timezone.js';\nimport { parsePineSession } from '../time/session.js';\n\n/** Session information of a symbol (hours, corrections, holidays). */\nexport interface SessionSpec {\n /** Session hours: \"0930-1600\", \"1700-1600\", \"24x7\", \"0400-2000\" ... */\n session: string;\n /** Exceptions by date (symbol info \"session-correction\"): \"0930-1300:20251128,20251224;dayoff:20250109\" */\n corrections?: string;\n /** Exchange holidays as \"YYYYMMDD\" (symbol info \"session_holidays\"), comma-separated or as an array */\n holidays?: string | string[];\n}\n\n/** Date as YYYYMMDD. */\nexport type DateNum = number;\n\ninterface Period {\n /** Minutes after midnight */\n start: number;\n end: number;\n /** Days before the trading day */\n startOffset: number;\n endOffset: number;\n}\n\ninterface Version {\n from: DateNum;\n periods: Period[];\n /** Index 1 (Sunday) to 7 (Saturday) */\n days: boolean[];\n /** PineScript session strings: the periods of each weekday (index 1 to 7), from the \"|\" sections */\n byDay?: Period[][];\n}\n\nexport const toDateNum = (y: number, m: number, d: number): DateNum => y * 10000 + m * 100 + d;\nconst utcOf = (date: DateNum): number => Date.UTC(Math.floor(date / 10000), Math.floor(date / 100) % 100 - 1, date % 100);\nconst fromUtc = (ms: number): DateNum => {\n const d = new Date(ms);\n return toDateNum(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());\n};\nexport const addDays = (date: DateNum, n: number): DateNum => fromUtc(utcOf(date) + n * 86_400_000);\n/** 1 = Sunday ... 7 = Saturday */\nexport const weekdayOf = (date: DateNum): number => new Date(utcOf(date)).getUTCDay() + 1;\n/** 00:00 UTC of the date, in ms (PineScript `time_tradingday`). */\nexport const dateUtcMs = utcOf;\n\nfunction parseTime(token: string, spec: string): { minutes: number; offset?: number } {\n const m = /^(\\d{2})(\\d{2})(?:F(\\d*))?$/.exec(token.trim());\n if (!m) throw new SyntaxError(`Invalid session \"${spec}\"`);\n // \"F\" without a number is one day before the trading day\n return { minutes: Number(m[1]) * 60 + Number(m[2]), offset: m[3] === undefined ? undefined : Number(m[3] || 1) };\n}\n\nfunction parsePeriods(text: string, spec: string): Period[] {\n if (text.trim() === '24x7') return [{ start: 0, end: 1440, startOffset: 0, endOffset: 0 }];\n return text.split(',').map((p) => {\n const [a = '', b = ''] = p.split('-');\n const s = parseTime(a, spec);\n const e = parseTime(b, spec);\n if (s.minutes === 0 && e.minutes === 0 && s.offset === undefined && e.offset === undefined) {\n return { start: 0, end: 1440, startOffset: 0, endOffset: 0 };\n }\n return {\n start: s.minutes,\n end: e.minutes,\n startOffset: s.offset ?? (e.minutes <= s.minutes ? 1 : 0),\n endOffset: e.offset ?? 0,\n };\n });\n}\n\n/** A PineScript session string as periods per weekday (rules in time/session.ts). */\nfunction pineVersion(text: string, from: DateNum): Version {\n const ranges = parsePineSession(text);\n if (ranges === null) throw new SyntaxError(`Session \"${text}\" is the symbol session`);\n const byDay: Period[][] = Array.from({ length: 8 }, () => []);\n for (const { start, end, days, startDays } of ranges) {\n // a run that ends at 0000 ends at 24:00 of the day it starts and belongs to that day (#173)\n const period: Period =\n start === 0 && end === 0\n ? { start: 0, end: 1440, startOffset: 0, endOffset: 0 }\n : startDays !== undefined\n ? { start, end, startOffset: startDays, endOffset: 0 }\n : end === 0\n ? { start, end: 1440, startOffset: 0, endOffset: 0 }\n : { start, end, startOffset: end <= start ? 1 : 0, endOffset: 0 };\n for (const d of days) byDay[d]!.push(period);\n }\n return { from, periods: [], days: byDay.map((p) => p.length > 0), byDay };\n}\n\nfunction parseVersion(text: string, from: DateNum, spec: string, rule: 'symbol' | 'pine'): Version {\n if (rule === 'pine') return pineVersion(text, from);\n if (text.includes('|')) {\n // sections with their own days\n const byDay: Period[][] = Array.from({ length: 8 }, () => []);\n for (const section of text.split('|').filter((part) => part.trim())) {\n const one = parseVersion(section, from, spec, rule);\n one.days.forEach((on, d) => {\n if (on) byDay[d] = one.periods;\n });\n }\n return { from, periods: [], days: byDay.map((p) => p.length > 0), byDay };\n }\n const [periodText = '', dayText] = text.trim().split(':');\n const periods = parsePeriods(periodText, spec);\n const allDays = periodText.trim() === '24x7';\n const digits = dayText ?? (allDays ? '1234567' : '23456');\n if (!/^[1-7]+$/.test(digits)) throw new SyntaxError(`Invalid session days in \"${spec}\"`);\n const days = new Array<boolean>(8).fill(false);\n for (const d of digits) days[Number(d)] = true;\n return { from, periods, days };\n}\n\n/** Session periods of every trading day of a symbol, as UNIX times (ms). */\nexport class TradingCalendar {\n private readonly versions: Version[];\n private readonly corrections = new Map<DateNum, Period[] | null>();\n private readonly holidays: Set<DateNum>;\n private readonly cache = new Map<DateNum, Array<[number, number]>>();\n private readonly pine: boolean;\n\n /**\n * @param timezone - Time zone of the session hours (the exchange time zone)\n * @param spec - Session information (hours, corrections, holidays)\n * @param rule - Days without \":days\": 'symbol' (Monday to Friday) or 'pine' (PineScript session strings)\n * @param dayPlacement - PineScript session strings read for `time(\"D\", session)`: the wall times of a clock-change\n * day are placed as the JVM does (see `periods`); without it, as `time.inSession` places them\n */\n constructor(\n readonly timezone: string,\n spec: SessionSpec,\n rule: 'symbol' | 'pine' = 'symbol',\n dayPlacement = false\n ) {\n this.pine = rule === 'pine' && dayPlacement;\n const [first = '', ...changes] = spec.session.split('#');\n this.versions = [parseVersion(first, 0, spec.session, rule)];\n for (const change of changes) {\n const m = /^(\\d{8})\\/(.+)$/.exec(change.trim());\n if (!m) throw new SyntaxError(`Invalid session change in \"${spec.session}\"`);\n this.versions.push(parseVersion(m[2]!, Number(m[1]), spec.session, rule));\n }\n for (const part of (spec.corrections ?? '').split(';').filter((p) => p.trim())) {\n const i = part.lastIndexOf(':');\n const text = part.slice(0, i).trim();\n const periods = text === 'dayoff' ? null : parsePeriods(text, part);\n for (const date of part.slice(i + 1).split(',')) this.corrections.set(Number(date), periods);\n }\n const holidays = Array.isArray(spec.holidays) ? spec.holidays : (spec.holidays ?? '').split(',');\n this.holidays = new Set(holidays.filter((h) => h.trim()).map(Number));\n }\n\n /** Session periods [start, end) of the trading day `date`; empty when the day has no session. */\n periods(date: DateNum): Array<[number, number]> {\n let out = this.cache.get(date);\n if (out) return out;\n let periods: Period[] = [];\n const correction = this.corrections.get(date);\n if (correction !== undefined) {\n periods = correction ?? [];\n } else if (!this.holidays.has(date)) {\n const version = [...this.versions].reverse().find((v) => v.from <= date)!;\n if (version.byDay) periods = version.byDay[weekdayOf(date)]!;\n else if (version.days[weekdayOf(date)]) periods = version.periods;\n }\n const y = Math.floor(date / 10000);\n const m = Math.floor(date / 100) % 100;\n const d = date % 100;\n const at = (dd: number, minutes: number, earlier = false): number =>\n zonedToUnix(this.timezone, y, m, dd, Math.floor(minutes / 60), minutes % 60, 0, earlier);\n // for \"D\", PineScript session strings place the wall times of a clock-change day as the JVM does: a skipped time moves\n // past the gap, a repeated time is its first pass, and the end is the minute before it plus one minute (\"0000-0300\"\n // on a 02:00 -> 03:00 night ends at 03:00 of the old offset, \"0000-0400\" at 04:00 of the new one) (#173)\n out = periods.map((p) =>\n this.pine\n ? [at(d - p.startOffset, p.start, true), at(d - p.endOffset, p.end - 1, true) + 60_000]\n : [at(d - p.startOffset, p.start), at(d - p.endOffset, p.end)]\n );\n // for \"D\", the runs of a PineScript session string on one day are one period, from the earliest start to the\n // latest end: the time between two runs is inside the day (#182)\n if (this.pine && out.length > 1) out = [[Math.min(...out.map((p) => p[0])), Math.max(...out.map((p) => p[1]))]];\n this.cache.set(date, out);\n return out;\n }\n\n isTradingDay(date: DateNum): boolean {\n return this.periods(date).length > 0;\n }\n\n /**\n * True for a bar that opens after the session of its day was cut by a correction (an early close) but inside the\n * usual hours of that day: PineScript has no period for such a bar (`time(\"D\")` is na on it).\n */\n afterEarlyClose(time: number): boolean {\n const at = this.locate(time);\n if (!at || at.inside || !this.corrections.get(at.date)) return false;\n const version = [...this.versions].reverse().find((v) => v.from <= at.date)!;\n const usual = version.byDay ? version.byDay[weekdayOf(at.date)]! : version.days[weekdayOf(at.date)] ? version.periods : [];\n const y = Math.floor(at.date / 10000);\n const m = Math.floor(at.date / 100) % 100;\n const d = at.date % 100;\n return usual.some(\n (p) =>\n zonedToUnix(this.timezone, y, m, d - p.startOffset, Math.floor(p.start / 60), p.start % 60) <= time &&\n time < zonedToUnix(this.timezone, y, m, d - p.endOffset, Math.floor(p.end / 60), p.end % 60)\n );\n }\n\n /**\n * Trading day and period of a time: the period that contains it, else the last period that started\n * before it. Null when no trading day is found near the time.\n */\n locate(time: number): { date: DateNum; index: number; inside: boolean } | null {\n const f = zonedFields(time, this.timezone);\n const local = toDateNum(f.year, f.month, f.day);\n for (let k = 0; k <= 5; k++) {\n const date = addDays(local, k);\n const index = this.periods(date).findIndex(([s, e]) => s <= time && time < e);\n if (index !== -1) return { date, index, inside: true };\n }\n for (let k = 5; k >= -7; k--) {\n const date = addDays(local, k);\n const periods = this.periods(date);\n let index = -1;\n periods.forEach(([s], i) => {\n if (s <= time) index = i;\n });\n if (index !== -1) return { date, index, inside: false };\n }\n return null;\n }\n\n /** First trading day in [from, to] (dates), or null. */\n firstTradingDay(from: DateNum, to: DateNum): DateNum | null {\n for (let date = from; date <= to; date = addDays(date, 1)) if (this.isTradingDay(date)) return date;\n return null;\n }\n\n /** Last trading day in [from, to] (dates), or null. */\n lastTradingDay(from: DateNum, to: DateNum): DateNum | null {\n for (let date = to; date >= from; date = addDays(date, -1)) if (this.isTradingDay(date)) return date;\n return null;\n }\n}\n\n/** Monday of the week of `date` (weeks run Monday to Sunday). */\nexport const weekStart = (date: DateNum): DateNum => addDays(date, -((weekdayOf(date) + 5) % 7));\n/** First day of the month of `date`. */\nexport const monthStart = (date: DateNum): DateNum => Math.floor(date / 100) * 100 + 1;\n/** Last day of the month of `date`. */\nexport const monthEnd = (date: DateNum): DateNum => addDays(monthStart(addDays(monthStart(date), 32)), -1);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,sBAAyC;AACzC,qBAAiC;AAiC1B,MAAM,YAAY,CAAC,GAAW,GAAW,MAAuB,IAAI,MAAQ,IAAI,MAAM;AAC7F,MAAM,QAAQ,CAAC,SAA0B,KAAK,IAAI,KAAK,MAAM,OAAO,GAAK,GAAG,KAAK,MAAM,OAAO,GAAG,IAAI,MAAM,GAAG,OAAO,GAAG;AACxH,MAAM,UAAU,CAAC,OAAwB;AACvC,QAAM,IAAI,IAAI,KAAK,EAAE;AACrB,SAAO,UAAU,EAAE,eAAe,GAAG,EAAE,YAAY,IAA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OAAO,QAAQ,MAAM,EAAE,EAAG,KAAI,KAAK,aAAa,IAAI,EAAG,QAAO;AAChG,WAAO;AAAA,EACT;AACF;AAGO,MAAM,YAAY,CAAC,SAA2B,QAAQ,MAAM,GAAG,UAAU,IAAI,IAAI,KAAK,EAAE;AAExF,MAAM,aAAa,CAAC,SAA2B,KAAK,MAAM,OAAO,GAAG,IAAI,MAAM;AAE9E,MAAM,WAAW,CAAC,SAA2B,QAAQ,WAAW,QAAQ,WAAW,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE;",
4
+ "sourcesContent": ["/**\n * Trading calendar: the session periods of each trading day of a symbol, from the symbol session\n * information (issue #100).\n *\n * Session format (symbol session information, also PineScript session strings):\n * - periods \"HHMM-HHMM\", several separated by commas; \"24x7\" is the whole day, every day\n * - a period whose end is not after its start (\"1700-1600\", \"1700-1700\") starts the day before the\n * trading day: the session that opens Sunday 17:00 is Monday's\n * - \"HHMMF<n>\" moves a time <n> days before the trading day (\"1700F2-1200F1\"); \"F\" alone is one day (\"1700F-1900\":\n * 17:00 of the day before to 19:00)\n * - several sections joined by \"|\", each with its own days (\"1900-1900:3456|1700F-1900:2\": Monday opens on Sunday\n * 17:00, the other days at 19:00 of the day before)\n * - optional days after \":\" (1 = Sunday ... 7 = Saturday); without days a symbol session trades Monday to\n * Friday (\"24x7\": every day), and a PineScript session string follows PineScript's rules (one period:\n * every day; several periods: Monday to Friday)\n * - \"#YYYYMMDD/<session>\" changes the session from that date (\"0900-1746#20251201/0800-2200\")\n * - corrections (\"session-correction\"): \"<session>:<dates>;dayoff:<dates>\" replace the session of these\n * dates (early closes, days off); holidays (\"session_holidays\") are dates without session\n */\n\nimport { civilFromDays, zoneOffset, zonedToUnix } from '../time/timezone.js';\nimport { parsePineSession } from '../time/session.js';\n\n/** Session information of a symbol (hours, corrections, holidays). */\nexport interface SessionSpec {\n /** Session hours: \"0930-1600\", \"1700-1600\", \"24x7\", \"0400-2000\" ... */\n session: string;\n /** Exceptions by date (symbol info \"session-correction\"): \"0930-1300:20251128,20251224;dayoff:20250109\" */\n corrections?: string;\n /** Exchange holidays as \"YYYYMMDD\" (symbol info \"session_holidays\"), comma-separated or as an array */\n holidays?: string | string[];\n}\n\n/** Date as YYYYMMDD. */\nexport type DateNum = number;\n\ninterface Period {\n /** Minutes after midnight */\n start: number;\n end: number;\n /** Days before the trading day */\n startOffset: number;\n endOffset: number;\n}\n\ninterface Version {\n from: DateNum;\n periods: Period[];\n /** Index 1 (Sunday) to 7 (Saturday) */\n days: boolean[];\n /** PineScript session strings: the periods of each weekday (index 1 to 7), from the \"|\" sections */\n byDay?: Period[][];\n}\n\nexport const toDateNum = (y: number, m: number, d: number): DateNum => y * 10000 + m * 100 + d;\nconst utcOf = (date: DateNum): number => Date.UTC(Math.floor(date / 10000), Math.floor(date / 100) % 100 - 1, date % 100);\n\nconst MS_PER_DAY = 86_400_000;\n/** Days of a valid `Date` on each side of 01/01/1970 (8.64e15 ms) */\nconst MAX_DAY = 100_000_000;\n\n/**\n * Days since 01/01/1970 of a date, as `utcOf(date) / 1 day` but without a `Date`: the calendar functions step\n * through days on every bar. Years before 100 and months outside 1-12 keep the `Date.UTC` reading (years 0-99 are\n * 1900-1999 there). NaN outside the `Date` range.\n */\nfunction dayOf(date: DateNum): number {\n let y = Math.floor(date / 10000);\n const m = Math.floor(date / 100) % 100;\n if (!(y >= 100 && m >= 1 && m <= 12)) return utcOf(date) / MS_PER_DAY;\n // proleptic Gregorian day count, years starting in March (the leap day last)\n if (m <= 2) y--;\n const era = Math.floor(y / 400);\n const yearOfEra = y - era * 400;\n const dayOfYear = Math.floor((153 * (m > 2 ? m - 3 : m + 9) + 2) / 5) + (date % 100) - 1;\n const day = era * 146_097 + yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear - 719_468;\n return Math.abs(day) <= MAX_DAY ? day : NaN;\n}\n\n/** Date of a day since 01/01/1970 (the inverse of `dayOf`); NaN outside the `Date` range. */\nfunction dateOf(day: number): DateNum {\n if (!(Math.abs(day) <= MAX_DAY)) return NaN;\n const { year, month, day: d } = civilFromDays(day);\n return toDateNum(year, month, d);\n}\n\n/** The date `n` (whole) days after `date`. */\nexport const addDays = (date: DateNum, n: number): DateNum => dateOf(dayOf(date) + n);\n/** 1 = Sunday ... 7 = Saturday (01/01/1970 is a Thursday) */\nexport const weekdayOf = (date: DateNum): number => ((((dayOf(date) + 4) % 7) + 7) % 7) + 1;\n/** 00:00 UTC of the date, in ms (PineScript `time_tradingday`). */\nexport const dateUtcMs = utcOf;\n\nfunction parseTime(token: string, spec: string): { minutes: number; offset?: number } {\n const m = /^(\\d{2})(\\d{2})(?:F(\\d*))?$/.exec(token.trim());\n if (!m) throw new SyntaxError(`Invalid session \"${spec}\"`);\n // \"F\" without a number is one day before the trading day\n return { minutes: Number(m[1]) * 60 + Number(m[2]), offset: m[3] === undefined ? undefined : Number(m[3] || 1) };\n}\n\nfunction parsePeriods(text: string, spec: string): Period[] {\n if (text.trim() === '24x7') return [{ start: 0, end: 1440, startOffset: 0, endOffset: 0 }];\n return text.split(',').map((p) => {\n const [a = '', b = ''] = p.split('-');\n const s = parseTime(a, spec);\n const e = parseTime(b, spec);\n if (s.minutes === 0 && e.minutes === 0 && s.offset === undefined && e.offset === undefined) {\n return { start: 0, end: 1440, startOffset: 0, endOffset: 0 };\n }\n return {\n start: s.minutes,\n end: e.minutes,\n startOffset: s.offset ?? (e.minutes <= s.minutes ? 1 : 0),\n endOffset: e.offset ?? 0,\n };\n });\n}\n\n/** A PineScript session string as periods per weekday (rules in time/session.ts). */\nfunction pineVersion(text: string, from: DateNum): Version {\n const ranges = parsePineSession(text);\n if (ranges === null) throw new SyntaxError(`Session \"${text}\" is the symbol session`);\n const byDay: Period[][] = Array.from({ length: 8 }, () => []);\n for (const { start, end, days, startDays } of ranges) {\n // a run that ends at 0000 ends at 24:00 of the day it starts and belongs to that day (#173)\n const period: Period =\n start === 0 && end === 0\n ? { start: 0, end: 1440, startOffset: 0, endOffset: 0 }\n : startDays !== undefined\n ? { start, end, startOffset: startDays, endOffset: 0 }\n : end === 0\n ? { start, end: 1440, startOffset: 0, endOffset: 0 }\n : { start, end, startOffset: end <= start ? 1 : 0, endOffset: 0 };\n for (const d of days) byDay[d]!.push(period);\n }\n return { from, periods: [], days: byDay.map((p) => p.length > 0), byDay };\n}\n\nfunction parseVersion(text: string, from: DateNum, spec: string, rule: 'symbol' | 'pine'): Version {\n if (rule === 'pine') return pineVersion(text, from);\n if (text.includes('|')) {\n // sections with their own days\n const byDay: Period[][] = Array.from({ length: 8 }, () => []);\n for (const section of text.split('|').filter((part) => part.trim())) {\n const one = parseVersion(section, from, spec, rule);\n one.days.forEach((on, d) => {\n if (on) byDay[d] = one.periods;\n });\n }\n return { from, periods: [], days: byDay.map((p) => p.length > 0), byDay };\n }\n const [periodText = '', dayText] = text.trim().split(':');\n const periods = parsePeriods(periodText, spec);\n const allDays = periodText.trim() === '24x7';\n const digits = dayText ?? (allDays ? '1234567' : '23456');\n if (!/^[1-7]+$/.test(digits)) throw new SyntaxError(`Invalid session days in \"${spec}\"`);\n const days = new Array<boolean>(8).fill(false);\n for (const d of digits) days[Number(d)] = true;\n return { from, periods, days };\n}\n\n/** Trading day and period of a time (see `TradingCalendar.locate`). */\ninterface Located {\n date: DateNum;\n index: number;\n inside: boolean;\n}\n\n/** Session periods of every trading day of a symbol, as UNIX times (ms). */\nexport class TradingCalendar {\n private readonly versions: Version[];\n private readonly corrections = new Map<DateNum, Period[] | null>();\n private readonly holidays: Set<DateNum>;\n private readonly cache = new Map<DateNum, Array<[number, number]>>();\n /** The date and periods of each day since 01/01/1970 that `search` looked at */\n private readonly days = new Map<number, { date: DateNum; periods: Array<[number, number]> }>();\n private readonly pine: boolean;\n /** The last time located and its result: the functions of one bar locate the same time several times */\n private lastTime = NaN;\n private lastAt: Located | null = null;\n\n /**\n * @param timezone - Time zone of the session hours (the exchange time zone)\n * @param spec - Session information (hours, corrections, holidays)\n * @param rule - Days without \":days\": 'symbol' (Monday to Friday) or 'pine' (PineScript session strings)\n * @param dayPlacement - PineScript session strings read for `time(\"D\", session)`: the wall times of a clock-change\n * day are placed as the JVM does (see `periods`); without it, as `time.inSession` places them\n */\n constructor(\n readonly timezone: string,\n spec: SessionSpec,\n rule: 'symbol' | 'pine' = 'symbol',\n dayPlacement = false\n ) {\n this.pine = rule === 'pine' && dayPlacement;\n const [first = '', ...changes] = spec.session.split('#');\n this.versions = [parseVersion(first, 0, spec.session, rule)];\n for (const change of changes) {\n const m = /^(\\d{8})\\/(.+)$/.exec(change.trim());\n if (!m) throw new SyntaxError(`Invalid session change in \"${spec.session}\"`);\n this.versions.push(parseVersion(m[2]!, Number(m[1]), spec.session, rule));\n }\n for (const part of (spec.corrections ?? '').split(';').filter((p) => p.trim())) {\n const i = part.lastIndexOf(':');\n const text = part.slice(0, i).trim();\n const periods = text === 'dayoff' ? null : parsePeriods(text, part);\n for (const date of part.slice(i + 1).split(',')) this.corrections.set(Number(date), periods);\n }\n const holidays = Array.isArray(spec.holidays) ? spec.holidays : (spec.holidays ?? '').split(',');\n this.holidays = new Set(holidays.filter((h) => h.trim()).map(Number));\n }\n\n /** Session periods [start, end) of the trading day `date`; empty when the day has no session. */\n periods(date: DateNum): Array<[number, number]> {\n let out = this.cache.get(date);\n if (out) return out;\n let periods: Period[] = [];\n const correction = this.corrections.get(date);\n if (correction !== undefined) {\n periods = correction ?? [];\n } else if (!this.holidays.has(date)) {\n const version = this.versionOf(date);\n if (version.byDay) periods = version.byDay[weekdayOf(date)]!;\n else if (version.days[weekdayOf(date)]) periods = version.periods;\n }\n const y = Math.floor(date / 10000);\n const m = Math.floor(date / 100) % 100;\n const d = date % 100;\n const at = (dd: number, minutes: number, earlier = false): number =>\n zonedToUnix(this.timezone, y, m, dd, Math.floor(minutes / 60), minutes % 60, 0, earlier);\n // for \"D\", PineScript session strings place the wall times of a clock-change day as the JVM does: a skipped time moves\n // past the gap, a repeated time is its first pass, and the end is the minute before it plus one minute (\"0000-0300\"\n // on a 02:00 -> 03:00 night ends at 03:00 of the old offset, \"0000-0400\" at 04:00 of the new one) (#173)\n out = periods.map((p) =>\n this.pine\n ? [at(d - p.startOffset, p.start, true), at(d - p.endOffset, p.end - 1, true) + 60_000]\n : [at(d - p.startOffset, p.start), at(d - p.endOffset, p.end)]\n );\n // for \"D\", the runs of a PineScript session string on one day are one period, from the earliest start to the\n // latest end: the time between two runs is inside the day (#182)\n if (this.pine && out.length > 1) out = [[Math.min(...out.map((p) => p[0])), Math.max(...out.map((p) => p[1]))]];\n this.cache.set(date, out);\n return out;\n }\n\n /** The session version in force on `date` (the last one that starts on or before it). */\n private versionOf(date: DateNum): Version {\n let k = this.versions.length - 1;\n while (k >= 0 && !(this.versions[k]!.from <= date)) k--;\n return this.versions[k]!;\n }\n\n isTradingDay(date: DateNum): boolean {\n return this.periods(date).length > 0;\n }\n\n /**\n * True for a bar that opens after the session of its day was cut by a correction (an early close) but inside the\n * usual hours of that day: PineScript has no period for such a bar (`time(\"D\")` is na on it).\n */\n afterEarlyClose(time: number): boolean {\n const at = this.locate(time);\n if (!at || at.inside || !this.corrections.get(at.date)) return false;\n const version = this.versionOf(at.date);\n const usual = version.byDay ? version.byDay[weekdayOf(at.date)]! : version.days[weekdayOf(at.date)] ? version.periods : [];\n const y = Math.floor(at.date / 10000);\n const m = Math.floor(at.date / 100) % 100;\n const d = at.date % 100;\n return usual.some(\n (p) =>\n zonedToUnix(this.timezone, y, m, d - p.startOffset, Math.floor(p.start / 60), p.start % 60) <= time &&\n time < zonedToUnix(this.timezone, y, m, d - p.endOffset, Math.floor(p.end / 60), p.end % 60)\n );\n }\n\n /**\n * Trading day and period of a time: the period that contains it, else the last period that started\n * before it. Null when no trading day is found near the time.\n */\n locate(time: number): Located | null {\n if (time !== this.lastTime) {\n this.lastAt = this.search(time);\n this.lastTime = time;\n }\n const at = this.lastAt;\n return at && { date: at.date, index: at.index, inside: at.inside };\n }\n\n private search(time: number): Located | null {\n // the local date of the time, as `Date` reads the wall clock (whole ms, NaN outside its range)\n const wall = time + zoneOffset(time, this.timezone);\n const local = dayOf(dateOf(Math.abs(wall) <= MAX_DAY * MS_PER_DAY ? Math.floor(Math.trunc(wall) / MS_PER_DAY) : NaN));\n for (let k = 0; k <= 5; k++) {\n const { date, periods } = this.dayAt(local + k);\n const index = periods.findIndex(([s, e]) => s <= time && time < e);\n if (index !== -1) return { date, index, inside: true };\n }\n for (let k = 5; k >= -7; k--) {\n const { date, periods } = this.dayAt(local + k);\n let index = periods.length - 1;\n while (index >= 0 && !(periods[index]![0] <= time)) index--;\n if (index !== -1) return { date, index, inside: false };\n }\n return null;\n }\n\n private dayAt(day: number): { date: DateNum; periods: Array<[number, number]> } {\n let at = this.days.get(day);\n if (!at) {\n const date = dateOf(day);\n at = { date, periods: this.periods(date) };\n this.days.set(day, at);\n }\n return at;\n }\n\n /** First trading day in [from, to] (dates), or null. */\n firstTradingDay(from: DateNum, to: DateNum): DateNum | null {\n for (let date = from; date <= to; date = addDays(date, 1)) if (this.isTradingDay(date)) return date;\n return null;\n }\n\n /** Last trading day in [from, to] (dates), or null. */\n lastTradingDay(from: DateNum, to: DateNum): DateNum | null {\n for (let date = to; date >= from; date = addDays(date, -1)) if (this.isTradingDay(date)) return date;\n return null;\n }\n}\n\n/** Monday of the week of `date` (weeks run Monday to Sunday). */\nexport const weekStart = (date: DateNum): DateNum => addDays(date, -((weekdayOf(date) + 5) % 7));\n/** First day of the month of `date`. */\nexport const monthStart = (date: DateNum): DateNum => Math.floor(date / 100) * 100 + 1;\n/** Last day of the month of `date`. */\nexport const monthEnd = (date: DateNum): DateNum => addDays(monthStart(addDays(monthStart(date), 32)), -1);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,sBAAuD;AACvD,qBAAiC;AAiC1B,MAAM,YAAY,CAAC,GAAW,GAAW,MAAu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