Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Parameter Suggestion Endpoint with LibertAI Integration #4

Merged
merged 5 commits into from
Dec 27, 2024

Conversation

MHHukiewitz
Copy link

Overview

This PR introduces a new endpoint that allows users to get AI-powered suggestions for strategy parameters. The system can either suggest values for missing required parameters or provide optimized values for specific requested parameters.

Key Changes

New Endpoint

  • Added /strategies/suggest-parameters POST endpoint
  • Supports both automatic suggestion of missing parameters and specific parameter requests
  • Returns suggestions with explanations and a summary of the configuration

Models

  • Added new request/response models for parameter suggestions
  • Enhanced ParameterSuggestionRequest to support optional parameter selection
  • Added comparison flags to show differences from default and provided values

LibertAI Integration

  • Implemented AI-powered parameter analysis
  • Added system context for trading strategy expertise
  • Supports strategy-specific context initialization
  • Handles type conversion based on parameter definitions

Testing

Added comprehensive test suite covering:

  • Parameter suggestion generation
  • AI response parsing
  • Type conversion handling
  • Error cases
  • Specific parameter requests

@MHHukiewitz
Copy link
Author

Example of new endpoint

POST /api/v1/strategies/suggest-parameters

Example 1: Get Suggestions for Missing Required Parameters

{
    "strategy_id": "bollinger_v1",
    "parameters": {
        "bb_std": 2.0,
        "trading_pair": "ETH-USDT"
    }
}

Response

{
    "suggestions": [
        {
            "parameter_name": "bb_length",
            "suggested_value": 20,
            "reasoning": "A 20-period length is standard for Bollinger Bands and provides a good balance between responsiveness and noise filtering.",
            "differs_from_default": false,
            "differs_from_provided": true
        },
        {
            "parameter_name": "bb_long_threshold",
            "suggested_value": 0.2,
            "reasoning": "Setting the long threshold to 0.2 means entering positions when price is 20% below the middle band, which is a conservative entry point for mean reversion.",
            "differs_from_default": true,
            "differs_from_provided": true
        }
    ],
    "summary": "These parameters are configured for conservative mean reversion trading using Bollinger Bands, suitable for volatile crypto markets."
}

@MHHukiewitz MHHukiewitz force-pushed the feat/parameter-suggestion branch from cb6b664 to 77e1d46 Compare December 16, 2024 17:26
@MHHukiewitz
Copy link
Author

@manomage @teezzan This PR will change parts of the /strategies API, so we will have to rewire it in the frontend. I will gladly help you adjusting these data models.

@MHHukiewitz MHHukiewitz merged commit 8821982 into main Dec 27, 2024
@MHHukiewitz MHHukiewitz deleted the feat/parameter-suggestion branch December 27, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant