Skip to main content

Contango

Documentation · License

Last Commit Python 3.11+ Stars License

Contango is a Python framework for backtesting, parameter optimization, and quantitative analysis of trading strategies.

Features

  • Cartesian parameter sweeps by evaluating every combination of selected strategy parameters.
  • Local data repository to cache OHLCV data locally for faster repeated backtests and offline research.
  • Full Yfinance data support (no API key needed) with easy additional data provider creation.
  • An entire metrics & graphing suite (equity curves, drawdown/underwater plots) to evaluate large amounts of strategy results at once.

This is not meant to be an extensive list, so see the documentation for everything not covered above.

Installation

Requires: Python 3.11+

pip install contango

See developer installation docs to build the project without pip.

Quickstart

Run the demo

python -m contango.research.demo_strategies.cartesian_bollinger_strategy.runner

The demo runs a Bollinger Band strategy across a Cartesian grid of parameters and generates performance and parameter-analysis graphs. The generated graphs (as HTML files) are saved to the root directory. To see the graphs, open the generated files in a browser.

The demo strategy itself is written as a RuleBasedStrategy.

Create a Strategy

The framework has two ways to create strategies. Subclassing RuleBasedStrategy allows for less boilerplate with the cost of implicitness, but is generally easier to comprehend at scale. If you would rather have more control (but generally more code to write), subclassing Strategy is the best way to do so:

class MyStrategy(Strategy):
    """
    A simplified strategy outline - not all logic is included.
    """
    def on_market_event(self, event: MarketDataEvent) -> None:
        # Strategy market logic here
        if should_buy:
            self.order_api.submit_order(event, "AAPL", quantity=3)
            self.order_api.submit_stoploss_order(event, "AAPL", quantity=-3, stoploss_price=...)
        elif should_sell:
            self.order_api.submit_order(event, "AAPL", quantity=-3)

Usage

See the documentation for an extensive breakdown on how to use the framework.

Credits

Developers:

License

See LICENSE


Metadata

Release files for contango 0.1.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 contango 0.1.1
File Size Uploaded Provenance Actions
contango-0.1.1.tar.gz 93.2 kB Without provenance Details for contango-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 223.9 kB

Release files / contango-0.1.1.tar.gz

Download URL contango-0.1.1.tar.gz
Size 93.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2ed9ca0b8dfff36ce16530c8895ab616ea122d174af37ff4365dbb3c5fc75802
BLAKE2b-256 checksum
How to use checksums
0a4c4d9040420e5eaed43808a63a3ba2f0cc0dd16414607cd0802996869fbb24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / contango-0.1.1-py3-none-any.whl

Download URL contango-0.1.1-py3-none-any.whl
Size 130.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eac75e555544450320d26f8deddb940fbe778ebd99c9dff64abca08b0ea335b6
BLAKE2b-256 checksum
How to use checksums
1391ef268a427a88ee6724412b185231d30c25eb1873495280db679280511f74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for contango 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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