📈 TinyCTA
A Lightweight Python Package for Commodity Trading Advisor Strategies.
Quick Links: 📚 Repository • 📦 PyPI • 🐛 Issues • 💬 Discussions
📋 Overview
TinyCTA provides essential tools for quantitative finance and algorithmic trading, particularly for trend-following strategies. The package includes:
- Signal processing functions for creating oscillators and adjusting returns
- Linear algebra utilities that handle matrices with missing values
- Matrix shrinkage techniques commonly used in portfolio optimization
This package is designed to be the foundation for implementing CTA strategies in just a few lines of code, hence the name "TinyCTA".
🚀 Installation
Using pip
pip install tinycta
From source
Clone the repository and install using the provided Makefile:
git clone https://github.com/tschm/tinycta.git
cd tinycta
make install
This will install uv (a fast Python package installer) and create a virtual environment with all dependencies.
💻 Usage
Creating an oscillator
from pathlib import Path
import pandas as pd
from tinycta.signal import osc
path = Path(__name__).resolve().parent.parent
# Load price data
prices = pd.read_csv("data.csv", index_col=0, parse_dates=True)
# Create an oscillator with default parameters
oscillator = prices.apply(osc)
# Create an oscillator with custom parameters
custom_oscillator = prices.apply(osc, fast=16, slow=64, scaling=False)
Adjusting returns for volatility
from tinycta.signal import returns_adjust
# Adjust returns for volatility
adjusted_returns = prices.apply(returns_adjust)
Linear algebra operations
import numpy as np
from tinycta.linalg import solve
# Create a matrix and right-hand side vector
matrix = np.array([[1.0, 0.5], [0.5, 1.0]])
rhs = np.array([1.0, 2.0])
# Solve the linear system
solution = solve(matrix, rhs)
print(solution)
[0. 2.]
📚 API Reference
Signal Processing
osc(prices, fast=32, slow=96, scaling=True): Creates an oscillator based on the difference between fast and slow moving averagesreturns_adjust(price, com=32, min_periods=300, clip=4.2): Adjusts log-returns by volatility and applies winsorizationshrink2id(matrix, lamb=1.0): Performs shrinkage of a matrix towards the identity matrix
Linear Algebra
valid(matrix): Constructs a valid subset of a matrix by filtering out rows/columns with NaN valuesa_norm(vector, matrix=None): Computes the matrix-norm of a vector with respect to a matrixinv_a_norm(vector, matrix=None): Computes the inverse matrix-norm of a vectorsolve(matrix, rhs): Solves a linear system of equations, handling matrices with NaN values
🛠️ Development
Setting up the development environment
make install
Running tests
make test
Code formatting and linting
make fmt
Cleaning up
make clean
📄 License
TinyCTA is licensed under the MIT License. See the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Metadata
Release files for TinyCTA 0.9.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tinycta-0.9.9.tar.gz | 1.6 MB | With provenance | Details for tinycta-0.9.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tinycta-0.9.9-py3-none-any.whl | Python 3 | none | any | Details for tinycta-0.9.9-py3-none-any.whl |
Total release size: 1.6 MB
Release files / tinycta-0.9.9.tar.gz
| Download URL | tinycta-0.9.9.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb06ec2352449cd024abde7eabba7c96b7d6a56bb14b705daf78c810dbf4b031
|
|
BLAKE2b-256 checksum How to use checksums |
892a8a9f946570995e9e76eb181760ddb62810c24b5527cf17853e714813a005
|
| 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 Apr 25, 2026.
Transparency logRelease files / tinycta-0.9.9-py3-none-any.whl
| Download URL | tinycta-0.9.9-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e502720f05d3834d3e1d2de2d292ca0d58decf4d80fc2bbfdded883211d5aa31
|
|
BLAKE2b-256 checksum How to use checksums |
a5587721669010660cdbb5fcf18592c7428eee3d3b6d56f3b85586a60c6470fe
|
| 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 Apr 25, 2026.
Transparency logSecurity for TinyCTA 0.9.9
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tinycta-0.9.9.tar.gz
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 Apr 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.