Skip to content

Commit 4d3a310

Browse files
committed
docs: update specification files for analysis-and-enhancement feature
1 parent 6bc896e commit 4d3a310

11 files changed

Lines changed: 1263 additions & 54 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Research: Configuration System Enhancement for MetaExpert
2+
3+
## Current State Analysis
4+
5+
### Environment Variable System
6+
The current `.env.example` file provides a basic structure but lacks comprehensive coverage of all supported exchanges and template parameters. It only includes configuration for Binance and Bybit, while the template supports Binance, Bybit, OKX, Bitget, and Kucoin.
7+
8+
### Configuration Module
9+
The `config.py` file has similar limitations:
10+
- Only supports Binance and Bybit exchanges
11+
- Missing many configuration options available in `template.py`
12+
- Lacks organization of parameters into logical groups that match the template structure
13+
14+
### Command-Line Interface
15+
The `_argument.py` file provides command-line arguments but:
16+
- Doesn't expose all template parameters
17+
- Lacks clear grouping of related parameters
18+
- Has inconsistent naming compared to template parameters
19+
20+
### Template Creator
21+
The `template_creator.py` file is functional but:
22+
- Doesn't leverage the full configuration system
23+
- Lacks flexibility for customizing templates during creation
24+
25+
## Identified Issues
26+
27+
1. **Incomplete Exchange Support**: The configuration system only supports 2 of the 5 exchanges available in the template.
28+
29+
2. **Configuration Mismatch**: Many parameters available in `template.py` are not configurable through environment variables or command-line arguments.
30+
31+
3. **Poor Organization**: Configuration options are not logically grouped to match the template structure.
32+
33+
4. **Limited Customization**: Users cannot easily customize all aspects of their trading strategy through configuration.
34+
35+
## Proposed Solution
36+
37+
### Enhanced Environment Variable System
38+
Create a comprehensive `.env` file structure that includes:
39+
- Configuration for all supported exchanges (Binance, Bybit, OKX, Bitget, Kucoin)
40+
- All parameters available in `template.py`
41+
- Logical grouping of related parameters
42+
- Clear documentation for each parameter
43+
44+
### Enhanced Configuration Module
45+
Update `config.py` to:
46+
- Support all 5 exchanges
47+
- Include all template parameters
48+
- Organize parameters into logical groups
49+
- Provide sensible defaults for all parameters
50+
51+
### Enhanced Command-Line Interface
52+
Update `_argument.py` to:
53+
- Expose all template parameters as command-line arguments
54+
- Group related parameters with clear section headers
55+
- Use consistent naming with template parameters
56+
- Provide comprehensive help text
57+
58+
### Enhanced Template Creator
59+
Update `template_creator.py` to:
60+
- Leverage the full configuration system
61+
- Allow customization of templates during creation
62+
- Provide better feedback to users
63+
64+
## Benefits
65+
66+
1. **Complete Exchange Support**: All exchanges supported by the template will be configurable.
67+
68+
2. **Consistent Configuration**: Environment variables, command-line arguments, and template parameters will be aligned.
69+
70+
3. **Improved User Experience**: Users can configure all template parameters through their preferred method.
71+
72+
4. **Better Organization**: Configuration options will be logically grouped and clearly documented.
73+
74+
5. **Enhanced Flexibility**: Users can easily customize any aspect of their trading strategy.
75+
76+
6. **Constitutional Compliance**: The enhanced system will follow the Library-First Development and CLI Interface Standard principles.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Configuration Management Contract
2+
3+
## Endpoint
4+
GET /config/parameters
5+
6+
## Description
7+
Returns a list of all configurable parameters with their descriptions, default values, and configuration sources.
8+
9+
## Request
10+
```json
11+
{
12+
"category": "string", // Optional: Filter by parameter category
13+
"exchange": "string" // Optional: Filter by exchange-specific parameters
14+
}
15+
```
16+
17+
## Response
18+
```json
19+
{
20+
"status": "success|error",
21+
"parameters": [
22+
{
23+
"name": "string",
24+
"description": "string",
25+
"default_value": "string",
26+
"category": "string",
27+
"env_var_name": "string",
28+
"cli_arg_name": "string",
29+
"required": "boolean"
30+
}
31+
]
32+
}
33+
```
34+
35+
## Error Responses
36+
- 400: Invalid request parameters
37+
- 500: Internal server error
38+
39+
---
40+
41+
## Endpoint
42+
POST /config/validate
43+
44+
## Description
45+
Validates a set of configuration parameters.
46+
47+
## Request
48+
```json
49+
{
50+
"parameters": {
51+
"parameter_name": "parameter_value"
52+
}
53+
}
54+
```
55+
56+
## Response
57+
```json
58+
{
59+
"status": "success|error",
60+
"valid": "boolean",
61+
"errors": [
62+
{
63+
"parameter": "string",
64+
"error": "string"
65+
}
66+
]
67+
}
68+
```
69+
70+
## Error Responses
71+
- 400: Invalid request parameters
72+
- 500: Internal server error

