@lumencharts/trading-platform 0.0.0-stage → 0.1.1
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/CHANGELOG.md +31 -0
- package/LICENSE +55 -0
- package/README.md +53 -2
- package/dist/asset-entry.d.ts +3 -0
- package/dist/asset.d.ts +3 -0
- package/dist/asset.js +21689 -0
- package/dist/chart/bracket-links.d.ts +8 -0
- package/dist/chart/context-actions.d.ts +7 -0
- package/dist/chart/edit-presentation.d.ts +32 -0
- package/dist/chart/edit-preview.d.ts +26 -0
- package/dist/chart/exit-profit.d.ts +32 -0
- package/dist/chart/frame-batch.d.ts +15 -0
- package/dist/chart/overlay-coordinator.d.ts +18 -0
- package/dist/chart/overlay-events.d.ts +3 -0
- package/dist/chart/overlay-gesture.d.ts +40 -0
- package/dist/chart/overlay-index.d.ts +30 -0
- package/dist/chart/overlay-projection.d.ts +51 -0
- package/dist/chart/overlay-types.d.ts +42 -0
- package/dist/chart/parent-links.d.ts +33 -0
- package/dist/chart/position-profit.d.ts +15 -0
- package/dist/chart/review-lock.d.ts +14 -0
- package/dist/chart/ticket-projection.d.ts +36 -0
- package/dist/compat/default-formatters.d.ts +6 -0
- package/dist/compat/delegate.d.ts +11 -0
- package/dist/compat/factory.d.ts +5 -0
- package/dist/compat/formatters.d.ts +26 -0
- package/dist/compat/host-dialogs.d.ts +5 -0
- package/dist/compat/host-preferences.d.ts +8 -0
- package/dist/compat/host.d.ts +39 -0
- package/dist/compat/watched-value.d.ts +25 -0
- package/dist/conformance/index.d.ts +78 -0
- package/dist/conformance/index.js +6859 -0
- package/dist/conformance/replay.d.ts +35 -0
- package/dist/contracts/broker.d.ts +1122 -0
- package/dist/contracts/broker.js +168 -0
- package/dist/contracts/index.d.ts +3 -0
- package/dist/contracts/index.js +168 -0
- package/dist/contracts/market-data.d.ts +289 -0
- package/dist/contracts/market-data.js +11 -0
- package/dist/contracts/ports.d.ts +469 -0
- package/dist/contracts/ports.js +5 -0
- package/dist/core/account-datasets.d.ts +29 -0
- package/dist/core/account-lifecycle.d.ts +70 -0
- package/dist/core/account-types.d.ts +6 -0
- package/dist/core/bounded-map.d.ts +12 -0
- package/dist/core/bracket-input.d.ts +32 -0
- package/dist/core/bracket-modification.d.ts +6 -0
- package/dist/core/bracket-parent.d.ts +11 -0
- package/dist/core/broker-debug.d.ts +10 -0
- package/dist/core/capabilities.d.ts +34 -0
- package/dist/core/capability-metadata.d.ts +60 -0
- package/dist/core/capability-policy.d.ts +32 -0
- package/dist/core/chart-exit-level.d.ts +11 -0
- package/dist/core/chart-order-edit.d.ts +50 -0
- package/dist/core/clock.d.ts +2 -0
- package/dist/core/close-commands.d.ts +24 -0
- package/dist/core/close-flow.d.ts +14 -0
- package/dist/core/command-context.d.ts +16 -0
- package/dist/core/command-coordinator.d.ts +71 -0
- package/dist/core/command-follow.d.ts +32 -0
- package/dist/core/command-keys.d.ts +11 -0
- package/dist/core/context-orders.d.ts +19 -0
- package/dist/core/deferred.d.ts +5 -0
- package/dist/core/dialog-coordinator.d.ts +73 -0
- package/dist/core/display-preferences.d.ts +10 -0
- package/dist/core/disposal.d.ts +8 -0
- package/dist/core/entity-store.d.ts +56 -0
- package/dist/core/entity-validation.d.ts +9 -0
- package/dist/core/errors.d.ts +24 -0
- package/dist/core/execution-demand.d.ts +11 -0
- package/dist/core/execution-sound.d.ts +10 -0
- package/dist/core/exit-level-draft.d.ts +9 -0
- package/dist/core/exit-level-summary.d.ts +3 -0
- package/dist/core/exit-level-template.d.ts +16 -0
- package/dist/core/features.d.ts +39 -0
- package/dist/core/financial-rules.d.ts +70 -0
- package/dist/core/history-limit.d.ts +11 -0
- package/dist/core/identity.d.ts +14 -0
- package/dist/core/immutable.d.ts +8 -0
- package/dist/core/keyed-ref-count.d.ts +18 -0
- package/dist/core/leverage-commands.d.ts +42 -0
- package/dist/core/modification-context.d.ts +22 -0
- package/dist/core/modification-routing.d.ts +43 -0
- package/dist/core/notification-log.d.ts +33 -0
- package/dist/core/number-precision.d.ts +4 -0
- package/dist/core/order-commands.d.ts +50 -0
- package/dist/core/order-duration.d.ts +14 -0
- package/dist/core/order-labels.d.ts +7 -0
- package/dist/core/order-matching.d.ts +16 -0
- package/dist/core/order-modification.d.ts +20 -0
- package/dist/core/order-notifications.d.ts +30 -0
- package/dist/core/order-protection.d.ts +4 -0
- package/dist/core/parent-protection.d.ts +10 -0
- package/dist/core/position-commands.d.ts +45 -0
- package/dist/core/position-custom-fields.d.ts +5 -0
- package/dist/core/position-estimates.d.ts +22 -0
- package/dist/core/position-protection-permissions.d.ts +4 -0
- package/dist/core/preferences-key.d.ts +2 -0
- package/dist/core/preview-leases.d.ts +12 -0
- package/dist/core/protection-legs.d.ts +23 -0
- package/dist/core/protection-notifications.d.ts +9 -0
- package/dist/core/protection-rules.d.ts +21 -0
- package/dist/core/quantity-input.d.ts +53 -0
- package/dist/core/read-coordinator.d.ts +15 -0
- package/dist/core/readers.d.ts +6 -0
- package/dist/core/relative-price.d.ts +4 -0
- package/dist/core/review-policy.d.ts +17 -0
- package/dist/core/session-types.d.ts +1 -0
- package/dist/core/session.d.ts +114 -0
- package/dist/core/snapshot-dataset.d.ts +47 -0
- package/dist/core/symbol-catalog.d.ts +37 -0
- package/dist/core/tradability.d.ts +26 -0
- package/dist/core/trading-commands.d.ts +104 -0
- package/dist/core/trading-rules.d.ts +14 -0
- package/dist/core/trading-settings.d.ts +39 -0
- package/dist/core/trading-state.d.ts +52 -0
- package/dist/core/value-store.d.ts +11 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +6593 -0
- package/dist/market-data/depth-book.d.ts +18 -0
- package/dist/market-data/index.d.ts +3 -0
- package/dist/market-data/index.js +735 -0
- package/dist/market-data/session-demand.d.ts +15 -0
- package/dist/market-data/subscriptions.d.ts +13 -0
- package/dist/mock/broker.d.ts +75 -0
- package/dist/mock/clock.d.ts +12 -0
- package/dist/mock/feeds.d.ts +18 -0
- package/dist/mock/index.d.ts +5 -0
- package/dist/mock/index.js +1956 -0
- package/dist/mock/protection-cancellation.d.ts +7 -0
- package/dist/mock/scenarios.d.ts +5 -0
- package/dist/paper/broker.d.ts +41 -0
- package/dist/paper/index.d.ts +6 -0
- package/dist/paper/index.js +469 -0
- package/dist/paper/market.d.ts +57 -0
- package/dist/paper/rules.d.ts +40 -0
- package/dist/ui/account-manager/account-pages.d.ts +18 -0
- package/dist/ui/account-manager/column-presentation.d.ts +5 -0
- package/dist/ui/account-manager/context-menu.d.ts +13 -0
- package/dist/ui/account-manager/csv-downloads.d.ts +5 -0
- package/dist/ui/account-manager/custom-page.d.ts +16 -0
- package/dist/ui/account-manager/custom-table.d.ts +18 -0
- package/dist/ui/account-manager/format-account-value.d.ts +12 -0
- package/dist/ui/account-manager/position-reader.d.ts +19 -0
- package/dist/ui/account-manager/row-action-tracker.d.ts +12 -0
- package/dist/ui/account-manager/row-actions.d.ts +37 -0
- package/dist/ui/account-manager/status-counts.d.ts +6 -0
- package/dist/ui/account-manager/table-controls.d.ts +13 -0
- package/dist/ui/account-manager/table-export.d.ts +30 -0
- package/dist/ui/account-manager/table-model.d.ts +11 -0
- package/dist/ui/account-manager/table-toolbar.d.ts +25 -0
- package/dist/ui/account-manager/table.d.ts +24 -0
- package/dist/ui/account-manager/view.d.ts +19 -0
- package/dist/ui/account-manager/workspace.d.ts +15 -0
- package/dist/ui/chart-actions.d.ts +11 -0
- package/dist/ui/chart-controls/eligibility.d.ts +6 -0
- package/dist/ui/chart-controls/quote-buttons.d.ts +15 -0
- package/dist/ui/chart-controls/quote-controls.d.ts +12 -0
- package/dist/ui/chart-controls/quote-widths.d.ts +8 -0
- package/dist/ui/dialogs/close-amount-form.d.ts +8 -0
- package/dist/ui/dialogs/close-preview-dialog.d.ts +5 -0
- package/dist/ui/dialogs/confirm-dialog.d.ts +7 -0
- package/dist/ui/dialogs/dialog-body.d.ts +11 -0
- package/dist/ui/dialogs/leverage-form.d.ts +10 -0
- package/dist/ui/dialogs/message-dialog.d.ts +6 -0
- package/dist/ui/dialogs/position-protection.d.ts +14 -0
- package/dist/ui/dialogs/properties-dialog.d.ts +9 -0
- package/dist/ui/dialogs/sanitize-html.d.ts +2 -0
- package/dist/ui/dialogs/types.d.ts +5 -0
- package/dist/ui/dialogs/view.d.ts +5 -0
- package/dist/ui/dock-sizes.d.ts +20 -0
- package/dist/ui/dom/controller.d.ts +34 -0
- package/dist/ui/dom/ladder.d.ts +23 -0
- package/dist/ui/dom/view.d.ts +8 -0
- package/dist/ui/dom/workspace.d.ts +17 -0
- package/dist/ui/effective-mode.d.ts +11 -0
- package/dist/ui/financial-lease.d.ts +3 -0
- package/dist/ui/icons.d.ts +4 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +15918 -0
- package/dist/ui/layout.d.ts +5 -0
- package/dist/ui/mount.d.ts +11 -0
- package/dist/ui/notifications/log.d.ts +6 -0
- package/dist/ui/notifications/toasts.d.ts +5 -0
- package/dist/ui/number-input.d.ts +2 -0
- package/dist/ui/order-ticket/chart-draft-controls.d.ts +8 -0
- package/dist/ui/order-ticket/chart-projection.d.ts +9 -0
- package/dist/ui/order-ticket/controller.d.ts +41 -0
- package/dist/ui/order-ticket/custom-field.d.ts +9 -0
- package/dist/ui/order-ticket/duration-input.d.ts +9 -0
- package/dist/ui/order-ticket/exit-input.d.ts +34 -0
- package/dist/ui/order-ticket/financial-controls.d.ts +10 -0
- package/dist/ui/order-ticket/layout-context.d.ts +7 -0
- package/dist/ui/order-ticket/market.d.ts +12 -0
- package/dist/ui/order-ticket/menu.d.ts +6 -0
- package/dist/ui/order-ticket/mode-rules.d.ts +4 -0
- package/dist/ui/order-ticket/modification-fields.d.ts +23 -0
- package/dist/ui/order-ticket/move-handle.d.ts +4 -0
- package/dist/ui/order-ticket/order-sent.d.ts +4 -0
- package/dist/ui/order-ticket/placement.d.ts +27 -0
- package/dist/ui/order-ticket/preview-message.d.ts +4 -0
- package/dist/ui/order-ticket/price-input.d.ts +14 -0
- package/dist/ui/order-ticket/quantity-input.d.ts +26 -0
- package/dist/ui/order-ticket/review-panel.d.ts +10 -0
- package/dist/ui/order-ticket/rules.d.ts +16 -0
- package/dist/ui/order-ticket/stop-input.d.ts +17 -0
- package/dist/ui/order-ticket/submit-bar.d.ts +13 -0
- package/dist/ui/order-ticket/symbol-search-controller.d.ts +50 -0
- package/dist/ui/order-ticket/symbol-search.d.ts +12 -0
- package/dist/ui/order-ticket/untradable-notice.d.ts +8 -0
- package/dist/ui/order-ticket/view.d.ts +16 -0
- package/dist/ui/panel-visibility.d.ts +6 -0
- package/dist/ui/pointer-drag.d.ts +20 -0
- package/dist/ui/popup-mount.d.ts +4 -0
- package/dist/ui/primitives.d.ts +29 -0
- package/dist/ui/protection/editor.d.ts +18 -0
- package/dist/ui/protection/fields.d.ts +30 -0
- package/dist/ui/protection/level.d.ts +14 -0
- package/dist/ui/protection/protected-size.d.ts +5 -0
- package/dist/ui/protection/ticket-workspace.d.ts +7 -0
- package/dist/ui/resize-handle.css +34 -0
- package/dist/ui/resize-handle.d.ts +20 -0
- package/dist/ui/resize-handle.js +185 -0
- package/dist/ui/select.d.ts +26 -0
- package/dist/ui/surface-theme.d.ts +3 -0
- package/dist/ui/switch.d.ts +7 -0
- package/dist/ui/symbol-logo.d.ts +7 -0
- package/dist/ui/tabs.d.ts +19 -0
- package/dist/ui/ticket-dock.d.ts +18 -0
- package/dist/ui/ticket-shell.d.ts +15 -0
- package/dist/ui/trading.css +1808 -0
- package/dist/ui/trap-tab.d.ts +11 -0
- package/dist/vendor/solid-ui/index.d.ts +3 -0
- package/dist/vendor/solid-ui/paged-list-window.d.ts +27 -0
- package/dist/vendor/solid-ui/virtual-list.d.ts +21 -0
- package/package.json +104 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Order } from "../contracts/broker.js";
|
|
2
|
+
/** Retains orphan links so a later parent arrival touches only its own children. */
|
|
3
|
+
export declare function createBracketLinks(): {
|
|
4
|
+
update(id: string, order?: Readonly<Order>): void;
|
|
5
|
+
parentOf(childId: string): string | undefined;
|
|
6
|
+
children(parentKey: string): readonly string[];
|
|
7
|
+
clear(): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Side } from "../contracts/broker.js";
|
|
2
|
+
import type { ActionMetaInfo, InstrumentInfo } from "../contracts/broker.js";
|
|
3
|
+
import type { TradingChartBinding, TradingContextAction } from "../contracts/ports.js";
|
|
4
|
+
import type { TradingSession } from "../core/session.js";
|
|
5
|
+
export declare function createContextActions(session: TradingSession, instrumentFor: (symbol: string) => InstrumentInfo | undefined, onError: (cause: unknown) => void): (target: TradingChartBinding, price?: number, source?: "pane" | "priceScale") => Promise<readonly TradingContextAction[]>;
|
|
6
|
+
/** Map broker-owned actions without running their callbacks during projection. */
|
|
7
|
+
export declare function mapContextActions(actions: readonly ActionMetaInfo[], tradeItem: (side: Side) => TradingContextAction): TradingContextAction[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TradingChartBinding, ReadonlyValue, TradingOverlayHandle, TradingOverlayPatch, TradingProtectionView } from "../contracts/ports.js";
|
|
2
|
+
import type { ChartOrderEdit } from "../core/chart-order-edit.js";
|
|
3
|
+
import { type EditPreviewPoint } from "./edit-preview.js";
|
|
4
|
+
import type { OverlayEntityKind, Projection } from "./overlay-projection.js";
|
|
5
|
+
import type { Overlay, Owner } from "./overlay-types.js";
|
|
6
|
+
import { type ReviewLock } from "./review-lock.js";
|
|
7
|
+
export interface EditPresentationHost {
|
|
8
|
+
/** The session's single unsent chart edit. */
|
|
9
|
+
readonly edits: ReadonlyValue<Readonly<ChartOrderEdit> | undefined>;
|
|
10
|
+
readonly owners: ReadonlyMap<string, Owner>;
|
|
11
|
+
readonly ownerKey: (binding: TradingChartBinding) => string;
|
|
12
|
+
/** Overlay keys painted with an edit group: the group's own key and its child exits. */
|
|
13
|
+
readonly groupKeys: (group: string) => readonly string[];
|
|
14
|
+
readonly keyFor: (kind: OverlayEntityKind, id: string) => string;
|
|
15
|
+
readonly updateOverlay: (handle: TradingOverlayHandle, patch: TradingOverlayPatch) => void;
|
|
16
|
+
readonly updateProtectionPreview: (owner: Owner, overlay: Overlay, point: EditPreviewPoint, gestureId?: string) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* How the session's unsent edit shows on the chart: which overlay displays it, the review lock that mutes its
|
|
20
|
+
* group once the user released it, and repainting the group when the edit changes or ends.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createEditPresentation(host: EditPresentationHost): {
|
|
23
|
+
lockFor: (owner: Owner, projection: Projection) => ReviewLock | undefined;
|
|
24
|
+
shownProtection: (owner: Owner, projection: Projection, preview?: TradingProtectionView) => TradingProtectionView | undefined;
|
|
25
|
+
releaseEdit: (edit: Readonly<ChartOrderEdit>, point: EditPreviewPoint | undefined) => void;
|
|
26
|
+
refreshPreview: () => void;
|
|
27
|
+
/** Symbol of the chart showing the edit, if any. */
|
|
28
|
+
symbol: () => string | undefined;
|
|
29
|
+
/** Runs `begin` with the edit displayed on `key` (a dragged child exit shows its parent's edit). */
|
|
30
|
+
displayOn<T>(key: string, begin: () => T): T;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { InstrumentInfo, Side } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingProtectionLeg, TradingProtectionView } from "../contracts/ports.js";
|
|
3
|
+
import type { ChartOrderEdit } from "../core/chart-order-edit.js";
|
|
4
|
+
/** A proposed price for one protection leg, or for the entry line when `leg` is omitted. */
|
|
5
|
+
export interface EditPreviewPoint {
|
|
6
|
+
readonly price: number;
|
|
7
|
+
readonly leg?: TradingProtectionLeg;
|
|
8
|
+
}
|
|
9
|
+
/** Where a saved (reviewing or sending) proposal sits: its proposed exit, or the moved order entry. */
|
|
10
|
+
export declare function proposedEditPoint(edit: Readonly<ChartOrderEdit>): EditPreviewPoint | undefined;
|
|
11
|
+
export interface EditPreviewInput {
|
|
12
|
+
readonly edit: Readonly<ChartOrderEdit>;
|
|
13
|
+
/** Protection the line is projected with (handles, entry, moving leg for exit lines). */
|
|
14
|
+
readonly protection: TradingProtectionView | undefined;
|
|
15
|
+
readonly point: EditPreviewPoint;
|
|
16
|
+
readonly instrument: InstrumentInfo;
|
|
17
|
+
/** Price a position's exits must sit around (its current closing price); orders use their entry. */
|
|
18
|
+
readonly reference?: number;
|
|
19
|
+
/** Estimated result text of closing `qty` of `side` exposure from `entry` at `exit`. */
|
|
20
|
+
readonly profitText: (side: Side, qty: number, entry: number | undefined, exit: number) => string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Protection shown while a TP/SL (or an exit line itself) is dragged or reviewed: the moving leg's price,
|
|
24
|
+
* amount, quantity and whether the price is on the profitable/protective side of entry.
|
|
25
|
+
*/
|
|
26
|
+
export declare function editPreviewProtection(input: EditPreviewInput): TradingProtectionView | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { InstrumentInfo, PipValues } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingDisplaySettings } from "../contracts/ports.js";
|
|
3
|
+
import type { ProtectionField } from "../core/protection-legs.js";
|
|
4
|
+
/** Instruments whose pip differs from the minimum tick count in pips; everything else counts ticks. */
|
|
5
|
+
export declare function profitTickUnit(instrument: Pick<InstrumentInfo, "pipSize" | "minTick">): "pips" | "ticks";
|
|
6
|
+
export interface ExitProfitInput {
|
|
7
|
+
readonly instrument: InstrumentInfo | undefined;
|
|
8
|
+
/** Side of the exposure the exit closes, not the side of the exit order. */
|
|
9
|
+
readonly side: number;
|
|
10
|
+
readonly qty: number;
|
|
11
|
+
readonly entry: number | undefined;
|
|
12
|
+
readonly exit: number;
|
|
13
|
+
readonly display: TradingDisplaySettings;
|
|
14
|
+
readonly pipValues?: PipValues;
|
|
15
|
+
/** `positionPLInInstrumentCurrency`: money stays in the instrument currency. */
|
|
16
|
+
readonly inInstrumentCurrency: boolean;
|
|
17
|
+
readonly accountCurrency?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Estimated result of closing at an exit price, as chart pill text; undefined when it cannot be shown. */
|
|
20
|
+
export declare function exitProfitText(input: ExitProfitInput): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Hover text for a confirmed exit line, as in the reference terminal: its distance from entry in profit terms
|
|
23
|
+
* (percent, then ticks or pips) and its price. Undefined without an entry or a valid tick.
|
|
24
|
+
*/
|
|
25
|
+
export declare function exitTooltip(input: {
|
|
26
|
+
readonly field: ProtectionField;
|
|
27
|
+
/** Side of the exposure the exit closes. */
|
|
28
|
+
readonly side: number;
|
|
29
|
+
readonly entry: number | undefined;
|
|
30
|
+
readonly exit: number;
|
|
31
|
+
readonly instrument: Pick<InstrumentInfo, "pipSize" | "minTick"> | undefined;
|
|
32
|
+
}): string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Runs a callback on the next presentation frame; returns a cancel function. */
|
|
2
|
+
export type FrameScheduler = (callback: () => void) => () => void;
|
|
3
|
+
/** Runs work at once: the default for headless consumers and deterministic tests. */
|
|
4
|
+
export declare const immediateFrames: FrameScheduler;
|
|
5
|
+
/** Browser animation frames when available; otherwise immediate. */
|
|
6
|
+
export declare function animationFrames(): FrameScheduler;
|
|
7
|
+
/**
|
|
8
|
+
* Collapses bursts of keyed work into one flush per frame. A key queued several times in one frame flushes once;
|
|
9
|
+
* `take` lets a synchronous owner do the work now and drop the queued copy.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createFrameBatch<V>(schedule: FrameScheduler, flush: (values: readonly V[]) => void): {
|
|
12
|
+
queue(key: string, value: V): void;
|
|
13
|
+
take(key: string): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReadonlyValue } from "../contracts/ports.js";
|
|
2
|
+
import type { OverlayAction } from "./overlay-types.js";
|
|
3
|
+
import { type FrameScheduler } from "./frame-batch.js";
|
|
4
|
+
import type { TradingCollectionPort } from "../contracts/ports.js";
|
|
5
|
+
import type { TradingSession } from "../core/session.js";
|
|
6
|
+
export type { OverlayAction } from "./overlay-types.js";
|
|
7
|
+
/** Converts immutable broker state into chart-owned transient overlays; never owns geometry or pointer capture. */
|
|
8
|
+
export declare function createOverlayCoordinator(session: TradingSession, collection: TradingCollectionPort, onAction: (action: OverlayAction) => void | Promise<unknown>, onError?: (error: unknown) => void,
|
|
9
|
+
/** Narrow viewport; with adaptive trading lines, position lines drop their TP/SL button and P&L text. */
|
|
10
|
+
narrow?: ReadonlyValue<boolean>,
|
|
11
|
+
/** Quote-driven re-projection (P&L text, market-parent exits) waits for this frame; immediate by default. */
|
|
12
|
+
frames?: FrameScheduler,
|
|
13
|
+
/** Work-count probes for tests; never part of the presentation contract. */
|
|
14
|
+
probes?: {
|
|
15
|
+
readonly financialSync?: () => void;
|
|
16
|
+
}): {
|
|
17
|
+
destroy(): void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { InstrumentInfo, Side } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingOverlayEvent, TradingOverlayHandle, TradingOverlayPatch, TradingProtectionLeg, TradingProtectionView } from "../contracts/ports.js";
|
|
3
|
+
import type { ChartOrderEdit } from "../core/chart-order-edit.js";
|
|
4
|
+
import type { TradingSession } from "../core/session.js";
|
|
5
|
+
import { type EditPreviewPoint } from "./edit-preview.js";
|
|
6
|
+
import type { OverlayEntityKind, Projection } from "./overlay-projection.js";
|
|
7
|
+
import type { Overlay, OverlayAction, Owner } from "./overlay-types.js";
|
|
8
|
+
import type { createParentLinks } from "./parent-links.js";
|
|
9
|
+
import { type ReviewLock } from "./review-lock.js";
|
|
10
|
+
/** What a chart gesture needs from its coordinator; everything is passed explicitly, there is no event bus. */
|
|
11
|
+
export interface GestureHost {
|
|
12
|
+
readonly session: TradingSession;
|
|
13
|
+
readonly onAction: (action: OverlayAction) => void | Promise<unknown>;
|
|
14
|
+
readonly onError: (error: unknown) => void;
|
|
15
|
+
readonly safely: (work: () => void) => void;
|
|
16
|
+
readonly instrument: (symbol: string) => InstrumentInfo | undefined;
|
|
17
|
+
readonly exitText: (symbol: string, side: Side, qty: number, entry: number | undefined, exit: number, currency?: string) => string;
|
|
18
|
+
readonly currentAccountCurrency: () => string | undefined;
|
|
19
|
+
readonly lockFor: (owner: Owner, projection: Projection) => ReviewLock | undefined;
|
|
20
|
+
readonly shownProtection: (owner: Owner, projection: Projection, preview?: TradingProtectionView) => TradingProtectionView | undefined;
|
|
21
|
+
readonly releaseEdit: (edit: Readonly<ChartOrderEdit>, point: EditPreviewPoint | undefined) => void;
|
|
22
|
+
readonly displayOn: <T>(key: string, begin: () => T) => T;
|
|
23
|
+
readonly updateOverlay: (handle: TradingOverlayHandle, patch: TradingOverlayPatch) => void;
|
|
24
|
+
readonly multipleExitLevels: (symbol: string) => boolean;
|
|
25
|
+
readonly pipFinanceNeeded: (symbol: string) => boolean;
|
|
26
|
+
readonly completedParent: ReturnType<typeof createParentLinks>["completedParent"];
|
|
27
|
+
readonly confirmedExitParent: (overlay: Overlay, kind: OverlayEntityKind, id: string) => ReturnType<ReturnType<typeof createParentLinks>["confirmedExitParent"]>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One semantic owner per chart gesture: drag start opens the edit (and its pip lease), previews are pure
|
|
31
|
+
* maths, commit dispatches one action or ends the gesture, and cancel paths restore the broker presentation.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createOverlayGestures(host: GestureHost): {
|
|
34
|
+
gestureEligible: (projection: Projection, leg: TradingProtectionLeg | undefined) => boolean;
|
|
35
|
+
updateProtectionPreview: (owner: Owner, overlay: Overlay, point: EditPreviewPoint, gestureId?: string) => void;
|
|
36
|
+
restoreProjection: (owner: Owner, overlay: Overlay) => void;
|
|
37
|
+
endGesture: (owner: Owner, overlay: Overlay) => void;
|
|
38
|
+
cancelGesture: (owner: Owner, overlay: Overlay) => void;
|
|
39
|
+
handler: (owner: Owner, overlay: Overlay, key: string, isCurrent: () => boolean) => (input: TradingOverlayEvent) => void;
|
|
40
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Order } from "../contracts/broker.js";
|
|
2
|
+
import type { OverlayEntityKind, Projection } from "./overlay-projection.js";
|
|
3
|
+
/**
|
|
4
|
+
* Symbol-keyed indexes over the current projections, so quote, pip and finance work stays proportional to the
|
|
5
|
+
* affected symbol: projections by symbol, the symbol each key was last indexed under, exit orders and position
|
|
6
|
+
* counts per symbol, and waiting market parents per symbol. Pure; owns no subscriptions.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OverlayIndex {
|
|
9
|
+
private readonly bySymbol;
|
|
10
|
+
private readonly previousSymbol;
|
|
11
|
+
private readonly exitsBySymbol;
|
|
12
|
+
private readonly positionCounts;
|
|
13
|
+
private readonly marketParentsBySymbol;
|
|
14
|
+
private readonly marketParentSymbol;
|
|
15
|
+
/** Records the projection for `key` (or its removal) and returns the symbol it was indexed under before. */
|
|
16
|
+
set(kind: OverlayEntityKind, id: string, key: string, projection: Projection | undefined): string | undefined;
|
|
17
|
+
/** Projections currently indexed for a symbol, keyed by overlay key. */
|
|
18
|
+
projections(symbol: string): ReadonlyMap<string, Projection>;
|
|
19
|
+
/** IDs of an entity kind still indexed, including ones whose entity has since gone. */
|
|
20
|
+
indexedIds(kind: OverlayEntityKind): string[];
|
|
21
|
+
exitIds(symbol: string): ReadonlySet<string>;
|
|
22
|
+
hasExits(symbol: string): boolean;
|
|
23
|
+
hasPositions(symbol: string): boolean;
|
|
24
|
+
/** Tracks orders that are waiting market orders: their exits follow the quote. */
|
|
25
|
+
indexMarketParent(id: string, order: Readonly<Order> | undefined): void;
|
|
26
|
+
marketParents(symbol: string): ReadonlySet<string>;
|
|
27
|
+
clearMarketParents(): void;
|
|
28
|
+
clear(): void;
|
|
29
|
+
private countPosition;
|
|
30
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Execution, IndividualPosition, Order, Position } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingOverlayPatch, TradingOverlaySpec } from "../contracts/ports.js";
|
|
3
|
+
import type { CapabilityFlags } from "../core/capabilities.js";
|
|
4
|
+
import type { TradingFeatures } from "../core/features.js";
|
|
5
|
+
import type { ProtectionField } from "../core/protection-legs.js";
|
|
6
|
+
export type OverlayEntityKind = "order" | "position" | "individualPosition" | "execution";
|
|
7
|
+
/** The one spelling of an overlay key (`kind:id`): command kinds share their coordinator lock key. */
|
|
8
|
+
export declare function overlayKey(kind: OverlayEntityKind, id: string): string;
|
|
9
|
+
export interface Projection {
|
|
10
|
+
readonly parentRevision?: number;
|
|
11
|
+
readonly kind: OverlayEntityKind;
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly revision: number;
|
|
14
|
+
readonly spec: TradingOverlaySpec;
|
|
15
|
+
}
|
|
16
|
+
export interface OverlayProjectionContext {
|
|
17
|
+
readonly visible: boolean;
|
|
18
|
+
readonly multiple?: boolean;
|
|
19
|
+
readonly ready: boolean;
|
|
20
|
+
readonly compact: boolean;
|
|
21
|
+
readonly flags: CapabilityFlags;
|
|
22
|
+
readonly features: TradingFeatures;
|
|
23
|
+
readonly parentRevision?: number;
|
|
24
|
+
readonly parentEntryPrice?: number;
|
|
25
|
+
/** TP/SL legs a position's active child orders already provide, for brokers that report them only as children. */
|
|
26
|
+
readonly childLegs?: ReadonlySet<ProtectionField>;
|
|
27
|
+
readonly bracketText?: string;
|
|
28
|
+
/** Hover text of a confirmed exit line; its label when absent. */
|
|
29
|
+
readonly bracketTooltip?: string;
|
|
30
|
+
readonly parentAvailable: (order: Readonly<Order>) => boolean;
|
|
31
|
+
readonly positionProtectionEditable?: (kind: "position" | "individualPosition", symbol: string) => boolean;
|
|
32
|
+
readonly protectionEditable?: (order: Readonly<Order>) => boolean;
|
|
33
|
+
readonly priceEditable: (order: Readonly<Order>) => boolean;
|
|
34
|
+
readonly reversible: (symbol: string) => boolean;
|
|
35
|
+
/** "Reverse position button" setting; the broker policy still decides whether reversing is possible. */
|
|
36
|
+
readonly reverseButton?: boolean;
|
|
37
|
+
/** "Execution labels" setting: marks keep their arrow and drop the Bought/Sold text when off. */
|
|
38
|
+
readonly executionLabels?: boolean;
|
|
39
|
+
readonly profitTone?: (kind: "position" | "individualPosition", id: string, position: Readonly<Position | IndividualPosition>) => "positive" | "negative" | "neutral";
|
|
40
|
+
readonly profitLabel: (kind: "position" | "individualPosition", id: string, position: Readonly<Position | IndividualPosition>) => string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** "Positions and orders" and "Execution marks" settings; bracket exits are orders. */
|
|
43
|
+
export declare function overlayKindVisible(kind: OverlayEntityKind, display: {
|
|
44
|
+
readonly showPositions: boolean;
|
|
45
|
+
readonly showOrders: boolean;
|
|
46
|
+
readonly showExecutions: boolean;
|
|
47
|
+
}): boolean;
|
|
48
|
+
/** State-to-spec mapping with explicit policy and formatting inputs; no session or chart effects. */
|
|
49
|
+
export declare function projectOverlay(kind: OverlayEntityKind, value: Readonly<Order | Position | IndividualPosition | Execution> | undefined, revision: number, context: OverlayProjectionContext): Projection | undefined;
|
|
50
|
+
/** Patch for the spec fields that changed; a field that changed to undefined is sent as an explicit undefined. */
|
|
51
|
+
export declare function overlaySpecPatch(old: TradingOverlaySpec, next: TradingOverlaySpec): TradingOverlayPatch;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TradingChartBinding, TradingChartPort, TradingOverlayEvent, TradingOverlayHandle, TradingProtectionLeg, TradingProtectionView } from "../contracts/ports.js";
|
|
2
|
+
import type { DisposalScope } from "../core/disposal.js";
|
|
3
|
+
import type { OverlayEntityKind, Projection } from "./overlay-projection.js";
|
|
4
|
+
export interface OverlayAction {
|
|
5
|
+
readonly binding: TradingChartBinding;
|
|
6
|
+
readonly entityId: string;
|
|
7
|
+
readonly kind: OverlayEntityKind;
|
|
8
|
+
readonly revision: number;
|
|
9
|
+
readonly event: TradingOverlayEvent;
|
|
10
|
+
}
|
|
11
|
+
/** One chart overlay and the state of its active gesture. */
|
|
12
|
+
export interface Overlay {
|
|
13
|
+
readonly handle: TradingOverlayHandle;
|
|
14
|
+
readonly scope: DisposalScope;
|
|
15
|
+
projection: Projection;
|
|
16
|
+
proposedProtection?: TradingProtectionView;
|
|
17
|
+
gestureRevision?: number;
|
|
18
|
+
editToken?: number;
|
|
19
|
+
gestureId?: string;
|
|
20
|
+
/** The protection leg the active gesture drags; undefined for a body move. */
|
|
21
|
+
gestureLeg?: TradingProtectionLeg;
|
|
22
|
+
releaseFinance?: () => void;
|
|
23
|
+
moneyCurrency?: string;
|
|
24
|
+
previewEvent?: Extract<TradingOverlayEvent, {
|
|
25
|
+
gestureId: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** A confirmed exit dragged by its body edits its parent's protection leg instead of the exit order. */
|
|
28
|
+
parentEdit?: {
|
|
29
|
+
readonly kind: "order" | "position" | "individualPosition";
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly leg: TradingProtectionLeg;
|
|
32
|
+
/** Broker level of an allocated exit; that level's leg moves instead of a new level being added. */
|
|
33
|
+
readonly level?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** One chart's overlays. */
|
|
37
|
+
export interface Owner {
|
|
38
|
+
readonly chart: TradingChartPort;
|
|
39
|
+
readonly binding: TradingChartBinding;
|
|
40
|
+
readonly overlays: Map<string, Overlay>;
|
|
41
|
+
readonly scope: DisposalScope;
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IndividualPosition, Order, Position, TradingQuotes } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingOverlaySpec } from "../contracts/ports.js";
|
|
3
|
+
import type { EntityReader } from "../core/entity-store.js";
|
|
4
|
+
import { type ProtectionField } from "../core/protection-legs.js";
|
|
5
|
+
import type { createBracketLinks } from "./bracket-links.js";
|
|
6
|
+
import type { OverlayEntityKind } from "./overlay-projection.js";
|
|
7
|
+
type ParentKind = "order" | "position" | "individualPosition";
|
|
8
|
+
export interface ParentLinkSources {
|
|
9
|
+
readonly stores: {
|
|
10
|
+
readonly order: EntityReader<Order>;
|
|
11
|
+
readonly position: EntityReader<Position>;
|
|
12
|
+
readonly individualPosition: EntityReader<IndividualPosition>;
|
|
13
|
+
};
|
|
14
|
+
readonly quotes: Pick<EntityReader<TradingQuotes & {
|
|
15
|
+
id: string;
|
|
16
|
+
}>, "get">;
|
|
17
|
+
readonly links: ReturnType<typeof createBracketLinks>;
|
|
18
|
+
readonly keyFor: (kind: OverlayEntityKind, id: string) => string;
|
|
19
|
+
}
|
|
20
|
+
/** Parent/child exit relationships as chart overlays read them; pure over the given stores and links. */
|
|
21
|
+
export declare function createParentLinks({ stores, quotes, links, keyFor }: ParentLinkSources): {
|
|
22
|
+
completedParent: (kind: ParentKind, id: string) => Readonly<import("../contracts/broker.js").PlacedOrder> | Readonly<Position> | Readonly<IndividualPosition> | undefined;
|
|
23
|
+
confirmedExitParent: (spec: Pick<TradingOverlaySpec, "kind" | "protection">, kind: OverlayEntityKind, id: string) => {
|
|
24
|
+
level?: string | undefined;
|
|
25
|
+
kind: import("../core/command-keys.js").CommandEntityKind;
|
|
26
|
+
id: string;
|
|
27
|
+
leg: import("../contracts/ports.js").TradingProtectionLeg;
|
|
28
|
+
completed: Readonly<import("../contracts/broker.js").PlacedOrder> | Readonly<Position> | Readonly<IndividualPosition> | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
exitEntryPrice: (kind: ParentKind, parent: Readonly<Order | Position | IndividualPosition>) => number | undefined;
|
|
31
|
+
childLegs: (parentKey: string) => ReadonlySet<ProtectionField>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TradingSession } from "../core/session.js";
|
|
2
|
+
type PositionKind = "position" | "individualPosition";
|
|
3
|
+
/** Owns chart profit display and demand, independently of broker-defined table columns. */
|
|
4
|
+
export declare function createChartPositionProfit(session: TradingSession, changed: (kind: PositionKind, id: string) => void, symbolChanged: (symbol: string) => void, onError: (cause: unknown) => void): {
|
|
5
|
+
label: (kind: PositionKind, id: string, position: {
|
|
6
|
+
readonly symbol: string;
|
|
7
|
+
readonly extra?: Record<string, unknown>;
|
|
8
|
+
}) => string | undefined;
|
|
9
|
+
tone(kind: PositionKind, id: string, position: {
|
|
10
|
+
readonly extra?: Record<string, unknown>;
|
|
11
|
+
}): "positive" | "negative" | "neutral";
|
|
12
|
+
synchronize: (symbols: readonly string[], withPositions: readonly string[]) => void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TradingOverlayAction, TradingProtectionLeg, TradingProtectionView } from "../contracts/ports.js";
|
|
2
|
+
/** A released proposal locks its protection group while the ticket owns the edit. */
|
|
3
|
+
export interface ReviewLock {
|
|
4
|
+
/** Overlay showing the proposal. */
|
|
5
|
+
readonly reviewedKey: string;
|
|
6
|
+
/** TP/SL leg under review; undefined for an entry price review. */
|
|
7
|
+
readonly leg?: TradingProtectionLeg;
|
|
8
|
+
}
|
|
9
|
+
/** Protection reviews lock every group member. Entry reviews only lock sibling lines. */
|
|
10
|
+
export declare function reviewLineLocked(key: string, lock: ReviewLock | undefined): boolean;
|
|
11
|
+
/** Protection a line shows during a review; unchanged outside it. */
|
|
12
|
+
export declare function reviewProtection(key: string, protection: TradingProtectionView, lock: ReviewLock | undefined): TradingProtectionView;
|
|
13
|
+
/** A locked line keeps its actions except chart modify, which also owns dragging. */
|
|
14
|
+
export declare function reviewActions(key: string, actions: readonly TradingOverlayAction[], lock: ReviewLock | undefined): readonly TradingOverlayAction[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PreOrder } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingOverlaySpec, TradingProtectionLeg } from "../contracts/ports.js";
|
|
3
|
+
/** What a projected exit line edits: a TP/SL leg (optionally of one allocated level) or the stop-limit trigger. */
|
|
4
|
+
export interface TicketLineTarget {
|
|
5
|
+
readonly leg?: TradingProtectionLeg;
|
|
6
|
+
readonly level?: string;
|
|
7
|
+
readonly trigger?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface TicketProjectionInput {
|
|
10
|
+
readonly order: Readonly<PreOrder>;
|
|
11
|
+
/** Projected entry: the order price, or the executable quote for market orders. */
|
|
12
|
+
readonly entry: number;
|
|
13
|
+
/** User can still change the draft (ticket editing or showing an error). */
|
|
14
|
+
readonly editable: boolean;
|
|
15
|
+
/** Ticket is reviewing or sending: lines show as pending instead of draft. */
|
|
16
|
+
readonly pending: boolean;
|
|
17
|
+
/** Leg dragged out of the entry line; its standalone line is hidden until the gesture ends. */
|
|
18
|
+
readonly activeLeg?: TradingProtectionLeg;
|
|
19
|
+
readonly flags: {
|
|
20
|
+
readonly supportOrderBrackets: boolean;
|
|
21
|
+
readonly supportMarketBrackets: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** Estimated result text for an exit at `exit` closing `qty`; undefined when unavailable. */
|
|
24
|
+
readonly profitText: (exit: number, qty: number) => string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export interface TicketLine {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly target: TicketLineTarget;
|
|
29
|
+
readonly spec: TradingOverlaySpec;
|
|
30
|
+
}
|
|
31
|
+
export interface TicketProjection {
|
|
32
|
+
readonly entry: TradingOverlaySpec;
|
|
33
|
+
readonly lines: readonly TicketLine[];
|
|
34
|
+
}
|
|
35
|
+
/** Unsent ticket draft as chart overlay specs; pure, so drafts never become broker rows. */
|
|
36
|
+
export declare function projectTicketOverlays(input: TicketProjectionInput): TicketProjection;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { INumberFormatter, IPriceFormatter } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingFormatterPort, TradingSymbolContext } from "../contracts/ports.js";
|
|
3
|
+
export declare function createNumericFormatter(locale: string, decimalPlaces?: number, trim?: boolean): INumberFormatter;
|
|
4
|
+
export declare function createPriceFormatter(locale: string, priceScale?: number, minMove?: number, fractional?: boolean, minMove2?: number, variableMinTick?: string, align?: boolean): IPriceFormatter;
|
|
5
|
+
/** Standalone fallback; provider/broker custom formatters retain precedence in the session. */
|
|
6
|
+
export declare function createDefaultTradingFormatters(locale: string, symbolContext: (symbol: string) => Promise<TradingSymbolContext>): TradingFormatterPort;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDelegate } from '../contracts/broker.js';
|
|
2
|
+
/** Matches subscriptions by both receiver and function; fires a stable subscription snapshot. */
|
|
3
|
+
export declare class Delegate<T extends Function> implements IDelegate<T> {
|
|
4
|
+
private readonly listeners;
|
|
5
|
+
private disposed;
|
|
6
|
+
readonly fire: T;
|
|
7
|
+
subscribe(owner: object | null, callback: T, singleshot?: boolean): void;
|
|
8
|
+
unsubscribe(owner: object | null, callback: T): void;
|
|
9
|
+
unsubscribeAll(owner: object | null): void;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IBrokerConnectionAdapterFactory } from '../contracts/broker.js';
|
|
2
|
+
import type { TradingFormatterPort } from '../contracts/ports.js';
|
|
3
|
+
import { DisposalScope } from '../core/disposal.js';
|
|
4
|
+
/** Every utility created for the broker belongs to this session's lifetime. */
|
|
5
|
+
export declare function createHostFactory(formatters: TradingFormatterPort, scope: DisposalScope): IBrokerConnectionAdapterFactory;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StandardFormatterName } from '../contracts/broker.js';
|
|
2
|
+
import type { FieldRef, INumberFormatter } from '../contracts/broker.js';
|
|
3
|
+
export interface FormattedCell {
|
|
4
|
+
readonly text: string;
|
|
5
|
+
readonly tone?: 'positive' | 'negative' | 'warning';
|
|
6
|
+
readonly superscriptLast?: boolean; /** Broker message for the cell, e.g. the Symbol formatter's withMessage dependency. */
|
|
7
|
+
readonly message?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TableFormatContext {
|
|
10
|
+
readonly numeric: INumberFormatter;
|
|
11
|
+
readonly integer: INumberFormatter;
|
|
12
|
+
readonly variable: INumberFormatter;
|
|
13
|
+
readonly quantity: INumberFormatter;
|
|
14
|
+
readonly price: INumberFormatter;
|
|
15
|
+
readonly accountCurrency?: string;
|
|
16
|
+
readonly instrumentType?: string;
|
|
17
|
+
readonly locale: string;
|
|
18
|
+
readonly timezone: string;
|
|
19
|
+
readonly exitLevelLeg?: 'takeProfit' | 'stopLoss';
|
|
20
|
+
/** prefer_symbol_name_over_fullname: show `name` rather than `exchange:name`. */
|
|
21
|
+
readonly preferSymbolName?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function fieldValue(row: unknown, reference: FieldRef): unknown;
|
|
24
|
+
export declare function columnValues(row: unknown, fields: readonly FieldRef[]): unknown[];
|
|
25
|
+
/** Structured cell output keeps broker text escaped; UI owns colors and superscript markup. */
|
|
26
|
+
export declare function formatStandard(name: StandardFormatterName | undefined, values: readonly unknown[], context: TableFormatContext, showZeroValues?: boolean): FormattedCell;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BrokerCustomUI, IBrokerConnectionAdapterHost, Order, Position } from "../contracts/broker.js";
|
|
2
|
+
import { DialogCoordinator } from "../core/dialog-coordinator.js";
|
|
3
|
+
type DialogHost = Pick<IBrokerConnectionAdapterHost, "showOrderDialog" | "showCancelOrderDialog" | "showCancelMultipleOrdersDialog" | "showCancelBracketsDialog" | "showCancelMultipleBracketsDialog" | "showReversePositionDialog" | "showPositionBracketsDialog" | "showTradingProperties" | "showMessageDialog" | "showConfirmDialog" | "showSimpleConfirmDialog">;
|
|
4
|
+
export declare function createHostDialogs(dialogs: DialogCoordinator, custom: BrokerCustomUI | undefined, order: (id: string) => Readonly<Order> | undefined, position: (id: string) => Readonly<Position> | undefined, context?: () => unknown, cancellingBothBracketsOnly?: () => boolean, openSettings?: () => boolean): DialogHost;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IBrokerConnectionAdapterHost, OrderTicketSettings } from "../contracts/broker.js";
|
|
2
|
+
import type { TradingSettingsPort } from "../contracts/ports.js";
|
|
3
|
+
import { DisposalScope } from "../core/disposal.js";
|
|
4
|
+
type PreferenceHost = Pick<IBrokerConnectionAdapterHost, "sellBuyButtonsVisibility" | "domPanelVisibility" | "orderPanelVisibility" | "tradedSourcesVisibility" | "silentOrdersPlacement" | "getAccountManagerVisibilityMode" | "setAccountManagerVisibilityMode" | "activateBottomWidget" | "getOrderTicketSetting" | "setOrderTicketSetting" | "setQty" | "getQty" | "subscribeSuggestedQtyChange" | "unsubscribeSuggestedQtyChange">;
|
|
5
|
+
export declare function createHostPreferences(settings: TradingSettingsPort, namespace: string, requireConfirmation: boolean, defaultQty: (symbol: string) => Promise<number>, scope: DisposalScope, ticketSettingsChanged: (value: Readonly<OrderTicketSettings>) => void,
|
|
6
|
+
/** Receives invalid synchronous host input and listener failures; the adapter never sees an exception. */
|
|
7
|
+
report?: (method: string, cause: unknown) => void): PreferenceHost;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Execution, OrderTicketSettings, TradingQuotes } from "../contracts/broker.js";
|
|
2
|
+
import type { BrokerConfigFlags, DOMData, IBrokerConnectionAdapterHost, InstrumentInfo, OrderDurationMetaInfo } from "../contracts/broker.js";
|
|
3
|
+
import type { TradingSessionOptions } from "../core/session-types.js";
|
|
4
|
+
import type { TradingDiagnostic } from "../contracts/ports.js";
|
|
5
|
+
import type { TradingState } from "../core/trading-state.js";
|
|
6
|
+
import type { SnapshotDataset } from "../core/snapshot-dataset.js";
|
|
7
|
+
import type { Order, Position, IndividualPosition } from "../contracts/broker.js";
|
|
8
|
+
import { DialogCoordinator } from "../core/dialog-coordinator.js";
|
|
9
|
+
import { DisposalScope } from "../core/disposal.js";
|
|
10
|
+
import type { NotificationLog } from "../core/notification-log.js";
|
|
11
|
+
export interface HostServices {
|
|
12
|
+
readonly state: TradingState;
|
|
13
|
+
readonly scope: DisposalScope;
|
|
14
|
+
readonly cancellingBothBracketsOnly?: () => boolean;
|
|
15
|
+
/** Opens the host's trading settings page; false falls back to the platform's own dialog. */
|
|
16
|
+
readonly openSettings?: () => boolean;
|
|
17
|
+
readonly ticketSettingsChanged: (value: Readonly<OrderTicketSettings>) => void;
|
|
18
|
+
readonly dialogs: DialogCoordinator;
|
|
19
|
+
readonly notifications: NotificationLog;
|
|
20
|
+
readonly orders: SnapshotDataset<Order>;
|
|
21
|
+
readonly positions: SnapshotDataset<Position>;
|
|
22
|
+
readonly individualPositions: SnapshotDataset<IndividualPosition>;
|
|
23
|
+
readonly active: () => boolean;
|
|
24
|
+
readonly read: <T>(load: () => T | Promise<T>) => Promise<T>;
|
|
25
|
+
readonly update: (callback: () => void) => void;
|
|
26
|
+
/** Receives broker input the host dropped. */
|
|
27
|
+
readonly diagnostic?: (diagnostic: TradingDiagnostic) => void;
|
|
28
|
+
readonly connectionChanged: IBrokerConnectionAdapterHost["connectionStatusUpdate"];
|
|
29
|
+
readonly accountChanged: () => void;
|
|
30
|
+
readonly patchConfig: (patch: Partial<BrokerConfigFlags>) => void;
|
|
31
|
+
readonly setDurations: (durations: OrderDurationMetaInfo[]) => void;
|
|
32
|
+
readonly symbolInfo: (symbol: string) => Promise<InstrumentInfo>;
|
|
33
|
+
readonly quoteUpdate: (symbol: string, data: TradingQuotes) => void;
|
|
34
|
+
readonly executionUpdate?: (execution: Execution) => void;
|
|
35
|
+
readonly depthUpdate: (symbol: string, data: DOMData) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare function createTradingHost(options: TradingSessionOptions & {
|
|
38
|
+
readonly settingsKey: string;
|
|
39
|
+
}, services: HostServices): IBrokerConnectionAdapterHost;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IWatchedValue, WatchedValueCallback, WatchedValueSubscribeOptions } from '../contracts/broker.js';
|
|
2
|
+
export declare class WatchedValue<T> implements IWatchedValue<T> {
|
|
3
|
+
private readonly accepts;
|
|
4
|
+
private readonly failed?;
|
|
5
|
+
private current;
|
|
6
|
+
private available;
|
|
7
|
+
private disposed;
|
|
8
|
+
private readonly listeners;
|
|
9
|
+
/** With `failed`, listener failures are reported there instead of thrown at the writer (host-facing values). */
|
|
10
|
+
constructor(value?: T, accepts?: (value: T) => boolean, failed?: ((cause: unknown) => void) | undefined);
|
|
11
|
+
value(): T;
|
|
12
|
+
setValue(value: T, forceUpdate?: boolean): void;
|
|
13
|
+
/**
|
|
14
|
+
* Platform-internal write that returns a listener failure instead of reporting or throwing it, so the
|
|
15
|
+
* platform's own controls (the Trading settings page) can tell the user a save failed.
|
|
16
|
+
*/
|
|
17
|
+
trySetValue(value: T, forceUpdate?: boolean): {
|
|
18
|
+
readonly cause: unknown;
|
|
19
|
+
} | undefined;
|
|
20
|
+
subscribe(callback: WatchedValueCallback<T>, options?: WatchedValueSubscribeOptions): void;
|
|
21
|
+
private add;
|
|
22
|
+
unsubscribe(callback?: WatchedValueCallback<T> | null): void;
|
|
23
|
+
when(callback: WatchedValueCallback<T>): void;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|