gloomberb 0.4.1 → 0.5.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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/app.tsx +168 -65
- package/src/cli/commands/ticker.ts +45 -15
- package/src/cli/helpers.ts +4 -2
- package/src/cli/registry.test.ts +42 -35
- package/src/cli.test.ts +4 -2
- package/src/components/chart/chart-control-hint.tsx +39 -0
- package/src/components/chart/chart-controller.test.ts +110 -0
- package/src/components/chart/chart-controller.ts +364 -2
- package/src/components/chart/chart-data.ts +177 -29
- package/src/components/chart/chart-indicator-selector.tsx +53 -0
- package/src/components/chart/chart-pane-settings.ts +20 -0
- package/src/components/chart/chart-renderer.ts +220 -30
- package/src/components/chart/chart-resolution.test.ts +67 -0
- package/src/components/chart/chart-resolution.ts +74 -4
- package/src/components/chart/chart-scroll.test.ts +69 -0
- package/src/components/chart/chart-scroll.ts +104 -0
- package/src/components/chart/chart-types.ts +12 -0
- package/src/components/chart/chart-viewport.test.ts +5 -1
- package/src/components/chart/chart-viewport.ts +1 -1
- package/src/components/chart/chart.test.ts +249 -10
- package/src/components/chart/comparison-chart-renderer.test.ts +71 -1
- package/src/components/chart/comparison-chart-renderer.ts +40 -3
- package/src/components/chart/comparison-stock-chart.tsx +218 -123
- package/src/components/chart/indicators/bands.test.ts +50 -0
- package/src/components/chart/indicators/bands.ts +29 -0
- package/src/components/chart/indicators/moving-averages.test.ts +54 -0
- package/src/components/chart/indicators/moving-averages.ts +42 -0
- package/src/components/chart/indicators/options.test.ts +32 -0
- package/src/components/chart/indicators/options.ts +107 -0
- package/src/components/chart/indicators/oscillators.test.ts +79 -0
- package/src/components/chart/indicators/oscillators.ts +92 -0
- package/src/components/chart/indicators/types.ts +36 -0
- package/src/components/chart/native/chart-rasterizer.ts +51 -0
- package/src/components/chart/native/kitty.test.ts +68 -0
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +740 -9
- package/src/components/chart/stock-chart.test.ts +239 -0
- package/src/components/chart/stock-chart.tsx +2257 -372
- package/src/components/command-bar/command-bar.test.tsx +337 -5
- package/src/components/command-bar/command-bar.tsx +292 -120
- package/src/components/command-bar/helpers.ts +1 -1
- package/src/components/command-bar/root-shortcuts.ts +33 -4
- package/src/components/command-bar/view-model.test.ts +3 -3
- package/src/components/command-bar/view-model.ts +4 -4
- package/src/components/command-bar/workflow-ops.ts +10 -0
- package/src/components/layout/header.tsx +2 -1
- package/src/components/layout/shell.test.tsx +186 -27
- package/src/components/layout/shell.tsx +5 -4
- package/src/components/layout/status-bar.test.tsx +16 -7
- package/src/components/layout/status-bar.tsx +4 -1
- package/src/components/markdown-editor.tsx +1 -0
- package/src/components/pane-settings-dialog.tsx +13 -152
- package/src/components/pane-template-wizard.tsx +1 -0
- package/src/components/price-selector-dialog.tsx +12 -7
- package/src/components/ticker-badge-text.test.tsx +50 -0
- package/src/components/ticker-badge-text.tsx +17 -2
- package/src/components/ticker-badge.tsx +2 -2
- package/src/components/ticker-list-table.tsx +54 -1
- package/src/components/toggle-list.tsx +15 -2
- package/src/components/ui/data-table.tsx +60 -3
- package/src/components/ui/external-link.tsx +48 -11
- package/src/components/ui/fields.tsx +2 -1
- package/src/components/ui/index.ts +8 -1
- package/src/components/ui/multi-select-chips.tsx +69 -0
- package/src/components/ui/multi-select-dialog.tsx +267 -0
- package/src/components/ui/multi-select.ts +78 -0
- package/src/components/ui/ui.test.tsx +343 -1
- package/src/data/plugin-state-store.ts +30 -19
- package/src/data/resource-store.ts +133 -103
- package/src/data/session-store.ts +19 -12
- package/src/data/sqlite-cache.test.ts +37 -2
- package/src/data/sqlite-database.ts +8 -2
- package/src/data/sqlite-retry.test.ts +63 -0
- package/src/data/sqlite-retry.ts +66 -0
- package/src/data/ticker-store.ts +29 -18
- package/src/index.tsx +6 -1
- package/src/market-data/coordinator.test.ts +114 -5
- package/src/market-data/coordinator.ts +70 -1
- package/src/market-data/hooks.test.tsx +73 -2
- package/src/market-data/hooks.tsx +16 -4
- package/src/notifications/app-notifier.test.ts +177 -0
- package/src/notifications/app-notifier.ts +241 -0
- package/src/pane-settings.test.ts +2 -0
- package/src/plugins/builtin/ai/index.test.tsx +1 -1
- package/src/plugins/builtin/ai/screener-pane.test.tsx +2 -0
- package/src/plugins/builtin/ai/screener-pane.tsx +1 -0
- package/src/plugins/builtin/ai/ticker-context.ts +3 -2
- package/src/plugins/builtin/alerts/alert-engine.test.ts +90 -0
- package/src/plugins/builtin/alerts/alert-engine.ts +55 -0
- package/src/plugins/builtin/alerts/index.test.tsx +357 -0
- package/src/plugins/builtin/alerts/index.tsx +519 -0
- package/src/plugins/builtin/alerts/types.ts +14 -0
- package/src/plugins/builtin/analytics/index.test.tsx +300 -0
- package/src/plugins/builtin/analytics/index.tsx +775 -0
- package/src/plugins/builtin/analytics/metrics.test.ts +125 -0
- package/src/plugins/builtin/analytics/metrics.ts +155 -0
- package/src/plugins/builtin/ask-ai.test.tsx +2 -0
- package/src/plugins/builtin/chat-controller.test.ts +62 -18
- package/src/plugins/builtin/chat-controller.ts +23 -12
- package/src/plugins/builtin/chat.test.tsx +715 -4
- package/src/plugins/builtin/chat.tsx +415 -119
- package/src/plugins/builtin/comparison-chart.test.tsx +97 -57
- package/src/plugins/builtin/comparison-chart.tsx +1 -2
- package/src/plugins/builtin/correlation/compute.test.ts +147 -0
- package/src/plugins/builtin/correlation/compute.ts +115 -0
- package/src/plugins/builtin/correlation/index.tsx +385 -0
- package/src/plugins/builtin/correlation/plugin.test.ts +44 -0
- package/src/plugins/builtin/correlation/settings.test.ts +34 -0
- package/src/plugins/builtin/correlation/settings.ts +95 -0
- package/src/plugins/builtin/debug.tsx +36 -50
- package/src/plugins/builtin/earnings/earnings-cache.test.ts +181 -0
- package/src/plugins/builtin/earnings/earnings-cache.ts +136 -0
- package/src/plugins/builtin/earnings/earnings-data.test.ts +59 -0
- package/src/plugins/builtin/earnings/earnings-data.ts +50 -0
- package/src/plugins/builtin/earnings/index.tsx +337 -0
- package/src/plugins/builtin/econ/calendar-source.test.ts +219 -0
- package/src/plugins/builtin/econ/calendar-source.ts +121 -0
- package/src/plugins/builtin/econ/fred-client.test.ts +63 -0
- package/src/plugins/builtin/econ/fred-client.ts +79 -0
- package/src/plugins/builtin/econ/fred-series-map.ts +88 -0
- package/src/plugins/builtin/econ/index.tsx +999 -0
- package/src/plugins/builtin/econ/types.ts +13 -0
- package/src/plugins/builtin/fred-settings.ts +10 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +178 -0
- package/src/plugins/builtin/fx-matrix/pairs.ts +30 -0
- package/src/plugins/builtin/help.test.tsx +1 -5
- package/src/plugins/builtin/help.tsx +1 -16
- package/src/plugins/builtin/insider/index.tsx +417 -0
- package/src/plugins/builtin/insider/insider-data.test.ts +55 -0
- package/src/plugins/builtin/insider/insider-data.ts +49 -0
- package/src/plugins/builtin/layout-manager.tsx +24 -16
- package/src/plugins/builtin/market-movers/index.tsx +573 -0
- package/src/plugins/builtin/market-movers/screener.test.ts +143 -0
- package/src/plugins/builtin/market-movers/screener.ts +105 -0
- package/src/plugins/builtin/options.tsx +4 -3
- package/src/plugins/builtin/portfolio-list/cli/commands.ts +11 -6
- package/src/plugins/builtin/portfolio-list/command-bar.ts +6 -3
- package/src/plugins/builtin/portfolio-list/header.tsx +3 -2
- package/src/plugins/builtin/portfolio-list/metrics.ts +22 -11
- package/src/plugins/builtin/portfolio-list/pane.tsx +3 -9
- package/src/plugins/builtin/portfolio-list/settings.ts +9 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -0
- package/src/plugins/builtin/portfolio-list.test.tsx +3 -1
- package/src/plugins/builtin/portfolio-metrics.test.ts +13 -1
- package/src/plugins/builtin/sec.tsx +114 -7
- package/src/plugins/builtin/sectors/index.tsx +359 -0
- package/src/plugins/builtin/sectors/sector-data.ts +18 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +75 -13
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +316 -80
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +4 -6
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +17 -12
- package/src/plugins/builtin/ticker-detail.test.tsx +3 -3
- package/src/plugins/builtin/world-indices/index.tsx +410 -0
- package/src/plugins/builtin/world-indices/indices.ts +52 -0
- package/src/plugins/builtin/yield-curve/index.tsx +242 -0
- package/src/plugins/builtin/yield-curve/treasury-data.test.ts +212 -0
- package/src/plugins/builtin/yield-curve/treasury-data.ts +107 -0
- package/src/plugins/catalog.ts +22 -0
- package/src/plugins/gridlock-notification.ts +15 -0
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +5 -5
- package/src/plugins/ibkr/index.test.tsx +1 -1
- package/src/plugins/ibkr/index.tsx +1 -1
- package/src/plugins/ibkr/trade-tab.tsx +23 -5
- package/src/plugins/ibkr/trade-utils.test.ts +1 -1
- package/src/plugins/ibkr/trade-utils.ts +7 -6
- package/src/plugins/ibkr/trading-pane.tsx +8 -7
- package/src/plugins/plugin-runtime.test.tsx +2 -0
- package/src/plugins/plugin-runtime.tsx +10 -0
- package/src/plugins/prediction-markets/controller-data.ts +8 -0
- package/src/plugins/prediction-markets/detail/shared.tsx +7 -6
- package/src/plugins/prediction-markets/plugin.test.tsx +48 -1
- package/src/plugins/prediction-markets/services/fetch.ts +13 -7
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +29 -11
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +20 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +2 -0
- package/src/plugins/registry.ts +22 -13
- package/src/sources/provider-router.test.ts +3 -2
- package/src/sources/sec-edgar.ts +13 -1
- package/src/sources/yahoo-finance.ts +75 -1
- package/src/state/app-context-selector.test.tsx +17 -1
- package/src/state/app-context.test.tsx +24 -0
- package/src/state/app-context.tsx +29 -6
- package/src/theme/colors.ts +5 -0
- package/src/theme/themes.ts +25 -0
- package/src/types/config.test.ts +107 -0
- package/src/types/config.ts +30 -1
- package/src/types/data-provider.ts +13 -0
- package/src/types/plugin.ts +35 -1
- package/src/utils/format.test.ts +11 -1
- package/src/utils/format.ts +86 -8
- package/src/utils/inline-content-tokenizer.test.ts +22 -0
- package/src/utils/inline-content-tokenizer.ts +76 -0
- package/src/utils/link-tokenizer.test.ts +27 -0
- package/src/utils/link-tokenizer.ts +93 -0
- package/src/utils/market-format.test.ts +109 -0
- package/src/utils/market-format.ts +299 -0
- package/src/utils/market-status.ts +3 -2
- package/src/utils/selection-clipboard.test.ts +43 -0
- package/src/utils/selection-clipboard.ts +88 -0
- package/src/utils/terminal-input-reset.test.ts +50 -0
- package/src/utils/terminal-input-reset.ts +24 -0
- package/src/utils/throttled-fetch.test.ts +145 -0
- package/src/utils/throttled-fetch.ts +212 -0
- package/src/utils/ticker-tokenizer.test.ts +31 -0
- package/src/utils/ticker-tokenizer.ts +7 -42
- package/src/version.ts +1 -1
|
@@ -2,8 +2,14 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import type { BoxRenderable, CliRenderer } from "@opentui/core";
|
|
3
3
|
import {
|
|
4
4
|
getLocalPlotPointer,
|
|
5
|
+
computeProjectedIndicatorOverlays,
|
|
5
6
|
projectCellCursorToLocalPixels,
|
|
7
|
+
resolveAutoDisplayState,
|
|
8
|
+
resolveAutoZoomWindow,
|
|
6
9
|
resolveAdjacentSelectionCursorX,
|
|
10
|
+
resolveChartKeyboardKey,
|
|
11
|
+
resolveIndicatorBufferRange,
|
|
12
|
+
resolveVisibleChartDateWindow,
|
|
7
13
|
resolveSelectionDisplayCursorState,
|
|
8
14
|
} from "./stock-chart";
|
|
9
15
|
import { getPointTerminalColumn } from "./chart-renderer";
|
|
@@ -21,6 +27,13 @@ const renderable = {
|
|
|
21
27
|
height: 12,
|
|
22
28
|
} as BoxRenderable;
|
|
23
29
|
|
|
30
|
+
function makeDailyHistory(startDay: number, length: number) {
|
|
31
|
+
return Array.from({ length }, (_, index) => ({
|
|
32
|
+
date: new Date(Date.UTC(2026, 0, startDay + index)),
|
|
33
|
+
close: 100 + index,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
describe("stock chart pointer helpers", () => {
|
|
25
38
|
test("returns both cell and pixel coordinates when pixel mouse is available", () => {
|
|
26
39
|
const pointer = getLocalPlotPointer({
|
|
@@ -105,3 +118,229 @@ describe("stock chart pointer helpers", () => {
|
|
|
105
118
|
expect(resolveAdjacentSelectionCursorX(previous, 1, pointCount, width, "candles")).toBe(rightmost);
|
|
106
119
|
});
|
|
107
120
|
});
|
|
121
|
+
|
|
122
|
+
describe("stock chart keyboard helpers", () => {
|
|
123
|
+
test("normalizes terminal zoom key variants", () => {
|
|
124
|
+
expect(resolveChartKeyboardKey({ sequence: "+" })).toBe("zoom-in");
|
|
125
|
+
expect(resolveChartKeyboardKey({ sequence: "=" })).toBe("zoom-in");
|
|
126
|
+
expect(resolveChartKeyboardKey({ name: "plus" })).toBe("zoom-in");
|
|
127
|
+
expect(resolveChartKeyboardKey({ sequence: "-" })).toBe("zoom-out");
|
|
128
|
+
expect(resolveChartKeyboardKey({ name: "minus" })).toBe("zoom-out");
|
|
129
|
+
expect(resolveChartKeyboardKey({ name: "A" })).toBe("a");
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("stock chart auto helpers", () => {
|
|
134
|
+
test("keeps planned auto data and the visible window in sync once fresh data is ready", () => {
|
|
135
|
+
const renderedAutoView = {
|
|
136
|
+
window: {
|
|
137
|
+
start: new Date("2026-01-01T00:00:00Z"),
|
|
138
|
+
end: new Date("2026-01-08T00:00:00Z"),
|
|
139
|
+
},
|
|
140
|
+
resolution: "1d" as const,
|
|
141
|
+
data: [{
|
|
142
|
+
date: new Date("2026-01-02T00:00:00Z"),
|
|
143
|
+
close: 101,
|
|
144
|
+
}],
|
|
145
|
+
};
|
|
146
|
+
const plannedBodyState = {
|
|
147
|
+
data: [{
|
|
148
|
+
date: new Date("2026-01-09T00:00:00Z"),
|
|
149
|
+
close: 102,
|
|
150
|
+
}],
|
|
151
|
+
blocking: false,
|
|
152
|
+
updating: false,
|
|
153
|
+
emptyMessage: null,
|
|
154
|
+
errorMessage: null,
|
|
155
|
+
};
|
|
156
|
+
const plannedWindow = {
|
|
157
|
+
start: new Date("2026-01-09T00:00:00Z"),
|
|
158
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const nextState = resolveAutoDisplayState({
|
|
162
|
+
shouldUseRenderedAutoView: false,
|
|
163
|
+
renderedAutoView,
|
|
164
|
+
isRenderedAutoViewUpdating: false,
|
|
165
|
+
plannedRenderBodyState: plannedBodyState,
|
|
166
|
+
plannedResolvedManualResolution: "1h",
|
|
167
|
+
plannedDateWindow: plannedWindow,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
expect(nextState.bodyState).toBe(plannedBodyState);
|
|
171
|
+
expect(nextState.resolution).toBe("1h");
|
|
172
|
+
expect(nextState.window).toEqual(plannedWindow);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("keeps showing the committed auto view while a replacement is still pending", () => {
|
|
176
|
+
const renderedAutoView = {
|
|
177
|
+
window: {
|
|
178
|
+
start: new Date("2026-01-01T00:00:00Z"),
|
|
179
|
+
end: new Date("2026-01-08T00:00:00Z"),
|
|
180
|
+
},
|
|
181
|
+
resolution: "1d" as const,
|
|
182
|
+
data: [{
|
|
183
|
+
date: new Date("2026-01-02T00:00:00Z"),
|
|
184
|
+
close: 101,
|
|
185
|
+
}],
|
|
186
|
+
};
|
|
187
|
+
const plannedBodyState = {
|
|
188
|
+
data: null,
|
|
189
|
+
blocking: true,
|
|
190
|
+
updating: false,
|
|
191
|
+
emptyMessage: null,
|
|
192
|
+
errorMessage: null,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const nextState = resolveAutoDisplayState({
|
|
196
|
+
shouldUseRenderedAutoView: true,
|
|
197
|
+
renderedAutoView,
|
|
198
|
+
isRenderedAutoViewUpdating: true,
|
|
199
|
+
plannedRenderBodyState: plannedBodyState,
|
|
200
|
+
plannedResolvedManualResolution: "1h",
|
|
201
|
+
plannedDateWindow: {
|
|
202
|
+
start: new Date("2026-01-09T00:00:00Z"),
|
|
203
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(nextState.bodyState).toEqual({
|
|
208
|
+
data: renderedAutoView.data,
|
|
209
|
+
blocking: false,
|
|
210
|
+
updating: true,
|
|
211
|
+
emptyMessage: null,
|
|
212
|
+
errorMessage: null,
|
|
213
|
+
});
|
|
214
|
+
expect(nextState.resolution).toBe("1d");
|
|
215
|
+
expect(nextState.window).toEqual(renderedAutoView.window);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("derives the visible label window from the actual visible chart points", () => {
|
|
219
|
+
const visibleWindow = resolveVisibleChartDateWindow([
|
|
220
|
+
{ date: new Date("2026-01-03T00:00:00Z") },
|
|
221
|
+
{ date: new Date("2026-01-06T00:00:00Z") },
|
|
222
|
+
], {
|
|
223
|
+
start: new Date("2026-01-01T00:00:00Z"),
|
|
224
|
+
end: new Date("2026-01-08T00:00:00Z"),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
expect(visibleWindow).toEqual({
|
|
228
|
+
start: new Date("2026-01-03T00:00:00Z"),
|
|
229
|
+
end: new Date("2026-01-06T00:00:00Z"),
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("zooms in by at least one visible point on every auto step when more detail is available", () => {
|
|
234
|
+
const history = makeDailyHistory(1, 10);
|
|
235
|
+
|
|
236
|
+
const nextWindow = resolveAutoZoomWindow({
|
|
237
|
+
historyPoints: history,
|
|
238
|
+
boundsDates: history.map((point) => point.date),
|
|
239
|
+
currentWindow: {
|
|
240
|
+
start: new Date("2026-01-06T00:00:00Z"),
|
|
241
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
242
|
+
},
|
|
243
|
+
direction: "in",
|
|
244
|
+
anchorRatio: 1,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
expect(nextWindow).toEqual({
|
|
248
|
+
start: new Date("2026-01-08T00:00:00Z"),
|
|
249
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test("zooms out into broader bounds data even when the current rendered history is already fully visible", () => {
|
|
254
|
+
const history = makeDailyHistory(8, 3);
|
|
255
|
+
const boundsDates = makeDailyHistory(1, 10).map((point) => point.date);
|
|
256
|
+
|
|
257
|
+
const nextWindow = resolveAutoZoomWindow({
|
|
258
|
+
historyPoints: history,
|
|
259
|
+
boundsDates,
|
|
260
|
+
currentWindow: {
|
|
261
|
+
start: new Date("2026-01-08T00:00:00Z"),
|
|
262
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
263
|
+
},
|
|
264
|
+
direction: "out",
|
|
265
|
+
anchorRatio: 1,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
expect(nextWindow).toEqual({
|
|
269
|
+
start: new Date("2026-01-06T00:00:00Z"),
|
|
270
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test("zooms out beyond the currently loaded bounds so auto can request a wider buffer", () => {
|
|
275
|
+
const history = makeDailyHistory(1, 10);
|
|
276
|
+
const boundsDates = history.map((point) => point.date);
|
|
277
|
+
|
|
278
|
+
const nextWindow = resolveAutoZoomWindow({
|
|
279
|
+
historyPoints: history,
|
|
280
|
+
boundsDates,
|
|
281
|
+
currentWindow: {
|
|
282
|
+
start: new Date("2026-01-01T00:00:00Z"),
|
|
283
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
284
|
+
},
|
|
285
|
+
direction: "out",
|
|
286
|
+
anchorRatio: 1,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
expect(nextWindow?.start?.getTime()).toBeLessThan(boundsDates[0]!.getTime());
|
|
290
|
+
expect(nextWindow).toEqual({
|
|
291
|
+
start: new Date("2025-12-27T00:00:00.000Z"),
|
|
292
|
+
end: new Date("2026-01-10T00:00:00.000Z"),
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test("keeps shrinking the auto time span once only two visible points remain", () => {
|
|
297
|
+
const history = makeDailyHistory(1, 10);
|
|
298
|
+
|
|
299
|
+
const nextWindow = resolveAutoZoomWindow({
|
|
300
|
+
historyPoints: history,
|
|
301
|
+
boundsDates: history.map((point) => point.date),
|
|
302
|
+
currentWindow: {
|
|
303
|
+
start: new Date("2026-01-09T00:00:00Z"),
|
|
304
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
305
|
+
},
|
|
306
|
+
direction: "in",
|
|
307
|
+
anchorRatio: 1,
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
expect(nextWindow).toEqual({
|
|
311
|
+
start: new Date("2026-01-09T08:00:00Z"),
|
|
312
|
+
end: new Date("2026-01-10T00:00:00Z"),
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
describe("stock chart indicator helpers", () => {
|
|
318
|
+
test("computes indicators from warmup history and reindexes them onto the visible projection", () => {
|
|
319
|
+
const source = makeDailyHistory(1, 30);
|
|
320
|
+
const projected = source.slice(20).map((point) => ({
|
|
321
|
+
date: point.date,
|
|
322
|
+
open: point.close,
|
|
323
|
+
high: point.close,
|
|
324
|
+
low: point.close,
|
|
325
|
+
close: point.close,
|
|
326
|
+
volume: 0,
|
|
327
|
+
}));
|
|
328
|
+
|
|
329
|
+
const overlays = computeProjectedIndicatorOverlays(source, projected, {
|
|
330
|
+
sma: [20],
|
|
331
|
+
bollinger: { period: 20, stdDev: 2 },
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
expect(overlays.smaLines[0]?.points).toHaveLength(projected.length);
|
|
335
|
+
expect(overlays.smaLines[0]?.points[0]?.index).toBe(0);
|
|
336
|
+
expect(overlays.smaLines[0]?.points.at(-1)?.index).toBe(projected.length - 1);
|
|
337
|
+
expect(overlays.bollinger?.upper[0]?.index).toBe(0);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
test("widens the data buffer enough for selected indicator warmup periods", () => {
|
|
341
|
+
expect(resolveIndicatorBufferRange("3M", "3M", { sma: [20] })).toBe("6M");
|
|
342
|
+
expect(resolveIndicatorBufferRange("3M", "6M", { sma: [20] })).toBe("6M");
|
|
343
|
+
expect(resolveIndicatorBufferRange("3M", "3M", { sma: [200] })).toBe("5Y");
|
|
344
|
+
expect(resolveIndicatorBufferRange("3M", "3M", {})).toBe("3M");
|
|
345
|
+
});
|
|
346
|
+
});
|