Files
Lottery_Project/README.md
T
2026-03-07 22:30:00 -05:00

102 lines
3.7 KiB
Markdown

# Lottery_Project
A Python project to analyze and pick lottery numbers using past draw results to predict future draws.
## Draw Dates
Mega Millions drawings are held every Tuesday and Friday. Powerball drawings are held every Monday,
Wednesday, and Friday. In order to conserve processing cycles, the predictor will only request new data
if there is the potential for new drawings to collect and save. Powerball can have up to 156/157 drawings
and Mega Millions can have up to 104/105 drawings per year, depending on how draw dates fall.
## Storage
The data will eventually be stored in database tables for faster execution. This will also allow for dynamic
calls for more data based on the draw dates and last drawing stored locally.
### Database Engine
Sqlite has been chosen for portability and ease of use.
## Historical Info
The first Powerball drawing was on April 22, 1992.
The first Mega Millions drawing was on September 6, 1996. The original name was "The Big Game" and was
rebranded to Mega Millions in May 2002.
However, each game has undergone rule changes that have altered the pool of numbers available for the main
(white) balls and their respective game balls as well. Due to this, the historical information used to
analyze the draws should start at the most recent rule change date.
**The most recent change for Powerball was on October 4, 2015, when the main ball pool increased from 59 to 69
numbers and the Powerball pool reduced from 35 to 26 numbers.**
**The most recent change for Mega Millions was on April 5, 2025, when the Megaball ball pool was decreased from
25 to 24 numbers as well as the addition of a 10x multiplier. The existing pool of 70 numbers for the main
game ball pool was part of changes made on October 28, 2017.**
Historical results can be scraped from the web and added to the database from the URLs below. The
results must be scraped by year. Changing the year in the URLs alters the resultset displayed.
Powerball: https://www.lotto.net/powerball/numbers/1992
Mega Millions: https://www.lotto.net/mega-millions/numbers/1996
### Historical Information Sources
- [Mega Millions Wikipedia](https://en.wikipedia.org/wiki/Mega_Millions)
- [Powerball Wikipedia](https://en.wikipedia.org/wiki/Powerball)
## Environment Variables
To facilitate environment variables for testing or execution, create a .env file in the root folder of
the project and add the following lines to it:
```bash
# General vars
LP_BASE_SCRAPE_URL="https://www.lotto.net/"
LP_RESULT_CONTAINER="div"
LP_RESULT_CLASS="results-vsmall archive-list"
LP_DRAW_DATE_CONTAINER="div"
LP_DRAW_DATE_CLASS="date"
LP_BALL_CONTAINER='li'
LP_BALL_CLASS="ball ball"
LP_DATE_INPUT_FORMAT="%B %d %Y"
LP_DATE_PASS_FORMAT="%m/%d/%Y"
# Powerball vars
LP_POWERBALL_INCEPTION="1992"
LP_POWERBALL_CLASS="ball powerball"
LP_POWERBALL_MULTIPLIER_CLASS="ball power-play"
LP_POWERBALL_RULE_CHANGE_DATE="2015-10-04"
LP_POWERBALL_MAX_MAIN_BALL="69"
LP_POWERBALL_MAX_POWERBALL="26"
# Mega Millions vars
LP_MEGA_MILLIONS_INCEPTION="1996"
LP_MEGABALL_CLASS="ball mega-ball"
LP_MEGA_MILLIONS_MULTIPLIER_CLASS="ball megaplier"
LP_MEGA_MILLIONS_RULE_CHANGE_DATE="2025-04-05"
LP_MEGA_MILLIONS_MAX_MAIN_BALL="70"
LP_MEGA_MILLIONS_MAX_MEGA_BALL="24"
# RegEx vars
LP_DATE_CLEAN_REGEX="r'(st|nd|rd|th)'"
# Datbase vars
LP_DATABASE_URL="sqlite:///predictor.db"
LP_DATE_INSERT_FORMAT="%Y-%m-%d"
# For pytest clean output
PYTHONWARNINGS=ignore
```
## TO-DOs
1. ~~Review standard tests for sqlalchemy objects~~
2. ~~Decide which DBE to use for data storage~~
3. ~~Create tests with in-memory database~~
4. ~~Update local database schema (alembic)~~
5. Complete starter code review
6. Add code to analyze numbers
7. Add code to main.py