@tony01/astroneum 0.4.1-beta.2

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 (59) hide show
  1. package/CHANGELOG.md +237 -0
  2. package/LICENSE +21 -0
  3. package/README.md +198 -0
  4. package/dist/Indicator-BBI3L_lx.d.ts +1181 -0
  5. package/dist/ar-SA-AEPUSRMF.js +2 -0
  6. package/dist/astroneum.css +1 -0
  7. package/dist/chunk-2SN3RH42.js +2 -0
  8. package/dist/chunk-2YYGUSVX.js +3 -0
  9. package/dist/chunk-3GJSZFLM.js +2 -0
  10. package/dist/chunk-4YOLQ5DC.js +2 -0
  11. package/dist/chunk-I4YQBP2M.js +3 -0
  12. package/dist/chunk-OOMZRONH.js +35 -0
  13. package/dist/chunk-PV2GAINM.js +2 -0
  14. package/dist/chunk-SDXH2WAI.js +3 -0
  15. package/dist/chunk-YFPXTHZX.js +2 -0
  16. package/dist/chunk-YW3STIPY.js +653 -0
  17. package/dist/de-DE-4PR3NRQ7.js +2 -0
  18. package/dist/entries/alerts.d.ts +93 -0
  19. package/dist/entries/alerts.js +2 -0
  20. package/dist/entries/datafeeds/crypto.d.ts +65 -0
  21. package/dist/entries/datafeeds/crypto.js +2 -0
  22. package/dist/entries/datafeeds/polygon.d.ts +113 -0
  23. package/dist/entries/datafeeds/polygon.js +2 -0
  24. package/dist/entries/multichart.d.ts +96 -0
  25. package/dist/entries/multichart.js +2 -0
  26. package/dist/entries/portfolio.d.ts +55 -0
  27. package/dist/entries/portfolio.js +2 -0
  28. package/dist/entries/replay.d.ts +141 -0
  29. package/dist/entries/replay.js +2 -0
  30. package/dist/entries/script.d.ts +68 -0
  31. package/dist/entries/script.js +2 -0
  32. package/dist/entries/watchlist.d.ts +43 -0
  33. package/dist/entries/watchlist.js +2 -0
  34. package/dist/es-ES-HNDVPSLW.js +2 -0
  35. package/dist/fr-FR-Y7XWRGF2.js +2 -0
  36. package/dist/hi-IN-KEGIKIMV.js +2 -0
  37. package/dist/id-ID-QXDIUQUZ.js +2 -0
  38. package/dist/index.d.ts +1434 -0
  39. package/dist/index.js +2 -0
  40. package/dist/it-IT-UDTDFSRB.js +2 -0
  41. package/dist/ja-JP-NIODTBW3.js +2 -0
  42. package/dist/ko-KR-DQHPXKBA.js +2 -0
  43. package/dist/nl-NL-BB3ZHCXS.js +2 -0
  44. package/dist/pl-PL-I5MZDLFD.js +2 -0
  45. package/dist/pt-BR-MAMRTOYR.js +2 -0
  46. package/dist/ru-RU-F43D6B7G.js +2 -0
  47. package/dist/th-TH-KTFIUAD6.js +2 -0
  48. package/dist/tr-TR-WFTKJ22Y.js +2 -0
  49. package/dist/vi-VN-CD3WI2FQ.js +2 -0
  50. package/dist/zh-CN-Y2C6RSOI.js +3 -0
  51. package/docs/STRUCTURE.md +231 -0
  52. package/docs/TODO-DESIGN.md +261 -0
  53. package/docs/TODO.md +222 -0
  54. package/docs/api.md +528 -0
  55. package/docs/datafeed-guide.md +311 -0
  56. package/docs/design-astroneum.md +479 -0
  57. package/docs/plugin-development.md +565 -0
  58. package/docs/tv-functions-skill.md +706 -0
  59. package/package.json +147 -0
