Skip to main content

ferrochart

Fast financial charts for Python, written in Rust. Renders on the GPU (Metal, Vulkan, DirectX 12) with a CPU fallback, in a native window, in Jupyter or to PNG.

  • Millions of bars: pans and zooms at full frame rate.
  • Candlestick, OHLC, Heikin-Ashi, line, area, baseline, histogram, points and volume series; Renko, range bars, Kagi and point & figure; multiple panes; price lines and markers; normal, logarithmic, percentage and indexed price scales.
  • 30 built-in indicators (ferrochart.indicator_names()), updated incrementally.
  • 29 drawing tools (trend lines, channels, Fibonacci tools, pitchforks, Gann fans, patterns, Elliott waves, paths, brushes, texts…) with undo and redo; save and restore the view, layout and drawings as JSON.
  • Takes pandas or polars DataFrames, or dicts of NumPy arrays.
pip install ferrochart              # windows and PNG
pip install "ferrochart[jupyter]"   # also the Jupyter widget

One wheel per platform serves Python 3.10 and later.

Quick start

import ferrochart as fc

chart = fc.Chart(theme="dark", width=1200, height=700)
candles = chart.add_series("candlestick")
candles.set_data(df)                 # columns time, open, high, low, close[, volume]
chart.add_volume_series(candles)
chart.add_indicator(candles, "ema", n=20)
chart.add_indicator(candles, "macd")  # in a new pane

chart.show()                         # a window; returns when it is closed
chart.to_png("chart.png")            # offscreen, GPU or CPU
chart                                # in Jupyter: an interactive chart

time is a datetime64 column (naive times are UTC) or integer milliseconds; a pandas DatetimeIndex is used when there is no time column. Line, area, baseline, histogram and points series take time and value, and optionally color per point.

Real-time data

candles.update_last(t, open=o, high=h, low=l, close=c, volume=v)  # same time: update, later: new bar
candles.append(new_bars)

Indicators follow the data. Changes made while the chart is shown are drawn at once, including changes from other threads.

Options, indicators and drawings

Options and parameters are keyword arguments; unknown names raise ValueError.

line = chart.add_series("line", color="#ff9800", line_width=2)
candles.apply_options(down_color="#e91e63")
candles.create_price_line(101.5, title="target", line_style="dashed")
candles.set_markers([{"time": t, "position": "below_bar", "shape": "arrow_up", "text": "buy"}])
chart.apply_price_scale_options(mode="logarithmic")

rsi = chart.add_indicator(candles, "rsi", n=14)
boll = chart.add_indicator(candles, "boll", n=20, k=2)

bricks = fc.Chart()                  # a transform series is the only series of its chart
renko = bricks.add_transform_series("renko", box_size=2.0)
renko.set_data(df)                   # OHLC bars in, Renko bricks drawn

d = chart.drawings
trend = d.add("trend_line", [(t0, 100.0), (t1, 120.0)], style={"line": "#e91e63", "line_width": 2})
d.add("fib_retracement", [(t0, 90.0), (t1, 130.0)], params={"levels": [0, 0.382, 0.618, 1]})
d.start_tool("rectangle")            # the next clicks in the window draw one
d.undo()

import json
saved = json.dumps(chart.save_state())   # view, panes, price scales, drawings
chart.load_state(json.loads(saved))      # on a chart set up the same way

Events

@chart.on("click")
def clicked(e):
    print(e["time"], e["price"], e["target"])

chart.on("crosshair_move", lambda e: print(e["point"]))

Events: click, crosshair_move, visible_range_changed, need_more_history, drawing_created, drawing_modified, drawing_removed, drawing_selected, warning. Callbacks run on the main thread while the chart is shown.

Windows

chart.show() blocks until the window is closed and can be called again. It must run on the main thread. On Linux and Windows, chart.show(block=False) opens the window from a background thread and returns at once; event callbacks then run on the main thread between Python statements, or when you call ferrochart.process_events(). The first show of a process fixes the mode.

In the window: drag to pan, wheel or pinch to zoom, drag an axis to scale it, double-click an axis to reset it. With a tool started, click to place anchors; Esc cancels, Delete removes the selected drawing, Ctrl/⌘+Z undoes.

Jupyter

A chart that is the last expression of a cell is shown as an interactive widget (with ferrochart[jupyter]; a PNG otherwise). Later changes, such as new bars, reach every view of it. chart.widget() returns the widget, for example to put it in an ipywidgets layout.

Plots

ferrochart.Plot draws lines, areas, scatter, bars, waterfalls and heatmaps on numeric, category or date axes. It is shown the same three ways as a chart: plot.show(), the last expression of a notebook cell, or plot.to_png().

import ferrochart as fc

plot = fc.Plot(width=640, height=400)
plot.axis("x").apply_options(type="category")
plot.axis("x").set_categories(["north", "south", "east"])
plot.add_mark("bars", [4, 6, 5], color="#2196f3")
plot.add_mark("line", {"x": [0, 1, 2], "y": [3, 5.5, 4.5]}, line_width=2)
plot.add_rule(5, label="target", line_style="dashed")
plot.add_label(1, 6, "best", icon="arrow_down")

@plot.on("click")
def clicked(e):
    if e["hit"]:
        print(e["hit"]["mark"], e["hit"]["index"], e["hit"]["y"])

plot.to_png("plot.png")

set_data takes a DataFrame or dict with columns x, y and optional y0, value (colored by the mark's color scale), size, color, step (waterfalls) and label; a pandas Series (x from its index); a list or array of y values; or keywords: mark.set_data(x=xs, y=ys). Datetimes in x work with plot.axis("x").apply_options(format="date"). Events: hover, click, view_change.

License

Apache-2.0.

Metadata

Release files for ferrochart 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for ferrochart 0.3.0
File Actions
ferrochart-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for ferrochart-0.3.0-cp310-abi3-win_amd64.whl
ferrochart-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for ferrochart-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ferrochart-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for ferrochart-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ferrochart-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for ferrochart-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
ferrochart-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for ferrochart-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 24.7 MB

Release files / ferrochart-0.3.0-cp310-abi3-win_amd64.whl

Download URL ferrochart-0.3.0-cp310-abi3-win_amd64.whl
Size 5.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8c7dc2e6a413389e50daa8b4a572d73c714f8c94dbbc7d9fc23eb817e890d32d
BLAKE2b-256 checksum
How to use checksums
294df81a93176e459a0a4198accce9347d73765cba5219f2cbdb656bc0501553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.12

Release files / ferrochart-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ferrochart-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 5.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
cae3ebd820dae39f2bce0356faaea40989868a46e390c88a82c9f53f48c5c776
BLAKE2b-256 checksum
How to use checksums
ee2a4341772bc6a40f73e81b9fd4f9b5e47021ca22aacca3e335eba9bbebe118
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.12

Release files / ferrochart-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ferrochart-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 5.4 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5ad6f846bb0803c3299493ab30d87c9799feb5978e99a15ef3d2b5addc33730a
BLAKE2b-256 checksum
How to use checksums
2731f66864c46311749b08568e9f4c893057c5c82cad25abc26dd230e5bbb697
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.12

Release files / ferrochart-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL ferrochart-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 4.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
32f9345705746cdacb845420fd35d8212a38b05907ca06c4918ccb1f6c0f630c
BLAKE2b-256 checksum
How to use checksums
1b320c983966203cfda2abe2752f4e61d44c7d950b376b5d4d799da21e43ae2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.12

Release files / ferrochart-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ferrochart-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 4.5 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b3878de4eecfe059b53f5742dc28a11b19655bfee79d3d03cedbe218f626091a
BLAKE2b-256 checksum
How to use checksums
81b650f6cf6ae672e670646379d8db93d5c979b374d34449cf92d08774dde4c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.12

Security for ferrochart 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page