From d5290643fbaaa1891a9a47480dd88a622023af1c Mon Sep 17 00:00:00 2001 From: Reynov Christian Date: Fri, 21 Nov 2025 18:11:34 +0800 Subject: [PATCH] chore: remove Vercel configuration and cleanup dependencies --- MT5_SETUP_GUIDE.md | 14 +++++++------- README_STREAMLIT.md | 3 ++- api/app.py | 10 ---------- core/backtesting/engine.py | 5 ++--- core/routes/ai_mentor.py | 2 +- last_broker.json | 2 +- requirements.txt | 1 - setup_quantumbotx.py | 2 +- streamlit_demo.py | 2 -- testing/BACKTESTING_FIX_SUMMARY.md | 6 +++--- testing/create_crypto_bot.py | 22 +++++++++++----------- testing/crypto_integration_demo.py | 3 +-- testing/debug_backtest_execution.py | 25 ++++++++++++------------- testing/test_ai_mentor_integration.py | 4 ++-- testing/test_analysis_api.py | 4 ++-- testing/test_atr_education.py | 4 ++-- testing/test_crypto_fixes.py | 3 --- vercel.json | 15 --------------- 18 files changed, 47 insertions(+), 80 deletions(-) delete mode 100644 api/app.py delete mode 100644 vercel.json diff --git a/MT5_SETUP_GUIDE.md b/MT5_SETUP_GUIDE.md index 156f960..c77b434 100644 --- a/MT5_SETUP_GUIDE.md +++ b/MT5_SETUP_GUIDE.md @@ -15,7 +15,7 @@ ## ⚔ Quick Setup (3 Steps) ### Step 1: Install MT5 Platform -``` +```text 1. Download MT5 from: https://www.metatrader5.com/en/download 2. Install in default location: C:\Program Files\MetaTrader 5 3. Launch MT5 and login to your account (demo recommended) @@ -113,7 +113,7 @@ MT5_SERVER=YourBroker-ServerName python lab/download_data.py ``` **Expected Output:** -``` +```text āœ… Successfully connected to MT5 šŸ“” Server: FBS-Demo šŸ‘¤ Account: 12345678 @@ -125,7 +125,7 @@ python lab/download_data.py ``` ### Test 2: Web Interface -``` +```text 1. Start QuantumBotX: python run.py 2. Open: http://localhost:5000/backtest 3. Click: "Download Data MT5" button @@ -147,7 +147,7 @@ pip install MetaTrader5-5.0.34-cp39-cp39-win_amd64.whl ``` ### Error: "Failed to initialize MT5" -``` +```text āœ… Check MT5 is running āœ… Verify account credentials in .env āœ… Try Demo account first @@ -155,7 +155,7 @@ pip install MetaTrader5-5.0.34-cp39-cp39-win_amd64.whl ``` ### Error: "Symbol not found" -``` +```text āœ… MT5 shows: "Enable Auto Trading" in algo settings āœ… Check if symbol is visible in MT5 Market Watch āœ… Some symbols need manual activation in MT5 @@ -163,7 +163,7 @@ pip install MetaTrader5-5.0.34-cp39-cp39-win_amd64.whl ``` ### Error: "Download timed out" -``` +```text āœ… Reduce download period in script if needed āœ… Check internet connection stability āœ… Some brokers are faster than others @@ -207,7 +207,7 @@ print(f"Latest close: {df['close'].iloc[-1]}") ``` **Expected Output:** -``` +```text Rows: 15800+ (4+ years of H1 data) Date range: 2020-01-01 to current_date Latest close: matches MT5 current price diff --git a/README_STREAMLIT.md b/README_STREAMLIT.md index 1762420..3571b85 100644 --- a/README_STREAMLIT.md +++ b/README_STREAMLIT.md @@ -74,7 +74,8 @@ Since MetaTrader 5 requires **Windows OS and persistent terminal connections**, 2. **Create requirements.txt** (use `streamlit_requirements.txt`) 3. **Create Procfile**: - ``` + + ```bash web: streamlit run streamlit_demo.py --server.port $PORT --server.headless true ``` diff --git a/api/app.py b/api/app.py deleted file mode 100644 index ab1d42f..0000000 --- a/api/app.py +++ /dev/null @@ -1,10 +0,0 @@ -import os -from core import create_app - -# Set environment to skip MT5 initialization on Vercel -os.environ['SKIP_MT5_INIT'] = '1' - -app = create_app() - -if __name__ == '__main__': - app.run() diff --git a/core/backtesting/engine.py b/core/backtesting/engine.py index 93a1b29..3b77fc0 100644 --- a/core/backtesting/engine.py +++ b/core/backtesting/engine.py @@ -2,7 +2,6 @@ import math # Import modul math import logging # Import modul logging -import os # Import for environment variables from core.strategies.strategy_map import STRATEGY_MAP logger = logging.getLogger(__name__) @@ -214,7 +213,7 @@ def run_backtest(strategy_id, params, historical_data_df, symbol_name=None): # Final safety check - never allow lot size above 0.03 for gold if lot_size > 0.03: lot_size = 0.03 - logger.warning(f"GOLD SAFETY: Lot capped at 0.03") + logger.warning("GOLD SAFETY: Lot capped at 0.03") # Round to valid lot size increments lot_size = round(lot_size, 2) @@ -304,7 +303,7 @@ def run_backtest(strategy_id, params, historical_data_df, symbol_name=None): logger.info(f"Backtest Complete: {len(trades)} trades, ${total_profit_clean:+.0f} profit, {win_rate_clean:.0f}% win rate") # Debug detailed results - logger.debug(f"=== DETAILED BACKTEST RESULTS ===") + logger.debug("=== DETAILED BACKTEST RESULTS ===") logger.debug(f"Initial Capital: {initial_capital}") logger.debug(f"Final Capital: {capital}") logger.debug(f"Total Profit: {total_profit}") diff --git a/core/routes/ai_mentor.py b/core/routes/ai_mentor.py index df88820..54d401b 100644 --- a/core/routes/ai_mentor.py +++ b/core/routes/ai_mentor.py @@ -5,7 +5,7 @@ Routes untuk menampilkan laporan AI mentor dan interaksi pengguna """ from flask import Blueprint, render_template, request, jsonify, flash, redirect, url_for -from datetime import datetime, date, timedelta +from datetime import datetime, date from core.ai.trading_mentor_ai import IndonesianTradingMentorAI, TradingSession from core.db.models import ( get_trading_session_data, save_ai_mentor_report, diff --git a/last_broker.json b/last_broker.json index 65cdf07..91e9a07 100644 --- a/last_broker.json +++ b/last_broker.json @@ -1,5 +1,5 @@ { "broker": "FBS-Demo", "company": "FBS Markets Inc.", - "last_check": "2025-10-16T03:19:13.829792" + "last_check": "2025-10-22T14:43:57.762205" } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2369f1e..3b4e637 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ charset-normalizer==3.4.2 click==8.2.1 colorama==0.4.6 Flask==3.1.1 -gunicorn==22.0.0 idna==3.10 itsdangerous==2.2.0 Jinja2==3.1.6 diff --git a/setup_quantumbotx.py b/setup_quantumbotx.py index c0c0cb1..94df5eb 100644 --- a/setup_quantumbotx.py +++ b/setup_quantumbotx.py @@ -82,7 +82,7 @@ def create_desktop_shortcut(): try: # Get user's desktop path desktop = Path.home() / "Desktop" - shortcut_path = desktop / "QuantumBotX.lnk" + desktop / "QuantumBotX.lnk" # Create a simple batch file that will be the shortcut target shortcut_bat = '''@echo off diff --git a/streamlit_demo.py b/streamlit_demo.py index e6876f7..fc4b35a 100644 --- a/streamlit_demo.py +++ b/streamlit_demo.py @@ -1,8 +1,6 @@ import streamlit as st import pandas as pd -import numpy as np from datetime import datetime, timedelta -import time import random # Page configuration diff --git a/testing/BACKTESTING_FIX_SUMMARY.md b/testing/BACKTESTING_FIX_SUMMARY.md index 50419bf..bab0809 100644 --- a/testing/BACKTESTING_FIX_SUMMARY.md +++ b/testing/BACKTESTING_FIX_SUMMARY.md @@ -16,7 +16,7 @@ After comprehensive testing, I identified the **PRIMARY ISSUE**: The enhanced backtesting engine was calculating spread costs that were **100% of the risk amount per trade**: -``` +```text Original Calculation: - Risk per trade: $100 (1% of $10,000) - Spread cost: $100 (100% of risk!) @@ -54,7 +54,7 @@ spread_cost = spread_pips * 1.0 * lot_size # $0.50 for 0.5 lot ## šŸ“Š BEFORE vs AFTER COMPARISON ### **BEFORE (Broken)** -``` +```text EURUSD Bollinger Squeeze Test: - Gross Profit: -$10,000.03 - Spread Costs: -$7,414.00 @@ -64,7 +64,7 @@ EURUSD Bollinger Squeeze Test: ``` ### **AFTER (Fixed)** -``` +```text EURUSD Test Results: - Spread costs: ~0.5% of risk per trade - Reasonable drawdowns (<50%) diff --git a/testing/create_crypto_bot.py b/testing/create_crypto_bot.py index d73a826..586968a 100644 --- a/testing/create_crypto_bot.py +++ b/testing/create_crypto_bot.py @@ -47,7 +47,7 @@ try: def check_crypto_symbols(): """Check if crypto symbols are available and get current prices""" - print(f"\\nšŸ’° CRYPTO MARKET CHECK") + print("\\nšŸ’° CRYPTO MARKET CHECK") print("=" * 30) if not mt5.initialize(): @@ -96,7 +96,7 @@ try: def create_trading_plan(): """Create a trading plan for SatoshiJakarta""" - print(f"\\nšŸ“‹ SATOSHIJAKARTA TRADING PLAN") + print("\\nšŸ“‹ SATOSHIJAKARTA TRADING PLAN") print("=" * 40) plan = { @@ -137,11 +137,11 @@ try: print(f" Size: {plan['secondary_pair']['position_size']}") print(f" Why: {plan['secondary_pair']['reasoning']}") - print(f"\\nšŸ›”ļø Risk Management:") + print("\\nšŸ›”ļø Risk Management:") for key, value in plan['risk_management'].items(): print(f" {key.replace('_', ' ').title()}: {value}") - print(f"\\nā° Trading Schedule:") + print("\\nā° Trading Schedule:") for day, activity in plan['schedule'].items(): print(f" {day.title()}: {activity}") @@ -149,7 +149,7 @@ try: def show_next_steps(): """Show immediate next steps""" - print(f"\\nšŸŽÆ IMMEDIATE NEXT STEPS") + print("\\nšŸŽÆ IMMEDIATE NEXT STEPS") print("=" * 30) steps = [ @@ -185,12 +185,12 @@ try: print(f" šŸŽÆ Action: {step_info['action']}") print(f" ā±ļø Time: {step_info['time']}") - print(f"\\nšŸ”„ TOTAL SETUP TIME: 12 minutes!") - print(f"Then you'll have 24/7 crypto profit machine! šŸš€") + print("\\nšŸ”„ TOTAL SETUP TIME: 12 minutes!") + print("Then you'll have 24/7 crypto profit machine! šŸš€") def show_crypto_advantages(): """Show why crypto trading is perfect for Indonesian traders""" - print(f"\\nšŸ‡®šŸ‡© WHY CRYPTO IS PERFECT FOR INDONESIA") + print("\\nšŸ‡®šŸ‡© WHY CRYPTO IS PERFECT FOR INDONESIA") print("=" * 45) advantages = [ @@ -230,7 +230,7 @@ try: # Show next steps show_next_steps() - print(f"\\n" + "=" * 60) + print("\\n" + "=" * 60) print("šŸŽ‰ SATOSHIJAKARTA IS READY!") print("=" * 60) print("āœ… Bot configured for Bitcoin & Ethereum") @@ -239,10 +239,10 @@ try: print("āœ… Weekend mode active for 24/7 profits") print("āœ… Perfect for your timezone and goals") - print(f"\\nšŸš€ FROM JAKARTA TO THE MOON!") + print("\\nšŸš€ FROM JAKARTA TO THE MOON!") print("Your crypto trading journey starts NOW! šŸŒ™šŸ‡®šŸ‡©") - print(f"\\nšŸ’Ž REMEMBER:") + print("\\nšŸ’Ž REMEMBER:") print("Satoshi Nakamoto gave us Bitcoin...") print("SatoshiJakarta will give you PROFITS! ā‚æšŸ’°") diff --git a/testing/crypto_integration_demo.py b/testing/crypto_integration_demo.py index 398457b..6b1a8a6 100644 --- a/testing/crypto_integration_demo.py +++ b/testing/crypto_integration_demo.py @@ -8,7 +8,6 @@ import sys import os import pandas as pd import numpy as np -from datetime import datetime, timedelta # Add the project root to the path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) @@ -153,7 +152,7 @@ def test_crypto_strategy_performance(): total_profit += strategy_stats['profit'] total_trades += strategy_stats['trades'] - print(f"\\nšŸ† Overall Results:") + print("\\nšŸ† Overall Results:") print(f" Total Profit: ${total_profit:,.2f}") print(f" Total Trades: {total_trades}") print(f" Average Profit per Trade: ${total_profit/max(total_trades,1):,.2f}") diff --git a/testing/debug_backtest_execution.py b/testing/debug_backtest_execution.py index 3d4502b..435fa30 100644 --- a/testing/debug_backtest_execution.py +++ b/testing/debug_backtest_execution.py @@ -65,7 +65,6 @@ def debug_enhanced_backtest(): df_with_signals = strategy.analyze_df(df.copy()) # Add ATR - import pandas_ta as ta df_with_signals.ta.atr(length=14, append=True) df_with_signals.dropna(inplace=True) df_with_signals.reset_index(inplace=True) @@ -78,7 +77,7 @@ def debug_enhanced_backtest(): # Show signal bars signal_bars = df_with_signals[df_with_signals['signal'] != 'HOLD'] - print(f"Signal bars:") + print("Signal bars:") for i, row in signal_bars.iterrows(): print(f" Index {i}: {row['signal']} | Close: {row['close']:.5f} | ATR: {row.get('ATRr_14', 'Missing')}") @@ -87,7 +86,7 @@ def debug_enhanced_backtest(): return # Manual backtest loop simulation - print(f"\\nšŸ”„ SIMULATING BACKTEST LOOP...") + print("\\nšŸ”„ SIMULATING BACKTEST LOOP...") # Initialize engine = EnhancedBacktestEngine() @@ -102,7 +101,7 @@ def debug_enhanced_backtest(): sl_atr_multiplier = float(params.get('sl_atr_multiplier', params.get('sl_pips', 2.0))) tp_atr_multiplier = float(params.get('tp_atr_multiplier', params.get('tp_pips', 4.0))) - print(f"Engine parameters:") + print("Engine parameters:") print(f" Risk: {risk_percent}%") print(f" SL: {sl_atr_multiplier}x ATR") print(f" TP: {tp_atr_multiplier}x ATR") @@ -129,7 +128,7 @@ def debug_enhanced_backtest(): print(f" ATR: {atr_value}") if atr_value <= 0: - print(f" āŒ Invalid ATR - skipping") + print(" āŒ Invalid ATR - skipping") continue # Calculate distances @@ -147,7 +146,7 @@ def debug_enhanced_backtest(): print(f" Calculated lot size: {lot_size}") if lot_size <= 0: - print(f" āŒ Invalid lot size - skipping") + print(" āŒ Invalid lot size - skipping") continue # Calculate entry price @@ -174,10 +173,10 @@ def debug_enhanced_backtest(): estimated_risk = sl_distance * lot_size * config['contract_size'] max_risk_dollar = capital * config.get('emergency_brake_percent', 0.05) if estimated_risk > max_risk_dollar: - print(f" 🚨 Emergency brake triggered - skipping") + print(" 🚨 Emergency brake triggered - skipping") continue - print(f" āœ… Trade would be executed!") + print(" āœ… Trade would be executed!") # For debugging, let's see if we can find the next exit for j in range(i+1, len(df_with_signals)): @@ -199,7 +198,7 @@ def debug_enhanced_backtest(): break if j > i + 10: # Only check next 10 bars - print(f" ā° No exit in next 10 bars") + print(" ā° No exit in next 10 bars") break trades.append({'signal': signal, 'entry': entry_price}) @@ -207,14 +206,14 @@ def debug_enhanced_backtest(): if len(trades) >= 3: # Limit debug output break - print(f"\\nšŸ“‹ DEBUG SUMMARY:") + print("\\nšŸ“‹ DEBUG SUMMARY:") print(f"Processed {len(trades)} potential trades") if len(trades) > 0: - print(f"āœ… Trade logic is working - trades should execute") - print(f"ā“ The issue might be in the actual enhanced_engine implementation") + print("āœ… Trade logic is working - trades should execute") + print("ā“ The issue might be in the actual enhanced_engine implementation") else: - print(f"āŒ No trades processed - issue in trade logic") + print("āŒ No trades processed - issue in trade logic") except Exception as e: print(f"Error in debug: {e}") diff --git a/testing/test_ai_mentor_integration.py b/testing/test_ai_mentor_integration.py index cac24b2..0323365 100644 --- a/testing/test_ai_mentor_integration.py +++ b/testing/test_ai_mentor_integration.py @@ -9,7 +9,7 @@ import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from datetime import date, datetime, timedelta +from datetime import date, timedelta from core.ai.trading_mentor_ai import IndonesianTradingMentorAI, TradingSession from core.db.models import ( create_trading_session, log_trade_for_ai_analysis, @@ -127,7 +127,7 @@ def test_historical_reports(): emotions_cycle = ['tenang', 'serakah', 'frustasi', 'takut', 'tenang', 'serakah', 'tenang'] for test_date, emotion in zip(historical_dates, emotions_cycle): - session_id = create_trading_session( + create_trading_session( session_date=test_date, emotions=emotion, market_conditions='normal', diff --git a/testing/test_analysis_api.py b/testing/test_analysis_api.py index e3174ef..e72e698 100644 --- a/testing/test_analysis_api.py +++ b/testing/test_analysis_api.py @@ -31,7 +31,7 @@ try: # Check if bot 3 is in active_bots if bot_id in active_bots: bot_instance = active_bots[bot_id] - print(f"Bot instance found:") + print("Bot instance found:") print(f" - Alive: {bot_instance.is_alive()}") print(f" - Status: {bot_instance.status}") if hasattr(bot_instance, 'last_analysis'): @@ -42,7 +42,7 @@ try: # Get bot from database bot_data = queries.get_bot_by_id(bot_id) if bot_data: - print(f"\\nBot in database:") + print("\\nBot in database:") print(f" - Name: {bot_data['name']}") print(f" - Market: {bot_data['market']}") print(f" - Status: {bot_data['status']}") diff --git a/testing/test_atr_education.py b/testing/test_atr_education.py index d2b5ac5..50e046a 100644 --- a/testing/test_atr_education.py +++ b/testing/test_atr_education.py @@ -69,7 +69,7 @@ def test_atr_education_system(): print(f" Risk-to-Reward: {example['risk_to_reward_ratio']}") if example['protection_active']: - print(f" šŸ›”ļø PROTECTION: System reduced risk for safety!") + print(" šŸ›”ļø PROTECTION: System reduced risk for safety!") # Test 3: Parameter validation print("\n3. āš™ļø Parameter Validation:") @@ -161,7 +161,7 @@ def demonstrate_atr_protection(): print(f" šŸ’° PROTECTION SAVED: ${savings:.0f}") print(f" šŸŽÆ System automatically reduced risk by {(savings/example['amount_to_risk_target']*100):.0f}%") - print(f"\\n šŸ“ Explanation:") + print("\\n šŸ“ Explanation:") for exp in example['explanation']: print(f" {exp}") diff --git a/testing/test_crypto_fixes.py b/testing/test_crypto_fixes.py index 3c6eef4..c83cd4c 100644 --- a/testing/test_crypto_fixes.py +++ b/testing/test_crypto_fixes.py @@ -8,10 +8,7 @@ import sys import os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) -import pandas as pd -import numpy as np import logging -from pathlib import Path # Set up logging to see what's happening logging.basicConfig(level=logging.INFO, format='%(levelname)s:%(name)s:%(message)s') diff --git a/vercel.json b/vercel.json deleted file mode 100644 index 9c74b42..0000000 --- a/vercel.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "routes": [ - { - "src": "/(.*)", - "dest": "/api/app.py" - } - ], - "env": { - "SKIP_MT5_INIT": "1" - } - ], - "env": { - "SKIP_MT5_INIT": "1" - } -}