Order from the price axis

Open-source charting engine

Order from the price axis

Orders from the price axis, as a paper simulation on replayed bars. The "+" beside the price axis or a right click offers the limit and stop orders that make sense at that price, the buy and sell buttons trade at market at the bid and ask, and Ladder splits one quantity into five buy limits. Each order is a line until the replayed price reaches it, then a fill marker; the engine sends nothing anywhere.

Apache-2.0

Order from the price axis: Execution & trade review example

createOrderButton · createQuickTrade · ladderOrders · createTradingLines · tradeMarkers

Code
import { FerroChart } from '@ferrochart/core';
import { createTradingLines, createOrderButton, createQuickTrade, ladderOrders, tradeMarkers } from '@ferrochart/core/trading';

const canvas = document.querySelector('canvas');
// Market data: the synthetic FerroChart demo API. Use your own feed.
const chart = await FerroChart.create(canvas, { theme: 'dark' });
const bars = await fetch('/api/bars?symbol=BTCUSD&interval=15m&count=400').then((r) => r.json());
// Bar replay with setData and update: all but the last 40 bars, then each
// step() moves the forming bar a little; it closes on its 4th tick. At the end
// of the data the replay starts over (restart() resets the example).
const n = bars.time.length, START = n - 40, TICKS = 4;
const head = (k) => Object.fromEntries(Object.entries(bars).map(([key, v]) => [key, v.slice(0, k)]));
const candles = chart.addCandlestickSeries();
candles.setData(head(START));
let next = START, tick = 0, forming = null;
function step() {
  if (next === n) { next = START; candles.setData(head(START)); restart(); }
  const i = next, t = ++tick, closed = t === TICKS, o = bars.open[i];
  const noise = (Math.random() - 0.5) * (bars.high[i] - bars.low[i]) * 0.5;
  const price = closed ? bars.close[i] : Math.round((o + (bars.close[i] - o) * t / TICKS + noise) * 10) / 10;
  if (t === 1) forming = { time: bars.time[i], open: o, high: o, low: o };
  forming = { ...forming, high: Math.max(forming.high, price), low: Math.min(forming.low, price), close: price, volume: bars.volume[i] * t / TICKS };
  candles.update(forming);
  if (closed) { next++; tick = 0; }
  return { time: bars.time[i], price, closed };
}
chart.setVisibleLogicalRange(START - (canvas.clientWidth < 480 ? 30 : 60), n + 3);
// Room above the bars for the buttons, and below them for buy orders.
chart.applyPriceScaleOptions({ margins: { top: 0.24, bottom: 0.16 } });
// Paper trading: orders "fill" in this page against the replayed price and go
// nowhere else. A real page sends each intent to its own server here.
const answer = () => new Promise((r) => setTimeout(r, 250)); // the server's reply
let now = { time: bars.time[START - 1], price: bars.close[START - 1] };
const quote = () => ({ bid: now.price - 2.5, ask: now.price + 2.5 });
const ui = (tag, css, parent = canvas.parentElement) => parent.appendChild(Object.assign(document.createElement(tag), { style: css }));
const bar = ui('div', 'position:absolute;left:12px;right:84px;top:60px;display:flex;flex-wrap:wrap;gap:8px;align-items:center;z-index:2;pointer-events:none');
const ladder = ui('button', 'font:600 12px system-ui;color:#fff;background:#2962ff;border:0;border-radius:5px;padding:6px 12px;cursor:pointer;pointer-events:auto', bar);
ladder.textContent = 'Ladder';
const note = ui('span', 'font:500 12px system-ui;color:#8b93a7;flex:1 1 150px', bar);
const say = (text) => { note.textContent = `Paper trading · ${text}`; };
say('Right-click the chart, or use the + beside the price axis.');

// Open orders are lines; a fill removes the line and adds a marker.
const lines = createTradingLines(chart, candles);
const orders = new Map(), fills = [];
let seq = 0;
const label = (o) => `${o.side === 'buy' ? 'Buy' : 'Sell'} ${o.type} ${o.quantity}`;
const place = (o) => { orders.set(++seq, o); lines.set({ id: seq, kind: 'order', price: o.price, title: label(o) }); };
const show = () => candles.setMarkers(tradeMarkers(fills, { times: bars.time }));
const fill = (side, price, quantity) => { fills.push({ time: now.time, side, price, quantity }); show(); };

// Market orders at the bid or ask; the second click confirms.
const quick = createQuickTrade(chart, {
  canvas, quantity: 0.1, quantityStep: 0.001, priceStep: 0.5,
  async onOrder({ side, quantity }) {
    await answer();
    const price = side === 'buy' ? quote().ask : quote().bid;
    fill(side, price, quantity);
    say(`${side === 'buy' ? 'Bought' : 'Sold'} ${quantity} at ${price}.`);
  },
});
// Limit and stop orders at a price: the "+" or a right click.
const button = createOrderButton(chart, candles, {
  canvas, priceStep: 0.5, lastPrice: () => now.price, quantity: () => quick.quantity,
  async onOrder(o) {
    await answer();
    place(o);
    say(`${label(o)} at ${o.price} placed.`);
  },
});
// Five buy limits below the market, larger the farther they are.
ladder.onclick = () => {
  const p = now.price;
  for (const o of ladderOrders({ side: 'buy', from: p * 0.997, to: p * 0.989, count: 5, total: 1, distribution: 'linear', priceStep: 0.5, quantityStep: 0.01 })) place(o);
  say('Ladder of 5 buy limits placed.');
};

