INNER CODE UNIT · Python

close_position

codedpro/mt5-trade-split-manager · server.py:277

async def close_position(ticket: int):
    return send_command_to_mt5({"action": "CLOSE_POSITION", "data": {"ticket": ticket}})


@app.get("/stats", dependencies=[Depends(require_key)])
async def get_stats():
    return send_command_to_mt5({"action": "GET_STATS"})


@app.post("/safe-shutdown", dependencies=[Depends(require_key)])
async def safe_shutdown():
    """Consolidate remaining TPs (TP2-TP5) to the TP2 level before going away."""
    return send_command_to_mt5({"action": "SAFE_SHUTDOWN"})


if __name__ == "__main__":
    print("🚀 Starting MT5 TCP Bridge Server...")
    print(f"   HTTP API: http://{HTTP_HOST}:{HTTP_PORT}  (auth: {'on' if API_KEY else 'off'})")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…