Skip to content

Contango

Contango is a python engine for backtesting, optimizing, and graphing trading strategies. This covers everything not already in the README - the strategy/event module, optimizer, brokers, calenders, indicators, and how to read the generated graphs.

If you are new, start with the Getting Started section. If you already have a strategy running and want to understand a specific piece (events, the optimizer, a graph type), jump straight inot the relevant section below.

Getting Started

  • Installation - environment setup, depencencies.

  • Quickstart - run the demo strategy and serve the generated graphs locally.

Core Concepts

  • Engine - event types, the event bus, and the Strategy base class.

  • Brokers - how historical brokers (e.g. Yfinance) fetch OHLCV data & how to use them.

  • Calendars - how calendars (e.g. NYSECalendar) define tradeable dates, and how the data repository avoids re-fetching cached data.

  • Backtester - how fills, slippage, and commission are simulations, current limitations, and how the backtester works.

  • Indicators & State Machines - built-in indicators (ATR, Bollinger Bands, EMA, RSI, SMA, VWAP, Wilder Average) and the state machines strategies can signal off of.

Trading

  • Optimizer - how the optimizer works & what each computed metric (sharpe, calmar, PnL, expectancy, etc.) means.
  • Graphing - how to read each of the seven graph types, what to look for in each of the graphs, and examples to walk through each of the graph types.

Reference