# finmarketpy: Cuemacro's backtesting library and its two sibling dependencies

> finmarketpy is Saeed Amen's Apache-2.0 Python library for backtesting trading strategies and analyzing financial markets, formerly pythalesians, offering prebuilt backtest templates, seasonality analysis, event studies and volatility-targeted risk weighting. It depends on the author's chartpy and findatapy libraries, requires Python 3.10, pins numpy below 2, and is maintained under the Rhiza template system with the v0.11.19 release current.

**cuemacro/finmarketpy** — Python library for backtesting trading strategies & analyzing financial markets (formerly pythalesians)

- Repository: https://github.com/cuemacro/finmarketpy
- Website: http://www.cuemacro.com
- Stars: 3,815 · Forks: 521
- Language: Python
- License: Apache-2.0
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/cuemacro-finmarketpy

## From pythalesians to finmarketpy

finmarketpy is a Python library for analyzing market data and backtesting trading strategies using a simple API with prebuilt templates, and its history is stated plainly, the author previously wrote the open source PyThalesians financial library, which has been merged into this one so maintenance could focus on a single set of libraries. The new library carries similar functionality to pythalesians' trading part, with the API rewritten to be much cleaner and easier to use plus many new features. The split philosophy is explicit, breaking into smaller more specialized libraries should make contributing easier, which produced the three-library constellation of finmarketpy, chartpy and findatapy that every install discussion circles back to. The README also states the project's present state without varnish, finmarketpy is under continual development, the API is heavily documented, but more general documentation is being looked for, a distinction between API reference and narrative docs that shapes the learning path, examples first, API second, general prose last.

## What the library computes

The included features are six, prebuilt templates for backtesting trading strategies, display of historical returns for strategies, investigation of strategy seasonality, market event studies around data events, an in-built calculator for risk weighting using volatility targeting, and an object-oriented design for reusability. The gallery names the concrete examples behind each, a cumulative returns calculation for an FX trend strategy in tradingmodelfxtrend_example.py, plots of the strategy's borrowed-exposure levels over time, individual trade returns, seasonality of gold and FX volatility in seasonality_examples.py, and event studies in events_examples.py. The example files are the documentation's backbone, each gallery claim pointing at a runnable script in finmarketpy_examples. The FX trend example being the flagship is no accident, trend following over long histories is the canonical backtest, sensitive to exactly the plumbing finmarketpy owns, contract rolls, session calendars and return calculation, and the gallery's exposure and per-trade plots are the diagnostics a practitioner actually checks before trusting an equity curve.

## The three-library installation dance

finmarketpy requires findatapy for downloading market data and chartpy for interactive plots, and the installation instructions sequence them. The library itself installs from the repository for the newest version:

```
pip install git+https://github.com/cuemacro/finmarketpy.git
```

with the two siblings beside it:

```bash
pip install git+https://github.com/cuemacro/chartpy.git
pip install git+https://github.com/cuemacro/findatapy.git
```

or from PyPI in slightly older form, pip install chartpy and pip install findatapy. Configuration follows the same split, chartpy's chartconstants.py needs a Plotly API key, findatapy's dataconstants.py takes a Quandl API key, or a datacred.py file in the util folder overrides the settings, with a first-run prompt as the fallback that installs the key. The library's own marketconstants.py can be edited or overridden by a marketcred.py.

## FinancePy, the deliberately difficult dependency

The option pricing dependency gets its own warning paragraph, and the warning is detailed enough to trust. FinancePy is optional, recommended to install separately from PyPI after finmarketpy and without dependencies, otherwise it can cause clashes with other libraries because of its strict version dependencies on libraries like llvmlite, which in practice can be relaxed. The API changes a lot, so installing the specific listed version is recommended:

```
pip install numba numpy scipy llvmlite ipython pandas prettytable
pip install financepy==0.370 --no-deps
```

The no-deps flag with the manually enumerated prerequisites is the workaround spelled out, the kind of instruction that only exists after the clash has bitten someone.

## Browser-based starts through Binder

