Skip to main content

QuantEx Documentation

QuantEx is a Python backtesting library for OHLCV data. It is designed to be easy to use and extend, and to provide a simple interface for backtesting trading strategies.

Getting Started

To get started with QuantEx, you can install it using pip:

pip install quantex

QuantEx is designed to be used by writing your strategy as event-driven code. An example buy and hold strategy is shown below:

from quantex.strategy import Strategy

class BuyAndHold(Strategy):
    def init(self):
        pass

    def next(self):
        if self.broker.is_closed():
            self.broker.buy(amount=50)

This strategy will buy 50 shares of the stock when there are no open positions. To run this strategy, we must first get some data. Currently, QuantEx supports Yahoo Finance and pandas DataFrames as data sources.
To run the strategy with the data, we can use the Backtester class:

from quantex.backtester import Backtester
from quantex.datasource import YahooDataSource

bt = Backtester(BuyAndHold)
source = YahooDataSource("NVDA", start="2020-01-01", end="2025-12-31")
bt.add_data(source, "NVDA")
result = bt.run()

The result object contains information about the strategy, such as the total return, annualized return, and max drawdown.

If you would like to include commissions in your strategy, you can use the Commission class:

from quantex.commission import Commission, ApplicationType
from quantex.backtester import Backtester
from quantex.datasource import YahooDataSource

bt = Backtester(BuyAndHold, commission=Commission(ApplicationType.PER_ORDER, fixed=1))
source = YahooDataSource("NVDA", start="2020-01-01", end="2025-12-31")
bt.add_data(source, "NVDA")
result = bt.run()

This will charge a fixed commission of 1 dollar (or whatever the currency price is quoted in) per order.

Documentation

The documentation for QuantEx can be found here.

Metadata

Release files for quantex 0.6.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 quantex 0.6.1
File Size Uploaded
quantex-0.6.1.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quantex 0.6.1
File Interpreter ABI Platform
quantex-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / quantex-0.6.1.tar.gz

Download URL quantex-0.6.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a80373f92e23384d62bdd579119d1865f151376e0b6652b921e6216c6da1fd28
BLAKE2b-256 checksum
How to use checksums
3a5a042971cb49696cdc8976e505cb8e05c736c2f28711d6a1d6ef206559f4bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Windows/11

Release files / quantex-0.6.1-py3-none-any.whl

Download URL quantex-0.6.1-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1aab9a19058b80b07f006b08bd539c43de4e3cdabda3257d24a088a55f0533a
BLAKE2b-256 checksum
How to use checksums
58c08f8e51061d81e5c3b215a76e0b7a91dd0ce4076aac63385a0219903a1eac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Windows/11

Release history Release notifications | RSS feed

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

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