function bindMarketEvents() {
  document.querySelector("#globalSearchButton").addEventListener("click", openGlobalSearch);
  document.querySelector("#closeGlobalSearch").addEventListener("click", closeGlobalSearch);
  document.querySelector("#closeEntityDetail").addEventListener("click", () => elements.entityDetailDialog.close());
  document.querySelectorAll("[data-entity-detail-chart]").forEach((button) => {
    button.addEventListener("click", () => selectEntityDetailChart(button.dataset.entityDetailChart));
  });
  elements.globalSearchDialog.addEventListener("click", (event) => {
    if (event.target === elements.globalSearchDialog) closeGlobalSearch();
  });
  elements.globalSearchInput.addEventListener("input", scheduleGlobalSearch);
  elements.globalSearchInput.addEventListener("keydown", handleGlobalSearchInputKeydown);
  elements.globalSearchResults.addEventListener("click", (event) => {
    const result = event.target.closest("[data-search-result-index]");
    if (result) openGlobalSearchResult(number(result.dataset.searchResultIndex));
  });
  document.querySelector("#closeStockDialog").addEventListener("click", () => elements.stockDialog.close());
  document.querySelectorAll("[data-stock-detail-chart]").forEach((button) => {
    button.addEventListener("click", () => selectStockDetailChart(button.dataset.stockDetailChart));
  });
  document.querySelector("#closeStockPreview").addEventListener("click", closeStockPreview);
  elements.stockPreviewBackdrop.addEventListener("click", closeStockPreview);
  document.querySelector("#openStockDetailFromPreview").addEventListener("click", openStockDetailFromPreview);
  document.querySelectorAll("[data-preview-chart]").forEach((button) => {
    button.addEventListener("click", () => selectStockPreviewChart(button.dataset.previewChart));
  });
  elements.stockPreview.addEventListener("pointerenter", cancelStockPreviewClose);
  elements.stockPreview.addEventListener("pointerleave", scheduleStockPreviewClose);
  document.addEventListener("pointerover", handleStockPreviewPointerOver);
  document.addEventListener("pointerout", handleStockPreviewPointerOut);
  document.addEventListener("focusin", handleStockPreviewFocus);
  document.addEventListener("focusout", handleStockPreviewFocusOut);
  document.addEventListener("click", handleMobileStockPreviewClick, true);
  document.addEventListener("keydown", handleStockPreviewKeydown);
  document.addEventListener("scroll", repositionStockPreview, true);
  window.addEventListener("keydown", handleGlobalSearchShortcut);
  window.addEventListener("resize", () => {
    if (!elements.stockPreview.hidden) closeStockPreview();
  });
}
