quantex 0.3.1__tar.gz → 0.3.2__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.1
3
+ Version: 0.3.2
4
4
  Summary: A simple quant strategy creation and backtesting package.
5
5
  License: MIT
6
6
  Author: Daniel Green
@@ -34,7 +34,7 @@ The project is intentionally small. It does not try to be a full research platfo
34
34
 
35
35
  ## Installation
36
36
 
37
- Quantex requires Python 3.10 or newer and is published as [`quantex`](pyproject.toml).
37
+ Quantex requires Python 3.11 or newer and is published as [`quantex`](pyproject.toml).
38
38
 
39
39
  ```bash
40
40
  pip install quantex
@@ -14,7 +14,7 @@ The project is intentionally small. It does not try to be a full research platfo
14
14
 
15
15
  ## Installation
16
16
 
17
- Quantex requires Python 3.10 or newer and is published as [`quantex`](pyproject.toml).
17
+ Quantex requires Python 3.11 or newer and is published as [`quantex`](pyproject.toml).
18
18
 
19
19
  ```bash
20
20
  pip install quantex
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "quantex"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "A simple quant strategy creation and backtesting package."
5
5
  authors = [
6
6
  {name = "Daniel Green",email = "dangreen07@outlook.com"}
@@ -224,10 +224,11 @@ def _risk_tolerance_passes(report: "BacktestReport", risk_tolerance: dict[str, f
224
224
  if not risk_tolerance:
225
225
  return True
226
226
 
227
+ metrics = _compute_backtest_metrics(report)
227
228
  for metric, max_value in risk_tolerance.items():
228
229
  if max_value is None:
229
230
  continue
230
- current_value = _extract_metric_value(report, metric)
231
+ current_value = metrics.get(metric, _extract_metric_value(report, metric))
231
232
  if current_value is None:
232
233
  raise AttributeError(f"BacktestReport does not expose metric '{metric}'")
233
234
  if not np.isfinite(float(current_value)):
@@ -319,6 +319,22 @@ def mfi(high: ArrayLike, low: ArrayLike, close: ArrayLike, volume: ArrayLike, pe
319
319
  return result
320
320
 
321
321
 
322
+ def vwap(high: ArrayLike, low: ArrayLike, close: ArrayLike, volume: ArrayLike) -> np.ndarray:
323
+ high_array = _as_float_array(high)
324
+ low_array = _as_float_array(low)
325
+ close_array = _as_float_array(close)
326
+ volume_array = _as_float_array(volume)
327
+ _validate_same_length(high_array, low_array, close_array, volume_array)
328
+ typical_price = (high_array + low_array + close_array) / 3.0
329
+ price_volume = typical_price * volume_array
330
+ cumulative_price_volume = np.cumsum(price_volume)
331
+ cumulative_volume = np.cumsum(volume_array)
332
+ with np.errstate(divide="ignore", invalid="ignore"):
333
+ result = cumulative_price_volume / cumulative_volume
334
+ result = np.where(cumulative_volume == 0.0, np.nan, result)
335
+ return result
336
+
337
+
322
338
  def adx(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: int = 14) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
323
339
  high_array = _as_float_array(high)
324
340
  low_array = _as_float_array(low)
@@ -589,6 +605,7 @@ class IndicatorCatalog:
589
605
  self.williams_r = williams_r
590
606
  self.obv = obv
591
607
  self.mfi = mfi
608
+ self.vwap = vwap
592
609
  self.adx = adx
593
610
  self.ichimoku_cloud = ichimoku_cloud
594
611
  self.keltner_channels = keltner_channels
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes