openalgo-script 0.1.0-alpha.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (990) hide show
  1. package/CHANGELOG.md +1200 -0
  2. package/README.md +49 -28
  3. package/dist/adapters/charts/alerts.d.ts +70 -0
  4. package/dist/adapters/charts/alerts.d.ts.map +1 -0
  5. package/dist/adapters/charts/alerts.js +52 -0
  6. package/dist/adapters/charts/alerts.js.map +1 -0
  7. package/dist/adapters/charts/bars.d.ts +39 -0
  8. package/dist/adapters/charts/bars.d.ts.map +1 -0
  9. package/dist/adapters/charts/bars.js +32 -0
  10. package/dist/adapters/charts/bars.js.map +1 -0
  11. package/dist/adapters/charts/candles.d.ts +40 -0
  12. package/dist/adapters/charts/candles.d.ts.map +1 -0
  13. package/dist/adapters/charts/candles.js +85 -0
  14. package/dist/adapters/charts/candles.js.map +1 -0
  15. package/dist/adapters/charts/colours.d.ts +47 -0
  16. package/dist/adapters/charts/colours.d.ts.map +1 -0
  17. package/dist/adapters/charts/colours.js +80 -0
  18. package/dist/adapters/charts/colours.js.map +1 -0
  19. package/dist/adapters/charts/columns.d.ts +37 -0
  20. package/dist/adapters/charts/columns.d.ts.map +1 -0
  21. package/dist/adapters/charts/columns.js +56 -0
  22. package/dist/adapters/charts/columns.js.map +1 -0
  23. package/dist/adapters/charts/contract.d.ts +278 -0
  24. package/dist/adapters/charts/contract.d.ts.map +1 -0
  25. package/dist/adapters/charts/contract.js +2 -0
  26. package/dist/adapters/charts/contract.js.map +1 -0
  27. package/dist/adapters/charts/descriptor.d.ts +48 -0
  28. package/dist/adapters/charts/descriptor.d.ts.map +1 -0
  29. package/dist/adapters/charts/descriptor.js +111 -0
  30. package/dist/adapters/charts/descriptor.js.map +1 -0
  31. package/dist/adapters/charts/drawings.d.ts +43 -0
  32. package/dist/adapters/charts/drawings.d.ts.map +1 -0
  33. package/dist/adapters/charts/drawings.js +172 -0
  34. package/dist/adapters/charts/drawings.js.map +1 -0
  35. package/dist/adapters/charts/errors.d.ts +28 -0
  36. package/dist/adapters/charts/errors.d.ts.map +1 -0
  37. package/dist/adapters/charts/errors.js +21 -0
  38. package/dist/adapters/charts/errors.js.map +1 -0
  39. package/dist/adapters/charts/fields.d.ts +33 -0
  40. package/dist/adapters/charts/fields.d.ts.map +1 -0
  41. package/dist/adapters/charts/fields.js +51 -0
  42. package/dist/adapters/charts/fields.js.map +1 -0
  43. package/dist/adapters/charts/fills.d.ts +23 -0
  44. package/dist/adapters/charts/fills.d.ts.map +1 -0
  45. package/dist/adapters/charts/fills.js +48 -0
  46. package/dist/adapters/charts/fills.js.map +1 -0
  47. package/dist/adapters/charts/index.d.ts +37 -0
  48. package/dist/adapters/charts/index.d.ts.map +1 -0
  49. package/dist/adapters/charts/index.js +33 -0
  50. package/dist/adapters/charts/index.js.map +1 -0
  51. package/dist/adapters/charts/levels.d.ts +39 -0
  52. package/dist/adapters/charts/levels.d.ts.map +1 -0
  53. package/dist/adapters/charts/levels.js +61 -0
  54. package/dist/adapters/charts/levels.js.map +1 -0
  55. package/dist/adapters/charts/markers.d.ts +41 -0
  56. package/dist/adapters/charts/markers.d.ts.map +1 -0
  57. package/dist/adapters/charts/markers.js +75 -0
  58. package/dist/adapters/charts/markers.js.map +1 -0
  59. package/dist/adapters/charts/paint.d.ts +61 -0
  60. package/dist/adapters/charts/paint.d.ts.map +1 -0
  61. package/dist/adapters/charts/paint.js +47 -0
  62. package/dist/adapters/charts/paint.js.map +1 -0
  63. package/dist/adapters/charts/plots.d.ts +39 -0
  64. package/dist/adapters/charts/plots.d.ts.map +1 -0
  65. package/dist/adapters/charts/plots.js +117 -0
  66. package/dist/adapters/charts/plots.js.map +1 -0
  67. package/dist/adapters/charts/produced.d.ts +57 -0
  68. package/dist/adapters/charts/produced.d.ts.map +1 -0
  69. package/dist/adapters/charts/produced.js +11 -0
  70. package/dist/adapters/charts/produced.js.map +1 -0
  71. package/dist/adapters/charts/requests.d.ts +114 -0
  72. package/dist/adapters/charts/requests.d.ts.map +1 -0
  73. package/dist/adapters/charts/requests.js +277 -0
  74. package/dist/adapters/charts/requests.js.map +1 -0
  75. package/dist/adapters/charts/run.d.ts +147 -0
  76. package/dist/adapters/charts/run.d.ts.map +1 -0
  77. package/dist/adapters/charts/run.js +148 -0
  78. package/dist/adapters/charts/run.js.map +1 -0
  79. package/dist/adapters/charts/settings.d.ts +78 -0
  80. package/dist/adapters/charts/settings.d.ts.map +1 -0
  81. package/dist/adapters/charts/settings.js +225 -0
  82. package/dist/adapters/charts/settings.js.map +1 -0
  83. package/dist/adapters/charts/surfaces.d.ts +204 -0
  84. package/dist/adapters/charts/surfaces.d.ts.map +1 -0
  85. package/dist/adapters/charts/surfaces.js +2 -0
  86. package/dist/adapters/charts/surfaces.js.map +1 -0
  87. package/dist/adapters/charts/tables.d.ts +65 -0
  88. package/dist/adapters/charts/tables.d.ts.map +1 -0
  89. package/dist/adapters/charts/tables.js +84 -0
  90. package/dist/adapters/charts/tables.js.map +1 -0
  91. package/dist/core/catalogue/catalogue.generated.d.ts +98 -10
  92. package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
  93. package/dist/core/catalogue/catalogue.generated.js +17 -9
  94. package/dist/core/catalogue/catalogue.generated.js.map +1 -1
  95. package/dist/core/catalogue/values.generated.d.ts +25 -0
  96. package/dist/core/catalogue/values.generated.d.ts.map +1 -1
  97. package/dist/core/check/arguments.d.ts +41 -0
  98. package/dist/core/check/arguments.d.ts.map +1 -0
  99. package/dist/core/check/arguments.js +84 -0
  100. package/dist/core/check/arguments.js.map +1 -0
  101. package/dist/core/check/call-sites.d.ts +22 -0
  102. package/dist/core/check/call-sites.d.ts.map +1 -0
  103. package/dist/core/check/call-sites.js +329 -0
  104. package/dist/core/check/call-sites.js.map +1 -0
  105. package/dist/core/check/call-warmup.d.ts +37 -0
  106. package/dist/core/check/call-warmup.d.ts.map +1 -0
  107. package/dist/core/check/call-warmup.js +97 -0
  108. package/dist/core/check/call-warmup.js.map +1 -0
  109. package/dist/core/check/calls.d.ts +33 -0
  110. package/dist/core/check/calls.d.ts.map +1 -0
  111. package/dist/core/check/calls.js +348 -0
  112. package/dist/core/check/calls.js.map +1 -0
  113. package/dist/core/check/check.d.ts +23 -0
  114. package/dist/core/check/check.d.ts.map +1 -0
  115. package/dist/core/check/check.js +163 -0
  116. package/dist/core/check/check.js.map +1 -0
  117. package/dist/core/check/checked.d.ts +198 -0
  118. package/dist/core/check/checked.d.ts.map +1 -0
  119. package/dist/core/check/checked.js +19 -0
  120. package/dist/core/check/checked.js.map +1 -0
  121. package/dist/core/check/checker.d.ts +182 -0
  122. package/dist/core/check/checker.d.ts.map +1 -0
  123. package/dist/core/check/checker.js +280 -0
  124. package/dist/core/check/checker.js.map +1 -0
  125. package/dist/core/check/conditional.d.ts +35 -0
  126. package/dist/core/check/conditional.d.ts.map +1 -0
  127. package/dist/core/check/conditional.js +100 -0
  128. package/dist/core/check/conditional.js.map +1 -0
  129. package/dist/core/check/constant.d.ts +47 -0
  130. package/dist/core/check/constant.d.ts.map +1 -0
  131. package/dist/core/check/constant.js +101 -0
  132. package/dist/core/check/constant.js.map +1 -0
  133. package/dist/core/check/declaration.d.ts +33 -0
  134. package/dist/core/check/declaration.d.ts.map +1 -0
  135. package/dist/core/check/declaration.js +181 -0
  136. package/dist/core/check/declaration.js.map +1 -0
  137. package/dist/core/check/expressions.d.ts +36 -0
  138. package/dist/core/check/expressions.d.ts.map +1 -0
  139. package/dist/core/check/expressions.js +398 -0
  140. package/dist/core/check/expressions.js.map +1 -0
  141. package/dist/core/check/functions.d.ts +31 -0
  142. package/dist/core/check/functions.d.ts.map +1 -0
  143. package/dist/core/check/functions.js +238 -0
  144. package/dist/core/check/functions.js.map +1 -0
  145. package/dist/core/check/handles.d.ts +48 -0
  146. package/dist/core/check/handles.d.ts.map +1 -0
  147. package/dist/core/check/handles.js +43 -0
  148. package/dist/core/check/handles.js.map +1 -0
  149. package/dist/core/check/index.d.ts +30 -0
  150. package/dist/core/check/index.d.ts.map +1 -0
  151. package/dist/core/check/index.js +26 -0
  152. package/dist/core/check/index.js.map +1 -0
  153. package/dist/core/check/library-bars.d.ts +7 -0
  154. package/dist/core/check/library-bars.d.ts.map +1 -0
  155. package/dist/core/check/library-bars.js +181 -0
  156. package/dist/core/check/library-bars.js.map +1 -0
  157. package/dist/core/check/library-orders.d.ts +5 -0
  158. package/dist/core/check/library-orders.d.ts.map +1 -0
  159. package/dist/core/check/library-orders.js +250 -0
  160. package/dist/core/check/library-orders.js.map +1 -0
  161. package/dist/core/check/library-output.d.ts +7 -0
  162. package/dist/core/check/library-output.d.ts.map +1 -0
  163. package/dist/core/check/library-output.js +195 -0
  164. package/dist/core/check/library-output.js.map +1 -0
  165. package/dist/core/check/library-series.d.ts +3 -0
  166. package/dist/core/check/library-series.d.ts.map +1 -0
  167. package/dist/core/check/library-series.js +415 -0
  168. package/dist/core/check/library-series.js.map +1 -0
  169. package/dist/core/check/library.d.ts +204 -0
  170. package/dist/core/check/library.d.ts.map +1 -0
  171. package/dist/core/check/library.js +198 -0
  172. package/dist/core/check/library.js.map +1 -0
  173. package/dist/core/check/literals.d.ts +19 -0
  174. package/dist/core/check/literals.d.ts.map +1 -0
  175. package/dist/core/check/literals.js +22 -0
  176. package/dist/core/check/literals.js.map +1 -0
  177. package/dist/core/check/outputs.d.ts +31 -0
  178. package/dist/core/check/outputs.d.ts.map +1 -0
  179. package/dist/core/check/outputs.js +113 -0
  180. package/dist/core/check/outputs.js.map +1 -0
  181. package/dist/core/check/statements.d.ts +25 -0
  182. package/dist/core/check/statements.d.ts.map +1 -0
  183. package/dist/core/check/statements.js +377 -0
  184. package/dist/core/check/statements.js.map +1 -0
  185. package/dist/core/check/suggest.d.ts +25 -0
  186. package/dist/core/check/suggest.d.ts.map +1 -0
  187. package/dist/core/check/suggest.js +61 -0
  188. package/dist/core/check/suggest.js.map +1 -0
  189. package/dist/core/check/surface.d.ts +38 -0
  190. package/dist/core/check/surface.d.ts.map +1 -0
  191. package/dist/core/check/surface.js +100 -0
  192. package/dist/core/check/surface.js.map +1 -0
  193. package/dist/core/check/tags.d.ts +4 -0
  194. package/dist/core/check/tags.d.ts.map +1 -0
  195. package/dist/core/check/tags.js +54 -0
  196. package/dist/core/check/tags.js.map +1 -0
  197. package/dist/core/check/types.d.ts +153 -0
  198. package/dist/core/check/types.d.ts.map +1 -0
  199. package/dist/core/check/types.js +221 -0
  200. package/dist/core/check/types.js.map +1 -0
  201. package/dist/core/check/warmup.d.ts +73 -0
  202. package/dist/core/check/warmup.d.ts.map +1 -0
  203. package/dist/core/check/warmup.js +62 -0
  204. package/dist/core/check/warmup.js.map +1 -0
  205. package/dist/core/diagnostics/collector.d.ts +12 -0
  206. package/dist/core/diagnostics/collector.d.ts.map +1 -1
  207. package/dist/core/diagnostics/collector.js +27 -1
  208. package/dist/core/diagnostics/collector.js.map +1 -1
  209. package/dist/core/emit/calls.d.ts +38 -0
  210. package/dist/core/emit/calls.d.ts.map +1 -0
  211. package/dist/core/emit/calls.js +347 -0
  212. package/dist/core/emit/calls.js.map +1 -0
  213. package/dist/core/emit/canonical.d.ts +39 -0
  214. package/dist/core/emit/canonical.d.ts.map +1 -0
  215. package/dist/core/emit/canonical.js +71 -0
  216. package/dist/core/emit/canonical.js.map +1 -0
  217. package/dist/core/emit/channels.d.ts +28 -0
  218. package/dist/core/emit/channels.d.ts.map +1 -0
  219. package/dist/core/emit/channels.js +110 -0
  220. package/dist/core/emit/channels.js.map +1 -0
  221. package/dist/core/emit/code.d.ts +75 -0
  222. package/dist/core/emit/code.d.ts.map +1 -0
  223. package/dist/core/emit/code.js +104 -0
  224. package/dist/core/emit/code.js.map +1 -0
  225. package/dist/core/emit/colours.d.ts +35 -0
  226. package/dist/core/emit/colours.d.ts.map +1 -0
  227. package/dist/core/emit/colours.js +50 -0
  228. package/dist/core/emit/colours.js.map +1 -0
  229. package/dist/core/emit/context.d.ts +271 -0
  230. package/dist/core/emit/context.d.ts.map +1 -0
  231. package/dist/core/emit/context.js +358 -0
  232. package/dist/core/emit/context.js.map +1 -0
  233. package/dist/core/emit/defaults.d.ts +45 -0
  234. package/dist/core/emit/defaults.d.ts.map +1 -0
  235. package/dist/core/emit/defaults.js +116 -0
  236. package/dist/core/emit/defaults.js.map +1 -0
  237. package/dist/core/emit/emit.d.ts +13 -0
  238. package/dist/core/emit/emit.d.ts.map +1 -0
  239. package/dist/core/emit/emit.js +281 -0
  240. package/dist/core/emit/emit.js.map +1 -0
  241. package/dist/core/emit/events.d.ts +21 -0
  242. package/dist/core/emit/events.d.ts.map +1 -0
  243. package/dist/core/emit/events.js +112 -0
  244. package/dist/core/emit/events.js.map +1 -0
  245. package/dist/core/emit/expressions.d.ts +23 -0
  246. package/dist/core/emit/expressions.d.ts.map +1 -0
  247. package/dist/core/emit/expressions.js +253 -0
  248. package/dist/core/emit/expressions.js.map +1 -0
  249. package/dist/core/emit/functions.d.ts +30 -0
  250. package/dist/core/emit/functions.d.ts.map +1 -0
  251. package/dist/core/emit/functions.js +171 -0
  252. package/dist/core/emit/functions.js.map +1 -0
  253. package/dist/core/emit/gaps.d.ts +34 -0
  254. package/dist/core/emit/gaps.d.ts.map +1 -0
  255. package/dist/core/emit/gaps.js +16 -0
  256. package/dist/core/emit/gaps.js.map +1 -0
  257. package/dist/core/emit/index.d.ts +29 -0
  258. package/dist/core/emit/index.d.ts.map +1 -0
  259. package/dist/core/emit/index.js +23 -0
  260. package/dist/core/emit/index.js.map +1 -0
  261. package/dist/core/emit/inputs.d.ts +47 -0
  262. package/dist/core/emit/inputs.d.ts.map +1 -0
  263. package/dist/core/emit/inputs.js +150 -0
  264. package/dist/core/emit/inputs.js.map +1 -0
  265. package/dist/core/emit/layout.d.ts +73 -0
  266. package/dist/core/emit/layout.d.ts.map +1 -0
  267. package/dist/core/emit/layout.js +126 -0
  268. package/dist/core/emit/layout.js.map +1 -0
  269. package/dist/core/emit/meta.d.ts +14 -0
  270. package/dist/core/emit/meta.d.ts.map +1 -0
  271. package/dist/core/emit/meta.js +68 -0
  272. package/dist/core/emit/meta.js.map +1 -0
  273. package/dist/core/emit/opcodes.d.ts +28 -0
  274. package/dist/core/emit/opcodes.d.ts.map +1 -0
  275. package/dist/core/emit/opcodes.js +137 -0
  276. package/dist/core/emit/opcodes.js.map +1 -0
  277. package/dist/core/emit/outputs.d.ts +67 -0
  278. package/dist/core/emit/outputs.d.ts.map +1 -0
  279. package/dist/core/emit/outputs.js +293 -0
  280. package/dist/core/emit/outputs.js.map +1 -0
  281. package/dist/core/emit/pool.d.ts +33 -0
  282. package/dist/core/emit/pool.d.ts.map +1 -0
  283. package/dist/core/emit/pool.js +79 -0
  284. package/dist/core/emit/pool.js.map +1 -0
  285. package/dist/core/emit/program.d.ts +333 -0
  286. package/dist/core/emit/program.d.ts.map +1 -0
  287. package/dist/core/emit/program.js +15 -0
  288. package/dist/core/emit/program.js.map +1 -0
  289. package/dist/core/emit/registers.d.ts +35 -0
  290. package/dist/core/emit/registers.d.ts.map +1 -0
  291. package/dist/core/emit/registers.js +170 -0
  292. package/dist/core/emit/registers.js.map +1 -0
  293. package/dist/core/emit/request-scope.d.ts +36 -0
  294. package/dist/core/emit/request-scope.d.ts.map +1 -0
  295. package/dist/core/emit/request-scope.js +41 -0
  296. package/dist/core/emit/request-scope.js.map +1 -0
  297. package/dist/core/emit/requests.d.ts +69 -0
  298. package/dist/core/emit/requests.d.ts.map +1 -0
  299. package/dist/core/emit/requests.js +230 -0
  300. package/dist/core/emit/requests.js.map +1 -0
  301. package/dist/core/emit/requires.d.ts +4 -0
  302. package/dist/core/emit/requires.d.ts.map +1 -0
  303. package/dist/core/emit/requires.js +71 -0
  304. package/dist/core/emit/requires.js.map +1 -0
  305. package/dist/core/emit/sha256.d.ts +24 -0
  306. package/dist/core/emit/sha256.d.ts.map +1 -0
  307. package/dist/core/emit/sha256.js +109 -0
  308. package/dist/core/emit/sha256.js.map +1 -0
  309. package/dist/core/emit/statements.d.ts +20 -0
  310. package/dist/core/emit/statements.d.ts.map +1 -0
  311. package/dist/core/emit/statements.js +393 -0
  312. package/dist/core/emit/statements.js.map +1 -0
  313. package/dist/core/emit/values.d.ts +80 -0
  314. package/dist/core/emit/values.d.ts.map +1 -0
  315. package/dist/core/emit/values.js +242 -0
  316. package/dist/core/emit/values.js.map +1 -0
  317. package/dist/core/engine/alerts.d.ts +66 -0
  318. package/dist/core/engine/alerts.d.ts.map +1 -0
  319. package/dist/core/engine/alerts.js +119 -0
  320. package/dist/core/engine/alerts.js.map +1 -0
  321. package/dist/core/engine/arithmetic.d.ts +82 -0
  322. package/dist/core/engine/arithmetic.d.ts.map +1 -0
  323. package/dist/core/engine/arithmetic.js +141 -0
  324. package/dist/core/engine/arithmetic.js.map +1 -0
  325. package/dist/core/engine/bars.d.ts +95 -0
  326. package/dist/core/engine/bars.d.ts.map +1 -0
  327. package/dist/core/engine/bars.js +133 -0
  328. package/dist/core/engine/bars.js.map +1 -0
  329. package/dist/core/engine/budget.d.ts +162 -0
  330. package/dist/core/engine/budget.d.ts.map +1 -0
  331. package/dist/core/engine/budget.js +188 -0
  332. package/dist/core/engine/budget.js.map +1 -0
  333. package/dist/core/engine/channels.d.ts +106 -0
  334. package/dist/core/engine/channels.d.ts.map +1 -0
  335. package/dist/core/engine/channels.js +99 -0
  336. package/dist/core/engine/channels.js.map +1 -0
  337. package/dist/core/engine/drawings.d.ts +64 -0
  338. package/dist/core/engine/drawings.d.ts.map +1 -0
  339. package/dist/core/engine/drawings.js +67 -0
  340. package/dist/core/engine/drawings.js.map +1 -0
  341. package/dist/core/engine/engine.d.ts +140 -0
  342. package/dist/core/engine/engine.d.ts.map +1 -0
  343. package/dist/core/engine/engine.js +405 -0
  344. package/dist/core/engine/engine.js.map +1 -0
  345. package/dist/core/engine/errors.d.ts +64 -0
  346. package/dist/core/engine/errors.d.ts.map +1 -0
  347. package/dist/core/engine/errors.js +63 -0
  348. package/dist/core/engine/errors.js.map +1 -0
  349. package/dist/core/engine/frames.d.ts +48 -0
  350. package/dist/core/engine/frames.d.ts.map +1 -0
  351. package/dist/core/engine/frames.js +41 -0
  352. package/dist/core/engine/frames.js.map +1 -0
  353. package/dist/core/engine/grids.d.ts +25 -0
  354. package/dist/core/engine/grids.d.ts.map +1 -0
  355. package/dist/core/engine/grids.js +77 -0
  356. package/dist/core/engine/grids.js.map +1 -0
  357. package/dist/core/engine/guard.d.ts +4 -0
  358. package/dist/core/engine/guard.d.ts.map +1 -0
  359. package/dist/core/engine/guard.js +46 -0
  360. package/dist/core/engine/guard.js.map +1 -0
  361. package/dist/core/engine/host.d.ts +219 -0
  362. package/dist/core/engine/host.d.ts.map +1 -0
  363. package/dist/core/engine/host.js +38 -0
  364. package/dist/core/engine/host.js.map +1 -0
  365. package/dist/core/engine/index.d.ts +49 -0
  366. package/dist/core/engine/index.d.ts.map +1 -0
  367. package/dist/core/engine/index.js +33 -0
  368. package/dist/core/engine/index.js.map +1 -0
  369. package/dist/core/engine/inputs.d.ts +77 -0
  370. package/dist/core/engine/inputs.d.ts.map +1 -0
  371. package/dist/core/engine/inputs.js +205 -0
  372. package/dist/core/engine/inputs.js.map +1 -0
  373. package/dist/core/engine/ledger/call.d.ts +63 -0
  374. package/dist/core/engine/ledger/call.d.ts.map +1 -0
  375. package/dist/core/engine/ledger/call.js +136 -0
  376. package/dist/core/engine/ledger/call.js.map +1 -0
  377. package/dist/core/engine/ledger/closable.d.ts +155 -0
  378. package/dist/core/engine/ledger/closable.d.ts.map +1 -0
  379. package/dist/core/engine/ledger/closable.js +173 -0
  380. package/dist/core/engine/ledger/closable.js.map +1 -0
  381. package/dist/core/engine/ledger/holdings.d.ts +194 -0
  382. package/dist/core/engine/ledger/holdings.d.ts.map +1 -0
  383. package/dist/core/engine/ledger/holdings.js +237 -0
  384. package/dist/core/engine/ledger/holdings.js.map +1 -0
  385. package/dist/core/engine/ledger/index.d.ts +19 -0
  386. package/dist/core/engine/ledger/index.d.ts.map +1 -0
  387. package/dist/core/engine/ledger/index.js +2 -0
  388. package/dist/core/engine/ledger/index.js.map +1 -0
  389. package/dist/core/engine/ledger/intent.d.ts +106 -0
  390. package/dist/core/engine/ledger/intent.d.ts.map +1 -0
  391. package/dist/core/engine/ledger/intent.js +21 -0
  392. package/dist/core/engine/ledger/intent.js.map +1 -0
  393. package/dist/core/engine/ledger/ledger.d.ts +143 -0
  394. package/dist/core/engine/ledger/ledger.d.ts.map +1 -0
  395. package/dist/core/engine/ledger/ledger.js +237 -0
  396. package/dist/core/engine/ledger/ledger.js.map +1 -0
  397. package/dist/core/engine/ledger/place.d.ts +75 -0
  398. package/dist/core/engine/ledger/place.d.ts.map +1 -0
  399. package/dist/core/engine/ledger/place.js +174 -0
  400. package/dist/core/engine/ledger/place.js.map +1 -0
  401. package/dist/core/engine/ledger/positions.d.ts +68 -0
  402. package/dist/core/engine/ledger/positions.d.ts.map +1 -0
  403. package/dist/core/engine/ledger/positions.js +114 -0
  404. package/dist/core/engine/ledger/positions.js.map +1 -0
  405. package/dist/core/engine/ledger/refuse.d.ts +43 -0
  406. package/dist/core/engine/ledger/refuse.d.ts.map +1 -0
  407. package/dist/core/engine/ledger/refuse.js +329 -0
  408. package/dist/core/engine/ledger/refuse.js.map +1 -0
  409. package/dist/core/engine/ledger/row.d.ts +176 -0
  410. package/dist/core/engine/ledger/row.d.ts.map +1 -0
  411. package/dist/core/engine/ledger/row.js +169 -0
  412. package/dist/core/engine/ledger/row.js.map +1 -0
  413. package/dist/core/engine/ledger/sizing.d.ts +142 -0
  414. package/dist/core/engine/ledger/sizing.d.ts.map +1 -0
  415. package/dist/core/engine/ledger/sizing.js +223 -0
  416. package/dist/core/engine/ledger/sizing.js.map +1 -0
  417. package/dist/core/engine/library/arrays.d.ts +14 -0
  418. package/dist/core/engine/library/arrays.d.ts.map +1 -0
  419. package/dist/core/engine/library/arrays.js +285 -0
  420. package/dist/core/engine/library/arrays.js.map +1 -0
  421. package/dist/core/engine/library/averages.d.ts +9 -0
  422. package/dist/core/engine/library/averages.d.ts.map +1 -0
  423. package/dist/core/engine/library/averages.js +41 -0
  424. package/dist/core/engine/library/averages.js.map +1 -0
  425. package/dist/core/engine/library/binding.d.ts +230 -0
  426. package/dist/core/engine/library/binding.d.ts.map +1 -0
  427. package/dist/core/engine/library/binding.js +109 -0
  428. package/dist/core/engine/library/binding.js.map +1 -0
  429. package/dist/core/engine/library/chart.d.ts +3 -0
  430. package/dist/core/engine/library/chart.d.ts.map +1 -0
  431. package/dist/core/engine/library/chart.js +83 -0
  432. package/dist/core/engine/library/chart.js.map +1 -0
  433. package/dist/core/engine/library/colours.d.ts +26 -0
  434. package/dist/core/engine/library/colours.d.ts.map +1 -0
  435. package/dist/core/engine/library/colours.js +81 -0
  436. package/dist/core/engine/library/colours.js.map +1 -0
  437. package/dist/core/engine/library/dates.d.ts +3 -0
  438. package/dist/core/engine/library/dates.d.ts.map +1 -0
  439. package/dist/core/engine/library/dates.js +75 -0
  440. package/dist/core/engine/library/dates.js.map +1 -0
  441. package/dist/core/engine/library/index.d.ts +13 -0
  442. package/dist/core/engine/library/index.d.ts.map +1 -0
  443. package/dist/core/engine/library/index.js +86 -0
  444. package/dist/core/engine/library/index.js.map +1 -0
  445. package/dist/core/engine/library/maths.d.ts +3 -0
  446. package/dist/core/engine/library/maths.d.ts.map +1 -0
  447. package/dist/core/engine/library/maths.js +89 -0
  448. package/dist/core/engine/library/maths.js.map +1 -0
  449. package/dist/core/engine/library/objects.d.ts +3 -0
  450. package/dist/core/engine/library/objects.d.ts.map +1 -0
  451. package/dist/core/engine/library/objects.js +199 -0
  452. package/dist/core/engine/library/objects.js.map +1 -0
  453. package/dist/core/engine/library/oscillators.d.ts +3 -0
  454. package/dist/core/engine/library/oscillators.d.ts.map +1 -0
  455. package/dist/core/engine/library/oscillators.js +29 -0
  456. package/dist/core/engine/library/oscillators.js.map +1 -0
  457. package/dist/core/engine/library/ranges.d.ts +3 -0
  458. package/dist/core/engine/library/ranges.d.ts.map +1 -0
  459. package/dist/core/engine/library/ranges.js +23 -0
  460. package/dist/core/engine/library/ranges.js.map +1 -0
  461. package/dist/core/engine/library/series.d.ts +3 -0
  462. package/dist/core/engine/library/series.d.ts.map +1 -0
  463. package/dist/core/engine/library/series.js +46 -0
  464. package/dist/core/engine/library/series.js.map +1 -0
  465. package/dist/core/engine/library/state.d.ts +35 -0
  466. package/dist/core/engine/library/state.d.ts.map +1 -0
  467. package/dist/core/engine/library/state.js +19 -0
  468. package/dist/core/engine/library/state.js.map +1 -0
  469. package/dist/core/engine/library/studies.d.ts +3 -0
  470. package/dist/core/engine/library/studies.d.ts.map +1 -0
  471. package/dist/core/engine/library/studies.js +35 -0
  472. package/dist/core/engine/library/studies.js.map +1 -0
  473. package/dist/core/engine/library/text.d.ts +6 -0
  474. package/dist/core/engine/library/text.d.ts.map +1 -0
  475. package/dist/core/engine/library/text.js +280 -0
  476. package/dist/core/engine/library/text.js.map +1 -0
  477. package/dist/core/engine/library/trend.d.ts +3 -0
  478. package/dist/core/engine/library/trend.d.ts.map +1 -0
  479. package/dist/core/engine/library/trend.js +29 -0
  480. package/dist/core/engine/library/trend.js.map +1 -0
  481. package/dist/core/engine/library/volume.d.ts +3 -0
  482. package/dist/core/engine/library/volume.d.ts.map +1 -0
  483. package/dist/core/engine/library/volume.js +51 -0
  484. package/dist/core/engine/library/volume.js.map +1 -0
  485. package/dist/core/engine/load.d.ts +45 -0
  486. package/dist/core/engine/load.d.ts.map +1 -0
  487. package/dist/core/engine/load.js +60 -0
  488. package/dist/core/engine/load.js.map +1 -0
  489. package/dist/core/engine/machine.d.ts +107 -0
  490. package/dist/core/engine/machine.d.ts.map +1 -0
  491. package/dist/core/engine/machine.js +337 -0
  492. package/dist/core/engine/machine.js.map +1 -0
  493. package/dist/core/engine/memory.d.ts +60 -0
  494. package/dist/core/engine/memory.d.ts.map +1 -0
  495. package/dist/core/engine/memory.js +92 -0
  496. package/dist/core/engine/memory.js.map +1 -0
  497. package/dist/core/engine/operations.d.ts +62 -0
  498. package/dist/core/engine/operations.d.ts.map +1 -0
  499. package/dist/core/engine/operations.js +149 -0
  500. package/dist/core/engine/operations.js.map +1 -0
  501. package/dist/core/engine/orders.d.ts +56 -0
  502. package/dist/core/engine/orders.d.ts.map +1 -0
  503. package/dist/core/engine/orders.js +83 -0
  504. package/dist/core/engine/orders.js.map +1 -0
  505. package/dist/core/engine/registers.d.ts +50 -0
  506. package/dist/core/engine/registers.d.ts.map +1 -0
  507. package/dist/core/engine/registers.js +85 -0
  508. package/dist/core/engine/registers.js.map +1 -0
  509. package/dist/core/engine/request-body.d.ts +138 -0
  510. package/dist/core/engine/request-body.d.ts.map +1 -0
  511. package/dist/core/engine/request-body.js +227 -0
  512. package/dist/core/engine/request-body.js.map +1 -0
  513. package/dist/core/engine/request-plan.d.ts +79 -0
  514. package/dist/core/engine/request-plan.d.ts.map +1 -0
  515. package/dist/core/engine/request-plan.js +228 -0
  516. package/dist/core/engine/request-plan.js.map +1 -0
  517. package/dist/core/engine/requests.d.ts +105 -0
  518. package/dist/core/engine/requests.d.ts.map +1 -0
  519. package/dist/core/engine/requests.js +260 -0
  520. package/dist/core/engine/requests.js.map +1 -0
  521. package/dist/core/engine/results.d.ts +40 -0
  522. package/dist/core/engine/results.d.ts.map +1 -0
  523. package/dist/core/engine/results.js +2 -0
  524. package/dist/core/engine/results.js.map +1 -0
  525. package/dist/core/engine/series.d.ts +61 -0
  526. package/dist/core/engine/series.d.ts.map +1 -0
  527. package/dist/core/engine/series.js +41 -0
  528. package/dist/core/engine/series.js.map +1 -0
  529. package/dist/core/engine/session/hours.d.ts +49 -0
  530. package/dist/core/engine/session/hours.d.ts.map +1 -0
  531. package/dist/core/engine/session/hours.js +31 -0
  532. package/dist/core/engine/session/hours.js.map +1 -0
  533. package/dist/core/engine/session/index.d.ts +17 -0
  534. package/dist/core/engine/session/index.d.ts.map +1 -0
  535. package/dist/core/engine/session/index.js +3 -0
  536. package/dist/core/engine/session/index.js.map +1 -0
  537. package/dist/core/engine/session/record.d.ts +56 -0
  538. package/dist/core/engine/session/record.d.ts.map +1 -0
  539. package/dist/core/engine/session/record.js +165 -0
  540. package/dist/core/engine/session/record.js.map +1 -0
  541. package/dist/core/engine/session/spec.d.ts +19 -0
  542. package/dist/core/engine/session/spec.d.ts.map +1 -0
  543. package/dist/core/engine/session/spec.js +31 -0
  544. package/dist/core/engine/session/spec.js.map +1 -0
  545. package/dist/core/engine/timeframe.d.ts +59 -0
  546. package/dist/core/engine/timeframe.d.ts.map +1 -0
  547. package/dist/core/engine/timeframe.js +140 -0
  548. package/dist/core/engine/timeframe.js.map +1 -0
  549. package/dist/core/engine/types.d.ts +15 -0
  550. package/dist/core/engine/types.d.ts.map +1 -0
  551. package/dist/core/engine/types.js +2 -0
  552. package/dist/core/engine/types.js.map +1 -0
  553. package/dist/core/engine/values/heap.d.ts +134 -0
  554. package/dist/core/engine/values/heap.d.ts.map +1 -0
  555. package/dist/core/engine/values/heap.js +230 -0
  556. package/dist/core/engine/values/heap.js.map +1 -0
  557. package/dist/core/engine/values/index.d.ts +13 -0
  558. package/dist/core/engine/values/index.d.ts.map +1 -0
  559. package/dist/core/engine/values/index.js +3 -0
  560. package/dist/core/engine/values/index.js.map +1 -0
  561. package/dist/core/engine/values/value.d.ts +82 -0
  562. package/dist/core/engine/values/value.d.ts.map +1 -0
  563. package/dist/core/engine/values/value.js +134 -0
  564. package/dist/core/engine/values/value.js.map +1 -0
  565. package/dist/core/engine/verify-budgets.d.ts +35 -0
  566. package/dist/core/engine/verify-budgets.d.ts.map +1 -0
  567. package/dist/core/engine/verify-budgets.js +172 -0
  568. package/dist/core/engine/verify-budgets.js.map +1 -0
  569. package/dist/core/engine/verify-code.d.ts +32 -0
  570. package/dist/core/engine/verify-code.d.ts.map +1 -0
  571. package/dist/core/engine/verify-code.js +278 -0
  572. package/dist/core/engine/verify-code.js.map +1 -0
  573. package/dist/core/engine/verify-requests.d.ts +44 -0
  574. package/dist/core/engine/verify-requests.d.ts.map +1 -0
  575. package/dist/core/engine/verify-requests.js +220 -0
  576. package/dist/core/engine/verify-requests.js.map +1 -0
  577. package/dist/core/engine/verify-shape.d.ts +46 -0
  578. package/dist/core/engine/verify-shape.d.ts.map +1 -0
  579. package/dist/core/engine/verify-shape.js +147 -0
  580. package/dist/core/engine/verify-shape.js.map +1 -0
  581. package/dist/core/engine/verify-tables.d.ts +19 -0
  582. package/dist/core/engine/verify-tables.d.ts.map +1 -0
  583. package/dist/core/engine/verify-tables.js +171 -0
  584. package/dist/core/engine/verify-tables.js.map +1 -0
  585. package/dist/core/engine/verify.d.ts +19 -0
  586. package/dist/core/engine/verify.d.ts.map +1 -0
  587. package/dist/core/engine/verify.js +309 -0
  588. package/dist/core/engine/verify.js.map +1 -0
  589. package/dist/core/index.d.ts +61 -6
  590. package/dist/core/index.d.ts.map +1 -1
  591. package/dist/core/index.js +48 -6
  592. package/dist/core/index.js.map +1 -1
  593. package/dist/core/parse/expressions.js +1 -1
  594. package/dist/core/parse/expressions.js.map +1 -1
  595. package/dist/core/parse/names.d.ts +7 -1
  596. package/dist/core/parse/names.d.ts.map +1 -1
  597. package/dist/core/parse/names.js +28 -2
  598. package/dist/core/parse/names.js.map +1 -1
  599. package/dist/core/stdlib/averages/exponential.d.ts +51 -0
  600. package/dist/core/stdlib/averages/exponential.d.ts.map +1 -0
  601. package/dist/core/stdlib/averages/exponential.js +72 -0
  602. package/dist/core/stdlib/averages/exponential.js.map +1 -0
  603. package/dist/core/stdlib/averages/index.d.ts +7 -0
  604. package/dist/core/stdlib/averages/index.d.ts.map +1 -0
  605. package/dist/core/stdlib/averages/index.js +5 -0
  606. package/dist/core/stdlib/averages/index.js.map +1 -0
  607. package/dist/core/stdlib/averages/select.d.ts +35 -0
  608. package/dist/core/stdlib/averages/select.d.ts.map +1 -0
  609. package/dist/core/stdlib/averages/select.js +43 -0
  610. package/dist/core/stdlib/averages/select.js.map +1 -0
  611. package/dist/core/stdlib/averages/shaped.d.ts +61 -0
  612. package/dist/core/stdlib/averages/shaped.d.ts.map +1 -0
  613. package/dist/core/stdlib/averages/shaped.js +126 -0
  614. package/dist/core/stdlib/averages/shaped.js.map +1 -0
  615. package/dist/core/stdlib/averages/simple.d.ts +58 -0
  616. package/dist/core/stdlib/averages/simple.d.ts.map +1 -0
  617. package/dist/core/stdlib/averages/simple.js +92 -0
  618. package/dist/core/stdlib/averages/simple.js.map +1 -0
  619. package/dist/core/stdlib/calendar/civil.d.ts +56 -0
  620. package/dist/core/stdlib/calendar/civil.d.ts.map +1 -0
  621. package/dist/core/stdlib/calendar/civil.js +70 -0
  622. package/dist/core/stdlib/calendar/civil.js.map +1 -0
  623. package/dist/core/stdlib/calendar/fields.d.ts +36 -0
  624. package/dist/core/stdlib/calendar/fields.d.ts.map +1 -0
  625. package/dist/core/stdlib/calendar/fields.js +93 -0
  626. package/dist/core/stdlib/calendar/fields.js.map +1 -0
  627. package/dist/core/stdlib/calendar/format.d.ts +19 -0
  628. package/dist/core/stdlib/calendar/format.d.ts.map +1 -0
  629. package/dist/core/stdlib/calendar/format.js +51 -0
  630. package/dist/core/stdlib/calendar/format.js.map +1 -0
  631. package/dist/core/stdlib/calendar/index.d.ts +7 -0
  632. package/dist/core/stdlib/calendar/index.d.ts.map +1 -0
  633. package/dist/core/stdlib/calendar/index.js +5 -0
  634. package/dist/core/stdlib/calendar/index.js.map +1 -0
  635. package/dist/core/stdlib/calendar/zone.d.ts +53 -0
  636. package/dist/core/stdlib/calendar/zone.d.ts.map +1 -0
  637. package/dist/core/stdlib/calendar/zone.js +138 -0
  638. package/dist/core/stdlib/calendar/zone.js.map +1 -0
  639. package/dist/core/stdlib/index.d.ts +57 -0
  640. package/dist/core/stdlib/index.d.ts.map +1 -0
  641. package/dist/core/stdlib/index.js +51 -0
  642. package/dist/core/stdlib/index.js.map +1 -0
  643. package/dist/core/stdlib/maths/arithmetic.d.ts +38 -0
  644. package/dist/core/stdlib/maths/arithmetic.d.ts.map +1 -0
  645. package/dist/core/stdlib/maths/arithmetic.js +66 -0
  646. package/dist/core/stdlib/maths/arithmetic.js.map +1 -0
  647. package/dist/core/stdlib/maths/elementary.d.ts +65 -0
  648. package/dist/core/stdlib/maths/elementary.d.ts.map +1 -0
  649. package/dist/core/stdlib/maths/elementary.js +93 -0
  650. package/dist/core/stdlib/maths/elementary.js.map +1 -0
  651. package/dist/core/stdlib/maths/index.d.ts +4 -0
  652. package/dist/core/stdlib/maths/index.d.ts.map +1 -0
  653. package/dist/core/stdlib/maths/index.js +4 -0
  654. package/dist/core/stdlib/maths/index.js.map +1 -0
  655. package/dist/core/stdlib/maths/rounding.d.ts +43 -0
  656. package/dist/core/stdlib/maths/rounding.d.ts.map +1 -0
  657. package/dist/core/stdlib/maths/rounding.js +62 -0
  658. package/dist/core/stdlib/maths/rounding.js.map +1 -0
  659. package/dist/core/stdlib/momentum/convergence.d.ts +36 -0
  660. package/dist/core/stdlib/momentum/convergence.d.ts.map +1 -0
  661. package/dist/core/stdlib/momentum/convergence.js +48 -0
  662. package/dist/core/stdlib/momentum/convergence.js.map +1 -0
  663. package/dist/core/stdlib/momentum/index.d.ts +6 -0
  664. package/dist/core/stdlib/momentum/index.d.ts.map +1 -0
  665. package/dist/core/stdlib/momentum/index.js +6 -0
  666. package/dist/core/stdlib/momentum/index.js.map +1 -0
  667. package/dist/core/stdlib/momentum/pressure.d.ts +43 -0
  668. package/dist/core/stdlib/momentum/pressure.d.ts.map +1 -0
  669. package/dist/core/stdlib/momentum/pressure.js +103 -0
  670. package/dist/core/stdlib/momentum/pressure.js.map +1 -0
  671. package/dist/core/stdlib/momentum/rates.d.ts +74 -0
  672. package/dist/core/stdlib/momentum/rates.d.ts.map +1 -0
  673. package/dist/core/stdlib/momentum/rates.js +134 -0
  674. package/dist/core/stdlib/momentum/rates.js.map +1 -0
  675. package/dist/core/stdlib/momentum/rsi.d.ts +21 -0
  676. package/dist/core/stdlib/momentum/rsi.d.ts.map +1 -0
  677. package/dist/core/stdlib/momentum/rsi.js +30 -0
  678. package/dist/core/stdlib/momentum/rsi.js.map +1 -0
  679. package/dist/core/stdlib/momentum/stochastic.d.ts +44 -0
  680. package/dist/core/stdlib/momentum/stochastic.d.ts.map +1 -0
  681. package/dist/core/stdlib/momentum/stochastic.js +97 -0
  682. package/dist/core/stdlib/momentum/stochastic.js.map +1 -0
  683. package/dist/core/stdlib/series/changes.d.ts +59 -0
  684. package/dist/core/stdlib/series/changes.d.ts.map +1 -0
  685. package/dist/core/stdlib/series/changes.js +129 -0
  686. package/dist/core/stdlib/series/changes.js.map +1 -0
  687. package/dist/core/stdlib/series/conditions.d.ts +34 -0
  688. package/dist/core/stdlib/series/conditions.d.ts.map +1 -0
  689. package/dist/core/stdlib/series/conditions.js +52 -0
  690. package/dist/core/stdlib/series/conditions.js.map +1 -0
  691. package/dist/core/stdlib/series/extremes.d.ts +29 -0
  692. package/dist/core/stdlib/series/extremes.d.ts.map +1 -0
  693. package/dist/core/stdlib/series/extremes.js +62 -0
  694. package/dist/core/stdlib/series/extremes.js.map +1 -0
  695. package/dist/core/stdlib/series/index.d.ts +9 -0
  696. package/dist/core/stdlib/series/index.d.ts.map +1 -0
  697. package/dist/core/stdlib/series/index.js +7 -0
  698. package/dist/core/stdlib/series/index.js.map +1 -0
  699. package/dist/core/stdlib/series/pivots.d.ts +25 -0
  700. package/dist/core/stdlib/series/pivots.d.ts.map +1 -0
  701. package/dist/core/stdlib/series/pivots.js +42 -0
  702. package/dist/core/stdlib/series/pivots.js.map +1 -0
  703. package/dist/core/stdlib/series/statistics.d.ts +64 -0
  704. package/dist/core/stdlib/series/statistics.d.ts.map +1 -0
  705. package/dist/core/stdlib/series/statistics.js +148 -0
  706. package/dist/core/stdlib/series/statistics.js.map +1 -0
  707. package/dist/core/stdlib/series/totals.d.ts +68 -0
  708. package/dist/core/stdlib/series/totals.d.ts.map +1 -0
  709. package/dist/core/stdlib/series/totals.js +115 -0
  710. package/dist/core/stdlib/series/totals.js.map +1 -0
  711. package/dist/core/stdlib/trend/directional.d.ts +69 -0
  712. package/dist/core/stdlib/trend/directional.d.ts.map +1 -0
  713. package/dist/core/stdlib/trend/directional.js +151 -0
  714. package/dist/core/stdlib/trend/directional.js.map +1 -0
  715. package/dist/core/stdlib/trend/index.d.ts +4 -0
  716. package/dist/core/stdlib/trend/index.d.ts.map +1 -0
  717. package/dist/core/stdlib/trend/index.js +4 -0
  718. package/dist/core/stdlib/trend/index.js.map +1 -0
  719. package/dist/core/stdlib/trend/psar.d.ts +33 -0
  720. package/dist/core/stdlib/trend/psar.d.ts.map +1 -0
  721. package/dist/core/stdlib/trend/psar.js +86 -0
  722. package/dist/core/stdlib/trend/psar.js.map +1 -0
  723. package/dist/core/stdlib/trend/supertrend.d.ts +30 -0
  724. package/dist/core/stdlib/trend/supertrend.d.ts.map +1 -0
  725. package/dist/core/stdlib/trend/supertrend.js +65 -0
  726. package/dist/core/stdlib/trend/supertrend.js.map +1 -0
  727. package/dist/core/stdlib/values/bar.d.ts +39 -0
  728. package/dist/core/stdlib/values/bar.d.ts.map +1 -0
  729. package/dist/core/stdlib/values/bar.js +33 -0
  730. package/dist/core/stdlib/values/bar.js.map +1 -0
  731. package/dist/core/stdlib/values/index.d.ts +11 -0
  732. package/dist/core/stdlib/values/index.d.ts.map +1 -0
  733. package/dist/core/stdlib/values/index.js +6 -0
  734. package/dist/core/stdlib/values/index.js.map +1 -0
  735. package/dist/core/stdlib/values/lookback.d.ts +83 -0
  736. package/dist/core/stdlib/values/lookback.d.ts.map +1 -0
  737. package/dist/core/stdlib/values/lookback.js +134 -0
  738. package/dist/core/stdlib/values/lookback.js.map +1 -0
  739. package/dist/core/stdlib/values/region.d.ts +55 -0
  740. package/dist/core/stdlib/values/region.d.ts.map +1 -0
  741. package/dist/core/stdlib/values/region.js +73 -0
  742. package/dist/core/stdlib/values/region.js.map +1 -0
  743. package/dist/core/stdlib/values/tail.d.ts +44 -0
  744. package/dist/core/stdlib/values/tail.d.ts.map +1 -0
  745. package/dist/core/stdlib/values/tail.js +23 -0
  746. package/dist/core/stdlib/values/tail.js.map +1 -0
  747. package/dist/core/stdlib/values/value.d.ts +64 -0
  748. package/dist/core/stdlib/values/value.d.ts.map +1 -0
  749. package/dist/core/stdlib/values/value.js +61 -0
  750. package/dist/core/stdlib/values/value.js.map +1 -0
  751. package/dist/core/stdlib/volatility/bands.d.ts +50 -0
  752. package/dist/core/stdlib/volatility/bands.d.ts.map +1 -0
  753. package/dist/core/stdlib/volatility/bands.js +101 -0
  754. package/dist/core/stdlib/volatility/bands.js.map +1 -0
  755. package/dist/core/stdlib/volatility/deviation.d.ts +43 -0
  756. package/dist/core/stdlib/volatility/deviation.d.ts.map +1 -0
  757. package/dist/core/stdlib/volatility/deviation.js +75 -0
  758. package/dist/core/stdlib/volatility/deviation.js.map +1 -0
  759. package/dist/core/stdlib/volatility/index.d.ts +6 -0
  760. package/dist/core/stdlib/volatility/index.d.ts.map +1 -0
  761. package/dist/core/stdlib/volatility/index.js +5 -0
  762. package/dist/core/stdlib/volatility/index.js.map +1 -0
  763. package/dist/core/stdlib/volatility/measures.d.ts +48 -0
  764. package/dist/core/stdlib/volatility/measures.d.ts.map +1 -0
  765. package/dist/core/stdlib/volatility/measures.js +73 -0
  766. package/dist/core/stdlib/volatility/measures.js.map +1 -0
  767. package/dist/core/stdlib/volatility/range.d.ts +69 -0
  768. package/dist/core/stdlib/volatility/range.d.ts.map +1 -0
  769. package/dist/core/stdlib/volatility/range.js +86 -0
  770. package/dist/core/stdlib/volatility/range.js.map +1 -0
  771. package/dist/core/stdlib/volume/accumulation.d.ts +61 -0
  772. package/dist/core/stdlib/volume/accumulation.d.ts.map +1 -0
  773. package/dist/core/stdlib/volume/accumulation.js +127 -0
  774. package/dist/core/stdlib/volume/accumulation.js.map +1 -0
  775. package/dist/core/stdlib/volume/flow.d.ts +60 -0
  776. package/dist/core/stdlib/volume/flow.d.ts.map +1 -0
  777. package/dist/core/stdlib/volume/flow.js +125 -0
  778. package/dist/core/stdlib/volume/flow.js.map +1 -0
  779. package/dist/core/stdlib/volume/index.d.ts +5 -0
  780. package/dist/core/stdlib/volume/index.d.ts.map +1 -0
  781. package/dist/core/stdlib/volume/index.js +4 -0
  782. package/dist/core/stdlib/volume/index.js.map +1 -0
  783. package/dist/core/stdlib/volume/weighted.d.ts +52 -0
  784. package/dist/core/stdlib/volume/weighted.d.ts.map +1 -0
  785. package/dist/core/stdlib/volume/weighted.js +64 -0
  786. package/dist/core/stdlib/volume/weighted.js.map +1 -0
  787. package/dist/core/version/version.generated.d.ts +2 -2
  788. package/dist/core/version/version.generated.d.ts.map +1 -1
  789. package/dist/core/version/version.generated.js +2 -2
  790. package/dist/core/version/version.generated.js.map +1 -1
  791. package/package.json +38 -14
  792. package/spec/errors.json +382 -183
  793. package/src/adapters/charts/alerts.ts +116 -0
  794. package/src/adapters/charts/bars.ts +63 -0
  795. package/src/adapters/charts/candles.ts +137 -0
  796. package/src/adapters/charts/colours.ts +113 -0
  797. package/src/adapters/charts/columns.ts +99 -0
  798. package/src/adapters/charts/contract.ts +320 -0
  799. package/src/adapters/charts/descriptor.ts +199 -0
  800. package/src/adapters/charts/drawings.ts +213 -0
  801. package/src/adapters/charts/errors.ts +45 -0
  802. package/src/adapters/charts/fields.ts +74 -0
  803. package/src/adapters/charts/fills.ts +71 -0
  804. package/src/adapters/charts/index.ts +78 -0
  805. package/src/adapters/charts/levels.ts +92 -0
  806. package/src/adapters/charts/markers.ts +119 -0
  807. package/src/adapters/charts/paint.ts +101 -0
  808. package/src/adapters/charts/plots.ts +185 -0
  809. package/src/adapters/charts/produced.ts +68 -0
  810. package/src/adapters/charts/requests.ts +357 -0
  811. package/src/adapters/charts/run.ts +327 -0
  812. package/src/adapters/charts/settings.ts +273 -0
  813. package/src/adapters/charts/surfaces.ts +238 -0
  814. package/src/adapters/charts/tables.ts +155 -0
  815. package/src/core/catalogue/catalogue.generated.ts +17 -9
  816. package/src/core/catalogue/values.generated.ts +8 -0
  817. package/src/core/check/arguments.ts +126 -0
  818. package/src/core/check/call-sites.ts +385 -0
  819. package/src/core/check/call-warmup.ts +121 -0
  820. package/src/core/check/calls.ts +412 -0
  821. package/src/core/check/check.ts +183 -0
  822. package/src/core/check/checked.ts +228 -0
  823. package/src/core/check/checker.ts +393 -0
  824. package/src/core/check/conditional.ts +143 -0
  825. package/src/core/check/constant.ts +127 -0
  826. package/src/core/check/declaration.ts +230 -0
  827. package/src/core/check/expressions.ts +471 -0
  828. package/src/core/check/functions.ts +283 -0
  829. package/src/core/check/handles.ts +75 -0
  830. package/src/core/check/index.ts +67 -0
  831. package/src/core/check/library-bars.ts +194 -0
  832. package/src/core/check/library-orders.ts +290 -0
  833. package/src/core/check/library-output.ts +241 -0
  834. package/src/core/check/library-series.ts +457 -0
  835. package/src/core/check/library.ts +374 -0
  836. package/src/core/check/literals.ts +35 -0
  837. package/src/core/check/outputs.ts +152 -0
  838. package/src/core/check/statements.ts +465 -0
  839. package/src/core/check/suggest.ts +63 -0
  840. package/src/core/check/surface.ts +115 -0
  841. package/src/core/check/tags.ts +94 -0
  842. package/src/core/check/types.ts +260 -0
  843. package/src/core/check/warmup.ts +100 -0
  844. package/src/core/diagnostics/collector.ts +27 -1
  845. package/src/core/emit/calls.ts +415 -0
  846. package/src/core/emit/canonical.ts +81 -0
  847. package/src/core/emit/channels.ts +144 -0
  848. package/src/core/emit/code.ts +155 -0
  849. package/src/core/emit/colours.ts +75 -0
  850. package/src/core/emit/context.ts +461 -0
  851. package/src/core/emit/defaults.ts +150 -0
  852. package/src/core/emit/emit.ts +313 -0
  853. package/src/core/emit/events.ts +141 -0
  854. package/src/core/emit/expressions.ts +292 -0
  855. package/src/core/emit/functions.ts +195 -0
  856. package/src/core/emit/gaps.ts +44 -0
  857. package/src/core/emit/index.ts +74 -0
  858. package/src/core/emit/inputs.ts +179 -0
  859. package/src/core/emit/layout.ts +165 -0
  860. package/src/core/emit/meta.ts +104 -0
  861. package/src/core/emit/opcodes.ts +160 -0
  862. package/src/core/emit/outputs.ts +357 -0
  863. package/src/core/emit/pool.ts +102 -0
  864. package/src/core/emit/program.ts +385 -0
  865. package/src/core/emit/registers.ts +179 -0
  866. package/src/core/emit/request-scope.ts +52 -0
  867. package/src/core/emit/requests.ts +258 -0
  868. package/src/core/emit/requires.ts +91 -0
  869. package/src/core/emit/sha256.ts +119 -0
  870. package/src/core/emit/statements.ts +438 -0
  871. package/src/core/emit/values.ts +284 -0
  872. package/src/core/engine/alerts.ts +152 -0
  873. package/src/core/engine/arithmetic.ts +165 -0
  874. package/src/core/engine/bars.ts +224 -0
  875. package/src/core/engine/budget.ts +284 -0
  876. package/src/core/engine/channels.ts +171 -0
  877. package/src/core/engine/drawings.ts +127 -0
  878. package/src/core/engine/engine.ts +498 -0
  879. package/src/core/engine/errors.ts +100 -0
  880. package/src/core/engine/frames.ts +85 -0
  881. package/src/core/engine/grids.ts +98 -0
  882. package/src/core/engine/guard.ts +71 -0
  883. package/src/core/engine/host.ts +251 -0
  884. package/src/core/engine/index.ts +93 -0
  885. package/src/core/engine/inputs.ts +263 -0
  886. package/src/core/engine/ledger/call.ts +218 -0
  887. package/src/core/engine/ledger/closable.ts +269 -0
  888. package/src/core/engine/ledger/holdings.ts +354 -0
  889. package/src/core/engine/ledger/index.ts +28 -0
  890. package/src/core/engine/ledger/intent.ts +112 -0
  891. package/src/core/engine/ledger/ledger.ts +314 -0
  892. package/src/core/engine/ledger/place.ts +277 -0
  893. package/src/core/engine/ledger/positions.ts +123 -0
  894. package/src/core/engine/ledger/refuse.ts +378 -0
  895. package/src/core/engine/ledger/row.ts +318 -0
  896. package/src/core/engine/ledger/sizing.ts +292 -0
  897. package/src/core/engine/library/arrays.ts +316 -0
  898. package/src/core/engine/library/averages.ts +97 -0
  899. package/src/core/engine/library/binding.ts +325 -0
  900. package/src/core/engine/library/chart.ts +115 -0
  901. package/src/core/engine/library/colours.ts +111 -0
  902. package/src/core/engine/library/dates.ts +109 -0
  903. package/src/core/engine/library/index.ts +103 -0
  904. package/src/core/engine/library/maths.ts +134 -0
  905. package/src/core/engine/library/objects.ts +265 -0
  906. package/src/core/engine/library/oscillators.ts +124 -0
  907. package/src/core/engine/library/ranges.ts +51 -0
  908. package/src/core/engine/library/series.ts +236 -0
  909. package/src/core/engine/library/state.ts +47 -0
  910. package/src/core/engine/library/studies.ts +150 -0
  911. package/src/core/engine/library/text.ts +303 -0
  912. package/src/core/engine/library/trend.ts +79 -0
  913. package/src/core/engine/library/volume.ts +101 -0
  914. package/src/core/engine/load.ts +104 -0
  915. package/src/core/engine/machine.ts +446 -0
  916. package/src/core/engine/memory.ts +129 -0
  917. package/src/core/engine/operations.ts +171 -0
  918. package/src/core/engine/orders.ts +121 -0
  919. package/src/core/engine/registers.ts +104 -0
  920. package/src/core/engine/request-body.ts +328 -0
  921. package/src/core/engine/request-plan.ts +270 -0
  922. package/src/core/engine/requests.ts +382 -0
  923. package/src/core/engine/results.ts +41 -0
  924. package/src/core/engine/series.ts +82 -0
  925. package/src/core/engine/session/hours.ts +86 -0
  926. package/src/core/engine/session/index.ts +17 -0
  927. package/src/core/engine/session/record.ts +191 -0
  928. package/src/core/engine/session/spec.ts +45 -0
  929. package/src/core/engine/timeframe.ts +161 -0
  930. package/src/core/engine/types.ts +47 -0
  931. package/src/core/engine/values/heap.ts +295 -0
  932. package/src/core/engine/values/index.ts +34 -0
  933. package/src/core/engine/values/value.ts +158 -0
  934. package/src/core/engine/verify-budgets.ts +202 -0
  935. package/src/core/engine/verify-code.ts +332 -0
  936. package/src/core/engine/verify-requests.ts +255 -0
  937. package/src/core/engine/verify-shape.ts +164 -0
  938. package/src/core/engine/verify-tables.ts +176 -0
  939. package/src/core/engine/verify.ts +341 -0
  940. package/src/core/index.ts +128 -6
  941. package/src/core/parse/expressions.ts +1 -1
  942. package/src/core/parse/names.ts +29 -2
  943. package/src/core/stdlib/averages/exponential.ts +119 -0
  944. package/src/core/stdlib/averages/index.ts +45 -0
  945. package/src/core/stdlib/averages/select.ts +71 -0
  946. package/src/core/stdlib/averages/shaped.ts +161 -0
  947. package/src/core/stdlib/averages/simple.ts +139 -0
  948. package/src/core/stdlib/calendar/civil.ts +89 -0
  949. package/src/core/stdlib/calendar/fields.ts +124 -0
  950. package/src/core/stdlib/calendar/format.ts +71 -0
  951. package/src/core/stdlib/calendar/index.ts +15 -0
  952. package/src/core/stdlib/calendar/zone.ts +161 -0
  953. package/src/core/stdlib/index.ts +400 -0
  954. package/src/core/stdlib/maths/arithmetic.ts +74 -0
  955. package/src/core/stdlib/maths/elementary.ts +124 -0
  956. package/src/core/stdlib/maths/index.ts +43 -0
  957. package/src/core/stdlib/maths/rounding.ts +78 -0
  958. package/src/core/stdlib/momentum/convergence.ts +82 -0
  959. package/src/core/stdlib/momentum/index.ts +47 -0
  960. package/src/core/stdlib/momentum/pressure.ts +141 -0
  961. package/src/core/stdlib/momentum/rates.ts +188 -0
  962. package/src/core/stdlib/momentum/rsi.ts +49 -0
  963. package/src/core/stdlib/momentum/stochastic.ts +147 -0
  964. package/src/core/stdlib/series/changes.ts +177 -0
  965. package/src/core/stdlib/series/conditions.ts +74 -0
  966. package/src/core/stdlib/series/extremes.ts +92 -0
  967. package/src/core/stdlib/series/index.ts +83 -0
  968. package/src/core/stdlib/series/pivots.ts +63 -0
  969. package/src/core/stdlib/series/statistics.ts +207 -0
  970. package/src/core/stdlib/series/totals.ts +164 -0
  971. package/src/core/stdlib/trend/directional.ts +196 -0
  972. package/src/core/stdlib/trend/index.ts +13 -0
  973. package/src/core/stdlib/trend/psar.ts +131 -0
  974. package/src/core/stdlib/trend/supertrend.ts +100 -0
  975. package/src/core/stdlib/values/bar.ts +54 -0
  976. package/src/core/stdlib/values/index.ts +14 -0
  977. package/src/core/stdlib/values/lookback.ts +198 -0
  978. package/src/core/stdlib/values/region.ts +86 -0
  979. package/src/core/stdlib/values/tail.ts +58 -0
  980. package/src/core/stdlib/values/value.ts +82 -0
  981. package/src/core/stdlib/volatility/bands.ts +178 -0
  982. package/src/core/stdlib/volatility/deviation.ts +111 -0
  983. package/src/core/stdlib/volatility/index.ts +48 -0
  984. package/src/core/stdlib/volatility/measures.ts +96 -0
  985. package/src/core/stdlib/volatility/range.ts +143 -0
  986. package/src/core/stdlib/volume/accumulation.ts +152 -0
  987. package/src/core/stdlib/volume/flow.ts +173 -0
  988. package/src/core/stdlib/volume/index.ts +43 -0
  989. package/src/core/stdlib/volume/weighted.ts +101 -0
  990. package/src/core/version/version.generated.ts +2 -2
