Files
uniswap_auto_clp/todo/EXTENDED_SHADOW_TIMEOUT.md

45 lines
2.3 KiB
Markdown

# Analysis Request: Extended Timeout for Shadow Orders
**Status:** Completed
**Date:** 2025-12-20
**Priority:** Medium
---
## 1. User Description & Query
**Goal:** Extend the Shadow Order timeout to **10 minutes (600s)** to capture the "Mean Time to Execution" across different market conditions.
**Reasoning:** Instead of failing fast (which assumes Maker is bad if not instant), we want to gather data on *how long* it actually takes to fill. This helps optimize the timeout later.
## 2. Agent Summary
* **Objective:** Modify `clp_hedger.py` to use a long fixed timeout (or much longer dynamic timeout) for shadow orders.
* **Risk:** "Success" at 9 minutes is effectively a "Failure" for hedging (Delta Drift).
* **Mitigation:** We are collecting *data*, not executing trades. A 9-minute fill log is valuable data point (it tells us "Maker is impossible here").
## 3. Main Analysis
### 3.1 Data Value vs. Hedging Reality
* **Hedging Reality:** If a hedge takes > 30s to fill, the price has likely moved significantly. The "Hedge" is no longer hedging the original risk.
* **Data Value:** By waiting 10 minutes, we can generate a distribution curve:
* *50% fill in < 5s* (Great!)
* *30% fill in 5s-60s* (Okay for stable markets)
* *20% fill in > 60s* (Terrible)
* *If we used a 60s timeout, we would just see "20% Failed", losing the nuance.*
### 3.2 Implementation Strategy
Instead of a complex dynamic timeout for now, let's set a **Fixed Long Timeout (600s)** for the Shadow Simulator.
* **Why?** We want to see the *actual* fill time for every order, not cut it off artificially.
* **Logging:** The log `filled in X.Xs` becomes the primary metric.
### 3.3 Memory Impact
* Even with 1 trade per minute, 10 minutes = 10 items in the list.
* Memory usage is negligible (<1KB).
## 4. Conclusion
**Recommendation:** Switch the Shadow Order logic to use a **Fixed 600s Timeout**.
* This turns the simulator into a "Fill Time Data Collector".
* We can analyze the logs later to find the "Optimal Timeout" (e.g., "95% of fills happen within 45s, so set timeout to 45s").
## 5. Implementation Plan
- [ ] **Step 1:** In `clp_hedger.py`, replace the dynamic timeout calculation with `timeout = 600`.
- [ ] **Step 2:** Update logging to ensure `fill_time` is prominent.