diff --git a/.vscode/launch.json b/.vscode/launch.json index 27b00aa..9edddf6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,6 @@ { "version": "0.2.0", "configurations": [ -<<<<<<< HEAD { "name": "๐Ÿ“Š Dashboard (Real-time + Training)", "type": "python", @@ -20,15 +19,10 @@ }, "preLaunchTask": "Kill Stale Processes" }, - -======= - ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b { "name": "๐Ÿ”ฌ Backtest Training (30 days)", "type": "python", "request": "launch", -<<<<<<< HEAD "program": "main_backtest.py", "args": [ "--start", @@ -57,14 +51,10 @@ "--symbol", "ETH/USDT" ], -======= - "program": "run_clean_dashboard.py", ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b "console": "integratedTerminal", "justMyCode": false, "env": { "PYTHONUNBUFFERED": "1", -<<<<<<< HEAD "CUDA_VISIBLE_DEVICES": "0" } }, @@ -89,12 +79,6 @@ "PYTHONUNBUFFERED": "1" } }, -======= - "ENABLE_REALTIME_CHARTS": "1" - } - }, - ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b { "name": "๐Ÿ—๏ธ Python Debugger: Current File", "type": "debugpy", @@ -106,6 +90,21 @@ "PYTHONUNBUFFERED": "1" } }, + { + "name": "๐Ÿ“ ANNOTATE Manual Trade Annotation UI", + "type": "python", + "request": "launch", + "program": "ANNOTATE/web/app.py", + "console": "integratedTerminal", + "justMyCode": false, + "env": { + "PYTHONUNBUFFERED": "1", + "FLASK_ENV": "development", + "FLASK_DEBUG": "1" + }, + "cwd": "${workspaceFolder}", + "preLaunchTask": "Kill Stale Processes" + }, { "name": "๐Ÿ“ˆ COB Data Provider Dashboard", "type": "python", @@ -120,7 +119,6 @@ }, "preLaunchTask": "Kill Stale Processes" }, -<<<<<<< HEAD { "name": "๐Ÿ”ฅ Real-time RL COB Trader", "type": "python", @@ -153,9 +151,6 @@ }, "preLaunchTask": "Kill Stale Processes" }, -======= - ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b { "name": "๐Ÿงช Run Tests", "type": "python", @@ -204,11 +199,6 @@ "order": 3 } } -<<<<<<< HEAD -======= - - ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b ], "compounds": [ { @@ -225,36 +215,22 @@ } }, { -<<<<<<< HEAD "name": "๐Ÿ”ฅ COB Trading System", "configurations": [ "๐Ÿ“ˆ COB Data Provider Dashboard", "๐Ÿ”ฅ Real-time RL COB Trader" -======= - "name": "๐Ÿ’น Live Trading System (Dashboard + Monitor)", - "configurations": [ - "๐Ÿ’น Live Scalping Dashboard (500x Leverage)", - "๐ŸŒ™ Overnight Training Monitor (504M Model)" ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b ], "stopAll": true, "presentation": { "hidden": false, -<<<<<<< HEAD "group": "COB", "order": 2 } - } -======= - "group": "Trading", - "order": 2 - } }, - { "name": "๐ŸŒ COBY Multi-Exchange System (Full Stack)", "configurations": [ - "๐ŸŒ COBY Multi-Exchange Data Aggregation" + "๐Ÿ”ง COBY Development Mode (Auto-reload) - main" ], "stopAll": true, "presentation": { @@ -266,7 +242,7 @@ { "name": "๐Ÿ”ง COBY Development Environment", "configurations": [ - "๐Ÿ”ง COBY Development Mode (Auto-reload)" + "๐Ÿ”ง COBY Development Mode (Auto-reload) - main" ], "stopAll": true, "presentation": { @@ -275,7 +251,5 @@ "order": 7 } } - ->>>>>>> d49a473ed6f4aef55bfdd47d6370e53582be6b7b ] } \ No newline at end of file diff --git a/ANNOTATE/README.md b/ANNOTATE/README.md index 28f463d..bcc2bde 100644 --- a/ANNOTATE/README.md +++ b/ANNOTATE/README.md @@ -44,12 +44,12 @@ ANNOTATE/ pip install dash plotly pandas numpy # Run the application -python TESTCASES/web/app.py +python ANNOTATE/web/app.py ``` ## Usage -1. **Start the application**: Run `python TESTCASES/web/app.py` +1. **Start the application**: Run `python ANNOTATE/web/app.py` 2. **Open browser**: Navigate to `http://localhost:8051` 3. **Select symbol and timeframe**: Choose trading pair and timeframes to display 4. **Navigate to time period**: Use date picker or scroll to find market conditions @@ -74,10 +74,10 @@ This sub-project is designed to be self-contained but can be integrated with the ```python # Import annotation manager in main system -from TESTCASES.core.annotation_manager import AnnotationManager +from ANNOTATE.core.annotation_manager import AnnotationManager # Import training simulator -from TESTCASES.core.training_simulator import TrainingSimulator +from ANNOTATE.core.training_simulator import TrainingSimulator # Use generated test cases in training test_cases = annotation_manager.get_test_cases() diff --git a/ANNOTATE/core/__init__.py b/ANNOTATE/core/__init__.py index f0daa1e..f4e8d36 100644 --- a/ANNOTATE/core/__init__.py +++ b/ANNOTATE/core/__init__.py @@ -1,5 +1,5 @@ """ -TESTCASES Core Module +ANNOTATE Core Module Core business logic for the Manual Trade Annotation UI """ diff --git a/ANNOTATE/core/annotation_manager.py b/ANNOTATE/core/annotation_manager.py index 10193ea..fc30013 100644 --- a/ANNOTATE/core/annotation_manager.py +++ b/ANNOTATE/core/annotation_manager.py @@ -39,7 +39,7 @@ class TradeAnnotation: class AnnotationManager: """Manages trade annotations and test case generation""" - def __init__(self, storage_path: str = "TESTCASES/data/annotations"): + def __init__(self, storage_path: str = "ANNOTATE/data/annotations"): """Initialize annotation manager""" self.storage_path = Path(storage_path) self.storage_path.mkdir(parents=True, exist_ok=True) diff --git a/ANNOTATE/core/training_simulator.py b/ANNOTATE/core/training_simulator.py index cf26372..39b63f0 100644 --- a/ANNOTATE/core/training_simulator.py +++ b/ANNOTATE/core/training_simulator.py @@ -54,7 +54,7 @@ class TrainingSimulator: self.training_sessions = {} # Storage for training results - self.results_dir = Path("TESTCASES/data/training_results") + self.results_dir = Path("ANNOTATE/data/training_results") self.results_dir.mkdir(parents=True, exist_ok=True) logger.info("TrainingSimulator initialized") diff --git a/ANNOTATE/data/trading_system.db b/ANNOTATE/data/trading_system.db new file mode 100644 index 0000000..80fef86 Binary files /dev/null and b/ANNOTATE/data/trading_system.db differ diff --git a/ANNOTATE/web/app.py b/ANNOTATE/web/app.py index 344d5a0..2b732f0 100644 --- a/ANNOTATE/web/app.py +++ b/ANNOTATE/web/app.py @@ -31,9 +31,9 @@ except ImportError as e: TradingOrchestrator = None get_config = lambda: {} -# Import TESTCASES modules -testcases_dir = Path(__file__).parent.parent -sys.path.insert(0, str(testcases_dir)) +# Import ANNOTATE modules +annotate_dir = Path(__file__).parent.parent +sys.path.insert(0, str(annotate_dir)) try: from core.annotation_manager import AnnotationManager @@ -45,7 +45,7 @@ except ImportError: # Load annotation_manager ann_spec = importlib.util.spec_from_file_location( "annotation_manager", - testcases_dir / "core" / "annotation_manager.py" + annotate_dir / "core" / "annotation_manager.py" ) ann_module = importlib.util.module_from_spec(ann_spec) ann_spec.loader.exec_module(ann_module) @@ -54,7 +54,7 @@ except ImportError: # Load training_simulator train_spec = importlib.util.spec_from_file_location( "training_simulator", - testcases_dir / "core" / "training_simulator.py" + annotate_dir / "core" / "training_simulator.py" ) train_module = importlib.util.module_from_spec(train_spec) train_spec.loader.exec_module(train_module) @@ -82,7 +82,7 @@ class AnnotationDashboard: static_folder='static' ) - # Initialize Dash app + # Initialize Dash app (optional component) self.app = Dash( __name__, server=self.server, @@ -93,13 +93,23 @@ class AnnotationDashboard: ] ) + # Set a simple Dash layout to avoid NoLayoutException + self.app.layout = html.Div([ + html.H1("ANNOTATE Dashboard", className="text-center mb-4"), + html.Div([ + html.P("This is the Dash component of the ANNOTATE system."), + html.P("The main interface is available at the Flask routes."), + html.A("Go to Main Interface", href="/", className="btn btn-primary") + ], className="container") + ]) + # Initialize core components self.data_provider = DataProvider() if DataProvider else None self.orchestrator = TradingOrchestrator( data_provider=self.data_provider ) if TradingOrchestrator and self.data_provider else None - # Initialize TESTCASES components + # Initialize ANNOTATE components self.annotation_manager = AnnotationManager() self.training_simulator = TrainingSimulator(self.orchestrator) if self.orchestrator else None @@ -114,18 +124,65 @@ class AnnotationDashboard: @self.server.route('/') def index(): """Main dashboard page""" - # Get current annotations - annotations = self.annotation_manager.get_annotations() - - # Prepare template data - template_data = { - 'current_symbol': 'ETH/USDT', - 'timeframes': ['1s', '1m', '1h', '1d'], - 'annotations': [ann.__dict__ if hasattr(ann, '__dict__') else ann - for ann in annotations] - } - - return render_template('annotation_dashboard.html', **template_data) + try: + # Get current annotations + annotations = self.annotation_manager.get_annotations() + + # Prepare template data + template_data = { + 'current_symbol': 'ETH/USDT', + 'timeframes': ['1s', '1m', '1h', '1d'], + 'annotations': [ann.__dict__ if hasattr(ann, '__dict__') else ann + for ann in annotations] + } + + return render_template('annotation_dashboard.html', **template_data) + except Exception as e: + logger.error(f"Error rendering main page: {e}") + # Fallback simple HTML page + return f""" + + + ANNOTATE - Manual Trade Annotation UI + + + +
+

๐Ÿ“ ANNOTATE - Manual Trade Annotation UI

+
+

System Status

+

โœ… Annotation Manager: Active

+

โš ๏ธ Data Provider: {'Available' if self.data_provider else 'Not Available (Standalone Mode)'}

+

โš ๏ธ Trading Orchestrator: {'Available' if self.orchestrator else 'Not Available (Standalone Mode)'}

+
+
+
+

Available Features

+
    +
  • Manual trade annotation
  • +
  • Test case generation
  • +
  • Annotation export
  • +
  • Training simulation
  • +
+
+
+

API Endpoints

+
    +
  • POST /api/chart-data - Get chart data
  • +
  • POST /api/save-annotation - Save annotation
  • +
  • POST /api/delete-annotation - Delete annotation
  • +
  • POST /api/generate-test-case - Generate test case
  • +
  • POST /api/export-annotations - Export annotations
  • +
+
+
+
+ Go to Dash Interface +
+
+ + + """ @self.server.route('/api/chart-data', methods=['POST']) def get_chart_data():