The zero-install path runs Jupyter notebooks in Binder, with the caveat that the instance takes a few minutes to start and more notebooks are being worked on. Two are linked, a backtest of an FX trend following strategy and a market data download example, each bound to the master branch. The Binder notebooks still need a Quandl API key for the data downloads, with a free account signup at quandl.com, so the browser path removes the environment setup but not the data provider account, the split that defines what findatapy contributes to the stack.

## Rhiza, AI-assisted ADRs, and the modern tooling

The repository's build surface shows a recent modernization, a Makefile marked repo-owned that includes a Rhiza template system through rhiza.mk, with a default AI model configured and gh-aw workflows defaulting to the copilot engine, selectable between copilot, claude and codex. The adr target creates Architecture Decision Records through an AI-assisted GitHub workflow, prompting for title and context, then triggering a workflow that generates the ADR number, writes the document, updates the index and opens a pull request. The pyproject is Hatch-based with a src layout, ruff at 120 characters targeting py39, bandit excluding tests, and deptry checking dependency hygiene, with pytest and coverage, pre-commit and marimo in the dev group. The .rhiza directory and rhiza.mk include mark the repository as template-managed, so hygiene targets like validation and typecheck inherit from the shared template while the local Makefile keeps only custom targets, a structure that lets one maintainer keep many repos consistent.

## Requirements, releases, and the Cuemacro economy

The requirements pin Python 3.10, pandas, numpy and the like, with the pyproject constraining numpy below 2 and pandas at 1.5.3 or later, plus seasonal and scikit-learn for the statistics, and blosc for compressed storage. The release notes track dependency maintenance, v0.11.15 fixing Pandas deprecation warnings, v0.11.16 removing print messages, and v0.11.19 changing NumPy and Pandas versions in March 2025, with the last push in April 2026. The sponsorship section describes the economy honestly, years of writing the libraries, GitHub Sponsors for funding, a two-day Python for finance workshop taught at firms, and commercial technical support, all contacted through the author's email, the funding model of a one-person quant library house.

## Conclusion

Use finmarketpy when backtesting trading strategies in Python with a template-driven API, particularly FX trend following, seasonality studies and event studies, and when the Cuemacro stack, chartpy for plots and findatapy for data, suits your pipeline, since the three libraries are designed together. Build your own stack from pandas and vectorized research code if the templates constrain you. Before installing, follow INSTALL.md for the full environment, install chartpy and findatapy first as required, edit their constants files or a marketcred.py for API keys, and handle FinancePy as the documented special case, installed separately without dependencies at a pinned version.

## FAQ

### Can Python be used for stock trading?

Yes, Python is widely used for trading strategy work, and finmarketpy is one such library, an Apache-2.0 Python toolkit for backtesting trading strategies and analyzing market data, with prebuilt backtest templates, seasonality analysis, event studies and volatility-targeted risk weighting, alongside its sibling libraries chartpy for plotting and findatapy for market data.

### How do you install finmarketpy?

Install finmarketpy from the repository with pip install git+https://github.com/cuemacro/finmarketpy.git, having first installed the required chartpy and findatapy libraries and their API key configurations. For option pricing, add FinancePy separately with financepy==0.370 and the --no-deps flag after installing numba, numpy, scipy, llvmlite, ipython, pandas and prettytable manually.

### What can finmarketpy analyze?

The library backtests trading strategies from prebuilt templates, displays historical returns and leverage and per-trade results, investigates seasonality of strategies and assets such as gold and FX volatility, conducts event studies around data events, and calculates volatility-targeted risk weightings, with runnable examples in the finmarketpy_examples directory and Binder notebooks for browser-based starts.

## Sources

- [cuemacro/finmarketpy on GitHub](https://github.com/cuemacro/finmarketpy)
- [License: Apache-2.0](https://github.com/cuemacro/finmarketpy/blob/master/LICENSE)
- [Project website](http://www.cuemacro.com)
- [README](https://github.com/cuemacro/finmarketpy/blob/master/README.md)
- [Releases](https://github.com/cuemacro/finmarketpy/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/cuemacro-finmarketpy
