gloomberb 0.9.2 → 0.9.4
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 +24 -2
- package/bin/gloomberb +1 -1
- package/package.json +1 -1
- package/src/app/runtime/desktop-menu.ts +5 -1
- package/src/app/runtime/ticker-refresh.ts +4 -1
- package/src/app.tsx +20 -8
- package/src/brokers/account-cache.ts +1 -1
- package/src/brokers/sync-broker-instance.test.ts +107 -0
- package/src/brokers/sync-broker-instance.ts +22 -10
- package/src/capabilities/registry.ts +1 -0
- package/src/capabilities/types.ts +23 -0
- package/src/cli/commands/api.ts +119 -0
- package/src/cli/commands/automation.ts +173 -0
- package/src/cli/commands/command-utils.ts +53 -0
- package/src/cli/commands/market.ts +527 -0
- package/src/cli/commands/overview.ts +222 -0
- package/src/cli/commands/search.ts +39 -0
- package/src/cli/commands/system.ts +553 -0
- package/src/cli/commands/ticker.ts +104 -12
- package/src/cli/context.ts +35 -2
- package/src/cli/desktop-pane-shot.ts +2 -1
- package/src/cli/entry.ts +51 -0
- package/src/cli/errors.ts +56 -5
- package/src/cli/index.ts +73 -11
- package/src/cli/options.test.ts +38 -0
- package/src/cli/options.ts +95 -0
- package/src/cli/pane-functions/index.ts +10 -1
- package/src/cli/pane-functions/screenshot.ts +13 -1
- package/src/cli/registry.test.ts +40 -0
- package/src/cli/registry.ts +46 -5
- package/src/cli/result.test.ts +82 -0
- package/src/cli/result.ts +149 -0
- package/src/cli/types.ts +11 -0
- package/src/cli.test.ts +11 -11
- package/src/components/chart/bar-chart-renderer.test.ts +108 -3
- package/src/components/chart/bar-chart-renderer.ts +226 -27
- package/src/components/chart/comparison-stock-chart/interactions.ts +7 -1
- package/src/components/chart/comparison-stock-chart/legend.tsx +4 -0
- package/src/components/chart/comparison-stock-chart/render-data.ts +37 -8
- package/src/components/chart/comparison-stock-chart/selection-runtime.ts +19 -2
- package/src/components/chart/comparison-stock-chart/sources.ts +8 -4
- package/src/components/chart/comparison-stock-chart/toolbar.tsx +13 -3
- package/src/components/chart/comparison-stock-chart/view.tsx +12 -2
- package/src/components/chart/core/pane-settings.test.ts +27 -0
- package/src/components/chart/core/pane-settings.ts +60 -1
- package/src/components/chart/core/pointer.ts +34 -6
- package/src/components/chart/price-axis-labels.tsx +3 -1
- package/src/components/chart/static/bar-chart-surface.test.tsx +97 -0
- package/src/components/chart/static/bar-chart-surface.tsx +151 -28
- package/src/components/chart/static/chart/axis-overlays.tsx +243 -0
- package/src/components/chart/static/chart/surface.test.tsx +92 -0
- package/src/components/chart/static/chart/surface.tsx +167 -24
- package/src/components/chart/stock-chart/index.test.ts +25 -0
- package/src/components/chart/stock-chart/resolved/runtime.ts +1 -1
- package/src/components/chart/stock-chart/settings.ts +7 -3
- package/src/components/chart/stock-chart/viewport/runtime.ts +5 -5
- package/src/components/command-bar/layout-items/current-layout.ts +5 -1
- package/src/components/command-bar/pane-templates/workflow-route.ts +10 -0
- package/src/components/command-bar/surface/pane.test.tsx +76 -0
- package/src/components/data-table/view.tsx +13 -2
- package/src/components/feed-data-table/stack-view.tsx +9 -1
- package/src/components/index.ts +1 -1
- package/src/components/input-search-bar.test.tsx +103 -0
- package/src/components/input-search-bar.tsx +16 -0
- package/src/components/layout/detached-pane-shell.tsx +6 -3
- package/src/components/layout/floating-pane.tsx +3 -2
- package/src/components/layout/pane/content.tsx +20 -8
- package/src/components/layout/pane/footer/registration.tsx +6 -2
- package/src/components/layout/pane/frame.tsx +4 -4
- package/src/components/layout/pane/header.tsx +40 -4
- package/src/components/layout/pane/index.tsx +3 -1
- package/src/components/layout/pane/sizing.test.ts +43 -0
- package/src/components/layout/pane/sizing.ts +13 -4
- package/src/components/layout/shell/active-drag.ts +5 -1
- package/src/components/layout/shell/cursor-occlusion.ts +196 -0
- package/src/components/layout/shell/drag/runtime.ts +28 -3
- package/src/components/layout/shell/fullscreen.ts +10 -0
- package/src/components/layout/shell/index.test.tsx +487 -4
- package/src/components/layout/shell/index.tsx +165 -4
- package/src/components/layout/shell/layout-state.test.ts +33 -0
- package/src/components/layout/shell/layout-state.ts +4 -9
- package/src/components/layout/shell/native/pointer-runtime.ts +10 -4
- package/src/components/layout/shell/pane/layers.tsx +34 -16
- package/src/components/layout/shell/pane/management-shortcuts.ts +19 -0
- package/src/components/layout/shell/shortcuts.ts +4 -0
- package/src/components/layout/shell/terminal-pointer-runtime.ts +29 -19
- package/src/components/layout/shell/visible-layout.ts +17 -0
- package/src/components/layout/shell/window-mode/index.ts +11 -3
- package/src/components/layout/shell/window-mode/overlays.tsx +8 -1
- package/src/components/layout/status-bar.test.tsx +111 -1
- package/src/components/layout/status-bar.tsx +37 -7
- package/src/components/layout/transient-layout.tsx +57 -0
- package/src/components/layout/window-edit/mode.test.ts +76 -5
- package/src/components/layout/window-edit/mode.ts +47 -2
- package/src/components/layout/window-edit/presentation.ts +2 -1
- package/src/components/onboarding/onboarding-steps.tsx +8 -28
- package/src/components/onboarding/onboarding-wizard.test.tsx +13 -12
- package/src/components/onboarding/onboarding-wizard.tsx +2 -4
- package/src/components/onboarding/portfolio-step/index.tsx +0 -12
- package/src/components/onboarding/portfolio-step/types.ts +1 -3
- package/src/components/onboarding/wizard-keyboard.ts +2 -5
- package/src/components/price-performance.tsx +9 -1
- package/src/components/table-view-shared.tsx +12 -4
- package/src/components/ui/data-table/opentui/index.tsx +25 -12
- package/src/components/ui/data-table/types.ts +4 -0
- package/src/components/ui/fields.tsx +10 -3
- package/src/components/ui/page-stack-view.tsx +6 -2
- package/src/components/ui/table-layout.test.ts +25 -0
- package/src/components/ui/table-layout.ts +22 -6
- package/src/components/ui/tabs.tsx +26 -10
- package/src/components/ui/ui.test.tsx +87 -0
- package/src/core/app-services.ts +7 -4
- package/src/core/state/app/layout-reducer.ts +2 -2
- package/src/data/config/store/index.ts +1 -2
- package/src/plugins/builtin/analytics/index.test.tsx +6 -2
- package/src/plugins/builtin/analytics/pane-model.ts +43 -8
- package/src/plugins/builtin/cloud-tweets/pane.tsx +2 -0
- package/src/plugins/builtin/cloud-tweets/search-bar.tsx +3 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +14 -2
- package/src/plugins/builtin/comparison-chart/index.test.tsx +130 -6
- package/src/plugins/builtin/kelly-sizer/constants.ts +3 -0
- package/src/plugins/builtin/kelly-sizer/fields.ts +214 -0
- package/src/plugins/builtin/kelly-sizer/index.test.tsx +197 -0
- package/src/plugins/builtin/kelly-sizer/index.tsx +47 -0
- package/src/plugins/builtin/kelly-sizer/model.test.ts +152 -0
- package/src/plugins/builtin/kelly-sizer/model.ts +580 -0
- package/src/plugins/builtin/kelly-sizer/pane.tsx +558 -0
- package/src/plugins/builtin/kelly-sizer/portfolio.ts +71 -0
- package/src/plugins/builtin/kelly-sizer/sections.tsx +142 -0
- package/src/plugins/builtin/kelly-sizer/state.ts +67 -0
- package/src/plugins/builtin/kelly-sizer/test-support.tsx +174 -0
- package/src/plugins/builtin/kelly-sizer/types.ts +156 -0
- package/src/plugins/builtin/kelly-sizer/view.test.tsx +77 -0
- package/src/plugins/builtin/kelly-sizer/view.tsx +375 -0
- package/src/plugins/builtin/layout-manager/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/read-state.ts +9 -32
- package/src/plugins/builtin/options/view.test.tsx +141 -4
- package/src/plugins/builtin/options/view.tsx +76 -15
- package/src/plugins/builtin/portfolio-list/account-metrics.test.ts +26 -1
- package/src/plugins/builtin/portfolio-list/account-metrics.ts +14 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +23 -0
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +19 -2
- package/src/plugins/builtin/portfolio-list/index.test.ts +23 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +2 -7
- package/src/plugins/builtin/portfolio-list/summary/index.test.ts +59 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +36 -5
- package/src/plugins/builtin/shared/read-state.ts +43 -0
- package/src/plugins/builtin/substack/article-detail.test.tsx +10 -0
- package/src/plugins/builtin/substack/article-detail.tsx +39 -15
- package/src/plugins/builtin/substack/article-stack.tsx +6 -2
- package/src/plugins/builtin/substack/feed-tabs.tsx +12 -9
- package/src/plugins/builtin/substack/pane.tsx +8 -3
- package/src/plugins/builtin/substack/read-state.ts +55 -0
- package/src/plugins/builtin/thirteenf/pane.test.tsx +26 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +12 -1
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/content.tsx +149 -48
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/model.ts +25 -2
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph.tsx +5 -4
- package/src/plugins/builtin/ticker-detail/data-panes.test.ts +16 -0
- package/src/plugins/builtin/ticker-detail/index.test.tsx +143 -0
- package/src/plugins/catalog-ui.ts +2 -0
- package/src/plugins/ibkr/broker-adapter.ts +19 -0
- package/src/plugins/ibkr/config.test.ts +31 -2
- package/src/plugins/ibkr/config.ts +9 -2
- package/src/plugins/ibkr/flex/index.test.ts +18 -9
- package/src/plugins/ibkr/flex/index.ts +30 -0
- package/src/plugins/ibkr/flex/statement-client.ts +68 -14
- package/src/plugins/ibkr/gateway/account-loaders.ts +1 -1
- package/src/plugins/ibkr/gateway/account-summary.ts +1 -0
- package/src/plugins/ibkr/gateway/service/index.test.ts +8 -0
- package/src/plugins/pane-manager/docking.ts +9 -2
- package/src/plugins/pane-manager/gridlock.ts +13 -5
- package/src/plugins/pane-manager/layout-state.ts +25 -0
- package/src/plugins/pane-manager/queries.ts +8 -2
- package/src/plugins/pane-manager.test.ts +33 -0
- package/src/plugins/pane-manager.ts +6 -1
- package/src/plugins/prediction-markets/chart.tsx +10 -4
- package/src/plugins/prediction-markets/controller/index.ts +2 -0
- package/src/plugins/prediction-markets/controller/keyboard.ts +34 -5
- package/src/plugins/prediction-markets/detail/book.tsx +141 -96
- package/src/plugins/prediction-markets/detail/overview.tsx +3 -0
- package/src/plugins/prediction-markets/detail/pane.tsx +71 -64
- package/src/plugins/prediction-markets/detail/shared.tsx +19 -0
- package/src/plugins/prediction-markets/detail/trades.tsx +64 -19
- package/src/plugins/prediction-markets/detail.test.tsx +50 -0
- package/src/plugins/prediction-markets/pane.test.tsx +75 -0
- package/src/plugins/prediction-markets/pane.tsx +71 -23
- package/src/plugins/prediction-markets/test-helpers.tsx +42 -23
- package/src/renderers/electrobun/bun/application-menu/click.test.ts +9 -0
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.test.ts +9 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +3 -2
- package/src/renderers/electrobun/bun/index.ts +13 -0
- package/src/renderers/electrobun/bun/window/focus.test.ts +35 -0
- package/src/renderers/electrobun/bun/window/focus.ts +5 -0
- package/src/renderers/electrobun/view/app-services.ts +6 -4
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +13 -2
- package/src/renderers/electrobun/view/data-table/index.tsx +19 -4
- package/src/renderers/electrobun/view/data-table/row.tsx +30 -6
- package/src/renderers/electrobun/view/desktop/controls.tsx +11 -5
- package/src/renderers/electrobun/view/host/ascii-text.ts +50 -0
- package/src/renderers/electrobun/view/host/input.tsx +115 -18
- package/src/renderers/electrobun/view/host/tabs.tsx +7 -2
- package/src/renderers/electrobun/view/host/text.test.ts +22 -0
- package/src/renderers/electrobun/view/host/text.tsx +24 -20
- package/src/renderers/electrobun/view/styles.css +11 -0
- package/src/renderers/electrobun/view/ui-host.tsx +1 -1
- package/src/renderers/opentui/host.tsx +17 -1
- package/src/renderers/opentui/start.tsx +13 -5
- package/src/renderers/opentui/ui-host.tsx +57 -25
- package/src/sources/provider-router/batches.ts +16 -2
- package/src/sources/provider-router/financial-routes.ts +5 -0
- package/src/sources/provider-router/financials.ts +11 -23
- package/src/sources/provider-router/index.test.ts +189 -0
- package/src/sources/provider-router/primary.ts +3 -2
- package/src/sources/sec-edgar.test.ts +83 -0
- package/src/sources/sec-edgar.ts +231 -0
- package/src/sources/yahoo-finance.test.ts +51 -0
- package/src/sources/yahoo-finance.ts +49 -1
- package/src/state/app/context/index.test.tsx +5 -8
- package/src/state/app/input-capture.ts +12 -0
- package/src/types/broker.ts +1 -0
- package/src/types/config.ts +10 -0
- package/src/types/plugin.ts +28 -0
- package/src/types/trading.ts +2 -0
- package/src/ui/host.tsx +16 -0
- package/src/ui/index.tsx +2 -0
- package/src/utils/cli-output.ts +6 -0
- package/src/utils/financial-statements.ts +23 -0
- package/src/utils/search-focus-navigation.ts +24 -0
- package/src/version.ts +1 -1
- package/src/components/onboarding/portfolio-step/manual-name-panel.tsx +0 -62
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
buildBinaryOutcomes,
|
|
4
|
+
buildKellyCurvePoints,
|
|
5
|
+
buildSensitivityGrid,
|
|
6
|
+
calculateKellySizing,
|
|
7
|
+
solveKellyFraction,
|
|
8
|
+
type BinaryKellyAssumptions,
|
|
9
|
+
type PredictionMarketKellyAssumptions,
|
|
10
|
+
type ScenarioKellyAssumptions,
|
|
11
|
+
} from "./model";
|
|
12
|
+
|
|
13
|
+
function expectClose(actual: number, expected: number, precision = 4) {
|
|
14
|
+
expect(actual).toBeGreaterThan(expected - precision);
|
|
15
|
+
expect(actual).toBeLessThan(expected + precision);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe("kelly sizing model", () => {
|
|
19
|
+
test("solves classic even-money Kelly sizing", () => {
|
|
20
|
+
const result = solveKellyFraction(buildBinaryOutcomes(0.6, 1, -1));
|
|
21
|
+
expectClose(result.fraction, 0.2);
|
|
22
|
+
expectClose(result.expectedReturn, 0.2);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("clips fractional binary Kelly by max name and max loss caps", () => {
|
|
26
|
+
const draft: BinaryKellyAssumptions = {
|
|
27
|
+
winProbability: 0.57,
|
|
28
|
+
upsideReturn: 0.24,
|
|
29
|
+
downsideReturn: -0.09,
|
|
30
|
+
kellyFraction: 0.25,
|
|
31
|
+
maxNameFraction: 0.08,
|
|
32
|
+
maxLossFraction: 0.01,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const result = calculateKellySizing({
|
|
36
|
+
mode: "binary",
|
|
37
|
+
draft,
|
|
38
|
+
bankroll: 100_000,
|
|
39
|
+
currentValue: 4_000,
|
|
40
|
+
price: 200,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(result.fullKellyFraction).toBeGreaterThan(4);
|
|
44
|
+
expectClose(result.clippedFraction, 0.08);
|
|
45
|
+
expect(result.clipReasons).toContain("max name");
|
|
46
|
+
expectClose(result.targetValue, 8_000, 0.01);
|
|
47
|
+
expectClose(result.addTrimValue, 4_000, 0.01);
|
|
48
|
+
expectClose(result.estimatedUnits ?? 0, 20, 0.01);
|
|
49
|
+
expectClose(result.riskFraction, 0.0072, 0.0001);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("returns zero size when there is no positive edge", () => {
|
|
53
|
+
const draft: BinaryKellyAssumptions = {
|
|
54
|
+
winProbability: 0.45,
|
|
55
|
+
upsideReturn: 0.1,
|
|
56
|
+
downsideReturn: -0.1,
|
|
57
|
+
kellyFraction: 0.25,
|
|
58
|
+
maxNameFraction: 0.2,
|
|
59
|
+
maxLossFraction: 0.05,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const result = calculateKellySizing({
|
|
63
|
+
mode: "binary",
|
|
64
|
+
draft,
|
|
65
|
+
bankroll: 10_000,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(result.clippedFraction).toBe(0);
|
|
69
|
+
expect(result.warnings).toContain("No positive Kelly edge.");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("solves scenario trees numerically", () => {
|
|
73
|
+
const draft: ScenarioKellyAssumptions = {
|
|
74
|
+
outcomes: [
|
|
75
|
+
{ id: "loss", label: "Loss", probability: 0.4, returnPct: -1 },
|
|
76
|
+
{ id: "win", label: "Win", probability: 0.6, returnPct: 1 },
|
|
77
|
+
],
|
|
78
|
+
kellyFraction: 1,
|
|
79
|
+
maxNameFraction: 1,
|
|
80
|
+
maxLossFraction: 1,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const result = calculateKellySizing({
|
|
84
|
+
mode: "scenario",
|
|
85
|
+
draft,
|
|
86
|
+
bankroll: 1_000,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expectClose(result.fullKellyFraction, 0.2);
|
|
90
|
+
expectClose(result.clippedFraction, 0.2);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("uses risk budget size before Kelly when in risk budget mode", () => {
|
|
94
|
+
const result = calculateKellySizing({
|
|
95
|
+
mode: "risk-budget",
|
|
96
|
+
draft: {
|
|
97
|
+
riskBudgetFraction: 0.01,
|
|
98
|
+
downsideReturn: -0.1,
|
|
99
|
+
winProbability: 0.6,
|
|
100
|
+
upsideReturn: 0.2,
|
|
101
|
+
kellyFraction: 0.25,
|
|
102
|
+
maxNameFraction: 1,
|
|
103
|
+
maxLossFraction: 1,
|
|
104
|
+
},
|
|
105
|
+
bankroll: 50_000,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expectClose(result.unclippedFraction, 0.1);
|
|
109
|
+
expectClose(result.clippedFraction, 0.1);
|
|
110
|
+
expectClose(result.riskValue, 500);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("sizes prediction market yes contracts from probability and price", () => {
|
|
114
|
+
const draft: PredictionMarketKellyAssumptions = {
|
|
115
|
+
estimatedProbability: 0.57,
|
|
116
|
+
marketPrice: 0.48,
|
|
117
|
+
side: "yes",
|
|
118
|
+
kellyFraction: 1,
|
|
119
|
+
maxNameFraction: 1,
|
|
120
|
+
maxLossFraction: 1,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const result = calculateKellySizing({
|
|
124
|
+
mode: "prediction-market",
|
|
125
|
+
draft,
|
|
126
|
+
bankroll: 1_000,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
expectClose(result.fullKellyFraction, 0.173076, 0.0001);
|
|
130
|
+
expectClose(result.clippedFraction, 0.173076, 0.0001);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("builds sensitivity grid and Kelly curve data", () => {
|
|
134
|
+
const draft: BinaryKellyAssumptions = {
|
|
135
|
+
winProbability: 0.57,
|
|
136
|
+
upsideReturn: 0.24,
|
|
137
|
+
downsideReturn: -0.09,
|
|
138
|
+
kellyFraction: 0.25,
|
|
139
|
+
maxNameFraction: 0.08,
|
|
140
|
+
maxLossFraction: 0.01,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const grid = buildSensitivityGrid("binary", draft);
|
|
144
|
+
expect(grid.rows).toHaveLength(3);
|
|
145
|
+
expect(grid.columns).toHaveLength(3);
|
|
146
|
+
expect(grid.cells[1]?.[1]?.text).toBe("8.00%");
|
|
147
|
+
|
|
148
|
+
const points = buildKellyCurvePoints("binary", draft);
|
|
149
|
+
expect(points.length).toBeGreaterThan(10);
|
|
150
|
+
expect(points[0]?.close).toBe(0);
|
|
151
|
+
});
|
|
152
|
+
});
|