Shared utilities for crypto trading systems — DB connectors, notifications, secrets
Project description
sqphi-trade-kit
Shared Python utilities for crypto trading systems. Provides database connectors (PostgreSQL, ArcticDB), Telegram notifications, AWS Secrets Manager access, and common helpers.
Installation
pip install sqphi-trade-kit
# or
uv add sqphi-trade-kit
Modules
Top-level imports
from sqphi_trade_kit import send_telegram_message, print_markdown, time_logger
| Function | Description |
|---|---|
send_telegram_message(message, thread_id) |
Send a notification to Telegram |
print_markdown(message) |
Print a DataFrame as markdown table, or plain print() otherwise |
time_logger |
Decorator that logs function execution time |
sqphi_trade_kit.db — Database connectors
from sqphi_trade_kit.db import get_engine, get_database_url
from sqphi_trade_kit.db import get_ohlcv, get_ohlcv_resampled, get_arctic, get_library
PostgreSQL (sqphi_trade_kit.db.postgres):
get_database_url()— Resolves DB URL fromDATABASE_URLenv var (local) or AWS Secrets Manager +DB_ENDPOINT(ECS)get_engine()— Lazily-created shared SQLAlchemy engine
ArcticDB (sqphi_trade_kit.db.arctic):
get_arctic()— Connect viaARCTIC_URIenv varget_library(name)— Return a named ArcticDB libraryget_ohlcv(start_date, end_date, bases, exchange)— Fetch 1-minute OHLCV candles. Symbol format:{exchange}__{base}__USDT-USDTget_ohlcv_resampled(start_date, end_date, bases, freq, exchange)— Fetch and resample to1hor1d
sqphi_trade_kit.notifications — Telegram
from sqphi_trade_kit.notifications import send_telegram_message
Requires TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID env vars.
sqphi_trade_kit.secrets — AWS Secrets Manager
from sqphi_trade_kit.secrets import get_aws_secrets
creds = get_aws_secrets("trading-systems-prod-db-credentials")
CLI: sqphi-sync-secrets
Sync .env keys to AWS Secrets Manager:
sqphi-sync-secrets --app my-app --env prod --keys KEY1,KEY2,KEY3
Environment variables
| Variable | Required by | Description |
|---|---|---|
DATABASE_URL |
db.postgres |
PostgreSQL connection string (local dev) |
DB_ENDPOINT |
db.postgres |
RDS endpoint (AWS ECS — required when DATABASE_URL is not set) |
ENV |
db.postgres |
prod or demo (default: prod) |
ARCTIC_URI |
db.arctic |
ArcticDB connection URI (e.g. lmdb:///path or s3://bucket/path) |
OHLCV_EXCHANGE |
db.arctic |
Exchange name for OHLCV symbols (default: binance) |
TELEGRAM_BOT_TOKEN |
notifications |
Telegram bot API token |
TELEGRAM_CHAT_ID |
notifications |
Telegram chat/group ID |
Dependencies
arcticdb,boto3,pandas,requests,psycopg2,sqlalchemy,tabulate- Python >= 3.12
License
MIT
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 sqphi_trade_kit-0.5.0.tar.gz.
File metadata
- Download URL: sqphi_trade_kit-0.5.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
699ea81441d488de30ce82a40b61e542cdbd656f2c5c75f0f96f726224d546a4
|
|
| MD5 |
da65c9ac1eaa09869dc44efe0b5c0a62
|
|
| BLAKE2b-256 |
e16aa69ea639b8272a85bddf27b2772e0c8f93fbd787019389237595db8dcc19
|
Provenance
The following attestation bundles were made for sqphi_trade_kit-0.5.0.tar.gz:
Publisher:
publish.yml on sigma-quantiphi/sqphi-trade-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqphi_trade_kit-0.5.0.tar.gz -
Subject digest:
699ea81441d488de30ce82a40b61e542cdbd656f2c5c75f0f96f726224d546a4 - Sigstore transparency entry: 1317017404
- Sigstore integration time:
-
Permalink:
sigma-quantiphi/sqphi-trade-kit@18c7fe95803d0a7685b5f50d042146a272c78139 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/sigma-quantiphi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18c7fe95803d0a7685b5f50d042146a272c78139 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqphi_trade_kit-0.5.0-py3-none-any.whl.
File metadata
- Download URL: sqphi_trade_kit-0.5.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff78bf774481080581c7d7fcbe8e0f0c65ccd5604178ab831c24d49ea29e6a98
|
|
| MD5 |
d0361642d60e40795e2fdac5f48be60a
|
|
| BLAKE2b-256 |
acb9dfc617dec56a730a7d56b51b9c504622fafd234fc52c8729a10e6d6b60c1
|
Provenance
The following attestation bundles were made for sqphi_trade_kit-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on sigma-quantiphi/sqphi-trade-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqphi_trade_kit-0.5.0-py3-none-any.whl -
Subject digest:
ff78bf774481080581c7d7fcbe8e0f0c65ccd5604178ab831c24d49ea29e6a98 - Sigstore transparency entry: 1317017410
- Sigstore integration time:
-
Permalink:
sigma-quantiphi/sqphi-trade-kit@18c7fe95803d0a7685b5f50d042146a272c78139 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/sigma-quantiphi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18c7fe95803d0a7685b5f50d042146a272c78139 -
Trigger Event:
push
-
Statement type: