hyperquant 0.67__py3-none-any.whl → 0.68__py3-none-any.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.
@@ -9,6 +9,7 @@ from typing import Any, Iterable, Literal
9
9
  import pybotters
10
10
 
11
11
  from .models.lbank import LbankDataStore
12
+ from .lib.util import fmt_value
12
13
 
13
14
  logger = logging.getLogger(__name__)
14
15
 
@@ -141,6 +142,24 @@ class Lbank:
141
142
  return detail_entries[0].get("symbol")
142
143
  return None
143
144
 
145
+ def _get_detail_entry(self, symbol: str) -> dict[str, Any]:
146
+ detail = self.store.detail.get({"symbol": symbol})
147
+ if not detail:
148
+ raise ValueError(f"Unknown LBank instrument: {symbol}")
149
+ return detail
150
+
151
+ @staticmethod
152
+ def _format_with_step(value: float, step: Any) -> str:
153
+ try:
154
+ step_float = float(step)
155
+ except (TypeError, ValueError): # pragma: no cover - defensive guard
156
+ step_float = 0.0
157
+
158
+ if step_float <= 0:
159
+ return str(value)
160
+
161
+ return fmt_value(value, step_float)
162
+
144
163
  async def update_finish_order(
145
164
  self,
146
165
  *,
@@ -199,6 +218,14 @@ class Lbank:
199
218
  offset_code = self._normalize_offset(offset_flag)
200
219
  price_type_code, order_type_code = self._resolve_order_type(order_type)
201
220
 
221
+ detail_entry = self._get_detail_entry(symbol)
222
+ volume_str = self._format_with_step(volume, detail_entry.get("step_size"))
223
+ price_str: str | None = None
224
+ if price_type_code == "0":
225
+ if price is None:
226
+ raise ValueError("price is required for limit orders")
227
+ price_str = self._format_with_step(price, detail_entry.get("tick_size"))
228
+
202
229
  payload: dict[str, Any] = {
203
230
  # "ProductGroup": product_group,
204
231
  "InstrumentID": symbol,
@@ -207,14 +234,12 @@ class Lbank:
207
234
  "OffsetFlag": offset_code,
208
235
  "OrderPriceType": price_type_code,
209
236
  "OrderType": order_type_code,
210
- "Volume": str(volume),
237
+ "Volume": volume_str,
211
238
  "orderProportion": order_proportion,
212
239
  }
213
240
 
214
241
  if price_type_code == "0":
215
- if price is None:
216
- raise ValueError("price is required for limit orders")
217
- payload["Price"] = price
242
+ payload["Price"] = price_str
218
243
  elif price is not None:
219
244
  logger.warning("Price is ignored for market orders")
220
245
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 0.67
3
+ Version: 0.68
4
4
  Summary: A minimal yet hyper-efficient backtesting framework for quantitative trading
5
5
  Project-URL: Homepage, https://github.com/yourusername/hyperquant
6
6
  Project-URL: Issues, https://github.com/yourusername/hyperquant/issues
@@ -7,7 +7,7 @@ hyperquant/notikit.py,sha256=x5yAZ_tAvLQRXcRbcg-VabCaN45LUhvlTZnUqkIqfAA,3596
7
7
  hyperquant/broker/auth.py,sha256=Wst7mTBuUS2BQ5hZd0a8FNNs5Uc01ac9WzJpseTuyAY,7673
8
8
  hyperquant/broker/edgex.py,sha256=TqUO2KRPLN_UaxvtLL6HnA9dAQXC1sGxOfqTHd6W5k8,18378
9
9
  hyperquant/broker/hyperliquid.py,sha256=7MxbI9OyIBcImDelPJu-8Nd53WXjxPB5TwE6gsjHbto,23252
10
- hyperquant/broker/lbank.py,sha256=lai9xgK4Vbw7qPhRb7PGj-qKgFP40m1rHgVguTAXqDg,10756
10
+ hyperquant/broker/lbank.py,sha256=7o0xaCuUuIGDUX93-1tnWBH39QGohHpqpL-KFa2OiJc,11662
11
11
  hyperquant/broker/ourbit.py,sha256=NUcDSIttf-HGWzoW1uBTrGLPHlkuemMjYCm91MigTno,18228
12
12
  hyperquant/broker/ws.py,sha256=9Zu5JSLj-ylYEVmFmRwvZDDnVYKwb37cLHfZzA0AZGc,2200
13
13
  hyperquant/broker/lib/edgex_sign.py,sha256=lLUCmY8HHRLfLKyGrlTJYaBlSHPsIMWg3EZnQJKcmyk,95785
@@ -22,6 +22,6 @@ hyperquant/datavison/_util.py,sha256=92qk4vO856RqycO0YqEIHJlEg-W9XKapDVqAMxe6rbw
22
22
  hyperquant/datavison/binance.py,sha256=3yNKTqvt_vUQcxzeX4ocMsI5k6Q6gLZrvgXxAEad6Kc,5001
23
23
  hyperquant/datavison/coinglass.py,sha256=PEjdjISP9QUKD_xzXNzhJ9WFDTlkBrRQlVL-5pxD5mo,10482
24
24
  hyperquant/datavison/okx.py,sha256=yg8WrdQ7wgWHNAInIgsWPM47N3Wkfr253169IPAycAY,6898
25
- hyperquant-0.67.dist-info/METADATA,sha256=5v5iJ5vnK9QCgjCjtAGZsKwlAdyG0TPc1_ppcUJtjw4,4317
26
- hyperquant-0.67.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- hyperquant-0.67.dist-info/RECORD,,
25
+ hyperquant-0.68.dist-info/METADATA,sha256=-5HFGYBVdzJALnWhh4AFh62i_3cPqw_CGs5wF3XXjEk,4317
26
+ hyperquant-0.68.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ hyperquant-0.68.dist-info/RECORD,,