WorldQuant BRAIN client — login (biometric Scan + auto re-login), simulation, batch run, and auto-keeping promising alphas
Project description
brain-login-and-sim
ไคลเอนต์ Python สำหรับ WorldQuant BRAIN — login (จัดการ biometric "Scan" + auto re-login), ส่ง simulation, รัน batch (สูงสุด 3 พร้อมกันตามลิมิต), และคัดเก็บ alpha ที่ผ่านเกณฑ์อัตโนมัติ
ติดตั้ง
pip install brain-login-and-sim
ตั้งค่า credentials
สร้างไฟล์ .env (ดู .env.example):
WQ_EMAIL=your-email@example.com
WQ_PASSWORD=your-password
# ส่งลิงก์ Scan เข้า Telegram (ทางเลือก แต่แนะนำ)
TELEGRAM_BOT_TOKEN=123456789:AAH...
TELEGRAM_CHAT_ID=123456789
ใช้งาน
from brain_login_and_sim import BrainClient, Simulator
# login — ถ้าระบบขอ biometric Scan จะส่งลิงก์เข้า Telegram แล้วรอจนสแกนเสร็จ
client = BrainClient(notify_telegram=True).authenticate()
print(client.whoami()["id"])
sim = Simulator(client)
# ยิง 1 ตัว
r = sim.simulate("ts_rank(close, 5)")
print(r["simulation"]["status"], r["alpha"]["is"]["sharpe"])
# รันหลายตัวจากไฟล์ JSONL คัดเก็บตัวที่ผ่านเกณฑ์อัตโนมัติ
sim.simulate_batch("alphas.jsonl", save_promising=True)
ฟีเจอร์หลัก
- Login + biometric Scan — ส่งลิงก์สแกนเข้า Telegram/อีเมล แล้ว poll รอจนเสร็จ (ไม่ต้องเฝ้าจอ)
- Auto re-login — เมื่อ session หมดอายุ (WorldQuant ให้ ~4 ชม.) เจอ 401 จะ login ใหม่แล้วลองซ้ำให้เอง
- คัดเก็บ alpha ดี — เกณฑ์
|Sharpe| ≥ 1และ|Fitness| ≥ 0.9(ค่าสัมบูรณ์ จับ flip candidate ที่ negate แล้วดี) - Batch — รันสูงสุด 3 ตัวพร้อมกัน (ลิมิต WorldQuant), error รายตัวไม่ล้มทั้ง batch
- Resume — จด checkpoint ด้วย hash รันไฟล์เดิมซ้ำจะข้ามตัวที่รันแล้ว รันต่อจากที่ค้าง
- Input ยืดหยุ่น — list ของสูตร, ไฟล์
.txt(1 สูตร/บรรทัด), หรือ.jsonlที่มี fieldexpression(+hash)
รูปแบบ JSONL
{"hash": "f7b3...", "expression": "rank(reverse(ts_delta(anl4_cfo_median, 10)))", "status": "generated"}
ระบบดึง expression ไปรัน และถ้าผ่านเกณฑ์จะเก็บ source_hash ไว้อ้างกลับไฟล์ต้นฉบับใน promising_alphas.jsonl
API ย่อ
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)
ทดสอบ
python tests/test_full_loop.py # mock API ไม่ต้องต่อเน็ต/รหัสผ่าน
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brain_login_and_sim-0.1.0.tar.gz.
File metadata
- Download URL: brain_login_and_sim-0.1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd7d6fcf498f55bb08c4044a0a278440478483d2c78d8fd58e8a88848135c62
|
|
| MD5 |
3f9dd069dd87638eb9549b85e26e773a
|
|
| BLAKE2b-256 |
fc42b4a4edbb453471f9a9a2f047b0f94c1c4924f9be38ed436e10c26cbde376
|
File details
Details for the file brain_login_and_sim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: brain_login_and_sim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbc01c1d59bca8b3ebd1191885be482bab447500b0d90b37bbe3dae5d91eb9eb
|
|
| MD5 |
59ab357eb5348fb23c53c9d094867c46
|
|
| BLAKE2b-256 |
c0fef6f813aa2d789586ae3a026a8d02d124d4d20e40adf5c10aa2732345121f
|