mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-01 17:17:24 -04:00
feat: add resume mode and idempotent behavior to /simulate/trigger endpoint
BREAKING CHANGE: end_date is now required and cannot be null/empty
New Features:
- Resume mode: Set start_date to null to continue from last completed date per model
- Idempotent by default: Skip already-completed dates with replace_existing=false
- Per-model independence: Each model resumes from its own last completed date
- Cold start handling: If no data exists in resume mode, runs only end_date as single day
API Changes:
- start_date: Now optional (null enables resume mode)
- end_date: Now REQUIRED (cannot be null or empty string)
- replace_existing: New optional field (default: false for idempotent behavior)
Implementation:
- Added JobManager.get_last_completed_date_for_model() method
- Added JobManager.get_completed_model_dates() method
- Updated create_job() to support model_day_filter for selective task creation
- Fixed bug with start_date=None in price data checks
Documentation:
- Updated API_REFERENCE.md with complete examples and behavior matrix
- Updated QUICK_START.md with resume mode examples
- Updated docs/user-guide/using-the-api.md
- Added CHANGELOG_NEW_API.md with migration guide
- Updated all integration tests for new schema
- Updated client library examples (Python, TypeScript)
Migration:
- Old: {"start_date": "2025-01-16"}
- New: {"start_date": "2025-01-16", "end_date": "2025-01-16"}
- Resume: {"start_date": null, "end_date": "2025-01-31"}
See CHANGELOG_NEW_API.md for complete details.
This commit is contained in:
@@ -108,6 +108,7 @@ curl -X POST http://localhost:8080/simulate/trigger \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"start_date": "2025-01-16",
|
||||
"end_date": "2025-01-16",
|
||||
"models": ["gpt-4"]
|
||||
}'
|
||||
```
|
||||
@@ -119,12 +120,14 @@ curl -X POST http://localhost:8080/simulate/trigger \
|
||||
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"status": "pending",
|
||||
"total_model_days": 1,
|
||||
"message": "Simulation job created with 1 trading dates"
|
||||
"message": "Simulation job created with 1 model-day tasks"
|
||||
}
|
||||
```
|
||||
|
||||
**Save the `job_id`** - you'll need it to check status.
|
||||
|
||||
**Note:** Both `start_date` and `end_date` are required. For a single day, set them to the same value. To simulate a range, use different dates (e.g., `"start_date": "2025-01-16", "end_date": "2025-01-20"`).
|
||||
|
||||
---
|
||||
|
||||
## Step 6: Monitor Progress
|
||||
@@ -234,12 +237,32 @@ curl -X POST http://localhost:8080/simulate/trigger \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"start_date": "2025-01-16",
|
||||
"end_date": "2025-01-16",
|
||||
"models": ["gpt-4", "claude-3.7-sonnet"]
|
||||
}'
|
||||
```
|
||||
|
||||
**Note:** Models must be defined and enabled in `configs/default_config.json`.
|
||||
|
||||
### Resume from Last Completed Date
|
||||
|
||||
Continue simulations from where you left off (useful for daily automation):
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8080/simulate/trigger \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"start_date": null,
|
||||
"end_date": "2025-01-31",
|
||||
"models": ["gpt-4"]
|
||||
}'
|
||||
```
|
||||
|
||||
This will:
|
||||
- Check the last completed date for each model
|
||||
- Resume from the next day after the last completed date
|
||||
- If no previous data exists, run only the `end_date` as a single day
|
||||
|
||||
### Query Specific Results
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user