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
- Clone the repository:
git clone https://github.com/oldhero5/energex.git
cd energex
- Set up the development environment:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
- Run tests:
pytest tests/
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c4f2d180fc5368e9b1857dcc234b7ab212a0da879c80e4812da961f69c3c32
|
|
| MD5 |
2fa2db8e0f93e5e3589e79db99a9a17f
|
|
| BLAKE2b-256 |
906a5cee2f188f5b0794114f1339179f7083e1ba7fc0f5265fc5646177e9e607
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
299d1489d69a64e32bb7397949e1a23509d7ee9698181dfcf5770c7237ba6f9d
|
|
| MD5 |
1e221eb53778f8483d6426d71717bac6
|
|
| BLAKE2b-256 |
b2b3b6670a572a57d81348b41866ed06e808d5dbebcde83d3f0d7cf8dc2842c0
|