A Streamlit dashboard application for visualizing trading account information and positions from the Alpaca Trading API. The dashboard displays portfolio value, positions, profit/loss metrics, and trading diary entries.
- Real-time Account Data: View portfolio value, cash balance, and buying power
- Positions Tracking: Monitor your positions with detailed information on current prices, market values, and profit/loss
- Trading Diary: Keep track of your trading thoughts and strategies with date-organized diary entries
- Collapsible Interface: Clean UI with collapsible diary sections and intuitive navigation
-
Clone the repository:
git clone https://github.com/yourusername/ai-trader-frontend.git cd ai-trader-frontend
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables in a
.env
file:ALPACA_API_KEY=your_api_key ALPACA_SECRET_KEY=your_secret_key ALPACA_PAPER=true # Use paper trading account
-
Run the Streamlit dashboard:
cd dashboard streamlit run app.py
-
Update portfolio data:
cd dashboard/update_jobs python positions_job.py
-
Deploy to Streamlit Cloud:
- Connect your GitHub repository to Streamlit Cloud
- Set the main file path as
dashboard/app.py
- Add your environment variables (ALPACA_API_KEY, ALPACA_SECRET_KEY, ALPACA_PAPER)
-
Automated Data Updates: This project includes a GitHub Actions workflow that automatically updates portfolio data every 15 minutes.
To set up automated updates:
- Push this repository to GitHub
- Add your Alpaca API keys as GitHub secrets:
- ALPACA_API_KEY
- ALPACA_SECRET_KEY
- ALPACA_PAPER (optional, defaults to true)
- The workflow will run every 15 minutes, fetch new data, and commit it to your repository
- Streamlit Cloud will automatically use the latest data
dashboard/app.py
- Main Streamlit applicationdashboard/data/snapshots/
- JSON files of account snapshotsdashboard/data/diary/
- Markdown files for trading diary entriesdashboard/update_jobs/positions_job.py
- Job for fetching data from Alpaca API
- Snapshots: JSON files with naming pattern
{agent_name}_{YYYYMMDD_HHMMSS}.json
- Diary Entries: Markdown files with naming pattern
{agent_name}_{YYYY-MM-DD}.md
ALPACA_API_KEY
: API key for AlpacaALPACA_SECRET_KEY
: Secret key for AlpacaALPACA_PAPER
: Whether to use paper trading (default: true)
Alpaca Trading API → positions_job.py → JSON snapshots → app.py → Dashboard UI
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Alpaca API - For providing the trading API
- Streamlit - For the awesome dashboard framework
- Pandas - For data manipulation capabilities