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.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quantex-0.6.7.tar.gz | 12.1 kB | Without provenance | Details for quantex-0.6.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantex-0.6.7-py3-none-any.whl | Python 3 | none | any | Details for quantex-0.6.7-py3-none-any.whl |
Total release size: 26.2 kB
Release files / quantex-0.6.7.tar.gz
| Download URL | quantex-0.6.7.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0a2eaf9c9ea20f5cf85fed174cfa93cbc2f63941638771cfe61d6ed59de73c3
|
|
BLAKE2b-256 checksum How to use checksums |
67af130f29de45bc19f0fc694464835bd3e13031a82a2e73d20de21bc0c81ad2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.1 Windows/11
|
Release files / quantex-0.6.7-py3-none-any.whl
| Download URL | quantex-0.6.7-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e333f5a373b8ece64a564d2e477a0586a98d1d8d03f9f19f2db1560ddefc972d
|
|
BLAKE2b-256 checksum How to use checksums |
7a7a2742e95c9fa4b94a57151bafd2587f71e85a2542fe4a16d0b10fd70e6e94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.1 Windows/11
|
Security for quantex 0.6.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.
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.