explaingit

cuemacro/finmarketpy

3,752PythonAudience · dataComplexity · 3/5LicenseSetup · moderate

TLDR

finmarketpy is a Python library for backtesting trading strategies and analyzing financial market data, define a strategy, pull historical prices from Bloomberg or Yahoo Finance, and measure returns, leverage, and trade outcomes with interactive charts.

Mindmap

mindmap
  root((finmarketpy))
    What It Does
      Backtest strategies
      Download market data
      Analyze seasonality
      Run event studies
    Tech Stack
      Python
      findatapy
      chartpy
      matplotlib
      Plotly
      Bokeh
    Data Sources
      Bloomberg
      Quandl
      Yahoo Finance
    Use Cases
      FX strategy testing
      Seasonality analysis
      Event-driven research
    Audience
      Quant researchers
      Finance professionals
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Backtest a foreign exchange trend-following strategy on historical price data and measure cumulative returns and max drawdown.

USE CASE 2

Run a seasonality analysis on an asset to see whether it tends to outperform at specific times of year.

USE CASE 3

Download market data from Bloomberg or Yahoo Finance using findatapy and feed it into a finmarketpy backtest template.

USE CASE 4

Generate an interactive Plotly chart of a strategy's leverage and returns over time by switching a single config setting from matplotlib.

Tech stack

PythonfindatapychartpyfinancepyJupyterAnaconda

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires installing three separate libraries (finmarketpy, findatapy, chartpy) and configuring API keys for each data provider such as Bloomberg or Quandl.

Free to use, modify, and distribute for any purpose, including commercial, with attribution required, you may not impose additional restrictions (Apache 2.0).

In plain English

finmarketpy is a Python library for analyzing financial market data and testing trading strategies. It provides templates that let you define a backtest (a simulation of how a trading strategy would have performed on historical data) and then run calculations to measure things like cumulative returns, leverage over time, and individual trade outcomes. It also supports seasonality analysis, which looks at whether an asset tends to perform differently at certain times of year, and event studies, which measure how prices move around specific announcements like US employment reports. The library is built around two companion packages by the same author: findatapy for downloading market data from sources such as Bloomberg, Quandl, and Yahoo Finance, and chartpy for generating interactive charts. By swapping a single setting you can switch the chart output between matplotlib, Plotly, or Bokeh. An optional third package, financepy, adds support for options pricing. Installing finmarketpy requires Python 3.10 and involves installing all three libraries separately via pip. Each library has its own configuration file where you add API keys for data providers and chart tools. The README links to a detailed installation guide and a course notebook covering how to set up an Anaconda environment for this stack. For people who want to try the library without a local setup, some Jupyter notebooks are available to run directly in the browser via Binder. Examples include backtesting a foreign exchange trend-following strategy and downloading market data. The project is released under the Apache 2.0 license and was previously named pythalesians before being rewritten with a cleaner API. The author's company, Cuemacro, offers paid workshops and commercial support for the library. Contributions are also welcomed, a planned features document in the repository lists areas where help is sought.

Copy-paste prompts

Prompt 1
Show me how to define a simple FX trend-following backtest in finmarketpy, download EUR/USD daily data via findatapy, and plot the cumulative returns using Plotly.
Prompt 2
How do I install finmarketpy, findatapy, and chartpy together in an Anaconda environment on Python 3.10?
Prompt 3
I want to run a seasonality analysis on gold prices using finmarketpy. Walk me through the analysis template and what the output shows.
Prompt 4
How do I switch finmarketpy chart output from matplotlib to Bokeh without changing any analysis code?
Prompt 5
What is an event study in finmarketpy and how do I configure one to measure price moves around US non-farm payroll announcement dates?
Open on GitHub → Explain another repo

← cuemacro on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.