#!/usr/bin/env python3
# FREEDOMMONEY tuning plan for iteration 4
# Goal: improve ratio (MTM/DD) while keeping margin_calls <= 2 and unrealized >= -60
# Strategy: adjust TP percents and investment caps to close positions faster

GRID_VALUES_ARE_DELTAS = True

def default_plan(limit_bars: int = None):
    return [
        # Short-focused leg: increase TP to lock gains faster
        ('rays', {'strategy_params_short.tpPercent': [-0.05, -0.025, 0.0, 0.025, 0.05]}),
        ('rays', {'strategy_params_short.subSellTPPercent': [-0.10, -0.05, 0.0, 0.05, 0.10]}),

        # Long leg: experiment with tighter TP (currently matched at 0.65)
        ('rays', {'strategy_params_long.tpPercent': [-0.05, -0.025, 0.0, 0.025, 0.05]}),
        ('rays', {'strategy_params_long.subSellTPPercent': [-0.10, -0.05, 0.0, 0.05, 0.10]}),

        # Investment sizing: reduce caps to limit underwater positions
        ('rays', {'strategy_params_long.maxLongInvestPct': [-0.3, -0.15, 0.0, 0.15]}),
        ('rays', {'strategy_params_short.maxShortInvestPct': [-0.2, -0.1, 0.0, 0.1]}),

        # Callback/Rise: tighter exits to close trades sooner
        ('rays', {'strategy_params_short.callbackPercent': [-0.04, -0.02, 0.0, 0.02, 0.04]}),
        ('rays', {'strategy_params_long.callbackPercent': [-0.02, -0.01, 0.0, 0.01, 0.02]}),

        # Focused short-first grids
        ('grid', {
            'strategy_params_short.tpPercent': 'around:0.02',
            'strategy_params_short.callbackPercent': 'around:0.02',
            'strategy_params_long.tpPercent': 'around:0.02',
        }),

        # Aggressive sizing grid
        ('grid', {
            'strategy_params_long.maxLongInvestPct': 'around:0.15',
            'strategy_params_short.maxShortInvestPct': 'around:0.10',
            'strategy_params_short.tpPercent': 'around:0.02',
        }),
    ]
