Skip to main content

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 from DATABASE_URL env 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 via ARCTIC_URI env var
  • get_library(name) — Return a named ArcticDB library
  • get_ohlcv(start_date, end_date, bases, exchange) — Fetch 1-minute OHLCV candles. Symbol format: {exchange}__{base}__USDT-USDT
  • get_ohlcv_resampled(start_date, end_date, bases, freq, exchange) — Fetch and resample to 1h or 1d

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqphi_trade_kit-0.5.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqphi_trade_kit-0.5.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

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

Hashes for sqphi_trade_kit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 699ea81441d488de30ce82a40b61e542cdbd656f2c5c75f0f96f726224d546a4
MD5 da65c9ac1eaa09869dc44efe0b5c0a62
BLAKE2b-256 e16aa69ea639b8272a85bddf27b2772e0c8f93fbd787019389237595db8dcc19

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for sqphi_trade_kit-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff78bf774481080581c7d7fcbe8e0f0c65ccd5604178ab831c24d49ea29e6a98
MD5 d0361642d60e40795e2fdac5f48be60a
BLAKE2b-256 acb9dfc617dec56a730a7d56b51b9c504622fafd234fc52c8729a10e6d6b60c1

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page