This repository hosts two automation projects:
- Auto Lotto - predicts numbers for the Lotto 6/49 game using language models, buys tickets, and checks results.
- Auto Stock Trading - demonstrates a simple stock trading strategy and logging (currently paused).
Key directories and files:
auto_lotto_main.pyorchestrates the lotto workflow.utils/contains helpers for predictions, scraping results, purchasing tickets, and database access.auto_stock/holds the trading scripts and its README.docs/publishes lotto outcomes via GitHub Pages.github-runner.Dockerfilebuilds the self-hosted runner used by GitHub Actions.
This project predicts numbers for the Lotto 6/49 lottery, automatically purchases tickets, and verifies winning statuses. It is specifically built around Loto-Québec's version of Lotto 6/49: the historical draws are scraped from the Loto‑Québec website and tickets are bought through Loto‑Québec's online platform. Other Canadian lottery systems are not supported. The available predictors include:
- LLM - a language model suggests numbers based on recent draws.
- Random - generates purely random combinations.
- Frequency-weighted - analyzes historical draws to select the most common numbers. Simulations are available for 1–5 years of history.
- Least frequency-weighted - selects numbers that appear the least often in historical draws.
The purchased tickets and their results are displayed on GitHub Pages. https://l1nwatch.github.io/auto_market/
You can also view the frequency-weighted simulation results here: 1 Year | 2 Years | 3 Years | 4 Years | 5 Years | All Years
You can view the least frequency-weighted simulation results here: 1 Year | 2 Years | 3 Years | 4 Years | 5 Years | All Years
flowchart TD
%% Root 1: Daily Run
A[Daily Run - GitHub Actions] --> B[Self-Hosted Runner]
B --> C[Setup Environment and Execute main.py Script]
C --> F[Fetch Historical Data]
F --> G[Predict Next Lotto Numbers]
G --> D[Auto Purchase Tickets]
I --> H[Update SQLite Database]
F --> I[Check Win Status]
D --> H
H --> J[Generate Results HTML]
J --> Q[Push and Publish on GitHub Pages]
%% Additional Connections
%% H --> K
%% Database shared between Daily Run and Web Display
%% Failure Handling
C --> R[Retry on Failure]
%% Root 2: Web Displaying
Z[Web Displaying]
Z --> M[View Results on GitHub Pages]
%% Styling
style A fill:#f9f,stroke:#333,stroke-width:2px
style Z fill:#f9f,stroke:#333,stroke-width:2px
style H fill:#faa,stroke:#333,stroke-width:2px
style J fill:#bfb,stroke:#333,stroke-width:2px
style Q fill:#bfb,stroke:#333,stroke-width:2px
style M fill:#bfb,stroke:#333,stroke-width:2px
The execution schedule is defined in
.github/workflows/daily-run-main.yml.
This GitHub Actions workflow runs auto_lotto_main.py every day at 14:00 UTC
(9:00 AM Montreal time).
-
Create a self-hosted runner
Build and start the runner container with your credentials:
docker build -f github-runner.Dockerfile \
--build-arg OPENAI_API_KEY="$OPENAI_API_KEY" \
--build-arg RUNNER_TOKEN="$RUNNER_TOKEN" \
--build-arg LOTTO_USER="$LOTTO_USER" \
--build-arg LOTTO_PASSWORD="$LOTTO_PASSWORD" \
-t auto-lotto-github-runner .
docker run -d auto-lotto-github-runner-
Workflow execution
Once the runner is online, GitHub automatically triggers the workflow daily. You can also manually start it from the Actions tab using the
workflow_dispatchoption.
An experimental bot that interacts with the Tonghuashun trading system to buy recently dipped stocks and automatically place sell orders for profit or loss. The scripts are paused but remain available for reference.