The close_trade_after setting in MagicTradeBot defines how many minutes the bot waits after the funding snapshot before closing hedged Spot + Futures positions.
This ensures that funding payments are properly received while controlling how long capital remains exposed in the market.
🔹 How It Works
Post-Funding Position Management
After the funding snapshot occurs, the bot keeps positions open for the duration specified by
close_trade_afterThis allows the funding payment to be credited before the hedge is exited
Impact of Closing Later
Pros:
- Ensures funding fees are fully settled
- Avoids missing partial funding payments due to early closure
Cons:
- Increases market exposure, even though the position is hedged
- Minor risk from price swings and liquidity changes
🔹 Practical Example
| Parameter | Example | Explanation |
|---|---|---|
close_trade_after |
30 | Keep positions open 30 minutes after funding snapshot |
| Funding snapshot | 12:00 PM | Positions remain open until 12:30 PM |
| Result | Funding fee is collected; positions are then closed safely |
- Adjust based on exchange funding timing, symbol liquidity, and risk tolerance
🔹 Key Takeaways
- Purpose: Ensures the bot collects funding fees properly before exiting positions
- Longer
close_trade_after: Secures funding, slightly increases exposure time - Shorter
close_trade_after: Reduces market exposure, may risk incomplete funding settlement - Balance this setting with
open_trade_beforefor optimal timing and risk management