openalgo-script 0.2.0 → 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 (276) hide show
  1. package/CHANGELOG.md +269 -0
  2. package/README.md +65 -31
  3. package/dist/adapters/charts/surfaces.d.ts +17 -0
  4. package/dist/adapters/charts/surfaces.d.ts.map +1 -1
  5. package/dist/adapters/charts/tables.js +82 -0
  6. package/dist/adapters/charts/tables.js.map +1 -1
  7. package/dist/adapters/codemirror/commands.d.ts +14 -0
  8. package/dist/adapters/codemirror/commands.d.ts.map +1 -0
  9. package/dist/adapters/codemirror/commands.js +52 -0
  10. package/dist/adapters/codemirror/commands.js.map +1 -0
  11. package/dist/adapters/codemirror/completion.d.ts +15 -0
  12. package/dist/adapters/codemirror/completion.d.ts.map +1 -0
  13. package/dist/adapters/codemirror/completion.js +64 -0
  14. package/dist/adapters/codemirror/completion.js.map +1 -0
  15. package/dist/adapters/codemirror/contract.d.ts +156 -0
  16. package/dist/adapters/codemirror/contract.d.ts.map +1 -0
  17. package/dist/adapters/codemirror/contract.js +42 -0
  18. package/dist/adapters/codemirror/contract.js.map +1 -0
  19. package/dist/adapters/codemirror/index.d.ts +43 -0
  20. package/dist/adapters/codemirror/index.d.ts.map +1 -0
  21. package/dist/adapters/codemirror/index.js +8 -0
  22. package/dist/adapters/codemirror/index.js.map +1 -0
  23. package/dist/adapters/codemirror/lint.d.ts +17 -0
  24. package/dist/adapters/codemirror/lint.d.ts.map +1 -0
  25. package/dist/adapters/codemirror/lint.js +62 -0
  26. package/dist/adapters/codemirror/lint.js.map +1 -0
  27. package/dist/adapters/codemirror/positions.d.ts +16 -0
  28. package/dist/adapters/codemirror/positions.d.ts.map +1 -0
  29. package/dist/adapters/codemirror/positions.js +65 -0
  30. package/dist/adapters/codemirror/positions.js.map +1 -0
  31. package/dist/adapters/codemirror/stream.d.ts +23 -0
  32. package/dist/adapters/codemirror/stream.d.ts.map +1 -0
  33. package/dist/adapters/codemirror/stream.js +70 -0
  34. package/dist/adapters/codemirror/stream.js.map +1 -0
  35. package/dist/adapters/codemirror/tokens.d.ts +44 -0
  36. package/dist/adapters/codemirror/tokens.d.ts.map +1 -0
  37. package/dist/adapters/codemirror/tokens.js +34 -0
  38. package/dist/adapters/codemirror/tokens.js.map +1 -0
  39. package/dist/adapters/codemirror/tooltips.d.ts +35 -0
  40. package/dist/adapters/codemirror/tooltips.d.ts.map +1 -0
  41. package/dist/adapters/codemirror/tooltips.js +108 -0
  42. package/dist/adapters/codemirror/tooltips.js.map +1 -0
  43. package/dist/core/accounting/charges.d.ts +136 -0
  44. package/dist/core/accounting/charges.d.ts.map +1 -0
  45. package/dist/core/accounting/charges.js +362 -0
  46. package/dist/core/accounting/charges.js.map +1 -0
  47. package/dist/core/accounting/equity.d.ts +158 -0
  48. package/dist/core/accounting/equity.d.ts.map +1 -0
  49. package/dist/core/accounting/equity.js +155 -0
  50. package/dist/core/accounting/equity.js.map +1 -0
  51. package/dist/core/accounting/index.d.ts +44 -0
  52. package/dist/core/accounting/index.d.ts.map +1 -0
  53. package/dist/core/accounting/index.js +36 -0
  54. package/dist/core/accounting/index.js.map +1 -0
  55. package/dist/core/accounting/markers.d.ts +43 -0
  56. package/dist/core/accounting/markers.d.ts.map +1 -0
  57. package/dist/core/accounting/markers.js +64 -0
  58. package/dist/core/accounting/markers.js.map +1 -0
  59. package/dist/core/accounting/monthly.d.ts +52 -0
  60. package/dist/core/accounting/monthly.d.ts.map +1 -0
  61. package/dist/core/accounting/monthly.js +99 -0
  62. package/dist/core/accounting/monthly.js.map +1 -0
  63. package/dist/core/accounting/report.d.ts +38 -0
  64. package/dist/core/accounting/report.d.ts.map +1 -0
  65. package/dist/core/accounting/report.js +63 -0
  66. package/dist/core/accounting/report.js.map +1 -0
  67. package/dist/core/accounting/shapes.d.ts +70 -0
  68. package/dist/core/accounting/shapes.d.ts.map +1 -0
  69. package/dist/core/accounting/shapes.js +21 -0
  70. package/dist/core/accounting/shapes.js.map +1 -0
  71. package/dist/core/accounting/statistics.d.ts +75 -0
  72. package/dist/core/accounting/statistics.d.ts.map +1 -0
  73. package/dist/core/accounting/statistics.js +246 -0
  74. package/dist/core/accounting/statistics.js.map +1 -0
  75. package/dist/core/accounting/trades.d.ts +118 -0
  76. package/dist/core/accounting/trades.d.ts.map +1 -0
  77. package/dist/core/accounting/trades.js +186 -0
  78. package/dist/core/accounting/trades.js.map +1 -0
  79. package/dist/core/backtest/compare.d.ts +38 -0
  80. package/dist/core/backtest/compare.d.ts.map +1 -0
  81. package/dist/core/backtest/compare.js +189 -0
  82. package/dist/core/backtest/compare.js.map +1 -0
  83. package/dist/core/backtest/declaration.d.ts +52 -0
  84. package/dist/core/backtest/declaration.d.ts.map +1 -0
  85. package/dist/core/backtest/declaration.js +48 -0
  86. package/dist/core/backtest/declaration.js.map +1 -0
  87. package/dist/core/backtest/drive.d.ts +29 -0
  88. package/dist/core/backtest/drive.d.ts.map +1 -0
  89. package/dist/core/backtest/drive.js +262 -0
  90. package/dist/core/backtest/drive.js.map +1 -0
  91. package/dist/core/backtest/index.d.ts +46 -0
  92. package/dist/core/backtest/index.d.ts.map +1 -0
  93. package/dist/core/backtest/index.js +36 -0
  94. package/dist/core/backtest/index.js.map +1 -0
  95. package/dist/core/backtest/range.d.ts +84 -0
  96. package/dist/core/backtest/range.d.ts.map +1 -0
  97. package/dist/core/backtest/range.js +90 -0
  98. package/dist/core/backtest/range.js.map +1 -0
  99. package/dist/core/backtest/record.d.ts +238 -0
  100. package/dist/core/backtest/record.d.ts.map +1 -0
  101. package/dist/core/backtest/record.js +176 -0
  102. package/dist/core/backtest/record.js.map +1 -0
  103. package/dist/core/backtest/replay.d.ts +48 -0
  104. package/dist/core/backtest/replay.d.ts.map +1 -0
  105. package/dist/core/backtest/replay.js +127 -0
  106. package/dist/core/backtest/replay.js.map +1 -0
  107. package/dist/core/backtest/resting.d.ts +62 -0
  108. package/dist/core/backtest/resting.d.ts.map +1 -0
  109. package/dist/core/backtest/resting.js +59 -0
  110. package/dist/core/backtest/resting.js.map +1 -0
  111. package/dist/core/backtest/settings.d.ts +117 -0
  112. package/dist/core/backtest/settings.d.ts.map +1 -0
  113. package/dist/core/backtest/settings.js +207 -0
  114. package/dist/core/backtest/settings.js.map +1 -0
  115. package/dist/core/backtest/simulate.d.ts +146 -0
  116. package/dist/core/backtest/simulate.d.ts.map +1 -0
  117. package/dist/core/backtest/simulate.js +217 -0
  118. package/dist/core/backtest/simulate.js.map +1 -0
  119. package/dist/core/catalogue/catalogue.generated.d.ts +66 -0
  120. package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
  121. package/dist/core/catalogue/catalogue.generated.js +6 -0
  122. package/dist/core/catalogue/catalogue.generated.js.map +1 -1
  123. package/dist/core/catalogue/values.generated.d.ts +24 -0
  124. package/dist/core/catalogue/values.generated.d.ts.map +1 -1
  125. package/dist/core/check/index.d.ts +2 -1
  126. package/dist/core/check/index.d.ts.map +1 -1
  127. package/dist/core/check/index.js +1 -1
  128. package/dist/core/check/index.js.map +1 -1
  129. package/dist/core/check/library-prose.generated.d.ts +16 -0
  130. package/dist/core/check/library-prose.generated.d.ts.map +1 -0
  131. package/dist/core/check/library-prose.generated.js +353 -0
  132. package/dist/core/check/library-prose.generated.js.map +1 -0
  133. package/dist/core/check/surface.d.ts +24 -0
  134. package/dist/core/check/surface.d.ts.map +1 -1
  135. package/dist/core/check/surface.js +29 -0
  136. package/dist/core/check/surface.js.map +1 -1
  137. package/dist/core/emit/defaults.d.ts +35 -16
  138. package/dist/core/emit/defaults.d.ts.map +1 -1
  139. package/dist/core/emit/defaults.js +66 -0
  140. package/dist/core/emit/defaults.js.map +1 -1
  141. package/dist/core/emit/index.d.ts +2 -0
  142. package/dist/core/emit/index.d.ts.map +1 -1
  143. package/dist/core/emit/index.js +2 -0
  144. package/dist/core/emit/index.js.map +1 -1
  145. package/dist/core/engine/index.d.ts +1 -1
  146. package/dist/core/engine/index.d.ts.map +1 -1
  147. package/dist/core/engine/index.js +1 -1
  148. package/dist/core/engine/index.js.map +1 -1
  149. package/dist/core/engine/load.d.ts +15 -1
  150. package/dist/core/engine/load.d.ts.map +1 -1
  151. package/dist/core/engine/load.js +1 -0
  152. package/dist/core/engine/load.js.map +1 -1
  153. package/dist/core/index.d.ts +37 -3
  154. package/dist/core/index.d.ts.map +1 -1
  155. package/dist/core/index.js +17 -1
  156. package/dist/core/index.js.map +1 -1
  157. package/dist/core/version/version.generated.d.ts +1 -1
  158. package/dist/core/version/version.generated.js +1 -1
  159. package/dist/editor/complete.d.ts +40 -0
  160. package/dist/editor/complete.d.ts.map +1 -0
  161. package/dist/editor/complete.js +206 -0
  162. package/dist/editor/complete.js.map +1 -0
  163. package/dist/editor/diagnose.d.ts +18 -0
  164. package/dist/editor/diagnose.d.ts.map +1 -0
  165. package/dist/editor/diagnose.js +70 -0
  166. package/dist/editor/diagnose.js.map +1 -0
  167. package/dist/editor/format.d.ts +11 -0
  168. package/dist/editor/format.d.ts.map +1 -0
  169. package/dist/editor/format.js +50 -0
  170. package/dist/editor/format.js.map +1 -0
  171. package/dist/editor/highlight.d.ts +28 -0
  172. package/dist/editor/highlight.d.ts.map +1 -0
  173. package/dist/editor/highlight.js +65 -0
  174. package/dist/editor/highlight.js.map +1 -0
  175. package/dist/editor/hover.d.ts +40 -0
  176. package/dist/editor/hover.d.ts.map +1 -0
  177. package/dist/editor/hover.js +147 -0
  178. package/dist/editor/hover.js.map +1 -0
  179. package/dist/editor/index.d.ts +60 -0
  180. package/dist/editor/index.d.ts.map +1 -0
  181. package/dist/editor/index.js +7 -0
  182. package/dist/editor/index.js.map +1 -0
  183. package/dist/editor/kinds.d.ts +27 -0
  184. package/dist/editor/kinds.d.ts.map +1 -0
  185. package/dist/editor/kinds.js +118 -0
  186. package/dist/editor/kinds.js.map +1 -0
  187. package/dist/editor/layout.d.ts +47 -0
  188. package/dist/editor/layout.d.ts.map +1 -0
  189. package/dist/editor/layout.js +135 -0
  190. package/dist/editor/layout.js.map +1 -0
  191. package/dist/editor/manifest.d.ts +47 -0
  192. package/dist/editor/manifest.d.ts.map +1 -0
  193. package/dist/editor/manifest.js +93 -0
  194. package/dist/editor/manifest.js.map +1 -0
  195. package/dist/editor/reading.d.ts +41 -0
  196. package/dist/editor/reading.d.ts.map +1 -0
  197. package/dist/editor/reading.js +51 -0
  198. package/dist/editor/reading.js.map +1 -0
  199. package/dist/editor/scan.d.ts +26 -0
  200. package/dist/editor/scan.d.ts.map +1 -0
  201. package/dist/editor/scan.js +139 -0
  202. package/dist/editor/scan.js.map +1 -0
  203. package/dist/editor/scope.d.ts +19 -0
  204. package/dist/editor/scope.d.ts.map +1 -0
  205. package/dist/editor/scope.js +99 -0
  206. package/dist/editor/scope.js.map +1 -0
  207. package/dist/editor/signature.d.ts +38 -0
  208. package/dist/editor/signature.d.ts.map +1 -0
  209. package/dist/editor/signature.js +112 -0
  210. package/dist/editor/signature.js.map +1 -0
  211. package/dist/editor/site.d.ts +46 -0
  212. package/dist/editor/site.d.ts.map +1 -0
  213. package/dist/editor/site.js +184 -0
  214. package/dist/editor/site.js.map +1 -0
  215. package/dist/editor/spacing.d.ts +29 -0
  216. package/dist/editor/spacing.d.ts.map +1 -0
  217. package/dist/editor/spacing.js +116 -0
  218. package/dist/editor/spacing.js.map +1 -0
  219. package/package.json +30 -3
  220. package/spec/errors.json +140 -0
  221. package/src/adapters/charts/surfaces.ts +17 -0
  222. package/src/adapters/charts/tables.ts +88 -0
  223. package/src/adapters/codemirror/commands.ts +53 -0
  224. package/src/adapters/codemirror/completion.ts +74 -0
  225. package/src/adapters/codemirror/contract.ts +156 -0
  226. package/src/adapters/codemirror/index.ts +66 -0
  227. package/src/adapters/codemirror/lint.ts +66 -0
  228. package/src/adapters/codemirror/positions.ts +79 -0
  229. package/src/adapters/codemirror/stream.ts +87 -0
  230. package/src/adapters/codemirror/tokens.ts +64 -0
  231. package/src/adapters/codemirror/tooltips.ts +113 -0
  232. package/src/core/accounting/charges.ts +452 -0
  233. package/src/core/accounting/equity.ts +276 -0
  234. package/src/core/accounting/index.ts +49 -0
  235. package/src/core/accounting/markers.ts +95 -0
  236. package/src/core/accounting/monthly.ts +137 -0
  237. package/src/core/accounting/report.ts +89 -0
  238. package/src/core/accounting/shapes.ts +73 -0
  239. package/src/core/accounting/statistics.ts +350 -0
  240. package/src/core/accounting/trades.ts +313 -0
  241. package/src/core/backtest/compare.ts +244 -0
  242. package/src/core/backtest/declaration.ts +97 -0
  243. package/src/core/backtest/drive.ts +364 -0
  244. package/src/core/backtest/index.ts +52 -0
  245. package/src/core/backtest/range.ts +137 -0
  246. package/src/core/backtest/record.ts +341 -0
  247. package/src/core/backtest/replay.ts +158 -0
  248. package/src/core/backtest/resting.ts +125 -0
  249. package/src/core/backtest/settings.ts +280 -0
  250. package/src/core/backtest/simulate.ts +304 -0
  251. package/src/core/catalogue/catalogue.generated.ts +6 -0
  252. package/src/core/catalogue/values.generated.ts +6 -0
  253. package/src/core/check/index.ts +3 -0
  254. package/src/core/check/library-prose.generated.ts +367 -0
  255. package/src/core/check/surface.ts +34 -0
  256. package/src/core/emit/defaults.ts +70 -0
  257. package/src/core/emit/index.ts +2 -0
  258. package/src/core/engine/index.ts +1 -1
  259. package/src/core/engine/load.ts +16 -2
  260. package/src/core/index.ts +85 -1
  261. package/src/core/version/version.generated.ts +1 -1
  262. package/src/editor/complete.ts +266 -0
  263. package/src/editor/diagnose.ts +71 -0
  264. package/src/editor/format.ts +85 -0
  265. package/src/editor/highlight.ts +110 -0
  266. package/src/editor/hover.ts +199 -0
  267. package/src/editor/index.ts +65 -0
  268. package/src/editor/kinds.ts +157 -0
  269. package/src/editor/layout.ts +189 -0
  270. package/src/editor/manifest.ts +119 -0
  271. package/src/editor/reading.ts +69 -0
  272. package/src/editor/scan.ts +162 -0
  273. package/src/editor/scope.ts +122 -0
  274. package/src/editor/signature.ts +150 -0
  275. package/src/editor/site.ts +233 -0
  276. package/src/editor/spacing.ts +132 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Highlighting, as the editor's line at a time tokenizer.
3
+ *
4
+ * The editor asks for one line's tokens at a time and remembers nothing between
5
+ * lines except the state this file hands back. The tier's `highlight` takes a
6
+ * whole file. So the line is what is lexed here, by the real lexer, through the
7
+ * same `highlight` a host would call itself.
8
+ *
9
+ * **That is an equivalence rather than an approximation, and it is measured.**
10
+ * `tests/adapters/codemirror/stream.test.ts` puts every script in the repository
11
+ * and the malformed corpus through both routes and compares them piece for
12
+ * piece: 4279 lines of real scripts, and not one of them differs. It holds
13
+ * because nothing in this language crosses a line ending: a string literal is
14
+ * refused at the end of its line, there is no block comment, and the layout
15
+ * tokens that do depend on the lines above are painted as whitespace either way.
16
+ * If the language ever grows something that does cross one, that test fails on
17
+ * the day it is added rather than on the day somebody notices a half painted
18
+ * line, and this becomes a line the narrowings file has to carry.
19
+ *
20
+ * A line is lexed once, not once per token: the pieces are computed when the
21
+ * editor arrives at the start of a line and walked from there. Without that, a
22
+ * line of twenty tokens would be lexed twenty times, which is the shape that
23
+ * makes a tokenizer show up in a frame budget.
24
+ */
25
+ import { highlight } from '../../editor/index.js';
26
+ import { HIGHLIGHT_TOKENS } from './tokens.js';
27
+ /** The pieces of one line, computed once and kept until the line changes. */
28
+ function piecesFor(state, line) {
29
+ if (state.line !== line || state.pieces.length === 0) {
30
+ state.line = line;
31
+ state.pieces = highlight(line);
32
+ }
33
+ return state.pieces;
34
+ }
35
+ /**
36
+ * The tokenizer, which a host turns into a language with one call.
37
+ *
38
+ * ```ts
39
+ * const openscript = StreamLanguage.define(openscriptStream);
40
+ * ```
41
+ *
42
+ * `token` moves the stream to the end of the piece that starts where it is and
43
+ * returns that piece's style. A stream that has somehow been left inside a piece,
44
+ * which the editor does when it re-tokenizes from a column rather than from the
45
+ * start of a line, is moved to the end of the piece containing it, so the
46
+ * tokenizer always advances and the editor cannot be made to loop.
47
+ */
48
+ export const openscriptStream = {
49
+ name: 'openscript',
50
+ startState: () => ({ line: '', pieces: [] }),
51
+ copyState: (state) => ({ line: state.line, pieces: state.pieces }),
52
+ token(stream, state) {
53
+ if (stream.eol())
54
+ return null;
55
+ const pieces = piecesFor(state, stream.string);
56
+ const at = stream.pos;
57
+ const piece = pieces.find((one) => at >= one.span.offset && at < one.span.offset + one.span.length);
58
+ if (piece === undefined) {
59
+ // No piece covers the position, which cannot happen for a line the tier
60
+ // has covered and is still answered rather than trusted: the pieces tile
61
+ // the line, so this is a position outside it. Moving to the end leaves the
62
+ // editor with an unstyled remainder instead of an infinite loop.
63
+ stream.pos = stream.string.length;
64
+ return null;
65
+ }
66
+ stream.pos = piece.span.offset + piece.span.length;
67
+ return HIGHLIGHT_TOKENS[piece.kind];
68
+ },
69
+ };
70
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAS/C,6EAA6E;AAC7E,SAAS,SAAS,CAAC,KAAkB,EAAE,IAAY;IACjD,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D,IAAI,EAAE,YAAY;IAElB,UAAU,EAAE,GAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAEzD,SAAS,EAAE,CAAC,KAAkB,EAAe,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAE5F,KAAK,CAAC,MAA0B,EAAE,KAAkB;QAClD,IAAI,MAAM,CAAC,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QAE9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/C,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CACvB,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CACzE,CAAC;QAEF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,wEAAwE;YACxE,yEAAyE;YACzE,2EAA2E;YAC3E,iEAAiE;YACjE,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QACnD,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The eleven kinds, as the editor's own highlighting tags.
3
+ *
4
+ * This is the translation an adapter exists to do: the language has eleven
5
+ * kinds, closed, and the editor has a vocabulary of tags its themes are written
6
+ * against. Neither knows about the other, and this file is the only place that
7
+ * knows both.
8
+ *
9
+ * **It is one record rather than a switch on purpose.** A style name is the one
10
+ * thing in this adapter that no type can hold: the editor looks a name up in its
11
+ * own tag table at run time and warns on a console about one it does not know,
12
+ * so a name that is wrong here is invisible to every check in this repository
13
+ * and shows up as an unpainted keyword in somebody's product. A host that
14
+ * disagrees with any of these, or whose theme is written against different
15
+ * names, replaces the row in one line:
16
+ *
17
+ * ```ts
18
+ * const tokens = { ...HIGHLIGHT_TOKENS, unknown: "invalid" };
19
+ * ```
20
+ *
21
+ * Two of the eleven are deliberately unstyled. `whitespace` has nothing to
22
+ * paint. `unknown` is the honest name for source the lexer took no token from,
23
+ * which is a character the language does not have, a region somebody wrote as a
24
+ * block comment, or a line continuation backslash: the first is a mistake and
25
+ * the last is not, so painting all three as invalid would paint a correct line
26
+ * red. `diagnose` is what says which of them is wrong, and the linter below is
27
+ * how a host shows that.
28
+ */
29
+ import type { HighlightKind } from '../../editor/index.js';
30
+ /**
31
+ * A style name per kind, or null for one the editor should leave alone.
32
+ *
33
+ * `builtin` uses the editor's modifier syntax for a name the environment
34
+ * supplies rather than the file, which is what a library name is.
35
+ */
36
+ export declare const HIGHLIGHT_TOKENS: Readonly<Record<HighlightKind, string | null>>;
37
+ /**
38
+ * The editor's name for the icon beside a completion row, per kind.
39
+ *
40
+ * The editor ships icons for a fixed set of names and shows none for a name it
41
+ * does not know, which is a missing icon rather than a missing row.
42
+ */
43
+ export declare const COMPLETION_TYPES: Readonly<Record<string, string>>;
44
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,CAY3E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO7D,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A style name per kind, or null for one the editor should leave alone.
3
+ *
4
+ * `builtin` uses the editor's modifier syntax for a name the environment
5
+ * supplies rather than the file, which is what a library name is.
6
+ */
7
+ export const HIGHLIGHT_TOKENS = {
8
+ keyword: 'keyword',
9
+ builtin: 'variableName.standard',
10
+ name: 'variableName',
11
+ number: 'number',
12
+ string: 'string',
13
+ color: 'color',
14
+ comment: 'comment',
15
+ operator: 'operator',
16
+ punctuation: 'punctuation',
17
+ whitespace: null,
18
+ unknown: null,
19
+ };
20
+ /**
21
+ * The editor's name for the icon beside a completion row, per kind.
22
+ *
23
+ * The editor ships icons for a fixed set of names and shows none for a name it
24
+ * does not know, which is a missing icon rather than a missing row.
25
+ */
26
+ export const COMPLETION_TYPES = {
27
+ function: 'function',
28
+ value: 'constant',
29
+ namespace: 'namespace',
30
+ member: 'property',
31
+ variable: 'variable',
32
+ argument: 'property',
33
+ };
34
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/tokens.ts"],"names":[],"mappings":"AA8BA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAmD;IAC9E,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqC;IAChE,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,UAAU;IACjB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACrB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { Hover, SignatureHelp } from '../../editor/index.js';
2
+ import type { EditorState, EditorTooltip, EditorTooltipView, EditorView } from './contract.js';
3
+ /** What a host supplies to draw a tooltip, which is the whole of the markup. */
4
+ export interface Renderer<Held> {
5
+ (held: Held): EditorTooltipView;
6
+ }
7
+ /**
8
+ * The lines a hover shows, in the order it shows them.
9
+ *
10
+ * Every one of them came from the compiler: the signatures from the library
11
+ * manifest, the sentence and the warmup from the specification's own tables, the
12
+ * type from the checker, and the refusal from the error catalogue. Nothing is
13
+ * written here, which is why this function is a join rather than a template.
14
+ */
15
+ export declare function hoverLines(held: Hover): readonly string[];
16
+ /** The lines a signature tooltip shows, with the active parameter named. */
17
+ export declare function signatureLines(held: SignatureHelp): readonly string[];
18
+ /**
19
+ * A hover tooltip source, which a host wires in one line.
20
+ *
21
+ * ```ts
22
+ * hoverTooltip(openscriptHoverTooltip(render))
23
+ * ```
24
+ */
25
+ export declare function openscriptHoverTooltip(render: Renderer<Hover>): (view: EditorView, pos: number) => EditorTooltip | null;
26
+ /**
27
+ * A signature tooltip for wherever the cursor is, or nothing where it is in no
28
+ * call.
29
+ *
30
+ * ```ts
31
+ * showTooltip.compute(["doc", "selection"], openscriptSignatureTooltip(render))
32
+ * ```
33
+ */
34
+ export declare function openscriptSignatureTooltip(render: Renderer<SignatureHelp>): (state: EditorState) => EditorTooltip | null;
35
+ //# sourceMappingURL=tooltips.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltips.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/tooltips.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG/F,gFAAgF;AAChF,MAAM,WAAW,QAAQ,CAAC,IAAI;IAC5B,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,MAAM,EAAE,CAOzD;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAYrE;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,GACtB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,aAAa,GAAG,IAAI,CAWzD;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC9B,CAAC,KAAK,EAAE,WAAW,KAAK,aAAa,GAAG,IAAI,CAY9C"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Hover and signature, as the editor's tooltips.
3
+ *
4
+ * This is the one part of the adapter that would put something on screen, and it
5
+ * is the one part that does not: the markup is a parameter, and there is no
6
+ * default for it. So nothing in this package, at any tier, names a browser
7
+ * global, and `scripts/check-layering.mjs` fails the build if anything under
8
+ * `src` does. The same files load in a worker, on a server and inside somebody
9
+ * else's application.
10
+ *
11
+ * It costs a host four lines and it is the whole point of the split. Every
12
+ * platform has a design system and none of them wants to fight a styled panel
13
+ * that arrived with a language package; a default renderer here would be that
14
+ * panel, and it would be the one thing in this adapter a host could not replace
15
+ * without replacing the adapter.
16
+ *
17
+ * What is not a parameter is the content. `hoverLines` and `signatureLines`
18
+ * below are what a tooltip says, in order, and every line of it came from the
19
+ * compiler: the signatures from the library manifest, the sentence and the
20
+ * warmup from the specification's own tables, the type from the checker, and the
21
+ * refusal from the error catalogue.
22
+ *
23
+ * ```ts
24
+ * hoverTooltip(openscriptHoverTooltip((held) => ({ dom: yourPanel(hoverLines(held)) })))
25
+ * ```
26
+ */
27
+ import { hover, signature } from '../../editor/index.js';
28
+ import { documentOf, normalisedOffset } from './positions.js';
29
+ /**
30
+ * The lines a hover shows, in the order it shows them.
31
+ *
32
+ * Every one of them came from the compiler: the signatures from the library
33
+ * manifest, the sentence and the warmup from the specification's own tables, the
34
+ * type from the checker, and the refusal from the error catalogue. Nothing is
35
+ * written here, which is why this function is a join rather than a template.
36
+ */
37
+ export function hoverLines(held) {
38
+ const lines = [...held.signatures];
39
+ if (held.summary !== undefined)
40
+ lines.push(held.summary);
41
+ if (held.warmup !== undefined)
42
+ lines.push(`First value: ${held.warmup}`);
43
+ if (held.refusal !== undefined)
44
+ lines.push(held.refusal);
45
+ if (held.kind === 'keyword')
46
+ lines.push('A reserved word of the language.');
47
+ return lines;
48
+ }
49
+ /** The lines a signature tooltip shows, with the active parameter named. */
50
+ export function signatureLines(held) {
51
+ const lines = [held.signature];
52
+ const active = held.parameters[held.active];
53
+ if (active !== undefined) {
54
+ const value = active.defaultText === undefined ? '' : ` = ${active.defaultText}`;
55
+ const need = active.required ? 'required' : 'optional';
56
+ lines.push(`${active.name}: ${active.type}${value} (${need})`);
57
+ if (active.values.length > 0)
58
+ lines.push(`One of: ${active.values.join(', ')}`);
59
+ }
60
+ if (held.summary !== undefined)
61
+ lines.push(held.summary);
62
+ if (held.refusal !== undefined)
63
+ lines.push(held.refusal);
64
+ return lines;
65
+ }
66
+ /**
67
+ * A hover tooltip source, which a host wires in one line.
68
+ *
69
+ * ```ts
70
+ * hoverTooltip(openscriptHoverTooltip(render))
71
+ * ```
72
+ */
73
+ export function openscriptHoverTooltip(render) {
74
+ return (view, pos) => {
75
+ const held = documentOf(view.state.doc.toString());
76
+ const found = hover(held.text, normalisedOffset(held, pos));
77
+ if (found === undefined)
78
+ return null;
79
+ return {
80
+ pos: held.at(found.span.offset),
81
+ end: held.at(found.span.offset + found.span.length),
82
+ create: () => render(found),
83
+ };
84
+ };
85
+ }
86
+ /**
87
+ * A signature tooltip for wherever the cursor is, or nothing where it is in no
88
+ * call.
89
+ *
90
+ * ```ts
91
+ * showTooltip.compute(["doc", "selection"], openscriptSignatureTooltip(render))
92
+ * ```
93
+ */
94
+ export function openscriptSignatureTooltip(render) {
95
+ return (state) => {
96
+ const held = documentOf(state.doc.toString());
97
+ const at = normalisedOffset(held, state.selection.main.head);
98
+ const found = signature(held.text, at);
99
+ if (found === undefined)
100
+ return null;
101
+ return {
102
+ pos: state.selection.main.head,
103
+ above: true,
104
+ create: () => render(found),
105
+ };
106
+ };
107
+ }
108
+ //# sourceMappingURL=tooltips.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltips.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/tooltips.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,136 @@
1
+ import type { Diagnostic } from '../diagnostics/index.js';
2
+ import type { Contract, Money, RecordedFill } from './shapes.js';
3
+ /**
4
+ * What a line's rate is measured against.
5
+ *
6
+ * Four bases cover every stack the documentation describes without naming a
7
+ * market: a fraction of turnover, money per unit, money per fill, and a
8
+ * fraction of the lines named before this one, which is the charge on a charge.
9
+ */
10
+ export type ChargeBase = 'turnover' | 'units' | 'order' | 'charges';
11
+ /**
12
+ * Which side of the trade a line applies to.
13
+ *
14
+ * A transaction tax levied on one side is expressed exactly rather than smeared
15
+ * across both fills at half the rate, which is what a reader doing it by hand
16
+ * has to do and what makes their figure disagree with their broker's.
17
+ */
18
+ export type ChargeSide = 'buy' | 'sell' | 'both';
19
+ /** One line of a schedule, applied to one fill. */
20
+ export interface ChargeLine {
21
+ /** The platform's own word. */
22
+ readonly name: string;
23
+ readonly base: ChargeBase;
24
+ readonly side: ChargeSide;
25
+ /**
26
+ * Fraction for turnover and charges, money per unit for units, money for
27
+ * order.
28
+ */
29
+ readonly rate: number;
30
+ /** Floor per application. */
31
+ readonly min: Money | null;
32
+ /** Cap per application. */
33
+ readonly max: Money | null;
34
+ /** Base 'charges' only: names of lines declared before this one. */
35
+ readonly of: readonly string[];
36
+ }
37
+ /** The whole cost model a run was carried out under. */
38
+ export interface ChargeSchedule {
39
+ readonly currency: string;
40
+ readonly digits: number;
41
+ readonly slippageTicks: number;
42
+ /** Applied in order, and order is part of the result. */
43
+ readonly lines: readonly ChargeLine[];
44
+ /**
45
+ * Where the schedule came from.
46
+ *
47
+ * A schedule derived from the declaration is derived again on replay rather
48
+ * than stored, because what the program states is stored once, as the
49
+ * program. A supplied one is the host's choice and travels with the record.
50
+ */
51
+ readonly source: 'declaration' | 'supplied';
52
+ }
53
+ /** What one fill was charged, line by line and in total. */
54
+ export interface ChargeBreakdown {
55
+ readonly lines: readonly {
56
+ readonly name: string;
57
+ readonly amount: Money;
58
+ }[];
59
+ readonly total: Money;
60
+ }
61
+ /**
62
+ * What one fill cost, line by line and in total.
63
+ *
64
+ * **The lines are the arithmetic and the total is the money.** Each line's
65
+ * amount is computed in binary64 and left unrounded, and the per-fill total is
66
+ * rounded once, half to even, to the contract's digits. Rounding each line
67
+ * would round once per line, and two engines rounding in two places disagree in
68
+ * the last bit, which is a failed conformance comparison months later on
69
+ * somebody else's engine. So a reader adding the lines up by hand may land a
70
+ * fraction of the last digit away from the total, and that is the honest way
71
+ * round: the total is the figure the report accumulates.
72
+ *
73
+ * **Half to even, and not the language's own rounding.** `round()` in the
74
+ * language is halves away from zero, because a price a trader reads should
75
+ * agree with what they would write down (`stdlib.md` 8.1). Money folded over
76
+ * thousands of fills is a different question: away from zero biases every exact
77
+ * half upward, and half a unit of the last digit per fill is a bias that grows
78
+ * with the length of the backtest. Two rules, two reasons, both written down.
79
+ *
80
+ * **A line that does not apply to this side is not in the breakdown at all.** A
81
+ * name beside a zero reads as a charge that was levied and came to nothing,
82
+ * which is not what happened, and a later line levied on that name is levied on
83
+ * nothing, which is exactly what a tax on one side of the trade does.
84
+ */
85
+ export declare function chargeFor(schedule: ChargeSchedule, fill: RecordedFill, contract: Contract): ChargeBreakdown;
86
+ /**
87
+ * The declaration's own cost model, as the one schedule this module evaluates.
88
+ *
89
+ * **The declaration is not a second cost engine.** Its three commission
90
+ * spellings are a schedule of one line: a flat fee is a line charged per fill,
91
+ * a per unit fee is a line charged per unit, and a percentage is a line charged
92
+ * on turnover. A second evaluator for the declaration would be the same money
93
+ * computed two ways, and the day the two disagreed the report and the
94
+ * platform's own cost panel would both be defensible.
95
+ *
96
+ * **A commission of zero is no line at all**, rather than a line charging
97
+ * nothing. A zero line would put a name in every breakdown, and it would make a
98
+ * declaration that states no commission indistinguishable from one that states
99
+ * a commission, which is the distinction a run has to make before it accepts a
100
+ * schedule from the host as well.
101
+ *
102
+ * **A flat fee is charged per fill**, which is the one place `language.md` 13.3
103
+ * lets a reasonable person read the words two ways: per order, or per completed
104
+ * round trip. A charge is attributed to the fill that incurred it everywhere in
105
+ * this module, because that is what attributes it to a trade, so a round trip of
106
+ * two fills is charged twice.
107
+ *
108
+ * The currency and the digit count are parameters because neither is the
109
+ * declaration's to state: the declaration's currency is a label and is often
110
+ * left blank, and money rounding is a fact about the contract. A default here
111
+ * would be this module inventing a rounding rule for somebody else's market.
112
+ *
113
+ * `commissionType`'s value set is declared once, in `check/declaration.ts`, and
114
+ * is not restated here: what is below is a mapping from each spelling to the
115
+ * line it means. A program reaching this has been checked, so a fourth spelling
116
+ * cannot arrive, and the spelling that falls through is the declaration's own
117
+ * default rather than a shape this module made up.
118
+ */
119
+ export declare function scheduleFromDeclaration(commission: number, commissionType: string, slippage: number, currency: string, digits: number): ChargeSchedule;
120
+ /**
121
+ * Why this schedule cannot be carried out, or null.
122
+ *
123
+ * **Asked before the first bar, and answered once.** Everything here is a fact
124
+ * about the schedule rather than about any fill, so a run that would produce a
125
+ * number nobody can explain is refused while nothing has been computed and the
126
+ * cost of correcting it is one run. The contract is optional because a schedule
127
+ * is checkable on its own: what it adds is the three questions that need both,
128
+ * which are the currency the money is in, the digits it is rounded to, and the
129
+ * tick a slippage in ticks is measured in.
130
+ *
131
+ * The first problem found is the one reported. A list of everything wrong with
132
+ * a schedule reads as a worse schedule than it is, and it is corrected one line
133
+ * at a time regardless.
134
+ */
135
+ export declare function scheduleProblem(schedule: ChargeSchedule, contract?: Contract | null): Diagnostic | null;
136
+ //# sourceMappingURL=charges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"charges.d.ts","sourceRoot":"","sources":["../../../src/core/accounting/charges.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,mDAAmD;AACnD,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,2BAA2B;IAC3B,QAAQ,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC;CAC7C;AAED,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAA;KAAE,EAAE,CAAC;IAC7E,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAgCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,QAAQ,GACjB,eAAe,CAcjB;AAyED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,cAAc,CAQhB;AAcD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,EACxB,QAAQ,GAAE,QAAQ,GAAG,IAAW,GAC/B,UAAU,GAAG,IAAI,CAQnB"}