@orangecharts/wrun-chart-host 0.2.0 → 0.4.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 +22 -8
- 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/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -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 +163 -5
- package/dist/host-ports.types.d.ts +431 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +138 -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/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -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/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -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/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/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -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-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/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -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 +58 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -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 +215 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +237 -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 +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -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 +62 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -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-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-frames.d.ts +20 -1
- package/dist/utility/wrun/wrun-frames.js +103 -49
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
- 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 +49 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -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-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- 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-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -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-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -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 +41 -1
- package/dist/utility/wrun/wrun-refusal.util.js +69 -2
- 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-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-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -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-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,100 @@
|
|
|
1
|
+
import type { OptionSettlementFamily } from '../utility/options/option-symbol.util.js';
|
|
2
|
+
import type { GateProvider } from '../workers/constants/socket-slots.js';
|
|
3
|
+
/**
|
|
4
|
+
* One settlement family a venue lists as its own product. `quoteAsset` names the pair (`BTC/USDC`);
|
|
5
|
+
* omitted, the contract is quoted and settled in the root coin itself and the pair is the root.
|
|
6
|
+
* Trade units are never a family rule: an option's coin size and premium come from the contract's
|
|
7
|
+
* registry multiplier and point value (option-trade-units.util), and the gateway serves `TRADE_AGG`
|
|
8
|
+
* volume already sized in coin (`optionCoinVolume`).
|
|
9
|
+
*/
|
|
10
|
+
export interface OptionVenueFamily {
|
|
11
|
+
family: OptionSettlementFamily;
|
|
12
|
+
quoteAsset?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A root served without a catalog read, and the settlement families the venue lists it under. */
|
|
15
|
+
export interface OptionKnownUnderlying {
|
|
16
|
+
root: string;
|
|
17
|
+
families: readonly OptionSettlementFamily[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One option provider on the options surfaces. `lane` picks the chain transport: CME chains only
|
|
21
|
+
* answer on the governed gate socket, crypto chains answer on the plain v2 socket. `gated` providers
|
|
22
|
+
* stay hidden unless the caller passes the `crypto-options` gate (see `visibleOptionVenues`).
|
|
23
|
+
*
|
|
24
|
+
* `exchanges` are pb-common `Exchange` member names, resolved at runtime so a name the installed
|
|
25
|
+
* build lacks is skipped rather than failing. `underlyingKey` names the catalog field the chain
|
|
26
|
+
* RPCs expect as the underlying (`'base'`, the parsed root, by default). `knownUnderlyings` lists
|
|
27
|
+
* roots served without a catalog read, for venues whose StreamMarkets rows are hidden. `families`
|
|
28
|
+
* lists the settlement families the venue serves; a `knownUnderlyings` root names its own, and a
|
|
29
|
+
* root listed in both is offered once, as the coin-settled product the quote summary prices.
|
|
30
|
+
* `chainWindowSec` is the trailing OPTION_SUMMARY window the chain snapshot reads. It must cover the
|
|
31
|
+
* venue's publish interval: Deribit ticks every 1 to 3 s, the other plain venues every 15 to 60 s
|
|
32
|
+
* (measured 2026-09-29), and the latest-snapshot answer does not grow with the window.
|
|
33
|
+
*/
|
|
34
|
+
export interface OptionVenue {
|
|
35
|
+
id: 'cme' | 'opra' | 'deribit' | 'binance-options' | 'okx-options' | 'bybit' | 'bullish' | 'derive';
|
|
36
|
+
labelKey: string;
|
|
37
|
+
exchanges: readonly string[];
|
|
38
|
+
lane: 'governed' | 'plain';
|
|
39
|
+
/** Governed rows name their entitlement-gate plane: the socket slots, served-access rows and delay default they ride. */
|
|
40
|
+
plane?: GateProvider;
|
|
41
|
+
gated: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Which gate lights a gated row: the crypto providers share `crypto-options` (signed in); OPRA has its
|
|
44
|
+
* own `opra` flag. A gated row without a `gate` is a crypto-options row (the shape before OPRA).
|
|
45
|
+
*/
|
|
46
|
+
gate?: 'crypto-options' | 'opra';
|
|
47
|
+
/**
|
|
48
|
+
* Chart exchanges whose symbol is this venue's UNDERLYING (not its contracts): a US stock chart carries
|
|
49
|
+
* US_STOCKS / POLYGON or a listing venue, while its options carry OPRA. CME needs none because futures and
|
|
50
|
+
* their options share exchange codes.
|
|
51
|
+
*/
|
|
52
|
+
underlyingExchanges?: readonly string[];
|
|
53
|
+
/**
|
|
54
|
+
* How the Options tab lists roots: `wire` pages the gateway's option directory (CME, crypto); `search`
|
|
55
|
+
* lists roots from the stock search and loads expiries on demand (OPRA: 1.9M contracts, no directory).
|
|
56
|
+
*/
|
|
57
|
+
directory?: 'wire' | 'search';
|
|
58
|
+
/** Roots the search cannot list (index options: no underlying series), offered by name with trades and OI only. */
|
|
59
|
+
syntheticRoots?: readonly string[];
|
|
60
|
+
/** Greeks and IV are computed in-house (Black-Scholes, flat rate, no dividends): caption them as estimates. */
|
|
61
|
+
greeksEstimated?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The chain stamps each expiry at the contract's true expiry instant (OPRA: 16:00 New York, 09:30 for the
|
|
64
|
+
* AM-settled roots), not a bare UTC-midnight date (CME's registry today). The heatmap's charm and vanna
|
|
65
|
+
* read time to expiry, so they are offered and kept only on a plane whose row says so: set it on a
|
|
66
|
+
* governed row the day its registry stamps instants (planeServesExpiryInstants).
|
|
67
|
+
*/
|
|
68
|
+
expiryInstants?: boolean;
|
|
69
|
+
/** Chain fields the venue never serves (OPRA publishes no settlement), folded into the hidden set. */
|
|
70
|
+
unavailableFields?: readonly string[];
|
|
71
|
+
/** The delayed tier's nominal minutes for copy until the gate's tier frame reports the real figure. */
|
|
72
|
+
delayMinutes?: number;
|
|
73
|
+
underlyingKey?: 'base' | 'assetTicker';
|
|
74
|
+
knownUnderlyings?: readonly OptionKnownUnderlying[];
|
|
75
|
+
families?: readonly OptionVenueFamily[];
|
|
76
|
+
chainWindowSec?: number;
|
|
77
|
+
/** The venue streams OPTION_SUMMARY on the live feed, so a chain's underlying follows it between summary polls. */
|
|
78
|
+
liveSummary?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The chain page's summary poll for this venue. Omitted polls at `OPTION_CHAIN_SUMMARY_POLL_MS` (3 s, Deribit and
|
|
81
|
+
* CME); the other plain venues publish every 15 to 60 s, so a 3 s poll mostly re-reads the same quotes.
|
|
82
|
+
*/
|
|
83
|
+
chainPollMs?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Chart exchange codes a US stock or ETF may carry (the post-flip vendor code, its enum alias and the
|
|
87
|
+
* legacy listing venues the catalog still emits). An OPRA chain attaches to a chart on any of them.
|
|
88
|
+
*/
|
|
89
|
+
export declare const OPRA_UNDERLYING_EXCHANGES: readonly string[];
|
|
90
|
+
/**
|
|
91
|
+
* Index option roots on OPRA, listed by name (no underlying series on the chart): the directory, the logo
|
|
92
|
+
* choice and the session table read this list. What their chain carries (an underlying price, open
|
|
93
|
+
* interest, greeks) is read off the summary itself, never off this list.
|
|
94
|
+
*/
|
|
95
|
+
export declare const OPRA_INDEX_ROOTS: readonly string[];
|
|
96
|
+
export declare const OPTION_VENUES: readonly OptionVenue[];
|
|
97
|
+
/** The Options tab's Any exchange row: every provider on offer, browsed as one list. */
|
|
98
|
+
export declare const ANY_OPTION_VENUE = "all";
|
|
99
|
+
/** What the Options tab browses: one provider, or every provider at once. */
|
|
100
|
+
export type OptionProviderId = OptionVenue['id'] | typeof ANY_OPTION_VENUE;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { CME_BUNDLE_EXCHANGES } from '../interfaces/cme-realtime.interface.js';
|
|
2
|
+
import { OPRA_DELAY_MINUTES, OPRA_GOVERNED_EXCHANGES } from '../interfaces/opra-realtime.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* The chain page's poll for the plain venues that publish every 15 to 60 s (see `OptionVenue.chainPollMs`): slow
|
|
5
|
+
* enough not to re-read the same quotes every 3 s, fast enough to add at most 5 s on top of the source's own delay.
|
|
6
|
+
*/
|
|
7
|
+
const SLOW_VENUE_CHAIN_POLL_MS = 5_000;
|
|
8
|
+
/**
|
|
9
|
+
* Chart exchange codes a US stock or ETF may carry (the post-flip vendor code, its enum alias and the
|
|
10
|
+
* legacy listing venues the catalog still emits). An OPRA chain attaches to a chart on any of them.
|
|
11
|
+
*/
|
|
12
|
+
export const OPRA_UNDERLYING_EXCHANGES = [
|
|
13
|
+
'US_STOCKS',
|
|
14
|
+
'POLYGON',
|
|
15
|
+
'NYSE',
|
|
16
|
+
'NYSE_AMERICAN',
|
|
17
|
+
'NYSE_NATIONAL',
|
|
18
|
+
'NYSE_ARCA',
|
|
19
|
+
'NYSE_CHICAGO',
|
|
20
|
+
'NASDAQ',
|
|
21
|
+
'NASDAQ_BX',
|
|
22
|
+
'NASDAQ_ISE',
|
|
23
|
+
'NASDAQ_PHILADELPHIA',
|
|
24
|
+
'NASDAQ_PSX',
|
|
25
|
+
'NASDAQ_INT',
|
|
26
|
+
'CBOE',
|
|
27
|
+
'CBOE_EDGA',
|
|
28
|
+
'CBOE_EDGX',
|
|
29
|
+
'CBOE_BYX',
|
|
30
|
+
'CBOE_BZX',
|
|
31
|
+
'IEX',
|
|
32
|
+
'LTSE',
|
|
33
|
+
'MIAX_PEARL',
|
|
34
|
+
'MEMBERS_EXCHANGE',
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Index option roots on OPRA, listed by name (no underlying series on the chart): the directory, the logo
|
|
38
|
+
* choice and the session table read this list. What their chain carries (an underlying price, open
|
|
39
|
+
* interest, greeks) is read off the summary itself, never off this list.
|
|
40
|
+
*/
|
|
41
|
+
export const OPRA_INDEX_ROOTS = [
|
|
42
|
+
'SPX',
|
|
43
|
+
'SPXW',
|
|
44
|
+
'XSP',
|
|
45
|
+
'NDX',
|
|
46
|
+
'NDXP',
|
|
47
|
+
'RUT',
|
|
48
|
+
'RUTW',
|
|
49
|
+
'VIX',
|
|
50
|
+
'VIXW',
|
|
51
|
+
'DJX',
|
|
52
|
+
];
|
|
53
|
+
// Order is the provider rail order. A backend venue change is one row here.
|
|
54
|
+
export const OPTION_VENUES = [
|
|
55
|
+
{
|
|
56
|
+
id: 'cme',
|
|
57
|
+
labelKey: 'symbolSelection.optionVenues.cme',
|
|
58
|
+
exchanges: CME_BUNDLE_EXCHANGES,
|
|
59
|
+
lane: 'governed',
|
|
60
|
+
plane: 'cme',
|
|
61
|
+
gated: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
// US equity and index options: one consolidated venue over the OPRA gate, 15-minute delayed free
|
|
65
|
+
// for registered users. Contracts carry the compact OSI symbol (AAPL261016C00250000); the
|
|
66
|
+
// underlying is the stock's ticker, charted under US_STOCKS / POLYGON or a listing venue.
|
|
67
|
+
id: 'opra',
|
|
68
|
+
labelKey: 'symbolSelection.optionVenues.opra',
|
|
69
|
+
exchanges: OPRA_GOVERNED_EXCHANGES,
|
|
70
|
+
lane: 'governed',
|
|
71
|
+
plane: 'opra',
|
|
72
|
+
gated: true,
|
|
73
|
+
gate: 'opra',
|
|
74
|
+
underlyingKey: 'base',
|
|
75
|
+
underlyingExchanges: OPRA_UNDERLYING_EXCHANGES,
|
|
76
|
+
directory: 'search',
|
|
77
|
+
syntheticRoots: OPRA_INDEX_ROOTS,
|
|
78
|
+
greeksEstimated: true,
|
|
79
|
+
// opraExpiryUnix: the OSI date at its New York close, the instant the gateway lists the expiry under.
|
|
80
|
+
expiryInstants: true,
|
|
81
|
+
unavailableFields: ['settlementPrice', 'settlementDate'],
|
|
82
|
+
delayMinutes: OPRA_DELAY_MINUTES,
|
|
83
|
+
// The delayed tier re-reads the same quotes for 15 minutes; 3 s polls would only burn the reader.
|
|
84
|
+
chainPollMs: 15_000,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'deribit',
|
|
88
|
+
labelKey: 'symbolSelection.optionVenues.deribit',
|
|
89
|
+
exchanges: ['DERIBIT'],
|
|
90
|
+
lane: 'plain',
|
|
91
|
+
gated: true,
|
|
92
|
+
chainWindowSec: 30,
|
|
93
|
+
// Deribit has no StreamMarkets option rows until tsdb-gateway !2122; its chain RPCs serve these.
|
|
94
|
+
// Measured 2026-09-29: only BTC and ETH list coin-settled contracts beside the USDC ones.
|
|
95
|
+
knownUnderlyings: [
|
|
96
|
+
{ root: 'BTC', families: ['inverse', 'linear'] },
|
|
97
|
+
{ root: 'ETH', families: ['inverse', 'linear'] },
|
|
98
|
+
{ root: 'SOL', families: ['linear'] },
|
|
99
|
+
{ root: 'XRP', families: ['linear'] },
|
|
100
|
+
{ root: 'HYPE', families: ['linear'] },
|
|
101
|
+
{ root: 'AVAX', families: ['linear'] },
|
|
102
|
+
],
|
|
103
|
+
families: [{ family: 'inverse' }, { family: 'linear', quoteAsset: 'USDC' }],
|
|
104
|
+
liveSummary: true,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'binance-options',
|
|
108
|
+
labelKey: 'symbolSelection.optionVenues.binance-options',
|
|
109
|
+
exchanges: ['BINANCE_OPTIONS'],
|
|
110
|
+
lane: 'plain',
|
|
111
|
+
gated: true,
|
|
112
|
+
chainWindowSec: 120,
|
|
113
|
+
underlyingKey: 'assetTicker',
|
|
114
|
+
families: [{ family: 'linear', quoteAsset: 'USDT' }],
|
|
115
|
+
liveSummary: true,
|
|
116
|
+
chainPollMs: SLOW_VENUE_CHAIN_POLL_MS,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'okx-options',
|
|
120
|
+
labelKey: 'symbolSelection.optionVenues.okx-options',
|
|
121
|
+
exchanges: ['OKEX_OPTIONS'],
|
|
122
|
+
lane: 'plain',
|
|
123
|
+
gated: true,
|
|
124
|
+
chainWindowSec: 120,
|
|
125
|
+
families: [
|
|
126
|
+
{ family: 'inverse', quoteAsset: 'USD' },
|
|
127
|
+
{ family: 'linear', quoteAsset: 'USDT' },
|
|
128
|
+
],
|
|
129
|
+
liveSummary: true,
|
|
130
|
+
chainPollMs: SLOW_VENUE_CHAIN_POLL_MS,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 'bybit',
|
|
134
|
+
labelKey: 'symbolSelection.optionVenues.bybit',
|
|
135
|
+
exchanges: ['BYBIT'],
|
|
136
|
+
lane: 'plain',
|
|
137
|
+
gated: true,
|
|
138
|
+
chainWindowSec: 120,
|
|
139
|
+
families: [{ family: 'linear', quoteAsset: 'USDT' }],
|
|
140
|
+
liveSummary: true,
|
|
141
|
+
chainPollMs: SLOW_VENUE_CHAIN_POLL_MS,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'bullish',
|
|
145
|
+
labelKey: 'symbolSelection.optionVenues.bullish',
|
|
146
|
+
exchanges: ['BULLISH'],
|
|
147
|
+
lane: 'plain',
|
|
148
|
+
gated: true,
|
|
149
|
+
chainWindowSec: 120,
|
|
150
|
+
families: [{ family: 'linear', quoteAsset: 'USDC' }],
|
|
151
|
+
liveSummary: true,
|
|
152
|
+
chainPollMs: SLOW_VENUE_CHAIN_POLL_MS,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: 'derive',
|
|
156
|
+
labelKey: 'symbolSelection.optionVenues.derive',
|
|
157
|
+
exchanges: ['DERIVE'],
|
|
158
|
+
lane: 'plain',
|
|
159
|
+
gated: true,
|
|
160
|
+
chainWindowSec: 120,
|
|
161
|
+
families: [{ family: 'linear', quoteAsset: 'USDC' }],
|
|
162
|
+
liveSummary: true,
|
|
163
|
+
chainPollMs: SLOW_VENUE_CHAIN_POLL_MS,
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
/** The Options tab's Any exchange row: every provider on offer, browsed as one list. */
|
|
167
|
+
export const ANY_OPTION_VENUE = 'all';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const NoExchangeOverlays: string[];
|
|
2
|
+
export declare const FUNDING_INTERVAL_MAP: {
|
|
3
|
+
'1h': number;
|
|
4
|
+
'8h': number;
|
|
5
|
+
'24h': number;
|
|
6
|
+
'1y': number;
|
|
7
|
+
};
|
|
8
|
+
export declare const DEFAULT_4K_MAX_DEPTH = 3500;
|
|
9
|
+
export type OrderbookDepthAccess = 'full' | 'reduced';
|
|
10
|
+
/**
|
|
11
|
+
* Heatmap overlay types whose orderbook depth is tiered by the
|
|
12
|
+
* `fullOrderbookDepth` entitlement (full vs reduced depth tables below).
|
|
13
|
+
* Shared by the entitlement-flip resubscriber and the tier clamp.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEPTH_TIERED_HEATMAP_TYPES: Set<string>;
|
|
16
|
+
export declare const FULL_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS: {
|
|
17
|
+
'1s': number;
|
|
18
|
+
'1m': number;
|
|
19
|
+
'5m': number;
|
|
20
|
+
'15m': number;
|
|
21
|
+
'30m': number;
|
|
22
|
+
'1h': number;
|
|
23
|
+
'4h': number;
|
|
24
|
+
'1d': number;
|
|
25
|
+
'1w': number;
|
|
26
|
+
default: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const OPTIMAL_HD_DEPTH_LEVELS: {
|
|
29
|
+
'1s': number;
|
|
30
|
+
'1m': number;
|
|
31
|
+
'5m': number;
|
|
32
|
+
'15m': number;
|
|
33
|
+
'30m': number;
|
|
34
|
+
'1h': number;
|
|
35
|
+
'4h': number;
|
|
36
|
+
'1d': number;
|
|
37
|
+
'1w': number;
|
|
38
|
+
default: number;
|
|
39
|
+
};
|
|
40
|
+
export declare const REDUCED_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS: {
|
|
41
|
+
'1s': number;
|
|
42
|
+
'1m': number;
|
|
43
|
+
'5m': number;
|
|
44
|
+
'15m': number;
|
|
45
|
+
'30m': number;
|
|
46
|
+
'1h': number;
|
|
47
|
+
'4h': number;
|
|
48
|
+
'1d': number;
|
|
49
|
+
'1w': number;
|
|
50
|
+
default: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function getOptimalMaxDepth(interval: string | undefined, resolution?: 'HD' | '4K', access?: OrderbookDepthAccess): number;
|
|
53
|
+
export declare function scaleMaxDepth(baseMaxDepth: number, smallerThanPct?: number): number;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { EChartType } from '../enums/chart.enum.js';
|
|
2
|
+
import { standardIntervalAtOrBelow } from '../utility/chart/interval-registry.util.js';
|
|
3
|
+
export const NoExchangeOverlays = [
|
|
4
|
+
EChartType.MARKETCAP,
|
|
5
|
+
EChartType.MARKETCAP_AGG,
|
|
6
|
+
EChartType.AGGREGATED_DAILY_VOLUME,
|
|
7
|
+
EChartType.AGGREGATED_DAILY_VOLUME_AGG,
|
|
8
|
+
];
|
|
9
|
+
export const FUNDING_INTERVAL_MAP = {
|
|
10
|
+
'1h': 3600000,
|
|
11
|
+
'8h': 28800000,
|
|
12
|
+
'24h': 86400000,
|
|
13
|
+
'1y': 31536000000,
|
|
14
|
+
};
|
|
15
|
+
export const DEFAULT_4K_MAX_DEPTH = 3500;
|
|
16
|
+
/**
|
|
17
|
+
* Heatmap overlay types whose orderbook depth is tiered by the
|
|
18
|
+
* `fullOrderbookDepth` entitlement (full vs reduced depth tables below).
|
|
19
|
+
* Shared by the entitlement-flip resubscriber and the tier clamp.
|
|
20
|
+
*/
|
|
21
|
+
export const DEPTH_TIERED_HEATMAP_TYPES = new Set([
|
|
22
|
+
'ORDERBOOK_HEATMAP',
|
|
23
|
+
'AGGREGATED_ORDERBOOK_HEATMAP',
|
|
24
|
+
'HYPERLIQUID_LIQUIDATION_HEATMAP',
|
|
25
|
+
'HYPERLIQUID_TPSL_HEATMAP',
|
|
26
|
+
// Orderbook Depth asks for the single heatmap's tier value so both ride
|
|
27
|
+
// one shared ladder (resolveOrderbookDepthLadderMaxDepth); it re-resolves
|
|
28
|
+
// on the same entitlement flip.
|
|
29
|
+
'ORDERBOOK_DEPTH',
|
|
30
|
+
]);
|
|
31
|
+
export const FULL_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS = {
|
|
32
|
+
'1s': 100,
|
|
33
|
+
'1m': 750,
|
|
34
|
+
'5m': 1000,
|
|
35
|
+
'15m': 1500,
|
|
36
|
+
'30m': 1500,
|
|
37
|
+
'1h': 1500,
|
|
38
|
+
'4h': 1500,
|
|
39
|
+
'1d': 1800,
|
|
40
|
+
'1w': 1800,
|
|
41
|
+
default: 1750,
|
|
42
|
+
};
|
|
43
|
+
export const OPTIMAL_HD_DEPTH_LEVELS = FULL_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS;
|
|
44
|
+
export const REDUCED_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS = {
|
|
45
|
+
'1s': 100,
|
|
46
|
+
'1m': 250,
|
|
47
|
+
'5m': 500,
|
|
48
|
+
'15m': 500,
|
|
49
|
+
'30m': 500,
|
|
50
|
+
'1h': 500,
|
|
51
|
+
'4h': 500,
|
|
52
|
+
'1d': 750,
|
|
53
|
+
'1w': 750,
|
|
54
|
+
default: 500,
|
|
55
|
+
};
|
|
56
|
+
const ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS = {
|
|
57
|
+
full: FULL_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS,
|
|
58
|
+
reduced: REDUCED_ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS,
|
|
59
|
+
};
|
|
60
|
+
export function getOptimalMaxDepth(interval, resolution = 'HD', access = 'full') {
|
|
61
|
+
const depthLevels = ORDERBOOK_HEATMAP_HD_DEPTH_LEVELS[access];
|
|
62
|
+
const key = interval === undefined ? undefined : standardIntervalAtOrBelow(interval);
|
|
63
|
+
const hdDepth = depthLevels[key] || depthLevels.default;
|
|
64
|
+
// Full depth doubles the rows at 4K. Reduced (free) depth keeps the HD row
|
|
65
|
+
// count: free 4K loads the same rows as free HD over a narrower price band.
|
|
66
|
+
return resolution === '4K' && access === 'full' ? hdDepth * 2 : hdDepth;
|
|
67
|
+
}
|
|
68
|
+
const DEPTH_TIERS = [100, 250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500];
|
|
69
|
+
function snapToDepthTier(value) {
|
|
70
|
+
for (const tier of DEPTH_TIERS) {
|
|
71
|
+
if (value <= tier)
|
|
72
|
+
return tier;
|
|
73
|
+
}
|
|
74
|
+
return DEFAULT_4K_MAX_DEPTH;
|
|
75
|
+
}
|
|
76
|
+
export function scaleMaxDepth(baseMaxDepth, smallerThanPct) {
|
|
77
|
+
const raw = Math.min(DEFAULT_4K_MAX_DEPTH, Math.round(baseMaxDepth * Math.max(1, (smallerThanPct ?? 5) / 10)));
|
|
78
|
+
const snapped = snapToDepthTier(raw);
|
|
79
|
+
return snapped;
|
|
80
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Tracks per axis. The workspace document stores at most 4x4 tracks. */
|
|
2
|
+
export declare const MAX_PANE_GRID_DIM = 4;
|
|
3
|
+
/** Panes per layout (one pane per cell of a 4x4). */
|
|
4
|
+
export declare const MAX_PANE_GRID_PANES: number;
|
|
5
|
+
/** Discriminator of the geometry object stored in `multiCharts.layout`. Its
|
|
6
|
+
* presence makes a workspace document canonical (see pane-grid.util). */
|
|
7
|
+
export declare const PANE_GRID_LAYOUT_KIND = "pane-grid";
|
|
8
|
+
export declare const PANE_GRID_LAYOUT_VERSION = 1;
|
|
9
|
+
/** Smallest track a splitter drag may leave: the classic 20% for layouts of
|
|
10
|
+
* up to 4 panes, Monitor's 5% for denser grids. */
|
|
11
|
+
export declare const PANE_GRID_MIN_FRACTION_CLASSIC = 0.2;
|
|
12
|
+
export declare const PANE_GRID_MIN_FRACTION_DENSE = 0.05;
|
|
13
|
+
/** Column resolution of the 2x2's per-row dividers (the classic technique:
|
|
14
|
+
* each row places its two panes on a fine shared column grid). */
|
|
15
|
+
export declare const PANE_GRID_FINE_COLUMNS = 1000;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Pane-grid limits and wire constants. Store-free on purpose: the layout model,
|
|
2
|
+
// the budget policy and their node specs import this module directly.
|
|
3
|
+
/** Tracks per axis. The workspace document stores at most 4x4 tracks. */
|
|
4
|
+
export const MAX_PANE_GRID_DIM = 4;
|
|
5
|
+
/** Panes per layout (one pane per cell of a 4x4). */
|
|
6
|
+
export const MAX_PANE_GRID_PANES = MAX_PANE_GRID_DIM * MAX_PANE_GRID_DIM;
|
|
7
|
+
/** Discriminator of the geometry object stored in `multiCharts.layout`. Its
|
|
8
|
+
* presence makes a workspace document canonical (see pane-grid.util). */
|
|
9
|
+
export const PANE_GRID_LAYOUT_KIND = 'pane-grid';
|
|
10
|
+
export const PANE_GRID_LAYOUT_VERSION = 1;
|
|
11
|
+
/** Smallest track a splitter drag may leave: the classic 20% for layouts of
|
|
12
|
+
* up to 4 panes, Monitor's 5% for denser grids. */
|
|
13
|
+
export const PANE_GRID_MIN_FRACTION_CLASSIC = 0.2;
|
|
14
|
+
export const PANE_GRID_MIN_FRACTION_DENSE = 0.05;
|
|
15
|
+
/** Column resolution of the 2x2's per-row dividers (the classic technique:
|
|
16
|
+
* each row places its two panes on a fine shared column grid). */
|
|
17
|
+
export const PANE_GRID_FINE_COLUMNS = 1000;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kScript snippet helpers shared by every built-in template: the classic input set (source,
|
|
3
|
+
* timeframe, waitForClose), the candle and price series they read, the colour slot reader and the
|
|
4
|
+
* oscillator level / smoothing blocks. `technicalIndicatorScripts.constants.ts` (the classic
|
|
5
|
+
* built-ins) and `staples/*.constants.ts` (the TradingView staples) assemble their templates from
|
|
6
|
+
* these, so every built-in reads its inputs, candles and levels the same way. This module is
|
|
7
|
+
* i18n-free on purpose: the staple modules import it while the catalog module imports them, and a
|
|
8
|
+
* template module must never import the catalog.
|
|
9
|
+
*/
|
|
10
|
+
/** A built-in's compute input values as an alert bakes them: the overlay's value, else the template default. */
|
|
11
|
+
export interface BuiltinInputReader {
|
|
12
|
+
num(name: string): number;
|
|
13
|
+
str(name: string): string;
|
|
14
|
+
}
|
|
15
|
+
/** Shape of a `BUILTIN_ALERT_CONTRACTS` entry (see the catalog module for the contract rules). */
|
|
16
|
+
export interface BuiltinAlertContract {
|
|
17
|
+
/**
|
|
18
|
+
* Rule-addressable output labels in DECLARATION ORDER, measured against the real alerts
|
|
19
|
+
* engine (compile + plot-series extraction). These are the identity anchors the server
|
|
20
|
+
* re-anchors rules to: they must match the engine's labels VERBATIM (including the
|
|
21
|
+
* double-space in 'Lower Band'), never a display guess.
|
|
22
|
+
*/
|
|
23
|
+
outputs: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* Input names that change the COMPUTED series (feed the math). Only these bake into the
|
|
26
|
+
* armable source: renderer-only inputs (colors, width, smooth) must not alter the alert's
|
|
27
|
+
* identity, or a cosmetic edit would orphan the armed badge and duplicate alerts on re-arm.
|
|
28
|
+
*/
|
|
29
|
+
computeInputs: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Templates with a `timeframe` input: the CLOSED selected-timeframe bars the slowest output needs
|
|
32
|
+
* before it has a value, from the compute inputs. The alert engine keeps a fixed window of chart
|
|
33
|
+
* bars and recomputes it from scratch on every bar, so an alert on a selected timeframe declares
|
|
34
|
+
* this depth when it is baked (bakeBuiltinAlertSource); the parity specs pin each formula.
|
|
35
|
+
*/
|
|
36
|
+
htfWarmup?: (inputs: BuiltinInputReader) => number;
|
|
37
|
+
}
|
|
38
|
+
/** Extra closed bars the oscillator smoothing (OSCILLATOR_SMOOTHING_INPUTS) adds to its oscillator's warm-up. */
|
|
39
|
+
export declare function oscillatorSmoothingWarmup(inputs: BuiltinInputReader): number;
|
|
40
|
+
export declare const CLASSIC_TIMEFRAME_INPUTS = "var timeframe = input(name=\"timeframe\", type=\"select\", defaultValue=\"chart\", options=[\"chart\", \"5m\", \"15m\", \"30m\", \"1h\", \"4h\", \"1D\", \"1W\"]);\nvar waitForClose = input(name=\"waitForClose\", type=\"boolean\", defaultValue=true);";
|
|
41
|
+
export declare const CLASSIC_PRICE_INPUTS = "var source = input(name=\"source\", type=\"select\", defaultValue=\"close\", options=[\"close\", \"open\", \"high\", \"low\"]);\nvar timeframe = input(name=\"timeframe\", type=\"select\", defaultValue=\"chart\", options=[\"chart\", \"5m\", \"15m\", \"30m\", \"1h\", \"4h\", \"1D\", \"1W\"]);\nvar waitForClose = input(name=\"waitForClose\", type=\"boolean\", defaultValue=true);";
|
|
42
|
+
export declare const CLASSIC_PRICE_SERIES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = timeframe == \"chart\" ? field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source) : htf(field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source), timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"});";
|
|
43
|
+
export declare const CLASSIC_CANDLE_ROW = "func candleValues(bars) {\n return [bars.open, bars.high, bars.low, bars.close, bars.volume];\n}";
|
|
44
|
+
export declare const CLASSIC_CANDLE_SERIES = "func candleValues(bars) {\n return [bars.open, bars.high, bars.low, bars.close, bars.volume];\n}\ntimeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries data = timeframe == \"chart\" ? [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume] : candleValues(htf(chartData, timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"}));";
|
|
45
|
+
export declare const CLASSIC_SELECTED_CANDLES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = timeframe == \"chart\" ? field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source) : htf(field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source), timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"});\nfunc candleValues(bars) {\n return [bars.open, bars.high, bars.low, bars.close, bars.volume];\n}\ntimeseries candles = timeframe == \"chart\" ? [data.open, data.high, data.low, data.close, data.volume] : candleValues(htf(data, timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"}));\ntimeseries selectedCandles = [candles.open, candles.high, candles.low, price, candles.volume];";
|
|
46
|
+
/**
|
|
47
|
+
* Reads slot `index` of a script's `colors` input as saved, alpha included. The chart completes
|
|
48
|
+
* every saved palette to the built-in's full slot list before a run (completeBuiltinPalette in
|
|
49
|
+
* builtin-script-theme-palette.util), so the first-slot fallback only covers a caller that hands a
|
|
50
|
+
* shorter one. Both branches read the input, so they share its colour type, which plot colour
|
|
51
|
+
* arrays require (a string-literal fallback needed an opacity() wrap, and opacity() forced full
|
|
52
|
+
* alpha and read most colour names as grey).
|
|
53
|
+
*/
|
|
54
|
+
export declare function colorSlot(index: number): string;
|
|
55
|
+
/** Level inputs shared by the bounded oscillators. */
|
|
56
|
+
export declare function oscillatorLevelInputs(overbought: number, oversold: number): string;
|
|
57
|
+
/** Colour slot of the oscillator line on a bar: 0 inside the levels, 1 overbought, 2 oversold. */
|
|
58
|
+
export declare function oscillatorExtremeIndex(value: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Dashed overbought / oversold levels, a dotted midline, and the zone between them shaded in the
|
|
61
|
+
* oscillator's own colour. The zone is a box drawn on the last bar from the first bar to well past
|
|
62
|
+
* the last one: drawings carry no alert output and no legend entry, and the last-bar box rolls back
|
|
63
|
+
* and redraws on live ticks.
|
|
64
|
+
*/
|
|
65
|
+
export declare function oscillatorLevelsScript(zoneColor: string, midline: number): string;
|
|
66
|
+
export declare const OSCILLATOR_SMOOTHING_INPUTS = "var smoothingType = input(name=\"smoothingType\", type=\"select\", defaultValue=\"None\", options=[\"None\", \"SMA\", \"SMA + Bollinger Bands\", \"EMA\", \"RMA\", \"WMA\", \"VWMA\"], group=\"Smoothing\");\nvar smoothingLength = input(name=\"smoothingLength\", type=\"number\", defaultValue=14, constraints={min: 1, step: 1}, group=\"Smoothing\");\nvar bbStdDev = input(name=\"bbStdDev\", type=\"number\", defaultValue=2, constraints={min: 0, step: 0.1}, group=\"Smoothing\");";
|
|
67
|
+
export declare function oscillatorSmoothingScript(value: string, label: string, width: string, color: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Window and step functions over a history array (oldest first). The window functions read the
|
|
70
|
+
* LAST `p` entries and return na unless all of them are finite, like the strict builtins (sma, wma,
|
|
71
|
+
* stdev, highest, lowest); htfSum skips na and accepts a short window, like sum(). The step
|
|
72
|
+
* functions mirror the engine's seeding (the plain average of the first `p` finite values) and its
|
|
73
|
+
* exact update arithmetic, so a converted template matches the builtin bit for bit.
|
|
74
|
+
*/
|
|
75
|
+
export declare const HTF_WINDOW_FUNCS = "func htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}";
|
|
76
|
+
/**
|
|
77
|
+
* The selected timeframe's closed and forming candles, materialized ONCE at init (a direct htf()
|
|
78
|
+
* of the source runs in init; the "1Y" placeholder only keeps the calls valid in chart mode, which
|
|
79
|
+
* never reads them), and `htfClosed`: true on the chart bar right after a selected-timeframe bar
|
|
80
|
+
* closed. Rolling tokens compare the engine's own epoch-floor bucket of consecutive chart bars;
|
|
81
|
+
* calendar tokens (1D / 1W) fall back to "the closed candle changed". Requires the `timeframe`
|
|
82
|
+
* input (CLASSIC_TIMEFRAME_INPUTS).
|
|
83
|
+
*/
|
|
84
|
+
export declare const HTF_SELECTED_TIMEFRAME = "func htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);";
|
|
85
|
+
/**
|
|
86
|
+
* Candle templates: `data` is the chart's own candles in every mode (chart mode reads it exactly as
|
|
87
|
+
* CLASSIC_CANDLE_SERIES did), and the selected timeframe is read from htfClosedCandle /
|
|
88
|
+
* htfFormingCandle (`.high[0]`, `.volume[0]`, ...). Replaces CLASSIC_CANDLE_SERIES.
|
|
89
|
+
*/
|
|
90
|
+
export declare const HTF_CANDLE_SERIES = "timeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries data = [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume];\nfunc htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);";
|
|
91
|
+
/**
|
|
92
|
+
* Price templates: `data` and `price` as CLASSIC_PRICE_SERIES declares them in chart mode, plus
|
|
93
|
+
* the selected price read from the SELECTED candle (open / high / low / close of the closed and of
|
|
94
|
+
* the forming selected-timeframe bar). Requires CLASSIC_PRICE_INPUTS. Replaces CLASSIC_PRICE_SERIES.
|
|
95
|
+
*/
|
|
96
|
+
export declare const HTF_PRICE_SERIES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source);\nfunc htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);\nvar htfClosedPrice = source == \"open\" ? htfClosedCandle.open[0] : source == \"high\" ? htfClosedCandle.high[0] : source == \"low\" ? htfClosedCandle.low[0] : htfClosedCandle.close[0];\nvar htfFormingPrice = source == \"open\" ? htfFormingCandle.open[0] : source == \"high\" ? htfFormingCandle.high[0] : source == \"low\" ? htfFormingCandle.low[0] : htfFormingCandle.close[0];";
|
|
97
|
+
/**
|
|
98
|
+
* OHLCV templates that use the selected price as close: `selectedCandles` as CLASSIC_SELECTED_CANDLES
|
|
99
|
+
* declares it in chart mode; the selected timeframe reads htfClosedCandle / htfFormingCandle with
|
|
100
|
+
* htfClosedPrice / htfFormingPrice as the close. Replaces CLASSIC_SELECTED_CANDLES.
|
|
101
|
+
*/
|
|
102
|
+
export declare const HTF_SELECTED_CANDLES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source);\nfunc htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);\nvar htfClosedPrice = source == \"open\" ? htfClosedCandle.open[0] : source == \"high\" ? htfClosedCandle.high[0] : source == \"low\" ? htfClosedCandle.low[0] : htfClosedCandle.close[0];\nvar htfFormingPrice = source == \"open\" ? htfFormingCandle.open[0] : source == \"high\" ? htfFormingCandle.high[0] : source == \"low\" ? htfFormingCandle.low[0] : htfFormingCandle.close[0];\ntimeseries selectedCandles = [data.open, data.high, data.low, price, data.volume];";
|
|
103
|
+
/**
|
|
104
|
+
* A persist history of `closedValue`, appended once per closed selected-timeframe bar (na values
|
|
105
|
+
* are skipped, so a derived value's warm-up leaves no hole) and capped at `cap` entries, oldest
|
|
106
|
+
* first. `cap` is a kScript expression (`period`, `period + 1`, `slowPeriod`). An offset history
|
|
107
|
+
* passes `keepNa`: one entry per closed bar, na included, so `htfValueBack(history, offset)` counts
|
|
108
|
+
* selected-timeframe bars like `series[offset]` and an undefined value stays undefined instead of
|
|
109
|
+
* repeating the bar before it.
|
|
110
|
+
*/
|
|
111
|
+
export declare function htfHistory(name: string, closedValue: string, cap: string | number, keepNa?: boolean): string;
|
|
112
|
+
/**
|
|
113
|
+
* The values a window reads: the closed history alone when waitForClose is on, the history plus
|
|
114
|
+
* `formingValue` (the forming selected-timeframe bar) when it is off.
|
|
115
|
+
*/
|
|
116
|
+
export declare function htfWindow(history: string, formingValue: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Recursive smoothing (EMA or RMA / Wilder) over closed selected-timeframe values. Declares the
|
|
119
|
+
* persist state (`<name>Closed`, `<name>Count`, `<name>Seed`), steps it once per closed bar with
|
|
120
|
+
* `closedValue`, and declares `var <name>`: the committed value when waitForClose is on, otherwise
|
|
121
|
+
* a provisional step with `formingValue` that is never committed. `closedValue` must be finite once
|
|
122
|
+
* it starts (leading na only), like the builtins' own seeding. Chain them by feeding one state's
|
|
123
|
+
* `<name>Closed` / `<name>` into the next (MACD's signal line, ATR from a true range).
|
|
124
|
+
*/
|
|
125
|
+
export declare function htfSmoothedState(name: string, kind: 'ema' | 'rma', closedValue: string, formingValue: string, period: string | number): string;
|
|
126
|
+
/**
|
|
127
|
+
* oscillatorSmoothingScript for a converted oscillator: chart mode smooths `value` with the
|
|
128
|
+
* builtins exactly as before; the selected timeframe smooths the oscillator's own closed values
|
|
129
|
+
* (`closedValue`, read on the bar a selected-timeframe bar closed) plus `formingValue` when
|
|
130
|
+
* waitForClose is off, weighted by the selected timeframe's volume for VWMA. Requires
|
|
131
|
+
* OSCILLATOR_SMOOTHING_INPUTS and one of the HTF_*_SERIES blocks.
|
|
132
|
+
*/
|
|
133
|
+
export declare function htfOscillatorSmoothingScript(value: string, closedValue: string, formingValue: string, label: string, width: string, color: string): string;
|