#!/usr/bin/env python3 """Setup Paper Trading for EXPLORATION_TEST_MULTI""" import json import subprocess import os from pathlib import Path # Verzeichnisse erstellen base_dir = Path("/opt/docker/freqtrade/paper_trading/user_data") (base_dir / "configs").mkdir(parents=True, exist_ok=True) (base_dir / "strategies").mkdir(parents=True, exist_ok=True) (base_dir / "logs").mkdir(parents=True, exist_ok=True) # Config erstellen config = { "max_open_trades": 5, "stake_currency": "USDT", "stake_amount": 100, "dry_run": True, "dry_run_wallet": 1000, "timeframe": "1h", "fee": 0.0015, "trading_mode": "spot", "exchange": {"name": "binance", "pair_whitelist": ["BTC/USDT", "ETH/USDT", "SOL/USDT", "ADA/USDT", "AVAX/USDT"]}, "pairlists": [{"method": "StaticPairList"}], "entry_pricing": {"price_side": "other", "use_order_book": True, "order_book_top": 1}, "exit_pricing": {"price_side": "other", "use_order_book": True, "order_book_top": 1}, "telegram": {"enabled": False, "token": "", "chat_id": ""}, "api_server": {"enabled": True, "listen_ip_address": "0.0.0.0", "listen_port": 8080, "username": os.getenv("PAPER_API_USERNAME", ""), "password": os.getenv("PAPER_API_PASSWORD", ""), "jwt_secret_key": os.getenv("PAPER_JWT_SECRET", "")}, "bot_name": "EXPLORATION_TEST_PAPER" } if not config["api_server"]["username"] or not config["api_server"]["password"] or not config["api_server"]["jwt_secret_key"]: raise RuntimeError("Set PAPER_API_USERNAME, PAPER_API_PASSWORD and PAPER_JWT_SECRET before running setup_paper_trading.py") with open(base_dir / "configs" / "paper_config.json", "w") as f: json.dump(config, f, indent=2) print("✅ Config created") # Strategie erstellen (die funktionierende EXPLORATION_TEST) strategy_code = '''from freqtrade.strategy import IStrategy from pandas import DataFrame import talib.abstract as ta class EXPLORATION_TEST(IStrategy): timeframe = '1h' stoploss = -0.10 trailing_stop = True trailing_stop_positive = 0.015 minimal_roi = { "0": 0.05, "30": 0.025, "60": 0.01, } def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe['ema'] = ta.EMA(dataframe, timeperiod=20) return dataframe def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[:, 'buy'] = 0 dataframe.loc[dataframe['close'] > dataframe['ema'] * 0.995, 'buy'] = 1 return dataframe def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[:, 'sell'] = 0 dataframe.loc[dataframe['close'] < dataframe['ema'] * 0.985, 'sell'] = 1 return dataframe ''' with open(base_dir / "strategies" / "EXPLORATION_TEST.py", 'w') as f: f.write(strategy_code) print("✅ Strategy created") # Container stoppen falls existiert subprocess.run(["docker", "stop", "freqtrade-paper-exploration"], capture_output=True) subprocess.run(["docker", "rm", "freqtrade-paper-exploration"], capture_output=True) print("🚀 Starting container...") result = subprocess.run([ "docker", "run", "-d", "--name", "freqtrade-paper-exploration", "--network", "host", "-v", "/opt/docker/freqtrade/paper_trading/user_data:/freqtrade/user_data:rw", "-v", "/opt/docker/freqtrade/shared_data/user_data/data:/freqtrade/user_data/data:ro", "--restart", "unless-stopped", "freqtradeorg/freqtrade:stable", "trade", "--strategy", "EXPLORATION_TEST", "--config", "/freqtrade/user_data/configs/paper_config.json", "--datadir", "/freqtrade/user_data/data/binance" ], capture_output=True, text=True) if result.returncode == 0: print(f"✅ Container started: {result.stdout[:12]}") else: print(f"❌ Error: {result.stderr}")