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.
Files changed (207) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/src/app.tsx +168 -65
  4. package/src/cli/commands/ticker.ts +45 -15
  5. package/src/cli/helpers.ts +4 -2
  6. package/src/cli/registry.test.ts +42 -35
  7. package/src/cli.test.ts +4 -2
  8. package/src/components/chart/chart-control-hint.tsx +39 -0
  9. package/src/components/chart/chart-controller.test.ts +110 -0
  10. package/src/components/chart/chart-controller.ts +364 -2
  11. package/src/components/chart/chart-data.ts +177 -29
  12. package/src/components/chart/chart-indicator-selector.tsx +53 -0
  13. package/src/components/chart/chart-pane-settings.ts +20 -0
  14. package/src/components/chart/chart-renderer.ts +220 -30
  15. package/src/components/chart/chart-resolution.test.ts +67 -0
  16. package/src/components/chart/chart-resolution.ts +74 -4
  17. package/src/components/chart/chart-scroll.test.ts +69 -0
  18. package/src/components/chart/chart-scroll.ts +104 -0
  19. package/src/components/chart/chart-types.ts +12 -0
  20. package/src/components/chart/chart-viewport.test.ts +5 -1
  21. package/src/components/chart/chart-viewport.ts +1 -1
  22. package/src/components/chart/chart.test.ts +249 -10
  23. package/src/components/chart/comparison-chart-renderer.test.ts +71 -1
  24. package/src/components/chart/comparison-chart-renderer.ts +40 -3
  25. package/src/components/chart/comparison-stock-chart.tsx +218 -123
  26. package/src/components/chart/indicators/bands.test.ts +50 -0
  27. package/src/components/chart/indicators/bands.ts +29 -0
  28. package/src/components/chart/indicators/moving-averages.test.ts +54 -0
  29. package/src/components/chart/indicators/moving-averages.ts +42 -0
  30. package/src/components/chart/indicators/options.test.ts +32 -0
  31. package/src/components/chart/indicators/options.ts +107 -0
  32. package/src/components/chart/indicators/oscillators.test.ts +79 -0
  33. package/src/components/chart/indicators/oscillators.ts +92 -0
  34. package/src/components/chart/indicators/types.ts +36 -0
  35. package/src/components/chart/native/chart-rasterizer.ts +51 -0
  36. package/src/components/chart/native/kitty.test.ts +68 -0
  37. package/src/components/chart/stock-chart-renderer-switch.test.tsx +740 -9
  38. package/src/components/chart/stock-chart.test.ts +239 -0
  39. package/src/components/chart/stock-chart.tsx +2257 -372
  40. package/src/components/command-bar/command-bar.test.tsx +337 -5
  41. package/src/components/command-bar/command-bar.tsx +292 -120
  42. package/src/components/command-bar/helpers.ts +1 -1
  43. package/src/components/command-bar/root-shortcuts.ts +33 -4
  44. package/src/components/command-bar/view-model.test.ts +3 -3
  45. package/src/components/command-bar/view-model.ts +4 -4
  46. package/src/components/command-bar/workflow-ops.ts +10 -0
  47. package/src/components/layout/header.tsx +2 -1
  48. package/src/components/layout/shell.test.tsx +186 -27
  49. package/src/components/layout/shell.tsx +5 -4
  50. package/src/components/layout/status-bar.test.tsx +16 -7
  51. package/src/components/layout/status-bar.tsx +4 -1
  52. package/src/components/markdown-editor.tsx +1 -0
  53. package/src/components/pane-settings-dialog.tsx +13 -152
  54. package/src/components/pane-template-wizard.tsx +1 -0
  55. package/src/components/price-selector-dialog.tsx +12 -7
  56. package/src/components/ticker-badge-text.test.tsx +50 -0
  57. package/src/components/ticker-badge-text.tsx +17 -2
  58. package/src/components/ticker-badge.tsx +2 -2
  59. package/src/components/ticker-list-table.tsx +54 -1
  60. package/src/components/toggle-list.tsx +15 -2
  61. package/src/components/ui/data-table.tsx +60 -3
  62. package/src/components/ui/external-link.tsx +48 -11
  63. package/src/components/ui/fields.tsx +2 -1
  64. package/src/components/ui/index.ts +8 -1
  65. package/src/components/ui/multi-select-chips.tsx +69 -0
  66. package/src/components/ui/multi-select-dialog.tsx +267 -0
  67. package/src/components/ui/multi-select.ts +78 -0
  68. package/src/components/ui/ui.test.tsx +343 -1
  69. package/src/data/plugin-state-store.ts +30 -19
  70. package/src/data/resource-store.ts +133 -103
  71. package/src/data/session-store.ts +19 -12
  72. package/src/data/sqlite-cache.test.ts +37 -2
  73. package/src/data/sqlite-database.ts +8 -2
  74. package/src/data/sqlite-retry.test.ts +63 -0
  75. package/src/data/sqlite-retry.ts +66 -0
  76. package/src/data/ticker-store.ts +29 -18
  77. package/src/index.tsx +6 -1
  78. package/src/market-data/coordinator.test.ts +114 -5
  79. package/src/market-data/coordinator.ts +70 -1
  80. package/src/market-data/hooks.test.tsx +73 -2
  81. package/src/market-data/hooks.tsx +16 -4
  82. package/src/notifications/app-notifier.test.ts +177 -0
  83. package/src/notifications/app-notifier.ts +241 -0
  84. package/src/pane-settings.test.ts +2 -0
  85. package/src/plugins/builtin/ai/index.test.tsx +1 -1
  86. package/src/plugins/builtin/ai/screener-pane.test.tsx +2 -0
  87. package/src/plugins/builtin/ai/screener-pane.tsx +1 -0
  88. package/src/plugins/builtin/ai/ticker-context.ts +3 -2
  89. package/src/plugins/builtin/alerts/alert-engine.test.ts +90 -0
  90. package/src/plugins/builtin/alerts/alert-engine.ts +55 -0
  91. package/src/plugins/builtin/alerts/index.test.tsx +357 -0
  92. package/src/plugins/builtin/alerts/index.tsx +519 -0
  93. package/src/plugins/builtin/alerts/types.ts +14 -0
  94. package/src/plugins/builtin/analytics/index.test.tsx +300 -0
  95. package/src/plugins/builtin/analytics/index.tsx +775 -0
  96. package/src/plugins/builtin/analytics/metrics.test.ts +125 -0
  97. package/src/plugins/builtin/analytics/metrics.ts +155 -0
  98. package/src/plugins/builtin/ask-ai.test.tsx +2 -0
  99. package/src/plugins/builtin/chat-controller.test.ts +62 -18
  100. package/src/plugins/builtin/chat-controller.ts +23 -12
  101. package/src/plugins/builtin/chat.test.tsx +715 -4
  102. package/src/plugins/builtin/chat.tsx +415 -119
  103. package/src/plugins/builtin/comparison-chart.test.tsx +97 -57
  104. package/src/plugins/builtin/comparison-chart.tsx +1 -2
  105. package/src/plugins/builtin/correlation/compute.test.ts +147 -0
  106. package/src/plugins/builtin/correlation/compute.ts +115 -0
  107. package/src/plugins/builtin/correlation/index.tsx +385 -0
  108. package/src/plugins/builtin/correlation/plugin.test.ts +44 -0
  109. package/src/plugins/builtin/correlation/settings.test.ts +34 -0
  110. package/src/plugins/builtin/correlation/settings.ts +95 -0
  111. package/src/plugins/builtin/debug.tsx +36 -50
  112. package/src/plugins/builtin/earnings/earnings-cache.test.ts +181 -0
  113. package/src/plugins/builtin/earnings/earnings-cache.ts +136 -0
  114. package/src/plugins/builtin/earnings/earnings-data.test.ts +59 -0
  115. package/src/plugins/builtin/earnings/earnings-data.ts +50 -0
  116. package/src/plugins/builtin/earnings/index.tsx +337 -0
  117. package/src/plugins/builtin/econ/calendar-source.test.ts +219 -0
  118. package/src/plugins/builtin/econ/calendar-source.ts +121 -0
  119. package/src/plugins/builtin/econ/fred-client.test.ts +63 -0
  120. package/src/plugins/builtin/econ/fred-client.ts +79 -0
  121. package/src/plugins/builtin/econ/fred-series-map.ts +88 -0
  122. package/src/plugins/builtin/econ/index.tsx +999 -0
  123. package/src/plugins/builtin/econ/types.ts +13 -0
  124. package/src/plugins/builtin/fred-settings.ts +10 -0
  125. package/src/plugins/builtin/fx-matrix/index.tsx +178 -0
  126. package/src/plugins/builtin/fx-matrix/pairs.ts +30 -0
  127. package/src/plugins/builtin/help.test.tsx +1 -5
  128. package/src/plugins/builtin/help.tsx +1 -16
  129. package/src/plugins/builtin/insider/index.tsx +417 -0
  130. package/src/plugins/builtin/insider/insider-data.test.ts +55 -0
  131. package/src/plugins/builtin/insider/insider-data.ts +49 -0
  132. package/src/plugins/builtin/layout-manager.tsx +24 -16
  133. package/src/plugins/builtin/market-movers/index.tsx +573 -0
  134. package/src/plugins/builtin/market-movers/screener.test.ts +143 -0
  135. package/src/plugins/builtin/market-movers/screener.ts +105 -0
  136. package/src/plugins/builtin/options.tsx +4 -3
  137. package/src/plugins/builtin/portfolio-list/cli/commands.ts +11 -6
  138. package/src/plugins/builtin/portfolio-list/command-bar.ts +6 -3
  139. package/src/plugins/builtin/portfolio-list/header.tsx +3 -2
  140. package/src/plugins/builtin/portfolio-list/metrics.ts +22 -11
  141. package/src/plugins/builtin/portfolio-list/pane.tsx +3 -9
  142. package/src/plugins/builtin/portfolio-list/settings.ts +9 -0
  143. package/src/plugins/builtin/portfolio-list/table.tsx +3 -0
  144. package/src/plugins/builtin/portfolio-list.test.tsx +3 -1
  145. package/src/plugins/builtin/portfolio-metrics.test.ts +13 -1
  146. package/src/plugins/builtin/sec.tsx +114 -7
  147. package/src/plugins/builtin/sectors/index.tsx +359 -0
  148. package/src/plugins/builtin/sectors/sector-data.ts +18 -0
  149. package/src/plugins/builtin/ticker-detail/chart-tab.tsx +75 -13
  150. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +316 -80
  151. package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +4 -6
  152. package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +17 -12
  153. package/src/plugins/builtin/ticker-detail.test.tsx +3 -3
  154. package/src/plugins/builtin/world-indices/index.tsx +410 -0
  155. package/src/plugins/builtin/world-indices/indices.ts +52 -0
  156. package/src/plugins/builtin/yield-curve/index.tsx +242 -0
  157. package/src/plugins/builtin/yield-curve/treasury-data.test.ts +212 -0
  158. package/src/plugins/builtin/yield-curve/treasury-data.ts +107 -0
  159. package/src/plugins/catalog.ts +22 -0
  160. package/src/plugins/gridlock-notification.ts +15 -0
  161. package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +5 -5
  162. package/src/plugins/ibkr/index.test.tsx +1 -1
  163. package/src/plugins/ibkr/index.tsx +1 -1
  164. package/src/plugins/ibkr/trade-tab.tsx +23 -5
  165. package/src/plugins/ibkr/trade-utils.test.ts +1 -1
  166. package/src/plugins/ibkr/trade-utils.ts +7 -6
  167. package/src/plugins/ibkr/trading-pane.tsx +8 -7
  168. package/src/plugins/plugin-runtime.test.tsx +2 -0
  169. package/src/plugins/plugin-runtime.tsx +10 -0
  170. package/src/plugins/prediction-markets/controller-data.ts +8 -0
  171. package/src/plugins/prediction-markets/detail/shared.tsx +7 -6
  172. package/src/plugins/prediction-markets/plugin.test.tsx +48 -1
  173. package/src/plugins/prediction-markets/services/fetch.ts +13 -7
  174. package/src/plugins/prediction-markets/services/polymarket-adapter.ts +29 -11
  175. package/src/plugins/prediction-markets/services/polymarket-ws.ts +20 -0
  176. package/src/plugins/prediction-markets/test-helpers.tsx +2 -0
  177. package/src/plugins/registry.ts +22 -13
  178. package/src/sources/provider-router.test.ts +3 -2
  179. package/src/sources/sec-edgar.ts +13 -1
  180. package/src/sources/yahoo-finance.ts +75 -1
  181. package/src/state/app-context-selector.test.tsx +17 -1
  182. package/src/state/app-context.test.tsx +24 -0
  183. package/src/state/app-context.tsx +29 -6
  184. package/src/theme/colors.ts +5 -0
  185. package/src/theme/themes.ts +25 -0
  186. package/src/types/config.test.ts +107 -0
  187. package/src/types/config.ts +30 -1
  188. package/src/types/data-provider.ts +13 -0
  189. package/src/types/plugin.ts +35 -1
  190. package/src/utils/format.test.ts +11 -1
  191. package/src/utils/format.ts +86 -8
  192. package/src/utils/inline-content-tokenizer.test.ts +22 -0
  193. package/src/utils/inline-content-tokenizer.ts +76 -0
  194. package/src/utils/link-tokenizer.test.ts +27 -0
  195. package/src/utils/link-tokenizer.ts +93 -0
  196. package/src/utils/market-format.test.ts +109 -0
  197. package/src/utils/market-format.ts +299 -0
  198. package/src/utils/market-status.ts +3 -2
  199. package/src/utils/selection-clipboard.test.ts +43 -0
  200. package/src/utils/selection-clipboard.ts +88 -0
  201. package/src/utils/terminal-input-reset.test.ts +50 -0
  202. package/src/utils/terminal-input-reset.ts +24 -0
  203. package/src/utils/throttled-fetch.test.ts +145 -0
  204. package/src/utils/throttled-fetch.ts +212 -0
  205. package/src/utils/ticker-tokenizer.test.ts +31 -0
  206. package/src/utils/ticker-tokenizer.ts +7 -42
  207. package/src/version.ts +1 -1
