hyperquant 0.32__py3-none-any.whl → 0.33__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.
@@ -1,6 +1,7 @@
1
1
  from typing import Literal, Optional
2
2
  import pybotters
3
3
  from .models.ourbit import OurbitSwapDataStore
4
+ from decimal import Decimal, ROUND_HALF_UP
4
5
 
5
6
 
6
7
  class OurbitSwap:
@@ -92,7 +93,13 @@ class OurbitSwap:
92
93
  return res.data["data"]
93
94
  case _:
94
95
  raise Exception(f"Failed api {res.response.url}: {res.data}")
95
-
96
+
97
+
98
+ def fmt_price(self, symbol, price: float) -> float:
99
+ tick = self.store.detail.find({"symbol": symbol})[0].get("tick_size")
100
+ tick_dec = Decimal(str(tick))
101
+ price_dec = Decimal(str(price))
102
+ return float((price_dec / tick_dec).quantize(Decimal("1"), rounding=ROUND_HALF_UP) * tick_dec)
96
103
 
97
104
  async def place_order(
98
105
  self,
@@ -123,8 +130,10 @@ class OurbitSwap:
123
130
  if usdt_amount is not None:
124
131
  cs = self.store.detail.find({"symbol": symbol})[0].get("contract_sz")
125
132
  size = max(int(usdt_amount / cs / price), 1)
126
-
127
133
 
134
+ price = self.fmt_price(symbol, price)
135
+
136
+ print(f'下单价格 {price}')
128
137
  leverage = max(max_lev, leverage)
129
138
 
130
139
  data = {
@@ -147,15 +156,15 @@ class OurbitSwap:
147
156
 
148
157
  if "close" in side:
149
158
  if side == 'close_buy':
150
- data["side"] = 4
151
- elif side == 'close_sell':
152
159
  data["side"] = 2
160
+ elif side == 'close_sell':
161
+ data["side"] = 4
153
162
 
154
163
  if position_id is None:
155
164
  raise ValueError("position_id is required for closing position")
156
165
  data["positionId"] = position_id
157
- import time
158
- print(time.time(), '下单')
166
+ # import time
167
+ # print(time.time(), '下单')
159
168
  res = await self.client.fetch(
160
169
  "POST", f"{self.api_url}/api/v1/private/order/create", data=data
161
170
  )
@@ -195,7 +204,7 @@ class OurbitSwap:
195
204
  data["takeProfitPrice"] = take_profit
196
205
  if stop_loss is not None:
197
206
  data["stopLossPrice"] = stop_loss
198
-
207
+
199
208
 
200
209
  res = await self.client.fetch(
201
210
  "POST",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 0.32
3
+ Version: 0.33
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
@@ -6,7 +6,7 @@ hyperquant/logkit.py,sha256=WALpXpIA3Ywr5DxKKK3k5EKubZ2h-ISGfc5dUReQUBQ,7795
6
6
  hyperquant/notikit.py,sha256=x5yAZ_tAvLQRXcRbcg-VabCaN45LUhvlTZnUqkIqfAA,3596
7
7
  hyperquant/broker/auth.py,sha256=hrdVuBTZwD3xSy5GI5JTFJhKiHhvIjZHA_7G5IUFznQ,1580
8
8
  hyperquant/broker/hyperliquid.py,sha256=7MxbI9OyIBcImDelPJu-8Nd53WXjxPB5TwE6gsjHbto,23252
9
- hyperquant/broker/ourbit.py,sha256=sPNdKxRiIICGVOjCIu0-VbqA-qPZ_1UeIpoDRaL9G_Q,9119
9
+ hyperquant/broker/ourbit.py,sha256=ejaRAM3Q8Iho7ng3o7xx-j0mT3GjrTykfVZNMTg5lO4,9567
10
10
  hyperquant/broker/ws.py,sha256=98Djt5n5sHUJKVbQ8Ql1t-G-Wiwu__4MYcUr5P6SDL0,326
11
11
  hyperquant/broker/lib/hpstore.py,sha256=LnLK2zmnwVvhEbLzYI-jz_SfYpO1Dv2u2cJaRAb84D8,8296
12
12
  hyperquant/broker/lib/hyper_types.py,sha256=HqjjzjUekldjEeVn6hxiWA8nevAViC2xHADOzDz9qyw,991
@@ -16,6 +16,6 @@ hyperquant/datavison/_util.py,sha256=92qk4vO856RqycO0YqEIHJlEg-W9XKapDVqAMxe6rbw
16
16
  hyperquant/datavison/binance.py,sha256=3yNKTqvt_vUQcxzeX4ocMsI5k6Q6gLZrvgXxAEad6Kc,5001
17
17
  hyperquant/datavison/coinglass.py,sha256=PEjdjISP9QUKD_xzXNzhJ9WFDTlkBrRQlVL-5pxD5mo,10482
18
18
  hyperquant/datavison/okx.py,sha256=yg8WrdQ7wgWHNAInIgsWPM47N3Wkfr253169IPAycAY,6898
19
- hyperquant-0.32.dist-info/METADATA,sha256=n6ti0zu8vGbaBI2cGFAnqI7AlhHpTLnOGd2tRkRPZUU,4317
20
- hyperquant-0.32.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
- hyperquant-0.32.dist-info/RECORD,,
19
+ hyperquant-0.33.dist-info/METADATA,sha256=TNKlHrMHpNgxFAsCIE3Oos_-skhADOqL7xMM6VrscjQ,4317
20
+ hyperquant-0.33.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
+ hyperquant-0.33.dist-info/RECORD,,