Metadata-Version: 2.3
Name: commomacrossoverbacktest
Version: 0.2.0
Summary: Python project designed to develop and implement backtesting for moving average crossover strategies applied to commodities underlyings
License: MIT
Author: Alexandre Cohen-Skalli
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: matplotlib (>=3.10.0,<4.0.0)
Requires-Dist: numba (>=0.60.0,<0.61.0)
Requires-Dist: pandas (>=2.2.3,<3.0.0)
Requires-Dist: pybacktestchain (>=0.2.1,<0.3.0)
Description-Content-Type: text/markdown

# commomacrossoverbacktest

`commomacrossoverbacktest` is a Python library designed to facilitate the development and implementation of backtesting for moving average crossover strategies applied to commodity underlyings. The library provides robust tools to simulate and evaluate trading strategies, enabling users to refine their approaches based on historical data.

## Features

- **Backtesting Framework**: Simulate and evaluate trading strategies based on exponential moving average crossovers, with short medium and long MA.
- **Commodity Trading**: Focused specifically on commodities like gold (`GC=F`), crude oil (`CL=F`), and others.
- **Customizable Signals**: Easily extend or modify signal generation logic using Exponential Moving Averages (EMAs).
- **Transaction Logs**: Automatic generation of detailed transaction logs and portfolio evolution files.
- **Visualization**: Plot portfolio value evolution over time for comprehensive strategy evaluation.
- **Configurable Parameters**: Adjust initial cash, trading universe, and backtesting periods.
- **Strategy**: Buy when MA_short > MA_medium > MA_long et sell if MA_short < MA_medium < MA_long.


## Installation

Install the package using pip:

```bash
pip install commomacrossoverbacktest
```
## Usage

### Basic Example

Below is an example of running a backtest using a moving average crossover strategy.

```python
from datetime import datetime
from commomacrossoverbacktest.commo_backtest import Backtest

# Define backtest parameters
backtest = Backtest(
    initial_date=datetime(2022, 1, 1),
    final_date=datetime(2023, 1, 1),
    universe=['GC=F', 'CL=F', 'CT=F', 'OJ=F', 'SB=F', 'ZS=F', 'ZC=F'],
    initial_cash=1000000
)

# Run the backtest
pnl_df = backtest.run_backtest()

# Visualize the portfolio value evolution
pnl_df.plot(x='Date', y='Portfolio Value', title="Portfolio Value Over Time")
```

## Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

## License

`commomacrossovernacktest` was created by Alexandre Cohen-Skalli as part of a project for the course Python Programming for M2 203 at Paris Dauphine University - PSL. 


. It is licensed under the terms of the MIT license.

## Credits

`commomacrossoverbacktest` was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).
