A library to for https://alpha.isnow.ai
Project description
alpha-isnow
alpha-isnow is a Python library to load daily asset data (Stocks, ETFs, Indices, and Cryptocurrencies) from Cloudflare R2 and merge them into a single Pandas DataFrame. The library:
- Lists parquet files stored under
bucket_name/ds/<repo_id>/*.parquetfor each asset. - Validates that the monthly slices (files named as
YYYY.MM.parquet) are continuous with no missing months. - Supports loading data concurrently using a configurable number of threads (default is 4).
- Uses Python's built-in logging module to log messages to the console (default level is ERROR).
Installation
When you install alpha-isnow via pip, its dependencies (pandas, s3fs, boto3) will be automatically installed. To install the package:
pip install alpha-isnow
Usage
from alpha.datasets import load_daily, AssetType
# Load all available months of stock data
df = load_daily(
asset_type=AssetType.Stocks,
token={ # Optional, defaults to environment variables
"R2_ENDPOINT_URL": "your-r2-endpoint",
"R2_ACCESS_KEY_ID": "your-access-key",
"R2_SECRET_ACCESS_KEY": "your-secret-key",
}
)
# Load a specific range of months
df_range = load_daily(
asset_type=AssetType.ETFs,
month_range=("2023.01", "2023.03")
)
print(f"Loaded {len(df)} records")
The package uses a namespace package structure, so even though the package name is alpha-isnow, you import it with from alpha.datasets import ...
Development
Installation for Development
For development, install the package in editable mode with development dependencies:
pip install -e ".[dev]"
This will install:
- Runtime dependencies (pandas, s3fs, boto3, pyarrow)
- Development tools:
- pytest: For running tests
- black: For code formatting
- isort: For import sorting
- mypy: For type checking
- flake8: For code quality checks
- build: For building distribution packages
- twine: For uploading to PyPI
Building and Releasing
To build distribution packages:
# Build both wheel and source distribution
python -m build
# The packages will be created in the dist/ directory
To release to PyPI:
# Upload to PyPI (requires PyPI credentials)
python -m twine upload dist/*
For first-time releases, it's recommended to test on TestPyPI first:
# Upload to TestPyPI
python -m twine upload --repository testpypi dist/*
Local Cache
The library implements a local caching mechanism to improve data loading performance:
- Cache location:
~/.alpha_isnow_cache/ - Cache format: Parquet files named as
{repo_name}_{month}.parquet - Cache validity: 24 hours
- Performance: Loading from cache is typically 100x faster than loading from R2
Running Tests
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_loader.py
# Run tests with verbose output
pytest -v tests/test_loader.py
Code Quality
The project follows Python best practices:
- Code formatting with black
- Import sorting with isort
- Type checking with mypy
- Code quality checks with flake8
All code changes should pass these checks before being committed.
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 alpha_isnow-0.1.1.tar.gz.
File metadata
- Download URL: alpha_isnow-0.1.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f7f882cb4944a3989740c2c5d116201489df2a8a44273730ffffb06421151c6
|
|
| MD5 |
bb4cefec67db32c3c94518a8dd84ad2f
|
|
| BLAKE2b-256 |
b6f191ca1c9cac27271133949ec4de4fefc9590a1f4ce1220e5587e4b615ba37
|
File details
Details for the file alpha_isnow-0.1.1-py3-none-any.whl.
File metadata
- Download URL: alpha_isnow-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fcabb62658e52449972d5009f0c4a35e20be54c75540a36a3bbde5810258269
|
|
| MD5 |
ed50eeddaf719fb25d3b2791d5b647d3
|
|
| BLAKE2b-256 |
541e3f7815189d09504110313d831ff912014d31d26334dd2cb757d35913f09a
|