Qubx 0.1.88__cp311-cp311-manylinux_2_35_x86_64.whl → 0.1.89__cp311-cp311-manylinux_2_35_x86_64.whl

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.

qubx/ta/indicators.pyx CHANGED
@@ -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
 
@@ -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
@@ -6,11 +6,11 @@ qubx/core/basics.py,sha256=2u7WV5KX-RbTmzoKfi1yT4HNLDPfQcFMCUZ1pVsM_VE,14777
6
6
  qubx/core/helpers.py,sha256=gPE78dO718NBY0-JbfqNGCzIvr4BVatFntNIy2RUrEY,11559
7
7
  qubx/core/loggers.py,sha256=HpgavBZegoDv9ssihtqX0pitXKULVAPHUpoE_volJw0,11910
8
8
  qubx/core/lookups.py,sha256=4aEC7b2AyEXFqHHGDenex3Z1FZGrpDSb8IwzBZrSqIA,13688
9
- qubx/core/series.cpython-311-x86_64-linux-gnu.so,sha256=A3tw0ZuTSxk-kthr1yU9tGGRNwPjTH0m6sdUG5Difn0,736872
9
+ qubx/core/series.cpython-311-x86_64-linux-gnu.so,sha256=9hfeOQKB00XkGhba8L9fUDJRuqW32c0qCwyL3SHLiek,736872
10
10
  qubx/core/series.pxd,sha256=YC1w11gzn1eq6kBrLTufLlECsKd0YWLu70k_CuAMksg,2916
11
11
  qubx/core/series.pyx,sha256=zO1M9MtVgzQyy0oVhO9HOWaIqT2HwcqhR-MdxpEk-HI,29401
12
12
  qubx/core/strategy.py,sha256=Fs4fFyHaEGYuz7mBeQHBWFu3Ipg0yFzcxXhskgsPxJE,30330
13
- qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=O0DhQLUfGRcxtf8HDWPNgNGNvYuo8RCKw6liyM46mtA,74248
13
+ qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=6tnz1_q2NFGTuGrF3liSn9Mbm5OliSLiXUol57klVmE,74248
14
14
  qubx/core/utils.pyx,sha256=csSIwI_lwvCd8CTbsp9Q0XiRCtGAHEuF62afHOJzCGQ,1382
15
15
  qubx/data/readers.py,sha256=YQvVbjyHsWDL54bVOzm78sTAF1ORYGT1eW4tVpnv5uA,32481
16
16
  qubx/impl/ccxt_connector.py,sha256=NqF-tgxfTATnmVqKUonNXCAzECrDU8YrgqM3Nq06fw8,9150
@@ -23,8 +23,8 @@ qubx/pandaz/__init__.py,sha256=Iw5uzicYGSC3FEKZ-W1O5-7cXq_P0kH11-EcXV0zZhs,175
23
23
  qubx/pandaz/ta.py,sha256=O17JPtee8MLyBoS8zdm32qsQcBJNtAPUpgFj3SMUKsA,85060
24
24
  qubx/pandaz/utils.py,sha256=FyLKQy8spkqxhBij_nPFC_ZzI_L3-IgB9O53MqWKmq0,19109
25
25
  qubx/ta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so,sha256=HRaZHGW_uRMzu9cuqS1CPgLbL4_uDHrxF82Zg9GcLsc,518504
27
- qubx/ta/indicators.pyx,sha256=iKSUz5sW6qd6yaYwmHfMyp3i98GH8mwgTHpk10PGJHM,22314
26
+ qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so,sha256=t9fwBx0C0wYRI5-jWSahKTK1NwAYTYVvXX3LZo7NVFE,539144
27
+ qubx/ta/indicators.pyx,sha256=qUjRrwHgf2GkzU6U2hRA0Lfzk1RMt4gbmfFUDfgq77o,23473
28
28
  qubx/trackers/__init__.py,sha256=1y_yvIy0OQwBqfhAW_EY33NxFzFSWvI0qNAPU6zchYc,60
29
29
  qubx/trackers/rebalancers.py,sha256=QCzANCooZBi2VMCBjjCPMq_Dt1h1zrBelATnfmVve74,5522
30
30
  qubx/utils/__init__.py,sha256=XJFje4jP69pnPTp7fpTUmqwXz9PKzGYtJf8-kBofum0,273
@@ -34,6 +34,6 @@ qubx/utils/marketdata/binance.py,sha256=36dl4rxOAGTeY3uoONmiPanj8BkP0oBdDiH-URJJ
34
34
  qubx/utils/misc.py,sha256=hmG_c7nneLiJ-xgyeOQucckPRemNAQ0Hsr7OqDdhbhU,9868
35
35
  qubx/utils/runner.py,sha256=OY7SoRfxHwzn0rKTGB_lbg5zNASEL_49hQXWqs-LiMk,9306
36
36
  qubx/utils/time.py,sha256=_DjCdQditzZwMy_8rvPdWyw5tjw__2p24LMPgXdZ8i0,4911
37
- qubx-0.1.88.dist-info/METADATA,sha256=2ON3hgyJnqhDBQ5u_5ylo1RVvS83PZq4kvoxPIqwKbY,2524
38
- qubx-0.1.88.dist-info/WHEEL,sha256=MLOa6LysROdjgj4FVxsHitAnIh8Be2D_c9ZSBHKrz2M,110
39
- qubx-0.1.88.dist-info/RECORD,,
37
+ qubx-0.1.89.dist-info/METADATA,sha256=RfvLeMFZbxe5C_gXJ6DI24VW08zEl0sycvAkvqM1tIY,2524
38
+ qubx-0.1.89.dist-info/WHEEL,sha256=MLOa6LysROdjgj4FVxsHitAnIh8Be2D_c9ZSBHKrz2M,110
39
+ qubx-0.1.89.dist-info/RECORD,,
File without changes