Skip to main content

Energy derivatives data collection and storage system

Project description

Energex: Energy Market Analysis Tools

A Python package for downloading, analyzing, and visualizing energy market data using Polars and DuckDB.

Features

  • Automated data collection from major energy markets
  • Fast data processing using Polars DataFrames
  • Persistent storage in DuckDB with SQL querying capabilities
  • Technical analysis tools including:
    • Moving averages (20, 50, 200 days)
    • RSI (Relative Strength Index)
    • Trading signals (Golden Cross, Death Cross)
  • Interactive visualizations using Plotly

Installation

# Install using uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install energex

# Or using pip
pip install energex

Quick Start

from energex import TechnicalAnalyzer

# Initialize analyzer
analyzer = TechnicalAnalyzer()

# Analyze crude oil futures
df, signals, fig = analyzer.analyze("CL=F")

# Save analysis chart
fig.write_html("crude_oil_analysis.html")

# Print recent trading signals
print("Recent Trading Signals:")
print(signals)

Project Structure

energex/
├── src/
│   ├── energex/
│   │   ├── __init__.py
│   │   ├── database.py       # DuckDB interface
│   │   ├── data_fetcher.py   # Data collection
│   │   └── analysis.py       # Technical analysis
│   └── examples/
│       ├── 01_basic_queries.py
│       ├── 02_technical_analysis.py
│       └── 03_spread_analysis.py
├── tests/                    # Unit and integration tests
├── pyproject.toml           # Project configuration
└── README.md

Basic Usage

1. Query Historical Data

from energex import EnergyQueryTool

# Initialize query tool
tool = EnergyQueryTool()

# Get latest prices
prices = tool.get_latest_prices()

# Get daily returns for crude oil
returns = tool.get_daily_returns("CL=F")

# Analyze trading volume
volume = tool.get_volume_analysis("NG=F")

2. Technical Analysis

from energex import TechnicalAnalyzer

analyzer = TechnicalAnalyzer()

# Full analysis with visualization
df, signals, fig = analyzer.analyze("CL=F")

# Access individual components
df = analyzer.get_data("CL=F")
df = analyzer.add_moving_averages(df)
df = analyzer.add_rsi(df)

3. Spread Analysis

from energex import SpreadAnalyzer

analyzer = SpreadAnalyzer()

# Analyze WTI-Brent spread
spread_data = analyzer.get_spread_data("CL=F", "BZ=F")
stats = analyzer.calculate_spread_stats(spread_data)

Configuration

The package uses DuckDB for storage and can be configured through environment variables:

ENERGEX_DB_PATH=/path/to/database.db
ENERGEX_DATA_DIR=/path/to/data

Development

  1. Clone the repository:
git clone https://github.com/oldhero5/energex.git
cd energex
  1. Set up the development environment:
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
  1. Run tests:
pytest tests/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

energex-0.1.0.tar.gz (112.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

energex-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file energex-0.1.0.tar.gz.

File metadata

  • Download URL: energex-0.1.0.tar.gz
  • Upload date:
  • Size: 112.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for energex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 38c4f2d180fc5368e9b1857dcc234b7ab212a0da879c80e4812da961f69c3c32
MD5 2fa2db8e0f93e5e3589e79db99a9a17f
BLAKE2b-256 906a5cee2f188f5b0794114f1339179f7083e1ba7fc0f5265fc5646177e9e607

See more details on using hashes here.

File details

Details for the file energex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: energex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for energex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 299d1489d69a64e32bb7397949e1a23509d7ee9698181dfcf5770c7237ba6f9d
MD5 1e221eb53778f8483d6426d71717bac6
BLAKE2b-256 b2b3b6670a572a57d81348b41866ed06e808d5dbebcde83d3f0d7cf8dc2842c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page