Qubx 0.1.89__cp311-cp311-manylinux_2_35_x86_64.whl → 0.1.90__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/core/series.pxd CHANGED
@@ -11,11 +11,16 @@ cdef class Indexed:
11
11
  cdef unsigned short _is_empty
12
12
 
13
13
 
14
+ cdef class Locator:
15
+ cdef TimeSeries _series
16
+
17
+
14
18
  cdef class TimeSeries:
15
19
  cdef public long long timeframe
16
20
  cdef public Indexed times
17
21
  cdef public Indexed values
18
22
  cdef public float max_series_length
23
+ cdef public Locator loc
19
24
  cdef unsigned short _is_new_item
20
25
  cdef public str name
21
26
  cdef dict indicators # it's used for indicators caching
qubx/core/series.pyx CHANGED
@@ -120,6 +120,54 @@ cdef class Indexed:
120
120
  global _plot_func
121
121
 
122
122
 
123
+ cdef class Locator:
124
+ """
125
+ Locator service class for TimeSeries
126
+ """
127
+
128
+ def __init__(self, TimeSeries series):
129
+ self._series = series
130
+
131
+ def __getitem__(self, idx):
132
+ cdef int _nlen = len(self._series)
133
+
134
+ if isinstance(idx, slice):
135
+ start = 0 if idx.start is None else idx.start
136
+ if isinstance(start, str):
137
+ start = max(self._get_time_index(start), 0)
138
+
139
+ if idx.stop is None:
140
+ stop = (_nlen - 1)
141
+ else:
142
+ if isinstance(idx.stop, str):
143
+ stop = self._get_time_index(idx.stop)
144
+ else:
145
+ stop = idx.stop - 1
146
+
147
+ new_ts = self._series._clone_empty(self._series.name, self._series.timeframe, self._series.max_series_length)
148
+ for i in range(start, min(stop + 1, _nlen)):
149
+ new_ts._add_new_item(self._series.times.values[i], self._series.values.values[i])
150
+ return new_ts
151
+
152
+ elif isinstance(idx, str):
153
+ # - handle single timestamp string
154
+ return self.find(idx)
155
+
156
+ return self._series.values[idx]
157
+
158
+ def _get_time_index(self, str t) -> int:
159
+ cdef long long _t = np.datetime64(t, 'ns').item()
160
+ cdef int idx = int(np.searchsorted(self._series.times.values, _t, side='right'))
161
+ idx = min(idx, len(self._series.values))
162
+ if idx == 0:
163
+ raise ValueError(f"Time {t} not found in {self._series.name}!")
164
+ return idx - 1
165
+
166
+ def find(self, str t):
167
+ ix = self._get_time_index(t)
168
+ return np.datetime64(self._series.times.values[ix], 'ns'), self._series.values.values[ix]
169
+
170
+
123
171
  cdef class TimeSeries:
124
172
 
