Qubx 0.6.10__cp312-cp312-manylinux_2_39_x86_64.whl → 0.6.11__cp312-cp312-manylinux_2_39_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/basics.py CHANGED
@@ -8,6 +8,7 @@ from typing import Any, Literal, Optional, TypeAlias, Union
8
8
  import numpy as np
9
9
  import pandas as pd
10
10
 
11
+ from qubx import logger
11
12
  from qubx.core.exceptions import QueueTimeout
12
13
  from qubx.core.series import Bar, OrderBook, Quote, Trade, time_as_nsec
13
14
  from qubx.core.utils import prec_ceil, prec_floor, time_delta_to_str
@@ -550,7 +551,7 @@ class Position:
550
551
  qty_opening = pos_change if prev_direction == direction else pos_change - qty_closing
551
552
 
552
553
  # - extract realized part of PnL
553
- if qty_closing != 0:
554
+ if not np.isclose(qty_closing, 0.0):
554
555
  _abs_qty_close = abs(qty_closing)
555
556
  deal_pnl = qty_closing * (self.position_avg_price - exec_price)
556
557
 
@@ -564,11 +565,19 @@ class Position:
564
565
  self.__pos_incr_qty = 0
565
566
 
566
567
  # - if it has something to add to position let's update price and cost
567
- if qty_opening != 0:
568
+ if not np.isclose(qty_opening, 0.0):
568
569
  _abs_qty_open = abs(qty_opening)
569
- pos_avg_price_raw = (_abs_qty_open * exec_price + self.__pos_incr_qty * self.position_avg_price) / (
570
- self.__pos_incr_qty + _abs_qty_open
571
- )
570
+ try:
571
+ pos_avg_price_raw = (_abs_qty_open * exec_price + self.__pos_incr_qty * self.position_avg_price) / (
572
+ self.__pos_incr_qty + _abs_qty_open
573
+ )
574
+ except ZeroDivisionError:
575
+ logger.warning(
576
+ "Zero division error in position update: "
577
+ f"qty_opening={qty_opening}, exec_price={exec_price}, pos_incr_qty={self.__pos_incr_qty}, position_avg_price={self.position_avg_price}"
578
+ )
579
+ pos_avg_price_raw = self.position_avg_price
580
+
572
581
  # - round position average price to be in line with how it's calculated by broker
573
582
  self.position_avg_price = self.instrument.round_price_down(pos_avg_price_raw)
574
583
  self.__pos_incr_qty += _abs_qty_open
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: Qubx
3
- Version: 0.6.10
3
+ Version: 0.6.11
4
4
  Summary: Qubx - Quantitative Trading Framework
5
5
  Author: Dmitry Marienko
6
6
  Author-email: dmitry.marienko@xlydian.com
@@ -27,7 +27,7 @@ qubx/connectors/ccxt/reader.py,sha256=qaZIaOZkRf3Rz31ZrEqqAv4kATk5zDlSq-LK1jziBs
27
27
  qubx/connectors/ccxt/utils.py,sha256=kWeYQ1Z9TxFTbgJgBh5o77mGB1g09l2AkiFdR6guDQY,11141
28
28
  qubx/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  qubx/core/account.py,sha256=Ewzmr1jxyLROnWshtx_ngi7fna1cH42NJ5wVRyP4dmQ,10411
30
- qubx/core/basics.py,sha256=3Q5E9yQ_bnOIeMsL98kdb9idzDnqwi13SlmO2LMns_4,28683
30
+ qubx/core/basics.py,sha256=O_m9sfmLoaYuQx-3q-zv-LQOhG8ARrUSJ73i5fqr0Yw,29164
31
31
  qubx/core/context.py,sha256=t4A1sWM6dn4t-LSKOC-66x4Y-_5aGduEedO_Gmd3Yrg,20593
32
32
  qubx/core/exceptions.py,sha256=ONFzWISjWfb2S0kEIorq-3L4MdhNR-xkHftHQALOZ0U,533
33
33
  qubx/core/helpers.py,sha256=9nl9L_ZzT1HsMC9VthMqXfmuRS_37crB-9bVfIRHeOs,19631
@@ -42,11 +42,11 @@ qubx/core/mixins/processing.py,sha256=Ny9EyrTuF_YBmPsAebykV54OfGMBGE1gSam9VFJJKa
42
42
  qubx/core/mixins/subscription.py,sha256=J_SX0CNw2bPy4bhxe0vswvDXY4LCkwXSaj_1PepKRLY,8540
43
43
  qubx/core/mixins/trading.py,sha256=KApWQE0zIh1jg_9HezLdR-mp3UEYIdylSyX9MajHmCc,3618
44
44
  qubx/core/mixins/universe.py,sha256=1ya2P3QZrsAVXmMXqq0t6CHGAC5iMGVD2ARUAtSfv04,10062
