尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
Automated trading bot for Bitcoin, Ethereum, gold & forex.
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗An open-source Python trading bot for automating 15-minute prediction markets on Public.com, including event contracts tied to Bitcoin (BTC), Ethereum (ETH), gold, and foreign exchange (forex).
The bot uses the Public API and Python SDK to monitor available markets, evaluate contract prices, and place orders based on user-defined trading rules. It runs locally on your computer and includes a browser-based dashboard for managing strategies, monitoring positions, and tracking trading activity.
The dashboard, shown with sample data.
Important: This bot can place real trades using real money. Trading begins only after you explicitly start it. Event contracts involve significant risk, including the potential loss of the entire purchase amount plus applicable fees. Automated trading does not eliminate market or execution risk.
Explore 15-minute prediction markets on Public or read the 15-minute prediction market API and Python SDK guide.
A computer that stays on and awake while the bot trades. The bot runs inside the app on your computer: it keeps trading with the browser closed, but stops if the app stops or the computer sleeps. It's built and tested on macOS.
A Public.com brokerage account that can trade prediction markets. If you can buy a 15-minute market (e.g. "BTC 15 min") in Public's own app, you're set.
git, to download the code (macOS asks to install it the first time you run git).
uv, the Python tool that installs and runs the app. You don't need to install Python yourself; uv downloads the right version the first time.
brew install uv # with Homebrew
# or
curl -LsSf https://astral.sh/uv/install.sh | sh # without Homebrew
Check it worked with uv --version.
git clone https://github.com/PublicDotCom/15-minute-prediction-market-bot.git
cd 15-minute-prediction-market-bot
uv sync
The first uv sync takes a minute, because uv downloads Python 3.14 and the app's libraries into a
private .venv folder in the project. Nothing is installed system-wide.
Treat the key like a password: anyone who has it can trade in your account. If it's ever exposed, delete it on that same page and it stops working immediately.
uv run python -m fifteen_bot
Your browser opens at http://127.0.0.1:8765. Leave the terminal window open: closing it stops the app, and with it the bot.
To keep your Mac awake while the bot runs, start it like this instead:
caffeinate -i uv run python -m fifteen_bot
caffeinate -i stops the Mac idle-sleeping, but closing a laptop lid still puts it to sleep.
By default nothing is written to disk: your key, markets, rules and results live only in the app's memory. To keep them when you stop and start the app, give it a database file and an encryption key:
# Once: create an encryption key, and keep a copy somewhere safe (e.g. a password manager).
uv run python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
# Every time you start the app:
DATABASE_URL=sqlite:///bot.db SESSION_ENCRYPTION_KEY=<your key> uv run python -m fifteen_bot
bot.db in the project folder: markets, rules, trade history,
the account you picked, whether the bot was running, and your API key encrypted with the
encryption key. Without the encryption key, the file is useless to anyone who copies it.SESSION_ENCRYPTION_KEY=<new key>,<old key> (the app re-encrypts
everything with the new key), then use just <new key> from then on.DATABASE_URL also accepts a Postgres database (postgresql://…).Stop the app (Ctrl+C), then:
git pull # get the latest code
uv sync # only needed if dependencies changed; safe to run anyway
uv run python -m fifteen_bot # with the same DATABASE_URL and SESSION_ENCRYPTION_KEY, if you use them
Always restart after an update. The browser loads the new page right away, but the running app keeps the old code until it restarts, and the mix causes odd errors. With saving turned on, your bot carries on after the update; without it, you set it up again.
127.0.0.1), so other devices on your network can't
reach it, and it refuses requests from other websites (strict Content-Security-Policy, no
cookies, no framing).localStorage, never the key), which is
what lets you come back without pasting the key. Anyone using your browser on this computer
could control the bot until you click Disconnect. Deleting the key in Public's API
settings also cuts it off immediately.| Setting | Default | What it does |
|---|---|---|
--port (or PORT) | 8765 | Port the dashboard is served on |
--no-browser | off | Don't open the browser on start |
DATABASE_URL | unset | Turns on saving: sqlite:///bot.db, or postgresql://… (see above) |
SESSION_ENCRYPTION_KEY | unset | Encrypts your saved API key; required with DATABASE_URL. Comma-separate two to change keys (new one first) |
Advanced, for when several people share one running copy or it runs behind a proxy: --host
(default 127.0.0.1, this computer only), MAX_SESSIONS (default 200, the most people
connected at once) and FORWARDED_ALLOW_IPS (default 127.0.0.1, proxies whose X-Forwarded-*
headers are trusted). Each person connects with their own key and gets their own bot.
| Problem | Fix |
|---|---|
| Odd errors after an update | The app is still running old code. Restart it (Ctrl+C, then start again). |
| "Public didn't accept that key" | Copy the whole key again, or generate a new one. Check it wasn't deleted in Public's API settings. |
| "Couldn't reach Public" | Check your internet connection and try again. |
| "Your session has ended" | You clicked Disconnect, the app was stopped (without saving turned on), the bot sat stopped with no page open for a day, or Public stopped accepting the key. Connect again. |
| "The bot is restarting" for more than a few seconds | Another copy of the app is running on the same database file. Stop it (Ctrl+C in its terminal). |
| "Reconnecting to the bot…" banner | The page lost its connection to the app and is retrying. If the app is still running, the bot keeps trading meanwhile. |
| Port 8765 is already in use | Another copy is probably still running. Stop it, or start this one with --port 9000. |
| The browser doesn't open | Go to http://127.0.0.1:8765 yourself, or start with --no-browser and open it when you like. |
| A card says "Not supported" | Markets with more than two outcomes (e.g. "Crypto Leader") can't be traded yet. Remove it. |
| A card says "Waiting for fresh prices" | Normal for a moment after starting or a network blip. If it persists, check your connection. |
| Use a different API key | Disconnect, then connect with the new key. |
| Start completely fresh | Disconnect. With saving turned on you can also stop the app and delete bot.db. |
KXBTC15M. Every 15 minutes it opens a new window
(event). Each market has its own rule and can be switched on/off independently.bid − estimated selling fee − (entry price + buying fee per contract) is at least the
take-profit, or at most minus the stop-loss, the bot sells the filled contracts with a DAY
limit sell at the bid (rounded down to the cent). A sell that hasn't filled after 5 seconds is
cancelled and re-placed at the new bid while the target still holds. A buy still filling is
cancelled first. If Public rejects a sell, the bot doesn't retry, and the position settles as
normal. Open sells are cancelled when the window closes.$1 × contracts still held if won, plus anything sold early, minus cost and Public's estimated
fees). A position sold out completely is marked sold straight away, and counts as a win or a
loss by its P&L.SELL
limit orders on the EVENTCONTRACT instrument. A sell still isn't guaranteed to fill, so try a
take-profit or stop-loss on a 1-contract position before relying on it.Both are optional: one for the whole account, and one per market (part of the market's rule).
Public allows 10 API requests per second per account. Every request the bot makes goes through a
limiter (fifteen_bot/ratelimit.py) that sends at most 8 per second, evenly spaced, with orders
and cancels ahead of routine price checks. If Public still answers 429, requests pause for its
Retry-After time. To keep traffic low, prices for all markets come from one batched quote request
and open orders from one order search; typical use is 1–3 requests per second. Requests time out
after 10 seconds, so one slow response can't make the bot miss a buy window. Other tools calling
Public's API for the same account at the same time count toward the same limit.
A 15-minute prediction market trading bot is software that monitors short-duration event contracts and executes supported trades based on predefined rules. Public’s open-source Python bot supports automated workflows for eligible 15-minute prediction markets using the Public API.
Yes. Public’s 15-minute trading bot supports automated trading workflows for Bitcoin (BTC) event contracts. Users can configure conditions such as contract prices, time remaining, and position sizes. Orders are subject to market availability, liquidity, and execution limitations.
The Public 15-Minute Bot is an open-source Python project for automating supported prediction market trading through Public’s API. It includes configurable strategies, order execution, and a browser-based dashboard.
Yes. The bot supports available 15-minute event contract series across multiple asset classes, including Bitcoin, Ethereum, gold, and selected forex pairs. Specific market availability depends on the contracts supported through Public’s API.
Yes. The bot uses the official Public Python SDK to communicate with Public’s API, retrieve supported market information, and submit orders. Developers can also follow the 15-minute prediction market API guide to build their own programmatic workflows.
Yes. The bot includes optional take-profit and stop-loss settings for attempting to close positions before expiration, and early sells have filled in live trading through Public’s API. However, orders may fail to execute, and configured thresholds do not guarantee a particular exit price or limit losses. To cap how much the bot can lose in a day, set a daily loss limit.
The bot can monitor supported 15-minute prediction markets continuously while the application is running and the computer remains awake. It stops operating if the application closes or the computer sleeps. Market availability and trading interruptions may affect execution.
Profitability is not guaranteed. Automated trading strategies remain exposed to market fluctuations, trading fees, liquidity constraints, and execution risk. The bot’s historical win-rate and profit-and-loss reporting do not predict future performance.
uv run pytest # run the tests
TEST_DATABASE_URL=postgresql://… uv run pytest # also test against a real Postgres
uv run python -m fifteen_bot --port 9000 --no-browser # other port, no auto-open
fifteen_bot/
app.py web server: JSON API + WebSocket + dashboard, all scoped per session
sessions.py sessions: create/rejoin by key, idle expiry, resume/suspend (tested)
persist.py optional saving: encryption, SQLite/Postgres, one-copy-at-a-time lock (tested)
engine.py the trading loop: windows, quotes, orders, early exits, settlement
ratelimit.py keeps a session under Public's 10/s limit (tested)
strategy.py strategy model and pure decision logic (tested)
store.py in-memory SQLite for one session's markets, rules and trades
static/ dashboard (plain HTML/CSS/JS, no build step)
.github/ CI: the tests, on every pull request
docs/ the dashboard screenshot in this README
tests/ uv run pytest
GET /healthz reports whether the app is up and "ready" (has loaded any saved sessions).
Uses the official publicdotcom-py SDK.