Update Portfolio Data #22296
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Portfolio Data | |
| on: | |
| schedule: | |
| # Run every 15 minutes | |
| - cron: '*/15 * * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| update-data: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Give the workflow write permissions to the repository | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| persist-credentials: true # Ensure credentials are passed to later steps | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run update job | |
| env: | |
| ALPACA_API_KEY: ${{ secrets.ALPACA_API_KEY }} | |
| ALPACA_SECRET_KEY: ${{ secrets.ALPACA_SECRET_KEY }} | |
| ALPACA_PAPER: ${{ secrets.ALPACA_PAPER || 'true' }} | |
| run: | | |
| cd dashboard/update_jobs | |
| python positions_job.py | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.name "GitHub Actions Bot" | |
| git config --global user.email "actions@github.com" | |
| git pull --rebase | |
| git add dashboard/data/snapshots/ | |
| git commit -m "Update portfolio data [skip ci]" || echo "No changes to commit" | |
| git push |