Skip to content

Ambassador-of-programming/HockeyBot-Automation-FastAPI

Repository files navigation

Hockey Betting Bot

A sophisticated FastAPI-based service for automating hockey betting strategies on the Marathon betting platform. This bot implements custom strategies for placing bets on hockey matches based on real-time score analysis.

Overview

This application monitors hockey matches and automatically places bets based on predefined strategies. It uses Selenium with undetected Chrome to navigate the Marathon betting site, analyze match information, and place bets during strategic moments such as periods breaks.

Features

  • Multiple Betting Strategies:

    • Strategy 1: Places "Under" bets on period totals
    • Strategy 2: Places "Over" bets on period totals
    • Strategy 3: Legacy strategy (previous implementation)
  • Real-time Match Analysis:

    • Analyzes period scores and detects break periods
    • Makes betting decisions based on previous period scores
    • Supports both 1.5 and 2.5 total goal options
  • Automated Browser Interaction:

    • Uses undetected Chrome to bypass anti-bot protections
    • Automatically navigates betting site
    • Handles cookie-based authentication
    • Performs form submissions
  • REST API:

    • Easy integration with frontend or other services
    • Multiple endpoints for different strategies
    • Cookie-based authentication support

System Requirements

  • Python 3.11+
  • Chrome browser (compatible with version 134)
  • Sufficient memory to run headless browsers

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/hockey-betting-bot.git
cd hockey-betting-bot
  1. Install dependencies using pipenv (recommended):
# Install pipenv if you don't have it
pip install pipenv

# Install dependencies from Pipfile
pipenv install

The project uses the following dependencies (from Pipfile):

fastapi = "*"
python-jose = "*"
undetected-chromedriver = "*"
beautifulsoup4 = "*"
uvicorn = "*"
python-multipart = "*"
  1. Download Chrome and ChromeDriver:
  • For Windows, place in browser/windows/ directory
  • For Ubuntu, place in browser/ubuntu/ directory

Project Structure

├── main.py                    # FastAPI application entry point
├── routes
│   ├── make_bet.py            # API endpoints for betting strategies
│   └── create_token.py        # Authentication token endpoints
├── strategies
│   ├── analyze_match_info.py  # Match analysis logic
│   ├── driver_chrome.py       # Chrome driver initialization
│   ├── old_stavka.py          # Legacy strategy implementation
│   ├── stavka_1.py            # Under betting strategy
│   └── stavka_2.py            # Over betting strategy

API Endpoints

Make Bet Endpoints

Strategy 1 (Under bets)

POST /make_bet/strategy_1

Strategy 2 (Over bets)

POST /make_bet/strategy_2

Strategy 3 (Legacy)

POST /make_bet/strategy_3

Parameters

All strategies accept the following parameters:

  • amount_rate_2period: Bet amount for 2nd period
  • amount_rate_3period: Bet amount for 3rd period
  • url_match: URL of the match to bet on
  • time_sleep: Refresh interval in seconds
  • file: Cookie file upload (containing authentication cookies)

Betting Strategy Logic

The bot implements the following strategy:

  1. After the 1st period:

    • If 1st period had more than 1 goal, bet on the 2nd period
  2. After the 2nd period:

    • If both 1st and 2nd periods had more than 1 goal, bet on the 3rd period
    • If 1st period had more than 1 goal but 2nd didn't, bet on the 2nd period
  3. The app only places bets during period breaks for optimal timing

Usage Example

  1. Start the server using pipenv:
# Activate virtual environment
pipenv shell

# Run the server
python main.py

# Alternatively, run without activating the shell
pipenv run python main.py
  1. Make a bet request:
curl -X POST "http://localhost:8000/make_bet/strategy_1" \
  -F "amount_rate_2period=100" \
  -F "amount_rate_3period=150" \
  -F "url_match=https://www.marathonbet.ru/en/betting/Ice+Hockey/NHL/New+York+Rangers+vs+Florida+Panthers+-+24837992" \
  -F "time_sleep=60" \
  -F "file=@cookies.txt"

Security Note

This application requires authentication cookies to operate. Make sure to:

  • Keep your cookies secure
  • Use dedicated betting accounts with appropriate limits
  • Run the service in a secure environment

Disclaimer

This project is designed for educational purposes only. Before using this bot for real betting:

  • Ensure that automated betting is allowed by the betting platform
  • Follow all applicable laws in your jurisdiction
  • Use responsible gambling practices

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages