Files
DOLPHIN/prod/launch_paper_portfolio.py

86 lines
2.8 KiB
Python
Raw Permalink Normal View History

"""
DOLPHIN Nautilus Paper Trading Portfolio - Realistic Friction Edition
=====================================================================
Path: prod/launch_paper_portfolio.py
Launches a Dolphin-Nautilus portfolio in PAPER mode using the internal
Sandbox matching engine with realistic Binance Futures fees and slippage.
"""
import asyncio
import os
import sys
import logging
from pathlib import Path
from dotenv import load_dotenv
# Add project root and package to path
# File is in prod/, so we need 2 .parent to reach project root
PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT / 'nautilus_dolphin'))
sys.path.insert(0, str(PROJECT_ROOT))
# Load credentials from .env
load_dotenv(PROJECT_ROOT / '.env')
from nautilus_trader.model.objects import Money
from nautilus_dolphin.nautilus.launcher import NautilusDolphinLauncher
# Configure Logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("PaperPortfolio")
# ---------------------------------------------------------------------------
# PAPER TRADING CONFIGURATION (Realistic Friction)
# ---------------------------------------------------------------------------
PAPER_CONFIG = {
'venue': 'BINANCE_FUTURES',
'environment': 'PAPER',
'trader_id': 'DOLPHIN-PHOENIX-01',
'auth': {
'api_key': os.getenv('MRS_BINANCE_API_KEY'),
'api_secret': os.getenv('MRS_BINANCE_SECRET_KEY'),
},
'strategy': {
'venue': 'BINANCE_FUTURES',
'acb_enabled': True,
# --- DISABLE INTERNAL FRICTION OVERRIDES ---
# We disable these so Nautilus can handle them natively
'use_sp_fees': False,
'use_sp_slippage': False,
'use_ob_edge': False, # Disable MC-fallback edge for cleaner proof
'max_leverage': 5.0,
'capital_fraction': 0.10, # Conservative 10% fraction for paper testing
'tp_bps': 99,
'max_hold_bars': 120,
},
'execution': {
'testnet': False, # Use Mainnet data feeds
'use_sandbox': True, # Match orders internally (Paper Trading)
'account_type': 'FUTURES_USDT',
},
}
async def launch():
logger.info("Starting DOLPHIN Paper Portfolio (Phoenix-01)...")
logger.info("Sandbox Mode: ENABLED")
logger.info("Internal Friction (Legacy): BYPASSED")
logger.info("Nautilus Friction (Realistic): ENABLED (0.02%/0.05%)")
try:
launcher = NautilusDolphinLauncher(PAPER_CONFIG)
await launcher.start()
except KeyboardInterrupt:
logger.info("Stopping portfolio...")
except Exception as e:
logger.error(f"Failed to launch portfolio: {e}")
if __name__ == "__main__":
if not os.getenv('MRS_BINANCE_API_KEY'):
logger.error("API Keys missing! Ensure .env is populated.")
sys.exit(1)
asyncio.run(launch())