Skip to main content

tastytrade order-execution consumer / SDK: drains order intents off Redis Streams and places them

Project description

faro — a tastytrade order-execution consumer

faro

A tastytrade order-execution consumer (and the seed of a small tastytrade SDK). faro drains order intents off a Redis Stream and places them against tastytrade, reporting results back on a results stream. It owns a minimal, in-house tastytrade REST client (not a third-party broker library), so the credential and money path is auditable end to end.

The wire schema it speaks is wire (dollarsmore-wire); a producer emits OrderIntents, faro consumes them and emits ResultEvents.

Install

pip install dollarsmore-faro
# or
uv add dollarsmore-faro

The distribution is dollarsmore-faro; the import package is faro.

Run

python -m faro                 # consumes intents, places against the tastytrade production broker
python -m faro --account ... --redis-url redis://host:6379/0 --consumer faro-1

Credentials and wiring come from the environment (never baked into the image):

Variable Purpose
TASTYTRADE_CLIENT_SECRET OAuth2 client secret
TASTYTRADE_REFRESH_TOKEN OAuth2 refresh token
TASTYTRADE_ACCOUNT account number (optional if exactly one account)
REDIS_URL Redis connection (default redis://localhost:6379/0)
FARO_CASEKEEPER_DIR audit-log directory (default /app/casekeeper)
FARO_ARCHIVE_DIR stream-archive directory (default /app/archive)

A second process, python -m faro.archive, tails every order/ops stream into a durable per-day archive and trims the streams so Redis stays bounded.

Runtime mode

faro reads the Redis key faro:mode each loop. Only the exact value live arms real placement; an absent or unrecognised key reads as dry (fail-safe), so a fresh deploy never trades until an operator deliberately sets live. In dry mode every placement is sent to the broker's dry-run endpoint, which validates the order (buying power, fees, structure) without executing it, while cancels and the corrective flatten are suppressed. The switch is hot (no restart), and flipping livedry while positions are open cancels any working orders and flattens any held position at market first.

faro assumes it owns the trading account exclusively. Reconciliation treats any position or order it did not place as a discrepancy, so in live mode it may auto-close such a position, and the livedry flatten cancels and closes everything in the account — including orders or trades placed manually in the broker UI. Do not hand-trade the same account.

Lifecycle

An order flows from a producer's intent on orders:intents to a terminal result on orders:results. An OpenBracketIntent is placed as one OTO bracket at tastytrade (a limit entry with a pre-staged take-profit); the entry then fills or expires, and a filled position is closed by its take-profit or by a producer CLOSE. The whole map:

faro trade lifecycle, every path

Each path, watched live:

take-profit fills
Take-profit: the entry fills, the pre-staged TP fills, the OTO self-closes.
entry never fills
Not filled: the entry limit never trades and expires at session end; nothing at risk.
producer closes the position
Close: a producer CLOSE cancels the resting TP and flattens the position.
broker rejects the order
Rejected: the broker refuses the placement; no order works.

A bracket can also be pulled before it fills (a producer CANCEL), and the livedry kill-switch cancels working orders and flattens any position at once. The animations are rendered from tools/lifecycle.py (python -m tools.lifecycle), not shipped in the package.

Layout

Two layers live side by side; the seam is where a future fuller SDK grows:

  • SDK coresession.py (OAuth2 refresh-token session, never logs tokens, refuses non-tastyworks hosts), client.py (TastytradeClient REST), symbols.py (OCC option symbols), executor.py (BrokerExecutor port + TastytradeExecutor adapter — the swappable broker seam).
  • Consumer appstream.py (Redis Streams transport: intents / results / dead-letter), service.py (FaroService dispatch loop, crash-tolerant with PEL recovery), fill_tracker.py (polls the broker to confirm fills, records the actual price/time, emits FILLED), book.py (faro's believed state per trade), reconciler.py (diffs the book against the broker's positions, alerts on ops:alerts, mints a guarded corrective close), casekeeper.py (append-only per-day audit log of every intent received and broker result), archive.py (python -m faro.archive: tails the streams into a durable per-day archive and trims them), heartbeat.py (container healthcheck verdict), __main__.py (wires it together).

Develop

uv sync                        # wire resolves from PyPI (dollarsmore-wire)
uv run pytest -q
uv run ruff check .

Docker

docker build -t faro .         # installs dollarsmore-wire from PyPI

The image ships only faro + wire + requests/redis — no strategy code — so it is safe to publish.

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

dollarsmore_faro-0.8.10.tar.gz (721.9 kB view details)

Uploaded Source

Built Distribution

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

dollarsmore_faro-0.8.10-py3-none-any.whl (52.9 kB view details)

Uploaded Python 3

File details

Details for the file dollarsmore_faro-0.8.10.tar.gz.

File metadata

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

File hashes

Hashes for dollarsmore_faro-0.8.10.tar.gz
Algorithm Hash digest
SHA256 3cbe4b547c4ed25e1cc788ee5f3a0bf818e8700cc193493cc556ebc5c89576a4
MD5 a699f397ca599fe7e2c10c204d63e500
BLAKE2b-256 e38f7569cba9ef0ce902f8ce677dff0b511512d380746d4c15b7b9b1b30f324a

See more details on using hashes here.

File details

Details for the file dollarsmore_faro-0.8.10-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dollarsmore_faro-0.8.10-py3-none-any.whl
Algorithm Hash digest
SHA256 8b8b156d6550ee0756c48edb36fc49ef27414987085fe4a1fb273175410c01cb
MD5 6a617c087fb2c40bb05d7680e873fd4c
BLAKE2b-256 4974c7f19d5b40a77a4858c2ccdbd5adb9ae19da3ecbc7ba5485860708513e76

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