diff --git a/.streamlit/config.toml b/.streamlit/config.toml new file mode 100644 index 0000000..2914bd0 --- /dev/null +++ b/.streamlit/config.toml @@ -0,0 +1,14 @@ +[theme] +primaryColor = "#667eea" +backgroundColor = "#FFFFFF" +secondaryBackgroundColor = "#F0F2F6" +textColor = "#262730" +font = "sans serif" + +[server] +headless = true +enableCORS = false +port = 8501 + +[browser] +gatherUsageStats = false diff --git a/ANDROID_TABLET_GUIDE.md b/ANDROID_TABLET_GUIDE.md new file mode 100644 index 0000000..407e8cf --- /dev/null +++ b/ANDROID_TABLET_GUIDE.md @@ -0,0 +1,287 @@ +# đą Android Tablet Quick Access Guide + +## For Samsung Galaxy S10 Ultra & Other Android Tablets + +--- + +## đ¯ Option 1: Access Already-Deployed Dashboard (Fastest) + +### If Someone Already Deployed It: + +1. **Open Chrome** (or Samsung Internet) on your tablet +2. **Go to your Streamlit app URL**: + ``` + https://your-app-name.streamlit.app + ``` + *(Ask the person who deployed it for this URL)* + +3. **Add to Home Screen** for easy access: + - Tap the **âŽ** menu (three dots) in the top-right + - Select **"Add to Home screen"** + - Name it "Trading Bot" + - Tap **"Add"** + +4. **Done!** Now you have an app icon on your home screen + +--- + +## đ Option 2: Deploy It Yourself (From Your Tablet) + +### You Can Deploy Directly From Your Android Tablet! + +#### Step 1: Open Browser & Go to Streamlit Cloud + +1. Open **Chrome** on your tablet +2. Go to: **[share.streamlit.io](https://share.streamlit.io)** +3. Sign in with **GitHub** (you'll need your GitHub account) + +#### Step 2: Deploy the App + +1. Tap **"New app"** button +2. Fill in these fields: + ``` + Repository: Netrade1/Institutional-Microstructure- + Branch: copilot/convert-flask-dashboard-to-streamlit + Main file path: app.py + ``` +3. Tap **"Deploy"** +4. Wait 2-3 minutes âąī¸ + +#### Step 3: Get Your URL + +You'll see a URL like: +``` +https://institutional-microstructure.streamlit.app +``` + +**Bookmark this** or **Add to Home Screen**! + +--- + +## đĄ Using the Dashboard on Your Tablet + +### Perfect for Galaxy S10 Ultra's Large Screen! + +#### Best Viewing Mode: +- â **Landscape mode** - Use horizontal orientation for best experience +- â **Full screen** - Tap address bar and scroll to hide it +- â **Zoom** - Pinch to zoom on charts if needed + +#### How to Use: + +1. **Initialize Bot** đ + - Tap the "đ Initialize Bot" button + - Wait for green "Initialized" status + +2. **Train Models** đ + - Tap "đ Train Models" + - This takes 3-5 minutes (be patient!) + - Watch for "Trained" status + +3. **Start Trading** âļī¸ + - Tap "âļī¸ Start Trading" + - Bot will execute one cycle + - View results instantly + +4. **Explore Tabs** đ + - **Dashboard** - See your portfolio + - **Performance** - View metrics + - **Configuration** - Change settings + - **ML Models** - See AI info + +--- + +## đ¨ Tablet-Specific Tips + +### Make It Look Great on Your S10 Ultra: + +1. **Use Samsung Internet** (alternative to Chrome): + - Better battery life + - Built-in ad blocker + - Smooth scrolling + +2. **Enable Desktop Mode** (for more space): + - Chrome menu ⎠â Settings â Desktop site â + - Shows more content at once + +3. **Split Screen** (multitask while monitoring): + - Swipe from bottom â Recent apps + - Tap app icon â Open in split screen + - Watch bot + browse other apps + +4. **Dark Mode** (save battery on AMOLED): + - Use the theme selector in the app + - Or enable system-wide dark mode + +--- + +## đą Accessing From Your Tablet + +### Three Ways to Access: + +#### 1. **Home Screen Icon** (Recommended) +After adding to home screen, just tap the icon! + +#### 2. **Bookmark** +- Chrome menu ⎠â â Bookmark +- Access from bookmarks bar + +#### 3. **Direct URL** +Just type the URL in your browser + +--- + +## âī¸ Adjusting Settings on Tablet + +### Configuration Tab is Touch-Friendly: + +1. **Change Trading Symbols**: + - Tap text box + - Keyboard pops up + - Type symbols (BTC/USDT, AAPL, etc.) + +2. **Adjust Sliders**: + - Drag sliders with your finger + - Very responsive on touchscreen + - Stop Loss, Position Size, etc. + +3. **Save Changes**: + - Tap "Save Configuration" + - Changes apply immediately + +--- + +## đ Battery & Performance Tips + +### Your S10 Ultra Can Handle It: + +- â Dashboard is lightweight +- â Won't drain battery fast +- â No installation needed +- â Updates happen in browser + +### To Save Battery: +- Use dark theme +- Lower screen brightness +- Close tab when not monitoring +- The bot runs in the cloud, not on your tablet! + +--- + +## đ Reading Charts on Tablet + +### Plotly Charts are Touch-Friendly: + +- **Zoom**: Pinch to zoom in/out +- **Pan**: Drag to move around chart +- **Hover**: Tap and hold to see values +- **Reset**: Double-tap to reset view + +### Perfect for Your Large Screen: +- Charts look amazing on S10 Ultra +- See all details clearly +- No need to scroll much + +--- + +## đ Refreshing Data + +### Keep Dashboard Updated: + +1. **Auto-refresh**: Dashboard updates when you perform actions +2. **Manual refresh**: Pull down to refresh (browser refresh) +3. **Re-run**: Tap buttons again to update data + +--- + +## đ Troubleshooting on Android + +### "Page won't load" +- Check WiFi/data connection +- Try different browser (Samsung Internet vs Chrome) +- Clear browser cache + +### "Buttons don't respond" +- Scroll up to see all buttons +- Try landscape mode +- Reload page + +### "Charts too small" +- Rotate to landscape +- Pinch to zoom +- Enable desktop site mode + +### "App is slow" +- Training takes 3-5 min (normal) +- Check your internet speed +- Close other browser tabs + +--- + +## đ¯ Quick Start Checklist for Your Tablet + +- [ ] Open Chrome or Samsung Internet +- [ ] Go to Streamlit Cloud or your app URL +- [ ] Sign in (if deploying) +- [ ] Deploy or access the app +- [ ] Add to home screen +- [ ] Rotate to landscape mode +- [ ] Tap "Initialize Bot" +- [ ] Tap "Train Models" (wait 5 min) +- [ ] Tap "Start Trading" +- [ ] Enjoy your dashboard! đ + +--- + +## đ Need Help on Your Tablet? + +### Can't Deploy? +- Make sure you're signed into GitHub in your browser +- Try using desktop mode in browser +- Or deploy from a computer, then access from tablet + +### Want to Test First? +You can't run it locally on Android (needs Python), but you CAN: +- Deploy to Streamlit Cloud (free) +- Access instantly from your tablet +- No installation needed! + +--- + +## ⨠Your S10 Ultra Advantages + +Your tablet is **perfect** for this dashboard: + +â **Large screen** - See everything at once +â **Touch optimized** - All controls work great +â **Portable** - Monitor from anywhere +â **Always connected** - Check anytime +â **Long battery** - Monitor for hours + +--- + +## đŦ Quick Video Steps (Text Version) + +### From Your Tablet Right Now: + +1. **Tap Chrome icon** đą +2. **Go to**: `share.streamlit.io` đ +3. **Sign in with GitHub** đ +4. **Tap "New app"** â +5. **Fill form with repo details** đ +6. **Tap Deploy** đ +7. **Wait 2 minutes** âąī¸ +8. **Get your URL** đ +9. **Add to home screen** đ +10. **Start using!** đ + +--- + +**Ready?** Open Chrome on your tablet and start with Step 1 above! đ + +**Questions?** See [DEPLOY_NOW.md](DEPLOY_NOW.md) for more details. + +--- + +*Optimized for Samsung Galaxy S10 Ultra and all Android tablets* +*Last Updated: March 2026* diff --git a/DEPLOYMENT_SUMMARY.md b/DEPLOYMENT_SUMMARY.md new file mode 100644 index 0000000..b289fd8 --- /dev/null +++ b/DEPLOYMENT_SUMMARY.md @@ -0,0 +1,283 @@ +# đ Deployment Documentation Summary + +## What Was Created + +This document summarizes all the deployment guides available for the AI Trading Bot dashboard. + +--- + +## đ¯ **Start Here (Based on Your Device)** + +### đą On Android Tablet Right Now? +âĄī¸ **[START_HERE_TABLET.md](START_HERE_TABLET.md)** +- Visual step-by-step guide with 8 simple steps +- Perfect for Samsung Galaxy S10 Ultra and all Android tablets +- Shows exactly what to tap and where +- ASCII boxes make it easy to follow + +### đą Want More Tablet Details? +âĄī¸ **[ANDROID_TABLET_GUIDE.md](ANDROID_TABLET_GUIDE.md)** +- Complete guide for Android tablets +- Tips for large screens (landscape mode, split screen) +- Battery and performance optimization +- Troubleshooting for mobile devices +- Touch-friendly chart interactions + +### đģ On Desktop/Laptop? +âĄī¸ **[DEPLOY_NOW.md](DEPLOY_NOW.md)** +- Simple 3-step deployment guide +- Works for all devices +- Quick reference format +- Common Q&A section + +### đ Want Full Details? +âĄī¸ **[STREAMLIT_DEPLOYMENT.md](STREAMLIT_DEPLOYMENT.md)** +- Comprehensive deployment guide +- All configuration options +- Advanced features +- Security considerations +- Complete usage instructions + +### ⥠Just Want to Test Locally? +âĄī¸ **[QUICKSTART.md](QUICKSTART.md)** +- Original quick start guide +- Command-line focused +- Local development setup + +--- + +## īŋŊīŋŊ Comparison of Guides + +| Guide | Best For | Length | Focus | +|-------|----------|--------|-------| +| START_HERE_TABLET.md | Android tablets, first-time users | 13KB | Visual, step-by-step | +| ANDROID_TABLET_GUIDE.md | Tablet optimization | 6.6KB | Mobile tips, troubleshooting | +| DEPLOY_NOW.md | Quick deployment | 4.1KB | Fast deployment | +| STREAMLIT_DEPLOYMENT.md | Complete reference | 4.5KB | All features | +| QUICKSTART.md | Developers | 2.7KB | CLI usage | + +--- + +## đ Deployment Process (Summary) + +### For Streamlit Cloud (Recommended): + +1. **Go to**: [share.streamlit.io](https://share.streamlit.io) +2. **Sign in** with GitHub +3. **Create new app** with: + - Repository: `Netrade1/Institutional-Microstructure-` + - Branch: `copilot/convert-flask-dashboard-to-streamlit` + - Main file: `app.py` +4. **Deploy** and wait 2-3 minutes +5. **Access** your dashboard at the provided URL + +### For Local Testing: + +```bash +pip install streamlit +streamlit run app.py +# Open http://localhost:8501 +``` + +--- + +## đą Device-Specific Features + +### Android Tablets +- Touch-optimized buttons and sliders +- Pinch-to-zoom charts +- Landscape mode support +- Add to home screen capability +- Split-screen multitasking +- Dark mode for battery saving + +### Desktop/Laptop +- Full-screen dashboard +- Keyboard shortcuts +- Multiple browser tabs +- Developer tools access + +### iOS Devices +- Safari optimization +- Add to home screen +- Gesture navigation +- Dark mode support + +--- + +## đ¯ After Deployment + +### First-Time Setup: + +1. **Initialize Bot** (đ button) + - Sets up trading system + - Takes a few seconds + +2. **Train Models** (đ button) + - Trains AI models + - Takes 3-5 minutes + - Don't close browser! + +3. **Start Trading** (âļī¸ button) + - Executes trading cycle + - Updates portfolio + - View results instantly + +### Dashboard Tabs: + +- **đ Dashboard**: Portfolio overview, equity curve, positions, trades +- **đ Performance**: Sharpe ratio, max drawdown, win rate, profit factor +- **âī¸ Configuration**: Trading symbols, capital, risk parameters +- **īŋŊīŋŊ ML Models**: Model information and weights + +--- + +## đ§ Configuration Options + +### Trading Settings: +- Symbols (BTC/USDT, ETH/USDT, AAPL, GOOGL, etc.) +- Initial capital +- Max position size (% of portfolio) +- Stop loss (% per trade) +- Take profit (% per trade) + +### Risk Management: +- Max daily loss (% of portfolio) +- Max portfolio risk (total exposure) +- Diversification minimums + +--- + +## â ī¸ Important Notes + +### For All Users: +- â Dashboard runs in the cloud (no local installation needed) +- â Access from any device with internet +- â Automatic updates when you push to GitHub +- â HTTPS secure connection +- â ī¸ For educational/testing purposes only +- â ī¸ Use paper trading for real testing + +### Security: +- No API keys in code +- Environment variables for secrets +- Streamlit Cloud handles infrastructure +- Session-based state management + +--- + +## đ Common Issues & Solutions + +### "Can't find deployment button" +- Make sure you're signed into GitHub first +- Try refreshing the page +- Use Chrome or Firefox + +### "Deployment failed" +- Check repository name is exact +- Verify branch name is correct +- Ensure app.py exists in repo + +### "Training takes forever" +- This is normal (3-5 minutes) +- Don't close browser tab +- ML models take time to train + +### "Dashboard looks weird on mobile" +- Try landscape orientation +- Use desktop site mode +- Pinch to zoom if needed + +--- + +## đ Getting Help + +### If You're Stuck: + +1. **Check the specific guide** for your device/situation +2. **Read troubleshooting** sections in the guides +3. **Review common questions** in DEPLOY_NOW.md +4. **Open an issue** on GitHub +5. **Check existing issues** for similar problems + +### Useful Commands: + +```bash +# Check if Streamlit is installed +pip show streamlit + +# Install Streamlit +pip install streamlit + +# Run locally +streamlit run app.py + +# Check Python version +python --version # Should be 3.8+ +``` + +--- + +## đ Additional Resources + +### In This Repository: +- `README.md` - Main documentation +- `ARCHITECTURE.md` - System architecture +- `SYSTEM_OVERVIEW.md` - Technical overview +- `config.yaml` - Configuration file +- `requirements.txt` - Dependencies + +### External Links: +- [Streamlit Documentation](https://docs.streamlit.io) +- [Streamlit Cloud](https://share.streamlit.io) +- [GitHub Docs](https://docs.github.com) + +--- + +## đ What You Get After Deployment + +â **Live Dashboard**: Access from anywhere +â **Shareable URL**: https://your-app.streamlit.app +â **Mobile Access**: Phone and tablet friendly +â **Auto-Updates**: Syncs with GitHub automatically +â **No Maintenance**: Streamlit handles infrastructure +â **Free Tier**: No cost for basic usage +â **HTTPS**: Secure connection +â **Analytics**: Optional usage tracking + +--- + +## đ¯ Quick Reference + +### URLs to Know: +- Streamlit Cloud: https://share.streamlit.io +- Your Repo: https://github.com/Netrade1/Institutional-Microstructure- +- Branch: copilot/convert-flask-dashboard-to-streamlit + +### Files to Know: +- Main App: `app.py` +- Config: `config.yaml` +- Requirements: `requirements.txt` +- Streamlit Config: `.streamlit/config.toml` + +### Key Info: +- Main File Path: `app.py` +- Python Version: 3.8+ +- Deployment Time: 2-3 minutes +- Training Time: 3-5 minutes + +--- + +## đ Version History + +- **March 2026**: Created comprehensive deployment guides + - Added START_HERE_TABLET.md for visual guidance + - Added ANDROID_TABLET_GUIDE.md for mobile optimization + - Added DEPLOY_NOW.md for quick deployment + - Updated README.md with clear navigation + +--- + +**Choose your guide above and get started! đ** + +*For immediate help on Android tablet: Open START_HERE_TABLET.md* diff --git a/DEPLOY_NOW.md b/DEPLOY_NOW.md new file mode 100644 index 0000000..9d1c759 --- /dev/null +++ b/DEPLOY_NOW.md @@ -0,0 +1,169 @@ +# đ Deploy Your Trading Bot in 3 Steps + +**Not sure how to deploy? Follow these simple steps!** + +--- + +## đą **ON AN ANDROID TABLET RIGHT NOW?** + +âĄī¸ **[GO HERE: ANDROID_TABLET_GUIDE.md](ANDROID_TABLET_GUIDE.md)** +*Specific instructions for Samsung Galaxy S10 Ultra and all Android tablets!* + +--- + +## đą Option 1: Deploy to Streamlit Cloud (Recommended for Mobile) + +### Step 1: Get Your GitHub Repository Ready â + +Your code is already on GitHub! You're at: +``` +https://github.com/Netrade1/Institutional-Microstructure- +``` + +### Step 2: Go to Streamlit Cloud đ + +1. **Open this link**: [share.streamlit.io](https://share.streamlit.io) +2. **Sign in** with your GitHub account (the same one you use for this repo) +3. Click the big **"New app"** button + +### Step 3: Configure Your App âī¸ + +Fill in these fields: + +``` +Repository: Netrade1/Institutional-Microstructure- +Branch: copilot/convert-flask-dashboard-to-streamlit +Main file path: app.py +``` + +Then click **"Deploy"**! + +### That's It! đ + +Wait 2-3 minutes for deployment. You'll get a URL like: +``` +https://your-app-name.streamlit.app +``` + +**Share this URL** to access your dashboard from any device (phone, tablet, computer)! + +--- + +## đģ Option 2: Run Locally (For Testing) + +### Quick Local Test + +```bash +# 1. Install Streamlit (if not already installed) +pip install streamlit + +# 2. Run the app +streamlit run app.py +``` + +Open your browser to: `http://localhost:8501` + +--- + +## đ¯ What to Do After Deployment + +### First Time Using the Dashboard? + +1. **Click "đ Initialize Bot"** - Sets up your trading bot +2. **Click "đ Train Models"** - Trains AI models (takes 2-5 minutes) +3. **Click "âļī¸ Start Trading"** - Executes one trading cycle +4. **View Results** - Check portfolio, positions, and performance + +### Need to Change Settings? + +Go to the **"âī¸ Configuration"** tab to adjust: +- Trading symbols (BTC, ETH, AAPL, etc.) +- Initial capital amount +- Risk parameters (stop loss, position size) + +--- + +## â Common Questions + +### Q: "I deployed but the app crashes" + +**A:** Check that all these files exist in your repository: +- â `app.py` (main file) +- â `requirements.txt` (dependencies) +- â `config.yaml` (settings) +- â `trading_bot/` folder (bot code) + +### Q: "Training takes forever" + +**A:** That's normal! ML model training can take 3-5 minutes. The page will update when done. + +### Q: "Can I use this on my phone?" + +**A:** Yes! Once deployed to Streamlit Cloud: +1. Open the URL in your phone's browser (Chrome, Safari) +2. Tap "Add to Home Screen" for quick access +3. Use landscape mode for better chart viewing + +### Q: "Is my data secure?" + +**A:** +- Your dashboard runs on Streamlit Cloud (secure HTTPS) +- No API keys or passwords are stored in the code +- All trading is simulated (educational purpose) +- For real trading, use paper trading accounts only + +### Q: "How do I update my deployed app?" + +**A:** Just push changes to GitHub! Streamlit Cloud auto-updates from your repository. + +```bash +git add . +git commit -m "Updated settings" +git push +``` + +Your app will redeploy automatically in 1-2 minutes. + +--- + +## đ Still Stuck? + +### Need More Help? + +1. **Read the full guide**: Check `STREAMLIT_DEPLOYMENT.md` for detailed instructions +2. **Check examples**: Run `python demo.py` to see how the bot works +3. **Review configuration**: See `config.yaml` for all settings +4. **Ask for help**: Open an issue on GitHub + +### Quick Links + +- đ [Full Deployment Guide](STREAMLIT_DEPLOYMENT.md) +- đ¯ [Quick Start](QUICKSTART.md) +- đ [Complete Documentation](README.md) +- âī¸ [System Architecture](ARCHITECTURE.md) + +--- + +## ⨠Pro Tips + +### For Mobile Users +- Use landscape mode for charts +- Pinch to zoom on graphs +- Swipe between tabs +- Add to home screen for app-like experience + +### For Advanced Users +- Edit `.streamlit/config.toml` for custom themes +- Set environment variables for API keys +- Use Streamlit secrets for sensitive data +- Enable authentication (Streamlit Pro) + +--- + +**Ready to Deploy?** Start with Option 1 above! đ + +**Just Testing?** Use Option 2 for local testing first! đģ + +--- + +*Last Updated: March 2026* diff --git a/README.md b/README.md index e0afac9..6a9e70f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,36 @@ A state-of-the-art cutting-edge machine learning augmented intelligence autonomous AI Trading Bot Platform System and Dashboard. +--- + +## đ **WANT TO DEPLOY NOW?** + +### đą **ON YOUR ANDROID TABLET RIGHT NOW?** + +**âĄī¸ [START HERE: START_HERE_TABLET.md](START_HERE_TABLET.md)** âŦ ī¸ +*Step-by-step visual guide for Samsung Galaxy S10 Ultra and all Android tablets!* + +--- + +### Choose Your Path: + +#### đą Android Tablet Users +1. **[START_HERE_TABLET.md](START_HERE_TABLET.md)** - Visual step-by-step guide (START HERE!) +2. **[ANDROID_TABLET_GUIDE.md](ANDROID_TABLET_GUIDE.md)** - Complete tablet guide + +#### đģ Desktop/Laptop Users +1. **[DEPLOY_NOW.md](DEPLOY_NOW.md)** - Simple 3-step deployment +2. **[STREAMLIT_DEPLOYMENT.md](STREAMLIT_DEPLOYMENT.md)** - Detailed guide + +#### đ Just Want to Test Locally? +```bash +pip install streamlit +streamlit run app.py +``` +Open: `http://localhost:8501` + +--- + ## đ Features ### Advanced Machine Learning diff --git a/START_HERE_TABLET.md b/START_HERE_TABLET.md new file mode 100644 index 0000000..06d745c --- /dev/null +++ b/START_HERE_TABLET.md @@ -0,0 +1,166 @@ +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + đą ANDROID TABLET - QUICK START (From Your Device Right Now!) +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +YOU ARE HERE: On your Samsung Galaxy S10 Ultra tablet â + +WHAT YOU NEED TO DO: +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 1: Open Chrome Browser â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â Tap the Chrome icon on your tablet â +â â Make sure you're connected to WiFi or mobile data â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 2: Go to Streamlit Cloud â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â Type this in the address bar: â +â â +â https://share.streamlit.io â +â â +â â Press Enter/Go â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 3: Sign In with GitHub â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â You'll see a "Sign in" button â +â â Tap it and choose "Sign in with GitHub" â +â â Use your GitHub username and password â +â â (If you don't have GitHub, create free account first) â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 4: Create New App â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â Look for the "New app" button (usually blue) â +â â Tap it â +â â A form will appear â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 5: Fill in the Form â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â Repository: â +â Netrade1/Institutional-Microstructure- â +â â +â Branch: â +â copilot/convert-flask-dashboard-to-streamlit â +â â +â Main file path: â +â app.py â +â â +â â Tap each field and type carefully â +â â Use the keyboard on your tablet â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 6: Deploy! â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â Tap the "Deploy" button at the bottom â +â â Wait 2-3 minutes (don't close the browser!) â +â â You'll see a loading animation â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 7: Get Your URL â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â When deployment finishes, you'll see a URL like: â +â â +â https://your-app-name.streamlit.app â +â â +â â THIS IS YOUR DASHBOARD URL! â +â â Bookmark it or add to home screen â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +â Step 8: Add to Home Screen (Optional but Recommended) â +â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â +â â Tap the ⎠menu (three dots) in Chrome â +â â Select "Add to Home screen" â +â â Name it "Trading Bot" â +â â Tap "Add" â +â â Now you have an app icon! đ â +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + WHAT HAPPENS NEXT? +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +Your dashboard is now LIVE on the internet! + +You can: +â Access it from any device +â Share the URL with others +â Use it on your tablet, phone, or computer +â Monitor your trading bot from anywhere + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + USING THE DASHBOARD (After Deployment) +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +1. TAP "đ Initialize Bot" + â Sets up the trading system + â Takes a few seconds + +2. TAP "đ Train Models" + â Trains the AI models + â Takes 3-5 minutes (be patient!) + â You'll see "Trained" status when done + +3. TAP "âļī¸ Start Trading" + â Executes one trading cycle + â Updates portfolio and positions + â See results immediately! + +4. EXPLORE THE TABS + â Dashboard: See portfolio and charts + â Performance: View metrics + â Configuration: Change settings + â ML Models: See AI information + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + TIPS FOR YOUR TABLET +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +đ Use LANDSCAPE MODE for best viewing +đ Pinch to ZOOM on charts +đ Tap and hold to see CHART VALUES +đ Use DARK THEME to save battery (in app settings) +đą ADD TO HOME SCREEN for quick access + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + NEED MORE HELP? +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +đ Read: ANDROID_TABLET_GUIDE.md - Complete guide +đ Read: DEPLOY_NOW.md - General deployment guide +đ Read: STREAMLIT_DEPLOYMENT.md - Detailed instructions + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + TROUBLESHOOTING +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + +â Can't find "New app" button? + â Make sure you're signed in to GitHub first + +â Deployment failed? + â Check that you typed the repository name correctly + â Check the branch name is exact + +â Training takes forever? + â This is normal! ML training takes 3-5 minutes + â Don't close the browser, just wait + +â Dashboard looks weird? + â Try landscape mode (rotate tablet) + â Try desktop site mode (in Chrome settings) + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ + + đ READY TO START? Follow Step 1 above on your tablet now! + +âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ diff --git a/STREAMLIT_DEPLOYMENT.md b/STREAMLIT_DEPLOYMENT.md new file mode 100644 index 0000000..43ae19f --- /dev/null +++ b/STREAMLIT_DEPLOYMENT.md @@ -0,0 +1,167 @@ +# AI Trading Bot - Streamlit Dashboard Deployment Guide + +## Overview +This guide explains how to deploy the AI Trading Bot dashboard to Streamlit Cloud for easy access from any device, including Android phones. + +## Features +- đ¤ Real-time bot monitoring and control +- đ Portfolio tracking with live metrics +- đ Interactive equity curve visualization +- âī¸ Configuration management interface +- đ§ ML model performance monitoring +- đ Dark/Light theme toggle +- đą Mobile-responsive design + +## Local Development + +### Prerequisites +- Python 3.8 or higher +- pip package manager + +### Installation + +1. Clone the repository: +```bash +git clone https://github.com/Netrade1/Institutional-Microstructure-.git +cd Institutional-Microstructure- +``` + +2. Install dependencies: +```bash +pip install -r requirements.txt +``` + +3. Configure the bot: +Edit `config.yaml` to set your trading parameters: +- Trading symbols +- Initial capital +- Risk parameters +- ML model settings + +### Running Locally + +Start the Streamlit dashboard: +```bash +streamlit run app.py +``` + +The dashboard will be available at `http://localhost:8501` + +## Deploying to Streamlit Cloud + +### Step 1: Prepare Your Repository + +1. Ensure all files are committed to your GitHub repository +2. Make sure `requirements.txt` is up to date +3. Verify `config.yaml` has sensible defaults + +### Step 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. Select your repository: `Netrade1/Institutional-Microstructure-` +5. Set the main file path: `app.py` +6. Click "Deploy" + +### Step 3: Access from Mobile + +Once deployed, you'll get a URL like: +``` +https://your-app-name.streamlit.app +``` + +Open this URL in any mobile browser (Chrome, Safari, etc.) to access the dashboard. + +## Usage Guide + +### 1. Initialize the Bot +Click the "đ Initialize Bot" button to create a bot instance with your configuration. + +### 2. Train Models +Click "đ Train Models" to train the ML models (LSTM, Random Forest, XGBoost) on historical data. +- This may take several minutes +- Models are trained on technical indicators + +### 3. Start Trading +Click "âļī¸ Start Trading" to execute a trading cycle: +- Fetches latest market data +- Generates predictions +- Creates trading signals +- Executes trades based on risk management rules + +### 4. Monitor Performance +Use the tabs to view: +- **Dashboard**: Portfolio overview, equity curve, positions, trades +- **Performance**: Sharpe ratio, max drawdown, win rate, profit factor +- **Configuration**: Adjust trading and risk parameters +- **ML Models**: View model information and weights + +### 5. Stop Trading +Click "âšī¸ Stop Trading" to halt the bot. + +## Configuration Options + +### Trading Settings +- **Symbols**: Assets to trade (e.g., BTC/USDT, AAPL, GOOGL) +- **Initial Capital**: Starting portfolio value +- **Max Position Size**: Maximum % of portfolio per trade +- **Stop Loss**: Maximum loss per trade before exit +- **Take Profit**: Target profit per trade + +### Risk Management +- **Max Daily Loss**: Maximum portfolio loss per day +- **Max Portfolio Risk**: Maximum total portfolio risk exposure + +## Mobile Tips + +### Android Devices +1. Open Chrome or your preferred browser +2. Navigate to your Streamlit Cloud URL +3. For best experience, use landscape mode for charts +4. Add to home screen for quick access: + - Menu â Add to Home screen + +### iOS Devices +1. Open Safari +2. Navigate to your Streamlit Cloud URL +3. Tap the Share button +4. Select "Add to Home Screen" + +## Troubleshooting + +### Bot Not Initializing +- Check that `config.yaml` exists and is valid +- Verify all required dependencies are installed + +### Training Takes Too Long +- Reduce `history_days` in config.yaml +- Use fewer symbols +- Consider using a more powerful deployment option + +### Mobile Layout Issues +- Try rotating to landscape mode +- Zoom out if content is too large +- Clear browser cache + +## Security Considerations + +â ī¸ **Important**: This dashboard is for educational and testing purposes. + +For production use: +1. Never commit API keys or secrets to the repository +2. Use environment variables for sensitive data +3. Enable authentication on Streamlit Cloud (Pro plan) +4. Regularly update dependencies for security patches +5. Use paper trading or testnet APIs for testing + +## Support + +For issues or questions: +1. Check the [GitHub Issues](https://github.com/Netrade1/Institutional-Microstructure-/issues) +2. Review the code documentation +3. Contact the repository maintainers + +## License + +See LICENSE file in the repository. diff --git a/app.py b/app.py new file mode 100644 index 0000000..a59f26e --- /dev/null +++ b/app.py @@ -0,0 +1,635 @@ +""" +Streamlit Dashboard for AI Trading Bot +Provides real-time monitoring and control interface +""" +import streamlit as st +import pandas as pd +import plotly.graph_objects as go +from datetime import datetime +import yaml +import json +import logging +from typing import Dict, List, Any + +from trading_bot.bot import AITradingBot + +# Configure logging +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + +# Constants +DEFAULT_INITIAL_CAPITAL = 100000 + +# Page configuration +st.set_page_config( + page_title="AI Trading Bot Dashboard", + page_icon="đ", + layout="wide", + initial_sidebar_state="expanded" +) + +# Custom CSS for better mobile responsiveness and professional look +st.markdown(""" + +""", unsafe_allow_html=True) + + +def initialize_session_state(): + """Initialize Streamlit session state variables""" + if 'bot' not in st.session_state: + st.session_state.bot = None + if 'bot_status' not in st.session_state: + st.session_state.bot_status = { + 'initialized': False, + 'trained': False, + 'running': False, + 'last_update': None + } + if 'theme' not in st.session_state: + st.session_state.theme = 'light' + if 'config' not in st.session_state: + try: + with open('config.yaml', 'r') as f: + st.session_state.config = yaml.safe_load(f) + except Exception as e: + logger.error(f"Error loading config: {e}") + st.session_state.config = {} + + +def load_config() -> Dict: + """Load configuration from YAML file""" + try: + with open('config.yaml', 'r') as f: + return yaml.safe_load(f) + except Exception as e: + logger.error(f"Error loading config: {e}") + st.error(f"Failed to load configuration: {e}") + return {} + + +def save_config(config: Dict): + """Save configuration to YAML file""" + try: + with open('config.yaml', 'w') as f: + yaml.dump(config, f, default_flow_style=False) + st.success("Configuration saved successfully!") + except Exception as e: + logger.error(f"Error saving config: {e}") + st.error(f"Failed to save configuration: {e}") + + +def initialize_bot(): + """Initialize the trading bot""" + try: + with st.spinner("Initializing bot..."): + st.session_state.bot = AITradingBot() + st.session_state.bot_status['initialized'] = True + st.session_state.bot_status['last_update'] = datetime.now().isoformat() + logger.info("Bot initialized via Streamlit") + st.success("â Bot initialized successfully!") + st.rerun() + except Exception as e: + logger.error(f"Error initializing bot: {e}") + st.error(f"Failed to initialize bot: {e}") + + +def train_bot(): + """Train the bot models""" + if st.session_state.bot is None: + st.error("Please initialize the bot first") + return + + try: + with st.spinner("Training models... This may take several minutes."): + data = st.session_state.bot.fetch_and_prepare_data() + st.session_state.bot.train_models(data) + st.session_state.bot_status['trained'] = True + st.session_state.bot_status['last_update'] = datetime.now().isoformat() + logger.info("Bot trained via Streamlit") + st.success("â Bot trained successfully!") + st.rerun() + except Exception as e: + logger.error(f"Error training bot: {e}") + st.error(f"Failed to train bot: {e}") + + +def execute_trading_cycle(): + """Execute one trading cycle""" + if st.session_state.bot is None: + st.error("Please initialize the bot first") + return + + if not st.session_state.bot.is_trained: + st.error("Please train the bot first") + return + + try: + with st.spinner("Executing trading cycle..."): + st.session_state.bot_status['running'] = True + st.session_state.bot_status['last_update'] = datetime.now().isoformat() + + data = st.session_state.bot.fetch_and_prepare_data() + st.session_state.bot.execute_trading_cycle(data) + + logger.info("Trading cycle executed via Streamlit") + st.success("â Trading cycle completed successfully!") + st.rerun() + except Exception as e: + logger.error(f"Error in trading cycle: {e}") + st.session_state.bot_status['running'] = False + st.error(f"Failed to execute trading cycle: {e}") + + +def stop_trading(): + """Stop trading bot""" + st.session_state.bot_status['running'] = False + st.session_state.bot_status['last_update'] = datetime.now().isoformat() + logger.info("Trading stopped via Streamlit") + st.success("Trading stopped") + st.rerun() + + +def render_header(): + """Render dashboard header""" + col1, col2 = st.columns([3, 1]) + + with col1: + st.title("đ¤ AI Trading Bot Dashboard") + st.caption("Autonomous Trading System with Machine Learning") + + with col2: + # Theme toggle + theme = st.selectbox( + "Theme", + ["Light", "Dark"], + index=0 if st.session_state.theme == 'light' else 1, + key="theme_selector" + ) + if theme.lower() != st.session_state.theme: + st.session_state.theme = theme.lower() + st.rerun() + + +def render_status_bar(): + """Render status bar with bot status badges""" + st.subheader("System Status") + + col1, col2, col3, col4 = st.columns(4) + + with col1: + status_class = "status-active" if st.session_state.bot_status['initialized'] else "status-inactive" + status_text = "Initialized" if st.session_state.bot_status['initialized'] else "Not Initialized" + st.markdown(f'