James McCool
fixed colorto
10e8968
metadata
title: Paydirt Model Updates
emoji: πŸ’
colorFrom: red
colorTo: yellow
sdk: docker
app_port: 8501
pinned: false

πŸ’ Paydirt NHL Model Updates

A Streamlit application for generating NHL DFS lineup projections and updating model data in real-time.

Features

  • NHL Lineup Generation: Automated lineup optimization for DraftKings and FanDuel
  • Real-time Updates: Integrates with Google Sheets for live data updates
  • Multiple Platforms: Supports both DK and FD contests
  • Ownership Projections: ML-powered ownership predictions using XGBoost, LightGBM, and KNN models
  • Discord Notifications: Automatic notifications when updates complete
  • MongoDB Integration: Stores historical data and projections

Architecture

  • Python/Streamlit: Web interface and data processing
  • Go: High-performance lineup generation
  • MongoDB: Data storage and retrieval
  • Google Sheets API: Live data integration
  • Docker: Containerized deployment

Setup

Local Development

  1. Install Dependencies
pip install -r requirements.txt
  1. Configure Secrets

Create .streamlit/secrets.toml:

MONGODB_URI = "your-mongodb-uri"
GOOGLE_PROJECT_ID_1 = "your-project-id"
# ... (see .streamlit/secrets.toml.example for full template)
  1. Build Go Programs (if developing locally on Windows)
cd func/dk_nhl_go
go build -o NHL_seed_frames.exe NHL_seed_frames.go

cd ../fd_nhl_go
go build -o NHL_seed_frames.exe NHL_seed_frames.go
  1. Run the App
streamlit run src/streamlit_app.py

Hugging Face Deployment

This app is configured for deployment on Hugging Face Spaces using Docker.

  1. Create a Space on Hugging Face with Docker SDK
  2. Add Secrets in Space settings (Settings β†’ Repository secrets)
    • Add all variables from .streamlit/secrets.toml.example
  3. Push Code to your Space repository
  4. The Docker build will automatically:
    • Build Go programs for Linux
    • Install Python dependencies
    • Configure the environment

Project Structure

Paydirt_model_updates/
β”œβ”€β”€ src/
β”‚   └── streamlit_app.py      # Main Streamlit application
β”œβ”€β”€ func/
β”‚   β”œβ”€β”€ NHL_own_regress.py    # Ownership prediction models
β”‚   β”œβ”€β”€ dk_nhl_go/            # DraftKings lineup generator (Go)
β”‚   └── fd_nhl_go/            # FanDuel lineup generator (Go)
β”œβ”€β”€ Dockerfile                # Docker configuration
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ go.mod                    # Go module definition
└── README.md                 # This file

Technologies Used

Python Stack

  • Streamlit: Web interface
  • pandas: Data manipulation
  • numpy: Numerical operations
  • xgboost/lightgbm/scikit-learn: Machine learning models
  • pymongo: MongoDB client
  • gspread: Google Sheets API
  • ortools: Linear optimization

Go Stack

  • MongoDB Driver: Database connectivity
  • High-performance lineup generation algorithms

Environment Variables

Required environment variables (can be set in .streamlit/secrets.toml or as environment variables):

Variable Description
MONGODB_URI MongoDB connection string
GOOGLE_PROJECT_ID_1 Google Cloud project ID (primary)
GOOGLE_PRIVATE_KEY_1 Service account private key (primary)
GOOGLE_CLIENT_EMAIL_1 Service account email (primary)
GOOGLE_PROJECT_ID_2 Google Cloud project ID (backup)
GOOGLE_PRIVATE_KEY_2 Service account private key (backup)
GOOGLE_CLIENT_EMAIL_2 Service account email (backup)
DISCORD_WEBHOOK_URL Discord webhook for notifications
MASTER_SHEET_URL Google Sheets URL for master data

Usage

  1. Open the app in your browser
  2. Check connection status in the sidebar
  3. Click "πŸš€ Generate NHL Lineups" to start the process
  4. Monitor progress as the app:
    • Builds prop betting tables
    • Generates player-level outcomes
    • Creates stack matrices
    • Runs lineup optimization
    • Updates MongoDB with results
    • Sends Discord notifications

Security Notes

  • Never commit .streamlit/secrets.toml to version control
  • Use Hugging Face Secrets for production deployment
  • Rotate service account keys regularly
  • Keep MongoDB credentials secure

License

Proprietary - Paydirt Sports

Support

For issues or questions, contact the development team.