125
173
  def __init__(
@@ -133,6 +181,8 @@ cdef class TimeSeries:
133
181
  self.values = Indexed(max_series_length)
134
182
  self.indicators = dict()
135
183
  self.calculation_order = []
184
+ # - locator service
185
+ self.loc = Locator(self)
136
186
 
137
187
  # - processing every update
138
188
  self._process_every_update = process_every_update
@@ -142,13 +192,17 @@ cdef class TimeSeries:
142
192
  def __len__(self) -> int:
143
193
  return len(self.times)
144
194
 
145
- def loc(self, str t):
146
- _t = np.datetime64(t, 'ns').item()
147
- ix = int(np.searchsorted(self.times.values, _t, side='right'))
148
- ix = min(ix, len(self.values))
149
- if ix == 0:
150
- raise ValueError(f"Time {t} not found in {self.name} !")
151
- return np.datetime64(self.times.values[ix - 1], 'ns'), self.values.values[ix - 1]
195
+ def _clone_empty(self, str name, long long timeframe, float max_series_length):
196
+ """
197
+ Make empty TimeSeries instance (no data and indicators)
198
+ """
199
+ return TimeSeries(name, timeframe, max_series_length)
200
+
201
+ def clone(self):
202
+ """
203
+ Clone TimeSeries instance with data without indcators attached
204
+ """
205
+ return self.loc[:]
152
206
 
153
207
  def _on_attach_indicator(self, indicator: Indicator, indicator_input: TimeSeries):
154
208
  self.calculation_order.append((
@@ -322,7 +376,7 @@ cdef class Indicator(TimeSeries):
322
376
  self.name = name
323
377
 
324
378
  # - we need to make a empty copy and fill it
325
- self.series = self._instantiate_base_series(series.name, series.timeframe, series.max_series_length)
379
+ self.series = self._clone_empty(series.name, series.timeframe, series.max_series_length)
326
380
  self.parent = series
327
381
 
328
382
  # - notify the parent series that indicator has been attached
@@ -331,9 +385,6 @@ cdef class Indicator(TimeSeries):
331
385
  # - recalculate indicator on data as if it would being streamed
332
386
  self._initial_data_recalculate(series)
333
387
 
334
- def _instantiate_base_series(self, str name, long long timeframe, float max_series_length):
335
- return TimeSeries(name, timeframe, max_series_length)
336
-
337
388
  def _on_attach_indicator(self, indicator: Indicator, indicator_input: TimeSeries):
338
389
  self.parent._on_attach_indicator(indicator, indicator_input)
339
390
 
@@ -365,7 +416,7 @@ cdef class IndicatorOHLC(Indicator):
365
416
  """
366
417
  Extension of indicator class to be used for OHLCV series
367
418
  """
368
- def _instantiate_base_series(self, str name, long long timeframe, float max_series_length):
419
+ def _clone_empty(self, str name, long long timeframe, float max_series_length):
369
420
  return OHLCV(name, timeframe, max_series_length)
370
421
 
371
422
  def calculate(self, long long time, Bar value, short new_item_started) -> object:
@@ -724,6 +775,9 @@ cdef class OHLCV(TimeSeries):
724
775
 
725
776
  return self
726
777
 
778
+ def _clone_empty(self, str name, long long timeframe, float max_series_length):
779
+ return OHLCV(name, timeframe, max_series_length)
780
+
727
781
  def _add_new_item(self, long long time, Bar value):
728
782
  self.times.add(time)
729
783
  self.values.add(value)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Qubx
3
- Version: 0.1.89
3
+ Version: 0.1.90
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=9hfeOQKB00XkGhba8L9fUDJRuqW32c0qCwyL3SHLiek,736872
10
- qubx/core/series.pxd,sha256=YC1w11gzn1eq6kBrLTufLlECsKd0YWLu70k_CuAMksg,2916
11
- qubx/core/series.pyx,sha256=zO1M9MtVgzQyy0oVhO9HOWaIqT2HwcqhR-MdxpEk-HI,29401
9
+ qubx/core/series.cpython-311-x86_64-linux-gnu.so,sha256=WE-5-tz9G9j6TuvZ24ewDCm-TyKb00IpGSP1GUd6tUs,762408
10
+ qubx/core/series.pxd,sha256=1KJGzun_R5GDDOynPbZER7Xg45a0JUM_S_lZ-9FFFJg,2994
11
+ qubx/core/series.pyx,sha256=fKBDHWyJIdgWXrKxef8vm98phFgKzzyfUI0_Adla4NU,31118
12
12
  qubx/core/strategy.py,sha256=Fs4fFyHaEGYuz7mBeQHBWFu3Ipg0yFzcxXhskgsPxJE,30330
13
- qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=6tnz1_q2NFGTuGrF3liSn9Mbm5OliSLiXUol57klVmE,74248
13
+ qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=C3fOY78zniScQYlIFQdE6wb0w9UbNnsZ-OZ4SCWp9cM,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,7 +23,7 @@ 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=t9fwBx0C0wYRI5-jWSahKTK1NwAYTYVvXX3LZo7NVFE,539144
26
+ qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so,sha256=z0mAq4lgmbsHbPigDaPBes4dZec7VZl3lkti9E_bOEI,543240
27
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
@@ -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.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,,
37
+ qubx-0.1.90.dist-info/METADATA,sha256=ZKKDtnzo0T4qMipZMAT2ZtcKbW4PUG6XyVBgoBOf3D4,2524
38
+ qubx-0.1.90.dist-info/WHEEL,sha256=MLOa6LysROdjgj4FVxsHitAnIh8Be2D_c9ZSBHKrz2M,110
39
+ qubx-0.1.90.dist-info/RECORD,,
File without changes