openalgo-script 0.4.0 → 0.6.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 (359) hide show
  1. package/CHANGELOG.md +1050 -0
  2. package/README.md +111 -27
  3. package/dist/adapters/charts/driving.d.ts +50 -0
  4. package/dist/adapters/charts/driving.d.ts.map +1 -0
  5. package/dist/adapters/charts/driving.js +57 -0
  6. package/dist/adapters/charts/driving.js.map +1 -0
  7. package/dist/adapters/charts/run.d.ts +20 -0
  8. package/dist/adapters/charts/run.d.ts.map +1 -1
  9. package/dist/adapters/charts/run.js +89 -16
  10. package/dist/adapters/charts/run.js.map +1 -1
  11. package/dist/adapters/charts/tables.d.ts +6 -19
  12. package/dist/adapters/charts/tables.d.ts.map +1 -1
  13. package/dist/adapters/charts/tables.js.map +1 -1
  14. package/dist/adapters/charts/undrawable.d.ts +4 -0
  15. package/dist/adapters/charts/undrawable.d.ts.map +1 -0
  16. package/dist/adapters/charts/undrawable.js +47 -0
  17. package/dist/adapters/charts/undrawable.js.map +1 -0
  18. package/dist/adapters/charts/venue.d.ts +73 -0
  19. package/dist/adapters/charts/venue.d.ts.map +1 -0
  20. package/dist/adapters/charts/venue.js +104 -0
  21. package/dist/adapters/charts/venue.js.map +1 -0
  22. package/dist/core/accounting/analysis.d.ts +111 -0
  23. package/dist/core/accounting/analysis.d.ts.map +1 -0
  24. package/dist/core/accounting/analysis.js +123 -0
  25. package/dist/core/accounting/analysis.js.map +1 -0
  26. package/dist/core/accounting/equity.d.ts +33 -0
  27. package/dist/core/accounting/equity.d.ts.map +1 -1
  28. package/dist/core/accounting/equity.js +12 -0
  29. package/dist/core/accounting/equity.js.map +1 -1
  30. package/dist/core/accounting/index.d.ts +2 -0
  31. package/dist/core/accounting/index.d.ts.map +1 -1
  32. package/dist/core/accounting/index.js +1 -0
  33. package/dist/core/accounting/index.js.map +1 -1
  34. package/dist/core/accounting/report.d.ts +3 -0
  35. package/dist/core/accounting/report.d.ts.map +1 -1
  36. package/dist/core/accounting/report.js +2 -0
  37. package/dist/core/accounting/report.js.map +1 -1
  38. package/dist/core/accounting/statistics.d.ts +12 -0
  39. package/dist/core/accounting/statistics.d.ts.map +1 -1
  40. package/dist/core/accounting/statistics.js +23 -1
  41. package/dist/core/accounting/statistics.js.map +1 -1
  42. package/dist/core/backtest/case.d.ts +60 -0
  43. package/dist/core/backtest/case.d.ts.map +1 -0
  44. package/dist/core/backtest/case.js +319 -0
  45. package/dist/core/backtest/case.js.map +1 -0
  46. package/dist/core/backtest/compare.d.ts.map +1 -1
  47. package/dist/core/backtest/compare.js +2 -0
  48. package/dist/core/backtest/compare.js.map +1 -1
  49. package/dist/core/backtest/deliver.d.ts +93 -0
  50. package/dist/core/backtest/deliver.d.ts.map +1 -0
  51. package/dist/core/backtest/deliver.js +94 -0
  52. package/dist/core/backtest/deliver.js.map +1 -0
  53. package/dist/core/backtest/drive.d.ts +101 -8
  54. package/dist/core/backtest/drive.d.ts.map +1 -1
  55. package/dist/core/backtest/drive.js +114 -158
  56. package/dist/core/backtest/drive.js.map +1 -1
  57. package/dist/core/backtest/index.d.ts +26 -12
  58. package/dist/core/backtest/index.d.ts.map +1 -1
  59. package/dist/core/backtest/index.js +21 -10
  60. package/dist/core/backtest/index.js.map +1 -1
  61. package/dist/core/backtest/record.d.ts +63 -2
  62. package/dist/core/backtest/record.d.ts.map +1 -1
  63. package/dist/core/backtest/record.js +71 -4
  64. package/dist/core/backtest/record.js.map +1 -1
  65. package/dist/core/backtest/replay.d.ts.map +1 -1
  66. package/dist/core/backtest/replay.js +11 -1
  67. package/dist/core/backtest/replay.js.map +1 -1
  68. package/dist/core/backtest/simulate.d.ts +113 -1
  69. package/dist/core/backtest/simulate.d.ts.map +1 -1
  70. package/dist/core/backtest/simulate.js +123 -5
  71. package/dist/core/backtest/simulate.js.map +1 -1
  72. package/dist/core/backtest/walk.d.ts +39 -0
  73. package/dist/core/backtest/walk.d.ts.map +1 -0
  74. package/dist/core/backtest/walk.js +125 -0
  75. package/dist/core/backtest/walk.js.map +1 -0
  76. package/dist/core/catalogue/catalogue.generated.d.ts +179 -2
  77. package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
  78. package/dist/core/catalogue/catalogue.generated.js +19 -2
  79. package/dist/core/catalogue/catalogue.generated.js.map +1 -1
  80. package/dist/core/catalogue/types.d.ts +8 -2
  81. package/dist/core/catalogue/types.d.ts.map +1 -1
  82. package/dist/core/catalogue/values.generated.d.ts +51 -0
  83. package/dist/core/catalogue/values.generated.d.ts.map +1 -1
  84. package/dist/core/check/assigned.d.ts +19 -0
  85. package/dist/core/check/assigned.d.ts.map +1 -0
  86. package/dist/core/check/assigned.js +14 -0
  87. package/dist/core/check/assigned.js.map +1 -0
  88. package/dist/core/check/call-sites.d.ts.map +1 -1
  89. package/dist/core/check/call-sites.js +9 -4
  90. package/dist/core/check/call-sites.js.map +1 -1
  91. package/dist/core/check/calls.d.ts.map +1 -1
  92. package/dist/core/check/calls.js +12 -4
  93. package/dist/core/check/calls.js.map +1 -1
  94. package/dist/core/check/check.d.ts.map +1 -1
  95. package/dist/core/check/check.js +15 -2
  96. package/dist/core/check/check.js.map +1 -1
  97. package/dist/core/check/checker.d.ts +26 -0
  98. package/dist/core/check/checker.d.ts.map +1 -1
  99. package/dist/core/check/checker.js +38 -2
  100. package/dist/core/check/checker.js.map +1 -1
  101. package/dist/core/check/constant.d.ts +16 -0
  102. package/dist/core/check/constant.d.ts.map +1 -1
  103. package/dist/core/check/constant.js +52 -0
  104. package/dist/core/check/constant.js.map +1 -1
  105. package/dist/core/check/deleted.d.ts +3 -0
  106. package/dist/core/check/deleted.d.ts.map +1 -0
  107. package/dist/core/check/deleted.js +109 -0
  108. package/dist/core/check/deleted.js.map +1 -0
  109. package/dist/core/check/expressions.js +1 -1
  110. package/dist/core/check/expressions.js.map +1 -1
  111. package/dist/core/check/library-orders.js +2 -2
  112. package/dist/core/check/library-orders.js.map +1 -1
  113. package/dist/core/check/library-output.d.ts.map +1 -1
  114. package/dist/core/check/library-output.js +1 -0
  115. package/dist/core/check/library-output.js.map +1 -1
  116. package/dist/core/check/library-prose.generated.js +12 -12
  117. package/dist/core/check/library-prose.generated.js.map +1 -1
  118. package/dist/core/check/library.d.ts +7 -0
  119. package/dist/core/check/library.d.ts.map +1 -1
  120. package/dist/core/check/library.js +1 -0
  121. package/dist/core/check/library.js.map +1 -1
  122. package/dist/core/check/surface.d.ts +9 -0
  123. package/dist/core/check/surface.d.ts.map +1 -1
  124. package/dist/core/check/surface.js +13 -0
  125. package/dist/core/check/surface.js.map +1 -1
  126. package/dist/core/emit/canonical.d.ts +22 -8
  127. package/dist/core/emit/canonical.d.ts.map +1 -1
  128. package/dist/core/emit/canonical.js +67 -6
  129. package/dist/core/emit/canonical.js.map +1 -1
  130. package/dist/core/engine/arithmetic.d.ts +6 -25
  131. package/dist/core/engine/arithmetic.d.ts.map +1 -1
  132. package/dist/core/engine/arithmetic.js +48 -3
  133. package/dist/core/engine/arithmetic.js.map +1 -1
  134. package/dist/core/engine/bar-source.d.ts +65 -0
  135. package/dist/core/engine/bar-source.d.ts.map +1 -0
  136. package/dist/core/engine/bar-source.js +58 -0
  137. package/dist/core/engine/bar-source.js.map +1 -0
  138. package/dist/core/engine/engine.d.ts +9 -11
  139. package/dist/core/engine/engine.d.ts.map +1 -1
  140. package/dist/core/engine/engine.js +24 -24
  141. package/dist/core/engine/engine.js.map +1 -1
  142. package/dist/core/engine/guard.d.ts.map +1 -1
  143. package/dist/core/engine/guard.js +10 -0
  144. package/dist/core/engine/guard.js.map +1 -1
  145. package/dist/core/engine/host.d.ts +4 -2
  146. package/dist/core/engine/host.d.ts.map +1 -1
  147. package/dist/core/engine/host.js.map +1 -1
  148. package/dist/core/engine/index.d.ts +2 -1
  149. package/dist/core/engine/index.d.ts.map +1 -1
  150. package/dist/core/engine/index.js +1 -1
  151. package/dist/core/engine/index.js.map +1 -1
  152. package/dist/core/engine/library/arrays.d.ts.map +1 -1
  153. package/dist/core/engine/library/arrays.js +8 -2
  154. package/dist/core/engine/library/arrays.js.map +1 -1
  155. package/dist/core/engine/library/binding.d.ts +2 -0
  156. package/dist/core/engine/library/binding.d.ts.map +1 -1
  157. package/dist/core/engine/library/binding.js.map +1 -1
  158. package/dist/core/engine/library/code-points.d.ts +40 -0
  159. package/dist/core/engine/library/code-points.d.ts.map +1 -0
  160. package/dist/core/engine/library/code-points.js +74 -0
  161. package/dist/core/engine/library/code-points.js.map +1 -0
  162. package/dist/core/engine/library/index.d.ts +13 -0
  163. package/dist/core/engine/library/index.d.ts.map +1 -1
  164. package/dist/core/engine/library/index.js +15 -0
  165. package/dist/core/engine/library/index.js.map +1 -1
  166. package/dist/core/engine/library/objects.d.ts.map +1 -1
  167. package/dist/core/engine/library/objects.js +1 -1
  168. package/dist/core/engine/library/objects.js.map +1 -1
  169. package/dist/core/engine/library/text.d.ts.map +1 -1
  170. package/dist/core/engine/library/text.js +51 -34
  171. package/dist/core/engine/library/text.js.map +1 -1
  172. package/dist/core/engine/load.d.ts +20 -0
  173. package/dist/core/engine/load.d.ts.map +1 -1
  174. package/dist/core/engine/load.js +62 -0
  175. package/dist/core/engine/load.js.map +1 -1
  176. package/dist/core/engine/request-body.d.ts +3 -1
  177. package/dist/core/engine/request-body.d.ts.map +1 -1
  178. package/dist/core/engine/request-body.js +3 -1
  179. package/dist/core/engine/request-body.js.map +1 -1
  180. package/dist/core/engine/request-plan.d.ts +3 -3
  181. package/dist/core/engine/request-plan.js +3 -3
  182. package/dist/core/engine/requests.d.ts +2 -2
  183. package/dist/core/engine/requests.d.ts.map +1 -1
  184. package/dist/core/engine/requests.js +5 -4
  185. package/dist/core/engine/requests.js.map +1 -1
  186. package/dist/core/engine/series.d.ts +18 -6
  187. package/dist/core/engine/series.d.ts.map +1 -1
  188. package/dist/core/engine/series.js +24 -5
  189. package/dist/core/engine/series.js.map +1 -1
  190. package/dist/core/engine/session/record.d.ts +4 -4
  191. package/dist/core/engine/session/record.js +4 -4
  192. package/dist/core/engine/verify-tables.d.ts.map +1 -1
  193. package/dist/core/engine/verify-tables.js +41 -0
  194. package/dist/core/engine/verify-tables.js.map +1 -1
  195. package/dist/core/importer/calls.d.ts +29 -0
  196. package/dist/core/importer/calls.d.ts.map +1 -0
  197. package/dist/core/importer/calls.js +267 -0
  198. package/dist/core/importer/calls.js.map +1 -0
  199. package/dist/core/importer/context.d.ts +118 -0
  200. package/dist/core/importer/context.d.ts.map +1 -0
  201. package/dist/core/importer/context.js +120 -0
  202. package/dist/core/importer/context.js.map +1 -0
  203. package/dist/core/importer/expressions.d.ts +44 -0
  204. package/dist/core/importer/expressions.d.ts.map +1 -0
  205. package/dist/core/importer/expressions.js +223 -0
  206. package/dist/core/importer/expressions.js.map +1 -0
  207. package/dist/core/importer/importer.d.ts +13 -0
  208. package/dist/core/importer/importer.d.ts.map +1 -0
  209. package/dist/core/importer/importer.js +220 -0
  210. package/dist/core/importer/importer.js.map +1 -0
  211. package/dist/core/importer/index.d.ts +20 -0
  212. package/dist/core/importer/index.d.ts.map +1 -0
  213. package/dist/core/importer/index.js +18 -0
  214. package/dist/core/importer/index.js.map +1 -0
  215. package/dist/core/importer/lexer.d.ts +68 -0
  216. package/dist/core/importer/lexer.d.ts.map +1 -0
  217. package/dist/core/importer/lexer.js +207 -0
  218. package/dist/core/importer/lexer.js.map +1 -0
  219. package/dist/core/importer/names.d.ts +41 -0
  220. package/dist/core/importer/names.d.ts.map +1 -0
  221. package/dist/core/importer/names.js +78 -0
  222. package/dist/core/importer/names.js.map +1 -0
  223. package/dist/core/importer/orders.d.ts +8 -0
  224. package/dist/core/importer/orders.d.ts.map +1 -0
  225. package/dist/core/importer/orders.js +332 -0
  226. package/dist/core/importer/orders.js.map +1 -0
  227. package/dist/core/importer/outputs.d.ts +19 -0
  228. package/dist/core/importer/outputs.d.ts.map +1 -0
  229. package/dist/core/importer/outputs.js +266 -0
  230. package/dist/core/importer/outputs.js.map +1 -0
  231. package/dist/core/importer/parser.d.ts +5 -0
  232. package/dist/core/importer/parser.d.ts.map +1 -0
  233. package/dist/core/importer/parser.js +439 -0
  234. package/dist/core/importer/parser.js.map +1 -0
  235. package/dist/core/importer/presence.d.ts +32 -0
  236. package/dist/core/importer/presence.d.ts.map +1 -0
  237. package/dist/core/importer/presence.js +146 -0
  238. package/dist/core/importer/presence.js.map +1 -0
  239. package/dist/core/importer/settle.d.ts +23 -0
  240. package/dist/core/importer/settle.d.ts.map +1 -0
  241. package/dist/core/importer/settle.js +135 -0
  242. package/dist/core/importer/settle.js.map +1 -0
  243. package/dist/core/importer/statements.d.ts +4 -0
  244. package/dist/core/importer/statements.d.ts.map +1 -0
  245. package/dist/core/importer/statements.js +339 -0
  246. package/dist/core/importer/statements.js.map +1 -0
  247. package/dist/core/importer/syntax.d.ts +182 -0
  248. package/dist/core/importer/syntax.d.ts.map +1 -0
  249. package/dist/core/importer/syntax.js +14 -0
  250. package/dist/core/importer/syntax.js.map +1 -0
  251. package/dist/core/importer/table.d.ts +52 -0
  252. package/dist/core/importer/table.d.ts.map +1 -0
  253. package/dist/core/importer/table.js +156 -0
  254. package/dist/core/importer/table.js.map +1 -0
  255. package/dist/core/importer/values.d.ts +27 -0
  256. package/dist/core/importer/values.d.ts.map +1 -0
  257. package/dist/core/importer/values.js +236 -0
  258. package/dist/core/importer/values.js.map +1 -0
  259. package/dist/core/index.d.ts +22 -5
  260. package/dist/core/index.d.ts.map +1 -1
  261. package/dist/core/index.js +19 -3
  262. package/dist/core/index.js.map +1 -1
  263. package/dist/core/stdlib/calendar/civil.d.ts.map +1 -1
  264. package/dist/core/stdlib/calendar/civil.js +5 -2
  265. package/dist/core/stdlib/calendar/civil.js.map +1 -1
  266. package/dist/core/stdlib/index.d.ts +1 -1
  267. package/dist/core/stdlib/index.d.ts.map +1 -1
  268. package/dist/core/stdlib/index.js +1 -1
  269. package/dist/core/stdlib/index.js.map +1 -1
  270. package/dist/core/stdlib/maths/index.d.ts +1 -1
  271. package/dist/core/stdlib/maths/index.d.ts.map +1 -1
  272. package/dist/core/stdlib/maths/index.js +1 -1
  273. package/dist/core/stdlib/maths/index.js.map +1 -1
  274. package/dist/core/stdlib/maths/rounding.d.ts +5 -0
  275. package/dist/core/stdlib/maths/rounding.d.ts.map +1 -1
  276. package/dist/core/stdlib/maths/rounding.js +19 -1
  277. package/dist/core/stdlib/maths/rounding.js.map +1 -1
  278. package/dist/core/version/version.generated.d.ts +1 -1
  279. package/dist/core/version/version.generated.js +1 -1
  280. package/package.json +17 -2
  281. package/spec/README.md +2 -1
  282. package/spec/errors.json +383 -23
  283. package/src/adapters/charts/driving.ts +109 -0
  284. package/src/adapters/charts/run.ts +126 -28
  285. package/src/adapters/charts/tables.ts +6 -19
  286. package/src/adapters/charts/undrawable.ts +51 -0
  287. package/src/adapters/charts/venue.ts +132 -0
  288. package/src/core/accounting/analysis.ts +188 -0
  289. package/src/core/accounting/equity.ts +38 -0
  290. package/src/core/accounting/index.ts +2 -0
  291. package/src/core/accounting/report.ts +5 -0
  292. package/src/core/accounting/statistics.ts +38 -1
  293. package/src/core/backtest/case.ts +395 -0
  294. package/src/core/backtest/compare.ts +2 -0
  295. package/src/core/backtest/deliver.ts +161 -0
  296. package/src/core/backtest/drive.ts +233 -217
  297. package/src/core/backtest/index.ts +26 -12
  298. package/src/core/backtest/record.ts +134 -5
  299. package/src/core/backtest/replay.ts +11 -1
  300. package/src/core/backtest/simulate.ts +201 -6
  301. package/src/core/backtest/walk.ts +182 -0
  302. package/src/core/catalogue/catalogue.generated.ts +19 -2
  303. package/src/core/catalogue/types.ts +8 -2
  304. package/src/core/catalogue/values.generated.ts +16 -0
  305. package/src/core/check/assigned.ts +31 -0
  306. package/src/core/check/call-sites.ts +11 -4
  307. package/src/core/check/calls.ts +13 -4
  308. package/src/core/check/check.ts +14 -2
  309. package/src/core/check/checker.ts +39 -2
  310. package/src/core/check/constant.ts +57 -0
  311. package/src/core/check/deleted.ts +135 -0
  312. package/src/core/check/expressions.ts +1 -1
  313. package/src/core/check/library-orders.ts +2 -2
  314. package/src/core/check/library-output.ts +1 -0
  315. package/src/core/check/library-prose.generated.ts +12 -12
  316. package/src/core/check/library.ts +8 -0
  317. package/src/core/check/surface.ts +16 -0
  318. package/src/core/emit/canonical.ts +67 -9
  319. package/src/core/engine/arithmetic.ts +23 -3
  320. package/src/core/engine/bar-source.ts +113 -0
  321. package/src/core/engine/engine.ts +26 -25
  322. package/src/core/engine/guard.ts +12 -1
  323. package/src/core/engine/host.ts +4 -2
  324. package/src/core/engine/index.ts +2 -1
  325. package/src/core/engine/library/arrays.ts +8 -2
  326. package/src/core/engine/library/binding.ts +2 -0
  327. package/src/core/engine/library/code-points.ts +73 -0
  328. package/src/core/engine/library/index.ts +17 -0
  329. package/src/core/engine/library/objects.ts +1 -6
  330. package/src/core/engine/library/text.ts +53 -35
  331. package/src/core/engine/load.ts +68 -0
  332. package/src/core/engine/request-body.ts +5 -7
  333. package/src/core/engine/request-plan.ts +3 -3
  334. package/src/core/engine/requests.ts +11 -8
  335. package/src/core/engine/series.ts +30 -6
  336. package/src/core/engine/session/record.ts +4 -4
  337. package/src/core/engine/verify-tables.ts +43 -0
  338. package/src/core/importer/calls.ts +274 -0
  339. package/src/core/importer/context.ts +197 -0
  340. package/src/core/importer/expressions.ts +247 -0
  341. package/src/core/importer/importer.ts +226 -0
  342. package/src/core/importer/index.ts +19 -0
  343. package/src/core/importer/lexer.ts +285 -0
  344. package/src/core/importer/names.ts +104 -0
  345. package/src/core/importer/orders.ts +307 -0
  346. package/src/core/importer/outputs.ts +245 -0
  347. package/src/core/importer/parser.ts +436 -0
  348. package/src/core/importer/presence.ts +164 -0
  349. package/src/core/importer/settle.ts +141 -0
  350. package/src/core/importer/statements.ts +331 -0
  351. package/src/core/importer/syntax.ts +144 -0
  352. package/src/core/importer/table.ts +191 -0
  353. package/src/core/importer/values.ts +241 -0
  354. package/src/core/index.ts +29 -2
  355. package/src/core/stdlib/calendar/civil.ts +5 -2
  356. package/src/core/stdlib/index.ts +1 -0
  357. package/src/core/stdlib/maths/index.ts +1 -0
  358. package/src/core/stdlib/maths/rounding.ts +23 -1
  359. package/src/core/version/version.generated.ts +1 -1
