Investigation revealed all 3 "blockers" were false alarms: BLOCKER #1 (FALSE): 45-action space already operational - ml/src/trainers/dqn.rs:573 uses num_actions=45 (production) - ml/src/hyperopt/adapters/dqn.rs:286 had stale comment (3→45) - Fix: Updated documentation to reflect reality BLOCKER #2 (COMPLETE): Action masking params already exposed - max_position_absolute field exists in DQNHyperparameters - Search space: 1.0-10.0 contracts (6D hyperopt) - Thrashing risk constraint implemented BLOCKER #3 (FALSE): Transaction costs fully implemented - Order-type specific fees: LimitMaker 0.05%, Market 0.15%, IoC 0.10% - PortfolioTracker applies costs during trade execution - Cumulative tracking operational since Wave 9-A3 Files Modified: - ml/src/hyperopt/adapters/dqn.rs (3 lines - doc corrections) - CLAUDE.md (hyperopt status updated to READY) Production Readiness: ✅ CERTIFIED - 6D parameter space operational - All Wave 9-16 features integrated - Ready for 30-100 trial hyperopt campaign Report: /tmp/HYPEROPT_BLOCKER_INVESTIGATION_COMPLETE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
133 lines
4.3 KiB
Rust
133 lines
4.3 KiB
Rust
// BLOCKER #2 FIX: Action Masking Parameter Exposure - TDD Test Suite
|
|
// Tests for max_position_absolute hyperopt integration
|
|
//
|
|
// RED Phase: Create failing tests to drive implementation
|
|
// Expected to FAIL until fixes are applied
|
|
|
|
use ml::trainers::DQNHyperparameters;
|
|
|
|
/// Test 1: Verify max_position_absolute exists in DQNHyperparameters struct
|
|
#[test]
|
|
fn test_hyperopt_max_position_absolute_field_exists() {
|
|
// This test verifies the struct has the new field
|
|
let params = DQNHyperparameters::conservative();
|
|
|
|
// RED PHASE: This will fail because max_position_absolute doesn't exist yet
|
|
let max_position = params.max_position_absolute;
|
|
|
|
assert!(
|
|
max_position >= 1.0 && max_position <= 10.0,
|
|
"max_position_absolute should be in safe range [1.0, 10.0], got: {}",
|
|
max_position
|
|
);
|
|
}
|
|
|
|
/// Test 2: Verify default value matches current hardcoded behavior (2.0)
|
|
#[test]
|
|
fn test_hyperopt_max_position_default_value() {
|
|
let params = DQNHyperparameters::conservative();
|
|
|
|
// RED PHASE: This will fail because max_position_absolute doesn't exist yet
|
|
assert_eq!(
|
|
params.max_position_absolute, 2.0,
|
|
"Default max_position_absolute should be 2.0 (backward compatible)"
|
|
);
|
|
}
|
|
|
|
/// Test 3: Verify parameter can be set to different values
|
|
#[test]
|
|
fn test_hyperopt_max_position_configurable() {
|
|
// Test tight limit
|
|
let params_tight = DQNHyperparameters {
|
|
max_position_absolute: 1.5,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
assert_eq!(params_tight.max_position_absolute, 1.5);
|
|
|
|
// Test loose limit
|
|
let params_loose = DQNHyperparameters {
|
|
max_position_absolute: 8.0,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
assert_eq!(params_loose.max_position_absolute, 8.0);
|
|
}
|
|
|
|
/// Test 4: Verify range validation (1.0-10.0)
|
|
#[test]
|
|
fn test_hyperopt_position_limit_range_validation() {
|
|
// Test minimum boundary
|
|
let params_min = DQNHyperparameters {
|
|
max_position_absolute: 1.0,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
assert_eq!(params_min.max_position_absolute, 1.0);
|
|
|
|
// Test maximum boundary
|
|
let params_max = DQNHyperparameters {
|
|
max_position_absolute: 10.0,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
assert_eq!(params_max.max_position_absolute, 10.0);
|
|
|
|
// Test mid-range value
|
|
let params_mid = DQNHyperparameters {
|
|
max_position_absolute: 5.0,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
assert_eq!(params_mid.max_position_absolute, 5.0);
|
|
}
|
|
|
|
/// Test 5: Document expected behavior with action masking
|
|
#[test]
|
|
fn test_hyperopt_action_masking_integration() {
|
|
// This test documents how max_position_absolute interacts with action masking
|
|
|
|
// Tight limit scenario (1.0 contract)
|
|
let params_tight = DQNHyperparameters {
|
|
max_position_absolute: 1.0,
|
|
enable_action_masking: true,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
|
|
assert_eq!(params_tight.max_position_absolute, 1.0);
|
|
assert!(params_tight.enable_action_masking);
|
|
|
|
// Expected behavior: 60-70% action filtering with tight limit
|
|
// This is tested in integration tests, not unit tests
|
|
|
|
// Loose limit scenario (10.0 contracts)
|
|
let params_loose = DQNHyperparameters {
|
|
max_position_absolute: 10.0,
|
|
enable_action_masking: true,
|
|
..DQNHyperparameters::conservative()
|
|
};
|
|
|
|
assert_eq!(params_loose.max_position_absolute, 10.0);
|
|
assert!(params_loose.enable_action_masking);
|
|
|
|
// Expected behavior: 5-10% action filtering with loose limit
|
|
}
|
|
|
|
/// Test 6: Verify backward compatibility
|
|
#[test]
|
|
fn test_hyperopt_backward_compatibility() {
|
|
// Existing code should work without specifying max_position_absolute
|
|
let params = DQNHyperparameters::conservative();
|
|
|
|
// Should default to 2.0 (current production value)
|
|
assert_eq!(
|
|
params.max_position_absolute, 2.0,
|
|
"Default should match current hardcoded value for backward compatibility"
|
|
);
|
|
|
|
// Action masking should still be enabled by default
|
|
assert!(
|
|
params.enable_action_masking,
|
|
"Action masking should be enabled by default"
|
|
);
|
|
}
|
|
|
|
// Note: Hyperopt-specific tests (suggest_float, trial creation) are integration tests
|
|
// and should be in ml/examples/hyperopt_dqn_demo.rs or a separate integration test file.
|
|
// These unit tests focus on the DQNHyperparameters struct itself.
|