cash works again!
This commit is contained in:
111
main_clean.py
111
main_clean.py
@ -26,7 +26,7 @@ import time
|
||||
project_root = Path(__file__).parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
from core.config import get_config, setup_logging
|
||||
from core.config import get_config, setup_logging, Config
|
||||
from core.data_provider import DataProvider
|
||||
from core.orchestrator import TradingOrchestrator
|
||||
|
||||
@ -86,6 +86,9 @@ def run_cnn_training(config: Config, symbol: str):
|
||||
"""Run CNN training mode with TensorBoard monitoring"""
|
||||
logger.info("Starting CNN Training Mode...")
|
||||
|
||||
# Import CNNTrainer
|
||||
from training.cnn_trainer import CNNTrainer
|
||||
|
||||
# Initialize data provider and trainer
|
||||
data_provider = DataProvider(config)
|
||||
trainer = CNNTrainer(config)
|
||||
@ -274,83 +277,53 @@ def run_live_trading():
|
||||
logger.error(f"Error in live trading: {e}")
|
||||
raise
|
||||
|
||||
def run_web_dashboard(port: int = 8050, demo_mode: bool = True):
|
||||
"""Run the enhanced web dashboard"""
|
||||
def run_web_dashboard():
|
||||
"""Run web dashboard with enhanced real-time data - NO SYNTHETIC DATA"""
|
||||
try:
|
||||
from web.dashboard import TradingDashboard
|
||||
logger.info("Starting Web Dashboard Mode with REAL LIVE DATA...")
|
||||
|
||||
logger.info("Starting Enhanced Web Dashboard...")
|
||||
# Initialize with real data provider
|
||||
data_provider = DataProvider()
|
||||
|
||||
# Initialize components with 1s scalping focus
|
||||
data_provider = DataProvider(
|
||||
symbols=['ETH/USDT'],
|
||||
timeframes=['1s', '1m', '5m', '1h', '4h']
|
||||
)
|
||||
# Verify we have real data connection
|
||||
logger.info("🔍 Verifying REAL data connection...")
|
||||
test_data = data_provider.get_historical_data('ETH/USDT', '1m', limit=10, refresh=True)
|
||||
if test_data is None or test_data.empty:
|
||||
logger.warning("⚠️ No fresh data available - trying cached data...")
|
||||
test_data = data_provider.get_historical_data('ETH/USDT', '1m', limit=10, refresh=False)
|
||||
|
||||
if test_data is None or test_data.empty:
|
||||
logger.warning("⚠️ No data available - starting dashboard with demo mode...")
|
||||
else:
|
||||
logger.info("✅ Data connection verified")
|
||||
logger.info(f"✅ Fetched {len(test_data)} candles for validation")
|
||||
|
||||
# Initialize orchestrator with real data only
|
||||
orchestrator = TradingOrchestrator(data_provider)
|
||||
|
||||
# Create dashboard
|
||||
# Start dashboard - use the correct import
|
||||
from web.dashboard import TradingDashboard
|
||||
dashboard = TradingDashboard(data_provider, orchestrator)
|
||||
|
||||
if demo_mode:
|
||||
# Start demo mode with realistic scalping decisions
|
||||
logger.info("Starting scalping demo mode...")
|
||||
|
||||
def scalping_demo_thread():
|
||||
"""Generate realistic scalping decisions"""
|
||||
import random
|
||||
import time
|
||||
from datetime import datetime
|
||||
from core.orchestrator import TradingDecision
|
||||
|
||||
actions = ['BUY', 'SELL', 'HOLD']
|
||||
action_weights = [0.3, 0.3, 0.4] # More holds in scalping
|
||||
base_price = 3000.0
|
||||
|
||||
while True:
|
||||
try:
|
||||
# Simulate small price movements for scalping
|
||||
price_change = random.uniform(-5, 5) # Smaller movements
|
||||
current_price = max(base_price + price_change, 1000)
|
||||
|
||||
# Create scalping decision
|
||||
action = random.choices(actions, weights=action_weights)[0]
|
||||
confidence = random.uniform(0.7, 0.95) # Higher confidence for scalping
|
||||
|
||||
decision = TradingDecision(
|
||||
action=action,
|
||||
confidence=confidence,
|
||||
symbol='ETH/USDT',
|
||||
price=current_price,
|
||||
timestamp=datetime.now(),
|
||||
reasoning={'scalping_demo': True, 'timeframe': '1s'},
|
||||
memory_usage={'demo': 0}
|
||||
)
|
||||
|
||||
dashboard.add_trading_decision(decision)
|
||||
logger.info(f"Scalping: {action} ETH/USDT @${current_price:.2f} (conf: {confidence:.2f})")
|
||||
|
||||
# Update base price occasionally
|
||||
if random.random() < 0.2:
|
||||
base_price = current_price
|
||||
|
||||
time.sleep(3) # Faster decisions for scalping
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in scalping demo: {e}")
|
||||
time.sleep(5)
|
||||
|
||||
# Start scalping demo thread
|
||||
demo_thread_instance = Thread(target=scalping_demo_thread, daemon=True)
|
||||
demo_thread_instance.start()
|
||||
logger.info("🎯 LAUNCHING DASHBOARD")
|
||||
logger.info(f"🌐 Access at: http://127.0.0.1:8050")
|
||||
|
||||
# Run dashboard
|
||||
dashboard.run(port=port, debug=False)
|
||||
# Run the dashboard
|
||||
dashboard.run(host='127.0.0.1', port=8050, debug=False)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error running web dashboard: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
raise
|
||||
logger.error(f"Error in web dashboard: {e}")
|
||||
logger.error("Dashboard stopped - trying fallback mode")
|
||||
# Try a simpler fallback
|
||||
try:
|
||||
from web.dashboard import TradingDashboard
|
||||
data_provider = DataProvider()
|
||||
orchestrator = TradingOrchestrator(data_provider)
|
||||
dashboard = TradingDashboard(data_provider, orchestrator)
|
||||
dashboard.run(host='127.0.0.1', port=8050, debug=False)
|
||||
except Exception as fallback_error:
|
||||
logger.error(f"Fallback dashboard also failed: {fallback_error}")
|
||||
raise
|
||||
|
||||
async def main():
|
||||
"""Main entry point with clean mode selection"""
|
||||
@ -390,7 +363,7 @@ async def main():
|
||||
elif args.mode == 'trade':
|
||||
run_live_trading()
|
||||
elif args.mode == 'web':
|
||||
run_web_dashboard(port=args.port, demo_mode=args.demo)
|
||||
run_web_dashboard()
|
||||
|
||||
logger.info("Operation completed successfully!")
|
||||
|
||||
|
Reference in New Issue
Block a user