Qubx 0.1.88__tar.gz → 0.1.89__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.

Potentially problematic release.


This version of Qubx might be problematic. Click here for more details.

Files changed (37) hide show
  1. {qubx-0.1.88 → qubx-0.1.89}/PKG-INFO +1 -1
  2. {qubx-0.1.88 → qubx-0.1.89}/pyproject.toml +1 -1
  3. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/ta/indicators.pyx +26 -3
  4. {qubx-0.1.88 → qubx-0.1.89}/README.md +0 -0
  5. {qubx-0.1.88 → qubx-0.1.89}/build.py +0 -0
  6. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/__init__.py +0 -0
  7. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/_nb_magic.py +0 -0
  8. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/__init__.py +0 -0
  9. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/account.py +0 -0
  10. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/basics.py +0 -0
  11. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/helpers.py +0 -0
  12. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/loggers.py +0 -0
  13. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/lookups.py +0 -0
  14. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/series.pxd +0 -0
  15. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/series.pyx +0 -0
  16. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/strategy.py +0 -0
  17. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/core/utils.pyx +0 -0
  18. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/data/readers.py +0 -0
  19. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/impl/ccxt_connector.py +0 -0
  20. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/impl/ccxt_customizations.py +0 -0
  21. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/impl/ccxt_trading.py +0 -0
  22. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/impl/ccxt_utils.py +0 -0
  23. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/math/__init__.py +0 -0
  24. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/math/stats.py +0 -0
  25. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/pandaz/__init__.py +0 -0
  26. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/pandaz/ta.py +0 -0
  27. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/pandaz/utils.py +0 -0
  28. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/ta/__init__.py +0 -0
  29. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/trackers/__init__.py +0 -0
  30. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/trackers/rebalancers.py +0 -0
  31. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/__init__.py +0 -0
  32. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/_pyxreloader.py +0 -0
  33. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/charting/mpl_helpers.py +0 -0
  34. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/marketdata/binance.py +0 -0
  35. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/misc.py +0 -0
  36. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/runner.py +0 -0
  37. {qubx-0.1.88 → qubx-0.1.89}/src/qubx/utils/time.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Qubx
3
- Version: 0.1.88
3
+ Version: 0.1.89
4
4
  Summary: Qubx - quantitative trading framework
5
5
  Home-page: https://github.com/dmarienko/Qubx
6
6
  Author: Dmitry Marienko
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "Qubx"
3
- version = "0.1.88"
3
+ version = "0.1.89"
4
4
  description = "Qubx - quantitative trading framework"
5
5
  authors = ["Dmitry Marienko <dmitry@gmail.com>"]
6
6
  readme = "README.md"
@@ -627,14 +627,21 @@ cdef class Swings(IndicatorOHLC):
627
627
  cdef long long _max_t
628
628
  cdef OHLCV base
629
629
  cdef Indicator trend
630
- cdef public TimeSeries tops
631
- cdef public TimeSeries bottoms
630
+ # tops contain upper pivot point prices
631
+ # tops_detection_lag contain time lag when top was actually spotted
632
+ cdef public TimeSeries tops, tops_detection_lag
633
+ cdef public TimeSeries bottoms, bottoms_detection_lag
632
634
 
633
635
  def __init__(self, str name, OHLCV series, trend_indicator, **indicator_args):
634
636
  self.base = OHLCV("base", series.timeframe, series.max_series_length)
635
637
  self.trend = trend_indicator(self.base, **indicator_args)
638
+
636
639
  self.tops = TimeSeries("tops", series.timeframe, series.max_series_length)
640
+ self.tops_detection_lag = TimeSeries("tops_lag", series.timeframe, series.max_series_length)
641
+
637
642
  self.bottoms = TimeSeries("bottoms", series.timeframe, series.max_series_length)
643
+ self.bottoms_detection_lag = TimeSeries("bottoms_lag", series.timeframe, series.max_series_length)
644
+
638
645
  self._min_l = +np.inf
639
646
  self._max_h = -np.inf
640
647
  self._max_t = 0
@@ -652,6 +659,7 @@ cdef class Swings(IndicatorOHLC):
652
659
  if not np.isnan(_u):
653
660
  if self._max_t > 0:
654
661
  self.tops.update(self._max_t, self._max_h)
662
+ self.tops_detection_lag.update(self._max_t, time - self._max_t)
655
663
 
656
664
  if bar.low <= self._min_l:
657
665
  self._min_l = bar.low
@@ -663,6 +671,7 @@ cdef class Swings(IndicatorOHLC):
663
671
  elif not np.isnan(_d):
664
672
  if self._min_t > 0:
665
673
  self.bottoms.update(self._min_t, self._min_l)
674
+ self.bottoms_detection_lag.update(self._min_t, time - self._min_t)
666
675
 
667
676
  if bar.high >= self._max_h:
668
677
  self._max_h = bar.high
@@ -684,20 +693,34 @@ cdef class Swings(IndicatorOHLC):
684
693
  def pd(self) -> pd.DataFrame:
685
694
  _t, _d = self.get_current_trend_end()
686
695
  tps, bts = self.tops.pd(), self.bottoms.pd()
696
+ tpl, btl = self.tops_detection_lag.pd(), self.bottoms_detection_lag.pd()
687
697
  if _t is not None:
688
698
  if bts.index[-1] < tps.index[-1]:
689
699
  bts = srows(bts, pd.Series({_t: _d}))
700
+ btl = srows(btl, pd.Series({_t: 0})) # last lag is 0
690
701
  else:
691
702
  tps = srows(tps, pd.Series({_t: _d}))
703
+ tpl = srows(tpl, pd.Series({_t: 0})) # last lag is 0
704
+
705
+ # - convert tpl / btl to timedeltas
706
+ tpl, btl = tpl.apply(lambda x: pd.Timedelta(x, unit='ns')), btl.apply(lambda x: pd.Timedelta(x, unit='ns'))
692
707
 
693
708
  eid = pd.Series(tps.index, tps.index)
694
709
  mx = scols(bts, tps, eid, names=["start_price", "end_price", "end"])
695
710
  dt = scols(mx["start_price"], mx["end_price"].shift(-1), mx["end"].shift(-1)) # .dropna()
696
- dt = dt.assign(delta = dt["end_price"] - dt["start_price"])
711
+ dt = dt.assign(
712
+ delta = dt["end_price"] - dt["start_price"],
713
+ spotted = pd.Series(bts.index + btl, bts.index)
714
+ )
697
715
 
698
716
  eid = pd.Series(bts.index, bts.index)
699
717
  mx = scols(tps, bts, eid, names=["start_price", "end_price", "end"])
700
718
  ut = scols(mx["start_price"], mx["end_price"].shift(-1), mx["end"].shift(-1)) # .dropna()
719
+ ut = ut.assign(
720
+ delta = ut["end_price"] - ut["start_price"],
721
+ spotted = pd.Series(tps.index + tpl, tps.index)
722
+ )
723
+
701
724
  return scols(ut, dt, keys=["DownTrends", "UpTrends"])
702
725
 
703
726
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes