""" Patch Nautilus 1.219.0 Bug ========================== Fixes the Strategy.__init__ bug where Logger expects str but gets StrategyId. Usage: python patch_nautilus_bug.py # Then run your backtest """ import sys import nautilus_trader from pathlib import Path # Find Nautilus installation nautilus_path = Path(nautilus_trader.__file__).parent strategy_pxd = nautilus_path / "trading" / "strategy.pyx" strategy_py = nautilus_path / "trading" / "strategy.py" print("Nautilus Trader Bug Patch") print("=" * 50) print(f"Nautilus path: {nautilus_path}") # Check if we can find the source if strategy_pxd.exists(): print(f"Found: {strategy_pxd}") # This is a Cython file - would need recompilation print("Note: strategy.pyx is a Cython file - requires recompilation after patching") elif strategy_py.exists(): print(f"Found: {strategy_py}") # This is a Python file - can patch directly with open(strategy_py, 'r') as f: content = f.read() if 'Logger(name=component_id)' in content: print("Patching strategy.py...") content = content.replace( 'Logger(name=component_id)', 'Logger(name=str(component_id))' ) with open(strategy_py, 'w') as f: f.write(content) print("✅ Patched successfully!") else: print("ℹ️ Already patched or different version") else: print("⚠️ Could not find strategy source files") print("\nAlternative: Use the workaround in DolphinExecutionStrategy") print("The strategy already has a try/except workaround for this bug.")