Skip to main content

data-energy-ff

CI PyPI version Python versions License: MIT

A small toolkit of helpers for crude-oil futures data analysis — loading pipeline CSVs into tidy pandas MultiIndex frames, building butterfly spreads from sequential outrights, splitting a series into roll-period windows, and quick normalized plots.

Installation

From PyPI (once published):

pip install data-energy-ff

Latest from source:

pip install "git+https://github.com/shubhquant1125ff-commits/pythonlib.git"

Quick start

import data_energy_ff as de

# 1. Load a futures CSV saved by the pipeline (restores the MultiIndex columns)
df = de.read_futures_csv_shubh("cl_outrights_1min.csv")

# 2. Build butterfly spreads from the sequential outrights (c1, c2, c3, ...)
flies = de.calculate_dynamic_butterflies(df)

# 3. Split a time series into pre / during / post roll windows
pre, during, post = de.split_by_roll_period(df, product="BRENT")

# 4. Compare two columns on a z-score normalized axis
de.plot_two_cols_normalized(df, ("c1", "weighted_mid"), ("c2", "weighted_mid"))

API

read_futures_csv_shubh(path, SEP="||")

Read a CSV saved by the futures pipeline and rebuild the clean MultiIndex DataFrame it was saved from. The first line is expected to be a metadata comment (#meta:<freq>||<level0_name>||<level1_name>), and column headers are SEP-joined tuples such as c1||weighted_mid. The datetime index is parsed as UTC and returned tz-naive.

calculate_dynamic_butterflies(df)

Build dynamic butterfly spreads from a MultiIndex frame of outrights. Level 0 holds the sequential outrights (c1, c2, ...) and level 1 holds contract and weighted_mid. For N outrights it returns N-2 butterflies priced as leg1 - 2*leg2 + leg3, with concatenated contract names. Raises ValueError if fewer than three outrights are present.

split_by_roll_period(df, product="BRENT")

Split a DatetimeIndex frame into (pre, during, post) roll-period windows using business-day-of-month thresholds. Windows adjust by product (BRENT/LCO, WTCL/CL/WTI, with a default fallback). Raises ValueError if the index is not a DatetimeIndex.

plot_two_cols_normalized(df, col1, col2)

Z-score normalize two columns and plot them together with a zero reference line, so you can see when each is above or below its own average.

Dependencies

Runtime: numpy, pandas, matplotlib, seaborn, plotly.

Development

git clone https://github.com/shubhquant1125ff-commits/pythonlib.git
cd pythonlib
python -m pip install -e ".[dev]"
pytest

See CONTRIBUTING.md for the full workflow and release steps.

License

MIT © Deepanshu Goyal and Shubh

Release files for data-energy-ff 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for data-energy-ff 0.1.0
File Size Uploaded
data_energy_ff-0.1.0.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for data-energy-ff 0.1.0
File Interpreter ABI Platform
data_energy_ff-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.8 kB

Release files / data_energy_ff-0.1.0.tar.gz

Download URL data_energy_ff-0.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7c4fef06c163658a9a6a6a793c957384094f261dd0fa72fb36e0779c15c02841
BLAKE2b-256 checksum
How to use checksums
d3c33ac3872e08cd5a5b3139abdfcd469b8d8b01c048a0b0d25f25bf40305f4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 16, 2026.

Transparency log

Release files / data_energy_ff-0.1.0-py3-none-any.whl

Download URL data_energy_ff-0.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba675e3ef50c35c05423f0ee156eed8259280bb73a3ac4a25c70f88f5937623d
BLAKE2b-256 checksum
How to use checksums
132553262561f33622b40913a2341d0f4d5c32c5b61ca12a1107796bc063c48f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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