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:
pip install commomacrossoverbacktest
Usage
Basic Example
Below is an example of running a backtest using a moving average crossover strategy.
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 and the py-pkgs-cookiecutter template.
Metadata
Release files for commomacrossoverbacktest 0.2.0
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 |
|---|---|---|---|---|
| commomacrossoverbacktest-0.2.0.tar.gz | 7.9 kB | Without provenance | Details for commomacrossoverbacktest-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| commomacrossoverbacktest-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for commomacrossoverbacktest-0.2.0-py3-none-any.whl |
Total release size: 18.4 kB
Release files / commomacrossoverbacktest-0.2.0.tar.gz
| Download URL | commomacrossoverbacktest-0.2.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54049a5f3c5aa0c06936da015e183d31c3631bde77459d1400d2cbce0c54a5e6
|
|
BLAKE2b-256 checksum How to use checksums |
1d76d07593ccedd131ae5841732e8ab7ed9f3bf37053e9cdac9c4f954fbe511c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.16
|
Release files / commomacrossoverbacktest-0.2.0-py3-none-any.whl
| Download URL | commomacrossoverbacktest-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d047a46531c9946808290b29c1207887f31ff1cb9a5a3f4325294f702b2339e5
|
|
BLAKE2b-256 checksum How to use checksums |
a1efb0fb475a135df8a0820826b9ba65a11691203cf5d364a76c0b97c4727a81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.16
|
Security for commomacrossoverbacktest 0.2.0
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.