What does close_trade_after control?

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

  1. Post-Funding Position Management

  2. After the funding snapshot occurs, the bot keeps positions open for the duration specified by close_trade_after

  3. This allows the funding payment to be credited before the hedge is exited

  4. Impact of Closing Later

  5. Pros:

    • Ensures funding fees are fully settled
    • Avoids missing partial funding payments due to early closure
  6. 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_before for optimal timing and risk management

📎 Related Topics