Skip to main content

WorldQuant BRAIN client — login (biometric Scan + auto re-login), simulation, batch run, and auto-keeping promising alphas

Project description

brain-login-and-sim

A Python client for WorldQuant BRAIN — handles login (including the biometric "Scan" step and automatic re-login), runs simulations, runs them in batches (up to 3 concurrently, matching the platform limit), and automatically keeps the alphas that pass your criteria.

Install

pip install brain-login-and-sim

Configure credentials

Create a .env file (see .env.example):

WQ_EMAIL=your-email@example.com
WQ_PASSWORD=your-password
# Send the Scan link to Telegram (optional, but recommended)
TELEGRAM_BOT_TOKEN=123456789:AAH...
TELEGRAM_CHAT_ID=123456789

Usage

from brain_login_and_sim import BrainClient, Simulator

# Log in — if a biometric Scan is required, the link is sent to Telegram
# and the client polls until you finish scanning on your phone.
client = BrainClient(notify_telegram=True).authenticate()
print(client.whoami()["id"])

sim = Simulator(client)

# Run a single simulation
r = sim.simulate("ts_rank(close, 5)")
print(r["simulation"]["status"], r["alpha"]["is"]["sharpe"])

# Run many alphas from a JSONL file and auto-keep the promising ones
sim.simulate_batch("alphas.jsonl", save_promising=True)

Features

  • Login + biometric Scan — sends the scan link to Telegram/email and polls until it's done, so you don't have to watch the terminal.
  • Auto re-login — when the session expires (WorldQuant allows ~4 hours), a 401 triggers an automatic re-login and the request is retried once.
  • Promising-alpha filter — keeps alphas with |Sharpe| >= 1 and |Fitness| >= 0.9 (absolute value, so it also catches "flip candidates" that become good when the expression is negated).
  • Batch — runs up to 3 simulations concurrently (the WorldQuant limit); a failure on one alpha does not abort the whole batch.
  • Resume — checkpoints by hash; re-running the same file skips already-processed alphas and continues where it left off (survives interruptions).
  • Flexible input — a list of expressions, a .txt file (one expression per line), or a .jsonl file with an expression field (and optional hash).

JSONL input format

{"hash": "f7b3...", "expression": "rank(reverse(ts_delta(anl4_cfo_median, 10)))", "status": "generated"}

The client extracts expression to run, and if the alpha passes the criteria it stores the originating source_hash in promising_alphas.jsonl so you can trace it back.

API at a glance

BrainClient: authenticate(on_biometric=None), whoami(), get(path), post(path), auto_relogin

Simulator(client): simulate(...), simulate_batch(...), is_promising(...), save_if_promising(...), load_promising(path), get_operators(), get_data_fields(...), get_alpha(id)

Test

python tests/test_full_loop.py   # mock API — no network or credentials needed

License

MIT

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

brain_login_and_sim-0.1.1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

brain_login_and_sim-0.1.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file brain_login_and_sim-0.1.1.tar.gz.

File metadata

  • Download URL: brain_login_and_sim-0.1.1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for brain_login_and_sim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e1da4da7f0167c97d1f92e09b4216f65cd940d41945dcc09d2c330d5eb142b1a
MD5 edabfa84c7d7d9d50f214d76c6f15b27
BLAKE2b-256 ed3600bbe0c2aaa36c44fa6b5463ba58a79a9ca3cc1958a5da1f667f35ffe2f9

See more details on using hashes here.

File details

Details for the file brain_login_and_sim-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for brain_login_and_sim-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d19dfbdb9d981ebf093582d88191c39225bdcf1b8e54a6bb9e2ade53cd6dd1c
MD5 6f09fd2fa4f3561cb083f9a78d487c4f
BLAKE2b-256 be6eadd76562a35004b164e2fe154b74f758a72ebae8d3ba22626f8867f30bba

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