A flexible toolkit for working with OHLC data and generating custom timeframes from minute data.
Project description
OHLC Toolkit
A flexible Python toolkit for working with OHLC (Open, High, Low, Close) market data.
Installation
The project is available on PyPI:
pip install ohlc-toolkit
Features
-
Read OHLC data from CSV files into pandas DataFrames, with built-in data quality checks:
df = read_ohlc_csv(csv_file_path, timeframe="1d")
-
Download BTCUSD 1-minute candle data in one line (using data from ff137/bitstamp-btcusd-minute-data):
df_1min = DatasetDownloader().download_bitstamp_btcusd_minute_data(bulk=True)
-
Transform your candle data into any desired timeframe and resolution:
# Convert 1-minute data into 5-minute data, maintaining a 1-minute resolution df_5m = transform_ohlc(df_1min, timeframe=5, step_size_minutes=1) # Convert 1-minute data into 1-day data, with a 1-day resolution df_1d = transform_ohlc(df_1min, timeframe="1d", step_size_minutes=1440) # Support for arbitrary timeframes is available! df_arb = transform_ohlc(df_1min, timeframe="1d3h7m")
-
Convert timeframe strings to the number of minutes, and vice versa:
# From string to minutes parse_timeframe("1h15m") == 75 # From minutes to string format_timeframe(minutes=75) == "1h15m"
-
Calculate future price changes:
# For every minute, compute the 1-hour percentage price change df_future_returns = calculate_percentage_return( df_1min["close"], # Use the close price column timestep_size=1, # Compute returns at 1-minute resolution (same as input) future_return_length=60, # Compute price changes over 60 minutes )
🚧 Coming soon™️:
- Calculate technical indicators
All of the above features will enable you to generate extensive training data for machine learning models, whether for research or trading, to predict future price changes based on technical indicators.
Examples
See the examples directory for examples of how to use the toolkit.
Run the example script to see how the toolkit works:
# Clone the repository
git clone https://github.com/ff137/ohlc-toolkit.git
cd ohlc-toolkit
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install poetry
poetry install
# Run the example script
python examples/basic_usage.py
Support
If you need any help or have any questions, please feel free to open an issue or contact me directly.
We hope this repo makes your life easier! If it does, please give us a star! ⭐
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
Built Distribution
File details
Details for the file ohlc_toolkit-0.4.0.tar.gz
.
File metadata
- Download URL: ohlc_toolkit-0.4.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
691ecebd7dfa440a2a6f3803df94581f22a7a881108126ec16a2cc286fc3768c
|
|
MD5 |
cf9a8452309822578daa6971f5d51c9f
|
|
BLAKE2b-256 |
b6e28033e12366f359d35e70c86d63711372baf251dc65a778528099b0caa07d
|
Provenance
The following attestation bundles were made for ohlc_toolkit-0.4.0.tar.gz
:
Publisher:
publish-on-release.yml
on ff137/ohlc-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
ohlc_toolkit-0.4.0.tar.gz
-
Subject digest:
691ecebd7dfa440a2a6f3803df94581f22a7a881108126ec16a2cc286fc3768c
- Sigstore transparency entry: 232461775
- Sigstore integration time:
-
Permalink:
ff137/ohlc-toolkit@cd609f9164ba19a67f09b9133f9e008562f06f89
-
Branch / Tag:
refs/tags/0.4.0
- Owner: https://github.com/ff137
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-on-release.yml@cd609f9164ba19a67f09b9133f9e008562f06f89
-
Trigger Event:
release
-
Statement type:
File details
Details for the file ohlc_toolkit-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: ohlc_toolkit-0.4.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4337ad806be842e8e5a74b67a91a05fc136ebebd1f9939115ef8318022fcb758
|
|
MD5 |
29f57d735393f95a1cfc3935b98caee5
|
|
BLAKE2b-256 |
2035856aa54b9cb0d438fa2a7e3de13d57708510a0273b4c187e4fab03290f6e
|
Provenance
The following attestation bundles were made for ohlc_toolkit-0.4.0-py3-none-any.whl
:
Publisher:
publish-on-release.yml
on ff137/ohlc-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
ohlc_toolkit-0.4.0-py3-none-any.whl
-
Subject digest:
4337ad806be842e8e5a74b67a91a05fc136ebebd1f9939115ef8318022fcb758
- Sigstore transparency entry: 232461777
- Sigstore integration time:
-
Permalink:
ff137/ohlc-toolkit@cd609f9164ba19a67f09b9133f9e008562f06f89
-
Branch / Tag:
refs/tags/0.4.0
- Owner: https://github.com/ff137
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-on-release.yml@cd609f9164ba19a67f09b9133f9e008562f06f89
-
Trigger Event:
release
-
Statement type: