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) |
FARO_PRODUCER_HEALTH_KEY |
Redis key carrying the producer's heartbeat; unset leaves the dead-man inert |
FARO_PRODUCER_SILENCE_S |
producer silence that arms the dead-man flatten (default 90) |
FARO_SIM_LIFECYCLE_STREAM |
Redis stream carrying the producer's sim fill/TP lifecycle; unset leaves the divergence response inert |
FARO_SIM_GRACE_S |
grace before a sim-vs-broker divergence is acted on (default 7) |
The last four have a matching CLI flag (--producer-health-key, --producer-silence-s,
--sim-lifecycle-stream, --sim-grace-s). The two keys default to unset, so the dead-man
flatten and the divergence response described below stay dormant until they are configured.
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 live→dry while positions are open cancels any working orders and
flattens any held position at market first.
Two exceptions to that suppression, both exposure-reducing only. A live→dry flatten that
cannot confirm the account flat records an owed flatten; while that marker stands, faro keeps
cancelling the working bracket and market-closing the held position on a fixed retry, even
though it is reporting dry mode, until the account is confirmed flat or a bounded number of
attempts is exhausted (FLATTEN_OWED_* alerts track it). Opening is never forced: a forced
close re-reads the live holding and places nothing when that read fails.
Within one pass a held position is closed once. The immediate retries exist to catch a position
that appears between the cancel and the read, and to re-send a close the broker REFUSED outright;
any close whose fate is unknown, including one that errored or raised after leaving faro, is
treated as placed and is not re-sent, because a market order that has not filled yet still
reports the holding and sending against it again would sell the same contracts twice. A flatten
performed while applying a mode change also stands the owed-flatten retry down for that pass, so
the two callers cannot each place a close milliseconds apart.
Re-sending against a position that is still held is the job of the owed-flatten retry, which is
spaced and bounded. The mode-change path takes exactly one corrective flatten, on the pass that
first sees the flip, and then hands the re-sending over: from there it only re-reads whether the
account has come flat. So a disengage that will not clear spends the same
FLATTEN_OWED_ABANDONED budget as any other owed flatten rather than re-attempting on every
pass, and the flip to dry still lands the moment the account reads flat, however it got there
(including flattened by hand at the broker, with no restart).
The retry is bounded in three independent ways, because a forced close is the one thing faro
does against the operator's stated mode. It retires only on evidence that its own reason has
passed, and the marker records which reason that is: a live→dry disengage is moot the moment
the operator asks for live again, so that aborts an unfinished disengage outright
(FLATTEN_OWED_CANCELLED, and faro resumes managing the position, whose book entry was never
reset), whereas a dead-man flatten retires only once the producer heart-beats again. Mode alone
never drops a dead-man marker: the producer being silent is exactly when nobody else is managing
the position. A marker written by an older faro, which carried no reason, reads as a disengage.
It spends a fixed attempt budget that is returned only by reading the marker gone, so
a clear that silently fails still ends at FLATTEN_OWED_ABANDONED rather than forcing a close
every retry forever; a new incident carrying a different reason gets a fresh budget. Once the
budget is spent faro stops forcing but keeps re-checking, so a position flattened by hand
clears the marker (FLATTEN_OWED_RECOVERED) the moment the account reads flat, without a
restart: from applied-dry no mode change would flatten it (arming is blocked by the marker, and
a dry request early-returns), so that re-check is the only in-band way out. And an owed flatten
blocks arming, so the two surfaces cannot disagree. A RECOVERED reports whether faro actually
placed or cancelled anything (flatten) or merely found the account already flat
(flatten:confirmed-flat), so the daily /compare gate does not grade a no-op settle as money moving.
Arming dry→live is gated. faro refuses to arm while a broker holding or a resting order
cannot be attributed to its own book, while intents are still unacked, while a reconciler
discrepancy is unresolved, or while a flatten is still owed; the blocking field is named in the
MODE_ENGAGE_BLOCKED alert, and any reading that faults counts as blocking. A holding its own
book accounts for (the usual restart-mid-trade case) does not block, so faro resumes
managing the position it already owns, and neither do faro's own corrective flatten orders.
Disengaging is never gated.
The health record faro publishes gained unattributed_positions, unattributed_orders and
flatten_owed in 0.10.0, and a consumer that derives its own arming view from that record (the
operator dashboard does) will read a record without them as unreadable evidence and refuse to
arm. Deploy faro before any such consumer, never after.
faroassumes 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 thelive→dryflatten cancels and closes everything in the account — including orders or trades placed manually in the broker UI. Do not hand-trade the same account.
Sim divergence
The producer runs its own model of each trade and can book a fill or a take-profit the broker never gave, because a modelled exit off a bar's extreme is not the same thing as a resting limit reaching the front of the queue. Left alone the two books drift apart: the model believes it is flat and sends nothing further, while a real position stays open with no exit behind it.
With FARO_SIM_LIFECYCLE_STREAM configured, faro watches that stream and acts once the
broker leg has lagged the model past FARO_SIM_GRACE_S. A modelled entry the broker never
filled cancels the resting bracket (MISS_FILL); a modelled take-profit whose real limit is
still unfilled cancels the bracket and closes the position at market (MISS_TP), which
accepts slippage in exchange for the two books agreeing. Both raise an alert on ops:alerts
recording the action taken. The market close is registered for fill confirmation under the
horizon of the book entry it resolves, so the record that proves the position closed can
never expire while faro still believes the position is open.
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:
Each path, watched live:
Take-profit: the entry fills, the pre-staged TP fills, the OTO self-closes. |
Not filled: the entry limit never trades and expires at session end; nothing at risk. |
Close: a producer CLOSE cancels the resting TP and flattens the position. |
Rejected: the broker refuses the placement; no order works. |
A bracket can also be pulled before it fills (a producer CANCEL), and the live→dry
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 core —
session.py(OAuth2 refresh-token session, never logs tokens, refuses non-tastyworks hosts),client.py(TastytradeClientREST),symbols.py(OCC option symbols),executor.py(BrokerExecutorport +TastytradeExecutoradapter — the swappable broker seam). - Consumer app —
stream.py(Redis Streams transport: intents / results / dead-letter),service.py(FaroServicedispatch loop, crash-tolerant with PEL recovery),fill_tracker.py(polls the broker to confirm fills, records the actual price/time, emitsFILLED),book.py(faro's believed state per trade),reconciler.py(diffs the book against the broker's positions, alerts onops:alerts, mints a guarded corrective close),sim_reconciler.py(acts when the producer's simulated fill or take-profit outruns the broker's real leg),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 .
uv run mypy faro tests tools
uv run typos .
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.
Metadata
Release files for dollarsmore-faro 0.11.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dollarsmore_faro-0.11.15.tar.gz | 164.5 kB | Without provenance | Details for dollarsmore_faro-0.11.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dollarsmore_faro-0.11.15-py3-none-any.whl | Python 3 | none | any | Details for dollarsmore_faro-0.11.15-py3-none-any.whl |
Total release size: 228.1 kB
Release files / dollarsmore_faro-0.11.15.tar.gz
| Download URL | dollarsmore_faro-0.11.15.tar.gz |
|---|---|
| Size | 164.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16cb087407b78ea57908cba618869facfa5d28524a3ed27fec585d2a5ae96bdc
|
|
BLAKE2b-256 checksum How to use checksums |
3a03740cc405c9eafe29b7d962ae4216debabff547aca002cba0e562a3e0051d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}
|
Release files / dollarsmore_faro-0.11.15-py3-none-any.whl
| Download URL | dollarsmore_faro-0.11.15-py3-none-any.whl |
|---|---|
| Size | 63.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3ef8ff2471afac49fda4a5719bb5ef51e9d6f7f52d1332b8d9ae49681b70ace
|
|
BLAKE2b-256 checksum How to use checksums |
be710e087e4d2896f62d3a4dd5ee961aa5d7b8b2bf602f8429cf2ecf7e3fe592
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}
|
Security for dollarsmore-faro 0.11.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.