@@ -0,0 +1,300 @@
1
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2
+ import { act, useReducer, type ReactElement } from "react";
3
+ import { testRender } from "@opentui/react/test-utils";
4
+ import {
5
+ AppContext,
6
+ appReducer,
7
+ createInitialState,
8
+ PaneInstanceProvider,
9
+ } from "../../../state/app-context";
10
+ import { setSharedMarketDataCoordinator } from "../../../market-data/coordinator";
11
+ import { cloneLayout, createDefaultConfig, type AppConfig } from "../../../types/config";
12
+ import type { TickerFinancials } from "../../../types/financials";
13
+ import type { TickerRecord } from "../../../types/ticker";
14
+ import type { BrokerAccount } from "../../../types/trading";
15
+ import { analyticsPlugin } from "./index";
16
+
17
+ const TEST_PANE_ID = "analytics:test";
18
+ const BROKER_PORTFOLIO_ID = "broker:ibkr-flex:DU12345";
19
+
20
+ let testSetup: Awaited<ReturnType<typeof testRender>> | undefined;
21
+ let harnessState: ReturnType<typeof createInitialState> | null = null;
22
+
23
+ const AnalyticsPane = analyticsPlugin.panes![0]!.component as (props: {
24
+ paneId: string;
25
+ paneType: string;
26
+ focused: boolean;
27
+ width: number;
28
+ height: number;
29
+ }) => ReactElement;
30
+
31
+ function createAnalyticsConfig(initialPortfolioId: string): AppConfig {
32
+ const baseConfig = createDefaultConfig("/tmp/gloomberb-analytics");
33
+ const layout: AppConfig["layout"] = {
34
+ dockRoot: { kind: "pane", instanceId: TEST_PANE_ID },
35
+ instances: [{
36
+ instanceId: TEST_PANE_ID,
37
+ paneId: "analytics",
38
+ binding: { kind: "none" },
39
+ params: { portfolioId: initialPortfolioId },
40
+ }],
41
+ floating: [],
42
+ };
43
+
44
+ return {
45
+ ...baseConfig,
46
+ portfolios: [
47
+ { id: "main", name: "Main Portfolio", currency: "USD" },
48
+ {
49
+ id: BROKER_PORTFOLIO_ID,
50
+ name: "Flex DU12345",
51
+ currency: "USD",
52
+ brokerId: "ibkr",
53
+ brokerInstanceId: "ibkr-flex",
54
+ brokerAccountId: "DU12345",
55
+ },
56
+ ],
57
+ layout,
58
+ layouts: [{ name: "Default", layout: cloneLayout(layout) }],
59
+ };
60
+ }
61
+
62
+ function createSharedTicker(): TickerRecord {
63
+ return {
64
+ metadata: {
65
+ ticker: "AAPL",
66
+ exchange: "NASDAQ",
67
+ currency: "USD",
68
+ name: "Apple",
69
+ sector: "Technology",
70
+ portfolios: ["main", BROKER_PORTFOLIO_ID],
71
+ watchlists: [],
72
+ positions: [
73
+ {
74
+ portfolio: "main",
75
+ shares: 10,
76
+ avgCost: 100,
77
+ currency: "USD",
78
+ broker: "manual",
79
+ marketValue: 1200,
80
+ unrealizedPnl: 200,
81
+ },
82
+ {
83
+ portfolio: BROKER_PORTFOLIO_ID,
84
+ shares: 10,
85
+ avgCost: 100,
86
+ currency: "USD",
87
+ broker: "ibkr",
88
+ brokerInstanceId: "ibkr-flex",
89
+ brokerAccountId: "DU12345",
90
+ marketValue: 1250,
91
+ unrealizedPnl: 250,
92
+ },
93
+ ],
94
+ custom: {},
95
+ tags: [],
96
+ },
97
+ };
98
+ }
99
+
100
+ function createFinancials(price: number): TickerFinancials {
101
+ return {
102
+ annualStatements: [],
103
+ quarterlyStatements: [],
104
+ priceHistory: [],
105
+ quote: {
106
+ symbol: "AAPL",
107
+ price,
108
+ currency: "USD",
109
+ change: price - 130,
110
+ changePercent: ((price - 130) / 130) * 100,
111
+ previousClose: 130,
112
+ lastUpdated: Date.now(),
113
+ },
114
+ };
115
+ }
116
+
117
+ function AnalyticsHarness({
118
+ config,
119
+ brokerAccounts,
120
+ financials,
121
+ }: {
122
+ config: AppConfig;
123
+ brokerAccounts?: Record<string, BrokerAccount[]>;
124
+ financials?: TickerFinancials;
125
+ }) {
126
+ const initialState = createInitialState(config);
127
+ initialState.focusedPaneId = TEST_PANE_ID;
128
+ initialState.paneState[TEST_PANE_ID] = {
129
+ portfolioId: config.layout.instances[0]?.params?.portfolioId,
130
+ };
131
+ initialState.tickers = new Map([["AAPL", createSharedTicker()]]);
132
+ initialState.brokerAccounts = brokerAccounts ?? {};
133
+ if (financials) {
134
+ initialState.financials = new Map([["AAPL", financials]]);
135
+ }
136
+
137
+ const [state, dispatch] = useReducer(appReducer, initialState);
138
+ harnessState = state;
139
+
140
+ return (
141
+ <AppContext value={{ state, dispatch }}>
142
+ <PaneInstanceProvider paneId={TEST_PANE_ID}>
143
+ <AnalyticsPane
144
+ paneId={TEST_PANE_ID}
145
+ paneType="analytics"
146
+ focused
147
+ width={100}
148
+ height={24}
149
+ />
150
+ </PaneInstanceProvider>
151
+ </AppContext>
152
+ );
153
+ }
154
+
155
+ async function flushFrame() {
156
+ await act(async () => {
157
+ await testSetup!.renderOnce();
158
+ });
159
+ }
160
+
161
+ function expectBlankLineBetween(frame: string, beforeText: string, afterText: string) {
162
+ const lines = frame.split("\n");
163
+ const beforeRow = lines.findIndex((line) => line.includes(beforeText));
164
+ const afterRow = lines.findIndex((line) => line.includes(afterText));
165
+
166
+ expect(beforeRow).toBeGreaterThanOrEqual(0);
167
+ expect(afterRow).toBe(beforeRow + 2);
168
+ expect(lines[beforeRow + 1]?.trim()).toBe("");
169
+ }
170
+
171
+ beforeEach(() => {
172
+ setSharedMarketDataCoordinator(null);
173
+ });
174
+
175
+ afterEach(async () => {
176
+ if (testSetup) {
177
+ await act(async () => {
178
+ testSetup!.renderer.destroy();
179
+ });
180
+ testSetup = undefined;
181
+ }
182
+ harnessState = null;
183
+ setSharedMarketDataCoordinator(null);
184
+ });
185
+
186
+ describe("PortfolioAnalyticsPane", () => {
187
+ test("renders portfolio tabs and filters broker-managed positions to the active portfolio", async () => {
188
+ await act(async () => {
189
+ testSetup = await testRender(
190
+ <AnalyticsHarness config={createAnalyticsConfig(BROKER_PORTFOLIO_ID)} />,
191
+ { width: 100, height: 24 },
192
+ );
193
+ await Promise.resolve();
194
+ await testSetup.renderOnce();
195
+ });
196
+
197
+ await flushFrame();
198
+
199
+ const frame = testSetup!.captureCharFrame();
200
+ expect(frame).toContain("Main Portfolio");
201
+ expect(frame).toContain("Flex DU12345");
202
+ expect(frame).toContain("Val 1.3k");
203
+ expect(frame).toContain("P&L +250 (+25.00%)");
204
+ expect(frame).toContain("Risk / Return");
205
+ expect(frame).toContain("Sharpe Ratio");
206
+ expect(frame).toContain("Beta (SPY)");
207
+ expect(frame).toContain("SECTOR");
208
+ expectBlankLineBetween(frame, "Beta (SPY)", "Sector Allocation");
209
+ expect(frame).toContain("Technology");
210
+ expect(frame).toContain("100.0%");
211
+ expect(frame).not.toContain("2.5k");
212
+ });
213
+
214
+ test("switches portfolio tabs with the same arrow-key interaction as the portfolio pane", async () => {
215
+ await act(async () => {
216
+ testSetup = await testRender(
217
+ <AnalyticsHarness config={createAnalyticsConfig("main")} />,
218
+ { width: 100, height: 24 },
219
+ );
220
+ await Promise.resolve();
221
+ await testSetup.renderOnce();
222
+ });
223
+
224
+ await flushFrame();
225
+ expect(testSetup!.captureCharFrame()).toContain("Val 1.2k");
226
+
227
+ await act(async () => {
228
+ testSetup!.mockInput.pressArrow("right");
229
+ await testSetup!.renderOnce();
230
+ });
231
+ await flushFrame();
232
+
233
+ expect(harnessState?.paneState[TEST_PANE_ID]?.portfolioId).toBe(BROKER_PORTFOLIO_ID);
234
+ expect(testSetup!.captureCharFrame()).toContain("Val 1.3k");
235
+ });
236
+
237
+ test("shows broker cash and margin data when account data is available", async () => {
238
+ await act(async () => {
239
+ testSetup = await testRender(
240
+ <AnalyticsHarness
241
+ config={createAnalyticsConfig(BROKER_PORTFOLIO_ID)}
242
+ brokerAccounts={{
243
+ "ibkr-flex": [{
244
+ accountId: "DU12345",
245
+ name: "DU12345",
246
+ currency: "USD",
247
+ source: "flex",
248
+ updatedAt: new Date(2026, 2, 27).getTime(),
249
+ totalCashValue: -50000,
250
+ settledCash: -45000,
251
+ availableFunds: 15000,
252
+ excessLiquidity: 12000,
253
+ buyingPower: 30000,
254
+ netLiquidation: 125000,
255
+ cashBalances: [
256
+ { currency: "USD", quantity: -50000, baseValue: -50000, baseCurrency: "USD" },
257
+ ],
258
+ }],
259
+ }}
260
+ />,
261
+ { width: 100, height: 24 },
262
+ );
263
+ await Promise.resolve();
264
+ await testSetup.renderOnce();
265
+ });
266
+
267
+ await flushFrame();
268
+
269
+ const frame = testSetup!.captureCharFrame();
270
+ expect(frame).toContain("Net Liq 125k");
271
+ expect(frame).toContain("Cash -50k");
272
+ expect(frame).toContain("Settled -45k");
273
+ expect(frame).toContain("Avail 15k");
274
+ expect(frame).toContain("Excess 12k");
275
+ expect(frame).toContain("BP 30k");
276
+ expect(frame).toContain("Source Flex Mar 27");
277
+ });
278
+
279
+ test("uses the portfolio pane quote math for value, pnl, and return", async () => {
280
+ await act(async () => {
281
+ testSetup = await testRender(
282
+ <AnalyticsHarness
283
+ config={createAnalyticsConfig(BROKER_PORTFOLIO_ID)}
284
+ financials={createFinancials(140)}
285
+ />,
286
+ { width: 100, height: 24 },
287
+ );
288
+ await Promise.resolve();
289
+ await testSetup.renderOnce();
290
+ });
291
+
292
+ await flushFrame();
293
+
294
+ const frame = testSetup!.captureCharFrame();
295
+ expect(frame).toContain("Val 1.4k");
296
+ expect(frame).toContain("P&L +400 (+40.00%)");
297
+ expect(frame).toContain("Technology 100.0% 1.4k +400 +40.00%");
298
+ expect(frame).not.toContain("1.3k");
299
+ });
300
+ });