@orangecharts/wrun-chart-host 0.1.0 → 0.3.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 +39 -6
- package/dist/constants/common.constants.d.ts +15 -0
- package/dist/constants/common.constants.js +23 -0
- package/dist/constants/data-source.constants.d.ts +1 -0
- package/dist/constants/data-source.constants.js +1 -0
- package/dist/constants/economic.constants.d.ts +39 -0
- package/dist/constants/economic.constants.js +77 -0
- package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
- package/dist/constants/etf-covered-coins.constants.js +9 -0
- package/dist/constants/feature-flags.constants.d.ts +60 -0
- package/dist/constants/feature-flags.constants.js +308 -0
- package/dist/constants/feature-limits.constants.d.ts +134 -0
- package/dist/constants/feature-limits.constants.js +155 -0
- package/dist/constants/marketCapabilities.constants.d.ts +87 -0
- package/dist/constants/marketCapabilities.constants.js +213 -0
- package/dist/constants/option-venues.constants.d.ts +100 -0
- package/dist/constants/option-venues.constants.js +167 -0
- package/dist/constants/overlay-data.constants.d.ts +53 -0
- package/dist/constants/overlay-data.constants.js +80 -0
- package/dist/constants/pane-grid.constants.d.ts +15 -0
- package/dist/constants/pane-grid.constants.js +17 -0
- package/dist/constants/venue-presets.constants.d.ts +10 -0
- package/dist/constants/venue-presets.constants.js +22 -0
- package/dist/enums/chart.enum.d.ts +68 -0
- package/dist/enums/chart.enum.js +70 -0
- package/dist/helpers/data.helpers.d.ts +2 -0
- package/dist/helpers/data.helpers.js +14 -0
- package/dist/host-env.d.ts +161 -5
- package/dist/host-ports.types.d.ts +446 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +131 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
- package/dist/interfaces/asset-venue.interface.d.ts +91 -0
- package/dist/interfaces/asset-venue.interface.js +1 -0
- package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
- package/dist/interfaces/cancel-reason.interface.js +2 -0
- package/dist/interfaces/catalog-display.interface.d.ts +3 -0
- package/dist/interfaces/catalog-display.interface.js +1 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
- package/dist/interfaces/cme-realtime.interface.js +46 -0
- package/dist/interfaces/feed.interface.d.ts +80 -0
- package/dist/interfaces/feed.interface.js +7 -0
- package/dist/interfaces/market-kind.interface.d.ts +8 -0
- package/dist/interfaces/market-kind.interface.js +1 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
- package/dist/interfaces/opra-realtime.interface.js +105 -0
- package/dist/interfaces/option-instrument.interface.d.ts +32 -0
- package/dist/interfaces/option-instrument.interface.js +1 -0
- package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
- package/dist/interfaces/options-chain-scope.interface.js +7 -0
- package/dist/interfaces/prediction-market.interface.d.ts +88 -0
- package/dist/interfaces/prediction-market.interface.js +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
- package/dist/settings-templates/frvp-fields.d.ts +27 -0
- package/dist/settings-templates/frvp-fields.js +108 -0
- package/dist/settings-templates/index.d.ts +119 -0
- package/dist/settings-templates/index.js +442 -0
- package/dist/settings-templates/indicator-fields.d.ts +56 -0
- package/dist/settings-templates/indicator-fields.js +793 -0
- package/dist/settings-templates/tool-rules.d.ts +59 -0
- package/dist/settings-templates/tool-rules.js +49 -0
- package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
- package/dist/settings-templates/tool-tables.generated.js +1668 -0
- package/dist/utility/blk-market.util.d.ts +5 -0
- package/dist/utility/blk-market.util.js +12 -0
- package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
- package/dist/utility/chart/chart-load-phase.util.js +78 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
- package/dist/utility/chart/cme-cache-context.util.js +166 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
- package/dist/utility/chart/cme-session-bucket.util.js +343 -0
- package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
- package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
- package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
- package/dist/utility/chart/continuous-contracts.util.js +374 -0
- package/dist/utility/chart/feed-interval.util.d.ts +119 -0
- package/dist/utility/chart/feed-interval.util.js +321 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
- package/dist/utility/chart/footprint-band.util.d.ts +76 -0
- package/dist/utility/chart/footprint-band.util.js +205 -0
- package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
- package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
- package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
- package/dist/utility/chart/formula-calendar.util.js +59 -0
- package/dist/utility/chart/history-wall.util.d.ts +67 -0
- package/dist/utility/chart/history-wall.util.js +87 -0
- package/dist/utility/chart/index-mode.util.d.ts +66 -0
- package/dist/utility/chart/index-mode.util.js +360 -0
- package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
- package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
- package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
- package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
- package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
- package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
- package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
- package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
- package/dist/utility/chart/interval-registry.util.d.ts +23 -0
- package/dist/utility/chart/interval-registry.util.js +83 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
- package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
- package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
- package/dist/utility/chart/live-bucket.util.d.ts +66 -0
- package/dist/utility/chart/live-bucket.util.js +165 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
- package/dist/utility/chart/market-session-schedule.util.js +337 -0
- package/dist/utility/chart/marketKind.util.d.ts +181 -0
- package/dist/utility/chart/marketKind.util.js +371 -0
- package/dist/utility/chart/om-panel.util.js +6 -0
- package/dist/utility/chart/om-widget.util.d.ts +4 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
- package/dist/utility/chart/opra-read-access.leaf.js +25 -0
- package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
- package/dist/utility/chart/prediction-identity.util.js +236 -0
- package/dist/utility/chart/rth-session.util.d.ts +352 -0
- package/dist/utility/chart/rth-session.util.js +926 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
- package/dist/utility/chart/titan-constants.pin.js +50 -0
- package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
- package/dist/utility/chart/us-equities-session.util.js +251 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
- package/dist/utility/chart/wrun-run-result.util.js +10 -0
- package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
- package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
- package/dist/utility/common/safe-math-eval.d.ts +18 -0
- package/dist/utility/common/safe-math-eval.js +160 -0
- package/dist/utility/common/time.util.d.ts +134 -0
- package/dist/utility/common/time.util.js +428 -0
- package/dist/utility/common/transformations.util.d.ts +126 -0
- package/dist/utility/common/transformations.util.js +711 -0
- package/dist/utility/common/visible-timeout.util.d.ts +17 -0
- package/dist/utility/common/visible-timeout.util.js +75 -0
- package/dist/utility/exchange-normalization.util.d.ts +8 -0
- package/dist/utility/exchange-normalization.util.js +32 -0
- package/dist/utility/intl-locale.util.d.ts +2 -0
- package/dist/utility/intl-locale.util.js +28 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +50 -19
- package/dist/utility/options/option-symbol.util.d.ts +28 -0
- package/dist/utility/options/option-symbol.util.js +176 -0
- package/dist/utility/options/option-trade-units.util.d.ts +190 -0
- package/dist/utility/options/option-trade-units.util.js +283 -0
- package/dist/utility/options/option-venue.util.d.ts +75 -0
- package/dist/utility/options/option-venue.util.js +85 -0
- package/dist/utility/pool-symbol.leaf.d.ts +34 -0
- package/dist/utility/pool-symbol.leaf.js +95 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
- package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
- package/dist/utility/v2/gate-plane.util.d.ts +58 -0
- package/dist/utility/v2/gate-plane.util.js +99 -0
- package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
- package/dist/utility/v2/gate-session-latch.util.js +34 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
- package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
- package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/economic.js +79 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
- package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/lanes/index.js +32 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
- package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
- package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
- package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
- package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
- package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
- package/dist/utility/wrun/sources/lanes/series.js +321 -0
- package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +196 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +207 -0
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
- package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
- package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +6 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +13 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
- package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +1 -1
- package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
- package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
- package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-deadline.util.js +82 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
- package/dist/utility/wrun/wrun-failure-cause.d.ts +39 -0
- package/dist/utility/wrun/wrun-failure-cause.js +94 -0
- package/dist/utility/wrun/wrun-frames.d.ts +28 -3
- package/dist/utility/wrun/wrun-frames.js +132 -52
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +167 -4
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +47 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +5 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.js +4 -2
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
- package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
- package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
- package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +30 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
- package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
- package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
- package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
- package/dist/utility/wrun/wrun-pack.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-pack.util.js +13 -3
- package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
- package/dist/utility/wrun/wrun-param-map.util.js +581 -0
- package/dist/utility/wrun/wrun-param-values.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-param-values.util.js +8 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +95 -7
- package/dist/utility/wrun/wrun-refusal.util.js +314 -18
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
- package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
- package/dist/utility/wrun/wrun-render-select.util.js +1 -0
- package/dist/utility/wrun/wrun-row-market.util.d.ts +29 -0
- package/dist/utility/wrun/wrun-row-market.util.js +92 -0
- package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
- package/dist/utility/wrun/wrun-row-source.js +75 -0
- package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
- package/dist/utility/wrun/wrun-run-health.util.js +273 -0
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
- package/dist/utility/wrun/wrun-symbol-code.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-symbol-code.util.js +56 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
- package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
- package/dist/utility/wrun-display-name.util.d.ts +33 -0
- package/dist/utility/wrun-display-name.util.js +64 -0
- package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
- package/dist/workers/constants/kscript-transport-codes.js +15 -0
- package/dist/workers/constants/socket-slots.d.ts +574 -0
- package/dist/workers/constants/socket-slots.js +539 -0
- package/dist/workers/utils/number.worker.util.d.ts +5 -0
- package/dist/workers/utils/number.worker.util.js +10 -0
- package/dist/workers/utils/time.worker.util.d.ts +12 -0
- package/dist/workers/utils/time.worker.util.js +24 -0
- package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
- package/dist/workers/utils/volume-profile.worker.util.js +631 -0
- package/package.json +10 -4
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadline wrapper for the WRUN add/run chain.
|
|
3
|
+
*
|
|
4
|
+
* The registry add path (ported-row click, add-by-name, registry row,
|
|
5
|
+
* rehydrate) awaits work with no intrinsic bound: network fetches, the chart
|
|
6
|
+
* store's mount pipeline, and the kScript source fetch lanes (a V2 stream only
|
|
7
|
+
* settles when the wire answers). Any one of them hanging left the UI pinned
|
|
8
|
+
* in its in-flight state forever ("Checking availability..." with no outcome,
|
|
9
|
+
* the shipped wrun-tab hang). Every await on that chain now races a deadline:
|
|
10
|
+
* the underlying work is not cancelled (fetches and mounts are not idempotent
|
|
11
|
+
* to abort), but the CALLER always settles, so the row always leaves its
|
|
12
|
+
* checking state with a user-visible outcome.
|
|
13
|
+
*
|
|
14
|
+
* Deadlines are ceilings against "forever", not latency budgets: each is far
|
|
15
|
+
* above the lane's healthy worst case (mount was observed taking ~25s when
|
|
16
|
+
* metadata RPCs ride their own 30s timeouts), so a trip means genuinely hung
|
|
17
|
+
* work, and the error message names the phase that hung.
|
|
18
|
+
*
|
|
19
|
+
* Two clocks, one per kind of phase. A NETWORK phase (the registry resolve and
|
|
20
|
+
* download, a source fetch) is answered whether or not anyone looks, so it
|
|
21
|
+
* counts wall time: a hidden tab whose reply never comes still times out. An
|
|
22
|
+
* APPLY phase (the mount, the first run up to its commit) is work a hidden tab
|
|
23
|
+
* holds back (the candle commit and the apply wait for a visible frame), so it
|
|
24
|
+
* counts visible time (visible-timeout.util): a chart restored in a background
|
|
25
|
+
* tab never reads "Did not load in time" nor records a `timeout`, and a stall
|
|
26
|
+
* the user watches still trips after the same budget. The apply phases' own
|
|
27
|
+
* network legs keep their wall-clock deadlines inside them.
|
|
28
|
+
*/
|
|
29
|
+
import { startVisibleTimeout } from '../common/visible-timeout.util.js';
|
|
30
|
+
import { WrunDeadlineError } from './wrun-registry-errors.util.js';
|
|
31
|
+
/** Downloading + verifying a package from the registry (resolve, tarball). A network phase. */
|
|
32
|
+
export const WRUN_DOWNLOAD_DEADLINE_MS = 45_000;
|
|
33
|
+
/** The one LATENCY budget here: the resolve of a built-in's proven twin
|
|
34
|
+
* (option A, wrun-proven-twin-add.util). That Add has the shipped template
|
|
35
|
+
* to fall back on, so a registry that accepts the connection and never
|
|
36
|
+
* answers holds the click a few seconds, never the download ceiling above;
|
|
37
|
+
* the resolve keeps running in its memo, so a later click finds it. */
|
|
38
|
+
export const WRUN_TWIN_RESOLVE_DEADLINE_MS = 4_000;
|
|
39
|
+
/** Mounting the overlay through chartStore.addIndicator. An apply phase (visible time). */
|
|
40
|
+
export const WRUN_MOUNT_DEADLINE_MS = 60_000;
|
|
41
|
+
/** One full compute pass (source fetches + sandbox run + integration). An
|
|
42
|
+
* apply phase (visible time): its source fetches carry their own wall-clock
|
|
43
|
+
* deadline below. */
|
|
44
|
+
export const WRUN_RUN_DEADLINE_MS = 90_000;
|
|
45
|
+
/** One kScript source fetch lane inside the run (book/trades/oi/vp/liq/
|
|
46
|
+
* funding/iv/skew). A network phase. */
|
|
47
|
+
export const WRUN_SOURCE_FETCH_DEADLINE_MS = 45_000;
|
|
48
|
+
/** Await `promise`, but reject with a labeled WrunDeadlineError if it has not
|
|
49
|
+
* settled within `ms` on `clock` (wall time unless the phase is an apply
|
|
50
|
+
* phase). The losing promise is left running with its eventual rejection
|
|
51
|
+
* marked handled (no unhandled-rejection noise). */
|
|
52
|
+
export async function withWrunDeadline(promise, ms, label, clock = 'wall') {
|
|
53
|
+
// If the deadline wins the race, a later rejection of the abandoned promise
|
|
54
|
+
// must not surface as an unhandled rejection.
|
|
55
|
+
void promise.catch(() => undefined);
|
|
56
|
+
let release;
|
|
57
|
+
try {
|
|
58
|
+
return await Promise.race([
|
|
59
|
+
promise,
|
|
60
|
+
new Promise((_, reject) => {
|
|
61
|
+
const seconds = Math.round(ms / 1000);
|
|
62
|
+
if (clock === 'visible') {
|
|
63
|
+
const deadline = startVisibleTimeout(() => {
|
|
64
|
+
// The background time before the visible budget ran out, for the report (never part of the budget).
|
|
65
|
+
const hiddenSeconds = Math.round(deadline.hiddenMs() / 1000);
|
|
66
|
+
const hidden = hiddenSeconds > 0 ? ` of visible time (${hiddenSeconds}s hidden before)` : '';
|
|
67
|
+
reject(new WrunDeadlineError(`${label} timed out after ${seconds}s${hidden}`));
|
|
68
|
+
}, ms);
|
|
69
|
+
release = () => deadline.clear();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
reject(new WrunDeadlineError(`${label} timed out after ${seconds}s`));
|
|
74
|
+
}, ms);
|
|
75
|
+
release = () => clearTimeout(timer);
|
|
76
|
+
}),
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
release?.();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
|
|
2
|
+
export declare const WRUN_ETF_FLOW_SOURCE = "etf_flow";
|
|
3
|
+
export declare const WRUN_ETF_FLOW_FIELD = "flow_usd";
|
|
4
|
+
/** The `fund` word for the sum over every fund listed for the chart's coin. */
|
|
5
|
+
export declare const WRUN_ETF_FLOW_ALL_FUNDS = "all";
|
|
6
|
+
/** A listed ETF ticker: the kit schema's `fund` shape (kept inside its zod refinement, not exported). */
|
|
7
|
+
export declare const WRUN_ETF_FLOW_TICKER_RE: RegExp;
|
|
8
|
+
/** The lane's own interval on every chart: the gateway serves ETF_FLOW_AGG at DAY only. */
|
|
9
|
+
export declare const WRUN_ETF_FLOW_INTERVAL_KEY = "1d";
|
|
10
|
+
export declare const WRUN_ETF_FLOW_DAY_MS: any;
|
|
11
|
+
/** The days before the window's day a live reconcile re-asks: a day's flow is published after
|
|
12
|
+
* the US session, possibly after midnight UTC (stamped the day before); three days reach the
|
|
13
|
+
* last trading day across a weekend. */
|
|
14
|
+
export declare const WRUN_ETF_FLOW_RECONCILE_LOOKBACK_DAYS = 3;
|
|
15
|
+
export interface WrunEtfFlowColumn {
|
|
16
|
+
/** The declared fund word (a ticker, or `all`). */
|
|
17
|
+
fund: string;
|
|
18
|
+
/** The lane row column (column 0 is the day ts). */
|
|
19
|
+
column: number;
|
|
20
|
+
/** The inputs reading this column, by index, in declaration order. */
|
|
21
|
+
inputIndexes: number[];
|
|
22
|
+
}
|
|
23
|
+
export interface WrunEtfFlowLanePlan {
|
|
24
|
+
coin: string;
|
|
25
|
+
/** Per declared fund word, in declaration order: the tickers its column sums (one for a
|
|
26
|
+
* ticker, the coin's whole list for `all`). */
|
|
27
|
+
columns: Array<{
|
|
28
|
+
fund: string;
|
|
29
|
+
tickers: string[];
|
|
30
|
+
}>;
|
|
31
|
+
/** Every ticker to fetch, once each, in first-use order. */
|
|
32
|
+
tickers: string[];
|
|
33
|
+
}
|
|
34
|
+
export declare function isWrunEtfFlowFund(fund: string): boolean;
|
|
35
|
+
/** The distinct fund words the sheet declares on `etf_flow` inputs, in declaration order, each
|
|
36
|
+
* with its lane column; the static refusals by name, before any fetch (a celled input, a field
|
|
37
|
+
* other than `flow_usd`, a missing or misspelled fund). Empty when no input reads the class. */
|
|
38
|
+
export declare function planWrunEtfFlowColumns(metadata: WrunIndicatorMetadata): WrunEtfFlowColumn[];
|
|
39
|
+
/** The UTC day (midnight, ms) a ts belongs to. */
|
|
40
|
+
export declare function wrunEtfFlowDayStart(ts: number): number;
|
|
41
|
+
/** Where the lane's live reconcile (its ask and its answer's authority) opens for the chart-bar
|
|
42
|
+
* window opening at `fromTs`, in a session whose first row is `sessionFirstRowTs`: the window's
|
|
43
|
+
* day, `WRUN_ETF_FLOW_RECONCILE_LOOKBACK_DAYS` earlier (the daily lane's rule,
|
|
44
|
+
* wrun-daily-lane.util), so a flow published after its day ended is fetched; never before the
|
|
45
|
+
* first row's day, where the full run opens (a flow needs no observation from before the chart
|
|
46
|
+
* window, and no bar reads an earlier day). */
|
|
47
|
+
export declare function wrunEtfFlowReconcileFrom(fromTs: number, sessionFirstRowTs: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* The landing rule: the raw observation an `etf_flow` column brings to the chart row opening at
|
|
50
|
+
* `ts` on a grid of `intervalMs`, off the lane rows indexed by day: the daily lane's `sum`
|
|
51
|
+
* landing (`wrunDailyLaneObservation`). Intraday (or daily) grid: the day's value on the first
|
|
52
|
+
* bar of its day only (a later bar of the day reads NaN, for the input's `missing` policy to
|
|
53
|
+
* fill); a grid coarser than a day: the sum over the days that open inside the bar, NaN when
|
|
54
|
+
* none reported. `byDay` maps a day start to its lane row.
|
|
55
|
+
*/
|
|
56
|
+
export declare function wrunEtfFlowObservation(byDay: ReadonlyMap<number, ArrayLike<number>>, column: number, ts: number, intervalMs: number): number;
|
|
57
|
+
/** The chart's coin, upper-cased, once it is one the ETF family covers (the native ETF
|
|
58
|
+
* indicators' `ETF_COVERED_COINS` gate, its leaf loaded lazily as the constants module it was split
|
|
59
|
+
* from was); refused by name otherwise, before any fetch. */
|
|
60
|
+
export declare function assertWrunEtfFlowCoin(coin: unknown, inputName: string): Promise<string>;
|
|
61
|
+
/** The tickers the metadata lists for a coin's spot-ETF flows (the native ETF flow indicator's
|
|
62
|
+
* own lookup: StreamMarkets type ETF_FLOW by coin, session-cached by the metadata service), in
|
|
63
|
+
* the metadata's order, each once. Lazy: the service and the proto enums load on demand. */
|
|
64
|
+
export declare function resolveWrunEtfFlowTickers(coin: string): Promise<string[]>;
|
|
65
|
+
/** The lane plan for a coin: each declared fund word resolved to the tickers its column sums,
|
|
66
|
+
* and the tickers to fetch once each. Refused by name: a coin the metadata lists no fund for,
|
|
67
|
+
* a ticker the coin does not list (naming the coin's funds). */
|
|
68
|
+
export declare function planWrunEtfFlowLane(columns: readonly WrunEtfFlowColumn[], coin: string, coinTickers: readonly string[], inputNameOf: (index: number) => string): WrunEtfFlowLanePlan;
|
|
69
|
+
/** Zip the per-ticker K_ETF_FLOW rows `[ts, flowUsd]` into the lane rows `[dayTs, ...columns]`,
|
|
70
|
+
* ascending by day: a column is its ticker's value or, for `all`, the per-day sum over the
|
|
71
|
+
* coin's tickers (a ticker with no row that day adds nothing; NaN where none reported). Two
|
|
72
|
+
* rows of one ticker on one day add up (the K worker's own rule for duplicate stamps). */
|
|
73
|
+
export declare function zipWrunEtfFlowRows(columns: ReadonlyArray<{
|
|
74
|
+
fund: string;
|
|
75
|
+
tickers: readonly string[];
|
|
76
|
+
}>, rowsByTicker: Readonly<Record<string, ReadonlyArray<ArrayLike<number>> | undefined>>): number[][];
|
|
77
|
+
/** What the per-ticker answers make of the lane: `rows` when a fund reported a day in the window;
|
|
78
|
+
* `loaded-empty` when every ticker's ask was answered (by the wire) and none holds a day there (a
|
|
79
|
+
* weekend, a US holiday, the hours before a day's flow is published): the lane is LOADED, its
|
|
80
|
+
* columns read NaN, and nothing re-asks it before its next poll; `declined` when an ask had no
|
|
81
|
+
* answer at all (`answered` false for a ticker), the one outcome that degrades the lane. */
|
|
82
|
+
export type WrunEtfFlowAnswer = 'rows' | 'loaded-empty' | 'declined';
|
|
83
|
+
export declare function wrunEtfFlowAnswer(zipped: ReadonlyArray<unknown>, tickers: readonly string[], answered: (ticker: string) => boolean): WrunEtfFlowAnswer;
|
|
84
|
+
/** The lane's acquisition record (the live reconcile re-asks the same tickers into the same
|
|
85
|
+
* columns): kept as plain data on the context. */
|
|
86
|
+
export interface WrunEtfFlowAcquisition {
|
|
87
|
+
coin: string;
|
|
88
|
+
columns: Array<{
|
|
89
|
+
fund: string;
|
|
90
|
+
tickers: string[];
|
|
91
|
+
}>;
|
|
92
|
+
tickers: string[];
|
|
93
|
+
}
|
|
94
|
+
export declare function isWrunEtfFlowAcquisition(value: unknown): value is WrunEtfFlowAcquisition;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `etf_flow` scalar class on the browser lane: daily net spot-ETF flow in USD for one fund,
|
|
3
|
+
* or the sum over every fund listed for the chart's coin, read off the chart's own K_ETF_FLOW
|
|
4
|
+
* lane (`k-etf-flow.control.ts`: one ETF per request, rows `[dayTs, flowUsd]`, the wire's
|
|
5
|
+
* millions x 1e6, stamped 00:00 UTC of the trading day, no rows on weekends and US holidays).
|
|
6
|
+
*
|
|
7
|
+
* The contract (the om kit freezes the words, `wrun-metadata-schema.ts` WRUN_ETF_FLOW_*):
|
|
8
|
+
* - class `etf_flow`, field `flow_usd`, knob `fund` REQUIRED: an ETF ticker (`IBIT`, `FBTC`,
|
|
9
|
+
* `ETHA`, ...) or `all`, the sum over every fund the metadata lists for the coin.
|
|
10
|
+
* - the coin is the chart market's: a chart of a coin with no listed spot ETFs refuses by name
|
|
11
|
+
* before any fetch (`ETF_COVERED_COINS` first, then the metadata's own fund list), and so does
|
|
12
|
+
* a ticker the coin does not list (the message names the coin's funds).
|
|
13
|
+
* - the series is DAILY on every chart, under the daily-lane rules (wrun-daily-lane.util) with
|
|
14
|
+
* the `sum` landing: the lane asks the DAY interval whatever the chart's (the gateway serves
|
|
15
|
+
* ETF_FLOW_AGG at DAY only) over a window opened at the first row's day. On an intraday
|
|
16
|
+
* chart the day's value lands on the FIRST bar of its day (`wrunEtfFlowObservation`); the
|
|
17
|
+
* later bars of that day bring no observation of their own and follow the input's `missing`
|
|
18
|
+
* policy (`carry` repeats the value across the day, `nan` and `zero` leave a one-bar spike);
|
|
19
|
+
* on a daily chart it joins row for row; on a chart coarser than a day a bar sums the days
|
|
20
|
+
* inside it. A day with no row (a weekend, a holiday, a fund that did not report) is no
|
|
21
|
+
* observation either. The day's flow is what the chart's own ETF flow indicator shows for
|
|
22
|
+
* that date: it is known after the US session, so on an intraday chart it is a same-day
|
|
23
|
+
* display series, never a no-lookahead signal.
|
|
24
|
+
* - lane rows are `[dayTs, <one column per declared fund word>]` in declaration order
|
|
25
|
+
* (`planWrunEtfFlowColumns`); a fund word's column is that ticker's own series or, for `all`,
|
|
26
|
+
* the per-day sum over the coin's tickers (NaN where none reported). `zipWrunEtfFlowRows`
|
|
27
|
+
* builds them from the per-ticker K rows in the run pass and in the live reconcile alike.
|
|
28
|
+
* - an empty answer is a loaded lane (`wrunEtfFlowAnswer`): a window with no US trading day in it
|
|
29
|
+
* (a weekend, a holiday, a 1m chart before the session) answers every ticker with no row, and
|
|
30
|
+
* the columns read NaN; only an ask with no answer at all degrades the lane for the ladder.
|
|
31
|
+
* - live: a POLL lane (K_ETF_FLOW has no live feed; a day's value appears after the US session,
|
|
32
|
+
* possibly after midnight UTC, and may be revised through the evening): the reconcile re-asks
|
|
33
|
+
* every ticker from three days before the window's day, never before the chart's first day
|
|
34
|
+
* (`wrunEtfFlowReconcileFrom`), and a changed or late-published day reseeds the session.
|
|
35
|
+
* - a market pin, an interval pin or a view on the input refuses by name in the pinned-wire
|
|
36
|
+
* planner (typed feeds follow the chart's own market and clock); a celled input refuses here.
|
|
37
|
+
* The om daemon has no ETF flow client and refuses the class by name (`wrun_etf_flow_unsupported`).
|
|
38
|
+
*/
|
|
39
|
+
import { wrunChartHostEnv } from '../../host-env.js';
|
|
40
|
+
import { WRUN_DAILY_LANE_DAY_MS, WRUN_DAILY_LANE_INTERVAL_KEY, wrunDailyLaneDayStart, wrunDailyLaneObservation, wrunDailyLaneReconcileFrom, } from './wrun-daily-lane.util.js';
|
|
41
|
+
export const WRUN_ETF_FLOW_SOURCE = 'etf_flow';
|
|
42
|
+
export const WRUN_ETF_FLOW_FIELD = 'flow_usd';
|
|
43
|
+
/** The `fund` word for the sum over every fund listed for the chart's coin. */
|
|
44
|
+
export const WRUN_ETF_FLOW_ALL_FUNDS = 'all';
|
|
45
|
+
/** A listed ETF ticker: the kit schema's `fund` shape (kept inside its zod refinement, not exported). */
|
|
46
|
+
export const WRUN_ETF_FLOW_TICKER_RE = /^[A-Z][A-Z0-9.]{0,9}$/;
|
|
47
|
+
/** The lane's own interval on every chart: the gateway serves ETF_FLOW_AGG at DAY only. */
|
|
48
|
+
export const WRUN_ETF_FLOW_INTERVAL_KEY = WRUN_DAILY_LANE_INTERVAL_KEY;
|
|
49
|
+
export const WRUN_ETF_FLOW_DAY_MS = WRUN_DAILY_LANE_DAY_MS;
|
|
50
|
+
/** The days before the window's day a live reconcile re-asks: a day's flow is published after
|
|
51
|
+
* the US session, possibly after midnight UTC (stamped the day before); three days reach the
|
|
52
|
+
* last trading day across a weekend. */
|
|
53
|
+
export const WRUN_ETF_FLOW_RECONCILE_LOOKBACK_DAYS = 3;
|
|
54
|
+
const etfLabel = (name) => `Input '${name}' (${WRUN_ETF_FLOW_SOURCE})`;
|
|
55
|
+
export function isWrunEtfFlowFund(fund) {
|
|
56
|
+
return fund === WRUN_ETF_FLOW_ALL_FUNDS || WRUN_ETF_FLOW_TICKER_RE.test(fund);
|
|
57
|
+
}
|
|
58
|
+
/** The distinct fund words the sheet declares on `etf_flow` inputs, in declaration order, each
|
|
59
|
+
* with its lane column; the static refusals by name, before any fetch (a celled input, a field
|
|
60
|
+
* other than `flow_usd`, a missing or misspelled fund). Empty when no input reads the class. */
|
|
61
|
+
export function planWrunEtfFlowColumns(metadata) {
|
|
62
|
+
const columns = [];
|
|
63
|
+
const inputs = [...metadata.inputs].sort((a, b) => a.index - b.index);
|
|
64
|
+
for (const input of inputs) {
|
|
65
|
+
const source = metadata.inputSources[input.name];
|
|
66
|
+
if (source?.source !== WRUN_ETF_FLOW_SOURCE)
|
|
67
|
+
continue;
|
|
68
|
+
const name = input.name;
|
|
69
|
+
if (input.cellType === 'array') {
|
|
70
|
+
throw new Error(`${etfLabel(name)} is celled: etf_flow serves one scalar per bar (a day's net flow), a scalar input`);
|
|
71
|
+
}
|
|
72
|
+
if (source.field !== WRUN_ETF_FLOW_FIELD) {
|
|
73
|
+
throw new Error(`${etfLabel(name)}: unknown etf_flow field '${String(source.field)}' (the one field is ${WRUN_ETF_FLOW_FIELD}, the day's net flow in USD)`);
|
|
74
|
+
}
|
|
75
|
+
const fund = source.fund;
|
|
76
|
+
if (fund === undefined) {
|
|
77
|
+
throw new Error(`${etfLabel(name)} declares no fund: declare the ETF ticker (IBIT, FBTC, ETHA, ...) or '${WRUN_ETF_FLOW_ALL_FUNDS}' for the sum over the chart coin's funds`);
|
|
78
|
+
}
|
|
79
|
+
if (!isWrunEtfFlowFund(fund)) {
|
|
80
|
+
throw new Error(`${etfLabel(name)} declares fund '${fund}': not an ETF ticker (1 to 10 upper-case letters, digits or dots, e.g. IBIT) or '${WRUN_ETF_FLOW_ALL_FUNDS}'`);
|
|
81
|
+
}
|
|
82
|
+
let column = columns.find((candidate) => candidate.fund === fund);
|
|
83
|
+
if (!column) {
|
|
84
|
+
column = { fund, column: columns.length + 1, inputIndexes: [] };
|
|
85
|
+
columns.push(column);
|
|
86
|
+
}
|
|
87
|
+
column.inputIndexes.push(input.index);
|
|
88
|
+
}
|
|
89
|
+
return columns;
|
|
90
|
+
}
|
|
91
|
+
/** The UTC day (midnight, ms) a ts belongs to. */
|
|
92
|
+
export function wrunEtfFlowDayStart(ts) {
|
|
93
|
+
return wrunDailyLaneDayStart(ts);
|
|
94
|
+
}
|
|
95
|
+
/** Where the lane's live reconcile (its ask and its answer's authority) opens for the chart-bar
|
|
96
|
+
* window opening at `fromTs`, in a session whose first row is `sessionFirstRowTs`: the window's
|
|
97
|
+
* day, `WRUN_ETF_FLOW_RECONCILE_LOOKBACK_DAYS` earlier (the daily lane's rule,
|
|
98
|
+
* wrun-daily-lane.util), so a flow published after its day ended is fetched; never before the
|
|
99
|
+
* first row's day, where the full run opens (a flow needs no observation from before the chart
|
|
100
|
+
* window, and no bar reads an earlier day). */
|
|
101
|
+
export function wrunEtfFlowReconcileFrom(fromTs, sessionFirstRowTs) {
|
|
102
|
+
return wrunDailyLaneReconcileFrom(fromTs, sessionFirstRowTs, WRUN_ETF_FLOW_RECONCILE_LOOKBACK_DAYS, 0);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The landing rule: the raw observation an `etf_flow` column brings to the chart row opening at
|
|
106
|
+
* `ts` on a grid of `intervalMs`, off the lane rows indexed by day: the daily lane's `sum`
|
|
107
|
+
* landing (`wrunDailyLaneObservation`). Intraday (or daily) grid: the day's value on the first
|
|
108
|
+
* bar of its day only (a later bar of the day reads NaN, for the input's `missing` policy to
|
|
109
|
+
* fill); a grid coarser than a day: the sum over the days that open inside the bar, NaN when
|
|
110
|
+
* none reported. `byDay` maps a day start to its lane row.
|
|
111
|
+
*/
|
|
112
|
+
export function wrunEtfFlowObservation(byDay, column, ts, intervalMs) {
|
|
113
|
+
return wrunDailyLaneObservation(byDay, column, ts, intervalMs, 'sum');
|
|
114
|
+
}
|
|
115
|
+
/** The chart's coin, upper-cased, once it is one the ETF family covers (the native ETF
|
|
116
|
+
* indicators' `ETF_COVERED_COINS` gate, its leaf loaded lazily as the constants module it was split
|
|
117
|
+
* from was); refused by name otherwise, before any fetch. */
|
|
118
|
+
export async function assertWrunEtfFlowCoin(coin, inputName) {
|
|
119
|
+
const word = typeof coin === 'string' ? coin.trim().toUpperCase() : '';
|
|
120
|
+
const { ETF_COVERED_COINS } = await import('../../constants/etf-covered-coins.constants.js');
|
|
121
|
+
if (word === '') {
|
|
122
|
+
throw new Error(`${etfLabel(inputName)} needs the chart's coin to pick the ETF family, and this chart has none`);
|
|
123
|
+
}
|
|
124
|
+
if (!ETF_COVERED_COINS.includes(word)) {
|
|
125
|
+
throw new Error(`${etfLabel(inputName)} needs a chart of a coin with listed spot ETFs (${ETF_COVERED_COINS.join(', ')}): this chart's coin is ${word}`);
|
|
126
|
+
}
|
|
127
|
+
return word;
|
|
128
|
+
}
|
|
129
|
+
/** The tickers the metadata lists for a coin's spot-ETF flows (the native ETF flow indicator's
|
|
130
|
+
* own lookup: StreamMarkets type ETF_FLOW by coin, session-cached by the metadata service), in
|
|
131
|
+
* the metadata's order, each once. Lazy: the service and the proto enums load on demand. */
|
|
132
|
+
export async function resolveWrunEtfFlowTickers(coin) {
|
|
133
|
+
const [{ default: metadataService }, { Type }] = await Promise.all([
|
|
134
|
+
wrunChartHostEnv().market.loadMetadataService(),
|
|
135
|
+
import('@orangecharts/orange-v2-pb-common'),
|
|
136
|
+
]);
|
|
137
|
+
const markets = (await metadataService.getMarkets({ type: [Type.ETF_FLOW], coin: [coin], excludePrices: true }));
|
|
138
|
+
const tickers = [];
|
|
139
|
+
for (const market of markets ?? []) {
|
|
140
|
+
const ticker = typeof market.rawSymbol === 'string' && market.rawSymbol !== ''
|
|
141
|
+
? market.rawSymbol
|
|
142
|
+
: typeof market.symbol === 'string'
|
|
143
|
+
? market.symbol
|
|
144
|
+
: '';
|
|
145
|
+
if (ticker !== '' && !tickers.includes(ticker))
|
|
146
|
+
tickers.push(ticker);
|
|
147
|
+
}
|
|
148
|
+
return tickers;
|
|
149
|
+
}
|
|
150
|
+
/** The lane plan for a coin: each declared fund word resolved to the tickers its column sums,
|
|
151
|
+
* and the tickers to fetch once each. Refused by name: a coin the metadata lists no fund for,
|
|
152
|
+
* a ticker the coin does not list (naming the coin's funds). */
|
|
153
|
+
export function planWrunEtfFlowLane(columns, coin, coinTickers, inputNameOf) {
|
|
154
|
+
const plan = { coin, columns: [], tickers: [] };
|
|
155
|
+
for (const column of columns) {
|
|
156
|
+
const name = inputNameOf(column.inputIndexes[0]);
|
|
157
|
+
if (coinTickers.length === 0) {
|
|
158
|
+
throw new Error(`${etfLabel(name)} needs a chart of a coin with listed spot ETFs: no spot ETF flows are listed for ${coin}`);
|
|
159
|
+
}
|
|
160
|
+
let tickers;
|
|
161
|
+
if (column.fund === WRUN_ETF_FLOW_ALL_FUNDS)
|
|
162
|
+
tickers = [...coinTickers];
|
|
163
|
+
else if (coinTickers.includes(column.fund))
|
|
164
|
+
tickers = [column.fund];
|
|
165
|
+
else {
|
|
166
|
+
throw new Error(`${etfLabel(name)} pins fund '${column.fund}', not one of the ${coin} spot ETFs (${coinTickers.join(', ')}); declare one of them or '${WRUN_ETF_FLOW_ALL_FUNDS}'`);
|
|
167
|
+
}
|
|
168
|
+
plan.columns.push({ fund: column.fund, tickers });
|
|
169
|
+
for (const ticker of tickers)
|
|
170
|
+
if (!plan.tickers.includes(ticker))
|
|
171
|
+
plan.tickers.push(ticker);
|
|
172
|
+
}
|
|
173
|
+
return plan;
|
|
174
|
+
}
|
|
175
|
+
/** Zip the per-ticker K_ETF_FLOW rows `[ts, flowUsd]` into the lane rows `[dayTs, ...columns]`,
|
|
176
|
+
* ascending by day: a column is its ticker's value or, for `all`, the per-day sum over the
|
|
177
|
+
* coin's tickers (a ticker with no row that day adds nothing; NaN where none reported). Two
|
|
178
|
+
* rows of one ticker on one day add up (the K worker's own rule for duplicate stamps). */
|
|
179
|
+
export function zipWrunEtfFlowRows(columns, rowsByTicker) {
|
|
180
|
+
const byTicker = new Map();
|
|
181
|
+
for (const [ticker, rows] of Object.entries(rowsByTicker)) {
|
|
182
|
+
const byDay = new Map();
|
|
183
|
+
for (const row of rows ?? []) {
|
|
184
|
+
const ts = Number(row[0]);
|
|
185
|
+
const value = Number(row[1]);
|
|
186
|
+
if (!Number.isFinite(ts) || !Number.isFinite(value))
|
|
187
|
+
continue;
|
|
188
|
+
const day = wrunEtfFlowDayStart(ts);
|
|
189
|
+
byDay.set(day, (byDay.get(day) ?? 0) + value);
|
|
190
|
+
}
|
|
191
|
+
byTicker.set(ticker, byDay);
|
|
192
|
+
}
|
|
193
|
+
const days = new Set();
|
|
194
|
+
for (const byDay of byTicker.values())
|
|
195
|
+
for (const day of byDay.keys())
|
|
196
|
+
days.add(day);
|
|
197
|
+
return [...days]
|
|
198
|
+
.sort((a, b) => a - b)
|
|
199
|
+
.map((day) => {
|
|
200
|
+
const row = [day];
|
|
201
|
+
for (const column of columns) {
|
|
202
|
+
let value = Number.NaN;
|
|
203
|
+
for (const ticker of column.tickers) {
|
|
204
|
+
const observed = byTicker.get(ticker)?.get(day);
|
|
205
|
+
if (observed === undefined)
|
|
206
|
+
continue;
|
|
207
|
+
value = Number.isFinite(value) ? value + observed : observed;
|
|
208
|
+
}
|
|
209
|
+
row.push(value);
|
|
210
|
+
}
|
|
211
|
+
return row;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
export function wrunEtfFlowAnswer(zipped, tickers, answered) {
|
|
215
|
+
if (zipped.length > 0)
|
|
216
|
+
return 'rows';
|
|
217
|
+
return tickers.every((ticker) => answered(ticker)) ? 'loaded-empty' : 'declined';
|
|
218
|
+
}
|
|
219
|
+
export function isWrunEtfFlowAcquisition(value) {
|
|
220
|
+
if (value === null || typeof value !== 'object')
|
|
221
|
+
return false;
|
|
222
|
+
const record = value;
|
|
223
|
+
return typeof record.coin === 'string' && Array.isArray(record.columns) && Array.isArray(record.tickers);
|
|
224
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart coin's spot-ETF facts a hosted wrun run sends the cloud (`wrunFacts`, the client half of
|
|
3
|
+
* cloud slice C6). The cloud holds no market directory, so it resolves the `fund` words of ETF inputs
|
|
4
|
+
* from what the chart sends: two independent lists, each exactly as the chart's own lanes look it up,
|
|
5
|
+
* never merged.
|
|
6
|
+
*
|
|
7
|
+
* - `etfFlowTickers`: the ETF_FLOW listing's tickers (wrun-etf-flow-lane.util
|
|
8
|
+
* `resolveWrunEtfFlowTickers`, the chart coin trimmed and upper-cased), for an `etf_flow` input.
|
|
9
|
+
* - `etfFunds`: the ETF_METRICS listing's funds (sources/lanes/etf_premium.ts
|
|
10
|
+
* `resolveWrunEtfPremiumFunds`, the tickers the holdings lane sums, each with the issuer the
|
|
11
|
+
* premium ask names; the coin read as the ETF family spells it, BitMEX's XBT as BTC), for an
|
|
12
|
+
* `etf_holdings` or `etf_premium` input.
|
|
13
|
+
* - Each lane gates the coin by `ETF_COVERED_COINS` before any read, and so does each list.
|
|
14
|
+
* - Which lists a payload carries: the sheet's (when the sheet is known) and every list the cloud
|
|
15
|
+
* asked this overlay for (a refusal's `needsFacts`, kept by `noteWrunHostedFactsAsked`). With
|
|
16
|
+
* neither, nothing rides.
|
|
17
|
+
* - A list is absent when it is unknown or not needed (no coin, a coin the family does not cover, a
|
|
18
|
+
* listing not answered yet, a read that failed or answered no fund), never empty; `wrunFacts` is
|
|
19
|
+
* absent when it would hold neither. Nothing rides until every listing needed has a definite
|
|
20
|
+
* answer, so a sheet reading both kinds recreates its session once, not twice.
|
|
21
|
+
*
|
|
22
|
+
* Session memo per listing and coin, the market facts' rule (wrun-chart-market-facts.util): a
|
|
23
|
+
* definite answer kept, concurrent reads share one, a failed or empty read asked again a minute
|
|
24
|
+
* later. The hosted createScript never waits for it (`wrunHostedEtfFacts` starts the read and sends
|
|
25
|
+
* nothing; the socket worker holds the facts as session identity, so the next fetch after they land
|
|
26
|
+
* recreates the session once); Run once awaits it (`awaitWrunEtfFacts`); the one extra ask after a
|
|
27
|
+
* refusal for absent facts (the socket row source's `routeWrunSocketFactsNeeded`) waits for it too
|
|
28
|
+
* (`wrunAskedFactsReady`).
|
|
29
|
+
*
|
|
30
|
+
* Main thread only. Light at module load: the directory read, the lanes and the covered-coin
|
|
31
|
+
* constants load on demand.
|
|
32
|
+
*/
|
|
33
|
+
import { type WrunHostedFactKind, type WrunHostedFacts } from './wrun-param-map.util.js';
|
|
34
|
+
/** A spot-ETF listing of the market directory: ETF_FLOW, or ETF_METRICS. */
|
|
35
|
+
export type WrunEtfListing = 'flow' | 'metrics';
|
|
36
|
+
/** The listings a sheet's inputs read (its `inputSources`), ETF_FLOW first: none when no input reads
|
|
37
|
+
* an ETF source. */
|
|
38
|
+
export declare function wrunEtfListingsOf(sheet: unknown): WrunEtfListing[];
|
|
39
|
+
/** The listings fact lists are read from, ETF_FLOW first. */
|
|
40
|
+
export declare function wrunEtfListingsOfFacts(kinds: readonly WrunHostedFactKind[]): WrunEtfListing[];
|
|
41
|
+
/** The coin a listing is asked by, as its lane spells it: trimmed and upper-cased, and on the
|
|
42
|
+
* ETF_METRICS listing BitMEX's XBT read as BTC (wrunEtfHoldingsCoinWord, wrunEtfPremiumFamilyCoin);
|
|
43
|
+
* '' when the chart has none. */
|
|
44
|
+
export declare function wrunEtfListingCoin(listing: WrunEtfListing, coin: unknown): string;
|
|
45
|
+
/** Start (or join) the reads `listings` need for the chart's `coin`. Never rejects. */
|
|
46
|
+
export declare function warmWrunEtfFunds(listings: readonly WrunEtfListing[], coin: unknown): Promise<void>;
|
|
47
|
+
/** The facts now, without waiting: `known` false while a listing they need has no definite answer
|
|
48
|
+
* (not read yet, in flight, or failed or empty within the last minute); else the facts, each list
|
|
49
|
+
* only when its listing holds a fund, undefined when neither does (no coin, a coin the family does
|
|
50
|
+
* not cover). */
|
|
51
|
+
export declare function wrunEtfFactsNow(listings: readonly WrunEtfListing[], coin: unknown): {
|
|
52
|
+
known: false;
|
|
53
|
+
} | {
|
|
54
|
+
known: true;
|
|
55
|
+
facts: WrunHostedFacts | undefined;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The facts a hosted createScript carries on a chart of `coin`, without waiting: the lists the sheet
|
|
59
|
+
* reads (the remembered sheet, else the record's own `wrunSheet`; undefined when unknown) and the
|
|
60
|
+
* lists the cloud asked this overlay for (`askedFacts`). Undefined when neither names a list, when
|
|
61
|
+
* there is nothing to send, or while the directory has not answered, in which case the read starts
|
|
62
|
+
* here and a later fetch carries the facts.
|
|
63
|
+
*/
|
|
64
|
+
export declare function wrunHostedEtfFacts(sheet: unknown, coin: unknown, askedFacts?: readonly WrunHostedFactKind[]): WrunHostedFacts | undefined;
|
|
65
|
+
/** The facts Run once sends for a build's sheet on a chart of `coin`, once the directory answered:
|
|
66
|
+
* undefined when the sheet reads no ETF source or there is nothing to send. Never rejects. */
|
|
67
|
+
export declare function awaitWrunEtfFacts(sheet: unknown, coin: unknown): Promise<WrunHostedFacts | undefined>;
|
|
68
|
+
/** Whether every asked fact list has a definite non-empty answer for the chart's `coin`, once the
|
|
69
|
+
* directory answered (the reads start here). False for no list, for a definite none (no coin, a
|
|
70
|
+
* coin the family does not cover) and while an answer is not definite. Never rejects. */
|
|
71
|
+
export declare function wrunAskedFactsReady(kinds: readonly WrunHostedFactKind[], coin: unknown): Promise<boolean>;
|
|
72
|
+
/** Remember the fact lists the cloud asked an overlay for (a refusal's `needsFacts`), beside the ones
|
|
73
|
+
* it asked before: the overlay's payloads send them from now on. Answers every list asked so far, in
|
|
74
|
+
* the fixed order. */
|
|
75
|
+
export declare function noteWrunHostedFactsAsked(chartIndex: number, overlayId: string, kinds: readonly WrunHostedFactKind[]): WrunHostedFactKind[];
|
|
76
|
+
/** The fact lists the cloud asked an overlay for: none until a refusal named one. */
|
|
77
|
+
export declare function wrunHostedFactsAsked(chartIndex: number, overlayId: string): WrunHostedFactKind[];
|
|
78
|
+
/** Forget what the cloud asked: one overlay on one chart, every overlay of a chart (`overlayId`
|
|
79
|
+
* undefined), or one overlay on every chart (`chartIndex` undefined). */
|
|
80
|
+
export declare function forgetWrunHostedFactsAsked(chartIndex: number | undefined, overlayId?: string): void;
|
|
81
|
+
/** Forget every kept answer and every asked list (spec isolation). */
|
|
82
|
+
export declare function clearWrunEtfFundsMemo(): void;
|