openalgo-script 0.1.0-alpha.1 → 0.4.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 (1210) hide show
  1. package/CHANGELOG.md +1469 -0
  2. package/README.md +85 -30
  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 +221 -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 +166 -0
  90. package/dist/adapters/charts/tables.js.map +1 -0
  91. package/dist/adapters/codemirror/commands.d.ts +14 -0
  92. package/dist/adapters/codemirror/commands.d.ts.map +1 -0
  93. package/dist/adapters/codemirror/commands.js +52 -0
  94. package/dist/adapters/codemirror/commands.js.map +1 -0
  95. package/dist/adapters/codemirror/completion.d.ts +15 -0
  96. package/dist/adapters/codemirror/completion.d.ts.map +1 -0
  97. package/dist/adapters/codemirror/completion.js +64 -0
  98. package/dist/adapters/codemirror/completion.js.map +1 -0
  99. package/dist/adapters/codemirror/contract.d.ts +156 -0
  100. package/dist/adapters/codemirror/contract.d.ts.map +1 -0
  101. package/dist/adapters/codemirror/contract.js +42 -0
  102. package/dist/adapters/codemirror/contract.js.map +1 -0
  103. package/dist/adapters/codemirror/index.d.ts +43 -0
  104. package/dist/adapters/codemirror/index.d.ts.map +1 -0
  105. package/dist/adapters/codemirror/index.js +8 -0
  106. package/dist/adapters/codemirror/index.js.map +1 -0
  107. package/dist/adapters/codemirror/lint.d.ts +17 -0
  108. package/dist/adapters/codemirror/lint.d.ts.map +1 -0
  109. package/dist/adapters/codemirror/lint.js +62 -0
  110. package/dist/adapters/codemirror/lint.js.map +1 -0
  111. package/dist/adapters/codemirror/positions.d.ts +16 -0
  112. package/dist/adapters/codemirror/positions.d.ts.map +1 -0
  113. package/dist/adapters/codemirror/positions.js +65 -0
  114. package/dist/adapters/codemirror/positions.js.map +1 -0
  115. package/dist/adapters/codemirror/stream.d.ts +23 -0
  116. package/dist/adapters/codemirror/stream.d.ts.map +1 -0
  117. package/dist/adapters/codemirror/stream.js +70 -0
  118. package/dist/adapters/codemirror/stream.js.map +1 -0
  119. package/dist/adapters/codemirror/tokens.d.ts +44 -0
  120. package/dist/adapters/codemirror/tokens.d.ts.map +1 -0
  121. package/dist/adapters/codemirror/tokens.js +34 -0
  122. package/dist/adapters/codemirror/tokens.js.map +1 -0
  123. package/dist/adapters/codemirror/tooltips.d.ts +35 -0
  124. package/dist/adapters/codemirror/tooltips.d.ts.map +1 -0
  125. package/dist/adapters/codemirror/tooltips.js +108 -0
  126. package/dist/adapters/codemirror/tooltips.js.map +1 -0
  127. package/dist/core/accounting/charges.d.ts +136 -0
  128. package/dist/core/accounting/charges.d.ts.map +1 -0
  129. package/dist/core/accounting/charges.js +362 -0
  130. package/dist/core/accounting/charges.js.map +1 -0
  131. package/dist/core/accounting/equity.d.ts +158 -0
  132. package/dist/core/accounting/equity.d.ts.map +1 -0
  133. package/dist/core/accounting/equity.js +155 -0
  134. package/dist/core/accounting/equity.js.map +1 -0
  135. package/dist/core/accounting/index.d.ts +44 -0
  136. package/dist/core/accounting/index.d.ts.map +1 -0
  137. package/dist/core/accounting/index.js +36 -0
  138. package/dist/core/accounting/index.js.map +1 -0
  139. package/dist/core/accounting/markers.d.ts +43 -0
  140. package/dist/core/accounting/markers.d.ts.map +1 -0
  141. package/dist/core/accounting/markers.js +64 -0
  142. package/dist/core/accounting/markers.js.map +1 -0
  143. package/dist/core/accounting/monthly.d.ts +52 -0
  144. package/dist/core/accounting/monthly.d.ts.map +1 -0
  145. package/dist/core/accounting/monthly.js +99 -0
  146. package/dist/core/accounting/monthly.js.map +1 -0
  147. package/dist/core/accounting/report.d.ts +38 -0
  148. package/dist/core/accounting/report.d.ts.map +1 -0
  149. package/dist/core/accounting/report.js +63 -0
  150. package/dist/core/accounting/report.js.map +1 -0
  151. package/dist/core/accounting/shapes.d.ts +70 -0
  152. package/dist/core/accounting/shapes.d.ts.map +1 -0
  153. package/dist/core/accounting/shapes.js +21 -0
  154. package/dist/core/accounting/shapes.js.map +1 -0
  155. package/dist/core/accounting/statistics.d.ts +75 -0
  156. package/dist/core/accounting/statistics.d.ts.map +1 -0
  157. package/dist/core/accounting/statistics.js +246 -0
  158. package/dist/core/accounting/statistics.js.map +1 -0
  159. package/dist/core/accounting/trades.d.ts +118 -0
  160. package/dist/core/accounting/trades.d.ts.map +1 -0
  161. package/dist/core/accounting/trades.js +186 -0
  162. package/dist/core/accounting/trades.js.map +1 -0
  163. package/dist/core/backtest/compare.d.ts +38 -0
  164. package/dist/core/backtest/compare.d.ts.map +1 -0
  165. package/dist/core/backtest/compare.js +189 -0
  166. package/dist/core/backtest/compare.js.map +1 -0
  167. package/dist/core/backtest/declaration.d.ts +52 -0
  168. package/dist/core/backtest/declaration.d.ts.map +1 -0
  169. package/dist/core/backtest/declaration.js +48 -0
  170. package/dist/core/backtest/declaration.js.map +1 -0
  171. package/dist/core/backtest/drive.d.ts +29 -0
  172. package/dist/core/backtest/drive.d.ts.map +1 -0
  173. package/dist/core/backtest/drive.js +262 -0
  174. package/dist/core/backtest/drive.js.map +1 -0
  175. package/dist/core/backtest/index.d.ts +46 -0
  176. package/dist/core/backtest/index.d.ts.map +1 -0
  177. package/dist/core/backtest/index.js +36 -0
  178. package/dist/core/backtest/index.js.map +1 -0
  179. package/dist/core/backtest/range.d.ts +84 -0
  180. package/dist/core/backtest/range.d.ts.map +1 -0
  181. package/dist/core/backtest/range.js +90 -0
  182. package/dist/core/backtest/range.js.map +1 -0
  183. package/dist/core/backtest/record.d.ts +238 -0
  184. package/dist/core/backtest/record.d.ts.map +1 -0
  185. package/dist/core/backtest/record.js +176 -0
  186. package/dist/core/backtest/record.js.map +1 -0
  187. package/dist/core/backtest/replay.d.ts +48 -0
  188. package/dist/core/backtest/replay.d.ts.map +1 -0
  189. package/dist/core/backtest/replay.js +127 -0
  190. package/dist/core/backtest/replay.js.map +1 -0
  191. package/dist/core/backtest/resting.d.ts +62 -0
  192. package/dist/core/backtest/resting.d.ts.map +1 -0
  193. package/dist/core/backtest/resting.js +59 -0
  194. package/dist/core/backtest/resting.js.map +1 -0
  195. package/dist/core/backtest/settings.d.ts +117 -0
  196. package/dist/core/backtest/settings.d.ts.map +1 -0
  197. package/dist/core/backtest/settings.js +207 -0
  198. package/dist/core/backtest/settings.js.map +1 -0
  199. package/dist/core/backtest/simulate.d.ts +146 -0
  200. package/dist/core/backtest/simulate.d.ts.map +1 -0
  201. package/dist/core/backtest/simulate.js +217 -0
  202. package/dist/core/backtest/simulate.js.map +1 -0
  203. package/dist/core/catalogue/catalogue.generated.d.ts +164 -10
  204. package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
  205. package/dist/core/catalogue/catalogue.generated.js +23 -9
  206. package/dist/core/catalogue/catalogue.generated.js.map +1 -1
  207. package/dist/core/catalogue/values.generated.d.ts +49 -0
  208. package/dist/core/catalogue/values.generated.d.ts.map +1 -1
  209. package/dist/core/check/arguments.d.ts +41 -0
  210. package/dist/core/check/arguments.d.ts.map +1 -0
  211. package/dist/core/check/arguments.js +84 -0
  212. package/dist/core/check/arguments.js.map +1 -0
  213. package/dist/core/check/call-sites.d.ts +22 -0
  214. package/dist/core/check/call-sites.d.ts.map +1 -0
  215. package/dist/core/check/call-sites.js +329 -0
  216. package/dist/core/check/call-sites.js.map +1 -0
  217. package/dist/core/check/call-warmup.d.ts +37 -0
  218. package/dist/core/check/call-warmup.d.ts.map +1 -0
  219. package/dist/core/check/call-warmup.js +97 -0
  220. package/dist/core/check/call-warmup.js.map +1 -0
  221. package/dist/core/check/calls.d.ts +33 -0
  222. package/dist/core/check/calls.d.ts.map +1 -0
  223. package/dist/core/check/calls.js +348 -0
  224. package/dist/core/check/calls.js.map +1 -0
  225. package/dist/core/check/check.d.ts +23 -0
  226. package/dist/core/check/check.d.ts.map +1 -0
  227. package/dist/core/check/check.js +163 -0
  228. package/dist/core/check/check.js.map +1 -0
  229. package/dist/core/check/checked.d.ts +198 -0
  230. package/dist/core/check/checked.d.ts.map +1 -0
  231. package/dist/core/check/checked.js +19 -0
  232. package/dist/core/check/checked.js.map +1 -0
  233. package/dist/core/check/checker.d.ts +182 -0
  234. package/dist/core/check/checker.d.ts.map +1 -0
  235. package/dist/core/check/checker.js +280 -0
  236. package/dist/core/check/checker.js.map +1 -0
  237. package/dist/core/check/conditional.d.ts +35 -0
  238. package/dist/core/check/conditional.d.ts.map +1 -0
  239. package/dist/core/check/conditional.js +100 -0
  240. package/dist/core/check/conditional.js.map +1 -0
  241. package/dist/core/check/constant.d.ts +47 -0
  242. package/dist/core/check/constant.d.ts.map +1 -0
  243. package/dist/core/check/constant.js +101 -0
  244. package/dist/core/check/constant.js.map +1 -0
  245. package/dist/core/check/declaration.d.ts +33 -0
  246. package/dist/core/check/declaration.d.ts.map +1 -0
  247. package/dist/core/check/declaration.js +181 -0
  248. package/dist/core/check/declaration.js.map +1 -0
  249. package/dist/core/check/expressions.d.ts +36 -0
  250. package/dist/core/check/expressions.d.ts.map +1 -0
  251. package/dist/core/check/expressions.js +398 -0
  252. package/dist/core/check/expressions.js.map +1 -0
  253. package/dist/core/check/functions.d.ts +31 -0
  254. package/dist/core/check/functions.d.ts.map +1 -0
  255. package/dist/core/check/functions.js +238 -0
  256. package/dist/core/check/functions.js.map +1 -0
  257. package/dist/core/check/handles.d.ts +48 -0
  258. package/dist/core/check/handles.d.ts.map +1 -0
  259. package/dist/core/check/handles.js +43 -0
  260. package/dist/core/check/handles.js.map +1 -0
  261. package/dist/core/check/index.d.ts +31 -0
  262. package/dist/core/check/index.d.ts.map +1 -0
  263. package/dist/core/check/index.js +26 -0
  264. package/dist/core/check/index.js.map +1 -0
  265. package/dist/core/check/library-bars.d.ts +7 -0
  266. package/dist/core/check/library-bars.d.ts.map +1 -0
  267. package/dist/core/check/library-bars.js +181 -0
  268. package/dist/core/check/library-bars.js.map +1 -0
  269. package/dist/core/check/library-orders.d.ts +5 -0
  270. package/dist/core/check/library-orders.d.ts.map +1 -0
  271. package/dist/core/check/library-orders.js +250 -0
  272. package/dist/core/check/library-orders.js.map +1 -0
  273. package/dist/core/check/library-output.d.ts +7 -0
  274. package/dist/core/check/library-output.d.ts.map +1 -0
  275. package/dist/core/check/library-output.js +195 -0
  276. package/dist/core/check/library-output.js.map +1 -0
  277. package/dist/core/check/library-prose.generated.d.ts +16 -0
  278. package/dist/core/check/library-prose.generated.d.ts.map +1 -0
  279. package/dist/core/check/library-prose.generated.js +353 -0
  280. package/dist/core/check/library-prose.generated.js.map +1 -0
  281. package/dist/core/check/library-series.d.ts +3 -0
  282. package/dist/core/check/library-series.d.ts.map +1 -0
  283. package/dist/core/check/library-series.js +415 -0
  284. package/dist/core/check/library-series.js.map +1 -0
  285. package/dist/core/check/library.d.ts +204 -0
  286. package/dist/core/check/library.d.ts.map +1 -0
  287. package/dist/core/check/library.js +198 -0
  288. package/dist/core/check/library.js.map +1 -0
  289. package/dist/core/check/literals.d.ts +19 -0
  290. package/dist/core/check/literals.d.ts.map +1 -0
  291. package/dist/core/check/literals.js +22 -0
  292. package/dist/core/check/literals.js.map +1 -0
  293. package/dist/core/check/outputs.d.ts +31 -0
  294. package/dist/core/check/outputs.d.ts.map +1 -0
  295. package/dist/core/check/outputs.js +113 -0
  296. package/dist/core/check/outputs.js.map +1 -0
  297. package/dist/core/check/statements.d.ts +25 -0
  298. package/dist/core/check/statements.d.ts.map +1 -0
  299. package/dist/core/check/statements.js +377 -0
  300. package/dist/core/check/statements.js.map +1 -0
  301. package/dist/core/check/suggest.d.ts +25 -0
  302. package/dist/core/check/suggest.d.ts.map +1 -0
  303. package/dist/core/check/suggest.js +61 -0
  304. package/dist/core/check/suggest.js.map +1 -0
  305. package/dist/core/check/surface.d.ts +62 -0
  306. package/dist/core/check/surface.d.ts.map +1 -0
  307. package/dist/core/check/surface.js +129 -0
  308. package/dist/core/check/surface.js.map +1 -0
  309. package/dist/core/check/tags.d.ts +4 -0
  310. package/dist/core/check/tags.d.ts.map +1 -0
  311. package/dist/core/check/tags.js +54 -0
  312. package/dist/core/check/tags.js.map +1 -0
  313. package/dist/core/check/types.d.ts +153 -0
  314. package/dist/core/check/types.d.ts.map +1 -0
  315. package/dist/core/check/types.js +221 -0
  316. package/dist/core/check/types.js.map +1 -0
  317. package/dist/core/check/warmup.d.ts +73 -0
  318. package/dist/core/check/warmup.d.ts.map +1 -0
  319. package/dist/core/check/warmup.js +62 -0
  320. package/dist/core/check/warmup.js.map +1 -0
  321. package/dist/core/diagnostics/collector.d.ts +12 -0
  322. package/dist/core/diagnostics/collector.d.ts.map +1 -1
  323. package/dist/core/diagnostics/collector.js +27 -1
  324. package/dist/core/diagnostics/collector.js.map +1 -1
  325. package/dist/core/emit/calls.d.ts +38 -0
  326. package/dist/core/emit/calls.d.ts.map +1 -0
  327. package/dist/core/emit/calls.js +347 -0
  328. package/dist/core/emit/calls.js.map +1 -0
  329. package/dist/core/emit/canonical.d.ts +39 -0
  330. package/dist/core/emit/canonical.d.ts.map +1 -0
  331. package/dist/core/emit/canonical.js +71 -0
  332. package/dist/core/emit/canonical.js.map +1 -0
  333. package/dist/core/emit/channels.d.ts +28 -0
  334. package/dist/core/emit/channels.d.ts.map +1 -0
  335. package/dist/core/emit/channels.js +110 -0
  336. package/dist/core/emit/channels.js.map +1 -0
  337. package/dist/core/emit/code.d.ts +75 -0
  338. package/dist/core/emit/code.d.ts.map +1 -0
  339. package/dist/core/emit/code.js +104 -0
  340. package/dist/core/emit/code.js.map +1 -0
  341. package/dist/core/emit/colours.d.ts +35 -0
  342. package/dist/core/emit/colours.d.ts.map +1 -0
  343. package/dist/core/emit/colours.js +50 -0
  344. package/dist/core/emit/colours.js.map +1 -0
  345. package/dist/core/emit/context.d.ts +271 -0
  346. package/dist/core/emit/context.d.ts.map +1 -0
  347. package/dist/core/emit/context.js +358 -0
  348. package/dist/core/emit/context.js.map +1 -0
  349. package/dist/core/emit/defaults.d.ts +64 -0
  350. package/dist/core/emit/defaults.d.ts.map +1 -0
  351. package/dist/core/emit/defaults.js +182 -0
  352. package/dist/core/emit/defaults.js.map +1 -0
  353. package/dist/core/emit/emit.d.ts +13 -0
  354. package/dist/core/emit/emit.d.ts.map +1 -0
  355. package/dist/core/emit/emit.js +281 -0
  356. package/dist/core/emit/emit.js.map +1 -0
  357. package/dist/core/emit/events.d.ts +21 -0
  358. package/dist/core/emit/events.d.ts.map +1 -0
  359. package/dist/core/emit/events.js +112 -0
  360. package/dist/core/emit/events.js.map +1 -0
  361. package/dist/core/emit/expressions.d.ts +23 -0
  362. package/dist/core/emit/expressions.d.ts.map +1 -0
  363. package/dist/core/emit/expressions.js +253 -0
  364. package/dist/core/emit/expressions.js.map +1 -0
  365. package/dist/core/emit/functions.d.ts +30 -0
  366. package/dist/core/emit/functions.d.ts.map +1 -0
  367. package/dist/core/emit/functions.js +171 -0
  368. package/dist/core/emit/functions.js.map +1 -0
  369. package/dist/core/emit/gaps.d.ts +34 -0
  370. package/dist/core/emit/gaps.d.ts.map +1 -0
  371. package/dist/core/emit/gaps.js +16 -0
  372. package/dist/core/emit/gaps.js.map +1 -0
  373. package/dist/core/emit/index.d.ts +31 -0
  374. package/dist/core/emit/index.d.ts.map +1 -0
  375. package/dist/core/emit/index.js +25 -0
  376. package/dist/core/emit/index.js.map +1 -0
  377. package/dist/core/emit/inputs.d.ts +47 -0
  378. package/dist/core/emit/inputs.d.ts.map +1 -0
  379. package/dist/core/emit/inputs.js +150 -0
  380. package/dist/core/emit/inputs.js.map +1 -0
  381. package/dist/core/emit/layout.d.ts +73 -0
  382. package/dist/core/emit/layout.d.ts.map +1 -0
  383. package/dist/core/emit/layout.js +126 -0
  384. package/dist/core/emit/layout.js.map +1 -0
  385. package/dist/core/emit/meta.d.ts +14 -0
  386. package/dist/core/emit/meta.d.ts.map +1 -0
  387. package/dist/core/emit/meta.js +68 -0
  388. package/dist/core/emit/meta.js.map +1 -0
  389. package/dist/core/emit/opcodes.d.ts +28 -0
  390. package/dist/core/emit/opcodes.d.ts.map +1 -0
  391. package/dist/core/emit/opcodes.js +137 -0
  392. package/dist/core/emit/opcodes.js.map +1 -0
  393. package/dist/core/emit/outputs.d.ts +67 -0
  394. package/dist/core/emit/outputs.d.ts.map +1 -0
  395. package/dist/core/emit/outputs.js +293 -0
  396. package/dist/core/emit/outputs.js.map +1 -0
  397. package/dist/core/emit/pool.d.ts +33 -0
  398. package/dist/core/emit/pool.d.ts.map +1 -0
  399. package/dist/core/emit/pool.js +79 -0
  400. package/dist/core/emit/pool.js.map +1 -0
  401. package/dist/core/emit/program.d.ts +333 -0
  402. package/dist/core/emit/program.d.ts.map +1 -0
  403. package/dist/core/emit/program.js +15 -0
  404. package/dist/core/emit/program.js.map +1 -0
  405. package/dist/core/emit/registers.d.ts +35 -0
  406. package/dist/core/emit/registers.d.ts.map +1 -0
  407. package/dist/core/emit/registers.js +170 -0
  408. package/dist/core/emit/registers.js.map +1 -0
  409. package/dist/core/emit/request-scope.d.ts +36 -0
  410. package/dist/core/emit/request-scope.d.ts.map +1 -0
  411. package/dist/core/emit/request-scope.js +41 -0
  412. package/dist/core/emit/request-scope.js.map +1 -0
  413. package/dist/core/emit/requests.d.ts +69 -0
  414. package/dist/core/emit/requests.d.ts.map +1 -0
  415. package/dist/core/emit/requests.js +230 -0
  416. package/dist/core/emit/requests.js.map +1 -0
  417. package/dist/core/emit/requires.d.ts +4 -0
  418. package/dist/core/emit/requires.d.ts.map +1 -0
  419. package/dist/core/emit/requires.js +71 -0
  420. package/dist/core/emit/requires.js.map +1 -0
  421. package/dist/core/emit/sha256.d.ts +24 -0
  422. package/dist/core/emit/sha256.d.ts.map +1 -0
  423. package/dist/core/emit/sha256.js +109 -0
  424. package/dist/core/emit/sha256.js.map +1 -0
  425. package/dist/core/emit/statements.d.ts +20 -0
  426. package/dist/core/emit/statements.d.ts.map +1 -0
  427. package/dist/core/emit/statements.js +393 -0
  428. package/dist/core/emit/statements.js.map +1 -0
  429. package/dist/core/emit/values.d.ts +80 -0
  430. package/dist/core/emit/values.d.ts.map +1 -0
  431. package/dist/core/emit/values.js +242 -0
  432. package/dist/core/emit/values.js.map +1 -0
  433. package/dist/core/engine/alerts.d.ts +66 -0
  434. package/dist/core/engine/alerts.d.ts.map +1 -0
  435. package/dist/core/engine/alerts.js +119 -0
  436. package/dist/core/engine/alerts.js.map +1 -0
  437. package/dist/core/engine/arithmetic.d.ts +82 -0
  438. package/dist/core/engine/arithmetic.d.ts.map +1 -0
  439. package/dist/core/engine/arithmetic.js +141 -0
  440. package/dist/core/engine/arithmetic.js.map +1 -0
  441. package/dist/core/engine/bars.d.ts +95 -0
  442. package/dist/core/engine/bars.d.ts.map +1 -0
  443. package/dist/core/engine/bars.js +133 -0
  444. package/dist/core/engine/bars.js.map +1 -0
  445. package/dist/core/engine/budget.d.ts +162 -0
  446. package/dist/core/engine/budget.d.ts.map +1 -0
  447. package/dist/core/engine/budget.js +188 -0
  448. package/dist/core/engine/budget.js.map +1 -0
  449. package/dist/core/engine/channels.d.ts +106 -0
  450. package/dist/core/engine/channels.d.ts.map +1 -0
  451. package/dist/core/engine/channels.js +99 -0
  452. package/dist/core/engine/channels.js.map +1 -0
  453. package/dist/core/engine/drawings.d.ts +64 -0
  454. package/dist/core/engine/drawings.d.ts.map +1 -0
  455. package/dist/core/engine/drawings.js +67 -0
  456. package/dist/core/engine/drawings.js.map +1 -0
  457. package/dist/core/engine/engine.d.ts +140 -0
  458. package/dist/core/engine/engine.d.ts.map +1 -0
  459. package/dist/core/engine/engine.js +405 -0
  460. package/dist/core/engine/engine.js.map +1 -0
  461. package/dist/core/engine/errors.d.ts +64 -0
  462. package/dist/core/engine/errors.d.ts.map +1 -0
  463. package/dist/core/engine/errors.js +63 -0
  464. package/dist/core/engine/errors.js.map +1 -0
  465. package/dist/core/engine/frames.d.ts +48 -0
  466. package/dist/core/engine/frames.d.ts.map +1 -0
  467. package/dist/core/engine/frames.js +41 -0
  468. package/dist/core/engine/frames.js.map +1 -0
  469. package/dist/core/engine/grids.d.ts +25 -0
  470. package/dist/core/engine/grids.d.ts.map +1 -0
  471. package/dist/core/engine/grids.js +77 -0
  472. package/dist/core/engine/grids.js.map +1 -0
  473. package/dist/core/engine/guard.d.ts +4 -0
  474. package/dist/core/engine/guard.d.ts.map +1 -0
  475. package/dist/core/engine/guard.js +46 -0
  476. package/dist/core/engine/guard.js.map +1 -0
  477. package/dist/core/engine/host.d.ts +219 -0
  478. package/dist/core/engine/host.d.ts.map +1 -0
  479. package/dist/core/engine/host.js +38 -0
  480. package/dist/core/engine/host.js.map +1 -0
  481. package/dist/core/engine/index.d.ts +49 -0
  482. package/dist/core/engine/index.d.ts.map +1 -0
  483. package/dist/core/engine/index.js +33 -0
  484. package/dist/core/engine/index.js.map +1 -0
  485. package/dist/core/engine/inputs.d.ts +77 -0
  486. package/dist/core/engine/inputs.d.ts.map +1 -0
  487. package/dist/core/engine/inputs.js +205 -0
  488. package/dist/core/engine/inputs.js.map +1 -0
  489. package/dist/core/engine/ledger/call.d.ts +63 -0
  490. package/dist/core/engine/ledger/call.d.ts.map +1 -0
  491. package/dist/core/engine/ledger/call.js +136 -0
  492. package/dist/core/engine/ledger/call.js.map +1 -0
  493. package/dist/core/engine/ledger/closable.d.ts +155 -0
  494. package/dist/core/engine/ledger/closable.d.ts.map +1 -0
  495. package/dist/core/engine/ledger/closable.js +173 -0
  496. package/dist/core/engine/ledger/closable.js.map +1 -0
  497. package/dist/core/engine/ledger/holdings.d.ts +194 -0
  498. package/dist/core/engine/ledger/holdings.d.ts.map +1 -0
  499. package/dist/core/engine/ledger/holdings.js +237 -0
  500. package/dist/core/engine/ledger/holdings.js.map +1 -0
  501. package/dist/core/engine/ledger/index.d.ts +19 -0
  502. package/dist/core/engine/ledger/index.d.ts.map +1 -0
  503. package/dist/core/engine/ledger/index.js +2 -0
  504. package/dist/core/engine/ledger/index.js.map +1 -0
  505. package/dist/core/engine/ledger/intent.d.ts +106 -0
  506. package/dist/core/engine/ledger/intent.d.ts.map +1 -0
  507. package/dist/core/engine/ledger/intent.js +21 -0
  508. package/dist/core/engine/ledger/intent.js.map +1 -0
  509. package/dist/core/engine/ledger/ledger.d.ts +143 -0
  510. package/dist/core/engine/ledger/ledger.d.ts.map +1 -0
  511. package/dist/core/engine/ledger/ledger.js +237 -0
  512. package/dist/core/engine/ledger/ledger.js.map +1 -0
  513. package/dist/core/engine/ledger/place.d.ts +75 -0
  514. package/dist/core/engine/ledger/place.d.ts.map +1 -0
  515. package/dist/core/engine/ledger/place.js +174 -0
  516. package/dist/core/engine/ledger/place.js.map +1 -0
  517. package/dist/core/engine/ledger/positions.d.ts +68 -0
  518. package/dist/core/engine/ledger/positions.d.ts.map +1 -0
  519. package/dist/core/engine/ledger/positions.js +114 -0
  520. package/dist/core/engine/ledger/positions.js.map +1 -0
  521. package/dist/core/engine/ledger/refuse.d.ts +43 -0
  522. package/dist/core/engine/ledger/refuse.d.ts.map +1 -0
  523. package/dist/core/engine/ledger/refuse.js +329 -0
  524. package/dist/core/engine/ledger/refuse.js.map +1 -0
  525. package/dist/core/engine/ledger/row.d.ts +176 -0
  526. package/dist/core/engine/ledger/row.d.ts.map +1 -0
  527. package/dist/core/engine/ledger/row.js +169 -0
  528. package/dist/core/engine/ledger/row.js.map +1 -0
  529. package/dist/core/engine/ledger/sizing.d.ts +142 -0
  530. package/dist/core/engine/ledger/sizing.d.ts.map +1 -0
  531. package/dist/core/engine/ledger/sizing.js +223 -0
  532. package/dist/core/engine/ledger/sizing.js.map +1 -0
  533. package/dist/core/engine/library/arrays.d.ts +14 -0
  534. package/dist/core/engine/library/arrays.d.ts.map +1 -0
  535. package/dist/core/engine/library/arrays.js +285 -0
  536. package/dist/core/engine/library/arrays.js.map +1 -0
  537. package/dist/core/engine/library/averages.d.ts +9 -0
  538. package/dist/core/engine/library/averages.d.ts.map +1 -0
  539. package/dist/core/engine/library/averages.js +41 -0
  540. package/dist/core/engine/library/averages.js.map +1 -0
  541. package/dist/core/engine/library/binding.d.ts +230 -0
  542. package/dist/core/engine/library/binding.d.ts.map +1 -0
  543. package/dist/core/engine/library/binding.js +109 -0
  544. package/dist/core/engine/library/binding.js.map +1 -0
  545. package/dist/core/engine/library/chart.d.ts +3 -0
  546. package/dist/core/engine/library/chart.d.ts.map +1 -0
  547. package/dist/core/engine/library/chart.js +83 -0
  548. package/dist/core/engine/library/chart.js.map +1 -0
  549. package/dist/core/engine/library/colours.d.ts +26 -0
  550. package/dist/core/engine/library/colours.d.ts.map +1 -0
  551. package/dist/core/engine/library/colours.js +81 -0
  552. package/dist/core/engine/library/colours.js.map +1 -0
  553. package/dist/core/engine/library/dates.d.ts +3 -0
  554. package/dist/core/engine/library/dates.d.ts.map +1 -0
  555. package/dist/core/engine/library/dates.js +75 -0
  556. package/dist/core/engine/library/dates.js.map +1 -0
  557. package/dist/core/engine/library/index.d.ts +13 -0
  558. package/dist/core/engine/library/index.d.ts.map +1 -0
  559. package/dist/core/engine/library/index.js +86 -0
  560. package/dist/core/engine/library/index.js.map +1 -0
  561. package/dist/core/engine/library/maths.d.ts +3 -0
  562. package/dist/core/engine/library/maths.d.ts.map +1 -0
  563. package/dist/core/engine/library/maths.js +89 -0
  564. package/dist/core/engine/library/maths.js.map +1 -0
  565. package/dist/core/engine/library/objects.d.ts +3 -0
  566. package/dist/core/engine/library/objects.d.ts.map +1 -0
  567. package/dist/core/engine/library/objects.js +199 -0
  568. package/dist/core/engine/library/objects.js.map +1 -0
  569. package/dist/core/engine/library/oscillators.d.ts +3 -0
  570. package/dist/core/engine/library/oscillators.d.ts.map +1 -0
  571. package/dist/core/engine/library/oscillators.js +29 -0
  572. package/dist/core/engine/library/oscillators.js.map +1 -0
  573. package/dist/core/engine/library/ranges.d.ts +3 -0
  574. package/dist/core/engine/library/ranges.d.ts.map +1 -0
  575. package/dist/core/engine/library/ranges.js +23 -0
  576. package/dist/core/engine/library/ranges.js.map +1 -0
  577. package/dist/core/engine/library/series.d.ts +3 -0
  578. package/dist/core/engine/library/series.d.ts.map +1 -0
  579. package/dist/core/engine/library/series.js +46 -0
  580. package/dist/core/engine/library/series.js.map +1 -0
  581. package/dist/core/engine/library/state.d.ts +35 -0
  582. package/dist/core/engine/library/state.d.ts.map +1 -0
  583. package/dist/core/engine/library/state.js +19 -0
  584. package/dist/core/engine/library/state.js.map +1 -0
  585. package/dist/core/engine/library/studies.d.ts +3 -0
  586. package/dist/core/engine/library/studies.d.ts.map +1 -0
  587. package/dist/core/engine/library/studies.js +35 -0
  588. package/dist/core/engine/library/studies.js.map +1 -0
  589. package/dist/core/engine/library/text.d.ts +6 -0
  590. package/dist/core/engine/library/text.d.ts.map +1 -0
  591. package/dist/core/engine/library/text.js +280 -0
  592. package/dist/core/engine/library/text.js.map +1 -0
  593. package/dist/core/engine/library/trend.d.ts +3 -0
  594. package/dist/core/engine/library/trend.d.ts.map +1 -0
  595. package/dist/core/engine/library/trend.js +29 -0
  596. package/dist/core/engine/library/trend.js.map +1 -0
  597. package/dist/core/engine/library/volume.d.ts +3 -0
  598. package/dist/core/engine/library/volume.d.ts.map +1 -0
  599. package/dist/core/engine/library/volume.js +51 -0
  600. package/dist/core/engine/library/volume.js.map +1 -0
  601. package/dist/core/engine/load.d.ts +59 -0
  602. package/dist/core/engine/load.d.ts.map +1 -0
  603. package/dist/core/engine/load.js +61 -0
  604. package/dist/core/engine/load.js.map +1 -0
  605. package/dist/core/engine/machine.d.ts +107 -0
  606. package/dist/core/engine/machine.d.ts.map +1 -0
  607. package/dist/core/engine/machine.js +337 -0
  608. package/dist/core/engine/machine.js.map +1 -0
  609. package/dist/core/engine/memory.d.ts +60 -0
  610. package/dist/core/engine/memory.d.ts.map +1 -0
  611. package/dist/core/engine/memory.js +92 -0
  612. package/dist/core/engine/memory.js.map +1 -0
  613. package/dist/core/engine/operations.d.ts +62 -0
  614. package/dist/core/engine/operations.d.ts.map +1 -0
  615. package/dist/core/engine/operations.js +149 -0
  616. package/dist/core/engine/operations.js.map +1 -0
  617. package/dist/core/engine/orders.d.ts +56 -0
  618. package/dist/core/engine/orders.d.ts.map +1 -0
  619. package/dist/core/engine/orders.js +83 -0
  620. package/dist/core/engine/orders.js.map +1 -0
  621. package/dist/core/engine/registers.d.ts +50 -0
  622. package/dist/core/engine/registers.d.ts.map +1 -0
  623. package/dist/core/engine/registers.js +85 -0
  624. package/dist/core/engine/registers.js.map +1 -0
  625. package/dist/core/engine/request-body.d.ts +138 -0
  626. package/dist/core/engine/request-body.d.ts.map +1 -0
  627. package/dist/core/engine/request-body.js +227 -0
  628. package/dist/core/engine/request-body.js.map +1 -0
  629. package/dist/core/engine/request-plan.d.ts +79 -0
  630. package/dist/core/engine/request-plan.d.ts.map +1 -0
  631. package/dist/core/engine/request-plan.js +228 -0
  632. package/dist/core/engine/request-plan.js.map +1 -0
  633. package/dist/core/engine/requests.d.ts +105 -0
  634. package/dist/core/engine/requests.d.ts.map +1 -0
  635. package/dist/core/engine/requests.js +260 -0
  636. package/dist/core/engine/requests.js.map +1 -0
  637. package/dist/core/engine/results.d.ts +40 -0
  638. package/dist/core/engine/results.d.ts.map +1 -0
  639. package/dist/core/engine/results.js +2 -0
  640. package/dist/core/engine/results.js.map +1 -0
  641. package/dist/core/engine/series.d.ts +61 -0
  642. package/dist/core/engine/series.d.ts.map +1 -0
  643. package/dist/core/engine/series.js +41 -0
  644. package/dist/core/engine/series.js.map +1 -0
  645. package/dist/core/engine/session/hours.d.ts +49 -0
  646. package/dist/core/engine/session/hours.d.ts.map +1 -0
  647. package/dist/core/engine/session/hours.js +31 -0
  648. package/dist/core/engine/session/hours.js.map +1 -0
  649. package/dist/core/engine/session/index.d.ts +17 -0
  650. package/dist/core/engine/session/index.d.ts.map +1 -0
  651. package/dist/core/engine/session/index.js +3 -0
  652. package/dist/core/engine/session/index.js.map +1 -0
  653. package/dist/core/engine/session/record.d.ts +56 -0
  654. package/dist/core/engine/session/record.d.ts.map +1 -0
  655. package/dist/core/engine/session/record.js +165 -0
  656. package/dist/core/engine/session/record.js.map +1 -0
  657. package/dist/core/engine/session/spec.d.ts +19 -0
  658. package/dist/core/engine/session/spec.d.ts.map +1 -0
  659. package/dist/core/engine/session/spec.js +31 -0
  660. package/dist/core/engine/session/spec.js.map +1 -0
  661. package/dist/core/engine/timeframe.d.ts +59 -0
  662. package/dist/core/engine/timeframe.d.ts.map +1 -0
  663. package/dist/core/engine/timeframe.js +140 -0
  664. package/dist/core/engine/timeframe.js.map +1 -0
  665. package/dist/core/engine/types.d.ts +15 -0
  666. package/dist/core/engine/types.d.ts.map +1 -0
  667. package/dist/core/engine/types.js +2 -0
  668. package/dist/core/engine/types.js.map +1 -0
  669. package/dist/core/engine/values/heap.d.ts +134 -0
  670. package/dist/core/engine/values/heap.d.ts.map +1 -0
  671. package/dist/core/engine/values/heap.js +230 -0
  672. package/dist/core/engine/values/heap.js.map +1 -0
  673. package/dist/core/engine/values/index.d.ts +13 -0
  674. package/dist/core/engine/values/index.d.ts.map +1 -0
  675. package/dist/core/engine/values/index.js +3 -0
  676. package/dist/core/engine/values/index.js.map +1 -0
  677. package/dist/core/engine/values/value.d.ts +82 -0
  678. package/dist/core/engine/values/value.d.ts.map +1 -0
  679. package/dist/core/engine/values/value.js +134 -0
  680. package/dist/core/engine/values/value.js.map +1 -0
  681. package/dist/core/engine/verify-budgets.d.ts +35 -0
  682. package/dist/core/engine/verify-budgets.d.ts.map +1 -0
  683. package/dist/core/engine/verify-budgets.js +172 -0
  684. package/dist/core/engine/verify-budgets.js.map +1 -0
  685. package/dist/core/engine/verify-code.d.ts +32 -0
  686. package/dist/core/engine/verify-code.d.ts.map +1 -0
  687. package/dist/core/engine/verify-code.js +278 -0
  688. package/dist/core/engine/verify-code.js.map +1 -0
  689. package/dist/core/engine/verify-requests.d.ts +44 -0
  690. package/dist/core/engine/verify-requests.d.ts.map +1 -0
  691. package/dist/core/engine/verify-requests.js +220 -0
  692. package/dist/core/engine/verify-requests.js.map +1 -0
  693. package/dist/core/engine/verify-shape.d.ts +46 -0
  694. package/dist/core/engine/verify-shape.d.ts.map +1 -0
  695. package/dist/core/engine/verify-shape.js +147 -0
  696. package/dist/core/engine/verify-shape.js.map +1 -0
  697. package/dist/core/engine/verify-tables.d.ts +19 -0
  698. package/dist/core/engine/verify-tables.d.ts.map +1 -0
  699. package/dist/core/engine/verify-tables.js +171 -0
  700. package/dist/core/engine/verify-tables.js.map +1 -0
  701. package/dist/core/engine/verify.d.ts +19 -0
  702. package/dist/core/engine/verify.d.ts.map +1 -0
  703. package/dist/core/engine/verify.js +309 -0
  704. package/dist/core/engine/verify.js.map +1 -0
  705. package/dist/core/index.d.ts +95 -6
  706. package/dist/core/index.d.ts.map +1 -1
  707. package/dist/core/index.js +64 -6
  708. package/dist/core/index.js.map +1 -1
  709. package/dist/core/parse/expressions.js +1 -1
  710. package/dist/core/parse/expressions.js.map +1 -1
  711. package/dist/core/parse/names.d.ts +7 -1
  712. package/dist/core/parse/names.d.ts.map +1 -1
  713. package/dist/core/parse/names.js +28 -2
  714. package/dist/core/parse/names.js.map +1 -1
  715. package/dist/core/stdlib/averages/exponential.d.ts +51 -0
  716. package/dist/core/stdlib/averages/exponential.d.ts.map +1 -0
  717. package/dist/core/stdlib/averages/exponential.js +72 -0
  718. package/dist/core/stdlib/averages/exponential.js.map +1 -0
  719. package/dist/core/stdlib/averages/index.d.ts +7 -0
  720. package/dist/core/stdlib/averages/index.d.ts.map +1 -0
  721. package/dist/core/stdlib/averages/index.js +5 -0
  722. package/dist/core/stdlib/averages/index.js.map +1 -0
  723. package/dist/core/stdlib/averages/select.d.ts +35 -0
  724. package/dist/core/stdlib/averages/select.d.ts.map +1 -0
  725. package/dist/core/stdlib/averages/select.js +43 -0
  726. package/dist/core/stdlib/averages/select.js.map +1 -0
  727. package/dist/core/stdlib/averages/shaped.d.ts +61 -0
  728. package/dist/core/stdlib/averages/shaped.d.ts.map +1 -0
  729. package/dist/core/stdlib/averages/shaped.js +126 -0
  730. package/dist/core/stdlib/averages/shaped.js.map +1 -0
  731. package/dist/core/stdlib/averages/simple.d.ts +58 -0
  732. package/dist/core/stdlib/averages/simple.d.ts.map +1 -0
  733. package/dist/core/stdlib/averages/simple.js +92 -0
  734. package/dist/core/stdlib/averages/simple.js.map +1 -0
  735. package/dist/core/stdlib/calendar/civil.d.ts +56 -0
  736. package/dist/core/stdlib/calendar/civil.d.ts.map +1 -0
  737. package/dist/core/stdlib/calendar/civil.js +70 -0
  738. package/dist/core/stdlib/calendar/civil.js.map +1 -0
  739. package/dist/core/stdlib/calendar/fields.d.ts +36 -0
  740. package/dist/core/stdlib/calendar/fields.d.ts.map +1 -0
  741. package/dist/core/stdlib/calendar/fields.js +93 -0
  742. package/dist/core/stdlib/calendar/fields.js.map +1 -0
  743. package/dist/core/stdlib/calendar/format.d.ts +19 -0
  744. package/dist/core/stdlib/calendar/format.d.ts.map +1 -0
  745. package/dist/core/stdlib/calendar/format.js +51 -0
  746. package/dist/core/stdlib/calendar/format.js.map +1 -0
  747. package/dist/core/stdlib/calendar/index.d.ts +7 -0
  748. package/dist/core/stdlib/calendar/index.d.ts.map +1 -0
  749. package/dist/core/stdlib/calendar/index.js +5 -0
  750. package/dist/core/stdlib/calendar/index.js.map +1 -0
  751. package/dist/core/stdlib/calendar/zone.d.ts +53 -0
  752. package/dist/core/stdlib/calendar/zone.d.ts.map +1 -0
  753. package/dist/core/stdlib/calendar/zone.js +138 -0
  754. package/dist/core/stdlib/calendar/zone.js.map +1 -0
  755. package/dist/core/stdlib/index.d.ts +57 -0
  756. package/dist/core/stdlib/index.d.ts.map +1 -0
  757. package/dist/core/stdlib/index.js +51 -0
  758. package/dist/core/stdlib/index.js.map +1 -0
  759. package/dist/core/stdlib/maths/arithmetic.d.ts +38 -0
  760. package/dist/core/stdlib/maths/arithmetic.d.ts.map +1 -0
  761. package/dist/core/stdlib/maths/arithmetic.js +66 -0
  762. package/dist/core/stdlib/maths/arithmetic.js.map +1 -0
  763. package/dist/core/stdlib/maths/elementary.d.ts +65 -0
  764. package/dist/core/stdlib/maths/elementary.d.ts.map +1 -0
  765. package/dist/core/stdlib/maths/elementary.js +93 -0
  766. package/dist/core/stdlib/maths/elementary.js.map +1 -0
  767. package/dist/core/stdlib/maths/index.d.ts +4 -0
  768. package/dist/core/stdlib/maths/index.d.ts.map +1 -0
  769. package/dist/core/stdlib/maths/index.js +4 -0
  770. package/dist/core/stdlib/maths/index.js.map +1 -0
  771. package/dist/core/stdlib/maths/rounding.d.ts +43 -0
  772. package/dist/core/stdlib/maths/rounding.d.ts.map +1 -0
  773. package/dist/core/stdlib/maths/rounding.js +62 -0
  774. package/dist/core/stdlib/maths/rounding.js.map +1 -0
  775. package/dist/core/stdlib/momentum/convergence.d.ts +36 -0
  776. package/dist/core/stdlib/momentum/convergence.d.ts.map +1 -0
  777. package/dist/core/stdlib/momentum/convergence.js +48 -0
  778. package/dist/core/stdlib/momentum/convergence.js.map +1 -0
  779. package/dist/core/stdlib/momentum/index.d.ts +6 -0
  780. package/dist/core/stdlib/momentum/index.d.ts.map +1 -0
  781. package/dist/core/stdlib/momentum/index.js +6 -0
  782. package/dist/core/stdlib/momentum/index.js.map +1 -0
  783. package/dist/core/stdlib/momentum/pressure.d.ts +43 -0
  784. package/dist/core/stdlib/momentum/pressure.d.ts.map +1 -0
  785. package/dist/core/stdlib/momentum/pressure.js +103 -0
  786. package/dist/core/stdlib/momentum/pressure.js.map +1 -0
  787. package/dist/core/stdlib/momentum/rates.d.ts +74 -0
  788. package/dist/core/stdlib/momentum/rates.d.ts.map +1 -0
  789. package/dist/core/stdlib/momentum/rates.js +134 -0
  790. package/dist/core/stdlib/momentum/rates.js.map +1 -0
  791. package/dist/core/stdlib/momentum/rsi.d.ts +21 -0
  792. package/dist/core/stdlib/momentum/rsi.d.ts.map +1 -0
  793. package/dist/core/stdlib/momentum/rsi.js +30 -0
  794. package/dist/core/stdlib/momentum/rsi.js.map +1 -0
  795. package/dist/core/stdlib/momentum/stochastic.d.ts +44 -0
  796. package/dist/core/stdlib/momentum/stochastic.d.ts.map +1 -0
  797. package/dist/core/stdlib/momentum/stochastic.js +97 -0
  798. package/dist/core/stdlib/momentum/stochastic.js.map +1 -0
  799. package/dist/core/stdlib/series/changes.d.ts +59 -0
  800. package/dist/core/stdlib/series/changes.d.ts.map +1 -0
  801. package/dist/core/stdlib/series/changes.js +129 -0
  802. package/dist/core/stdlib/series/changes.js.map +1 -0
  803. package/dist/core/stdlib/series/conditions.d.ts +34 -0
  804. package/dist/core/stdlib/series/conditions.d.ts.map +1 -0
  805. package/dist/core/stdlib/series/conditions.js +52 -0
  806. package/dist/core/stdlib/series/conditions.js.map +1 -0
  807. package/dist/core/stdlib/series/extremes.d.ts +29 -0
  808. package/dist/core/stdlib/series/extremes.d.ts.map +1 -0
  809. package/dist/core/stdlib/series/extremes.js +62 -0
  810. package/dist/core/stdlib/series/extremes.js.map +1 -0
  811. package/dist/core/stdlib/series/index.d.ts +9 -0
  812. package/dist/core/stdlib/series/index.d.ts.map +1 -0
  813. package/dist/core/stdlib/series/index.js +7 -0
  814. package/dist/core/stdlib/series/index.js.map +1 -0
  815. package/dist/core/stdlib/series/pivots.d.ts +25 -0
  816. package/dist/core/stdlib/series/pivots.d.ts.map +1 -0
  817. package/dist/core/stdlib/series/pivots.js +42 -0
  818. package/dist/core/stdlib/series/pivots.js.map +1 -0
  819. package/dist/core/stdlib/series/statistics.d.ts +64 -0
  820. package/dist/core/stdlib/series/statistics.d.ts.map +1 -0
  821. package/dist/core/stdlib/series/statistics.js +148 -0
  822. package/dist/core/stdlib/series/statistics.js.map +1 -0
  823. package/dist/core/stdlib/series/totals.d.ts +68 -0
  824. package/dist/core/stdlib/series/totals.d.ts.map +1 -0
  825. package/dist/core/stdlib/series/totals.js +115 -0
  826. package/dist/core/stdlib/series/totals.js.map +1 -0
  827. package/dist/core/stdlib/trend/directional.d.ts +69 -0
  828. package/dist/core/stdlib/trend/directional.d.ts.map +1 -0
  829. package/dist/core/stdlib/trend/directional.js +151 -0
  830. package/dist/core/stdlib/trend/directional.js.map +1 -0
  831. package/dist/core/stdlib/trend/index.d.ts +4 -0
  832. package/dist/core/stdlib/trend/index.d.ts.map +1 -0
  833. package/dist/core/stdlib/trend/index.js +4 -0
  834. package/dist/core/stdlib/trend/index.js.map +1 -0
  835. package/dist/core/stdlib/trend/psar.d.ts +33 -0
  836. package/dist/core/stdlib/trend/psar.d.ts.map +1 -0
  837. package/dist/core/stdlib/trend/psar.js +86 -0
  838. package/dist/core/stdlib/trend/psar.js.map +1 -0
  839. package/dist/core/stdlib/trend/supertrend.d.ts +30 -0
  840. package/dist/core/stdlib/trend/supertrend.d.ts.map +1 -0
  841. package/dist/core/stdlib/trend/supertrend.js +65 -0
  842. package/dist/core/stdlib/trend/supertrend.js.map +1 -0
  843. package/dist/core/stdlib/values/bar.d.ts +39 -0
  844. package/dist/core/stdlib/values/bar.d.ts.map +1 -0
  845. package/dist/core/stdlib/values/bar.js +33 -0
  846. package/dist/core/stdlib/values/bar.js.map +1 -0
  847. package/dist/core/stdlib/values/index.d.ts +11 -0
  848. package/dist/core/stdlib/values/index.d.ts.map +1 -0
  849. package/dist/core/stdlib/values/index.js +6 -0
  850. package/dist/core/stdlib/values/index.js.map +1 -0
  851. package/dist/core/stdlib/values/lookback.d.ts +83 -0
  852. package/dist/core/stdlib/values/lookback.d.ts.map +1 -0
  853. package/dist/core/stdlib/values/lookback.js +134 -0
  854. package/dist/core/stdlib/values/lookback.js.map +1 -0
  855. package/dist/core/stdlib/values/region.d.ts +55 -0
  856. package/dist/core/stdlib/values/region.d.ts.map +1 -0
  857. package/dist/core/stdlib/values/region.js +73 -0
  858. package/dist/core/stdlib/values/region.js.map +1 -0
  859. package/dist/core/stdlib/values/tail.d.ts +44 -0
  860. package/dist/core/stdlib/values/tail.d.ts.map +1 -0
  861. package/dist/core/stdlib/values/tail.js +23 -0
  862. package/dist/core/stdlib/values/tail.js.map +1 -0
  863. package/dist/core/stdlib/values/value.d.ts +64 -0
  864. package/dist/core/stdlib/values/value.d.ts.map +1 -0
  865. package/dist/core/stdlib/values/value.js +61 -0
  866. package/dist/core/stdlib/values/value.js.map +1 -0
  867. package/dist/core/stdlib/volatility/bands.d.ts +50 -0
  868. package/dist/core/stdlib/volatility/bands.d.ts.map +1 -0
  869. package/dist/core/stdlib/volatility/bands.js +101 -0
  870. package/dist/core/stdlib/volatility/bands.js.map +1 -0
  871. package/dist/core/stdlib/volatility/deviation.d.ts +43 -0
  872. package/dist/core/stdlib/volatility/deviation.d.ts.map +1 -0
  873. package/dist/core/stdlib/volatility/deviation.js +75 -0
  874. package/dist/core/stdlib/volatility/deviation.js.map +1 -0
  875. package/dist/core/stdlib/volatility/index.d.ts +6 -0
  876. package/dist/core/stdlib/volatility/index.d.ts.map +1 -0
  877. package/dist/core/stdlib/volatility/index.js +5 -0
  878. package/dist/core/stdlib/volatility/index.js.map +1 -0
  879. package/dist/core/stdlib/volatility/measures.d.ts +48 -0
  880. package/dist/core/stdlib/volatility/measures.d.ts.map +1 -0
  881. package/dist/core/stdlib/volatility/measures.js +73 -0
  882. package/dist/core/stdlib/volatility/measures.js.map +1 -0
  883. package/dist/core/stdlib/volatility/range.d.ts +69 -0
  884. package/dist/core/stdlib/volatility/range.d.ts.map +1 -0
  885. package/dist/core/stdlib/volatility/range.js +86 -0
  886. package/dist/core/stdlib/volatility/range.js.map +1 -0
  887. package/dist/core/stdlib/volume/accumulation.d.ts +61 -0
  888. package/dist/core/stdlib/volume/accumulation.d.ts.map +1 -0
  889. package/dist/core/stdlib/volume/accumulation.js +127 -0
  890. package/dist/core/stdlib/volume/accumulation.js.map +1 -0
  891. package/dist/core/stdlib/volume/flow.d.ts +60 -0
  892. package/dist/core/stdlib/volume/flow.d.ts.map +1 -0
  893. package/dist/core/stdlib/volume/flow.js +125 -0
  894. package/dist/core/stdlib/volume/flow.js.map +1 -0
  895. package/dist/core/stdlib/volume/index.d.ts +5 -0
  896. package/dist/core/stdlib/volume/index.d.ts.map +1 -0
  897. package/dist/core/stdlib/volume/index.js +4 -0
  898. package/dist/core/stdlib/volume/index.js.map +1 -0
  899. package/dist/core/stdlib/volume/weighted.d.ts +52 -0
  900. package/dist/core/stdlib/volume/weighted.d.ts.map +1 -0
  901. package/dist/core/stdlib/volume/weighted.js +64 -0
  902. package/dist/core/stdlib/volume/weighted.js.map +1 -0
  903. package/dist/core/version/version.generated.d.ts +2 -2
  904. package/dist/core/version/version.generated.d.ts.map +1 -1
  905. package/dist/core/version/version.generated.js +2 -2
  906. package/dist/core/version/version.generated.js.map +1 -1
  907. package/dist/editor/complete.d.ts +40 -0
  908. package/dist/editor/complete.d.ts.map +1 -0
  909. package/dist/editor/complete.js +206 -0
  910. package/dist/editor/complete.js.map +1 -0
  911. package/dist/editor/diagnose.d.ts +18 -0
  912. package/dist/editor/diagnose.d.ts.map +1 -0
  913. package/dist/editor/diagnose.js +70 -0
  914. package/dist/editor/diagnose.js.map +1 -0
  915. package/dist/editor/format.d.ts +11 -0
  916. package/dist/editor/format.d.ts.map +1 -0
  917. package/dist/editor/format.js +50 -0
  918. package/dist/editor/format.js.map +1 -0
  919. package/dist/editor/highlight.d.ts +28 -0
  920. package/dist/editor/highlight.d.ts.map +1 -0
  921. package/dist/editor/highlight.js +65 -0
  922. package/dist/editor/highlight.js.map +1 -0
  923. package/dist/editor/hover.d.ts +40 -0
  924. package/dist/editor/hover.d.ts.map +1 -0
  925. package/dist/editor/hover.js +147 -0
  926. package/dist/editor/hover.js.map +1 -0
  927. package/dist/editor/index.d.ts +60 -0
  928. package/dist/editor/index.d.ts.map +1 -0
  929. package/dist/editor/index.js +7 -0
  930. package/dist/editor/index.js.map +1 -0
  931. package/dist/editor/kinds.d.ts +27 -0
  932. package/dist/editor/kinds.d.ts.map +1 -0
  933. package/dist/editor/kinds.js +118 -0
  934. package/dist/editor/kinds.js.map +1 -0
  935. package/dist/editor/layout.d.ts +47 -0
  936. package/dist/editor/layout.d.ts.map +1 -0
  937. package/dist/editor/layout.js +135 -0
  938. package/dist/editor/layout.js.map +1 -0
  939. package/dist/editor/manifest.d.ts +47 -0
  940. package/dist/editor/manifest.d.ts.map +1 -0
  941. package/dist/editor/manifest.js +93 -0
  942. package/dist/editor/manifest.js.map +1 -0
  943. package/dist/editor/reading.d.ts +41 -0
  944. package/dist/editor/reading.d.ts.map +1 -0
  945. package/dist/editor/reading.js +51 -0
  946. package/dist/editor/reading.js.map +1 -0
  947. package/dist/editor/scan.d.ts +26 -0
  948. package/dist/editor/scan.d.ts.map +1 -0
  949. package/dist/editor/scan.js +139 -0
  950. package/dist/editor/scan.js.map +1 -0
  951. package/dist/editor/scope.d.ts +19 -0
  952. package/dist/editor/scope.d.ts.map +1 -0
  953. package/dist/editor/scope.js +99 -0
  954. package/dist/editor/scope.js.map +1 -0
  955. package/dist/editor/signature.d.ts +38 -0
  956. package/dist/editor/signature.d.ts.map +1 -0
  957. package/dist/editor/signature.js +112 -0
  958. package/dist/editor/signature.js.map +1 -0
  959. package/dist/editor/site.d.ts +46 -0
  960. package/dist/editor/site.d.ts.map +1 -0
  961. package/dist/editor/site.js +184 -0
  962. package/dist/editor/site.js.map +1 -0
  963. package/dist/editor/spacing.d.ts +29 -0
  964. package/dist/editor/spacing.d.ts.map +1 -0
  965. package/dist/editor/spacing.js +116 -0
  966. package/dist/editor/spacing.js.map +1 -0
  967. package/package.json +66 -15
  968. package/spec/errors.json +522 -183
  969. package/src/adapters/charts/alerts.ts +116 -0
  970. package/src/adapters/charts/bars.ts +63 -0
  971. package/src/adapters/charts/candles.ts +137 -0
  972. package/src/adapters/charts/colours.ts +113 -0
  973. package/src/adapters/charts/columns.ts +99 -0
  974. package/src/adapters/charts/contract.ts +320 -0
  975. package/src/adapters/charts/descriptor.ts +199 -0
  976. package/src/adapters/charts/drawings.ts +213 -0
  977. package/src/adapters/charts/errors.ts +45 -0
  978. package/src/adapters/charts/fields.ts +74 -0
  979. package/src/adapters/charts/fills.ts +71 -0
  980. package/src/adapters/charts/index.ts +78 -0
  981. package/src/adapters/charts/levels.ts +92 -0
  982. package/src/adapters/charts/markers.ts +119 -0
  983. package/src/adapters/charts/paint.ts +101 -0
  984. package/src/adapters/charts/plots.ts +185 -0
  985. package/src/adapters/charts/produced.ts +68 -0
  986. package/src/adapters/charts/requests.ts +357 -0
  987. package/src/adapters/charts/run.ts +327 -0
  988. package/src/adapters/charts/settings.ts +273 -0
  989. package/src/adapters/charts/surfaces.ts +255 -0
  990. package/src/adapters/charts/tables.ts +243 -0
  991. package/src/adapters/codemirror/commands.ts +53 -0
  992. package/src/adapters/codemirror/completion.ts +74 -0
  993. package/src/adapters/codemirror/contract.ts +156 -0
  994. package/src/adapters/codemirror/index.ts +66 -0
  995. package/src/adapters/codemirror/lint.ts +66 -0
  996. package/src/adapters/codemirror/positions.ts +79 -0
  997. package/src/adapters/codemirror/stream.ts +87 -0
  998. package/src/adapters/codemirror/tokens.ts +64 -0
  999. package/src/adapters/codemirror/tooltips.ts +113 -0
  1000. package/src/core/accounting/charges.ts +452 -0
  1001. package/src/core/accounting/equity.ts +276 -0
  1002. package/src/core/accounting/index.ts +49 -0
  1003. package/src/core/accounting/markers.ts +95 -0
  1004. package/src/core/accounting/monthly.ts +137 -0
  1005. package/src/core/accounting/report.ts +89 -0
  1006. package/src/core/accounting/shapes.ts +73 -0
  1007. package/src/core/accounting/statistics.ts +350 -0
  1008. package/src/core/accounting/trades.ts +313 -0
  1009. package/src/core/backtest/compare.ts +244 -0
  1010. package/src/core/backtest/declaration.ts +97 -0
  1011. package/src/core/backtest/drive.ts +364 -0
  1012. package/src/core/backtest/index.ts +52 -0
  1013. package/src/core/backtest/range.ts +137 -0
  1014. package/src/core/backtest/record.ts +341 -0
  1015. package/src/core/backtest/replay.ts +158 -0
  1016. package/src/core/backtest/resting.ts +125 -0
  1017. package/src/core/backtest/settings.ts +280 -0
  1018. package/src/core/backtest/simulate.ts +304 -0
  1019. package/src/core/catalogue/catalogue.generated.ts +23 -9
  1020. package/src/core/catalogue/values.generated.ts +14 -0
  1021. package/src/core/check/arguments.ts +126 -0
  1022. package/src/core/check/call-sites.ts +385 -0
  1023. package/src/core/check/call-warmup.ts +121 -0
  1024. package/src/core/check/calls.ts +412 -0
  1025. package/src/core/check/check.ts +183 -0
  1026. package/src/core/check/checked.ts +228 -0
  1027. package/src/core/check/checker.ts +393 -0
  1028. package/src/core/check/conditional.ts +143 -0
  1029. package/src/core/check/constant.ts +127 -0
  1030. package/src/core/check/declaration.ts +230 -0
  1031. package/src/core/check/expressions.ts +471 -0
  1032. package/src/core/check/functions.ts +283 -0
  1033. package/src/core/check/handles.ts +75 -0
  1034. package/src/core/check/index.ts +70 -0
  1035. package/src/core/check/library-bars.ts +194 -0
  1036. package/src/core/check/library-orders.ts +290 -0
  1037. package/src/core/check/library-output.ts +241 -0
  1038. package/src/core/check/library-prose.generated.ts +367 -0
  1039. package/src/core/check/library-series.ts +457 -0
  1040. package/src/core/check/library.ts +374 -0
  1041. package/src/core/check/literals.ts +35 -0
  1042. package/src/core/check/outputs.ts +152 -0
  1043. package/src/core/check/statements.ts +465 -0
  1044. package/src/core/check/suggest.ts +63 -0
  1045. package/src/core/check/surface.ts +149 -0
  1046. package/src/core/check/tags.ts +94 -0
  1047. package/src/core/check/types.ts +260 -0
  1048. package/src/core/check/warmup.ts +100 -0
  1049. package/src/core/diagnostics/collector.ts +27 -1
  1050. package/src/core/emit/calls.ts +415 -0
  1051. package/src/core/emit/canonical.ts +81 -0
  1052. package/src/core/emit/channels.ts +144 -0
  1053. package/src/core/emit/code.ts +155 -0
  1054. package/src/core/emit/colours.ts +75 -0
  1055. package/src/core/emit/context.ts +461 -0
  1056. package/src/core/emit/defaults.ts +220 -0
  1057. package/src/core/emit/emit.ts +313 -0
  1058. package/src/core/emit/events.ts +141 -0
  1059. package/src/core/emit/expressions.ts +292 -0
  1060. package/src/core/emit/functions.ts +195 -0
  1061. package/src/core/emit/gaps.ts +44 -0
  1062. package/src/core/emit/index.ts +76 -0
  1063. package/src/core/emit/inputs.ts +179 -0
  1064. package/src/core/emit/layout.ts +165 -0
  1065. package/src/core/emit/meta.ts +104 -0
  1066. package/src/core/emit/opcodes.ts +160 -0
  1067. package/src/core/emit/outputs.ts +357 -0
  1068. package/src/core/emit/pool.ts +102 -0
  1069. package/src/core/emit/program.ts +385 -0
  1070. package/src/core/emit/registers.ts +179 -0
  1071. package/src/core/emit/request-scope.ts +52 -0
  1072. package/src/core/emit/requests.ts +258 -0
  1073. package/src/core/emit/requires.ts +91 -0
  1074. package/src/core/emit/sha256.ts +119 -0
  1075. package/src/core/emit/statements.ts +438 -0
  1076. package/src/core/emit/values.ts +284 -0
  1077. package/src/core/engine/alerts.ts +152 -0
  1078. package/src/core/engine/arithmetic.ts +165 -0
  1079. package/src/core/engine/bars.ts +224 -0
  1080. package/src/core/engine/budget.ts +284 -0
  1081. package/src/core/engine/channels.ts +171 -0
  1082. package/src/core/engine/drawings.ts +127 -0
  1083. package/src/core/engine/engine.ts +498 -0
  1084. package/src/core/engine/errors.ts +100 -0
  1085. package/src/core/engine/frames.ts +85 -0
  1086. package/src/core/engine/grids.ts +98 -0
  1087. package/src/core/engine/guard.ts +71 -0
  1088. package/src/core/engine/host.ts +251 -0
  1089. package/src/core/engine/index.ts +93 -0
  1090. package/src/core/engine/inputs.ts +263 -0
  1091. package/src/core/engine/ledger/call.ts +218 -0
  1092. package/src/core/engine/ledger/closable.ts +269 -0
  1093. package/src/core/engine/ledger/holdings.ts +354 -0
  1094. package/src/core/engine/ledger/index.ts +28 -0
  1095. package/src/core/engine/ledger/intent.ts +112 -0
  1096. package/src/core/engine/ledger/ledger.ts +314 -0
  1097. package/src/core/engine/ledger/place.ts +277 -0
  1098. package/src/core/engine/ledger/positions.ts +123 -0
  1099. package/src/core/engine/ledger/refuse.ts +378 -0
  1100. package/src/core/engine/ledger/row.ts +318 -0
  1101. package/src/core/engine/ledger/sizing.ts +292 -0
  1102. package/src/core/engine/library/arrays.ts +316 -0
  1103. package/src/core/engine/library/averages.ts +97 -0
  1104. package/src/core/engine/library/binding.ts +325 -0
  1105. package/src/core/engine/library/chart.ts +115 -0
  1106. package/src/core/engine/library/colours.ts +111 -0
  1107. package/src/core/engine/library/dates.ts +109 -0
  1108. package/src/core/engine/library/index.ts +103 -0
  1109. package/src/core/engine/library/maths.ts +134 -0
  1110. package/src/core/engine/library/objects.ts +265 -0
  1111. package/src/core/engine/library/oscillators.ts +124 -0
  1112. package/src/core/engine/library/ranges.ts +51 -0
  1113. package/src/core/engine/library/series.ts +236 -0
  1114. package/src/core/engine/library/state.ts +47 -0
  1115. package/src/core/engine/library/studies.ts +150 -0
  1116. package/src/core/engine/library/text.ts +303 -0
  1117. package/src/core/engine/library/trend.ts +79 -0
  1118. package/src/core/engine/library/volume.ts +101 -0
  1119. package/src/core/engine/load.ts +118 -0
  1120. package/src/core/engine/machine.ts +446 -0
  1121. package/src/core/engine/memory.ts +129 -0
  1122. package/src/core/engine/operations.ts +171 -0
  1123. package/src/core/engine/orders.ts +121 -0
  1124. package/src/core/engine/registers.ts +104 -0
  1125. package/src/core/engine/request-body.ts +328 -0
  1126. package/src/core/engine/request-plan.ts +270 -0
  1127. package/src/core/engine/requests.ts +382 -0
  1128. package/src/core/engine/results.ts +41 -0
  1129. package/src/core/engine/series.ts +82 -0
  1130. package/src/core/engine/session/hours.ts +86 -0
  1131. package/src/core/engine/session/index.ts +17 -0
  1132. package/src/core/engine/session/record.ts +191 -0
  1133. package/src/core/engine/session/spec.ts +45 -0
  1134. package/src/core/engine/timeframe.ts +161 -0
  1135. package/src/core/engine/types.ts +47 -0
  1136. package/src/core/engine/values/heap.ts +295 -0
  1137. package/src/core/engine/values/index.ts +34 -0
  1138. package/src/core/engine/values/value.ts +158 -0
  1139. package/src/core/engine/verify-budgets.ts +202 -0
  1140. package/src/core/engine/verify-code.ts +332 -0
  1141. package/src/core/engine/verify-requests.ts +255 -0
  1142. package/src/core/engine/verify-shape.ts +164 -0
  1143. package/src/core/engine/verify-tables.ts +176 -0
  1144. package/src/core/engine/verify.ts +341 -0
  1145. package/src/core/index.ts +212 -6
  1146. package/src/core/parse/expressions.ts +1 -1
  1147. package/src/core/parse/names.ts +29 -2
  1148. package/src/core/stdlib/averages/exponential.ts +119 -0
  1149. package/src/core/stdlib/averages/index.ts +45 -0
  1150. package/src/core/stdlib/averages/select.ts +71 -0
  1151. package/src/core/stdlib/averages/shaped.ts +161 -0
  1152. package/src/core/stdlib/averages/simple.ts +139 -0
  1153. package/src/core/stdlib/calendar/civil.ts +89 -0
  1154. package/src/core/stdlib/calendar/fields.ts +124 -0
  1155. package/src/core/stdlib/calendar/format.ts +71 -0
  1156. package/src/core/stdlib/calendar/index.ts +15 -0
  1157. package/src/core/stdlib/calendar/zone.ts +161 -0
  1158. package/src/core/stdlib/index.ts +400 -0
  1159. package/src/core/stdlib/maths/arithmetic.ts +74 -0
  1160. package/src/core/stdlib/maths/elementary.ts +124 -0
  1161. package/src/core/stdlib/maths/index.ts +43 -0
  1162. package/src/core/stdlib/maths/rounding.ts +78 -0
  1163. package/src/core/stdlib/momentum/convergence.ts +82 -0
  1164. package/src/core/stdlib/momentum/index.ts +47 -0
  1165. package/src/core/stdlib/momentum/pressure.ts +141 -0
  1166. package/src/core/stdlib/momentum/rates.ts +188 -0
  1167. package/src/core/stdlib/momentum/rsi.ts +49 -0
  1168. package/src/core/stdlib/momentum/stochastic.ts +147 -0
  1169. package/src/core/stdlib/series/changes.ts +177 -0
  1170. package/src/core/stdlib/series/conditions.ts +74 -0
  1171. package/src/core/stdlib/series/extremes.ts +92 -0
  1172. package/src/core/stdlib/series/index.ts +83 -0
  1173. package/src/core/stdlib/series/pivots.ts +63 -0
  1174. package/src/core/stdlib/series/statistics.ts +207 -0
  1175. package/src/core/stdlib/series/totals.ts +164 -0
  1176. package/src/core/stdlib/trend/directional.ts +196 -0
  1177. package/src/core/stdlib/trend/index.ts +13 -0
  1178. package/src/core/stdlib/trend/psar.ts +131 -0
  1179. package/src/core/stdlib/trend/supertrend.ts +100 -0
  1180. package/src/core/stdlib/values/bar.ts +54 -0
  1181. package/src/core/stdlib/values/index.ts +14 -0
  1182. package/src/core/stdlib/values/lookback.ts +198 -0
  1183. package/src/core/stdlib/values/region.ts +86 -0
  1184. package/src/core/stdlib/values/tail.ts +58 -0
  1185. package/src/core/stdlib/values/value.ts +82 -0
  1186. package/src/core/stdlib/volatility/bands.ts +178 -0
  1187. package/src/core/stdlib/volatility/deviation.ts +111 -0
  1188. package/src/core/stdlib/volatility/index.ts +48 -0
  1189. package/src/core/stdlib/volatility/measures.ts +96 -0
  1190. package/src/core/stdlib/volatility/range.ts +143 -0
  1191. package/src/core/stdlib/volume/accumulation.ts +152 -0
  1192. package/src/core/stdlib/volume/flow.ts +173 -0
  1193. package/src/core/stdlib/volume/index.ts +43 -0
  1194. package/src/core/stdlib/volume/weighted.ts +101 -0
  1195. package/src/core/version/version.generated.ts +2 -2
  1196. package/src/editor/complete.ts +266 -0
  1197. package/src/editor/diagnose.ts +71 -0
  1198. package/src/editor/format.ts +85 -0
  1199. package/src/editor/highlight.ts +110 -0
  1200. package/src/editor/hover.ts +199 -0
  1201. package/src/editor/index.ts +65 -0
  1202. package/src/editor/kinds.ts +157 -0
  1203. package/src/editor/layout.ts +189 -0
  1204. package/src/editor/manifest.ts +119 -0
  1205. package/src/editor/reading.ts +69 -0
  1206. package/src/editor/scan.ts +162 -0
  1207. package/src/editor/scope.ts +122 -0
  1208. package/src/editor/signature.ts +150 -0
  1209. package/src/editor/site.ts +233 -0
  1210. package/src/editor/spacing.ts +132 -0
