This project is a collection of scripts that generate and submit alphas to the WorldQuant platform.
For the best performance and user experience, we recommend using the Naive-Ollama Alpha Generator which features:
Quick Start:
cd naive-ollama
# Setup credentials in credential.txt
docker-compose -f docker-compose.gpu.yml up -d
# Access dashboard at http://localhost:5000
__ __ .__ .___ __ .__ / \ / \___________| | __| _/________ _______ _____/ |_ _____ |__| ____ ___________ \ \/\/ / _ \_ __ \ | / __ |/ ____/ | \__ \ / \ __\ / \| |/ \_/ __ \_ __ \ \ ( <_> ) | \/ |__/ /_/ < <_| | | // __ \| | \ | | Y Y \ | | \ ___/| | \/ \__/\ / \____/|__| |____/\____ |\__ |____/(____ /___| /__| |__|_| /__|___| /\___ >__| \/ \/ |__| \/ \/ \/ \/ \/
Discord: https://discord.gg/3B2TmHQw
Usage Tutorial(WIP) on the web version: https://www.youtube.com/watch?v=xwr9atsulSA Further usage tutorial on the local ollama version: https://www.youtube.com/watch?v=EAeujBRrKiI
This is a Rust implementation of the alpha generator.
cargo build --release
cargo run --release
This is a Python implementation of the alpha generator.
Incoming... lol
A sophisticated alpha factor generation system that uses Ollama with financial language models to generate, test, and submit alpha factors to WorldQuant Brain. This system replaces the previous Kimi interface with a local Ollama-based solution for better performance and control.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ Web Dashboard │ │ Alpha Generator │ │ WorldQuant API │ │ (Flask) │◄──►│ (Ollama) │◄──►│ (External) │ │ Port 5000 │ │ Port 11434 │ │ │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │ │ │ │ ┌─────────────────┐ │ └──────────────►│ Alpha Orchestrator │◄─────────────┘ │ (Python) │ └─────────────────┘ │ ▼ ┌─────────────────┐ │ Results & │ │ Logs Storage │ └─────────────────┘
Create naive-ollama/credential.txt with your WorldQuant Brain credentials:
["your.email@worldquant.com", "your_password"]
cd naive-ollama
# Start the complete system with GPU acceleration
docker-compose -f docker-compose.gpu.yml up -d
# Or use the convenience script
start_gpu.bat
Open your browser and navigate to:
The web dashboard provides real-time monitoring and control:
naive-ollama/ ├── alpha_generator_ollama.py # Main alpha generation script ├── alpha_orchestrator.py # Orchestration and scheduling ├── alpha_expression_miner.py # Alpha expression mining ├── successful_alpha_submitter.py # Alpha submission to WorldQuant ├── web_dashboard.py # Flask web dashboard ├── templates/ │ └── dashboard.html # Dashboard HTML template ├── results/ # Generated alpha results ├── logs/ # System logs ├── Dockerfile # Docker image definition ├── docker-compose.gpu.yml # GPU-enabled deployment ├── docker-compose.yml # CPU-only deployment ├── requirements.txt # Python dependencies ├── credential.txt # WorldQuant credentials ├── start_gpu.bat # Windows GPU startup script ├── start_dashboard.bat # Windows dashboard startup script ├── README.md # Detailed documentation ├── README_Docker.md # Docker-specific documentation └── CHANGELOG.md # Version history
For detailed documentation, see:
This is basically a closed loop system where it starts with alpha_generator.py, which generates alpha ideas with Kimi AI. Then it dumps promising alpha to a local log file, which promising_alpha_miner.py will mine for better results, and dumps refined alpha to a local log file, which you can run successful_alpha_submitter.py to submit to the WorldQuant platform. These script can run concurrently.
While alpha_expression_miner.py is more of a utility script to mine alpha expressions from a given expression manually but not within the aforementioned closed loop system.
alpha_101_testing is currently under development.
alpha_polisher.py is currently under development.
pip install -r requirements.txt
The pre-consultant Python alpha generator uses Kimi AI to generate alpha expressions. Notice this may get you some alpha ideas as long as you are fine with the cost.
Human in the loop control is the future development direction of this script.
python alpha_generator.py
This script is used to mine alpha expressions from a given expression.
python alpha_expression_miner.py --expression "expression"
PS ~> python .\alpha_expression_miner.py --expression "cashflow_stability = ts_mean(cashflow_op, 252) / (debt_lt + 0.01);
>> stability_z = zscore(cashflow_stability);
>> debt_ratio = debt_lt / (assets + 0.01);
>> combined_score = stability_z - zscore(debt_ratio);
>> -rank(combined_score)"
2025-05-04 01:37:50,111 - INFO - Starting alpha expression mining with parameters:
2025-05-04 01:37:50,111 - INFO - Expression: cashflow_stability = ts_mean(cashflow_op, 252) / (debt_lt + 0.01);
stability_z = zscore(cashflow_stability);
debt_ratio = debt_lt / (assets + 0.01);
combined_score = stability_z - zscore(debt_ratio);
-rank(combined_score)
2025-05-04 01:37:50,111 - INFO - Output file: mined_expressions.json
2025-05-04 01:37:50,112 - INFO - Initializing AlphaExpressionMiner
2025-05-04 01:37:50,112 - INFO - Loading credentials from ./credential.txt
2025-05-04 01:37:50,112 - INFO - Authenticating with WorldQuant Brain...
2025-05-04 01:37:51,303 - INFO - Authentication response status: 201
2025-05-04 01:37:51,303 - INFO - Authentication successful
2025-05-04 01:37:51,303 - INFO - Parsing expression: cashflow_stability = ts_mean(cashflow_op, 252) / (debt_lt + 0.01);
stability_z = zscore(cashflow_stability);
debt_ratio = debt_lt / (assets + 0.01);
combined_score = stability_z - zscore(debt_ratio);
-rank(combined_score)
2025-05-04 01:37:51,303 - INFO - Found 3 parameters to vary
Found the following parameters in the expression:
1. Value: 252.0 | Context: ...s_mean(cashflow_op, 252) / (debt_lt + 0.01)...
2. Value: 0.01 | Context: ..., 252) / (debt_lt + 0.01);
stability_z = zsc...
3. Value: 0.01 | Context: ...debt_lt / (assets + 0.01);
combined_score = ...
Enter the numbers of parameters to vary (comma-separated, or 'all'): all
Parameter: 252.0 | Context: ...s_mean(cashflow_op, 252) / (debt_lt + 0.01)...
Enter range (e.g., '10' for ±10, or '5,15' for 5 to 15): 25
Enter step size: 1
Parameter: 0.01 | Context: ..., 252) / (debt_lt + 0.01);
stability_z = zsc...
Enter range (e.g., '10' for ±10, or '5,15' for 5 to 15): -0.05,0.05
Enter step size: 0.01
Parameter: 0.01 | Context: ...debt_lt / (assets + 0.01);
combined_score = ...
Enter range (e.g., '10' for ±10, or '5,15' for 5 to 15): -0.05,0.05
Enter step size: 0.01
2025-05-04 01:38:18,371 - INFO - Generating variations based on selected parameters
2025-05-04 01:38:18,375 - INFO - Generated 5100 total variations
2025-05-04 01:38:18,376 - INFO - Testing variation 1/5100: cashflow_stability = ts_mean(cashflow_op, 227) / (debt_lt + -0.05);
stability_z = zscore(cashflow_stability);
debt_ratio = debt_lt / (assets + -0.05);
combined_score = stability_z - zscore(debt_ratio);
-rank(combined_score)
2025-05-04 01:38:18,376 - INFO - Testing alpha: cashflow_stability = ts_mean(cashflow_op, 227) / (debt_lt + -0.05);
stability_z = zscore(cashflow_stability);
debt_ratio = debt_lt / (assets + -0.05);
combined_score = stability_z - zscore(debt_ratio);
-rank(combined_score)
2025-05-04 01:38:18,754 - INFO - Simulation creation response: 201
This script is used to clean up the logs.
python clean_up_logs.py
This script is used to submit successful alphas to the WorldQuant platform. It's not recommended to use this script as of now because it submits alphas in one batch instead of once per day.
python successful_alpha_submitter.py
The machine_lib.py module provides core functionality for alpha generation and testing through the WorldQuant platform. Here are the key components:
The main class that handles interactions with WorldQuant's API and alpha generation logic:
The library serves as the foundation for automated alpha mining and testing, providing the necessary tools to interact with WorldQuant's platform programmatically.
python machine_miner.py --username your_worldquant_username --password your_worldquant_password
Just like the pre-consultant non ai but without workaround like single simulation and skip for inaccessible data fields and operators.
pip install -r requirements.txt
python machine_miner.py --username your_worldquant_username --password your_worldquant_password