// Two earlier trades and an open order to start with.
fills.push({ time: bars.time[START - 30], side: 'buy', price: bars.close[START - 30], quantity: 0.2 },
  { time: bars.time[START - 12], side: 'sell', price: bars.close[START - 12], quantity: 0.2 });
show();
place({ side: 'sell', type: 'limit', price: Math.round(now.price * 1.004), quantity: 0.1 });
quick.setQuote(quote());

function restart() { fills.length = 0; show(); }
const timer = setInterval(() => {
  now = step();
  quick.setQuote(quote());
  for (const [id, o] of orders) {
    // Buy limits and sell stops fill at or below their price, the others at or above.
    const down = (o.type === 'limit') === (o.side === 'buy');
    if (down ? now.price > o.price : now.price < o.price) continue;
    const price = o.type === 'limit' ? o.price : now.price;
    orders.delete(id);
    lines.remove(id);
    fill(o.side, price, o.quantity);
    say(`${label(o)} filled at ${price}.`);
  }
}, 600);

// The page calls this before it destroys the chart.
const stop = () => { clearInterval(timer); button.destroy(); quick.destroy(); lines.destroy(); bar.remove(); };

Built for tick-level data.

Apple M4 Max · Chrome + WebGPU

Load 1 million bars and draw the first frame in the browser

WASM · WebGPU

Load 10 million bars natively, level-of-detail pyramid included

native Rust

Heap allocations per frame while panning, zooming and streaming

steady state

WebAssembly package size, gzip

all features

Browser figures: Google Chrome with WebGPU; the 10 million bar load is native Rust. Bars show each figure against its target: 300 ms for a load, no allocations, 1.5 MB for the package.

Examples

320 examples
across 20 use cases.

Each example is a live chart rendered by FerroChart in your browser, with its source code alongside. All data is synthetic.

Bar replay
Real-time stream
Candlesticks + volume
01

Price action

28 examples →

Candles, bars and lines for any market, streaming in real time.

Depth heatmap
Delta footprint
Footprint
04

Order flow

20 examples →

Footprint, depth heatmap and market profile, on a compute-shader path.

Implied volatility · basis
Long/short ratio · CVD
Funding · open interest · liquidations
06

Crypto derivatives

15 examples →

Funding, open interest, liquidations and basis in panes under price.

Risk reversal · butterfly
Expected move to expiry
Implied vs realised vol · IV rank
12

Options & volatility

18 examples →

Implied against realised, skew, expected moves and dealer exposure in time.

Joint drawdowns
Underwater curve · worst drawdown
Equity curve · drawdown
16

Portfolio, risk & quant

24 examples →

Equity curves, drawdowns, rolling statistics, factor research and risk checks.

Grouped columns
Stacked columns
100% stacked area
19

Custom series & plugins

11 examples →

Stacked, grouped, box and brushed series: layer plugins on the same GPU frame.

Browse all 20 use cases

Price action

Bar types & transforms

Technical analysis

Order flow

Execution & trade review

Crypto derivatives

On-chain

DeFi & AMMs

Memecoins & wallets

Equities & fundamentals

China A-shares

Options & volatility

Rates, FX & macro

Futures & commodities

Funds & ETFs

Portfolio, risk & quant

Private markets & personal finance

Prediction markets

Custom series & plugins

Labs & flagships

Features

Designed for market data.

01

Cross-platform rendering

A single Rust core with WebGPU and WebGL2 backends in the browser, wgpu on Metal, Vulkan and DirectX 12 in native applications, and a CPU renderer for servers. Golden-image tests keep the backends consistent.

02

Performance independent of data size

Bar data stays on the GPU and coordinate transforms run in shaders, so panning and zooming update only a few uniforms. A level-of-detail pyramid keeps tens of millions of bars responsive.

03

30 built-in indicators

Moving averages, channels and oscillators from SMA to Ichimoku. Values are updated incrementally on each tick and tested against reference data.

04

29 drawing tools

Trend lines, channels, Fibonacci tools, pitchforks, Gann fans, patterns, Elliott waves, ranges, positions and text, with undo and redo. Drawings and chart state serialize to JSON.

05

Synchronized charts

Sync groups link the crosshair and the visible range across multiple charts.

06

Extensible

Plugin interfaces for custom series, layers and drawing tools. Bindings for JavaScript, Rust and Python, and a C ABI for C#, C++, Qt and Flutter.

Get started

One API in every language.

Every binding follows the same model: create a chart, add series, set data and add indicators. Data is passed as columns, from typed arrays, Rust slices or DataFrames.

  • JavaScript & TypeScript
  • Rust
  • Python & Jupyter
  • C, C#, C++
Read the documentation
main.js
$ npm install @ferrochart/core
import { FerroChart } from '@ferrochart/core';

const chart = await FerroChart.create(canvas, { theme: 'dark' });
const candles = chart.addCandlestickSeries();
chart.addVolumeSeries(candles);
candles.setData(bars); // [{ time, open, high, low, close, volume }, ...]
chart.addIndicator(candles, 'ema', { n: 20 });
chart.addIndicator(candles, 'macd'); // in a new pane

FerroChart

Every market.
Every screen.
One engine.

Open source under Apache-2.0, from the browser to the trading desk.