Automated trading system for HowTheMarketWorks.com (HTMW) that exploits the delay between HTMW prices and real-time Yahoo Finance prices to identify and execute profitable arbitrage opportunities.
DelayEdge exploits the 3-15 minute delay in HTMW price updates to identify and execute profitable arbitrage opportunities. The system:
- Scans for stocks with the biggest gains in the last 3 minutes
- Selects the most profitable opportunity (by total profit, not just percentage)
- Buys all-in ($20,000) on the single best opportunity
- Monitors the position until HTMW price catches up to the entry real-time price
- Sells automatically when HTMW reaches the fixed target price
- Fixed Target Price: Target is set once at purchase time (Yahoo Finance real-time price) and never changes
- Market Hours Protection: Only trades during market hours (6:30 AM - 1:00 PM PST, Mon-Fri)
- All-In Strategy: Invests $20,000 per trade on the single most profitable opportunity
- Position Tracking: Uses CSV file as primary source of truth, with JSON metadata backup
- Failed Stock Filtering: Tracks and avoids stocks that cause errors
- Automated Execution: Fully automated trading with minimal manual intervention
Before you begin, ensure you have:
- Python 3.8 or higher - Download Python
- HTMW Account - A registered account on HowTheMarketWorks.com
- HTMW Cookies - Your authentication cookies from HTMW (see setup instructions below)
git clone https://github.com/yourusername/delayedge.git
cd delayedgepip install -r requirements.txtRequired packages:
requests- HTTP library for API callsyfinance- Yahoo Finance data retrievalpython-dotenv- Environment variable managementbeautifulsoup4- HTML parsingpytz(optional but recommended) - Timezone handling
- Log into HTMW in your web browser
- Install a cookie export extension (e.g., "EditThisCookie" for Chrome/Edge)
- Export your cookies as JSON:
- Click the extension icon
- Select "Export" → "JSON"
- Copy the entire JSON array
- Create a
.envfile in the project root:touch .env
- Add your cookies to the
.envfile:Important: The JSON must be on a single line with no line breaks.HTMW_COOKIES=[{"name":"cookie1","value":"value1",...},{"name":"cookie2","value":"value2",...}]
Edit config/config.json to customize trading parameters:
{
"threshold_pct": 0.001,
"order_size": 0,
"max_positions": 10,
"refresh_interval": 10,
"num_stocks": 50,
"min_cash_reserve": 10000.0,
"profit_target_pct": 0.002,
"test_mode": false,
"target_trade_value": 100.0
}Key settings:
num_stocks: Number of stocks to scan (default: 50)max_trade_value: Maximum trade value per position (default: $20,000)max_positions: Maximum simultaneous positions (default: 1)threshold_pct: Minimum gap percentage to trade (default: 0.25%)test_mode: Enable test mode (no actual trades)
Run the main trading system:
python delayedge.pySelect option 1 for Auto Mode to start automated trading.
# Use custom config file
python delayedge.py --config config/my_config.json
# Run in test mode (no actual trades)
python delayedge.py --test
# Limit number of trading cycles
python delayedge.py --cycles 10
# Custom number of stocks to scan
python delayedge.py --num-stocks 100Test the system without making real trades:
python delayedge.py --testdelayedge/
├── delayedge.py # Main trading system
├── README.md # This file
├── requirements.txt # Python dependencies
├── LICENSE # License file
├── CONTRIBUTING.md # Contribution guidelines
├── .gitignore # Git ignore rules
├── .env # Your HTMW cookies (create this, not in repo)
├── config/
│ └── config.json # Configuration file
├── data/ # Runtime data (auto-generated, gitignored)
│ ├── OpenPositions_*.csv # Position tracking
│ ├── failed_stocks.json # Failed stock tracking
│ └── positions_metadata.json
├── scripts/ # Utility scripts
│ ├── test_execution_price.py
│ ├── test_gap_strategy.py
│ ├── market_hours_arbitrage.py
│ └── price_gap_monitor.py
└── docs/ # Documentation
├── README.md
├── DATA_SOURCES.txt
├── HTMW_API.txt
├── LEGAL_ETHICS.txt
├── MODELS.txt
├── PIPELINE.txt
├── SCORING_AND_REPORTS.txt
├── STRATEGIES.txt
├── UI_FLOW.txt
└── extra/ # Additional docs
├── OPTIMIZATIONS.md
├── PROJECT_STRUCTURE.md
├── QUICKSTART.md
├── README_ARBITRAGE.md
├── README_ORDER_MONITORING.md
└── SUMMARY.md
- Market Hours: 6:30 AM - 1:00 PM PST, Monday-Friday
- Fixed Target: Target price is set at purchase time and never changes (prevents "chasing a moving target")
- All-In Strategy: Currently configured for 1 position at a time, $20,000 per trade
- Data Files: All runtime data (CSV, JSON) are stored in the
data/folder
The system uses a .env file for sensitive configuration:
HTMW_COOKIES: JSON array of your HTMW authentication cookies
- Never commit your
.envfile to version control - Never share your HTMW cookies publicly
- The
.envfile is automatically ignored by git (see.gitignore)
- Market Hours Only: System only trades during market hours (6:30 AM - 1:00 PM PST)
- Fixed Target: The target price is set at purchase time and never changes
- All-In Strategy: Currently configured for 1 position at a time, $20,000 per trade
- Educational Purpose: This project is for educational purposes only. Use at your own risk.
- Ensure your
.envfile exists in the project root - Verify the
HTMW_COOKIESvariable is set correctly - Make sure the JSON is on a single line with no line breaks
- Check that cookie names and values are properly formatted
Install pytz for better timezone handling:
pip install pytz- Verify your HTMW cookies are still valid (they may expire)
- Check your internet connection
- Ensure HTMW service is accessible
For more detailed information, see the docs/ folder:
docs/extra/QUICKSTART.md- Quick start guidedocs/extra/PROJECT_STRUCTURE.md- Detailed project structuredocs/extra/OPTIMIZATIONS.md- Performance optimizationsdocs/STRATEGIES.txt- Trading strategies documentation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This project is for educational purposes only. Trading involves risk, and past performance does not guarantee future results. Use at your own risk. The authors and contributors are not responsible for any financial losses incurred from using this software.
Made for the HTMW trading community