Skip to main content

freshmeat-heikinashi

Fast Heikin-Ashi candle computation with Numba JIT acceleration.

A drop-in replacement for technical.candles.heikinashi() and qtpylib.indicators.heikinashi() — same formula, hundreds to thousands of times faster.

Why?

The standard Heikin-Ashi implementations in the Python trading ecosystem use pure-Python for loops or list comprehensions over pandas DataFrames. The recursive nature of ha_open (each bar depends on the previous bar) makes vectorization impossible with plain NumPy/pandas.

freshmeat-heikinashi solves this by compiling the loop with Numba JIT, achieving native-code speed while keeping a pure-Python API.

Installation

pip install freshmeat-heikinashi

Requirements: Python 3.10+, NumPy, pandas, Numba.

Usage

DataFrame API

from freshmeat_heikinashi import heikinashi

ha = heikinashi(df)  # df must have open/high/low/close columns
# Returns a new DataFrame with HA open/high/low/close

NumPy array API

from freshmeat_heikinashi import heikinashi_arrays

ha_open, ha_high, ha_low, ha_close = heikinashi_arrays(
    open_prices, high_prices, low_prices, close_prices,
)

Freqtrade strategy

from freshmeat_heikinashi import heikinashi

class MyStrategy(IStrategy):
    def populate_indicators(self, dataframe, metadata):
        ha = heikinashi(dataframe)
        dataframe["ha_open"] = ha["open"]
        dataframe["ha_high"] = ha["high"]
        dataframe["ha_low"] = ha["low"]
        dataframe["ha_close"] = ha["close"]
        return dataframe

Correctness

Output is verified to be bit-identical (within 1e-10 tolerance) to both technical.candles.heikinashi() and qtpylib.indicators.heikinashi() across 1k, 10k, and 100k row datasets:

pytest tests/test_benchmark.py -k "TestCorrectnessVsTechnical" -v

Benchmark

Latest local pytest-benchmark result on 100,000 OHLC rows (min time):

Implementation Min time Relative
freshmeat-heikinashi (Numba) 1.65 ms 1x
technical.candles.heikinashi (list comp) 423.50 ms 256x slower
qtpylib.indicators.heikinashi (for loop) 2,239.60 ms 1,354x slower

The absolute values are machine-dependent, but the speedup pattern is consistent.

Run the benchmarks yourself:

# pytest-benchmark (grouped comparison)
pytest tests/test_benchmark.py -v

# CLI script
python benchmarks/bench_heikinashi.py --rows 100000

Documentation

  • Heikin-Ashi Formula — step-by-step formula explanation with worked example, lookahead safety analysis.
  • Implementation Comparison — detailed source code comparison of qtpylib, technical.candles, and freshmeat-heikinashi with full benchmark tables.

Status

Experimental. This project is under active development. The API may change without notice between minor versions until 1.0.

Disclaimer

This software is provided for educational and research purposes only. It is not financial advice. The authors make no guarantees regarding the accuracy, reliability, or suitability of this software for any particular purpose, including but not limited to live trading.

Use at your own risk. The authors accept no responsibility or liability for any financial losses, trading losses, damages, or other consequences — direct or indirect — arising from the use of this software. This includes, without limitation, any commercial or trading losses incurred through live, paper, or backtested trading operations. Always validate outputs independently before making any trading decisions.

License

Apache License 2.0

Metadata

Release files for freshmeat-heikinashi 0.1.1

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

Source distribution (sdist)

Source distribution for freshmeat-heikinashi 0.1.1
File Size Uploaded
freshmeat_heikinashi-0.1.1.tar.gz 19.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for freshmeat-heikinashi 0.1.1
File Interpreter ABI Platform
freshmeat_heikinashi-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 kB

Release files / freshmeat_heikinashi-0.1.1.tar.gz

Download URL freshmeat_heikinashi-0.1.1.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a4b6abf9bdffe278408b4a11ce08efba6cbf5c8c59db6b48fa08e24c9229ddd2
BLAKE2b-256 checksum
How to use checksums
3890ead969b1bda3e805eca33e1278fd50254610942d59bffd2c19d3f96ed23b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.

Transparency log

Release files / freshmeat_heikinashi-0.1.1-py3-none-any.whl

Download URL freshmeat_heikinashi-0.1.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69fe89ac7578fe9f00abb71379f0159730e90c03b09f89bac53b3efed5480373
BLAKE2b-256 checksum
How to use checksums
56212cb66bf21a5e70296838c290b0492bd39825aa37fa8382d233f5039c7793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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