45
- qubx/core/series.cpython-312-x86_64-linux-gnu.so,sha256=23fTZIr_aK_IaTkwhaSWHbMMq1jBgZCMLJvhuCm6UDk,970056
45
+ qubx/core/series.cpython-312-x86_64-linux-gnu.so,sha256=APsllVvq0Nc5QyZAYfOIKFPVFroKbJLH7p56viwHDms,970056
46
46
  qubx/core/series.pxd,sha256=ZA9mBrZ-ha112ZMZnBIun1kNrKjxzlaOoq4D_cDZYJw,3923
47
47
  qubx/core/series.pyi,sha256=r6o2SnYIBujmJuuoM8oEc3tbVg2Blz2CfSIdRKn9VMo,4547
48
48
  qubx/core/series.pyx,sha256=Y6GbCihO3zgUWOF9UvmyXisWLnGcVOcFl2u1ZtvM1zI,44909
49
- qubx/core/utils.cpython-312-x86_64-linux-gnu.so,sha256=cOfj8bdUMj8VYurQajzxqhiPIdXlxo2rthWEnn5FPFM,86568
49
+ qubx/core/utils.cpython-312-x86_64-linux-gnu.so,sha256=HX-7iU5diG9cXb1EGWZSjuiScWsX5kN5TfbUUnvB35k,86568
50
50
  qubx/core/utils.pyi,sha256=a-wS13V2p_dM1CnGq40JVulmiAhixTwVwt0ah5By0Hc,348
51
51
  qubx/core/utils.pyx,sha256=k5QHfEFvqhqWfCob89ANiJDKNG8gGbOh-O4CVoneZ8M,1696
52
52
  qubx/data/__init__.py,sha256=ELZykvpPGWc5rX7QoNyNQwMLgdKMG8MACOByA4pM5hA,549
@@ -104,7 +104,7 @@ qubx/restorers/signal.py,sha256=iruHe4ieTSV73zeJbFPubsmAEf4TzVXnkM4zjupCAJQ,6462
104
104
  qubx/restorers/state.py,sha256=ePmh604fp2kRYzMNXL-TWvZOxmtTGAaKYfHJcnKResY,4042
105
105
  qubx/restorers/utils.py,sha256=We2gfqwQKWziUYhuUnjb-xo-5tSlbuHWpPQn0CEMTn0,1155
106
106
  qubx/ta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
- qubx/ta/indicators.cpython-312-x86_64-linux-gnu.so,sha256=WWckO4c42inIW-CCEmcW-xCNY7dpmujiJ55TvCqQuwc,654440
107
+ qubx/ta/indicators.cpython-312-x86_64-linux-gnu.so,sha256=iqWHwrqYR28G5SX-XCN3d9Jssc6baqZFLoQ3qRKl-OI,654440
108
108
  qubx/ta/indicators.pxd,sha256=eCJ9paOxtxbDFx4U5CUhcgB1jjCQAfVqMF2FnbJ03Lo,4222
109
109
  qubx/ta/indicators.pyi,sha256=19W0uERft49In5bf9jkJHkzJYEyE9gzudN7_DJ5Vdv8,1963
110
110
  qubx/ta/indicators.pyx,sha256=FVkv5ld04TpZMT3a_kR1MU3IUuWfijzjJnh_lG78JxM,26029
@@ -138,7 +138,7 @@ qubx/utils/runner/configs.py,sha256=vtl04A42kT21hD68zpoZZw96rEC8HnFFX9en0Y85GLA,
138
138
  qubx/utils/runner/runner.py,sha256=kwigJ9MgBcOkDpYAHj2TuwQzNerwyUWaE4UmyNYxD34,37910
139
139
  qubx/utils/time.py,sha256=J0ZFGjzFL5T6GA8RPAel8hKG0sg2LZXeQ5YfDCfcMHA,10055
140
140
  qubx/utils/version.py,sha256=e52fIHyxzCiIuH7svCF6pkHuDlqL64rklqz-2XjWons,5309
141
- qubx-0.6.10.dist-info/METADATA,sha256=LPSsRviGdvTomS-OolxJMEr5I61F9tLUTPegAsDSQAM,4142
142
- qubx-0.6.10.dist-info/WHEEL,sha256=h1DdjcD2ZFnKGsDLjEycQhNNPJ5l-R8qdFdDSXHrAGY,110
143
- qubx-0.6.10.dist-info/entry_points.txt,sha256=VqilDTe8mVuV9SbR-yVlZJBTjbkHIL2JBgXfQw076HY,47
144
- qubx-0.6.10.dist-info/RECORD,,
141
+ qubx-0.6.11.dist-info/METADATA,sha256=0jn6yriiV1zR00FDlO0QiOkGdC8vQo8Se8dbErd3jNE,4142
142
+ qubx-0.6.11.dist-info/WHEEL,sha256=h1DdjcD2ZFnKGsDLjEycQhNNPJ5l-R8qdFdDSXHrAGY,110
143
+ qubx-0.6.11.dist-info/entry_points.txt,sha256=VqilDTe8mVuV9SbR-yVlZJBTjbkHIL2JBgXfQw076HY,47
144
+ qubx-0.6.11.dist-info/RECORD,,
File without changes