Data Collection Agents
Alpha Research Agents
Execution Agents
We welcome contributions from the community! Here's how you can help:
git checkout -b feature/improvement)git commit -am 'Add new feature')git push origin feature/improvement)We appreciate all contributions that help make this project better!
This project integrates components from Dify (agent-dify-api and agent-dify-web) for enhanced alpha mining capabilities. These components are used under the Apache License 2.0.
The Dify components (agent-dify-api and agent-dify-web) are licensed under the Apache License 2.0. This means:
For the complete terms and conditions, please refer to the Apache License 2.0.
The Dify components are integrated into this project to enhance alpha mining capabilities:
The Dify components are used to:
This project uses components from Dify, which are licensed under the Apache License 2.0. The original copyright notices and license information are preserved in the respective component directories.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
# Start the Dify API and Web services
docker-compose -f docker-compose.middleware.yaml up -d
# Check if services are running
docker ps
Access the Web Interface
http://localhost:3000Creating Alpha Mining Tasks
Monitoring Mining Progress
import requests
API_URL = "http://localhost:8000"
headers = {
"Authorization": "Bearer your_api_key"
}
# Create a new mining task
response = requests.post(
f"{API_URL}/api/v1/mining/tasks",
headers=headers,
json={
"name": "My Mining Task",
"data_fields": ["close", "volume", "high", "low"],
"time_period": "1Y",
"universe": "US",
"strategy": "correlation"
}
)
# Get task status
task_id = response.json()["task_id"]
status = requests.get(
f"{API_URL}/api/v1/mining/tasks/{task_id}",
headers=headers
)
# Get mining results
results = requests.get(
f"{API_URL}/api/v1/mining/tasks/{task_id}/results",
headers=headers
)
Resource Management
Error Handling
Performance Optimization
Service Issues
docker logs <container_id>docker-compose psdocker-compose restartAPI Issues
Mining Issues
For more detailed information about specific features and configurations, refer to the Dify Documentation.