@@ -0,0 +1,479 @@
1
+ ---
2
+ name: Astroneum
3
+ description: A charting-first trading terminal built on the astroneum npm package. The chart is the page; everything else is thin chrome.
4
+ colors:
5
+ bg: "#131722"
6
+ surface: "#1E222D"
7
+ surface-elevated: "#2A2E39"
8
+ border-hairline: "#363A45"
9
+ border-strong: "#434651"
10
+ ink: "#D1D4DC"
11
+ ink-muted: "#787B86"
12
+ ink-subtle: "#5D606B"
13
+ accent: "#2962FF"
14
+ accent-soft: "#1E53E5"
15
+ accent-deep: "#0D2B8C"
16
+ profit: "#26A69A"
17
+ loss: "#EF5350"
18
+ warning: "#F89D3E"
19
+ typography:
20
+ display:
21
+ fontFamily: "'Trebuchet MS', -apple-system, BlinkMacSystemFont, Roboto, Ubuntu, sans-serif"
22
+ fontSize: "1.5rem"
23
+ fontWeight: 700
24
+ lineHeight: "1.875rem"
25
+ letterSpacing: "-0.01em"
26
+ headline:
27
+ fontFamily: "'Trebuchet MS', -apple-system, BlinkMacSystemFont, Roboto, Ubuntu, sans-serif"
28
+ fontSize: "1rem"
29
+ fontWeight: 700
30
+ lineHeight: "1.375rem"
31
+ letterSpacing: "normal"
32
+ title:
33
+ fontFamily: "'Trebuchet MS', -apple-system, BlinkMacSystemFont, Roboto, Ubuntu, sans-serif"
34
+ fontSize: "0.8125rem"
35
+ fontWeight: 700
36
+ lineHeight: "1.125rem"
37
+ letterSpacing: "normal"
38
+ body:
39
+ fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
40
+ fontSize: "0.8125rem"
41
+ fontWeight: 400
42
+ lineHeight: "1.25rem"
43
+ letterSpacing: "normal"
44
+ label:
45
+ fontFamily: "'Trebuchet MS', -apple-system, BlinkMacSystemFont, Roboto, Ubuntu, sans-serif"
46
+ fontSize: "0.6875rem"
47
+ fontWeight: 700
48
+ lineHeight: "0.9375rem"
49
+ letterSpacing: "0.02em"
50
+ numeric:
51
+ fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
52
+ fontSize: "0.8125rem"
53
+ fontWeight: 500
54
+ lineHeight: "1.25rem"
55
+ letterSpacing: "normal"
56
+ fontFeature: "'tnum' 1, 'cv11' 1"
57
+ rounded:
58
+ sm: "3px"
59
+ md: "4px"
60
+ lg: "6px"
61
+ full: "9999px"
62
+ spacing:
63
+ xs: "4px"
64
+ sm: "8px"
65
+ md: "12px"
66
+ lg: "16px"
67
+ xl: "24px"
68
+ "2xl": "32px"
69
+ components:
70
+ toolbar-button:
71
+ backgroundColor: "transparent"
72
+ textColor: "{colors.ink-muted}"
73
+ rounded: "{rounded.sm}"
74
+ padding: "6px"
75
+ toolbar-button-hover:
76
+ backgroundColor: "{colors.surface-elevated}"
77
+ textColor: "{colors.ink}"
78
+ toolbar-button-active:
79
+ backgroundColor: "{colors.surface-elevated}"
80
+ textColor: "{colors.accent}"
81
+ symbol-search-pill:
82
+ backgroundColor: "{colors.surface}"
83
+ textColor: "{colors.ink}"
84
+ rounded: "{rounded.md}"
85
+ padding: "6px 10px"
86
+ border: "1px solid {colors.border-hairline}"
87
+ watchlist-row:
88
+ backgroundColor: "transparent"
89
+ textColor: "{colors.ink}"
90
+ padding: "6px 10px"
91
+ border: "1px solid transparent"
92
+ watchlist-row-hover:
93
+ backgroundColor: "{colors.surface-elevated}"
94
+ watchlist-row-selected:
95
+ borderLeft: "2px solid {colors.accent}"
96
+ backgroundColor: "{colors.surface}"
97
+ panel-tab:
98
+ backgroundColor: "transparent"
99
+ textColor: "{colors.ink-muted}"
100
+ padding: "8px 12px"
101
+ panel-tab-active:
102
+ textColor: "{colors.ink}"
103
+ borderBottom: "2px solid {colors.accent}"
104
+ context-menu:
105
+ backgroundColor: "{colors.surface}"
106
+ rounded: "{rounded.md}"
107
+ padding: "4px"
108
+ border: "1px solid {colors.border-hairline}"
109
+ boxShadow: "0 8px 32px -8px rgba(0, 0, 0, 0.6)"
110
+ context-menu-item:
111
+ backgroundColor: "transparent"
112
+ textColor: "{colors.ink}"
113
+ rounded: "{rounded.sm}"
114
+ padding: "6px 10px"
115
+ context-menu-item-hover:
116
+ backgroundColor: "{colors.surface-elevated}"
117
+ context-menu-item-disabled:
118
+ textColor: "{colors.ink-subtle}"
119
+ ohlc-legend:
120
+ backgroundColor: "transparent"
121
+ textColor: "{colors.ink}"
122
+ padding: "8px 12px"
123
+ ---
124
+
125
+ # Design System: Astroneum
126
+
127
+ > **Last verified against:** `astroneum` pre-v1.0 (pre-integration in `/opt/astroneum`; reference: `Desktop\Astroneum\docs\api.md`) · TV Super Chart Jul 2026 · `/opt/astroneum` @ HEAD.
128
+
129
+ ## 1. Overview
130
+
131
+ **Creative North Star: "The Astroneum Terminal"**
132
+
133
+ Astroneum is a charting-first trading product. The chart is the page; everything else is thin chrome around it. The product mirrors TradingView's Super Chart terminal: a multi-pane layout where one surface (the chart) occupies the majority of the screen, and four thin regions (top bar, left drawing toolbar, right watchlist rail, bottom panel) carry the supporting state. Astroneum is NOT a dashboard. It rejects the SaaS marketing dialect — hero-metric grids, glass panels, gradient text, animated sparkle, motivational empty states, tracked-uppercase eyebrows — that has saturated crypto and fintech UI. Its temperament is closer to TradingView, Bloomberg Terminal, and ThinkorSwim than to any exchange's marketing site.
134
+
135
+ The aesthetic is **dense, precise, instrument-grade**. The operator is a chartist first and a trader second; the interface is built for someone who reads price action, draws levels, and fires orders from the same canvas. Density is allowed because the operator is fluent in this domain and wants to see more, not less. Identity is carried by precision (tabular numerics, hairline borders, exact spacing rhythm, a single accent used sparingly), not by decoration.
136
+
137
+ **Mount model.** The chart pane is `<AstroneumChart>` from the `astroneum` npm package — a MIT-licensed, TV-class React charting library (Canvas2D / WebGL2, Web Workers, OPFS cache, `EventBus`, plugin system, subpath modules for replay/multichart/watchlist/portfolio/alerts/script/crypto datafeeds). Astroneum does NOT embed a TradingView widget; the `astroneum` library IS the chart engine. Everything around it (top bar, left toolbar, right rail, bottom panel, context menu, OHLC legend) is native Next.js chrome, styled to match the library's dark palette so the seam between `<AstroneumChart>` and chrome is invisible. The library is the chart; Astroneum chrome wraps it.
138
+
139
+ **Key Characteristics:**
140
+ - Single accent (`#2962FF`, Astroneum Blue) used on ≤8% of any screen.
141
+ - Three neutral tones stack for depth: BG → Surface → Surface-Elevated. Matched to the `astroneum` library's default dark theme.
142
+ - Two UI type families: Trebuchet MS for labels and headings, Inter with tabular-nums for all data.
143
+ - Profit/Loss carried by teal and coral, paired always with the numeric sign or an explicit side label.
144
+ - Motion conveys state only: crosshair tracking, tooltip follow, panel collapse. No entrance animations. No card hover lifts.
145
+ - Chart-occupies-most-of-screen: the chart pane is never smaller than 60% of non-chrome viewport area at any breakpoint ≥ lg.
146
+
147
+ ## 2. Colors: The TV Dark Palette
148
+
149
+ The palette is TradingView's dark theme, transcribed exactly. Astroneum inherits it so `<AstroneumChart>` and the native chrome read as one surface. Anything outside this list is wrong.
150
+
151
+ ### Primary
152
+ - **Astroneum Blue** (`#2962FF`, `oklch(0.55 0.22 264)`): The single accent. Reserved for the active panel tab underline, selected watchlist row left-edge, focused input ring, primary action button, current timeframe button, and the active drawing-tool indicator. Never used for decoration, never on inactive states, never paired with another saturated color on the same screen.
153
+ - **Astroneum Blue Soft** (`#1E53E5`, `oklch(0.50 0.22 264)`): Hover state of `Astroneum Blue` only. Not a standalone color.
154
+ - **Astroneum Blue Deep** (`#0D2B8C`, `oklch(0.27 0.16 264)`): Used as a 12% background tint behind the selected watchlist row and the active toolbar button, and as the deep ring on focused inputs. Not used for text.
155
+
156
+ ### Tertiary (Data Semantics)
157
+ - **Profit Teal** (`#26A69A`, `oklch(0.65 0.10 175)`): Positive P&L, BUY/LONG side pill, "Connected" status dot, "Live" mode chip. Always paired with the numeric sign (`+`) so the meaning survives color blindness.
158
+ - **Loss Coral** (`#EF5350`, `oklch(0.63 0.18 25)`): Negative P&L, SELL/SHORT side pill, destructive action label, error border, unread alert badge. Always paired with the numeric sign (`-`) or an explicit destructive verb.
159
+ - **Warning Amber** (`#F89D3E`, `oklch(0.80 0.14 65)`): "Paper Trading" mode chip, expiring API key notice, partial-fill warnings. Rare. Never used for primary action.
160
+
161
+ ### Neutral
162
+ - **Terminal BG** (`#131722`, `oklch(0.16 0.01 245)`): The page background. Matches the `astroneum` library's default dark theme so the seam is invisible.
163
+ - **Surface** (`#1E222D`, `oklch(0.20 0.01 245)`): The default panel surface. Top bar, watchlist rail, bottom panel, context menu, OHLC legend container chrome.
164
+ - **Surface Elevated** (`#2A2E39`, `oklch(0.24 0.01 245)`): Hovered rows, hovered toolbar buttons, popover/dropdown surfaces, active-item background tint.
165
+ - **Hairline Border** (`#363A45`, `oklch(0.30 0.01 245)`): The default stroke. 1px everywhere a boundary is needed.
166
+ - **Border Strong** (`#434651`, `oklch(0.36 0.01 245)`): Active panel tab underline fallback, divider lines between major regions.
167
+ - **Ink** (`#D1D4DC`, `oklch(0.86 0.005 245)`): Default text color. Cool off-white.
168
+ - **Ink Muted** (`#787B86`, `oklch(0.52 0.008 245)`): Secondary text. Body-text contrast ≥4.5:1 against Terminal BG.
169
+ - **Ink Subtle** (`#5D606B`, `oklch(0.42 0.008 245)`): Tertiary text. Disabled state, timestamps.
170
+
171
+ ### Named Rules
172
+
173
+ **The One Voice Rule.** Astroneum Blue is used on ≤8% of pixels on any screen.
174
+ **The Sign + Color Rule.** P&L and side semantics always carry the numeric sign or an explicit label.
175
+ **The Two-Layer Rule.** Neutral surfaces stack at most three tones deep: BG → Surface → Surface-Elevated.
176
+ **The Match-The-Library Rule.** Native chrome colors match the `astroneum` library's dark theme exactly. Do not tune `#131722` toward a brand tint; if chrome drifts, the seam shows.
177
+
178
+ ## 3. Typography
179
+
180
+ **UI Font:** Trebuchet MS (with `-apple-system, BlinkMacSystemFont, Roboto, Ubuntu, sans-serif` fallback)
181
+ **Data Font:** Inter (with `ui-sans-serif, system-ui, sans-serif` fallback)
182
+ **Numeric Font:** Inter with `font-feature-settings: 'tnum' 1, 'cv11' 1` for tabular numerals
183
+
184
+ **Character:** Two families, deliberately split. Trebuchet MS carries UI chrome (panel titles, toolbar labels, symbol search, watchlist symbols, tab labels). Inter carries data (prices, P&L, quantities, percentages, timestamps). The Inter numeric variant locks digits to a fixed advance so columns of numbers align.
185
+
186
+ ### Hierarchy
187
+
188
+ - **Display** (Trebuchet MS, 700, 1.5rem / 1.875rem, -0.01em): The active symbol/ticker at top-left of the chart legend only. One per screen.
189
+ - **Headline** (Trebuchet MS, 700, 1rem / 1.375rem): Panel titles — "Watchlist", "Trading Panel", "Open Positions".
190
+ - **Title** (Trebuchet MS, 700, 0.8125rem / 1.125rem): Section titles inside a panel, modal titles, popover headers.
191
+ - **Body** (Inter, 400, 0.8125rem / 1.25rem): Default text.
192
+ - **Label** (Trebuchet MS, 700, 0.6875rem / 0.9375rem, 0.02em): Toolbar button tooltips, table column headers, form field labels. Sentence case, never tracked-uppercase.
193
+ - **Numeric** (Inter with tabular-nums, 500, 0.8125rem / 1.25rem): All numbers.
194
+
195
+ ### Named Rules
196
+
197
+ **The No-Eyebrow Rule.** Tracked uppercase labels above sections are prohibited.
198
+ **The Tabular Rule.** Every numeric value uses tabular numerals.
199
+ **The Display Ceiling.** Display style maxes out at 1.5rem (24px).
200
+ **The Family-Split Rule.** Trebuchet MS for UI chrome; Inter for data. Never mix.
201
+
202
+ ## 4. Layout: The Super Chart Shell
203
+
204
+ Astroneum v1 ships one layout: the Super Chart terminal. It is a 5-region grid that fills the viewport below the app's shared top navigation. The chart pane is the dominant region; the four chrome regions are thin and dense.
205
+
206
+ ### Regions
207
+
208
+ | Region | Size | Position | Contents |
209
+ |---|---|---|---|
210
+ | Top bar | 44px height, full width | top | symbol-search pill (left), timeframe selector, chart-type button, indicators button, alerts button, settings, fullscreen toggle (right) |
211
+ | Left toolbar | 48px width, full chart height | left of chart | drawing tools: cursor, trend line, fib retracement, rectangle, text, measure, magnet snap |
212
+ | Chart pane | flex-1 (≥60% of non-chrome viewport) | center | `<AstroneumChart>` mounted here; owns all chart rendering |
213
+ | Right rail | 260px width, collapsible to 0 | right of chart | watchlist (top), quote summary + P&L (bottom) |
214
+ | Bottom panel | 220px height, collapsible to 0, tabs | below chart | tabs: Trading Panel (default), Strategy Tester, Script Editor |
215
+
216
+ ### Behavior
217
+
218
+ - **Top bar** is fixed-height. Symbol-search pill opens a command-palette-style overlay (see §5). Timeframe buttons are mutually exclusive; active gets the Astroneum Blue underline + tint.
219
+ - **Left toolbar** is icon-only, vertical. Active tool gets Astroneum Blue icon + 12% tint background. Hover reveals a settings popover for the active drawing (stroke width, color, magnet). Controls `astroneum`'s `drawingBarVisible` + drawing overlays via the library's drawing API.
220
+ - **Chart pane** is `<AstroneumChart>`. The library owns all rendering inside this pane — candles, indicators, drawing overlays, crosshair, axis. Astroneum adds two read-only overlays on top: the OHLC legend (§11, via `EventBus` `crosshair-move`) and the context menu (§11, via DOM `contextmenu` on the container). No other chrome inside the pane.
221
+ - **Right rail** collapses with a 240ms slide. Collapsed state stores per-user via `serializeState()`. Watchlist row selection drives `chartRef.current.setSymbol()`.
222
+ - **Bottom panel** tabs are underline-on-active. Trading Panel tab is always present; Strategy Tester and Script Editor tabs surface the `astroneum/script` `ScriptEngine` and backtest capabilities. Panel collapses to 0 with the same 240ms slide.
223
+
224
+ ### Responsive
225
+
226
+ - **≥ lg (1024px+):** Full 5-region layout. Chart pane ≥60% of viewport.
227
+ - **< lg:** Chart pane only. Top bar collapses to symbol-search + timeframe. Left toolbar, right rail, bottom panel hidden. A floating action button opens the right rail as an overlay. Mobile/touch UX is explicitly out of scope for v1 (§12).
228
+
229
+ ## 5. Components
230
+
231
+ Each component ships `default`, `hover`, `focus-visible`, `active`, `disabled`, `loading`, and `error` states where applicable. Missing states are not shipped.
232
+
233
+ ### Toolbar Button (top bar + left toolbar)
234
+ - 3px corner radius. 32px square (top bar) or 36px square (left toolbar).
235
+ - Default: transparent, `Ink Muted` icon. Hover: `Surface-Elevated`, `Ink`. Active: `Surface-Elevated`, `Astroneum Blue` icon, 12% `Astroneum Blue Deep` tint. Focus: 2px `Astroneum Blue` ring. Disabled: 40% opacity.
236
+
237
+ ### Symbol Search Pill (top bar)
238
+ - 4px radius, 6px / 10px padding, 1px `Hairline Border`. `Surface` background, `Ink` text, search icon left.
239
+ - Click opens command-palette overlay (640px max, `Surface-Elevated`, `shadow-floating`). Search input 40px tall. Result rows 36px: symbol + name + muted exchange. Selected: 8% `Astroneum Blue` tint.
240
+ - Keyboard: `/` focuses. `Enter` calls `chartRef.current.setSymbol()`.
241
+
242
+ ### Watchlist Row (right rail)
243
+ - Transparent, `Ink` symbol + `Ink Muted` last + Sign+Color change%. Hover: `Surface-Elevated`. Selected: 2px `Astroneum Blue` left edge, `Surface` bg.
244
+ - 1px `Hairline Border` top divider. 32px row. Tabular-nums on price + change.
245
+
246
+ ### Panel Tab (bottom panel)
247
+ - Transparent, `Ink Muted`, 8px / 12px padding. Active: `Ink` text, 2px `Astroneum Blue` bottom border. Hover (inactive): `Ink` text. Underline-on-active, never pill.
248
+
249
+ ### Order / Position Table (Trading Panel tab)
250
+ - Header: `Label`, `Ink Muted`, sentence case, 1px bottom `Hairline Border`. Data rows: `Body`/`Numeric`, 1px top `Hairline Border`, 36px dense. Row hover: `Surface-Elevated`. Row selection: 2px `Astroneum Blue` left edge + 8% tint.
251
+ - Side pill: transparent, `Profit Teal`/`Loss Coral` text, 1px colored border at 40% alpha. Always paired with `LONG`/`SHORT`.
252
+ - Empty state: one `Ink Muted` sentence + a `Secondary` button. No illustration.
253
+
254
+ ### Drawing Tool Popover (left toolbar, hover of active tool)
255
+ - `Surface-Elevated`, 4px radius, `shadow-floating`, 1px `Hairline Border`. Stroke width input, color swatches (limited to 7 system colors), magnet toggle, "delete drawing" danger link. Dismiss on `Esc` or outside-click.
256
+
257
+ ### Charts — `<AstroneumChart>` options
258
+
259
+ The chart pane is `<AstroneumChart>` from the `astroneum` npm package. Configuration is via React props + instance methods, NOT widget config flags.
260
+
261
+ **Mount props** (from `astroneum` API):
262
+ - `symbol: SymbolInfo` — ticker + precision + description
263
+ - `period: Period` — `{ multiplier, timespan, text }` e.g. `{ multiplier: 1, timespan: 'hour', text: '1H' }`
264
+ - `datafeed: Datafeed` — implements `searchSymbols` / `getHistoryData` / `subscribe` / `unsubscribe` (see §6)
265
+ - `theme: 'dark'` — locked to dark in v1
266
+ - `locale`, `timezone` — UI locale + IANA timezone for X-axis
267
+ - `watermark` — Astroneum logo SVG (or omit)
268
+ - `styles: DeepPartial<Styles>` — override the library's dark theme to match this palette exactly
269
+ - `drawingBarVisible: boolean` — controls the library's left drawing toolbar (default `true`; Astroneum chrome left toolbar is separate)
270
+ - `periods: Period[]` — timeframes in the period bar
271
+ - `mainIndicators: IndicatorDef[]` — overlays on the candle pane (e.g. `[{ name: 'EMA', calcParams: [7,25,99] }]`)
272
+ - `subIndicators: string[]` — sub-pane indicators (e.g. `['VOL']`)
273
+ - `plugins: ChartPlugin[]` — lifecycle bundles (`onInit` / disposer)
274
+ - `accessible: boolean` — opts the canvas into screen-reader + keyboard-focus support; `aria-live` announces OHLCV on crosshair changes (the data plumbing for §11 OhlcLegend)
275
+ - `ariaLabel: string` — override the default `"<ticker> <period> chart"` label
276
+
277
+ **Instance methods** (via `ref`): `setSymbol()`, `setPeriod()`, `setTheme()`, `setLocale()`, `setTimezone()`, `setStyles()`, `getStyles()`, `serializeState()` / `loadState()`.
278
+
279
+ **EventBus** (`new EventBus<ChartEventMap>()`): `symbol-change`, `period-change`, `crosshair-move`, `zoom`, `data-load`, `tick`, `drawing-start`, `drawing-end`, `theme-change`.
280
+
281
+ **Subpath modules**: `astroneum/replay` (`BarReplay`), `astroneum/multichart` (`MultiChartLayout`), `astroneum/watchlist` (`WatchlistManager`), `astroneum/portfolio` (`PortfolioTracker`), `astroneum/alerts` (`AlertManager`), `astroneum/script` (`ScriptEngine`), `astroneum/datafeeds/polygon`, `astroneum/datafeeds/crypto` (`createStandardCryptoDatafeed`, `BinanceAdapter`, `BitgetAdapter`, `OkxAdapter`).
282
+
283
+ ### Context Menu (chart pane right-click) — see §11
284
+ ### OHLC Legend (chart pane top-left overlay) — see §11
285
+
286
+ ## 6. The AstroneumChart Mount
287
+
288
+ The chart pane is `<AstroneumChart>` from the `astroneum` npm package. Astroneum does not embed a TradingView widget; the `astroneum` library IS the chart engine.
289
+
290
+ ### Install
291
+ ```bash
292
+ pnpm add astroneum
293
+ ```
294
+ Declared in `/opt/astroneum/demo/package.json` as `"astroneum": "workspace:*"` (the `astroneum-demo-next` workspace package). Pre-v1.0 today; migrate root imports to subpath imports before v1.0 (root re-exports removed at v1.0 — see `astroneum` CHANGELOG). Astroneum is a SEPARATE project from Trading-Bot-V2 — do not declare the dependency in the Trading-Bot-V2 repo.
295
+
296
+ ### Mount
297
+ ```tsx
298
+ import { AstroneumChart, EventBus } from '@tony01/astroneum'
299
+ import { createStandardCryptoDatafeed } from '@tony01/astroneum/datafeeds/crypto'
300
+
301
+ const bus = new EventBus()
302
+ const datafeed = createStandardCryptoDatafeed({ exchange: 'binance' })
303
+
304
+ <AstroneumChart
305
+ ref={chartRef}
306
+ symbol={{ ticker: 'BTCUSDT' }}
307
+ period={{ multiplier: 1, timespan: 'hour', text: '1H' }}
308
+ datafeed={datafeed}
309
+ theme="dark"
310
+ locale="en-US"
311
+ timezone="Asia/Bangkok"
312
+ drawingBarVisible={false} // Astroneum chrome left toolbar is the surface
313
+ periods={[/* 1m, 5m, 15m, 1H, 4H, 1D, 1W */]}
314
+ mainIndicators={[{ name: 'EMA', calcParams: [7, 25, 99] }]}
315
+ subIndicators={['VOL']}
316
+ plugins={[/* ChartPlugin bundles */]}
317
+ accessible
318
+ ariaLabel="BTCUSDT 1-hour candles"
319
+ styles={astPaletteOverride} // DeepPartial<Styles> matching §2 exactly
320
+ />
321
+ ```
322
+
323
+ ### Lifecycle
324
+ - **Symbol / interval change:** call `chartRef.current.setSymbol(next)` or `chartRef.current.setPeriod(next)`. **Do not reboot the component.** The library reloads data via the datafeed and re-renders in place. (This is the key difference from a TV widget embed, which required destroy + re-init.)
325
+ - **Unmount cleanup:** dispose the `EventBus` subscribers and any `ChartPlugin` disposers returned from `onInit`. The library handles its own canvas/WebGL teardown.
326
+ - **State persistence:** `serializeState()` → `localStorage`; `loadState()` on mount. Covers theme, locale, timezone, symbol, period, styles, indicators, drawing overlays.
327
+
328
+ ### Bridge to app state
329
+ Subscribe to `EventBus` events so Astroneum chrome stays in sync with the chart. The demo app manages its own state (it does NOT share Trading-Bot-V2's `useTradingStore` — the projects are separate):
330
+ - `symbol-change` → update the demo app's symbol state; refresh RightRail details + BottomPanel positions filter.
331
+ - `period-change` → route query `?interval=...` (optional, for shareable URLs).
332
+ - `crosshair-move` → OhlcLegend overlay update (§11).
333
+ - `tick` → RightRail last-price + P&L live update.
334
+ - `theme-change` → not used in v1 (dark locked), but wired for v2 light theme.
335
+
336
+ ### Bridge from chrome
337
+ - Watchlist row click → `chartRef.current.setSymbol({ ticker })`.
338
+ - Timeframe button click → `chartRef.current.setPeriod(period)`.
339
+ - Indicators button → mutate `mainIndicators` / `subIndicators` state → re-render `<AstroneumChart>`.
340
+ - Layout save/load → `serializeState()` / `loadState()`.
341
+
342
+ ### Datafeed
343
+ Use `astroneum/datafeeds/crypto` (`createStandardCryptoDatafeed` with `BinanceAdapter` / `BitgetAdapter` / `OkxAdapter`) for 100+ crypto symbols with real-time WebSocket. This is the default. The Astroneum demo app does NOT proxy through Trading-Bot-V2's `/api/binance` — the two projects are separate. For exchange keys / account-specific data, implement a custom `Datafeed` (`searchSymbols` / `getHistoryData` / `subscribe` / `unsubscribe`) inside `/opt/astroneum/demo/src/app/api/`.
344
+
345
+ ### Trading & Data Bridge
346
+ The Astroneum demo app is **charting-first** — it does NOT have a trading API. The only existing API route is `/api/alerts/email` (in `/opt/astroneum/demo/src/app/api/alerts/`). Trading-Bot-V2's `/api/orders`, `/api/portfolio`, `/api/tv-positions`, `/api/webhooks/tradingview` are in a SEPARATE project and are NOT available to Astroneum.
347
+
348
+ If trading integration is needed in a future version:
349
+ - Build new API routes in `/opt/astroneum/demo/src/app/api/` (do not import from Trading-Bot-V2).
350
+ - OR use `astroneum/portfolio`'s `PortfolioTracker` (`astroneum/portfolio` subpath) for read-only position/P&L display — but it is not an execution path.
351
+
352
+ For v1, the Trading Panel tab in the bottom panel is charting-only (no order placement). The `OrderPanel` and `OpenPositions` components referenced in the original spec are Trading-Bot-V2's and are NOT reused — the demo app builds its own.
353
+
354
+ ## 7. Motion & State
355
+
356
+ The terminal is sparse on motion. Motion conveys state, never entry.
357
+
358
+ - **Permitted:** crosshair tracking (library-native via `crosshair-move`), tooltip follow, OHLC legend value updates on crosshair move, panel collapse/expand slide (240ms, the only layout-motion permitted), focus ring appearance, hover background fades (120ms, color-only).
359
+ - **Prohibited:** page-entrance fades, card hover lifts (`-translate-y`), card-gradient surfaces, decorative iconography in empty states, animated sparkle, count-up animations on numeric values.
360
+ - **Loading:** the chart pane shows nothing until `<AstroneumChart>` mounts; the library renders its own loading state. Surrounding chrome shows skeleton bars (`Surface-Elevated` blocks pulsing at 1.2s) until data resolves.
361
+ - **Error:** the affected chrome region shows a single `Ink Muted` sentence with the specific problem and the retry action.
362
+
363
+ ## 8. Accessibility
364
+
365
+ The keyboard is a first-class input. The terminal is operable without a mouse.
366
+
367
+ - `/` — focuses the symbol search pill.
368
+ - `Esc` — dismisses every floating layer (search overlay, drawing popover, context menu).
369
+ - `1`–`9` — selects timeframe (TV convention: `1`=1m, `2`=5m, `3`=15m, `4`=30m, `5`=1h, `6`=4h, `7`=1D, `8`=1W, `9`=1M).
370
+ - `Cmd/Ctrl-K` — opens the app-wide command palette.
371
+ - Arrow keys — navigate menus, watchlist rows, context menu items.
372
+ - `Enter` — confirms selection.
373
+ - `<AstroneumChart accessible>` — opts the canvas into screen-reader + keyboard-focus support: container gets `tabindex=0`, `role="img"`, `aria-label`; a visually-hidden `aria-live="polite"` region announces OHLCV on crosshair changes (throttled ~10/s).
374
+ - Focus ring: 2px `Astroneum Blue` offset by 2px `Terminal BG`, via `box-shadow`.
375
+ - Color is never the only state channel — always paired with sign, label, or icon.
376
+
377
+ ## 9. Do's and Don'ts
378
+
379
+ ### Do:
380
+ - **Do** match the `astroneum` library's dark theme exactly. The seam between `<AstroneumChart>` and chrome must be invisible.
381
+ - **Do** use Trebuchet MS for UI chrome and Inter with tabular-nums for data.
382
+ - **Do** give Astroneum Blue the rarest seat in the house. ≤8% of any screen.
383
+ - **Do** pair P&L and side semantics with the numeric sign or explicit label.
384
+ - **Do** call `chartRef.current.setSymbol()` / `setPeriod()` on change. Do not reboot `<AstroneumChart>`.
385
+ - **Do** clean up `EventBus` subscribers and `ChartPlugin` disposers on unmount.
386
+ - **Do** keep Astroneum separate from Trading-Bot-V2. The demo app is charting-first; if trading is needed, build new API routes in `/opt/astroneum/demo/src/app/api/` — do not import from the Trading-Bot-V2 project.
387
+ - **Do** use `astroneum/datafeeds/crypto` (`BinanceAdapter`) as the default datafeed.
388
+ - **Do** ship every interactive primitive with default, hover, focus-visible, active, disabled, loading, and error states.
389
+
390
+ ### Don't:
391
+ - **Don't** fork the `astroneum` package. Extend via props, `ChartPlugin`, `registerOverlay`, or `IndicatorPlugin`. If the library lacks a feature, file an issue or write a plugin — do not patch the source.
392
+ - **Don't** embed a TradingView widget. The `astroneum` library IS the chart engine. Mixing TV-widget flags (`hide_top_toolbar`, `hide_legend`, `disable_native_context_menu`) is wrong — those flags do not exist on `<AstroneumChart>`.
393
+ - **Don't** reboot `<AstroneumChart>` on symbol/interval change. Call the instance methods.
394
+ - **Don't** use CryptoBot Console Blue (`#0A21C0`) anywhere in `/astroneum`. Different product, different accent.
395
+ - **Don't** use `backdrop-filter: blur` on panels. Glass is reserved for the command-palette overlay.
396
+ - **Don't** orchestrate page-entrance animations. Motion conveys state, not entry.
397
+ - **Don't** rely on color alone for state. Always pair with sign, label, or icon.
398
+ - **Don't** wire trading through `astroneum/portfolio`'s `PortfolioTracker` for execution. The demo app is charting-first; build new API routes in `/opt/astroneum/demo/src/app/api/` if trading is needed — do not import from Trading-Bot-V2.
399
+
400
+ ## 10. Project layout & components
401
+
402
+ Astroneum is a **SEPARATE project** from Trading-Bot-V2. It lives at `/opt/astroneum/` on the server (served at `https://72.62.73.180/astroneum/` via nginx → PM2 `astroneum-demo` on port 3002) and `C:\Users\Joooo\Desktop\Astroneum\` locally. The git remote is `github.com/kowito/astroneum` — a different repo from Trading-Bot-V2 (`github.com/Tony1185/trading-bot-v2.git`). Do not mix the two.
403
+
404
+ ### Structure
405
+ - `/opt/astroneum/` — the `astroneum` charting library (npm package, `src/`, `dist/`, `package.json`).
406
+ - `/opt/astroneum/demo/` — the `astroneum-demo-next` Next.js 15 app (workspace package, port 3002, the actual terminal served at `/astroneum/`). Dependencies: `astroneum: workspace:*`, `next`, `react@19`.
407
+ - `/opt/astroneum/docs/` — engine docs (`api.md`, `datafeed-guide.md`, `plugin-development.md`) + this doc + `tv-functions-skill.md`.
408
+ - `/opt/astroneum/demo/DESIGN.md` + `PRODUCT.md` — the demo app's own product/design docs (companion to this doc).
409
+
410
+ ### Existing demo app components (already built)
411
+ The home page (`/opt/astroneum/demo/src/app/page.tsx`) renders `<ChartTerminal />`. The terminal is already scaffolded:
412
+ - `src/app/components/ChartTerminal.tsx` — the main terminal orchestrator.
413
+ - `src/app/components/TerminalShell.tsx` — the 5-region shell.
414
+ - `src/app/components/MultiChartView.tsx` — multi-pane layout.
415
+ - `src/app/components/ChartTypeDropdown.tsx` — chart-type selector.
416
+ - `src/app/components/PatternDialog.tsx` — pattern detection dialog.
417
+ - `src/app/components/ReplayToolbar.tsx` — bar replay controls.
418
+ - `src/app/components/ChartDemo.tsx` — chart mount demo.
419
+ - `src/app/components/panels/WatchlistPanel.tsx` — watchlist rail.
420
+ - `src/app/components/panels/PineEditorPanel.tsx` — Pine-like script editor.
421
+ - `src/app/_components/alerts/` — `AlertDialog`, `NotificationsDialog`, `Popover`, `ErrorBoundary`.
422
+ - `src/app/api/alerts/email/route.ts` — the only API route (alerts email).
423
+
424
+ ### Where to add new components
425
+ - Chart chrome → `src/app/components/` (existing convention: `ChartTerminal`, `TerminalShell`, etc.).
426
+ - Alert/utility components → `src/app/_components/` (existing convention).
427
+ - New API routes → `src/app/api/` (build fresh; do not import from Trading-Bot-V2).
428
+
429
+ ### NOT reused from Trading-Bot-V2
430
+ The following are in the Trading-Bot-V2 project and are NOT available to Astroneum:
431
+ - `useTradingStore`, `OrderPanel`, `OpenPositions`, `TvPositionCard` — Trading-Bot-V2 components.
432
+ - `/api/orders`, `/api/portfolio`, `/api/tv-positions`, `/api/webhooks/tradingview`, `/api/integrations/tradingview` — Trading-Bot-V2 API routes.
433
+ - `DashboardLayout`, `globals.css` tokens (`--bg`, `bg-bg`) — Trading-Bot-V2 layout/CSS.
434
+
435
+ The demo app has its own `DESIGN.md` token block, its own `terminal.css` / `panels.css` / `enhancements.css`, and its own component tree. Use `astroneum`'s `formatPrice` / `formatVolume` / `formatPercent` exports (from the library) for symbol-precision-aware formatting — do not reach into Trading-Bot-V2's `src/lib/utils.ts`.
436
+
437
+ ## 11. In-Scope Additions (TV-native feel, built on `astroneum` EventBus + DOM)
438
+
439
+ These two overlays are native Astroneum chrome built on top of `<AstroneumChart>`. They do NOT require any widget config flag — the `astroneum` library has no built-in visual legend or context menu, so there is no double-render risk.
440
+
441
+ ### Chart Right-Click Context Menu
442
+ Native Astroneum chrome — not library-provided. Right-click anywhere on the chart pane opens a context menu styled to the dark palette (`#1E222D` surface, `#2A2E39` hover, `#D1D4DC` ink).
443
+ - **Mechanism:** DOM `contextmenu` event listener on the `<AstroneumChart>` container `div` (`e.preventDefault()` + show menu at `e.clientX`/`e.clientY`). No library flag needed.
444
+ - **Sections:** Insert indicator, Add alert at cursor price, Trade from here (buy/sell at price), Reset chart, Copy price, Settings.
445
+ - **States:** default / hover (`Surface-Elevated`) / disabled (`Ink-Muted`) / with-submenu (chevron right).
446
+ - **Divider:** hairline (`#2A2E39`) between logical groups.
447
+ - Dismiss on `Esc` or outside-click. Keyboard-navigable (arrow keys, `Enter`).
448
+ - **v2-future:** if canvas-coordinate resolution is needed (e.g. "Add alert at cursor price" needs the price at the click point), request a `context-menu` event in `ChartEventMap` from the `astroneum` library. For v1, derive price from the last `crosshair-move` coordinate or the visible-range `Viewport`.
449
+
450
+ ### Crosshair OHLC Legend / Data Window
451
+ Top-left overlay inside the chart pane showing live values as the crosshair moves.
452
+ - **Mechanism:** subscribe to `EventBus` `'crosshair-move'` event (`Coordinate | null`). On each event, map the coordinate to a bar index, fetch O/H/L/C/V from the chart's bar store, and render the overlay. On `null` (mouse-leave), snap to the last bar.
453
+ - **Line 1:** symbol + interval (Trebuchet MS, `Ink`).
454
+ - **Line 2:** O H L C values (Inter, tabular-nums) with Sign+Color applied to change (profit teal `#26A69A` / loss coral `#EF5350`).
455
+ - **Line 3:** Volume + active `mainIndicators`/`subIndicators` with their current values (via the library's indicator output API).
456
+ - No entrance animation (per §7).
457
+ - **Data plumbing reuse:** the `accessible` prop's `aria-live` OHLCV announcement already does this data extraction for screen readers. The visual OhlcLegend renders the same data in a positioned overlay. No duplication of the data path.
458
+ - This is a read-only overlay — it does NOT add interactive chrome inside the chart pane beyond the legend (see §9 Don'ts).
459
+
460
+ ## 12. Out of Scope for v1
461
+
462
+ The following surfaces are explicitly **not** part of Astroneum v1. Some are supported by the `astroneum` library but deferred at the APP level for v1 scope; the rest are not in the library.
463
+
464
+ | Surface | Library supports? | v1 status | Reason |
465
+ |---|---|---|---|
466
+ | Multi-chart layouts (2×2, 3×1 grid) | YES (`astroneum/multichart`) | Deferred to v1.1 | v1 ships single-pane; layout selector is a follow-up. |
467
+ | Compare / overlay / spread symbols | YES (README "Compare/Overlay") | Deferred to v1.1 | Native UX for it deferred. |
468
+ | Indicator settings dialog (Inputs/Style/Visibility) | Partial (via `ChartPlugin`) | Deferred | Native modal out of scope; use `mainIndicators`/`subIndicators` props for v1. |
469
+ | Full alerts flow (modal, log, drag-to-set) | YES (`astroneum/alerts` `AlertManager`) | Deferred to v1.1 | v1 ships the alerts button only; deep UX deferred. |
470
+ | Screener, Heatmaps, Calendars, News, Ideas/social | NO | v2-future | Separate products, not charting features. |
471
+ | Broker OAuth connection | NO | v2-future | Astroneum is charting-first; no trading in v1. Build new API routes in `/opt/astroneum/demo/src/app/api/` if trading is needed. |
472
+ | On-chart order dragging (drag SL/TP) | NO | v2-future | Needs `context-menu`/`drawing` event integration. |
473
+ | Depth of Market (DOM) | YES (README "Depth of Market") | Deferred to v1.1 | Library supports it; APP defers surface. |
474
+ | Light theme | YES (`theme="light"`, `high-contrast`) | v2 | Astroneum commits to dark only in v1. |
475
+ | Full mobile/touch UX | NO | v2 | v1 collapses to chart-only < lg. |
476
+ | Object tree / layers panel | NO | v2-future | Not required for v1 charting-first goal. |
477
+ | Logo / brand mark lockup | n/a | separate design pass | Needs dedicated brand work. |
478
+
479
+ **Moved OUT of deferred (now native via `astroneum` package):** multi-chart, compare/overlay, alerts, script editor (`astroneum/script` `ScriptEngine`), layouts (`serializeState`/`loadState` + `DrawingTemplates`), DOM — all library-supported. They remain v1-deferred at the APP surface level (v1.1 follow-up), not blocked on the library.