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.
📊 Features
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
🛠️ Installation
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
🚀 Usage
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
📁 Project Structure
dashboard/app.py - Main Streamlit application
dashboard/data/snapshots/ - JSON files of account snapshots
dashboard/data/diary/ - Markdown files for trading diary entries
dashboard/update_jobs/positions_job.py - Job for fetching data from Alpaca API
📝 Data Format
Snapshots: JSON files with naming pattern {agent_name}_{YYYYMMDD_HHMMSS}.json
Diary Entries: Markdown files with naming pattern {agent_name}_{YYYY-MM-DD}.md
🔑 Environment Variables
ALPACA_API_KEY: API key for Alpaca
ALPACA_SECRET_KEY: Secret key for Alpaca
ALPACA_PAPER: Whether to use paper trading (default: true)
AI Trader Frontend
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.
📊 Features
🛠️ Installation
Clone the repository:
Create and activate a virtual environment:
Install dependencies:
Set up environment variables in a
.envfile:🚀 Usage
Run the Streamlit dashboard:
Update portfolio data:
Deploy to Streamlit Cloud:
dashboard/app.pyAutomated Data Updates: This project includes a GitHub Actions workflow that automatically updates portfolio data every 15 minutes.
To set up automated updates:
📁 Project Structure
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📝 Data Format
{agent_name}_{YYYYMMDD_HHMMSS}.json{agent_name}_{YYYY-MM-DD}.md🔑 Environment Variables
ALPACA_API_KEY: API key for AlpacaALPACA_SECRET_KEY: Secret key for AlpacaALPACA_PAPER: Whether to use paper trading (default: true)📸 Screenshots
🔄 Data Flow
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
🙏 Acknowledgements