@@ -0,0 +1,382 @@
1
+ /**
2
+ * Higher timeframe and other instrument reads, folded onto the chart's bars.
3
+ *
4
+ * A read is an expression evaluated over a **different set of bars** than the
5
+ * chart's, whose value is then folded back onto the chart's. Two halves, and
6
+ * they are in two files: `request-body.ts` runs the expression once per
7
+ * requested bar, and this decides which requested bar each chart bar is allowed
8
+ * to see. The second half is where the off-by-one lives, so it is written as
9
+ * one comparison repeated three times rather than as three rules.
10
+ *
11
+ * **Bars in, buckets out.** Source bars are grouped by the bucket key of their
12
+ * open instant (`timeframe.ts`); a bucket becomes one requested bar. The source
13
+ * is the chart's own bars for a read of the chart's instrument, which is the
14
+ * read `host-interface.md` 5.1 says an engine can satisfy from what it already
15
+ * holds, and the host's answer for a read of another instrument, which it never
16
+ * can. One fold serves both, so the two kinds of read cannot drift apart.
17
+ *
18
+ * **The three modes differ in one thing: how far past the chart bar the fold is
19
+ * allowed to look.** Everything else about them is the same code.
20
+ *
21
+ * | Mode | Source bars it may consume | Value the chart bar takes |
22
+ * |---|---|---|
23
+ * | `"confirmed"` | Those opening at or before this chart bar | The last bucket that closed |
24
+ * | `"developing"` | Those opening at or before this chart bar | The bucket this bar is inside, so far |
25
+ * | `"lookahead"` | Those belonging to this bar's bucket or earlier | The bucket this bar is inside, in full |
26
+ *
27
+ * Read the middle column, because it is the repainting question written out.
28
+ * Confirmed and developing stop at the chart bar and can be computed live;
29
+ * lookahead reads past it, which is why it repaints on history permanently and
30
+ * by design, and why on the newest bucket, where there is nothing past the bar
31
+ * to read, it is the bucket so far and nothing better exists.
32
+ *
33
+ * **The boundary.** A bucket has begun on the first chart bar whose key is the
34
+ * new one, because a bar's open instant is what dates it. So a confirmed read
35
+ * steps to the closed bucket's value on the first chart bar of the next bucket,
36
+ * holds it across every bar inside that bucket including the last, and steps
37
+ * again on the first bar of the one after. The bar a bucket closes on still
38
+ * reads the bucket before it: at that bar's open, the bucket it is inside had
39
+ * not closed.
40
+ *
41
+ * **Warmup translates by arithmetic and not by a rule.** The expression runs on
42
+ * requested bars, so its own warmup is counted in requested bars and its absence
43
+ * folds onto the chart like any other value: a twenty period average of daily
44
+ * closes is absent until twenty daily bars exist, which on a five minute chart
45
+ * is about a month in. The `warmup` field of the compiled program is what a host
46
+ * extends the fetch range backwards by, a floor and not a promise, and an engine
47
+ * given less gets a read that is absent for longer rather than a wrong number.
48
+ */
49
+ import type { Span } from '../span/index.js';
50
+ import type { HostBar } from './bars.js';
51
+ import type { Clock, EngineLimits } from './budget.js';
52
+ import type { EngineHost } from './host.js';
53
+ import type { ResolvedInput } from './inputs.js';
54
+ import type { HostFacts, ManifestEntry, PositionFacts } from './library/index.js';
55
+ import type { Registers } from './registers.js';
56
+ import { RequestBody, bodyProgram } from './request-body.js';
57
+ import { askHost, reasonFor, undatable, undatableReason } from './request-plan.js';
58
+ import type { RequestPlan } from './request-plan.js';
59
+ import { bucketKeyOf } from './timeframe.js';
60
+ import type { CompiledProgram, Request } from './types.js';
61
+ import { ABSENT } from './values/index.js';
62
+ import type { Heap, Value } from './values/index.js';
63
+
64
+ export interface RequestParts {
65
+ readonly program: CompiledProgram;
66
+ /** Every read in the program, nested ones included, keyed by its own id. */
67
+ readonly plans: ReadonlyMap<number, RequestPlan>;
68
+ readonly host: EngineHost;
69
+ readonly limits: EngineLimits;
70
+ readonly clock: Clock | undefined;
71
+ readonly library: readonly ManifestEntry[];
72
+ readonly inputs: readonly ResolvedInput[];
73
+ /** The facts a body inherits, with its own identity written over three of them. */
74
+ readonly facts: HostFacts;
75
+ /** The strategy's own position, which a body reads as the chart's bars do. */
76
+ readonly position: PositionFacts;
77
+ /**
78
+ * The heap of the machine these reads land in, read when a bar asks for it.
79
+ *
80
+ * A function rather than the heap, because a read written inside another lands
81
+ * in the enclosing body's heap and that body does not exist until its own
82
+ * reads have been built.
83
+ */
84
+ heapOf(): Heap;
85
+ spanAt(line: number, column: number): Span;
86
+ }
87
+
88
+ /** Where the fold of one read stands, and what a re-executed bar restores. */
89
+ interface Mark {
90
+ readonly cursor: number;
91
+ readonly openKey: number | undefined;
92
+ readonly openFrom: number;
93
+ }
94
+
95
+ interface Read {
96
+ readonly plan: RequestPlan;
97
+ readonly register: number;
98
+ readonly body: RequestBody;
99
+ /** The host's bars for a `symbol` read, or nothing when the fold is the chart's. */
100
+ readonly source: readonly HostBar[] | undefined;
101
+ readonly ready: boolean;
102
+ readonly reason: string;
103
+ /** How far into the source the fold has read. */
104
+ cursor: number;
105
+ openKey: number | undefined;
106
+ /** Where in the source the bucket now forming began. */
107
+ openFrom: number;
108
+ open: HostBar | undefined;
109
+ /** The value of the most recently closed bucket, which a confirmed read takes. */
110
+ closedValue: Value;
111
+ /** The highest bucket key ever closed, so a re-executed bar closes none twice. */
112
+ highestClosed: number | undefined;
113
+ mark: Mark;
114
+ }
115
+
116
+ const START: Mark = { cursor: 0, openKey: undefined, openFrom: 0 };
117
+
118
+ export class RequestSet {
119
+ private readonly reads: Read[] = [];
120
+ private readonly byId = new Map<number, Read>();
121
+ private readonly parts: RequestParts;
122
+
123
+ constructor(parts: RequestParts, requests: readonly Request[]) {
124
+ this.parts = parts;
125
+ for (const request of requests) {
126
+ const plan = parts.plans.get(request.id);
127
+ if (plan === undefined) continue;
128
+ const read = build(parts, request, plan);
129
+ this.reads.push(read);
130
+ this.byId.set(request.id, read);
131
+ }
132
+ }
133
+
134
+ get empty(): boolean {
135
+ return this.reads.length === 0;
136
+ }
137
+
138
+ /**
139
+ * Step 4: each read's value for this bar, written into its `"request"`
140
+ * register.
141
+ *
142
+ * `fresh` says whether this is the first execution of this bar. A bar that is
143
+ * executing again restores the fold to where it stood when the bar began and
144
+ * rebuilds the bucket now forming from the source as it now stands, which is
145
+ * what makes a moving bar idempotent one level down: the newest chart bar may
146
+ * have been revised since the last execution, and the bucket it is inside has
147
+ * to be rebuilt from the revision rather than from the reading it replaced.
148
+ */
149
+ fill(registers: Registers, bars: readonly HostBar[], index: number, fresh: boolean): void {
150
+ const heap = this.parts.heapOf();
151
+ for (const read of this.reads) {
152
+ if (fresh) {
153
+ read.mark = { cursor: read.cursor, openKey: read.openKey, openFrom: read.openFrom };
154
+ } else {
155
+ restore(read, bars);
156
+ }
157
+ // The body's value is the body's, in the body's heap. `carry` is what
158
+ // makes it a value of the machine that is about to read it.
159
+ registers.set(read.register, read.body.carry(valueOf(read, bars, index), heap));
160
+ }
161
+ }
162
+
163
+ /** `req.isReady(read)`: whether the host has answered this one yet. */
164
+ answered(id: Value): Value {
165
+ return typeof id === 'number' ? this.byId.get(id)?.ready === true : false;
166
+ }
167
+
168
+ /** `req.error(read)`: the reason it failed, or the empty string when none has. */
169
+ failure(id: Value): Value {
170
+ return typeof id === 'number' ? this.byId.get(id)?.reason ?? '' : '';
171
+ }
172
+ }
173
+
174
+ function build(parts: RequestParts, request: Request, plan: RequestPlan): Read {
175
+ const view = bodyProgram(parts.program, request);
176
+ const answer = askHost(plan, parts.host);
177
+ const refused = answer !== undefined && 'refused' in answer ? answer.refused : undefined;
178
+ let body: RequestBody | undefined;
179
+
180
+ // The facts a body reads are the chart's, except the three that identify an
181
+ // instrument: inside a read, those are the instrument and the interval the
182
+ // read asked for. The two request calls answer about the reads written inside
183
+ // this body, which is why the set below is built before the body is.
184
+ let nested: RequestSet | undefined;
185
+ const facts: HostFacts = {
186
+ ...parts.facts,
187
+ symbol: () => plan.query.instrument ?? parts.facts.symbol(),
188
+ exchange: () => plan.query.exchange ?? parts.facts.exchange(),
189
+ interval: () => plan.query.timeframe,
190
+ requestReady: (id: Value) => nested?.answered(id) ?? false,
191
+ requestError: (id: Value) => nested?.failure(id) ?? '',
192
+ };
193
+ nested = new RequestSet(
194
+ // A read inside this one lands in this body's heap, which is built below.
195
+ { ...parts, program: view, facts, heapOf: () => (body as RequestBody).objects },
196
+ request.body.requests,
197
+ );
198
+
199
+ body = new RequestBody({
200
+ program: view,
201
+ limits: parts.limits,
202
+ clock: parts.clock,
203
+ host: facts,
204
+ position: parts.position,
205
+ library: parts.library,
206
+ inputs: request.body.inputs.map((one) => ({
207
+ series: one.series,
208
+ value: parts.inputs.find((input) => input.key === one.input)?.value ?? null,
209
+ })),
210
+ nested,
211
+ spanAt: parts.spanAt,
212
+ });
213
+
214
+ // A reason is the read saying why it will never answer. A refusal is the
215
+ // host's; a calendar fold with no zone to date a bucket in is the engine's,
216
+ // and it is stated here rather than left as an absence the study cannot
217
+ // explain. The host's own words win where both hold: a source that refused is
218
+ // the fix the user can act on first.
219
+ const reason =
220
+ refused !== undefined
221
+ ? reasonFor(refused, plan.query)
222
+ : undatable(plan)
223
+ ? undatableReason(plan.query)
224
+ : '';
225
+
226
+ return {
227
+ plan,
228
+ register: request.series,
229
+ body,
230
+ source: answer !== undefined && 'bars' in answer ? answer.bars : undefined,
231
+ // A fold of the chart's own bars needs nothing from the host, so it is
232
+ // answered the moment it is planned. A read the host is still fetching is
233
+ // not: the read is absent, `req.isReady` is false, and the study keeps
234
+ // drawing everything that does not depend on it. A read with a reason is
235
+ // never ready: it is not waiting for anything.
236
+ ready:
237
+ reason === '' && (answer === undefined ? plan.query.read === 'timeframe' : 'bars' in answer),
238
+ reason,
239
+ cursor: 0,
240
+ openKey: undefined,
241
+ openFrom: 0,
242
+ open: undefined,
243
+ closedValue: ABSENT,
244
+ highestClosed: undefined,
245
+ mark: START,
246
+ };
247
+ }
248
+
249
+ /** The read's value for the chart bar at `index`, and the fold that gets there. */
250
+ function valueOf(read: Read, bars: readonly HostBar[], index: number): Value {
251
+ if (!read.ready) return ABSENT;
252
+ const bar = bars[index];
253
+ const at = bar?.time ?? null;
254
+ if (at === null) return ABSENT;
255
+ const key = keyOf(read, at);
256
+ if (key === undefined) return ABSENT;
257
+
258
+ const source = read.source ?? bars;
259
+ const lookahead = read.plan.request.mode === 'lookahead';
260
+ for (;;) {
261
+ const next = source[read.cursor];
262
+ if (next === undefined) break;
263
+ const found = next.time === null ? undefined : keyOf(read, next.time);
264
+ if (found === undefined) {
265
+ // A source bar with no time, or none this calendar can date, belongs to
266
+ // no bucket. It is stepped over rather than folded into whichever bucket
267
+ // happens to be open.
268
+ read.cursor += 1;
269
+ continue;
270
+ }
271
+ // The one line the three modes differ in. A lookahead read may read to the
272
+ // end of the bucket the chart bar is inside; the other two stop at the bar.
273
+ if (lookahead ? found > key : (next.time ?? 0) > at) break;
274
+ read.cursor += 1;
275
+ feed(read, next, found);
276
+ }
277
+
278
+ if (read.plan.request.mode === 'confirmed') return read.closedValue;
279
+ if (read.openKey !== key || read.open === undefined) return ABSENT;
280
+ return read.body.peek(read.open);
281
+ }
282
+
283
+ function keyOf(read: Read, instant: number): number | undefined {
284
+ return bucketKeyOf(instant, read.plan.timeframe, read.plan.zone);
285
+ }
286
+
287
+ /**
288
+ * One source bar folded in.
289
+ *
290
+ * A bar whose key is the open bucket's extends it. A bar whose key is new
291
+ * closes the open bucket, which is the only place a requested bar ever settles:
292
+ * a bucket is closed by something later, never by the clock. The guard on
293
+ * `highestClosed` is what makes that idempotent, because a chart bar that
294
+ * closed a bucket on its first execution must not close it again on its second.
295
+ */
296
+ function feed(read: Read, bar: HostBar, key: number): void {
297
+ if (read.openKey === key && read.open !== undefined) {
298
+ read.open = extend(read.open, bar);
299
+ return;
300
+ }
301
+ if (read.openKey !== undefined && read.open !== undefined) {
302
+ if (read.highestClosed === undefined || read.openKey > read.highestClosed) {
303
+ read.closedValue = read.body.settle(read.open);
304
+ read.highestClosed = read.openKey;
305
+ }
306
+ }
307
+ read.openKey = key;
308
+ read.openFrom = read.cursor - 1;
309
+ read.open = start(bar);
310
+ }
311
+
312
+ /** A re-executed bar: the fold as it stood when the bar began. */
313
+ function restore(read: Read, bars: readonly HostBar[]): void {
314
+ read.cursor = read.mark.cursor;
315
+ read.openKey = read.mark.openKey;
316
+ read.openFrom = read.mark.openFrom;
317
+ read.open = undefined;
318
+ if (read.openKey === undefined) return;
319
+ const source = read.source ?? bars;
320
+ for (let at = read.openFrom; at < read.cursor; at += 1) {
321
+ const bar = source[at];
322
+ if (bar === undefined || bar.time === null) continue;
323
+ if (keyOf(read, bar.time) !== read.openKey) continue;
324
+ read.open = read.open === undefined ? start(bar) : extend(read.open, bar);
325
+ }
326
+ }
327
+
328
+ /**
329
+ * The first source bar of a bucket, as a bar of its own.
330
+ *
331
+ * The bucket's `time` is this bar's open instant rather than the instant the
332
+ * bucket's key names. The two differ whenever trading begins after the boundary,
333
+ * which is every session on a daily fold, and the first bar's instant is a
334
+ * reading from the data while the boundary is a number the engine chose.
335
+ */
336
+ function start(bar: HostBar): HostBar {
337
+ return {
338
+ open: bar.open,
339
+ high: bar.high,
340
+ low: bar.low,
341
+ close: bar.close,
342
+ volume: bar.volume ?? null,
343
+ time: bar.time,
344
+ oi: bar.oi ?? null,
345
+ };
346
+ }
347
+
348
+ /**
349
+ * One more source bar in the same bucket.
350
+ *
351
+ * **Absence propagates through every field**, which is `host-interface.md` 3.1:
352
+ * an absent price is a hole and what it feeds turns absent. So a bucket whose
353
+ * high is missing from one of its bars has no high, rather than the highest of
354
+ * the bars that did report one, which would be a number with no name. Open is
355
+ * the first bar's, close is the last bar's, and open interest is a level rather
356
+ * than a flow so the coarser bar takes the last and never the sum.
357
+ */
358
+ function extend(into: HostBar, bar: HostBar): HostBar {
359
+ return {
360
+ open: into.open,
361
+ high: higher(into.high, bar.high),
362
+ low: lower(into.low, bar.low),
363
+ close: bar.close ?? null,
364
+ volume: both(into.volume ?? null, bar.volume ?? null),
365
+ time: into.time,
366
+ oi: bar.oi ?? null,
367
+ };
368
+ }
369
+
370
+ function higher(a: number | null, b: number | null | undefined): number | null {
371
+ if (a === null || typeof b !== 'number') return null;
372
+ return b > a ? b : a;
373
+ }
374
+
375
+ function lower(a: number | null, b: number | null | undefined): number | null {
376
+ if (a === null || typeof b !== 'number') return null;
377
+ return b < a ? b : a;
378
+ }
379
+
380
+ function both(a: number | null, b: number | null): number | null {
381
+ return a === null || b === null ? null : a + b;
382
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * What a host reads back from a bar and from a run.
3
+ *
4
+ * Declared apart from the loop that fills it, because these are the shapes an
5
+ * adapter, a test and a second engine's harness all read, and a shape somebody
6
+ * outside this repository depends on is worth being able to read on its own.
7
+ *
8
+ * Four of the six fields are about one bar's execution and two are about what
9
+ * that execution sent and was told: the effects it applied, each carrying the
10
+ * intents it became, and what the frames that arrived before it did to the
11
+ * ledger. A run that places no orders carries both empty for every bar.
12
+ */
13
+ import type { Diagnostic } from '../diagnostics/index.js';
14
+ import type { AlertFiring } from './alerts.js';
15
+ import type { RoutedEffect } from './host.js';
16
+ import type { FrameOutcome } from './ledger/index.js';
17
+ import type { Value } from './values/index.js';
18
+
19
+ /** What one execution of one bar produced. */
20
+ export interface BarResult {
21
+ readonly index: number;
22
+ /** One value per channel, absent where nothing wrote, in channel order. */
23
+ readonly columns: readonly Value[];
24
+ /** Whether step 9 applied the deferred channels and the pending effects. */
25
+ readonly applied: boolean;
26
+ readonly effects: readonly RoutedEffect[];
27
+ /**
28
+ * What the frames delivered since the previous bar did to the ledger, a
29
+ * refused one included (`stdlib.md` 17.14).
30
+ */
31
+ readonly frames: readonly FrameOutcome[];
32
+ /** The watched conditions this bar raised, empty on a bar that raised none. */
33
+ readonly alerts: readonly AlertFiring[];
34
+ /** The failure that stopped the bar, when one did. */
35
+ readonly diagnostic: Diagnostic | undefined;
36
+ }
37
+
38
+ export interface RunResult {
39
+ readonly bars: readonly BarResult[];
40
+ readonly diagnostic: Diagnostic | undefined;
41
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The two things the engine checks about the bars it is handed,
3
+ * `host-interface.md` 3.5 and conformance item 1.
4
+ *
5
+ * Everything else about a series the engine takes exactly as stated: it does
6
+ * not adjust, round, resample, deduplicate or reorder what it is given (3.2),
7
+ * because each of those is a decision with a market consequence and the party
8
+ * that knows the market makes it. These two are not decisions. They are the
9
+ * cases where the engine cannot compute anything at all and would otherwise
10
+ * compute something anyway.
11
+ *
12
+ * **No bars is not an empty chart, it is an unanswerable question.** The script
13
+ * is the body of the per-bar loop, so a loop over nothing draws nothing, and a
14
+ * pane with nothing in it looks exactly like a study that ran and had nothing
15
+ * to say. One of those is worth a sentence to the user and the other is not,
16
+ * and only the engine can tell them apart.
17
+ *
18
+ * **A repeated or a reversed timestamp is worse, because it computes.** The
19
+ * history operator, warmup and every session test are defined against a time
20
+ * that strictly increases (3.2). Hand over a swapped pair or the same bar twice
21
+ * and none of them means what it says, every number downstream is derived from
22
+ * a history that never happened, and nothing on the chart marks which ones. The
23
+ * wrongness enters at the boundary, which is the one place it cannot be
24
+ * attributed to anything later.
25
+ *
26
+ * **What it costs: one comparison per bar handed over, and no allocation.** The
27
+ * check is on the hand-over rather than on the execution, so a bar that moves
28
+ * and is executed a hundred times is compared once per hand-over rather than
29
+ * once per execution, and a series that is handed over once is walked once. On
30
+ * fifty thousand bars that is fifty thousand comparisons of two numbers against
31
+ * a full compute of the same fifty thousand bars, which is the relationship
32
+ * that makes an honest check of the whole series affordable: it is paid at the
33
+ * load and never again.
34
+ */
35
+ import type { Diagnostic } from '../diagnostics/index.js';
36
+ import type { HostBar } from './bars.js';
37
+ import { NO_POSITION, failure } from './errors.js';
38
+ import type { Instrument } from './host.js';
39
+
40
+ /** The spelling a reason uses for a fact the record does not hold. */
41
+ const UNNAMED_INSTRUMENT = 'the chart\'s instrument';
42
+ const UNNAMED_INTERVAL = 'the chart\'s interval';
43
+
44
+ /**
45
+ * A run over nothing, OS6010.
46
+ *
47
+ * It names the instrument and the interval because the fix is to choose a pair
48
+ * that has history, and a sentence that does not say which pair was empty
49
+ * sends the reader back to the chart to work it out.
50
+ */
51
+ export function noBars(instrument: Instrument | undefined): Diagnostic {
52
+ return failure('OS6010', NO_POSITION, {
53
+ symbol: instrument?.symbol ?? UNNAMED_INSTRUMENT,
54
+ timeframe: instrument?.interval ?? UNNAMED_INTERVAL,
55
+ });
56
+ }
57
+
58
+ /**
59
+ * A bar whose time does not follow the one before it, OS6011.
60
+ *
61
+ * The first such bar and not a count of them, because the fix is the same
62
+ * whether the feed sent one duplicate or a thousand, and the first one is the
63
+ * only one whose position tells the host where its own ordering went wrong.
64
+ *
65
+ * `previous` is the bar already handed over, or nothing for the first bar of a
66
+ * run, which follows nothing and is therefore always in order. A time the host
67
+ * did not state is not compared: the absent value is what `barField` gives a
68
+ * script for it (3.1), and the catalogue has no code for a bar dated nothing,
69
+ * so inventing this one for it would be a refusal the specification does not
70
+ * describe.
71
+ */
72
+ export function outOfOrder(
73
+ bar: HostBar,
74
+ previous: HostBar | undefined,
75
+ index: number,
76
+ ): Diagnostic | undefined {
77
+ const time = bar.time;
78
+ const before = previous?.time;
79
+ if (typeof time !== 'number' || typeof before !== 'number') return undefined;
80
+ if (time > before) return undefined;
81
+ return failure('OS6011', NO_POSITION, { index, time, previous: index - 1 });
82
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * A range of wall clock hours, and where one reading sits inside it.
3
+ *
4
+ * Two different things in this repository are a range of hours: the
5
+ * instrument's own trading session, which a host states in its instrument
6
+ * record (`host-interface.md` 4.3), and the range a script writes for
7
+ * `session.isIn` (`stdlib.md` 12.5). They are spelled differently and they mean
8
+ * different things, but the arithmetic is one arithmetic, and it is here so
9
+ * that it is one rule rather than two that can drift.
10
+ *
11
+ * **The open is inclusive and the close is exclusive**, so two ranges written
12
+ * back to back cover every minute once and no minute twice. A range whose start
13
+ * and end are the same minute holds nothing, which is what writing a zero length
14
+ * range says.
15
+ *
16
+ * **A range whose end is before its start crosses midnight and is read that
17
+ * way**, which is what an overnight session needs. The day list then names the
18
+ * day the range opened on rather than the day the reading falls on, because a
19
+ * session that opens on Friday evening and closes on Saturday morning is a
20
+ * Friday session: reading the list against the reading's own day would drop
21
+ * half of every overnight session and keep the wrong half.
22
+ *
23
+ * **A session is named by the day it opened on**, which is what tells two
24
+ * readings in one session from two readings in two. Naming it by an instant
25
+ * would be wrong across a seasonal clock change, where a wall clock hour inside
26
+ * a session is not an hour of elapsed time.
27
+ */
28
+ import type { Civil } from '../../stdlib/index.js';
29
+ import { dayNumber, weekdayOfDay } from '../../stdlib/index.js';
30
+
31
+ /** Minutes in a day, so the wrap is named rather than written as a number. */
32
+ const DAY = 1440;
33
+
34
+ /** Hours as minutes from midnight, and the days they open on. */
35
+ export interface Hours {
36
+ readonly from: number;
37
+ /** Minutes from midnight at the close, which may be at 24:00. */
38
+ readonly to: number;
39
+ /** The days it opens on, Monday as 1, or nothing for every day. */
40
+ readonly days: readonly number[] | null;
41
+ }
42
+
43
+ /** Where one reading sits in a range of hours. */
44
+ export interface Standing {
45
+ readonly inside: boolean;
46
+ /** Minutes since the hours opened, zero on the minute they opened. */
47
+ readonly elapsed: number;
48
+ /** Minutes until they are scheduled to close. */
49
+ readonly remaining: number;
50
+ /** The day they opened on, which is the name of this one session. */
51
+ readonly openingDay: number;
52
+ }
53
+
54
+ const OUTSIDE: Standing = { inside: false, elapsed: 0, remaining: 0, openingDay: 0 };
55
+
56
+ /** Where a wall clock reading sits in a range of hours, or outside every one. */
57
+ export function standingIn(hours: Hours, at: Civil): Standing {
58
+ const minutes = at.hour * 60 + at.minute + at.second / 60;
59
+ const today = dayNumber(at.year, at.month, at.day);
60
+
61
+ if (hours.to > hours.from) {
62
+ if (minutes < hours.from || minutes >= hours.to) return OUTSIDE;
63
+ return held(hours, today, minutes - hours.from, hours.to - minutes);
64
+ }
65
+ if (hours.to === hours.from) return OUTSIDE;
66
+
67
+ // Crossing midnight: the evening part belongs to today's session and the
68
+ // morning part to yesterday's, which is the day the list is read against.
69
+ if (minutes >= hours.from) {
70
+ return held(hours, today, minutes - hours.from, DAY - minutes + hours.to);
71
+ }
72
+ if (minutes < hours.to) {
73
+ return held(hours, today - 1, DAY - hours.from + minutes, hours.to - minutes);
74
+ }
75
+ return OUTSIDE;
76
+ }
77
+
78
+ function held(
79
+ hours: Hours,
80
+ openingDay: number,
81
+ elapsed: number,
82
+ remaining: number,
83
+ ): Standing {
84
+ if (hours.days !== null && !hours.days.includes(weekdayOfDay(openingDay))) return OUTSIDE;
85
+ return { inside: true, elapsed, remaining, openingDay };
86
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Sessions: the instrument's own trading hours, and the ones a script writes.
3
+ *
4
+ * One module because they are one arithmetic. The instrument's hours come from
5
+ * the host's record (`host-interface.md` 4.3) and produce the per-bar facts of
6
+ * `stdlib.md` 12.4; the script's are the spec string of 12.5 and produce one
7
+ * test. Both read the same hours the same way, and keeping them behind one door
8
+ * is what stops a script's overnight range and an instrument's overnight
9
+ * session coming to disagree about which day a session belongs to.
10
+ *
11
+ * The hours themselves are behind the door rather than on it. Two spellings
12
+ * reach them, and a third caller reading them raw would be a third spelling.
13
+ */
14
+ export type { SessionFacts, SessionHours, SessionReader } from './record.js';
15
+ export { NO_SESSION, recordProblem, sessionReader } from './record.js';
16
+
17
+ export { sessionHolds } from './spec.js';