Guides
Examples and scripts
Rystic-Inc/rystic-scripts holds the scripts that ship in the simulators’ release archives, one folder per simulator, plus four example stacks. The scripts are MIT-licensed: copy, change and share them. The simulators stay under each archive’s LICENSE.txt.
git clone https://github.com/Rystic-Inc/rystic-scripts
| folder | what’s in it |
|---|---|
<simulator>/check.sh | a smoke check, one per simulator |
kalshi/ | trade-check.sh, api-check.py, bots/, recordings/capture-setup.sh |
github-pulls/bots/ | bot.py, test_bot.py and five broken variants/ |
environments/ | four example stacks |
What you need
bashandcurl. The shell scripts run on thebash3.2 that macOS ships. None usesjq, but the command that reads a port fromrystic run --jsondoes.curl7.75 or later fors3/check.sh, which signs its requests with--aws-sigv4.- Python 3.9 or later. The Kalshi scripts use only the standard library; the GitHub bots need
requests(pip install requests). opensslforapi-check.py. Kalshi’s and Clerk’scheck.shuse it when it’s there.- An installed simulator, and the API key or license
rystic loginstored. A script that boots a simulator finds them where the CLI does.
check.sh
One per simulator. It boots its own simulator from the binary in its folder, runs a short round trip on that simulator’s API (table below), then resets. The simulator stays up so you can point a client at it.
Run the shipped copy
An installed simulator lives in ~/.rystic/twins/<product>/<version>/ (under $RYSTIC_HOME if you set it): the binary, check.sh, HOWTO.md, LICENSE.txt and any extra scripts. rystic check prints the path:
rystic check stripe-twin
# -> ✓ stripe-twin ... serves and resets cleanly (model ...)
# -> deeper product checks: bash .../check.sh
PORT=$(python3 -c 'import socket; s = socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
bash ~/.rystic/twins/stripe-twin/$(cat ~/.rystic/twins/stripe-twin/current)/check.sh localhost:$PORT
# -> ...✓ stripe-twin is good to go on localhost:... (kill ... to stop; its log is ...)
- The argument is the address to serve on, and the Python line above picks a port nothing holds. Without one it takes port 8080 or a free port, depending on the simulator, and it prints the address it serves on.
RYSTIC_CHECK_STOP=1stops the simulator once the checks pass, for CI:
PORT=$(python3 -c 'import socket; s = socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
RYSTIC_CHECK_STOP=1 bash ~/.rystic/twins/stripe-twin/$(cat ~/.rystic/twins/stripe-twin/current)/check.sh localhost:$PORT
# -> ...✓ stripe-twin passed its checks on localhost:... (stopped)
rystic check is the same idea for any simulator: it serves, reports a model hash and resets.
Run the repo copy
check.sh runs the binary next to it. Put the two in a folder of your own, not in ~/.rystic:
mkdir check
cp rystic-scripts/stripe/check.sh check/
ln -s ~/.rystic/twins/stripe-twin/0.0.36/stripe-twin check/
PORT=$(python3 -c 'import socket; s = socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
RYSTIC_CHECK_STOP=1 bash check/check.sh localhost:$PORT
# -> ✓ stripe-twin passed its checks on localhost:... (stopped)
What each one checks
| simulator | check.sh |
|---|---|
| Kalshi | seeds a market and reads it back; then run trade-check.sh |
| GitHub | lists the open-queue scenario’s pull requests, reads one, refuses an unknown one |
| Stripe | creates a customer, reads it back, 404 on an unknown id |
| Slack | creates a channel, posts a message, reads both back, refuses an unknown channel |
| Linear | files an issue in the sprint-board scenario, reads it back, refuses an unknown issue |
| Lob | saves an address, sends a postcard to it, reads both back, refuses an unknown postcard |
| Notion | adds a page and a paragraph to the team wiki, reads them back, trashes the page; refuses a missing page and a request without Notion-Version |
| Okta | creates a staged user and a group, adds the user, reads both back, 404 on an unknown user |
| PayPal | creates an order, reads it, patches it, 404 on an unknown capture |
| Resend | creates, reads and lists an email; creates, reads and deletes a webhook; 404 on an unknown email |
| S3 | lists the static-site scenario’s buckets, puts and reads an object under a key with a slash, deletes it, refuses a missing key |
| Clerk | creates a user and an organization, merges metadata, refuses a missing user and a request with no secret key; with openssl, signs in through the browser companion |
| Dropbox | creates a folder, uploads and downloads a file, refuses a duplicate and a missing path with 409, deletes |
| Google Drive | creates a folder, uploads a file into it, downloads it, 404 on a missing file, deletes |
| Anthropic | reads the skill library scenario’s skills, sends a message and gets an assistant reply, creates a skill and reads it and its version back, 404 on an unknown skill, refuses a request with no API key |
| Gmail | reads the busy inbox scenario’s messages, inserts a message and reads it back at the top of the inbox, 404 on an unknown message, refuses a request with no token |
| Shopify | reads the apparel storefront scenario’s shop and a product, creates a product and reads it back with the handle its title makes, null for an unknown product, refuses a request with no access token, resets and reloads the scenario |
| Word | serves the add-in harness, reads the redlined contract’s tracked changes and comment, appends a tracked insertion, refuses a missing comment with ItemNotFound |
| Jira | reads the sprint-board scenario’s epic and searches its issues, files an issue and reads it back in To Do, 404 on an unknown issue, refuses a request with no credential, resets and reloads the scenario |
| QuickBooks | reads the Blue Heron Bakery company and the seeded customer with its balance, creates a vendor and reads it back at SyncToken 0, fault 610 on an unknown customer, 401 with no token, resets and reloads the scenario |
| PostHog | reads the first-event scenario’s signup event, captures an event and reads it back, 401 on an event with no project token, resets and reloads the scenario |
| Modal | over gRPC, with a curl built for HTTP/2: looks up the app-states scenario’s deployed app by name, creates an app and reads it back, NOT_FOUND on a function the app does not have, resets and reloads the scenario |
| Airtable | reads the launch-tracker scenario’s first task, creates a record and reads it back, 404 NOT_FOUND on a malformed record id, 401 on a request with no token, resets and reloads the scenario |
Kalshi
Start a simulator with a market in it:
PORT=$(rystic run kalshi-twin -d --name kalshi --port 0 --scenario tight_book --json | jq -r .data.port)
--port 0 picks a free port and PORT keeps it. The commands below use it, and rystic stop kalshi ends it.
In the archive these scripts sit next to the binary; in the repo they’re under kalshi/.
Bots
B=rystic-scripts/kalshi/bots
python3 $B/book-reader.py http://localhost:$PORT
# -> bid 0.3900 x 25 | ask 0.4000 x 25 | mid 0.3950
python3 $B/balance-watcher.py http://localhost:$PORT
# -> balance 10000.0000 | positions flat | 0 resting order(s) | 0 fill(s)
python3 $B/simple-bot.py http://localhost:$PORT
# -> buy 1 @ 0.4000: filled 1.00 — balance 9999.6000
python3 $B/random-walker.py http://localhost:$PORT
# -> the twin coped: every order answered, account and book still read
The first three run until Ctrl-C. What each bot does, its arguments and how RYSTIC_TICKS stops it: Kalshi → Example bots.
Checks
bash rystic-scripts/kalshi/trade-check.sh localhost:$PORT
# -> ✓ trade check passed: FOK bid 10 @ 0.40 crossed the book — fill, position, book depletion, and WS egress all correct
python3 rystic-scripts/kalshi/api-check.py http://localhost:$PORT
# -> ✓ account.limits: GET account/limits -> 200 (want 200)
# -> …one line per check, then the total
Both reset the simulator and seed their own state, so post your scenario again afterward. What each one checks: Kalshi → Smoke tests.
Sort your captures into tapes
capture-setup.sh sorts Kalshi capture files you already have into the folder layout replay and batch backtests read. It records nothing:
bash rystic-scripts/kalshi/recordings/capture-setup.sh ~/Downloads/captures
# -> ✓ 2 placed, 0 already in place, 0 skipped — 2 markets / 2 files under /Users/you/data/kalshi-orderbook/events
Kalshi → Batch backtests → Tapes says where it copies and what it skips.
GitHub review bots
github-pulls/bots/ holds a Kalshi market maker, not a GitHub client. It is the code under review in the GitHub simulator’s github-pulls_bot_pr_queue scenario.
bot.pykeeps a bid and an ask resting behind the touch on one market, never crosses, and cancels everything atSESSION_SECONDS(default 30) or on SIGTERM. It is configured through the environment:KALSHI_BASE_URL,TICKER,QUOTE_SIZE,MAX_INVENTORYand others.variants/holds five copies ofbot.py, each broken one way: sides swapped, a syntax error, the wrong orders path, prices in cents, a required order field dropped. Each one is an open pull request in that scenario, #11 to #15, with a failedbot-smokecheck run. Use them to test a grader or a review agent: approving any of them means it missed the bug.test_bot.pychecks thatbot.pyrests both sides, never crosses or fills on a static book, and exits flat. Then it checks that no variant ever rests both sides.
pip install requests
python3 rystic-scripts/github-pulls/bots/test_bot.py
# -> Ran 2 tests in 33.3s
# -> OK
- With no variables, it boots the kalshi-twin that
rystic pullinstalled.KALSHI_BASE_URL=http://localhost:$PORTuses a simulator that’s already running;KALSHI_TWIN_BIN=./kalshi-twinboots that binary. - It loads the
tight_bookscenario before each bot.
Run the bot on its own against the Kalshi simulator from above, reset to tight_book:
curl -X POST localhost:$PORT/_rystic/scenario \
-H 'content-type: application/json' -d '{"name":"tight_book"}'
KALSHI_BASE_URL=http://localhost:$PORT SESSION_SECONDS=5 python3 rystic-scripts/github-pulls/bots/bot.py
# -> rest bid 2@0.38 …
# -> rest ask 2@0.41 …
# -> flat, exiting
rystic stop kalshi
Example stacks
environments/ holds four stack files, each with the docker-compose.yaml that rystic export compose writes from it: Multi-simulator environments → Example stacks lists them and how to run one.