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.
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.
-
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
- Python 3.11+
- Chrome browser (compatible with version 134)
- Sufficient memory to run headless browsers
- Clone the repository:
git clone https://github.com/yourusername/hockey-betting-bot.git
cd hockey-betting-bot
- 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 = "*"
- Download Chrome and ChromeDriver:
- For Windows, place in
browser/windows/
directory - For Ubuntu, place in
browser/ubuntu/
directory
├── 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
POST /make_bet/strategy_1
POST /make_bet/strategy_2
POST /make_bet/strategy_3
All strategies accept the following parameters:
amount_rate_2period
: Bet amount for 2nd periodamount_rate_3period
: Bet amount for 3rd periodurl_match
: URL of the match to bet ontime_sleep
: Refresh interval in secondsfile
: Cookie file upload (containing authentication cookies)
The bot implements the following strategy:
-
After the 1st period:
- If 1st period had more than 1 goal, bet on the 2nd period
-
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
-
The app only places bets during period breaks for optimal timing
- 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
- 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"
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
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