CommodityNode Automated Daily Updates

Prerequisites

  1. Python dependencies:
    pip install yfinance openai Pillow
    
  2. Environment variable:
    export OPENAI_API_KEY="sk-..."
    

    For cron, add it to your shell profile (~/.bashrc or ~/.zshrc) or set it directly in the crontab.

Quick Test

Run the full pipeline manually to verify everything works:

cd /home/phillip/.openclaw/workspace/commoditynode

# Test individual scripts
python3 scripts/update_prices.py
python3 scripts/auto_post.py --dry-run
python3 scripts/auto_post.py --max 1 --no-commit

# Test the full daily script
bash scripts/run_daily.sh

Cron Setup

# Open the cron editor
crontab -e

# Add this line (runs at 9 AM daily, after US pre-market opens):
0 9 * * * OPENAI_API_KEY="sk-..." /home/phillip/.openclaw/workspace/commoditynode/scripts/run_daily.sh

# Or if your API key is in ~/.bashrc:
0 9 * * * bash -lc '/home/phillip/.openclaw/workspace/commoditynode/scripts/run_daily.sh'

Alternative schedules

0 9 * * 1-5    # Weekdays only (commodity markets are closed on weekends)
0 10 * * *     # 10 AM daily
0 9,16 * * 1-5 # Twice daily: 9 AM and 4 PM on weekdays

Log Files

Logs are written to the logs/ directory:

View recent logs:

tail -50 logs/daily_$(date +%Y-%m-%d).log

Script Reference

Script Purpose Flags
scripts/update_prices.py Fetch latest prices from Yahoo Finance
scripts/auto_post.py Generate posts for top commodity movers --dry-run, --max N, --min-move N, --model MODEL, --no-og, --no-commit
scripts/generate_og_images.py Generate Open Graph images for posts
scripts/run_daily.sh Full pipeline (all of the above + git push)

Troubleshooting