hyperquant 0.32__tar.gz → 0.34__tar.gz
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.
- {hyperquant-0.32 → hyperquant-0.34}/PKG-INFO +1 -1
- {hyperquant-0.32 → hyperquant-0.34}/pyproject.toml +1 -1
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/models/ourbit.py +2 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/ourbit.py +16 -7
- {hyperquant-0.32 → hyperquant-0.34}/uv.lock +1 -1
- {hyperquant-0.32 → hyperquant-0.34}/.gitignore +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/.python-version +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/README.md +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/data/logs/notikit.log +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/pub.sh +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/requirements-dev.lock +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/requirements.lock +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/__init__.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/auth.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/core.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/db.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/draw.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/logkit.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/src/hyperquant/notikit.py +0 -0
- {hyperquant-0.32 → hyperquant-0.34}/test.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyperquant
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.34
|
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
|
@@ -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",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|