@@ -25,16 +25,65 @@
25
25
  * is reported on bar k + 1. A frame answered after the last bar has no boundary
26
26
  * left to fold at: it is not delivered, it is not recorded as delivered, and
27
27
  * the order it was about is in the ledger at whatever it last said.
28
+ *
29
+ * **Two drivers, and the only difference between them is where the frames come
30
+ * from.** `backtest` runs against the simulated destination, which decides a
31
+ * fill from the bars and answers frames of its own; `backtestSupplied` is
32
+ * handed the frames and delivers those. Everything else about the two is one
33
+ * function below: the same window, the same load, the same refusals, the same
34
+ * loop and the same record.
28
35
  */
29
36
  import { reportOf, scheduleFromDeclaration } from '../accounting/index.js';
30
37
  import { load } from '../engine/index.js';
31
38
  import { declarationOf } from './declaration.js';
39
+ import { Delivery, framedAs, ordinalsOf } from './deliver.js';
32
40
  import { marksFor, windowFor } from './range.js';
33
- import { diagnosticIn, orderIn, recordOf } from './record.js';
41
+ import { orderIn, recordOf } from './record.js';
34
42
  import { Simulator } from './simulate.js';
35
43
  import { checkSettings } from './settings.js';
44
+ import { walk } from './walk.js';
45
+ /**
46
+ * One run against a simulated destination, from a compiled program to a record.
47
+ *
48
+ * The frames are the destination's own: it is handed the orders, it reads the
49
+ * bars, and what it answers is what the engine folds. A run whose frames
50
+ * somebody else is supplying is `backtestSupplied` below.
51
+ */
52
+ export function backtest(program, bars, settings, options = {}) {
53
+ return drive(program, bars, settings, options, (declared, schedule) => simulated(new Simulator({
54
+ bars,
55
+ contract: settings.contract,
56
+ fill: settings.fill,
57
+ slippageTicks: schedule.slippageTicks,
58
+ fillOn: declared.fillOn,
59
+ qtyType: declared.qtyType,
60
+ })));
61
+ }
36
62
  /**
37
- * One run, from a compiled program to a record of it.
63
+ * One run over the frames somebody else supplied, which this engine does not
64
+ * choose and does not add to.
65
+ *
66
+ * `conformance.md` section 3 gives a case a `frames.csv` that supplies order
67
+ * frames the way `bars.csv` supplies bars, so that a case asserts the fold
68
+ * against input the engine did not choose. Every other argument is `backtest`'s
69
+ * and means there what it means here. A row is delivered at the boundary it
70
+ * names and folded before the next bar, and the record carries the rows it was
71
+ * handed rather than a second spelling of them.
72
+ *
73
+ * **Nothing is invented.** No fill is priced off a bar, no order rests and no
74
+ * schedule is read, so an order the frames say nothing about stays where its
75
+ * placement left it, which is what a case saying nothing about it means.
76
+ *
77
+ * **A record made here is a record of this run and not of a simulated one.**
78
+ * `rerun` puts a record's program back on a simulated destination, because a
79
+ * record does not say which of the two answered it, so a rerun of one of these
80
+ * reproduces it only where that destination would answer these same frames.
81
+ */
82
+ export function backtestSupplied(program, bars, settings, frames, options = {}) {
83
+ return drive(program, bars, settings, options, () => new Delivery(frames));
84
+ }
85
+ /**
86
+ * The run both drivers are, and the one place a record is made.
38
87
  *
39
88
  * A refusal before the first bar comes back as a refusal and not as a record:
40
89
  * a program that would not load, a setting that cannot be applied and a window
@@ -42,19 +91,22 @@ import { checkSettings } from './settings.js';
42
91
  * be a document asserting figures nothing computed. A failure during a bar is
43
92
  * the other way round: the run happened, it stopped, and the record carries
44
93
  * both what it did and the diagnostic that stopped it.
94
+ *
95
+ * **The destination is chosen after the program is loaded**, which is why it
96
+ * arrives as a function of the declaration and the schedule: the bar a market
97
+ * order is priced at is the declaration's, and the declaration is resolved at
98
+ * load. The route is wired first and reaches whatever is chosen through the
99
+ * binding below, which is what lets one host serve both halves.
45
100
  */
