Qubx 0.1.7__cp311-cp311-manylinux_2_35_x86_64.whl → 0.1.81__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.cpython-311-x86_64-linux-gnu.so +0 -0
- qubx/core/utils.cpython-311-x86_64-linux-gnu.so +0 -0
- qubx/data/readers.py +51 -15
- qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so +0 -0
- {qubx-0.1.7.dist-info → qubx-0.1.81.dist-info}/METADATA +1 -1
- {qubx-0.1.7.dist-info → qubx-0.1.81.dist-info}/RECORD +7 -7
- {qubx-0.1.7.dist-info → qubx-0.1.81.dist-info}/WHEEL +0 -0
|
Binary file
|
|
Binary file
|
qubx/data/readers.py
CHANGED
|
@@ -507,31 +507,33 @@ class QuestDBConnector(DataReader):
|
|
|
507
507
|
"""
|
|
508
508
|
Very first version of QuestDB connector
|
|
509
509
|
|
|
510
|
-
|
|
511
|
-
>>> db = QuestDBConnector(
|
|
512
|
-
>>> db.read('
|
|
510
|
+
### Connect to an existing QuestDB instance
|
|
511
|
+
>>> db = QuestDBConnector()
|
|
512
|
+
>>> db.read('BINANCE.UM:ETHUSDT', '2024-01-01', transform=AsPandasFrame())
|
|
513
513
|
"""
|
|
514
514
|
_reconnect_tries = 5
|
|
515
515
|
_reconnect_idle = 0.1 # wait seconds before retying
|
|
516
516
|
|
|
517
|
-
def __init__(self,
|
|
517
|
+
def __init__(self, host='localhost', user='admin', password='quest', port=8812) -> None:
|
|
518
518
|
self._connection = None
|
|
519
519
|
self._cursor = None
|
|
520
|
-
self.
|
|
520
|
+
self._host = host
|
|
521
|
+
self._port = port
|
|
522
|
+
self.connection_url = f'user={user} password={password} host={host} port={port}'
|
|
521
523
|
self._connect()
|
|
522
524
|
|
|
523
525
|
def _connect(self):
|
|
524
|
-
logger.info("Connecting to QuestDB ...")
|
|
525
526
|
self._connection = pg.connect(self.connection_url, autocommit=True)
|
|
526
527
|
self._cursor = self._connection.cursor()
|
|
528
|
+
logger.debug(f"Connected to QuestDB at {self._host}:{self._port}")
|
|
527
529
|
|
|
528
530
|
@_retry
|
|
529
531
|
def read(self, data_id: str, start: str|None=None, stop: str|None=None,
|
|
530
532
|
transform: DataTransformer = DataTransformer(),
|
|
531
533
|
chunksize=0, # TODO: use self._cursor.fetchmany in this case !!!!
|
|
532
|
-
timeframe: str='1m') -> Any:
|
|
534
|
+
timeframe: str='1m', suffix='candles_1m') -> Any:
|
|
533
535
|
start, end = handle_start_stop(start, stop)
|
|
534
|
-
_req = self._prepare_data_sql(data_id, start, end, timeframe)
|
|
536
|
+
_req = self._prepare_data_sql(data_id, start, end, timeframe, suffix)
|
|
535
537
|
|
|
536
538
|
self._cursor.execute(_req) # type: ignore
|
|
537
539
|
records = self._cursor.fetchall() # TODO: for chunksize > 0 use fetchmany etc
|
|
@@ -542,14 +544,49 @@ class QuestDBConnector(DataReader):
|
|
|
542
544
|
transform.process_data(records)
|
|
543
545
|
return transform.collect()
|
|
544
546
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
547
|
+
@staticmethod
|
|
548
|
+
def _convert_time_delta_to_qdb_resample_format(c_tf: str):
|
|
549
|
+
if c_tf:
|
|
550
|
+
_t = re.match(r'(\d+)(\w+)', c_tf)
|
|
551
|
+
if _t and len(_t.groups()) > 1:
|
|
552
|
+
c_tf = f"{_t[1]}{_t[2][0].lower()}"
|
|
553
|
+
return c_tf
|
|
554
|
+
|
|
555
|
+
def _get_table_name(self, data_id: str, sfx: str='') -> str:
|
|
556
|
+
"""
|
|
557
|
+
Get table name for data_id
|
|
558
|
+
data_id can have format <exchange>.<type>:<symbol>
|
|
559
|
+
for example:
|
|
560
|
+
BINANCE.UM:BTCUSDT or BINANCE:BTCUSDT for spot
|
|
561
|
+
"""
|
|
562
|
+
_aliases = {'um': 'umfutures', 'cm': 'cmfutures', 'f': 'futures'}
|
|
563
|
+
table_name = data_id
|
|
564
|
+
_ss = data_id.split(':')
|
|
565
|
+
if len(_ss) > 1:
|
|
566
|
+
_exch, symb = _ss
|
|
567
|
+
_mktype = 'spot'
|
|
568
|
+
_ss = _exch.split('.')
|
|
569
|
+
if len(_ss) > 1:
|
|
570
|
+
_exch = _ss[0]
|
|
571
|
+
_mktype = _ss[1]
|
|
572
|
+
_mktype = _mktype.lower()
|
|
573
|
+
table_name = '.'.join(filter(lambda x: x, [_exch.lower(), _aliases.get(_mktype, _mktype), symb.lower(), sfx]))
|
|
574
|
+
return table_name
|
|
575
|
+
|
|
576
|
+
def _prepare_data_sql(self, data_id: str, start: str|None, end: str|None, resample: str, suffix: str) -> str:
|
|
577
|
+
where = ''
|
|
549
578
|
w0 = f"timestamp >= '{start}'" if start else ''
|
|
550
579
|
w1 = f"timestamp <= '{end}'" if end else ''
|
|
551
|
-
where = f'where {w0} and {w1}' if (w0 and w1) else f"where {(w0 or w1)}"
|
|
552
580
|
|
|
581
|
+
# - fix: when no data ranges are provided we must skip empy where keyword
|
|
582
|
+
if w0 or w1:
|
|
583
|
+
where = f'where {w0} and {w1}' if (w0 and w1) else f"where {(w0 or w1)}"
|
|
584
|
+
|
|
585
|
+
# - check resample format
|
|
586
|
+
resample = QuestDBConnector._convert_time_delta_to_qdb_resample_format(resample) if resample else resample
|
|
587
|
+
_rsmpl = f"SAMPLE by {resample}" if resample else ''
|
|
588
|
+
|
|
589
|
+
table_name = self._get_table_name(data_id, suffix)
|
|
553
590
|
return f"""
|
|
554
591
|
select timestamp,
|
|
555
592
|
first(open) as open,
|
|
@@ -561,8 +598,7 @@ class QuestDBConnector(DataReader):
|
|
|
561
598
|
sum(count) as count,
|
|
562
599
|
sum(taker_buy_volume) as taker_buy_volume,
|
|
563
600
|
sum(taker_buy_quote_volume) as taker_buy_quote_volume
|
|
564
|
-
from "{
|
|
565
|
-
SAMPLE by {resample};
|
|
601
|
+
from "{table_name}" {where} {_rsmpl};
|
|
566
602
|
"""
|
|
567
603
|
|
|
568
604
|
def _prepare_names_sql(self) -> str:
|
|
Binary file
|
|
@@ -6,13 +6,13 @@ 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=
|
|
9
|
+
qubx/core/series.cpython-311-x86_64-linux-gnu.so,sha256=4VkAkErkdGu0bJIOLxSeKm1xz-g8-nVLuXKZ1bzXe34,698952
|
|
10
10
|
qubx/core/series.pxd,sha256=IS89NQ5FYp3T0YIHe1lELKZIAKrNvX8K6WlLyac44I4,2847
|
|
11
11
|
qubx/core/series.pyx,sha256=WEAjn4j3zn540Cxx68X5gRXilvwa7NGdbki6myzZbIM,28108
|
|
12
12
|
qubx/core/strategy.py,sha256=Fs4fFyHaEGYuz7mBeQHBWFu3Ipg0yFzcxXhskgsPxJE,30330
|
|
13
|
-
qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=
|
|
13
|
+
qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=pzT_Pa_rBfspU1IxASo_yW11pRBXombGkO3kIbb9MkI,74216
|
|
14
14
|
qubx/core/utils.pyx,sha256=6dQ8R02bl8V3f-W3Wk9-e86D9OvDz-5-4NA_dlF_xwc,1368
|
|
15
|
-
qubx/data/readers.py,sha256=
|
|
15
|
+
qubx/data/readers.py,sha256=qBMKjE2RfiryLWpe_4XXmNExL3ve6M58Lc0Qwl2zUUs,24822
|
|
16
16
|
qubx/impl/ccxt_connector.py,sha256=NqF-tgxfTATnmVqKUonNXCAzECrDU8YrgqM3Nq06fw8,9150
|
|
17
17
|
qubx/impl/ccxt_customizations.py,sha256=kK_4KmOyKvDVgd4MTkVg4CyqdjE-6r41siZIvLj-A-Q,3488
|
|
18
18
|
qubx/impl/ccxt_trading.py,sha256=cmg4P-zd78w-V8j3-IGS2LFxikGhxFPgmCvz3sr065Q,9097
|
|
@@ -23,7 +23,7 @@ qubx/pandaz/__init__.py,sha256=Iw5uzicYGSC3FEKZ-W1O5-7cXq_P0kH11-EcXV0zZhs,175
|
|
|
23
23
|
qubx/pandaz/ta.py,sha256=TUvjrvmk4EQvDcXoRp6Os08-HUap-ZvpSDGawhViOgg,85271
|
|
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=
|
|
26
|
+
qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so,sha256=ZH66BIfzLOdIoALDI5kP7jED7pc5_q4iVz8jBSVutS8,284552
|
|
27
27
|
qubx/ta/indicators.pyx,sha256=P-GEYUks2lSHo6hbtUFAB7TWE1AunjLR4jIjwqPHrwU,7708
|
|
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=z5rdz5hbRu9-F2QgF47OCkMvhfIkRKs-PHR8L5DWkBM,9831
|
|
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.
|
|
38
|
-
qubx-0.1.
|
|
39
|
-
qubx-0.1.
|
|
37
|
+
qubx-0.1.81.dist-info/METADATA,sha256=Y0Nhj7gt38F-Hvz8T5DZxfY8_OL-PWCvoD6c_5YawtU,2491
|
|
38
|
+
qubx-0.1.81.dist-info/WHEEL,sha256=MLOa6LysROdjgj4FVxsHitAnIh8Be2D_c9ZSBHKrz2M,110
|
|
39
|
+
qubx-0.1.81.dist-info/RECORD,,
|
|
File without changes
|