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.0.tar.gz (9.4 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.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqphi_trade_kit-0.4.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sqphi_trade_kit-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a8fc26c021822bee34bcf315cb41d849729e9c537267c1069b843580d2846312
MD5 5c1bbbdf2da61ac1a56e1b23d34ff154
BLAKE2b-256 c07abe48b8a089924796f1338733ce79e14a759878432fc1538030c5a88eb2cf

See more details on using hashes here.

File details

Details for the file sqphi_trade_kit-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: sqphi_trade_kit-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sqphi_trade_kit-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 836d355b59fa9b1aefb58c1b19fb876dbecda4db8e0214caa61733cdecb361aa
MD5 d6659e61ffb99b820f9c1caeb82f5fb3
BLAKE2b-256 ec115b5009c49789502ce4062320bac991b73943a3d7ee9723dc9e3b1ec8c72c

See more details on using hashes here.

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