Qubx 0.2.69__cp311-cp311-manylinux_2_35_x86_64.whl → 0.2.70__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/gathering/simplest.py +56 -12
- qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so +0 -0
- {qubx-0.2.69.dist-info → qubx-0.2.70.dist-info}/METADATA +1 -1
- {qubx-0.2.69.dist-info → qubx-0.2.70.dist-info}/RECORD +7 -7
- {qubx-0.2.69.dist-info → qubx-0.2.70.dist-info}/WHEEL +0 -0
|
Binary file
|
|
Binary file
|
qubx/gathering/simplest.py
CHANGED
|
@@ -8,23 +8,66 @@ class SimplePositionGatherer(IPositionGathering):
|
|
|
8
8
|
Default implementation of positions gathering by single orders through strategy context
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
+
entry_order_id: str | None = None
|
|
12
|
+
|
|
13
|
+
def _cncl_order(self, ctx: StrategyContext, instrument: Instrument) -> None:
|
|
14
|
+
if self.entry_order_id:
|
|
15
|
+
logger.debug(
|
|
16
|
+
f"<green>{instrument.symbol}</green>: Cancelling previous entry order <red>{self.entry_order_id}</red>"
|
|
17
|
+
)
|
|
18
|
+
try:
|
|
19
|
+
ctx.cancel_order(self.entry_order_id)
|
|
20
|
+
except Exception as e:
|
|
21
|
+
logger.error(f"Cancelling entry order failed: {str(e)}")
|
|
22
|
+
self.entry_order_id = None
|
|
23
|
+
|
|
11
24
|
def alter_position_size(self, ctx: StrategyContext, target: TargetPosition) -> float:
|
|
25
|
+
# Here is default inplementation:
|
|
26
|
+
# just trade it through the strategy context by using market (or limit) orders.
|
|
27
|
+
# but in general it may have complex logic for position adjustment
|
|
12
28
|
instrument, new_size, at_price = target.instrument, target.target_position_size, target.price
|
|
13
29
|
current_position = ctx.positions[instrument.symbol].quantity
|
|
14
30
|
to_trade = new_size - current_position
|
|
31
|
+
|
|
32
|
+
# - first cancel previous entry order if exists
|
|
33
|
+
self._cncl_order(ctx, instrument)
|
|
34
|
+
|
|
15
35
|
if abs(to_trade) < instrument.min_size:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
if current_position != 0:
|
|
37
|
+
logger.warning(
|
|
38
|
+
f"{instrument.exchange}:{instrument.symbol}: Unable change position from {current_position} to {new_size} : too small difference"
|
|
39
|
+
)
|
|
19
40
|
else:
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
|
|
42
|
+
# - check how it should be traded: market or limit or stop order
|
|
43
|
+
opts = {}
|
|
44
|
+
_is_stop_or_limit = False
|
|
45
|
+
if at_price:
|
|
46
|
+
# - we already havbe position but it's requested to change at a specific price
|
|
47
|
+
if abs(current_position) > instrument.min_size:
|
|
48
|
+
logger.warning(
|
|
49
|
+
f"<green>{instrument.symbol}</green>: Attempt to change current position {current_position} to {new_size} at {at_price} !"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
quote = ctx.quote(instrument.symbol)
|
|
53
|
+
if (to_trade > 0 and at_price > quote.ask) or (to_trade < 0 and at_price < quote.bid):
|
|
54
|
+
opts["stop_type"] = "market"
|
|
55
|
+
_is_stop_or_limit = True
|
|
56
|
+
|
|
57
|
+
if (to_trade > 0 and at_price <= quote.bid) or (to_trade < 0 and at_price >= quote.ask):
|
|
58
|
+
_is_stop_or_limit = True
|
|
59
|
+
|
|
60
|
+
r = ctx.trade(instrument, to_trade, at_price, **opts)
|
|
61
|
+
if _is_stop_or_limit:
|
|
62
|
+
self.entry_order_id = r.id
|
|
63
|
+
logger.debug(
|
|
64
|
+
f"<green>{instrument.symbol}</green>: Position may be adjusted from {current_position} to {new_size} at {at_price} : {r}"
|
|
65
|
+
)
|
|
66
|
+
else:
|
|
67
|
+
self.entry_order_id = None
|
|
68
|
+
logger.debug(
|
|
69
|
+
f"<green>{instrument.symbol}</green>: Adjusting position from {current_position} to {new_size} : {r}"
|
|
70
|
+
)
|
|
28
71
|
|
|
29
72
|
current_position = new_size
|
|
30
73
|
# - TODO: need to check how fast position is being updated on live
|
|
@@ -33,7 +76,8 @@ class SimplePositionGatherer(IPositionGathering):
|
|
|
33
76
|
return current_position
|
|
34
77
|
|
|
35
78
|
def on_execution_report(self, ctx: StrategyContext, instrument: Instrument, deal: Deal):
|
|
36
|
-
|
|
79
|
+
if deal.order_id == self.entry_order_id:
|
|
80
|
+
self.entry_order_id = None
|
|
37
81
|
|
|
38
82
|
|
|
39
83
|
class SplittedOrdersPositionGatherer(IPositionGathering):
|
|
Binary file
|
|
@@ -14,17 +14,17 @@ qubx/core/helpers.py,sha256=JAB1kcKO8l--gxg9_W2BzWW1N4x72sicw1oBszKYcbo,12657
|
|
|
14
14
|
qubx/core/loggers.py,sha256=zpehm2-RdKG1ISe6t3DiM3RrL_zzGni3YFcxfgDkV24,16575
|
|
15
15
|
qubx/core/lookups.py,sha256=qGOSb2SIxmgVPGJFLJnPDI1P9hCzFMVipRDcVLUm8qk,14599
|
|
16
16
|
qubx/core/metrics.py,sha256=pL1obxnk8I7bDF41bQcOZ7MDsq4Wmj6g5cRiV7cFZKQ,38657
|
|
17
|
-
qubx/core/series.cpython-311-x86_64-linux-gnu.so,sha256=
|
|
17
|
+
qubx/core/series.cpython-311-x86_64-linux-gnu.so,sha256=MBbJM6pkp8I6FHCKYQy3PfmRAx58P9MRgmzRYisMHHo,779016
|
|
18
18
|
qubx/core/series.pxd,sha256=kF7QeLFgCM-C2hDxVvJM97ZOmyw1v7JEI9WfPKtQ6xs,3002
|
|
19
19
|
qubx/core/series.pyi,sha256=QeOSi57-NxHEfiP-i7IImf-06KrqSHob5dr6kp45mM4,2603
|
|
20
20
|
qubx/core/series.pyx,sha256=UhZsnT7R3-UED05Fnp3mGxr4RSdMpWAHB4lkcz46MFo,32598
|
|
21
21
|
qubx/core/strategy.py,sha256=tTXhDbFTH63yj53mLgVEDBZxYOxC51prcsyXWkdTgLs,10991
|
|
22
|
-
qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=
|
|
22
|
+
qubx/core/utils.cpython-311-x86_64-linux-gnu.so,sha256=O86lbSsB9GOEQ-LWUIMLCUvyEEEc-BMSK5wYbqH5_zU,82504
|
|
23
23
|
qubx/core/utils.pyi,sha256=DAjyRVPJSxK4Em-9wui2F0yYHfP5tI5DjKavXNOnHa8,276
|
|
24
24
|
qubx/core/utils.pyx,sha256=-8ek58CrbqWZq0-OY7WSREsCXBoBeWrD_wEYbIBS9rI,1696
|
|
25
25
|
qubx/data/helpers.py,sha256=A0NGzhpXYWD92-GeB8TghwMnR0NW8bjcNJOCXybQw3g,782
|
|
26
26
|
qubx/data/readers.py,sha256=HzNkFI2W4Rkh2AZWsOnnsi9VlHmlBCKaigyMd0T0Jiw,39523
|
|
27
|
-
qubx/gathering/simplest.py,sha256=
|
|
27
|
+
qubx/gathering/simplest.py,sha256=MTulwYqR5tLP6CP_jFPELUl0wQKG_RcRNMZBB2aajVI,3818
|
|
28
28
|
qubx/impl/ccxt_connector.py,sha256=ja_0WJDyZfkzqhNvoV-c5CCg15YnbRIThxw0TTNdwcc,13066
|
|
29
29
|
qubx/impl/ccxt_customizations.py,sha256=WUhDT9x2SYuFrOyBIbk2D9Q_U_5QZhtLomLq88Egf_c,6230
|
|
30
30
|
qubx/impl/ccxt_trading.py,sha256=OW0s_kW7GZlbDz_pGBlzLCUT2iDK4dhaBtmIAvj7QDw,9889
|
|
@@ -35,7 +35,7 @@ qubx/pandaz/__init__.py,sha256=Iw5uzicYGSC3FEKZ-W1O5-7cXq_P0kH11-EcXV0zZhs,175
|
|
|
35
35
|
qubx/pandaz/ta.py,sha256=NthiiueUoqWGRcjovcKKThcCcdImZn3JRdWDA2vL28k,85075
|
|
36
36
|
qubx/pandaz/utils.py,sha256=XB28Zwv3cXWbKFXbcV5QGj_d6w-i8Yo4LYkX8aPuCHo,19613
|
|
37
37
|
qubx/ta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
-
qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so,sha256=
|
|
38
|
+
qubx/ta/indicators.cpython-311-x86_64-linux-gnu.so,sha256=VcXW5JKSl6PTfE9FIXCyQfYRlNezHSrYMahADOtTfQI,576168
|
|
39
39
|
qubx/ta/indicators.pxd,sha256=YzPDhbbNPmy3m4NafwIRF5sNFsmkq-MM1gbeAygtBwM,4007
|
|
40
40
|
qubx/ta/indicators.pyi,sha256=mM_7ISmGQDgjhwxCoZXDw7Rm9fynQSYjevV7fRoLdNc,1683
|
|
41
41
|
qubx/ta/indicators.pyx,sha256=GuxB63YApFnA9IWNJDbBt90J1sOoxTf3jDWYQ3uD9So,24306
|
|
@@ -53,6 +53,6 @@ qubx/utils/misc.py,sha256=Av0mhrPCy5NZRrRmjOAhTKusa8wVdL7vCQtEy9bVnz4,10450
|
|
|
53
53
|
qubx/utils/ntp.py,sha256=LZo4FPVY3rqLUV9VWkLcZaPOpUDFC8Qleynmfggg9No,1758
|
|
54
54
|
qubx/utils/runner.py,sha256=Czo01KUCc9Oj9TIcs03d6Qh7fOpQV5w8oH6UDZ6Yqn0,9539
|
|
55
55
|
qubx/utils/time.py,sha256=ioIos3VLA-iYI8LiQIn2m-t0Y37CEQAHFw_-C9Uwo0o,5188
|
|
56
|
-
qubx-0.2.
|
|
57
|
-
qubx-0.2.
|
|
58
|
-
qubx-0.2.
|
|
56
|
+
qubx-0.2.70.dist-info/METADATA,sha256=9TR9KbFamJCbpShZLxQV6XvV8Hkbk2CqTEDRFB9WaQI,2573
|
|
57
|
+
qubx-0.2.70.dist-info/WHEEL,sha256=MLOa6LysROdjgj4FVxsHitAnIh8Be2D_c9ZSBHKrz2M,110
|
|
58
|
+
qubx-0.2.70.dist-info/RECORD,,
|
|
File without changes
|