Metadata-Version: 2.4
Name: quantex
Version: 0.6.2
Summary: A simple quant strategy creation and backtesting package.
License-Expression: MIT
License-File: LICENSE.md
Author: Daniel Green
Author-email: dangreen07@outlook.com
Requires-Python: >=3.11,<4
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: fastparquet (>=2024.11.0,<2025.0.0)
Requires-Dist: matplotlib (>=3.10.8,<4.0.0)
Requires-Dist: mkdocs (>=1.6.1,<2.0.0)
Requires-Dist: mplfinance (>=0.12.10b0,<0.13.0)
Requires-Dist: numpy (>=2.4.3,<3.0.0)
Requires-Dist: optuna (>=4.8.0,<5.0.0)
Requires-Dist: pandas (>=2.3.0,<3.0.0)
Requires-Dist: ta-lib (>=0.7.1,<0.8.0)
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
Requires-Dist: yfinance (>=1.7.0,<2.0.0)
Description-Content-Type: text/markdown

# 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:
```bash
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:

```python
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:
```python
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:

```python
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](https://dangreen07.github.io/quantex/).
