File size: 3,221 Bytes
aaa6e1c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# Streamlit Cloud Deployment Guide
## Overview
This guide will help you deploy your algorithmic trading system to Streamlit Cloud.
## Files Created for Deployment
### 1. `streamlit_app.py` (Root Entry Point)
- Main entry point for Streamlit Cloud
- Imports and runs the UI from the `ui/` directory
### 2. `.streamlit/config.toml`
- Streamlit configuration for deployment
- Optimized for cloud deployment
### 3. `packages.txt`
- System dependencies for the deployment environment
### 4. Updated `requirements.txt`
- Fixed dependencies for cloud deployment
- Removed problematic packages
## Deployment Steps
### 1. Push to GitHub
```bash
git add .
git commit -m "feat: prepare for Streamlit Cloud deployment"
git push origin main
```
### 2. Deploy to Streamlit Cloud
1. Go to [share.streamlit.io](https://share.streamlit.io)
2. Sign in with your GitHub account
3. Click "New app"
4. Configure your app:
- **Repository**: `your-username/algorithmic_trading`
- **Branch**: `main`
- **Main file path**: `streamlit_app.py`
- **App URL**: Choose your preferred URL
### 3. Environment Variables (Optional)
If you want to use real API keys, add these in Streamlit Cloud:
- `ALPACA_API_KEY`
- `ALPACA_SECRET_KEY`
- `ALPACA_BASE_URL`
## Deployment Features
### β
Deployment Mode
- The app automatically detects deployment environment
- Falls back to demo mode if modules aren't available
- Shows sample data and mock trading functionality
### β
Error Handling
- Graceful handling of missing dependencies
- Informative error messages
- Fallback functionality
### β
Performance Optimized
- Minimal dependencies
- Efficient imports
- Cloud-optimized configuration
## Troubleshooting
### Common Issues
1. **Import Errors**
- The app now handles missing modules gracefully
- Check the browser console for specific error messages
2. **Dependency Issues**
- All dependencies are now properly specified in `requirements.txt`
- System packages are included in `packages.txt`
3. **Configuration Issues**
- The app uses a default configuration in deployment mode
- No external files are required
### Debug Mode
To debug deployment issues:
1. Check the Streamlit Cloud logs
2. Look for error messages in the browser console
3. Verify all files are properly committed to GitHub
## Local Testing
Test the deployment version locally:
```bash
streamlit run streamlit_app.py
```
## Features Available in Deployment
### β
Working Features
- Configuration loading (demo mode)
- Data visualization with sample data
- Chart generation
- UI navigation
- Mock trading interface
### β οΈ Limited Features
- Real API connections (requires environment variables)
- Live trading (demo mode only)
- Model training (simulated)
## Next Steps
1. **Deploy to Streamlit Cloud** using the steps above
2. **Test the deployment** to ensure everything works
3. **Add environment variables** for real API access
4. **Monitor the deployment** for any issues
## Support
If you encounter issues:
1. Check the Streamlit Cloud logs
2. Verify all files are committed to GitHub
3. Test locally with `streamlit run streamlit_app.py`
4. Review the error handling in the code
The deployment is now ready! π |