.specify/specs/feature/analysis-and-enhancement/contracts/template-create.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
POST /template/create
55

66
## Description
7-
Creates a new trading strategy template file for a user.
7+
Creates a new trading strategy template file for a user with optional configuration parameters.
88

99
## Request
1010
```json
1111
{
1212
"strategy_name": "string",
13-
"output_directory": "string"
13+
"output_directory": "string",
14+
"exchange": "string", // Optional: binance, bybit, okx, bitget, kucoin
15+
"symbol": "string", // Optional: Trading pair (e.g., BTCUSDT)
16+
"timeframe": "string", // Optional: Timeframe (e.g., 1h, 5m)
17+
"market_type": "string", // Optional: spot, futures, options
18+
"contract_type": "string", // Optional: linear, inverse
19+
"leverage": "integer", // Optional: Leverage value
20+
"strategy_id": "integer", // Optional: Strategy ID
21+
"strategy_name": "string", // Optional: Strategy name
22+
"comment": "string" // Optional: Order comment
1423
}
1524
```
1625

@@ -25,4 +34,12 @@ Creates a new trading strategy template file for a user.
2534

2635
## Error Responses
2736
- 400: Invalid request parameters
28-
- 500: Internal server error
37+
- 500: Internal server error
38+
39+
## Additional Endpoints
40+
41+
### GET /template/exchanges
42+
Returns a list of supported exchanges.
43+
44+
### GET /template/parameters
45+
Returns a list of configurable template parameters with descriptions and default values.

.specify/specs/feature/analysis-and-enhancement/data-model.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Data Model: MetaExpert Library Template Enhancement
1+
# Updated Data Model: MetaExpert Library Template Enhancement
22

33
## Entities
44

@@ -23,6 +23,8 @@ Represents a configuration parameter in the template.
2323
- default_value: string - Default value of the parameter
2424
- category: string - Category/group the parameter belongs to
2525
- required: boolean - Whether the parameter is required
26+
- env_var_name: string - Corresponding environment variable name
27+
- cli_arg_name: string - Corresponding command-line argument name
2628

2729
**Relationships:**
2830
- Belongs to TemplateFile (one-to-many)
@@ -46,6 +48,31 @@ Represents a supported exchange.
4648
- name: string - Name of the exchange
4749
- supported_features: list - List of features supported by the exchange
4850
- api_documentation_url: string - URL to the exchange's API documentation
51+
- requires_passphrase: boolean - Whether the exchange requires an API passphrase
4952

5053
**Relationships:**
51-
- Referenced in TemplateFile configuration
54+
- Referenced in TemplateFile configuration
55+
56+
### ConfigurationSource
57+
Represents a source of configuration values.
58+
59+
**Attributes:**
60+
- type: string - Type of configuration source (environment, cli, file, default)
61+
- priority: int - Priority order for applying configuration values
62+
- description: string - Description of the configuration source
63+
64+
**Relationships:**
65+
- Used by ConfigurationParameter (many-to-many)
66+
67+
### StrategyParameter
68+
Represents a strategy-specific parameter in the template.
69+
70+
**Attributes:**
71+
- name: string - Name of the parameter
72+
- description: string - Description of what the parameter does
73+
- default_value: string - Default value of the parameter
74+
- category: string - Category/group the parameter belongs to
75+
- required: boolean - Whether the parameter is required
76+
77+
**Relationships:**
78+
- Belongs to TemplateFile (one-to-many)

0 commit comments

Comments
 (0)