DocsA five-minute read
Pervigil
Vigilat dum dormisIt keeps watch while you sleep.
Pervigil is a night watchman for US stocks. While the real stock market is closed and you are asleep, it watches the prices, decides whether to trade, explains itself in one sentence, and hands everything back flat in the morning.
The problem
US stocks used to sleep when Wall Street slept. They don't any more.
On Bitget, tokenised copies of Apple, Tesla, Nvidia and other US stocks trade all day, every day. The real market is only open 32.5 hours a week. For the other 80% of the week, prices keep moving while nobody is at the desk.
- Earnings come out after the close. News breaks on Saturday. Bitcoin moves on Sunday.
- A person cannot watch ten stocks through every night and weekend.
- Plenty of AI trading agents claim they can. Almost none of them show whether they beat a rule a child could write.
The answer
An agent that works the night shift, and a scorecard that says how good it is.
The watchman
An AI model (Qwen) that looks at the market every 6 hours while it is closed, chooses to buy, sell or stay out, and writes down why. Hard limits it cannot override keep it from betting too much.
The proving ground
The same agent, replayed over 55 past nights and marked against three fixed rules: do nothing, always follow the move, always bet against it. The results are published, including the runs where it lost.
One decision, step by step
- Sense. For each of ten stocks (NVDA, TSLA, AAPL, MSFT, AMZN, GOOGL, META, SPY, QQQ, COIN) it reads how far the price has moved since the market closed, and compares that with the size of that stock's normal day. It also reads Bitcoin's move, whether the company has just reported earnings, and recent headlines.
- Decide. Qwen answers with a target for each stock and a one-sentence reason. Staying out is a valid answer, and it is the usual one.
- Risk layer. Plain code checks the answer against the rule book below and cuts or blocks anything outside it. Every block is logged.
- Execute. What survives is filled in a paper account at Bitget prices, with fees and slippage, and placed as a real order on Bitget's demo exchange, so there is an order number to check.
- Flatten. 15 minutes after the market opens, everything is closed and a short morning note is written for the human.
What it is built on
Pervigil is assembled from the tools this hackathon put on the table. Each one does a specific job.
- The brain
- Qwen 3.8 MaxAlibaba Cloud's model, called through the hackathon gateway. It makes every trading decision and writes the morning note. 335 of its answers are saved in the repository, so the replay can be re-scored without calling it again.
- The prices
- Bitget market data15-minute candles for ten stock tokens and Bitcoin, from Bitget's public API. The replay and the live agent read the same feed.
- The calendar
- Bitget MCP serverThe earnings calendar and the
market headlines the live agent reads, from
agent.bitget.com/mcp. - The news
- Chainbase AgentKeyCompany news for the stocks that have moved at least half a normal day, so the agent can tell a move with a cause from one without.
- The orders
- Bitget demo exchangeEvery position is placed as a market order through the unified account API, and the order number is written to the live log.
- The clock
- GitHub ActionsWakes the agent every hour, commits its log, and rebuilds this site. Nobody presses anything.
The rule book
These limits are ordinary code, not instructions to the AI. The model cannot talk its way past them.
- Per stock
- 20%of the account, at most
- All positions
- 60%of the account in total, at most
- Position stop
- −3%on one stock closes it and bars it for the night
- Night stop
- −2%on the account closes everything until the next night
- Late entries
- 30 minbefore the open, no new risk is allowed
- Costs charged
- 0.15%per side: 0.10% fee plus 0.05% slippage
Is it any good
Over 55 replayed nights the current agent returned +5.80% after costs, against +3.40% for the best fixed rule and 0.00% for doing nothing.
That number needs three honest notes, and the live page shows all of them:
- The first run lost. The agent bet that big overnight moves would reverse. They mostly continued.
- A data bug was part of the story. The earnings calendar was one night early, so the agent was told "no news" on the very night a company reported.
- The gain is concentrated. Almost all of it comes from four earnings nights, after one rule was added: do not bet against a move on the night a company reports. That rule was written after seeing those nights, so it is not yet proven on new ones.
You can test this yourself. Beat the agent lets you build a rule with two sliders and replays it over the same nights. A few rules do beat it.
Run your own
Watching costs nothing: open the live page. To run your own copy you need to be comfortable with GitHub. It takes about twenty minutes.
- Fork the repository to your own GitHub account.
- Get an AI key for any OpenAI-compatible model, and a Bitget demo API key if you want demo orders.
- Add them as repository secrets:
LLM_BASE_URL,LLM_API_KEY,LLM_MODEL, and optionallyBITGET_DEMO_API_KEY,BITGET_DEMO_SECRET,BITGET_DEMO_PASSPHRASE. - Enable GitHub Actions and GitHub Pages. The agent then wakes every hour, decides when a decision is due, and rebuilds your page.
It is plain Python 3.12 with no extra packages. The README lists the commands to replay the proving ground on your own machine.
What it is not
- Paper trading only. No real money is at risk, and it cannot connect to anyone's live account.
- Not a product yet. There is no sign-up or one-click start. Running your own copy needs a developer.
- A short record. 55 replayed nights and a few days of live log. The replay sees prices and earnings dates, not the news the live agent reads.
- Three stocks are paper only. Bitget's demo exchange does not list MSFT, SPY or QQQ, so those positions exist in the paper account alone.
- Not financial advice.