update_optimization
Modify the name of an existing optimization in QuantConnect's trading platform to reflect changes or improvements in strategy analysis.
Instructions
Update the name of an optimization.
Args: optimization_id: ID of the optimization to update name: New name for the optimization
Returns: Dictionary containing update result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| optimization_id | Yes | ||
| name | Yes |
Implementation Reference
- The MCP tool handler function for 'update_optimization'. Decorated with @mcp.tool(), it handles updating the name of an optimization job by making an authenticated POST request to the QuantConnect API endpoint 'optimizations/update'.@mcp.tool() async def update_optimization( optimization_id: str, name: str ) -> Dict[str, Any]: """ Update the name of an optimization. Args: optimization_id: ID of the optimization to update name: New name for the optimization Returns: Dictionary containing update result """ auth = get_auth_instance() if auth is None: return { "status": "error", "error": "QuantConnect authentication not configured. Use configure_auth() first.", } try: # Prepare request data request_data = { "optimizationId": optimization_id, "name": name } # Make API request response = await auth.make_authenticated_request( endpoint="optimizations/update", method="POST", json=request_data ) # Parse response if response.status_code == 200: data = response.json() if data.get("success", False): return { "status": "success", "optimization_id": optimization_id, "new_name": name, "message": f"Successfully updated optimization {optimization_id} name to '{name}'", } else: # API returned success=false errors = data.get("errors", ["Unknown error"]) return { "status": "error", "error": "Optimization update failed", "details": errors, "optimization_id": optimization_id, } elif response.status_code == 401: return { "status": "error", "error": "Authentication failed. Check your credentials and ensure they haven't expired.", } else: return { "status": "error", "error": f"API request failed with status {response.status_code}", "response_text": ( response.text[:500] if hasattr(response, "text") else "No response text" ), } except Exception as e: return { "status": "error", "error": f"Failed to update optimization: {str(e)}", "optimization_id": optimization_id, }