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.4.1.tar.gz (9.8 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.4.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file sqphi_trade_kit-0.4.1.tar.gz.

File metadata

  • Download URL: sqphi_trade_kit-0.4.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sqphi_trade_kit-0.4.1.tar.gz
Algorithm Hash digest
SHA256 358522883932cffb90b2d0f7c44166dfbb240e9d6a8a00e00aa7cde267e003b1
MD5 1a7a3cf2178e85f959225e1f7b6f011b
BLAKE2b-256 a7ade2429ea28f38d8d3d0a3687b5f295c31d3d637226d58a6f8d7fe3252bc29

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqphi_trade_kit-0.4.1.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.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sqphi_trade_kit-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f4845e038a68f6bb02c9043f5c27bb354915f979c2400e574225b645385f08b
MD5 554f6ae01b68aa82f8695390527519b9
BLAKE2b-256 4b3d670be495534e5f2eeda7eb6a990a22ab96700125af29353e3762f2f89fa5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqphi_trade_kit-0.4.1-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