Spaces:
Running
Running
Deploy Aureon OS (deploy/selfhost stack: nginx edge + fusion API x2 + console + HNC organ + redis + postgres; paper mode) (part 19)
da0ce7b verified Download scripts/python/monitor_trades.py from GaryLeckey/aureon-os: direct link, hf CLI and curl.
- Browser
- Download file 3.5 kB
-
https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/python/monitor_trades.py
- Command line
-
hf download hf://spaces/GaryLeckey/aureon-os/scripts/python/monitor_trades.py
-
curl -L -o monitor_trades.py https://huggingface.co/spaces/GaryLeckey/aureon-os/resolve/main/scripts/python/monitor_trades.py
3.5 kB
| #!/usr/bin/env python3 | |
| """ | |
| π LIVE TRADE MONITOR - Watch Micro Profit Labyrinth | |
| """ | |
| from aureon_baton_link import link_system as _baton_link; _baton_link(__name__) | |
| import json | |
| import time | |
| import os | |
| from datetime import datetime | |
| def monitor_trades(): | |
| """Watch trades in real-time""" | |
| last_count = 0 | |
| while True: | |
| try: | |
| # Read pending validations | |
| if os.path.exists('7day_pending_validations.json'): | |
| with open('7day_pending_validations.json', 'r') as f: | |
| trades = json.load(f) | |
| current_count = len(trades) | |
| print(f"\n{'='*70}") | |
| print(f"β° {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") | |
| print(f"{'='*70}") | |
| print(f"π Total Trades: {current_count}") | |
| # Show last 5 trades | |
| if trades: | |
| print(f"\nπ RECENT TRADES (Last 5):") | |
| print(f"{'-'*70}") | |
| for trade in trades[-5:]: | |
| symbol = trade.get('symbol', 'UNKNOWN') | |
| entry = trade.get('entry_price', 0) | |
| exit_p = trade.get('exit_price', 0) | |
| entry_t = trade.get('entry_time', '')[:19] | |
| exit_t = trade.get('exit_time', '')[:19] | |
| # Calculate P&L | |
| actual_edge = trade.get('actual_edge', 0) | |
| status = trade.get('status', 'unknown') | |
| if actual_edge > 0: | |
| emoji = 'β ' | |
| elif actual_edge < 0: | |
| emoji = 'β' | |
| else: | |
| emoji = 'βͺ' | |
| print(f"{emoji} {symbol:15} | Entry: {entry:.8f} β Exit: {exit_p:.8f}") | |
| print(f" PnL: ${actual_edge:+.4f} | Status: {status}") | |
| print(f" Time: {entry_t} β {exit_t}") | |
| print() | |
| # Calculate totals | |
| total_pnl = sum(t.get('actual_edge', 0) for t in trades) | |
| wins = sum(1 for t in trades if t.get('actual_edge', 0) > 0) | |
| losses = sum(1 for t in trades if t.get('actual_edge', 0) < 0) | |
| print(f"{'-'*70}") | |
| print(f"π° TOTALS: ${total_pnl:+.2f} | Wins: {wins} | Losses: {losses} | Win%: {wins/(wins+losses)*100 if (wins+losses) > 0 else 0:.0f}%") | |
| # Check for new trades | |
| if current_count > last_count: | |
| new_trades = current_count - last_count | |
| print(f"\nπ {new_trades} NEW TRADE(S) SINCE LAST CHECK!") | |
| last_count = current_count | |
| # Wait 5 seconds before next check | |
| time.sleep(5) | |
| except KeyboardInterrupt: | |
| print("\n\nπ Monitor stopped") | |
| break | |
| except Exception as e: | |
| print(f"β οΈ Error: {e}") | |
| time.sleep(5) | |
| if __name__ == "__main__": | |
| print("π LIVE TRADE MONITOR - Starting...") | |
| print("Press Ctrl+C to stop\n") | |
| monitor_trades() | |