Skip to content

feat: display liquidation price line on trading chart (fixes #7)#205

Open
jiangyj545 wants to merge 2 commits into
capofficial:mainfrom
jiangyj545:fix/liquidation-price-chart-7
Open

feat: display liquidation price line on trading chart (fixes #7)#205
jiangyj545 wants to merge 2 commits into
capofficial:mainfrom
jiangyj545:fix/liquidation-price-chart-7

Conversation

@jiangyj545
Copy link
Copy Markdown

Summary

Fixes #7: Add optional liquidation price display on the trading chart as a dashed red price line.

Problem

Users can see orders and positions on the chart, but cannot visualize their liquidation price — a critical risk metric.

Solution

Added a "Liquidation price on chart" toggle in Account Settings (default: off). When enabled:

  • Each open position shows a dashed red line at its liquidation price
  • Line displays "⚠ LIQ {price}" as the axis label
  • Only shows for positions in the currently selected market
  • Follows the same pattern as existing showOrdersOnChart/showPositionsOnChart

Changes

File Change
src/lib/stores.js Add showLiqPriceOnChart writable store (default: false)
src/lib/chart.js Add loadLiqPriceLines() + clearLiqPriceLines() using createPriceLine() with dashed red style
src/components/modals/Settings.svelte Add checkbox toggle, wire up settings persistence

Technical Details

  • Uses lightweight-charts createPriceLine() API (same as orders/positions)
  • Line style: LineStyle.Dashed, color: #FF2D00 (red), lineWidth: 1
  • Filters by selectedMarket — only shows liq prices for visible market
  • Skips positions without valid liqprice
  • Settings persisted via saveUserSetting() / localStorage

Build verified: npx rollup -c

Hermes Admin added 2 commits May 25, 2026 12:09
…ial#7)

- Add showLiqPriceOnChart setting (default: off, toggle in Settings)
- Show dashed red price line at liquidation price per position
- Uses lightweight-charts createPriceLine with axis label
- Filters by selected market, skips positions without liqprice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display liquidation price on chart

1 participant