Files
uniswap_auto_clp/todo/DYNAMIC_TIMEOUT_ANALYSIS.md

1.7 KiB

Analysis Request: Dynamic Timeout for Shadow Orders

Status: Completed Date: 2025-12-20 Priority: Medium


1. User Description & Query

Goal: Optimize the Shadow Order simulation by making the "Time to Live" (timeout) dynamic based on market volatility. Logic:

  • Low Volatility (Slow Market): Orders sit on the book longer. Give the shadow order more time (e.g., 60s) to fill.
  • High Volatility (Fast Market): Price moves quickly. If it doesn't fill instantly, it likely ran away. Timeout should be short (e.g., 10s) to fail fast.

2. Agent Summary

  • Objective: Implement a dynamic timeout calculation during shadow order creation.
  • Formula: Inverse relationship with volatility.

3. Main Analysis

3.1 Volatility Scaling

We already calculate vol_pct (5-min rolling StdDev).

  • Base Vol: 0.05% (0.0005).
  • Base Timeout: 30 seconds.

Formula: timeout = Base_Timeout * (Base_Vol / Current_Vol)

Examples:

  • Low Vol (0.025%): 30 * (0.05 / 0.025) = 60s (Max cap).
  • Normal Vol (0.05%): 30 * (0.05 / 0.05) = 30s.
  • High Vol (0.15%): 30 * (0.05 / 0.15) = 10s.

3.2 Constraints

  • Min Timeout: 10s (Give at least some chance even in crazy markets).
  • Max Timeout: 60s (Don't track stale orders forever).

4. Conclusion

Recommendation: Implement this dynamic timeout alongside the shadow order logic. It makes the "Success/Fail" metric much more realistic for a Maker strategy in different regimes.

5. Implementation Plan

  • Step 1: Add get_dynamic_timeout(vol_pct) helper method.
  • Step 2: Use this timeout when creating the shadow order entry.