@@ -0,0 +1,318 @@
1
+ /**
2
+ * One row of the strategy's order and fill ledger, and the fold of one frame
3
+ * into it, `stdlib.md` 17.7 and 17.8.
4
+ *
5
+ * **A row is appended when the order is sent and is never rewritten by
6
+ * guesswork.** Every change to it comes from a frame the destination sent, so
7
+ * the sequence that produced a position can be replayed rather than inferred.
8
+ *
9
+ * **The fold is where double counting happens**, which is why it is written
10
+ * once, here, and why every step of it is the numbered step `stdlib.md` 17.8
11
+ * gives. Frames repeat, cross in flight and arrive after the order they are
12
+ * about has ended, and an engine that added each frame's quantity to a running
13
+ * total would report a position the strategy never held. Taking the greatest
14
+ * cumulative quantity instead makes a repeat cost nothing and makes a terminal
15
+ * frame that overtook a partial one carry the whole remainder in one piece.
16
+ *
17
+ * **A row also carries what its order takes out of the position**, because that
18
+ * is the only record of it that outlives the bar the order was sent on. A
19
+ * position moves when a fill settles, so an order that has been sent and not
20
+ * answered has moved nothing and is invisible to every position figure; the row
21
+ * is where it is visible. `closable.ts` reads the reduction back, and what makes
22
+ * the reading work is that a row already says whether the order is still going:
23
+ * an order neither terminal nor fully filled is one the destination still has.
24
+ */
25
+ import type { Identity, OrderFrame, OrderSide, OrderType } from './intent.js';
26
+
27
+ /**
28
+ * What one order claimed of the part it reduces, in units, when it was sent.
29
+ *
30
+ * Absent on an order that adds to a position, and absent on one whose quantity
31
+ * the engine cannot count in units, which are two different facts with the same
32
+ * consequence: neither subtracts anything from what is left to close.
33
+ *
34
+ * **`claimed` is a claim and not a size**, and the name says so because reading
35
+ * it as a size was a defect twice over. On an order the engine sized itself the
36
+ * two are the same number; on one it could not read they are not, and there it
37
+ * is the whole of what was left to close at the moment the order left, which is
38
+ * the reading `stdlib.md` 17.1 makes for an order it cannot count. That number
39
+ * belongs to one question, how much of a part is already spoken for, and it
40
+ * answers it whatever unit the order itself was written in. The order's own
41
+ * size, where the engine can read it, is `units` on the row beside this.
42
+ */
43
+ export interface Reduction {
44
+ /** The tag the close named, or absent where it reduces the leg as a whole. */
45
+ readonly part: string | null;
46
+ /** The units of that part this order claimed when it was sent. */
47
+ readonly claimed: number;
48
+ /**
49
+ * Whether `claimed` is the order's own quantity or the most it could have
50
+ * been. False on an order whose quantity the engine cannot read in units,
51
+ * where `claimed` is the whole of what was left to close when it was sent.
52
+ */
53
+ readonly counted: boolean;
54
+ }
55
+
56
+ /**
57
+ * The words a row's status may take, `stdlib.md` 17.7.
58
+ *
59
+ * `placed` is the engine's own and no host may send it: it means an intent has
60
+ * left and nothing has come back, and a destination cannot report a state it
61
+ * has never described.
62
+ */
63
+ export type OrderStatus =
64
+ | 'placed'
65
+ | 'working'
66
+ | 'triggerPending'
67
+ | 'filled'
68
+ | 'cancelled'
69
+ | 'rejected'
70
+ | 'expired';
71
+
72
+ const STATUSES: readonly OrderStatus[] = [
73
+ 'placed',
74
+ 'working',
75
+ 'triggerPending',
76
+ 'filled',
77
+ 'cancelled',
78
+ 'rejected',
79
+ 'expired',
80
+ ];
81
+
82
+ /**
83
+ * Which words end an order.
84
+ *
85
+ * A terminal row still takes a fill, under 17.8, so this decides what the
86
+ * status may become and nothing about what the quantity may do.
87
+ */
88
+ const TERMINAL: ReadonlySet<OrderStatus> = new Set<OrderStatus>([
89
+ 'filled',
90
+ 'cancelled',
91
+ 'rejected',
92
+ 'expired',
93
+ ]);
94
+
95
+ /**
96
+ * How far along its life a status sits.
97
+ *
98
+ * Two words share the middle rank because an order that is live and one that is
99
+ * waiting for its trigger are the same distance from the end, and either may
100
+ * follow the other without going backwards.
101
+ */
102
+ function rankOf(status: OrderStatus): number {
103
+ if (status === 'placed') return 0;
104
+ return TERMINAL.has(status) ? 2 : 1;
105
+ }
106
+
107
+ export function isTerminal(status: OrderStatus): boolean {
108
+ return TERMINAL.has(status);
109
+ }
110
+
111
+ /** The word a host sent, or nothing when it is not one of the seven. */
112
+ export function statusFrom(word: string): OrderStatus | undefined {
113
+ return STATUSES.find((one) => one === word);
114
+ }
115
+
116
+ /** A row of the ledger, `stdlib.md` 17.7. */
117
+ export interface LedgerRow {
118
+ readonly intentId: number;
119
+ /** The destination's own reference, recorded, shown, and never parsed. */
120
+ orderRef: string;
121
+ readonly tag: string;
122
+ readonly leg: string;
123
+ readonly positionRef: number;
124
+ /** The contract actually sent, which the host may restate in a frame. */
125
+ instrument: Identity;
126
+ /** The product actually sent, after the host's own translation. */
127
+ product: string;
128
+ readonly side: OrderSide;
129
+ readonly qty: number;
130
+ readonly type: OrderType;
131
+ readonly price: number | null;
132
+ readonly trigger: number | null;
133
+ status: OrderStatus;
134
+ filledQty: number;
135
+ avgFillPrice: number | null;
136
+ rejection: string;
137
+ readonly placedAt: number | null;
138
+ updatedAt: number | null;
139
+ /**
140
+ * What this order claimed of the position, absent where it claimed nothing.
141
+ *
142
+ * Fixed when the order was sent and never rewritten, because it is a record
143
+ * of what the engine measured at that moment and not a running total. What
144
+ * moves is `filledQty` beside it, and the two together say how much of the
145
+ * claim the destination still has.
146
+ */
147
+ readonly reduces: Reduction | null;
148
+ /**
149
+ * This order's own quantity in units, absent where the engine cannot read it.
150
+ *
151
+ * A quantity the script stated is in the declaration's own unit
152
+ * (`host-interface.md` 7.1) and a quantity the engine worked out is in units,
153
+ * and the two are told apart per order rather than per run: a reverse under a
154
+ * declaration counting in lots opens its replacement at a size the engine
155
+ * worked out, in units, on the same bar as orders that are not.
156
+ *
157
+ * `reduces` says what an order takes out of a position and this says what it
158
+ * puts into one, which is the half `holdings.ts` needs to see a position
159
+ * being opened before any of it has settled.
160
+ */
161
+ readonly units: number | null;
162
+ }
163
+
164
+ /**
165
+ * How much of this row's claim on the part it reduces is still outstanding.
166
+ *
167
+ * **An order that has been sent and not answered is the whole of what this
168
+ * file exists to make visible.** A position is folded from settled fills and
169
+ * from nothing else (17.8), so such an order has moved no position figure: the
170
+ * leg still reads what it held before it was sent, and a second reducing order
171
+ * measured against the leg alone sends the position a second time.
172
+ *
173
+ * Four facts decide the number, and each of them is a case a strategy meets:
174
+ *
175
+ * - **A partial fill of an order the engine counted.** Three sold with one
176
+ * filled leaves two working, because the one that filled has already moved
177
+ * the leg and only the other two are still to come.
178
+ * - **A partial fill of one it could not count**, where the claim stands whole
179
+ * until the order ends. The claim is in units and the fill is in whatever
180
+ * the destination answered a quantity in lots, cash or an equity percent
181
+ * with, and subtracting one from the other is the drift this file is written
182
+ * to make impossible: a destination answering more than the claim released
183
+ * room that was never there and the next close sent the position again.
184
+ * - **An order that has ended.** A rejection, a cancellation and an expiry all
185
+ * put the row at a terminal status, and nothing more is coming from any of
186
+ * them, so the claim is released and the strategy may close again. That is
187
+ * the script's way out of a destination that refused its close.
188
+ * - **An order that adds**, which claims nothing and holds nothing: an entry
189
+ * that has not settled is not a position, and counting it would let a close
190
+ * be sent for units that may never exist.
191
+ *
192
+ * **This answers one question and one reader.** What is left to close is a
193
+ * question about a part of the leg, and `closable.ts` is where it is asked.
194
+ * Which side a position reference is on is a different question, asked of one
195
+ * reference against what has settled on it, and `holdings.ts` reads the order's
196
+ * own size for it rather than this.
197
+ */
198
+ export function workingUnits(row: LedgerRow): number {
199
+ const reduces = row.reduces;
200
+ if (reduces === null || isTerminal(row.status)) return 0;
201
+ return reduces.counted ? Math.max(0, reduces.claimed - row.filledQty) : reduces.claimed;
202
+ }
203
+
204
+ /** Why a frame was refused, `stdlib.md` 17.14. */
205
+ export type FrameRefusal = 'unknownIntent' | 'fillWithNoPrice';
206
+
207
+ /**
208
+ * What one frame did.
209
+ *
210
+ * A refused frame changes nothing and is recorded, because a frame naming an
211
+ * order this strategy never placed is a fact about the host rather than about
212
+ * the strategy, and one reporting a fill with no price cannot be marked against
213
+ * anything.
214
+ */
215
+ export interface FrameOutcome {
216
+ readonly intentId: number;
217
+ readonly refused: FrameRefusal | undefined;
218
+ readonly changed: boolean;
219
+ /** Units this frame added, which is what settles against a position. */
220
+ readonly delta: number;
221
+ readonly price: number | null;
222
+ /** Whether the delta arrived after the row had already ended, 17.11. */
223
+ readonly afterTerminal: boolean;
224
+ }
225
+
226
+ function refuse(frame: OrderFrame, why: FrameRefusal): FrameOutcome {
227
+ return {
228
+ intentId: frame.intentId,
229
+ refused: why,
230
+ changed: false,
231
+ delta: 0,
232
+ price: null,
233
+ afterTerminal: false,
234
+ };
235
+ }
236
+
237
+ /**
238
+ * Folds one frame into one row, `stdlib.md` 17.8 steps 2 to 5 and 7.
239
+ *
240
+ * Step 1 is the ledger's, because locating a row is a question about the whole
241
+ * ledger rather than about any one row, and step 6 is the position book's: this
242
+ * function says how many units settled and at what price, and where they settle
243
+ * is `positions.ts`.
244
+ */
245
+ export function foldFrame(row: LedgerRow, frame: OrderFrame): FrameOutcome {
246
+ // A word outside the vocabulary leaves the status alone and the rest of the
247
+ // frame folds anyway. Mapping a destination's own words onto the vocabulary
248
+ // is the host's job under 17.7, and an engine that guessed at one would
249
+ // decide an order was dead on a word it had never seen. Refusing the whole
250
+ // frame instead would throw away the cumulative quantity it carries, which is
251
+ // real whatever the word beside it says, and losing a real fill is silent in
252
+ // exactly the way decision 24 describes.
253
+ const status = statusFrom(frame.status);
254
+
255
+ const wasTerminal = isTerminal(row.status);
256
+
257
+ // Step 2. The cumulative quantity never decreases, so a frame reporting less
258
+ // than the row already holds contributes nothing.
259
+ const filled = Math.max(row.filledQty, frame.filledQty);
260
+ const delta = filled - row.filledQty;
261
+
262
+ // Step 3. The destination computed its average over the cumulative quantity,
263
+ // so the row takes that average whole. The engine never averages two averages
264
+ // of its own.
265
+ const price = frame.avgFillPrice ?? null;
266
+ if (delta > 0 && price === null) return refuse(frame, 'fillWithNoPrice');
267
+
268
+ // Step 4, which a frame arriving at a terminal row does not run: the status
269
+ // records how the order ended and the quantity records what traded, and the
270
+ // two are both true.
271
+ const moved =
272
+ status !== undefined &&
273
+ status !== 'placed' &&
274
+ !wasTerminal &&
275
+ rankOf(status) >= rankOf(row.status) &&
276
+ status !== row.status;
277
+
278
+ const text = frame.text ?? '';
279
+ const newText = text !== '' && text !== row.rejection;
280
+
281
+ // Step 5.
282
+ const changed = moved || delta > 0 || newText;
283
+
284
+ // Step 7. A repeated frame and one overtaken by a later frame both end here,
285
+ // having changed nothing: no fill, no event, no report row.
286
+ if (!changed) {
287
+ return {
288
+ intentId: frame.intentId,
289
+ refused: undefined,
290
+ changed: false,
291
+ delta: 0,
292
+ price: null,
293
+ afterTerminal: false,
294
+ };
295
+ }
296
+
297
+ if (moved && status !== undefined) row.status = status;
298
+ if (delta > 0) {
299
+ row.filledQty = filled;
300
+ row.avgFillPrice = price;
301
+ }
302
+ if (newText) row.rejection = text;
303
+ if (typeof frame.orderRef === 'string') row.orderRef = frame.orderRef;
304
+ if (frame.sentInstrument !== undefined && frame.sentInstrument !== null) {
305
+ row.instrument = frame.sentInstrument;
306
+ }
307
+ if (typeof frame.sentProduct === 'string') row.product = frame.sentProduct;
308
+ if (typeof frame.time === 'number') row.updatedAt = frame.time;
309
+
310
+ return {
311
+ intentId: frame.intentId,
312
+ refused: undefined,
313
+ changed: true,
314
+ delta,
315
+ price: delta > 0 ? price : null,
316
+ afterTerminal: wasTerminal && delta > 0,
317
+ };
318
+ }
@@ -0,0 +1,292 @@
1
+ /**
2
+ * How much each order of a call sends, and which position it is sent against,
3
+ * `stdlib.md` 17.1.
4
+ *
5
+ * **This is the half of a call that is arithmetic.** `place.ts` says what each
6
+ * call means and dispatches to the two functions here; these two decide how many
7
+ * orders the call becomes, how large each is, and which position reference each
8
+ * one carries. They were one file with the dispatch until the second question
9
+ * arrived: issue 0018 is about attachment rather than about quantity, and the
10
+ * two answers are long enough written down that keeping them beside the
11
+ * vocabulary of the calls made one file out of two subjects.
12
+ *
13
+ * The two entry points are `entering`, for a call that states a side and a size,
14
+ * and `flattening`, for one that reduces what the leg holds. What they differ
15
+ * about is not the split but the budget, and the difference is the whole of
16
+ * `holdings.ts`: an entry sends the size the script wrote whatever the leg holds,
17
+ * so the only question is where its units land; a close chooses its own number,
18
+ * so it may only choose one that has settled.
19
+ */
20
+ import { closableUnits } from './closable.js';
21
+ import type { Closing } from './closable.js';
22
+ import { divide, holdings, joining, opposing, outgoingFor } from './holdings.js';
23
+ import type { Book, Holding } from './holdings.js';
24
+ import type { Identity, IntentBar, OrderIntent, OrderSide, OrderType } from './intent.js';
25
+ import type { Reduction } from './row.js';
26
+
27
+ /**
28
+ * An order this run is about to send, before it is given an id.
29
+ *
30
+ * The intent's own shape less the four fields that are the same for every
31
+ * order this run sends, so that the mapping below cannot state one of them
32
+ * differently from one call to the next.
33
+ */
34
+ export type Placement = Omit<OrderIntent, 'intentId' | 'instrument' | 'product' | 'bar'>;
35
+
36
+ /** One order a call sends, and what that order takes out of the leg. */
37
+ export interface MappedOrder {
38
+ readonly placement: Placement;
39
+ readonly reduces: Reduction | null;
40
+ }
41
+
42
+ /** An order that adds to a position, or whose size the engine cannot count. */
43
+ export function adding(placement: Placement): MappedOrder {
44
+ return { placement, reduces: null };
45
+ }
46
+
47
+ /** The fields every placement states, so each case below states only its own. */
48
+ export const NOTHING = {
49
+ side: null,
50
+ qty: null,
51
+ qtyType: 'units',
52
+ type: null,
53
+ limit: null,
54
+ trigger: null,
55
+ target: null,
56
+ stop: null,
57
+ profit: null,
58
+ loss: null,
59
+ } as const;
60
+
61
+ /** What the mapping and the refusals read: the declaration, the leg and the ledger. */
62
+ export interface PlacingContext extends Closing, Book {
63
+ readonly instrument: Identity;
64
+ readonly product: string;
65
+ /** The unit a quantity the script stated is counted in, `language.md` 13.3. */
66
+ readonly qtyType: string;
67
+ /** The size an order that names none takes, from the declaration. */
68
+ readonly declaredQty: number;
69
+ /** The instrument's tick size, absent where the host states none. */
70
+ readonly tickSize: number | null;
71
+ /** Entries allowed in one direction before one is refused, `language.md` 13.3. */
72
+ readonly pyramiding: number;
73
+ readonly bar: IntentBar;
74
+ /** The average price of the open position, absent while flat. */
75
+ avgPrice(): number | null;
76
+ /** A fresh position, for the replacement half of a flip. */
77
+ mint(): number;
78
+ }
79
+
80
+ /** What an entering order states, at one quantity and one position. */
81
+ interface Entry {
82
+ readonly side: OrderSide;
83
+ readonly limit: number | null;
84
+ readonly trigger: number | null;
85
+ readonly type: OrderType;
86
+ readonly tag: string;
87
+ }
88
+
89
+ /** One order of an entry, at the quantity and the position it is given. */
90
+ function placing(entry: Entry, qty: number, qtyType: string, positionRef: number): Placement {
91
+ return {
92
+ ...NOTHING,
93
+ kind: 'place',
94
+ side: entry.side,
95
+ qty,
96
+ qtyType,
97
+ type: entry.type,
98
+ limit: entry.limit,
99
+ trigger: entry.trigger,
100
+ tag: entry.tag,
101
+ positionRef,
102
+ };
103
+ }
104
+
105
+ /**
106
+ * The orders an entry sends, which is two where it crosses zero.
107
+ *
108
+ * **An instruction that would take a leg from long to short is sent as two
109
+ * orders** (`stdlib.md` 17.1), one that closes the outgoing position and one
110
+ * that opens the replacement, each carrying its own position reference. The
111
+ * reason is not tidiness: a single order that crossed zero would leave a late
112
+ * fill with no way to say which of the two positions it settled, and during a
113
+ * flip a leg holds both at once. `sell(qty = abs(pos.size) + more)` is the
114
+ * spelling the documentation teaches, and it is `order.reverse` with the
115
+ * arithmetic written out.
116
+ *
117
+ * **The closing half is what is left to close, not what the leg holds.** An
118
+ * order the destination has not answered has filled nothing, so a leg with a
119
+ * close already going has nothing left for the outgoing half to take, whether
120
+ * that close was sent on this bar or on one before it.
121
+ *
122
+ * **What it crosses is decided per position, not from the leg's net.** The net
123
+ * is folded from settled fills, so on a silent destination it reads zero while
124
+ * an entry is still going and an opposing entry is not seen as opposing
125
+ * anything at all: `buy(qty = 6)` and then `sell(qty = 9)` a bar later put both
126
+ * orders on reference 1, which opened six long and settled three short. The
127
+ * question is about one position rather than about the leg, so it is asked of
128
+ * one position (`holdings.ts`), and the answer is the same whether or not the
129
+ * destination has answered yet.
130
+ *
131
+ * **An order that spans two positions is that many orders.** A leg holds more
132
+ * than one position whenever an order that opposes it is outstanding, and each
133
+ * of them is reduced by an order of its own, oldest first, for the same reason
134
+ * the flip is two orders: a late fill has to be able to say which position it
135
+ * settled.
136
+ *
137
+ * **The reference is minted in every unit; only the arithmetic waits.** The
138
+ * split subtracts a position folded from filled quantities from a quantity the
139
+ * script stated, and those are the same kind of number only in a declaration
140
+ * counting in units: in lots, cash or an equity percent the engine cannot say
141
+ * how much of the instruction closes and how much opens, and the lot size that
142
+ * would tell it is the fact OS7005 is deferred on. Minting a reference needs
143
+ * none of that arithmetic. So an order the engine cannot size against the leg
144
+ * is still sent on a position of its own rather than on the outgoing one:
145
+ * `buy(qty = 3)` then `sell(qty = 9)` under a declaration counting in lots took
146
+ * reference 1 from seventy five units to minus one hundred and fifty, which is
147
+ * the crossing 17.1 is unconditional about and the late fill with no owner the
148
+ * split exists to prevent. What does not hold, and what has to exist before it
149
+ * can, is written where a reader meets it: `stdlib.md` 17.1 and OS7005.
150
+ */
151
+ export function entering(
152
+ ctx: PlacingContext,
153
+ entry: Entry,
154
+ qty: number | null,
155
+ ): readonly MappedOrder[] {
156
+ // The declaration's own size where the call named none, `stdlib.md` 17.2.
157
+ const wanted = qty ?? ctx.declaredQty;
158
+ const book = holdings(ctx);
159
+ // Nothing to cross: the leg holds no position this order opposes, so it opens
160
+ // one or joins the one it is on the side of.
161
+ if (opposing(book, entry.side).length === 0) {
162
+ return [adding(placing(entry, wanted, ctx.qtyType, openingOn(ctx, book, entry.side)))];
163
+ }
164
+
165
+ if (ctx.qtyType !== 'units') {
166
+ return [
167
+ {
168
+ // A position of its own, in every unit, because minting one needs no
169
+ // lot size. On the outgoing reference this order was the crossing
170
+ // 17.1 refuses outright: one order taking one position from one sign
171
+ // to the other, with a late fill on the entry it replaced settling
172
+ // against a book that had already gone the other way.
173
+ placement: placing(entry, wanted, ctx.qtyType, ctx.mint()),
174
+ // Unreadable in units, so it is taken to have reduced the whole of what
175
+ // was left: see `closable.ts` on why that is the only safe reading.
176
+ reduces: { part: null, claimed: closableUnits(ctx, null), counted: false },
177
+ },
178
+ ];
179
+ }
180
+
181
+ // What each position it opposes can absorb, oldest first. A position holding
182
+ // six is sent six of the nine, whether those six have settled or are still
183
+ // going, because six of this order is what brings that position back to zero.
184
+ const split = divide(book, entry.side, wanted, (one) => one.units);
185
+ const out: MappedOrder[] = split.shares.map((share) => ({
186
+ placement: placing(entry, share.units, 'units', share.ref),
187
+ reduces: { part: null, claimed: share.units, counted: true },
188
+ }));
189
+ if (split.left === 0) return out;
190
+ // The replacement is a position of its own where the leg holds none on this
191
+ // side, so that a fill on an outgoing order settles the position it
192
+ // belonged to.
193
+ out.push(adding(placing(entry, split.left, 'units', openingOn(ctx, book, entry.side))));
194
+ return out;
195
+ }
196
+
197
+ /** The reference an order that opens or adds to a position carries. */
198
+ function openingOn(ctx: PlacingContext, book: readonly Holding[], side: OrderSide): number {
199
+ return joining(book, side) ?? ctx.mint();
200
+ }
201
+
202
+ /** One order of a flattening call, at the quantity and position it is given. */
203
+ function reducing(
204
+ side: OrderSide,
205
+ qty: number,
206
+ qtyType: string,
207
+ tag: string,
208
+ positionRef: number,
209
+ ): Placement {
210
+ return { ...NOTHING, kind: 'place', side, qty, qtyType, type: 'market', tag, positionRef };
211
+ }
212
+
213
+ /**
214
+ * The orders a flattening call sends, which is one per position it reduces.
215
+ *
216
+ * A quantity the script stated is in the declaration's own unit and is passed
217
+ * through as written. A quantity the engine worked out is in units, because a
218
+ * filled quantity is what it was folded from.
219
+ *
220
+ * **It is divided across the positions holding it, oldest first.** A leg holds
221
+ * more than one position whenever an order that opposes it is outstanding, and
222
+ * this sized against the whole leg and attached the result to a single
223
+ * reference with nothing asking whether that reference could absorb it: a leg
224
+ * holding two positions was flattened by one order large enough to take the
225
+ * first of them through zero and out the other side. Each position gets an
226
+ * order of its own, bounded by what has settled on it and is not already
227
+ * working against it, which is `closable.ts`'s rule read per position.
228
+ *
229
+ * **Only what has settled on a position**, never what is working into it. A
230
+ * close chooses its own quantity, so a close counting an entry that has not
231
+ * settled would send units that may never exist. That is the one place this
232
+ * differs from an opposing entry, which is sent at the size the script wrote
233
+ * whatever the leg holds, and whose only open question is where its units land.
234
+ *
235
+ * **A quantity the engine cannot read is one order.** It cannot be divided at
236
+ * all, so it goes on the position it is closing, oldest first, and that
237
+ * position is what it may take past zero: the one shape of 17.1 an engine does
238
+ * not keep, named there and in OS7005 and waiting on the same lot size. Which
239
+ * position that is, is not the question the two numbers above answer, and
240
+ * `outgoingFor` is where it is asked: an order that is not choosing a quantity
241
+ * is not held back by a position having no quantity left to give.
242
+ *
243
+ * `part` is what the order is counted against afterwards: the tag a close
244
+ * named, or the leg as a whole. A stated quantity is counted only where the
245
+ * declaration counts in units, for the reason `Reduction` gives.
246
+ */
247
+ export function flattening(
248
+ ctx: PlacingContext,
249
+ units: number,
250
+ side: OrderSide,
251
+ qty: number | null,
252
+ tag: string,
253
+ part: string | null,
254
+ ): readonly MappedOrder[] {
255
+ // Nothing to flatten and no size named: an instruction about a position the
256
+ // strategy does not hold, which is not an error and is not an order either.
257
+ if (units <= 0 && qty === null) return [];
258
+ const sending = qty ?? units;
259
+ // A quantity the engine worked out is counted as itself. One the script
260
+ // stated in a unit the engine cannot read is counted as the whole of what was
261
+ // left, which is what keeps a close after it from sending the position again.
262
+ const counted = qty === null || ctx.qtyType === 'units';
263
+ const book = holdings(ctx);
264
+ if (!counted) {
265
+ // The position it is closing, which is the oldest one holding the side this
266
+ // order reduces (`holdings.ts`). **Where the leg holds no such position the
267
+ // call sends nothing**, which is the same answer the division below gives
268
+ // for the same reason: a close is never minted a position of its own
269
+ // (`stdlib.md` 17.1), and an order sent against a position on its own side
270
+ // would be a close adding to one. A part can read as holding something
271
+ // while no reference does, because a part is netted over the rows carrying
272
+ // one tag and a reference is not.
273
+ const outgoing = outgoingFor(ctx, book, side);
274
+ if (outgoing === null) return [];
275
+ return [
276
+ {
277
+ placement: reducing(side, sending, ctx.qtyType, tag, outgoing),
278
+ reduces: { part, claimed: units, counted: false },
279
+ },
280
+ ];
281
+ }
282
+ // Anything left when every position it reduces is full is left unsent rather
283
+ // than pushed onto one of them past its own size. A close states no quantity
284
+ // of its own, so the next one measures what is left and sends it, which is
285
+ // 17.2's idempotence and not a silence. By construction there is nothing
286
+ // left: what a close may send is the leg's settled net less what is working
287
+ // against it, and that is never more than the positions on that side hold.
288
+ return divide(book, side, sending, (one) => one.settled).shares.map((share) => ({
289
+ placement: reducing(side, share.units, 'units', tag, share.ref),
290
+ reduces: { part, claimed: share.units, counted: true },
291
+ }));
292
+ }