quantex 0.3.3__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: quantex
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: A simple quant strategy creation and backtesting package.
5
5
  License: MIT
6
6
  Author: Daniel Green
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "quantex"
3
- version = "0.3.3"
3
+ version = "0.3.4"
4
4
  description = "A simple quant strategy creation and backtesting package."
5
5
  authors = [
6
6
  {name = "Daniel Green",email = "dangreen07@outlook.com"}
@@ -1344,6 +1344,7 @@ class SimpleBacktester():
1344
1344
  test_ratio: float = 0.15,
1345
1345
  selection_criterion: str = "validate",
1346
1346
  progress_bar: bool = True,
1347
+ integer_params: set[str] | None = None,
1347
1348
  ) -> OptimizationResult:
1348
1349
  """
1349
1350
  Optimize strategy parameters using gradient descent.
@@ -1382,6 +1383,10 @@ class SimpleBacktester():
1382
1383
  Defaults to "validate".
1383
1384
  progress_bar (bool, optional): Whether to show progress bar.
1384
1385
  Defaults to True.
1386
+ integer_params (set[str] | None, optional): Set of parameter names
1387
+ that should be treated as integers. These parameters will be
1388
+ rounded to the nearest integer after each gradient update.
1389
+ Defaults to None (all parameters are continuous).
1385
1390
 
1386
1391
  Returns:
1387
1392
  OptimizationResult: Object containing:
@@ -1395,19 +1400,22 @@ class SimpleBacktester():
1395
1400
  - all_results: DataFrame with iteration history
1396
1401
 
1397
1402
  Example:
1398
- >>> bt = SimpleBacktester(strategy)
1403
+ >>> # Optimize with integer parameters
1399
1404
  >>> result = bt.optimize_gradient_descent(
1400
1405
  ... param_init={'fast_period': 10.0, 'slow_period': 30.0},
1401
1406
  ... param_bounds={
1402
1407
  ... 'fast_period': (2.0, 50.0),
1403
1408
  ... 'slow_period': (10.0, 100.0)
1404
1409
  ... },
1410
+ ... integer_params={'fast_period', 'slow_period'},
1405
1411
  ... learning_rate=0.05,
1406
1412
  ... max_iterations=50
1407
1413
  ... )
1408
1414
  >>> print(f"Optimized params: {result.best_params}")
1409
1415
  >>> print(f"Final validation Sharpe: {result.validate_metrics['sharpe']}")
1410
1416
  """
1417
+ if integer_params is None:
1418
+ integer_params = set()
1411
1419
  # Validate selection criterion
1412
1420
  valid_criteria = {"train", "validate", "test"}
1413
1421
  if selection_criterion not in valid_criteria:
@@ -1545,6 +1553,10 @@ class SimpleBacktester():
1545
1553
  # Apply bounds
1546
1554
  min_val, max_val = param_bounds[key]
1547
1555
  current_params[key] = np.clip(current_params[key], min_val, max_val)
1556
+
1557
+ # Round integer parameters to nearest integer
1558
+ if key in integer_params:
1559
+ current_params[key] = round(current_params[key])
1548
1560
 
1549
1561
  # Evaluate on all splits
1550
1562
  train_score = evaluate_params(current_params, DataSplitMode.TRAIN)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes