hyperquant 0.31__tar.gz → 0.33__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.31 → hyperquant-0.33}/PKG-INFO +1 -1
- {hyperquant-0.31 → hyperquant-0.33}/pyproject.toml +1 -1
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/ourbit.py +60 -7
- {hyperquant-0.31 → hyperquant-0.33}/uv.lock +1 -1
- {hyperquant-0.31 → hyperquant-0.33}/.gitignore +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/.python-version +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/README.md +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/data/logs/notikit.log +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/pub.sh +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/requirements-dev.lock +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/requirements.lock +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/__init__.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/auth.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/models/ourbit.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/core.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/db.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/draw.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/logkit.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/src/hyperquant/notikit.py +0 -0
- {hyperquant-0.31 → hyperquant-0.33}/test.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyperquant
|
3
|
-
Version: 0.
|
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
|
@@ -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,19 +156,63 @@ 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
|
153
|
-
|
160
|
+
elif side == 'close_sell':
|
161
|
+
data["side"] = 4
|
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
|
)
|
162
171
|
return self.ret_content(res)
|
172
|
+
|
173
|
+
async def place_tpsl(self,
|
174
|
+
position_id: int,
|
175
|
+
take_profit: Optional[float] = None,
|
176
|
+
stop_loss: Optional[float] = None,
|
177
|
+
):
|
178
|
+
"""
|
179
|
+
position_id 持仓ID
|
180
|
+
|
181
|
+
.. code:: json
|
182
|
+
|
183
|
+
{
|
184
|
+
"success": true,
|
185
|
+
"code": 0,
|
186
|
+
"data": 2280508
|
187
|
+
}
|
188
|
+
"""
|
189
|
+
if (take_profit is None) and (stop_loss is None):
|
190
|
+
raise ValueError("params err")
|
191
|
+
|
192
|
+
data = {
|
193
|
+
"positionId": position_id,
|
194
|
+
"profitTrend": "1",
|
195
|
+
"lossTrend": "1",
|
196
|
+
"profitLossVolType": "SAME",
|
197
|
+
"volType": 2,
|
198
|
+
"takeProfitReverse": 2,
|
199
|
+
"stopLossReverse": 2,
|
200
|
+
"priceProtect": "0",
|
201
|
+
}
|
202
|
+
|
203
|
+
if take_profit is not None:
|
204
|
+
data["takeProfitPrice"] = take_profit
|
205
|
+
if stop_loss is not None:
|
206
|
+
data["stopLossPrice"] = stop_loss
|
207
|
+
|
208
|
+
|
209
|
+
res = await self.client.fetch(
|
210
|
+
"POST",
|
211
|
+
f"{self.api_url}/api/v1/private/stoporder/place",
|
212
|
+
data=data
|
213
|
+
)
|
214
|
+
|
215
|
+
return self.ret_content(res)
|
163
216
|
|
164
217
|
async def cancel_orders(self, order_ids: list[str]):
|
165
218
|
res = await self.client.fetch(
|
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
|
File without changes
|