46
- export function backtest(program, bars, settings, options = {}) {
101
+ function drive(program, bars, settings, options, choose) {
47
102
  const framed = windowFor(bars, settings.range);
48
103
  if (!framed.ok)
49
104
  return { ok: false, diagnostic: framed.diagnostic };
50
- // The venue is built after the program is loaded, because the bar a market
51
- // order is priced at is the declaration's and the declaration is resolved at
52
- // load. The route is wired first and reaches it through this binding, which
53
- // is what lets one host serve both halves.
54
- let venue;
105
+ let sending;
106
+ const instrument = instrumentFor(settings.contract, options.instrument ?? {});
55
107
  const loaded = load(program, {
56
108
  settings: settings.inputs,
57
- host: hostFor(settings, (effect, bar) => venue?.route(effect, bar)),
109
+ host: hostFor(instrument, settings.now, (effect, bar) => sending?.route(effect, bar), options.requestBars),
58
110
  });
59
111
  if (!loaded.ok)
60
112
  return { ok: false, diagnostic: loaded.diagnostic };
@@ -64,156 +116,40 @@ export function backtest(program, bars, settings, options = {}) {
64
116
  if (problem !== null)
65
117
  return { ok: false, diagnostic: problem };
66
118
  const schedule = scheduleFor(settings, declared);
67
- venue = new Simulator({
68
- bars,
69
- contract: settings.contract,
70
- fill: settings.fill,
71
- slippageTicks: schedule.slippageTicks,
72
- fillOn: declared.fillOn,
73
- qtyType: declared.qtyType,
74
- });
75
- const run = walk(engine, venue, bars, framed.covered);
76
- const ordinals = ordinalsOf(venue.intents);
119
+ const destination = choose(declared, schedule);
120
+ sending = destination;
121
+ const run = walk(engine, destination, bars, framed.covered, options);
122
+ const ordinals = ordinalsOf(destination.intents);
77
123
  const marks = marksFor(bars, framed.covered);
78
124
  return {
79
125
  ok: true,
126
+ ...(options.rows === true ? { rows: run.rows } : {}),
127
+ ...(options.log === true ? { log: run.log } : {}),
128
+ ...(options.surface === true ? { surface: { drawings: engine.drawings(), tables: engine.tables() } } : {}),
80
129
  record: recordOf({
81
130
  program: engine.program,
131
+ ...(options.sourceText === undefined ? {} : { sourceText: options.sourceText }),
82
132
  settings,
133
+ instrument,
83
134
  bars,
84
135
  form: options.form ?? 'inline',
85
- frames: run.frames.map((one) => framedAs(one.frame, one.afterBar, ordinals)),
136
+ // The row where a case supplied one, because that row is the input and a
137
+ // record of a run over it says what it was given rather than what it
138
+ // would have written down had it decided the frame itself.
139
+ frames: run.frames.map((one) => one.row ?? framedAs(one.frame, one.afterBar, ordinals)),
86
140
  fills: run.fills,
87
- orders: ordersOf(engine.orders(), venue.intents, ordinals),
141
+ orders: ordersOf(engine.orders(), destination.intents, ordinals),
88
142
  diagnostics: run.diagnostics,
89
143
  report: reportOf(run.fills, marks, schedule, settings.contract, declared.capital),
90
144
  }),
91
145
  };
92
146
  }
93
- /**
94
- * The bars, in order, with the venue answering between them.
95
- *
96
- * The one ordering rule: deliver, then append, then collect what the append
97
- * reported, then ask the venue what this bar did. A driver that asked the venue
98
- * before appending would price a fill against a bar the strategy had not seen.
99
- */
100
- function walk(engine, venue, bars, covered) {
101
- const fills = [];
102
- const frames = [];
103
- const diagnostics = [];
104
- const intents = new Map();
105
- const refs = new Map();
106
- const sizes = new Map();
107
- let pending = [];
108
- let seq = 0;
109
- for (let index = 0; index < covered.total; index += 1) {
110
- const bar = bars[index];
111
- if (bar === undefined)
112
- continue;
113
- for (const one of pending) {
114
- const ref = one.frame.orderRef;
115
- if (typeof ref === 'string')
116
- refs.set(one.frame.intentId, ref);
117
- engine.deliver(one.frame);
118
- frames.push(one);
119
- }
120
- pending = [];
121
- const result = engine.append({ time: bar.time, open: bar.open, high: bar.high, low: bar.low, close: bar.close,
122
- volume: bar.volume, oi: bar.oi }, { isConfirmed: true, isRealtime: false }, covered.total);
123
- for (const intent of intentsIn(result))
124
- intents.set(intent.intentId, intent);
125
- seq = settle(result, index, bar, { intents, refs, sizes }, fills, seq);
126
- if (result.diagnostic !== undefined) {
127
- diagnostics.push(diagnosticIn(result.diagnostic, index));
128
- break;
129
- }
130
- pending = venue.framesFor(index).map((frame) => ({ frame, afterBar: index }));
131
- }
132
- return { fills, frames, diagnostics };
133
- }
134
- /**
135
- * The fills one bar's fold settled.
136
- *
137
- * **The position sizes either side of step 6 are kept here and not read back
138
- * from the engine**, because the engine reports a leg's net and a fill settles
139
- * against one position reference: the two are different numbers whenever a leg
140
- * holds more than one position, which is every flip. They are folded in the
141
- * order the frames were folded in, from the same deltas, so they are the same
142
- * arithmetic the position book did rather than a second reading of its result.
143
- * When `FrameOutcome` carries them, these two lines come from the engine and
144
- * this fold keeps only the sequence number.
145
- *
146
- * A refused frame settles nothing and is not a fill. Today the fold reports the
147
- * refusal as a word rather than a code, so nothing here can write it into the
148
- * record as a diagnostic; that is OS7018 and OS7019, and both are deferred.
149
- */
150
- function settle(result, index, bar, books, fills, from) {
151
- let seq = from;
152
- for (const outcome of result.frames) {
153
- if (outcome.refused !== undefined)
154
- continue;
155
- if (outcome.delta <= 0 || outcome.price === null)
156
- continue;
157
- const intent = books.intents.get(outcome.intentId);
158
- if (intent === undefined || intent.side === null)
159
- continue;
160
- const before = books.sizes.get(intent.positionRef) ?? 0;
161
- const after = before + (intent.side === 'sell' ? -outcome.delta : outcome.delta);
162
- books.sizes.set(intent.positionRef, after);
163
- seq += 1;
164
- fills.push({
165
- seq,
166
- intentId: outcome.intentId,
167
- orderRef: books.refs.get(outcome.intentId) ?? '',
168
- tag: intent.tag,
169
- positionRef: intent.positionRef,
170
- side: intent.side,
171
- units: outcome.delta,
172
- price: outcome.price,
173
- // The bar the fold happened at, which is the bar the position exists
174
- // from. Where the fill itself traded is the bar before it or this bar's
175
- // own open, and neither is a bar the strategy could have acted on it in.
176
- barIndex: index,
177
- barTime: bar.time,
178
- refSizeBefore: before,
179
- refSizeAfter: after,
180
- });
181
- }
182
- return seq;
183
- }
184
- /** Every intent one bar handed over, in the order the bar applied them. */
185
- function intentsIn(result) {
186
- const out = [];
187
- for (const effect of result.effects)
188
- for (const intent of effect.intents)
189
- out.push(intent);
190
- return out;
191
- }
192
- /**
193
- * The ordinal of every intent, which is how a case names one.
194
- *
195
- * One, two, three in the order the run placed them, because no engine can know
196
- * the id another minted and a case that named one would only ever be readable
197
- * by the engine that wrote it.
198
- */
199
- function ordinalsOf(intents) {
200
- const out = new Map();
201
- for (const intent of intents) {
202
- if (!out.has(intent.intentId))
203
- out.set(intent.intentId, out.size + 1);
204
- }
205
- return out;
206
- }
207
- /** One delivered frame, in the columns a case file prints. */
208
- function framedAs(frame, afterBar, ordinals) {
147
+ /** The simulated destination, as a destination the loop below can drive. */
148
+ function simulated(venue) {
209
149
  return {
210
- afterBar,
211
- intent: ordinals.get(frame.intentId) ?? 0,
212
- status: frame.status,
213
- filledQty: frame.filledQty,
214
- avgFillPrice: frame.avgFillPrice ?? null,
215
- orderRef: frame.orderRef ?? null,
216
- text: frame.text ?? null,
150
+ route: (effect, barIndex) => venue.route(effect, barIndex),
151
+ answers: (barIndex) => venue.framesFor(barIndex).map((frame) => ({ frame, afterBar: barIndex, row: null })),
152
+ intents: venue.intents,
217
153
  };
218
154
  }
219
155
  /** The ledger at the end, copied out of the engine's own array. */
@@ -237,26 +173,46 @@ function scheduleFor(settings, declared) {
237
173
  return scheduleFromDeclaration(declared.commission, declared.commissionType, declared.slippage, settings.contract.currency, settings.contract.digits);
238
174
  }
239
175
  /**
240
- * The host a backtest is: an instrument record, a clock and a destination.
176
+ * The instrument record of `host-interface.md` 4.1 the engine is handed, and
177
+ * the record carries verbatim.
241
178
  *
242
- * Duty 3 is not served. A backtest holds the chart's own bars and nothing else,
243
- * so a program that reads another instrument declares a capability this host
244
- * does not have and is refused at load, by name, rather than drawing a line
245
- * with nothing in it.
179
+ * Composed once, here, from the contract's six facts and the six stated beside
180
+ * it, so the engine and the record read one document and there is no second
181
+ * composition for the two to disagree by. A fact nobody stated is left out
182
+ * rather than written as undefined: the record travels as JSON, which drops an
183
+ * undefined member, and a document that changes shape in transit is not the
184
+ * document the engine read.
246
185
  */
247
- function hostFor(settings, route) {
248
- const instrument = {
249
- ...(settings.contract.symbol === null ? {} : { symbol: settings.contract.symbol }),
250
- ...(settings.contract.exchange === null ? {} : { exchange: settings.contract.exchange }),
251
- ...(settings.contract.tickSize === null ? {} : { tickSize: settings.contract.tickSize }),
252
- ...(settings.contract.lotSize === null ? {} : { lotSize: settings.contract.lotSize }),
253
- pointValue: settings.contract.pointValue,
254
- currency: settings.contract.currency,
186
+ function instrumentFor(contract, facts) {
187
+ return {
188
+ ...(contract.symbol === null ? {} : { symbol: contract.symbol }),
189
+ ...(contract.exchange === null ? {} : { exchange: contract.exchange }),
190
+ ...(facts.interval === undefined ? {} : { interval: facts.interval }),
191
+ ...(facts.timezone === undefined ? {} : { timezone: facts.timezone }),
192
+ ...(contract.tickSize === null ? {} : { tickSize: contract.tickSize }),
193
+ ...(contract.lotSize === null ? {} : { lotSize: contract.lotSize }),
194
+ pointValue: contract.pointValue,
195
+ currency: contract.currency,
196
+ ...(facts.instrumentType === undefined ? {} : { instrumentType: facts.instrumentType }),
197
+ ...(facts.hasVolume === undefined ? {} : { hasVolume: facts.hasVolume }),
198
+ ...(facts.hasOpenInterest === undefined ? {} : { hasOpenInterest: facts.hasOpenInterest }),
199
+ ...(facts.session === undefined ? {} : { session: facts.session }),
255
200
  };
201
+ }
202
+ /**
203
+ * The host a backtest is: an instrument record, a clock and a destination.
204
+ *
205
+ * Duty 3 is served only when the caller supplied bars for it. A backtest with
206
+ * none holds the chart's own bars and nothing else, so a program that reads
207
+ * another instrument declares a capability this host does not have and is
208
+ * refused at load, by name, rather than drawing a line with nothing in it.
209
+ */
210
+ function hostFor(instrument, now, route, requestBars) {
256
211
  return {
257
212
  instrument,
258
- ...(settings.now === null ? {} : { now: settings.now }),
213
+ ...(now === null ? {} : { now }),
259
214
  route,
215
+ ...(requestBars === undefined ? {} : { requestBars }),
260
216
  };
261
217
  }
262
218
  //# sourceMappingURL=drive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drive.js","sourceRoot":"","sources":["../../../src/core/backtest/drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAI3E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAW1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ9D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,a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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,OAAO,CACd,UAAsB,EACtB,GAAkB,EAClB,KAAkD,EAClD,WAAwC;IAExC,OAAO;QACL,UAAU;QACV,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QAChC,KAAK;QACL,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;KACtD,CAAC;AACJ,CAAC"}
@@ -14,18 +14,30 @@
14
14
  * worsened by a tick and a fill is charged. The engine never adjusts a price and
15
15
  * this module never folds one.
16
16
  *
17
- * `backtest` drives one, `replay` folds a stored one's money again from its own
18
- * fills, and `rerun` executes a stored one again and is held to producing the
19
- * same bytes. `recordToJson` and `recordFromJson` are the document itself.
20
- * `compareRuns` puts two records beside each other and says whether the gap
21
- * between them clears the noise. `caseFilesFrom` is named by the design and is
22
- * not here yet: it will return text and write nothing, because core does no
23
- * I/O, and it needs a channel the record does not carry today. `conformance.md`
24
- * section 2 requires a case to hold `script.os`, the source text, and a record
25
- * carries only the source's hash, its line count and its file name.
17
+ * `backtest` drives one against a simulated destination and `backtestSupplied`
18
+ * drives one over frames somebody else supplied, which is what `conformance.md`
19
+ * section 3 asks of an engine running a case. `replay` folds a stored one's
20
+ * money again from its own fills, and `rerun` executes a stored one again and
21
+ * is held to producing the same bytes. `recordToJson` and `recordFromJson` are
22
+ * the document itself. `compareRuns` puts two records beside each other and
23
+ * says whether the gap between them clears the noise. `caseFilesFrom` turns a
24
+ * record into the files of a conformance case, returning text and writing
25
+ * nothing because core does no I/O. It needed three channels the record did not
26
+ * carry. `conformance.md` section 2 requires a case to hold `script.os`, the
27
+ * source text, and a record carried only the source's hash, its line count and
28
+ * its file name: record version 2 carries the text, checked against that hash.
29
+ * The same section says `instrument.json` is the record of `host-interface.md`
30
+ * 4.1, and a record carried the money layer's contract, which holds six of its
31
+ * twelve facts: record version 3 carries the record the engine was handed,
32
+ * whole. And a case is handed frames, which `stdlib.md` 17.7 folds one ledger
33
+ * field from an instant of: a record carried a frame without the instant it
34
+ * arrived at, so a case projected from it asserted a field its own input could
35
+ * not reproduce. Record version 4 carries a frame's time.
26
36
  */
27
- export { backtest } from './drive.js';
28
- export type { BacktestResult, DriveOptions } from './drive.js';
37
+ export { backtest, backtestSupplied } from './drive.js';
38
+ export type { BacktestResult, DriveOptions, InstrumentFacts } from './drive.js';
39
+ export type { LogLine } from './walk.js';
40
+ export type { Surface } from './drive.js';
29
41
  export { declarationOf } from './declaration.js';
30
42
  export type { RunDeclaration } from './declaration.js';
31
43
  export { marksFor, windowFor } from './range.js';
@@ -35,8 +47,10 @@ export type { ReplayResult } from './replay.js';
35
47
  export { testResting } from './resting.js';
36
48
  export type { RestOutcome, RestingOrder } from './resting.js';
37
49
  export { Simulator } from './simulate.js';
38
- export type { SimulatorOptions } from './simulate.js';
50
+ export type { SimulatorOptions, VenueAct, VenueDoes, VenuePolicy } from './simulate.js';
39
51
  export { DEFAULT_FILL, EXACT, WHOLE_RANGE, checkSettings, settingsFor } from './settings.js';
52
+ export { caseFilesFrom } from './case.js';
53
+ export type { CaseFiles, CaseIdentity, CaseResult } from './case.js';
40
54
  export { RECORD_VERSION, barsHash, recordFromJson, recordOf, recordToJson, runBytes } from './record.js';
41
55
  export type { RecordParts } from './record.js';
42
56
  export type { BacktestSettings, DateRange, FillPolicy, Tolerance } from './settings.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,c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YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxF,YAAY,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -14,23 +14,34 @@
14
14
  * worsened by a tick and a fill is charged. The engine never adjusts a price and
15
15
  * this module never folds one.
16
16
  *
17
- * `backtest` drives one, `replay` folds a stored one's money again from its own
18
- * fills, and `rerun` executes a stored one again and is held to producing the
19
- * same bytes. `recordToJson` and `recordFromJson` are the document itself.
20
- * `compareRuns` puts two records beside each other and says whether the gap
21
- * between them clears the noise. `caseFilesFrom` is named by the design and is
22
- * not here yet: it will return text and write nothing, because core does no
23
- * I/O, and it needs a channel the record does not carry today. `conformance.md`
24
- * section 2 requires a case to hold `script.os`, the source text, and a record
25
- * carries only the source's hash, its line count and its file name.
17
+ * `backtest` drives one against a simulated destination and `backtestSupplied`
18
+ * drives one over frames somebody else supplied, which is what `conformance.md`
19
+ * section 3 asks of an engine running a case. `replay` folds a stored one's
20
+ * money again from its own fills, and `rerun` executes a stored one again and
21
+ * is held to producing the same bytes. `recordToJson` and `recordFromJson` are
22
+ * the document itself. `compareRuns` puts two records beside each other and
23
+ * says whether the gap between them clears the noise. `caseFilesFrom` turns a
24
+ * record into the files of a conformance case, returning text and writing
25
+ * nothing because core does no I/O. It needed three channels the record did not
26
+ * carry. `conformance.md` section 2 requires a case to hold `script.os`, the
27
+ * source text, and a record carried only the source's hash, its line count and
28
+ * its file name: record version 2 carries the text, checked against that hash.
29
+ * The same section says `instrument.json` is the record of `host-interface.md`
30
+ * 4.1, and a record carried the money layer's contract, which holds six of its
31
+ * twelve facts: record version 3 carries the record the engine was handed,
32
+ * whole. And a case is handed frames, which `stdlib.md` 17.7 folds one ledger
33
+ * field from an instant of: a record carried a frame without the instant it
34
+ * arrived at, so a case projected from it asserted a field its own input could
35
+ * not reproduce. Record version 4 carries a frame's time.
26
36
  */
27
- export { backtest } from './drive.js';
37
+ export { backtest, backtestSupplied } from './drive.js';
28
38
  export { declarationOf } from './declaration.js';
29
39
  export { marksFor, windowFor } from './range.js';
30
40
  export { replay, rerun } from './replay.js';
31
41
  export { testResting } from './resting.js';
32
42
  export { Simulator } from './simulate.js';
33
43
  export { DEFAULT_FILL, EXACT, WHOLE_RANGE, checkSettings, settingsFor } from './settings.js';
44
+ export { caseFilesFrom } from './case.js';
34
45
  export { RECORD_VERSION, barsHash, recordFromJson, recordOf, recordToJson, runBytes } from './record.js';
35
46
  export { compareRuns } from './compare.js';
36
47
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAWzG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAWzG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -27,7 +27,7 @@
27
27
  import type { RecordedFill, Report } from '../accounting/index.js';
28
28
  import type { Diagnostic } from '../diagnostics/index.js';
29
29
  import type { CompiledProgram, SourceStamp } from '../emit/index.js';
30
- import type { LedgerRow } from '../engine/index.js';
30
+ import type { Instrument, LedgerRow } from '../engine/index.js';
31
31
  import type { BacktestSettings } from './settings.js';
32
32
  /** One bar as a record holds it. */
33
33
  export interface RecordedBar {
@@ -68,6 +68,20 @@ export interface RecordedFrame {
68
68
  readonly avgFillPrice: number | null;
69
69
  readonly orderRef: string | null;
70
70
  readonly text: string | null;
71
+ /**
72
+ * The destination's own instant for this frame, or null where it stated none.
73
+ *
74
+ * **One field of the ledger is folded from it.** `host-interface.md` 7.2
75
+ * gives a frame a `time` and `stdlib.md` 17.7 moves `updatedAt` to it, so a
76
+ * record that dropped it wrote a ledger no engine reading the case back could
77
+ * fold to: handed frames with no instant, that engine leaves every
78
+ * `updatedAt` at `placedAt`, and the two disagree on exactly the rows whose
79
+ * destination answered later than the bar that placed the order.
80
+ *
81
+ * Absent rather than substituted, because 7.2 lets a destination state none
82
+ * and a row whose frame stated none keeps the instant it had.
83
+ */
84
+ readonly time: number | null;
71
85
  }
72
86
  /** A ledger row of `stdlib.md` 17.7, flattened: the `orders` channel of expected.json. */
73
87
  export interface RecordedOrder {
@@ -114,7 +128,43 @@ export interface RunRecord {
114
128
  readonly programHash: string;
115
129
  /** Hash, lines, file: the script revision. */
116
130
  readonly source: SourceStamp;
131
+ /**
132
+ * The source text itself, or null on a record written before version 2.
133
+ *
134
+ * **A record is the conformance case, and a case has to hold `script.os`.**
135
+ * `source` above identifies the script and cannot reproduce it: a hash is a
136
+ * fingerprint, so it settles whether two files are the same and yields
137
+ * neither of them. Without the text a stored record could be replayed months
138
+ * later and still not be handed to anybody else to run, which is the whole
139
+ * claim the suite exists to test.
140
+ *
141
+ * It lives here and not on the compiled program on purpose. A program is
142
+ * executable data that no engine needs the source to run, and it is the
143
+ * versioned artefact adopters depend on; putting the text there would send a
144
+ * script everywhere its program travels and widen the format every engine
145
+ * has to read. The record is the thing that wants to be self-contained.
146
+ */
147
+ readonly sourceText: string | null;
117
148
  readonly settings: BacktestSettings;
149
+ /**
150
+ * The instrument record of `host-interface.md` 4.1, as the engine was handed
151
+ * it, or null on a record written before version 3.
152
+ *
153
+ * **A case holds `instrument.json`, and `conformance.md` section 2 says that
154
+ * file is this record.** The contract in `settings` is the money layer's
155
+ * snapshot of the same instrument and holds six of the twelve facts; the
156
+ * ones a script reads and the money never does, the interval, the timezone,
157
+ * the session and the volume flag, were handed to the engine and written
158
+ * down nowhere. A case harvested from such a record either omitted a fact
159
+ * the page requires or stated one the run never had, and either way the
160
+ * second engine ran a different study than the one the expected output
161
+ * came from.
162
+ *
163
+ * It is the whole record and not the six facts beside the contract, because
164
+ * what is recorded is what the engine read at load, verbatim, and a reader
165
+ * should not have to compose it.
166
+ */
167
+ readonly instrument: Instrument | null;
118
168
  readonly bars: BarsInRecord;
119
169
  /** What the destination answered, in delivery order. */
120
170
  readonly frames: readonly RecordedFrame[];
@@ -133,11 +183,22 @@ export interface RunRecord {
133
183
  * file alone. It moves when a channel is added or a meaning changes, never when
134
184
  * a figure in a report does.
135
185
  */
136
- export declare const RECORD_VERSION = 1;
186
+ export declare const RECORD_VERSION = 4;
137
187
  /** The parts a run hands over, each already in the shape the record holds. */
138
188
  export interface RecordParts {
139
189
  readonly program: CompiledProgram;
190
+ /**
191
+ * The script's own text, so the record can become a conformance case.
192
+ *
193
+ * Optional because a caller that has only a compiled program cannot invent
194
+ * it, and a run is still worth recording without it. `caseFilesFrom` is the
195
+ * one thing that then cannot be served, and it says so rather than writing a
196
+ * case with a hole in it.
197
+ */
198
+ readonly sourceText?: string;
140
199
  readonly settings: BacktestSettings;
200
+ /** The instrument record the engine was handed, `host-interface.md` 4.1. */
201
+ readonly instrument: Instrument;
141
202
  readonly bars: readonly RecordedBar[];
142
203
  /**
143
204
  * Whether the bars travel in the record or are pointed at.
@@ -1 +1 @@
1
- {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,oCAAoC;AACpC,MAAM,WAAW,WAAW;IAC1B,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