unicex 0.13.17__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.
- unicex/__init__.py +200 -0
- unicex/_abc/__init__.py +11 -0
- unicex/_abc/exchange_info.py +216 -0
- unicex/_abc/uni_client.py +329 -0
- unicex/_abc/uni_websocket_manager.py +294 -0
- unicex/_base/__init__.py +9 -0
- unicex/_base/client.py +214 -0
- unicex/_base/websocket.py +261 -0
- unicex/binance/__init__.py +27 -0
- unicex/binance/adapter.py +202 -0
- unicex/binance/client.py +1577 -0
- unicex/binance/exchange_info.py +62 -0
- unicex/binance/uni_client.py +188 -0
- unicex/binance/uni_websocket_manager.py +166 -0
- unicex/binance/user_websocket.py +186 -0
- unicex/binance/websocket_manager.py +912 -0
- unicex/bitget/__init__.py +27 -0
- unicex/bitget/adapter.py +188 -0
- unicex/bitget/client.py +2514 -0
- unicex/bitget/exchange_info.py +48 -0
- unicex/bitget/uni_client.py +198 -0
- unicex/bitget/uni_websocket_manager.py +275 -0
- unicex/bitget/user_websocket.py +7 -0
- unicex/bitget/websocket_manager.py +232 -0
- unicex/bybit/__init__.py +27 -0
- unicex/bybit/adapter.py +208 -0
- unicex/bybit/client.py +1876 -0
- unicex/bybit/exchange_info.py +53 -0
- unicex/bybit/uni_client.py +200 -0
- unicex/bybit/uni_websocket_manager.py +291 -0
- unicex/bybit/user_websocket.py +7 -0
- unicex/bybit/websocket_manager.py +339 -0
- unicex/enums.py +273 -0
- unicex/exceptions.py +64 -0
- unicex/extra.py +335 -0
- unicex/gate/__init__.py +27 -0
- unicex/gate/adapter.py +178 -0
- unicex/gate/client.py +1667 -0
- unicex/gate/exchange_info.py +55 -0
- unicex/gate/uni_client.py +214 -0
- unicex/gate/uni_websocket_manager.py +269 -0
- unicex/gate/user_websocket.py +7 -0
- unicex/gate/websocket_manager.py +513 -0
- unicex/hyperliquid/__init__.py +27 -0
- unicex/hyperliquid/adapter.py +261 -0
- unicex/hyperliquid/client.py +2315 -0
- unicex/hyperliquid/exchange_info.py +119 -0
- unicex/hyperliquid/uni_client.py +325 -0
- unicex/hyperliquid/uni_websocket_manager.py +269 -0
- unicex/hyperliquid/user_websocket.py +7 -0
- unicex/hyperliquid/websocket_manager.py +393 -0
- unicex/mapper.py +111 -0
- unicex/mexc/__init__.py +27 -0
- unicex/mexc/_spot_ws_proto/PrivateAccountV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PrivateDealsV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PrivateOrdersV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicAggreBookTickerV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicAggreDealsV3Api_pb2.py +40 -0
- unicex/mexc/_spot_ws_proto/PublicAggreDepthsV3Api_pb2.py +40 -0
- unicex/mexc/_spot_ws_proto/PublicBookTickerBatchV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicBookTickerV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicDealsV3Api_pb2.py +40 -0
- unicex/mexc/_spot_ws_proto/PublicFuture_pb2.py +103 -0
- unicex/mexc/_spot_ws_proto/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicIncreaseDepthsV3Api_pb2.py +40 -0
- unicex/mexc/_spot_ws_proto/PublicLimitDepthsV3Api_pb2.py +40 -0
- unicex/mexc/_spot_ws_proto/PublicMiniTickerV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicMiniTickersV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PublicSpotKlineV3Api_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/PushDataV3ApiWrapper_pb2.py +38 -0
- unicex/mexc/_spot_ws_proto/__init__.py +335 -0
- unicex/mexc/adapter.py +239 -0
- unicex/mexc/client.py +846 -0
- unicex/mexc/exchange_info.py +47 -0
- unicex/mexc/uni_client.py +211 -0
- unicex/mexc/uni_websocket_manager.py +269 -0
- unicex/mexc/user_websocket.py +7 -0
- unicex/mexc/websocket_manager.py +456 -0
- unicex/okx/__init__.py +27 -0
- unicex/okx/adapter.py +150 -0
- unicex/okx/client.py +2864 -0
- unicex/okx/exchange_info.py +47 -0
- unicex/okx/uni_client.py +202 -0
- unicex/okx/uni_websocket_manager.py +269 -0
- unicex/okx/user_websocket.py +7 -0
- unicex/okx/websocket_manager.py +743 -0
- unicex/types.py +164 -0
- unicex/utils.py +218 -0
- unicex-0.13.17.dist-info/METADATA +243 -0
- unicex-0.13.17.dist-info/RECORD +93 -0
- unicex-0.13.17.dist-info/WHEEL +5 -0
- unicex-0.13.17.dist-info/licenses/LICENSE +28 -0
- unicex-0.13.17.dist-info/top_level.txt +1 -0
unicex/bitget/client.py
ADDED
|
@@ -0,0 +1,2514 @@
|
|
|
1
|
+
__all__ = ["Client"]
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import time
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
|
|
7
|
+
from unicex._base import BaseClient
|
|
8
|
+
from unicex.exceptions import NotAuthorized
|
|
9
|
+
from unicex.types import RequestMethod
|
|
10
|
+
from unicex.utils import (
|
|
11
|
+
dict_to_query_string,
|
|
12
|
+
filter_params,
|
|
13
|
+
generate_hmac_sha256_signature,
|
|
14
|
+
sort_params_by_alphabetical_order,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Client(BaseClient):
|
|
19
|
+
"""Клиент для работы с Bitget API."""
|
|
20
|
+
|
|
21
|
+
_BASE_URL: str = "https://api.bitget.com"
|
|
22
|
+
"""Базовый URL для REST API Bitget."""
|
|
23
|
+
|
|
24
|
+
def is_authorized(self) -> bool:
|
|
25
|
+
"""Проверяет наличие API‑ключей у клиента.
|
|
26
|
+
|
|
27
|
+
Возвращает:
|
|
28
|
+
`bool`: Признак наличия ключей.
|
|
29
|
+
"""
|
|
30
|
+
return (
|
|
31
|
+
self._api_key is not None
|
|
32
|
+
and self._api_secret is not None
|
|
33
|
+
and self._api_passphrase is not None
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def _sign_message(
|
|
37
|
+
self,
|
|
38
|
+
method: RequestMethod,
|
|
39
|
+
endpoint: str,
|
|
40
|
+
params: dict[str, Any] | None,
|
|
41
|
+
body: dict[str, Any] | None,
|
|
42
|
+
) -> tuple[str, str]:
|
|
43
|
+
"""Создает timestamp и signature для приватного запроса.
|
|
44
|
+
|
|
45
|
+
Алгоритм:
|
|
46
|
+
- формирует строку prehash из timestamp, метода, endpoint, query и body
|
|
47
|
+
- подписывает строку секретным ключом (HMAC-SHA256)
|
|
48
|
+
- кодирует результат в base64
|
|
49
|
+
|
|
50
|
+
Параметры:
|
|
51
|
+
method (`RequestMethod`): HTTP-метод (GET, POST и т.д.).
|
|
52
|
+
endpoint (`str`): Относительный путь эндпоинта (например `/api/spot/v1/account/assets`).
|
|
53
|
+
params (`dict[str, Any] | None`): Query-параметры.
|
|
54
|
+
body (`dict[str, Any] | None`): Тело запроса (для POST/PUT).
|
|
55
|
+
|
|
56
|
+
Возвращает:
|
|
57
|
+
tuple:
|
|
58
|
+
- `timestamp (str)`: Временная метка в миллисекундах.
|
|
59
|
+
- `signature (str)`: Подпись в формате base64.
|
|
60
|
+
"""
|
|
61
|
+
if not self.is_authorized():
|
|
62
|
+
raise NotAuthorized("Api key and api secret is required to private endpoints")
|
|
63
|
+
|
|
64
|
+
timestamp = str(int(time.time() * 1000))
|
|
65
|
+
|
|
66
|
+
path = f"{endpoint}?{dict_to_query_string(params)}" if params else endpoint
|
|
67
|
+
body_str = json.dumps(body) if body else ""
|
|
68
|
+
prehash = f"{timestamp}{method}{path}{body_str}"
|
|
69
|
+
signature = generate_hmac_sha256_signature(
|
|
70
|
+
self._api_secret, # type: ignore[attr-defined]
|
|
71
|
+
prehash,
|
|
72
|
+
"base64",
|
|
73
|
+
)
|
|
74
|
+
return timestamp, signature
|
|
75
|
+
|
|
76
|
+
def _get_headers(self, timestamp: str, signature: str) -> dict[str, str]:
|
|
77
|
+
"""Возвращает заголовки для REST-запросов Bitget.
|
|
78
|
+
|
|
79
|
+
Параметры:
|
|
80
|
+
timestamp (`str`): Временная метка.
|
|
81
|
+
signature (`str`): Подпись (base64).
|
|
82
|
+
|
|
83
|
+
Возвращает:
|
|
84
|
+
`dict[str, str]`: Словарь заголовков запроса.
|
|
85
|
+
"""
|
|
86
|
+
headers = {"Content-Type": "application/json", "Accept": "application/json"}
|
|
87
|
+
headers.update(
|
|
88
|
+
{
|
|
89
|
+
"ACCESS-KEY": self._api_key, # type: ignore[attr-defined]
|
|
90
|
+
"ACCESS-PASSPHRASE": self._api_passphrase, # type: ignore[attr-defined]
|
|
91
|
+
"ACCESS-TIMESTAMP": timestamp,
|
|
92
|
+
"ACCESS-SIGN": signature,
|
|
93
|
+
"locale": "en-US",
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
return headers
|
|
97
|
+
|
|
98
|
+
def _prepare_request_params(
|
|
99
|
+
self,
|
|
100
|
+
*,
|
|
101
|
+
method: RequestMethod,
|
|
102
|
+
endpoint: str,
|
|
103
|
+
signed: bool,
|
|
104
|
+
params: dict[str, Any] | None,
|
|
105
|
+
body: dict[str, Any] | None = None,
|
|
106
|
+
) -> tuple[str, dict[str, Any] | None, dict[str, Any] | None, dict[str, str] | None]:
|
|
107
|
+
"""Готовит данные для запроса.
|
|
108
|
+
|
|
109
|
+
Если signed=True:
|
|
110
|
+
- генерирует timestamp и signature
|
|
111
|
+
- добавляет авторизационные заголовки
|
|
112
|
+
|
|
113
|
+
Если signed=False:
|
|
114
|
+
- возвращает только url и переданные параметры.
|
|
115
|
+
|
|
116
|
+
Параметры:
|
|
117
|
+
method (`RequestMethod`): HTTP-метод (GET, POST и т.д.).
|
|
118
|
+
endpoint (`str`): Относительный путь эндпоинта.
|
|
119
|
+
signed (`bool`): Нужно ли подписывать запрос.
|
|
120
|
+
params (`dict[str, Any] | None`): Query-параметры.
|
|
121
|
+
body (`dict[str, Any] | None`): Тело запроса.
|
|
122
|
+
|
|
123
|
+
Возвращает:
|
|
124
|
+
tuple:
|
|
125
|
+
- `url (str)`: Полный URL для запроса.
|
|
126
|
+
- `params (dict | None)`: Query-параметры.
|
|
127
|
+
- `body (dict | None)`: Тело запроса.
|
|
128
|
+
- `headers (dict | None)`: Заголовки (если signed=True).
|
|
129
|
+
"""
|
|
130
|
+
url = f"{self._BASE_URL}{endpoint}"
|
|
131
|
+
|
|
132
|
+
# Предобрабатывает параметры запроса и сортирует их в соответствии с требованиями Bitget
|
|
133
|
+
if params:
|
|
134
|
+
params = filter_params(params)
|
|
135
|
+
params = sort_params_by_alphabetical_order(params)
|
|
136
|
+
|
|
137
|
+
headers = None
|
|
138
|
+
if signed:
|
|
139
|
+
timestamp, signature = self._sign_message(method, endpoint, params, body)
|
|
140
|
+
headers = self._get_headers(timestamp, signature)
|
|
141
|
+
return url, params, body, headers
|
|
142
|
+
|
|
143
|
+
async def _make_request(
|
|
144
|
+
self,
|
|
145
|
+
method: RequestMethod,
|
|
146
|
+
endpoint: str,
|
|
147
|
+
signed: bool = False,
|
|
148
|
+
*,
|
|
149
|
+
params: dict[str, Any] | None = None,
|
|
150
|
+
data: dict[str, Any] | None = None,
|
|
151
|
+
) -> Any:
|
|
152
|
+
"""Выполняет HTTP-запрос к эндпоинтам Bitget API.
|
|
153
|
+
|
|
154
|
+
Если `signed=True`:
|
|
155
|
+
- генерирует `timestamp` и `signature`;
|
|
156
|
+
- добавляет авторизационные заголовки (`ACCESS-KEY`, `ACCESS-PASSPHRASE`, `ACCESS-TIMESTAMP`, `ACCESS-SIGN`).
|
|
157
|
+
|
|
158
|
+
Если `signed=False`:
|
|
159
|
+
- выполняет публичный запрос без подписи.
|
|
160
|
+
|
|
161
|
+
Параметры:
|
|
162
|
+
method (`RequestMethod`): HTTP-метод (`"GET"`, `"POST"`, и т. п.).
|
|
163
|
+
endpoint (`str`): Относительный путь эндпоинта (например, `"/api/spot/v1/market/tickers"`).
|
|
164
|
+
signed (`bool`): Приватный запрос (с подписью) или публичный. По умолчанию `False`.
|
|
165
|
+
params (`dict[str, Any] | None`): Query-параметры запроса.
|
|
166
|
+
data (`dict[str, Any] | None`): Тело запроса для `POST/PUT`.
|
|
167
|
+
|
|
168
|
+
Возвращает:
|
|
169
|
+
`Any`: Ответ API в формате JSON (`dict` или `list`), как вернул сервер.
|
|
170
|
+
"""
|
|
171
|
+
url, params, data, headers = self._prepare_request_params(
|
|
172
|
+
method=method,
|
|
173
|
+
endpoint=endpoint,
|
|
174
|
+
signed=signed,
|
|
175
|
+
params=params,
|
|
176
|
+
body=data,
|
|
177
|
+
)
|
|
178
|
+
return await super()._make_request(
|
|
179
|
+
method=method,
|
|
180
|
+
url=url,
|
|
181
|
+
params=params,
|
|
182
|
+
data=data,
|
|
183
|
+
headers=headers,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
async def request(
|
|
187
|
+
self, method: RequestMethod, endpoint: str, params: dict, data: dict, signed: bool
|
|
188
|
+
) -> dict:
|
|
189
|
+
"""Специальный метод для выполнения запросов на эндпоинты, которые не обернуты в клиенте.
|
|
190
|
+
|
|
191
|
+
Параметры:
|
|
192
|
+
method (`RequestMethod`): HTTP-метод (`"GET"`, `"POST"`, и т. п.).
|
|
193
|
+
endpoint (`str`): Относительный путь эндпоинта (например, `"/api/spot/v1/market/tickers"`).
|
|
194
|
+
signed (`bool`): Приватный запрос (с подписью) или публичный. По умолчанию `False`.
|
|
195
|
+
params (`dict[str, Any] | None`): Query-параметры запроса.
|
|
196
|
+
data (`dict[str, Any] | None`): Тело запроса для `POST/PUT`.
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
Возвращает:
|
|
200
|
+
`dict`: Ответ в формате JSON.
|
|
201
|
+
"""
|
|
202
|
+
return await self._make_request(
|
|
203
|
+
method=method, endpoint=endpoint, params=params, data=data, signed=signed
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# topic: common
|
|
207
|
+
|
|
208
|
+
async def get_server_time(self) -> dict:
|
|
209
|
+
"""Получение серверного времени.
|
|
210
|
+
|
|
211
|
+
https://www.bitget.com/api-doc/common/public/Get-Server-Time
|
|
212
|
+
"""
|
|
213
|
+
return await self._make_request("GET", "/api/v2/public/time")
|
|
214
|
+
|
|
215
|
+
async def get_trade_rate(
|
|
216
|
+
self,
|
|
217
|
+
symbol: str,
|
|
218
|
+
business: str,
|
|
219
|
+
) -> dict:
|
|
220
|
+
"""Получение торговой ставки (комиссии) для пары.
|
|
221
|
+
|
|
222
|
+
https://www.bitget.com/api-doc/common/public/Get-Trade-Rate
|
|
223
|
+
"""
|
|
224
|
+
params = {"symbol": symbol, "business": business}
|
|
225
|
+
|
|
226
|
+
return await self._make_request("GET", "/api/v2/common/trade-rate", params=params)
|
|
227
|
+
|
|
228
|
+
async def get_business_line_all_symbol_trade_rate(
|
|
229
|
+
self,
|
|
230
|
+
business: str,
|
|
231
|
+
) -> dict:
|
|
232
|
+
"""Получение торговых ставок по всем парам для заданной линии.
|
|
233
|
+
|
|
234
|
+
https://www.bitget.com/api-doc/common/public/Get-All-Trade-Rate
|
|
235
|
+
"""
|
|
236
|
+
params = {"business": business}
|
|
237
|
+
|
|
238
|
+
return await self._make_request("GET", "/api/v2/common/all-trade-rate", params=params)
|
|
239
|
+
|
|
240
|
+
async def funding_assets(
|
|
241
|
+
self,
|
|
242
|
+
coin: str | None = None,
|
|
243
|
+
) -> dict:
|
|
244
|
+
"""Получение информации о фандинговых активах (балансах).
|
|
245
|
+
|
|
246
|
+
https://www.bitget.com/api-doc/common/account/Funding-Assets
|
|
247
|
+
"""
|
|
248
|
+
params = {"coin": coin}
|
|
249
|
+
|
|
250
|
+
return await self._make_request(
|
|
251
|
+
"GET", "/api/v2/account/funding-assets", params=params, signed=True
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
async def all_account_balance(self) -> dict:
|
|
255
|
+
"""Получение балансов по всем типам аккаунтов.
|
|
256
|
+
|
|
257
|
+
https://www.bitget.com/api-doc/common/account/All-Account-Balance
|
|
258
|
+
"""
|
|
259
|
+
return await self._make_request("GET", "/api/v2/account/all-account-balance", signed=True)
|
|
260
|
+
|
|
261
|
+
# topic: market
|
|
262
|
+
|
|
263
|
+
async def get_coin_info(
|
|
264
|
+
self,
|
|
265
|
+
coin: str | None = None,
|
|
266
|
+
) -> dict:
|
|
267
|
+
"""Получение списка монет (информация по валютам).
|
|
268
|
+
|
|
269
|
+
https://www.bitget.com/api-doc/spot/market/Get-Coin-List
|
|
270
|
+
"""
|
|
271
|
+
params = {"coin": coin}
|
|
272
|
+
|
|
273
|
+
return await self._make_request("GET", "/api/v2/spot/public/coins", params=params)
|
|
274
|
+
|
|
275
|
+
async def get_symbol_info(
|
|
276
|
+
self,
|
|
277
|
+
symbol: str | None = None,
|
|
278
|
+
) -> dict:
|
|
279
|
+
"""Получение списка торговых пар / конфигураций символов.
|
|
280
|
+
|
|
281
|
+
https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
|
282
|
+
"""
|
|
283
|
+
params = {"symbol": symbol}
|
|
284
|
+
|
|
285
|
+
return await self._make_request("GET", "/api/v2/spot/public/symbols", params=params)
|
|
286
|
+
|
|
287
|
+
async def get_vip_fee_rate(self) -> dict:
|
|
288
|
+
"""Получение VIP ставок комиссии на спотовом рынке.
|
|
289
|
+
|
|
290
|
+
https://www.bitget.com/api-doc/spot/market/Get-VIP-Fee-Rate
|
|
291
|
+
"""
|
|
292
|
+
return await self._make_request("GET", "/api/v2/spot/market/vip-fee-rate")
|
|
293
|
+
|
|
294
|
+
async def get_ticker_information(
|
|
295
|
+
self,
|
|
296
|
+
symbol: str | None = None,
|
|
297
|
+
) -> dict:
|
|
298
|
+
"""Получение информации по тикерам (все или конкретная пара).
|
|
299
|
+
|
|
300
|
+
https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
|
301
|
+
"""
|
|
302
|
+
params = {"symbol": symbol}
|
|
303
|
+
|
|
304
|
+
return await self._make_request("GET", "/api/v2/spot/market/tickers", params=params)
|
|
305
|
+
|
|
306
|
+
async def get_merge_depth(
|
|
307
|
+
self,
|
|
308
|
+
symbol: str,
|
|
309
|
+
precision: str | None = None,
|
|
310
|
+
limit: str | None = None,
|
|
311
|
+
) -> dict:
|
|
312
|
+
"""Получение объединённой книги ордеров (merge depth).
|
|
313
|
+
|
|
314
|
+
https://www.bitget.com/api-doc/spot/market/Merge-Orderbook
|
|
315
|
+
"""
|
|
316
|
+
params = {
|
|
317
|
+
"symbol": symbol,
|
|
318
|
+
"precision": precision,
|
|
319
|
+
"limit": limit,
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return await self._make_request("GET", "/api/v2/spot/market/merge-depth", params=params)
|
|
323
|
+
|
|
324
|
+
async def get_orderbook_depth(
|
|
325
|
+
self,
|
|
326
|
+
symbol: str,
|
|
327
|
+
type: str | None = None,
|
|
328
|
+
limit: str | None = None,
|
|
329
|
+
) -> dict:
|
|
330
|
+
"""Получение книги ордеров (orderbook depth).
|
|
331
|
+
|
|
332
|
+
https://www.bitget.com/api-doc/spot/market/Get-Orderbook
|
|
333
|
+
"""
|
|
334
|
+
params = {"symbol": symbol, "type": type, "limit": limit}
|
|
335
|
+
|
|
336
|
+
return await self._make_request("GET", "/api/v2/spot/market/orderbook", params=params)
|
|
337
|
+
|
|
338
|
+
async def get_candlestick_data(
|
|
339
|
+
self,
|
|
340
|
+
symbol: str,
|
|
341
|
+
granularity: str,
|
|
342
|
+
start_time: int | None = None,
|
|
343
|
+
end_time: int | None = None,
|
|
344
|
+
limit: int | None = None,
|
|
345
|
+
) -> list[list]:
|
|
346
|
+
"""Получение данных свечей (klines).
|
|
347
|
+
|
|
348
|
+
https://www.bitget.com/api-doc/spot/market/Get-Candle-Data
|
|
349
|
+
"""
|
|
350
|
+
params = {
|
|
351
|
+
"symbol": symbol,
|
|
352
|
+
"granularity": granularity,
|
|
353
|
+
"startTime": start_time,
|
|
354
|
+
"endTime": end_time,
|
|
355
|
+
"limit": limit,
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return await self._make_request("GET", "/api/v2/spot/market/candles", params=params)
|
|
359
|
+
|
|
360
|
+
async def get_call_auction_information(
|
|
361
|
+
self,
|
|
362
|
+
symbol: str,
|
|
363
|
+
) -> dict:
|
|
364
|
+
"""Получение аукционной информации (если поддерживается).
|
|
365
|
+
|
|
366
|
+
https://www.bitget.com/api-doc/spot/market/Get-Auction
|
|
367
|
+
"""
|
|
368
|
+
params = {"symbol": symbol}
|
|
369
|
+
|
|
370
|
+
return await self._make_request("GET", "/api/v2/spot/market/auction", params=params)
|
|
371
|
+
|
|
372
|
+
async def get_history_candlestick_data(
|
|
373
|
+
self,
|
|
374
|
+
symbol: str,
|
|
375
|
+
granularity: str,
|
|
376
|
+
start_time: int | None = None,
|
|
377
|
+
end_time: int | None = None,
|
|
378
|
+
limit: int | None = None,
|
|
379
|
+
) -> list[list]:
|
|
380
|
+
"""Получение исторических данных свечей.
|
|
381
|
+
|
|
382
|
+
https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data
|
|
383
|
+
"""
|
|
384
|
+
params = {
|
|
385
|
+
"symbol": symbol,
|
|
386
|
+
"granularity": granularity,
|
|
387
|
+
"startTime": start_time,
|
|
388
|
+
"endTime": end_time,
|
|
389
|
+
"limit": limit,
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return await self._make_request("GET", "/api/v2/spot/market/history-candles", params=params)
|
|
393
|
+
|
|
394
|
+
async def get_recent_trades(
|
|
395
|
+
self,
|
|
396
|
+
symbol: str,
|
|
397
|
+
limit: int | None = None,
|
|
398
|
+
) -> dict:
|
|
399
|
+
"""Получение последних совершённых сделок.
|
|
400
|
+
|
|
401
|
+
https://www.bitget.com/api-doc/spot/market/Get-Recent-Trades
|
|
402
|
+
"""
|
|
403
|
+
params = {"symbol": symbol, "limit": limit}
|
|
404
|
+
|
|
405
|
+
return await self._make_request("GET", "/api/v2/spot/market/fills", params=params)
|
|
406
|
+
|
|
407
|
+
async def get_market_trades(
|
|
408
|
+
self,
|
|
409
|
+
symbol: str,
|
|
410
|
+
limit: int | None = None,
|
|
411
|
+
start_time: int | None = None,
|
|
412
|
+
end_time: int | None = None,
|
|
413
|
+
id_less_than: str | None = None,
|
|
414
|
+
) -> dict:
|
|
415
|
+
"""Получение исторических сделок на рынке.
|
|
416
|
+
|
|
417
|
+
https://www.bitget.com/api-doc/spot/market/Get-Market-Trades
|
|
418
|
+
"""
|
|
419
|
+
params = {
|
|
420
|
+
"symbol": symbol,
|
|
421
|
+
"limit": limit,
|
|
422
|
+
"startTime": start_time,
|
|
423
|
+
"endTime": end_time,
|
|
424
|
+
"idLessThan": id_less_than,
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return await self._make_request("GET", "/api/v2/spot/market/fills-history", params=params)
|
|
428
|
+
|
|
429
|
+
# topic: trade
|
|
430
|
+
|
|
431
|
+
async def place_order(
|
|
432
|
+
self,
|
|
433
|
+
symbol: str,
|
|
434
|
+
side: str,
|
|
435
|
+
order_type: str,
|
|
436
|
+
force: str | None = None,
|
|
437
|
+
price: str | None = None,
|
|
438
|
+
size: str | None = None,
|
|
439
|
+
client_oid: str | None = None,
|
|
440
|
+
trigger_price: str | None = None,
|
|
441
|
+
tpsl_type: str | None = None,
|
|
442
|
+
request_time: str | None = None,
|
|
443
|
+
receive_window: str | None = None,
|
|
444
|
+
stp_mode: str | None = None,
|
|
445
|
+
preset_take_profit_price: str | None = None,
|
|
446
|
+
execute_take_profit_price: str | None = None,
|
|
447
|
+
preset_stop_loss_price: str | None = None,
|
|
448
|
+
execute_stop_loss_price: str | None = None,
|
|
449
|
+
) -> dict:
|
|
450
|
+
"""Размещение спотового ордера.
|
|
451
|
+
|
|
452
|
+
https://www.bitget.com/api-doc/spot/trade/Place-Order
|
|
453
|
+
"""
|
|
454
|
+
if order_type == "limit" and not force:
|
|
455
|
+
raise TypeError("force is required for limit order")
|
|
456
|
+
data = {
|
|
457
|
+
"symbol": symbol,
|
|
458
|
+
"side": side,
|
|
459
|
+
"orderType": order_type,
|
|
460
|
+
"force": force,
|
|
461
|
+
"price": price,
|
|
462
|
+
"size": size,
|
|
463
|
+
"clientOid": client_oid,
|
|
464
|
+
"triggerPrice": trigger_price,
|
|
465
|
+
"tpslType": tpsl_type,
|
|
466
|
+
"requestTime": request_time,
|
|
467
|
+
"receiveWindow": receive_window,
|
|
468
|
+
"stpMode": stp_mode,
|
|
469
|
+
"presetTakeProfitPrice": preset_take_profit_price,
|
|
470
|
+
"executeTakeProfitPrice": execute_take_profit_price,
|
|
471
|
+
"presetStopLossPrice": preset_stop_loss_price,
|
|
472
|
+
"executeStopLossPrice": execute_stop_loss_price,
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return await self._make_request(
|
|
476
|
+
"POST", "/api/v2/spot/trade/place-order", data=data, signed=True
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
async def cancel_an_existing_order_and_send_a_new_order(
|
|
480
|
+
self,
|
|
481
|
+
symbol: str,
|
|
482
|
+
price: str,
|
|
483
|
+
size: str,
|
|
484
|
+
order_id: str | None = None,
|
|
485
|
+
client_oid: str | None = None,
|
|
486
|
+
new_client_oid: str | None = None,
|
|
487
|
+
preset_take_profit_price: str | None = None,
|
|
488
|
+
execute_take_profit_price: str | None = None,
|
|
489
|
+
preset_stop_loss_price: str | None = None,
|
|
490
|
+
execute_stop_loss_price: str | None = None,
|
|
491
|
+
) -> dict:
|
|
492
|
+
"""Отмена существующего ордера и размещение нового.
|
|
493
|
+
|
|
494
|
+
https://www.bitget.com/api-doc/spot/trade/Cancel-Replace-Order
|
|
495
|
+
"""
|
|
496
|
+
data = {
|
|
497
|
+
"symbol": symbol,
|
|
498
|
+
"price": price,
|
|
499
|
+
"size": size,
|
|
500
|
+
"orderId": order_id,
|
|
501
|
+
"clientOid": client_oid,
|
|
502
|
+
"newClientOid": new_client_oid,
|
|
503
|
+
"presetTakeProfitPrice": preset_take_profit_price,
|
|
504
|
+
"executeTakeProfitPrice": execute_take_profit_price,
|
|
505
|
+
"presetStopLossPrice": preset_stop_loss_price,
|
|
506
|
+
"executeStopLossPrice": execute_stop_loss_price,
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return await self._make_request(
|
|
510
|
+
"POST", "/api/v2/spot/trade/cancel-replace-order", data=data, signed=True
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
async def batch_cancel_existing_order_and_send_new_orders(
|
|
514
|
+
self,
|
|
515
|
+
order_list: list[dict],
|
|
516
|
+
) -> dict:
|
|
517
|
+
"""Пакетная отмена существующих ордеров и размещение новых.
|
|
518
|
+
|
|
519
|
+
https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Replace-Order
|
|
520
|
+
"""
|
|
521
|
+
data = {"orderList": order_list}
|
|
522
|
+
|
|
523
|
+
return await self._make_request(
|
|
524
|
+
"POST", "/api/v2/spot/trade/batch-cancel-replace-order", data=data, signed=True
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
async def cancel_order(
|
|
528
|
+
self,
|
|
529
|
+
symbol: str,
|
|
530
|
+
order_id: str | None = None,
|
|
531
|
+
client_oid: str | None = None,
|
|
532
|
+
tpsl_type: str | None = None,
|
|
533
|
+
) -> dict:
|
|
534
|
+
"""Отмена спотового ордера.
|
|
535
|
+
|
|
536
|
+
https://www.bitget.com/api-doc/spot/trade/Cancel-Order
|
|
537
|
+
"""
|
|
538
|
+
data = {
|
|
539
|
+
"symbol": symbol,
|
|
540
|
+
"orderId": order_id,
|
|
541
|
+
"clientOid": client_oid,
|
|
542
|
+
"tpslType": tpsl_type,
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return await self._make_request(
|
|
546
|
+
"POST", "/api/v2/spot/trade/cancel-order", data=data, signed=True
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
async def batch_place_orders(
|
|
550
|
+
self,
|
|
551
|
+
symbol: str,
|
|
552
|
+
batch_mode: str | None = None,
|
|
553
|
+
order_list: list[dict] | None = None,
|
|
554
|
+
) -> dict:
|
|
555
|
+
"""Пакетное размещение спотовых ордеров.
|
|
556
|
+
|
|
557
|
+
https://www.bitget.com/api-doc/spot/trade/Batch-Place-Orders
|
|
558
|
+
"""
|
|
559
|
+
if not order_list:
|
|
560
|
+
raise TypeError("order_list is required")
|
|
561
|
+
data = {"symbol": symbol, "orderList": order_list, "batchMode": batch_mode}
|
|
562
|
+
|
|
563
|
+
return await self._make_request(
|
|
564
|
+
"POST", "/api/v2/spot/trade/batch-orders", data=data, signed=True
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
async def batch_cancel_orders(
|
|
568
|
+
self,
|
|
569
|
+
symbol: str | None = None,
|
|
570
|
+
batch_mode: str | None = None,
|
|
571
|
+
order_list: list[dict] | None = None,
|
|
572
|
+
) -> dict:
|
|
573
|
+
"""Пакетная отмена спотовых ордеров.
|
|
574
|
+
|
|
575
|
+
https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Orders
|
|
576
|
+
"""
|
|
577
|
+
if not order_list:
|
|
578
|
+
raise TypeError("order_list is required")
|
|
579
|
+
data = {"symbol": symbol, "batchMode": batch_mode, "orderList": order_list}
|
|
580
|
+
|
|
581
|
+
return await self._make_request(
|
|
582
|
+
"POST", "/api/v2/spot/trade/batch-cancel-order", data=data, signed=True
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
async def cancel_order_by_symbol(
|
|
586
|
+
self,
|
|
587
|
+
symbol: str,
|
|
588
|
+
) -> dict:
|
|
589
|
+
"""Отмена всех открытых ордеров по символу.
|
|
590
|
+
|
|
591
|
+
https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
|
|
592
|
+
"""
|
|
593
|
+
data = {"symbol": symbol}
|
|
594
|
+
|
|
595
|
+
return await self._make_request(
|
|
596
|
+
"POST", "/api/v2/spot/trade/cancel-symbol-order", data=data, signed=True
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
async def get_order_info(
|
|
600
|
+
self,
|
|
601
|
+
order_id: str | None = None,
|
|
602
|
+
client_oid: str | None = None,
|
|
603
|
+
request_time: int | None = None,
|
|
604
|
+
receive_window: int | None = None,
|
|
605
|
+
) -> dict:
|
|
606
|
+
"""Получение информации об ордере.
|
|
607
|
+
|
|
608
|
+
https://www.bitget.com/api-doc/spot/trade/Get-Order-Info
|
|
609
|
+
"""
|
|
610
|
+
if not any([order_id, client_oid]):
|
|
611
|
+
raise TypeError("either order_id or client_oid is required.")
|
|
612
|
+
params = {
|
|
613
|
+
"orderId": order_id,
|
|
614
|
+
"clientOid": client_oid,
|
|
615
|
+
"requestTime": request_time,
|
|
616
|
+
"receiveWindow": receive_window,
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return await self._make_request(
|
|
620
|
+
"GET", "/api/v2/spot/trade/orderInfo", params=params, signed=True
|
|
621
|
+
)
|
|
622
|
+
|
|
623
|
+
async def get_current_orders(
|
|
624
|
+
self,
|
|
625
|
+
symbol: str | None = None,
|
|
626
|
+
start_time: int | None = None,
|
|
627
|
+
end_time: int | None = None,
|
|
628
|
+
id_less_than: str | None = None,
|
|
629
|
+
limit: int | None = None,
|
|
630
|
+
order_id: str | None = None,
|
|
631
|
+
tpsl_type: str | None = None,
|
|
632
|
+
request_time: int | None = None,
|
|
633
|
+
receive_window: int | None = None,
|
|
634
|
+
) -> dict:
|
|
635
|
+
"""Получение списка активных (не исполненных) ордеров.
|
|
636
|
+
|
|
637
|
+
https://www.bitget.com/api-doc/spot/trade/Get-Unfilled-Orders
|
|
638
|
+
"""
|
|
639
|
+
params = {
|
|
640
|
+
"symbol": symbol,
|
|
641
|
+
"startTime": start_time,
|
|
642
|
+
"endTime": end_time,
|
|
643
|
+
"idLessThan": id_less_than,
|
|
644
|
+
"limit": limit,
|
|
645
|
+
"orderId": order_id,
|
|
646
|
+
"tpslType": tpsl_type,
|
|
647
|
+
"requestTime": request_time,
|
|
648
|
+
"receiveWindow": receive_window,
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
return await self._make_request(
|
|
652
|
+
"GET", "/api/v2/spot/trade/unfilled-orders", params=params, signed=True
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
async def get_history_orders(
|
|
656
|
+
self,
|
|
657
|
+
symbol: str | None = None,
|
|
658
|
+
start_time: int | None = None,
|
|
659
|
+
end_time: int | None = None,
|
|
660
|
+
id_less_than: str | None = None,
|
|
661
|
+
limit: int | None = None,
|
|
662
|
+
order_id: str | None = None,
|
|
663
|
+
tpsl_type: str | None = None,
|
|
664
|
+
request_time: int | None = None,
|
|
665
|
+
receive_window: int | None = None,
|
|
666
|
+
) -> dict:
|
|
667
|
+
"""Получение истории ордеров (за последние 90 дней).
|
|
668
|
+
|
|
669
|
+
https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
|
670
|
+
"""
|
|
671
|
+
params = {
|
|
672
|
+
"symbol": symbol,
|
|
673
|
+
"startTime": start_time,
|
|
674
|
+
"endTime": end_time,
|
|
675
|
+
"idLessThan": id_less_than,
|
|
676
|
+
"limit": limit,
|
|
677
|
+
"orderId": order_id,
|
|
678
|
+
"tpslType": tpsl_type,
|
|
679
|
+
"requestTime": request_time,
|
|
680
|
+
"receiveWindow": receive_window,
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return await self._make_request(
|
|
684
|
+
"GET", "/api/v2/spot/trade/history-orders", params=params, signed=True
|
|
685
|
+
)
|
|
686
|
+
|
|
687
|
+
async def get_fills(
|
|
688
|
+
self,
|
|
689
|
+
symbol: str | None = None,
|
|
690
|
+
order_id: str | None = None,
|
|
691
|
+
start_time: int | None = None,
|
|
692
|
+
end_time: int | None = None,
|
|
693
|
+
limit: int | None = None,
|
|
694
|
+
id_less_than: str | None = None,
|
|
695
|
+
) -> dict:
|
|
696
|
+
"""Получение списка исполненных сделок (fills).
|
|
697
|
+
|
|
698
|
+
https://www.bitget.com/api-doc/spot/trade/Get-Fills
|
|
699
|
+
"""
|
|
700
|
+
params = {
|
|
701
|
+
"symbol": symbol,
|
|
702
|
+
"orderId": order_id,
|
|
703
|
+
"startTime": start_time,
|
|
704
|
+
"endTime": end_time,
|
|
705
|
+
"limit": limit,
|
|
706
|
+
"idLessThan": id_less_than,
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return await self._make_request(
|
|
710
|
+
"GET", "/api/v2/spot/trade/fills", params=params, signed=True
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
# topic: trigger
|
|
714
|
+
|
|
715
|
+
async def place_plan_order(
|
|
716
|
+
self,
|
|
717
|
+
symbol: str,
|
|
718
|
+
side: str,
|
|
719
|
+
trigger_price: str,
|
|
720
|
+
order_type: str,
|
|
721
|
+
size: str | float,
|
|
722
|
+
trigger_type: str,
|
|
723
|
+
execute_price: str | None = None,
|
|
724
|
+
plan_type: str | None = None,
|
|
725
|
+
client_oid: str | None = None,
|
|
726
|
+
stp_mode: str | None = None,
|
|
727
|
+
) -> dict:
|
|
728
|
+
"""Размещение планового ордера (trigger / conditional order).
|
|
729
|
+
|
|
730
|
+
https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
|
|
731
|
+
"""
|
|
732
|
+
data = {
|
|
733
|
+
"symbol": symbol,
|
|
734
|
+
"side": side,
|
|
735
|
+
"triggerPrice": trigger_price,
|
|
736
|
+
"orderType": order_type,
|
|
737
|
+
"size": size,
|
|
738
|
+
"triggerType": trigger_type,
|
|
739
|
+
"executePrice": execute_price,
|
|
740
|
+
"planType": plan_type,
|
|
741
|
+
"clientOid": client_oid,
|
|
742
|
+
"stpMode": stp_mode,
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
return await self._make_request(
|
|
746
|
+
"POST", "/api/v2/spot/trade/place-plan-order", data=data, signed=True
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
async def modify_plan_order(
|
|
750
|
+
self,
|
|
751
|
+
trigger_price: str,
|
|
752
|
+
size: str | float,
|
|
753
|
+
order_type: str,
|
|
754
|
+
order_id: str | None = None,
|
|
755
|
+
client_oid: str | None = None,
|
|
756
|
+
execute_price: str | None = None,
|
|
757
|
+
) -> dict:
|
|
758
|
+
"""Изменение планового ордера (trigger order).
|
|
759
|
+
|
|
760
|
+
https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
|
|
761
|
+
"""
|
|
762
|
+
if not any([order_id, client_oid]):
|
|
763
|
+
raise TypeError("either order_id or client_oid is required.")
|
|
764
|
+
data = {
|
|
765
|
+
"orderId": order_id,
|
|
766
|
+
"clientOid": client_oid,
|
|
767
|
+
"triggerPrice": trigger_price,
|
|
768
|
+
"executePrice": execute_price,
|
|
769
|
+
"size": size,
|
|
770
|
+
"orderType": order_type,
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
return await self._make_request("POST", "/api/v2/spot/trade/modify-plan-order", data=data)
|
|
774
|
+
|
|
775
|
+
async def cancel_plan_order(
|
|
776
|
+
self,
|
|
777
|
+
order_id: str | None = None,
|
|
778
|
+
client_oid: str | None = None,
|
|
779
|
+
) -> dict:
|
|
780
|
+
"""Отмена планового ордера.
|
|
781
|
+
|
|
782
|
+
https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order
|
|
783
|
+
"""
|
|
784
|
+
if not any([order_id, client_oid]):
|
|
785
|
+
raise TypeError("either order_id or client_oid is required.")
|
|
786
|
+
data = {"orderId": order_id, "clientOid": client_oid}
|
|
787
|
+
|
|
788
|
+
return await self._make_request(
|
|
789
|
+
"POST", "/api/v2/spot/trade/cancel-plan-order", data=data, signed=True
|
|
790
|
+
)
|
|
791
|
+
|
|
792
|
+
async def get_current_plan_orders(
|
|
793
|
+
self,
|
|
794
|
+
symbol: str,
|
|
795
|
+
limit: int | None = None,
|
|
796
|
+
id_less_than: str | None = None,
|
|
797
|
+
start_time: int | None = None,
|
|
798
|
+
end_time: int | None = None,
|
|
799
|
+
) -> dict:
|
|
800
|
+
"""Получение текущих плановых (trigger) ордеров.
|
|
801
|
+
|
|
802
|
+
https://www.bitget.com/api-doc/spot/plan/Get-Current-Plan-Order
|
|
803
|
+
"""
|
|
804
|
+
params = {
|
|
805
|
+
"symbol": symbol,
|
|
806
|
+
"limit": limit,
|
|
807
|
+
"idLessThan": id_less_than,
|
|
808
|
+
"startTime": start_time,
|
|
809
|
+
"endTime": end_time,
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
return await self._make_request(
|
|
813
|
+
"GET", "/api/v2/spot/trade/current-plan-order", params=params, signed=True
|
|
814
|
+
)
|
|
815
|
+
|
|
816
|
+
async def get_plan_sub_order(
|
|
817
|
+
self,
|
|
818
|
+
plan_order_id: str,
|
|
819
|
+
) -> dict:
|
|
820
|
+
"""Получение списка суб-ордеров (исполненных частей планового ордера).
|
|
821
|
+
|
|
822
|
+
https://www.bitget.com/api-doc/spot/plan/Get-Plan-Sub-Order
|
|
823
|
+
"""
|
|
824
|
+
params = {"planOrderId": plan_order_id}
|
|
825
|
+
|
|
826
|
+
return await self._make_request(
|
|
827
|
+
"GET", "/api/v2/spot/trade/plan-sub-order", params=params, signed=True
|
|
828
|
+
)
|
|
829
|
+
|
|
830
|
+
async def get_history_plan_orders(
|
|
831
|
+
self,
|
|
832
|
+
symbol: str,
|
|
833
|
+
start_time: int,
|
|
834
|
+
end_time: int,
|
|
835
|
+
limit: int | None = None,
|
|
836
|
+
id_less_than: str | None = None,
|
|
837
|
+
) -> dict:
|
|
838
|
+
"""Получение истории плановых ордеров (за период).
|
|
839
|
+
|
|
840
|
+
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
|
841
|
+
"""
|
|
842
|
+
params = {
|
|
843
|
+
"symbol": symbol,
|
|
844
|
+
"startTime": start_time,
|
|
845
|
+
"endTime": end_time,
|
|
846
|
+
"limit": limit,
|
|
847
|
+
"idLessThan": id_less_than,
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return await self._make_request(
|
|
851
|
+
"GET", "/api/v2/spot/trade/history-plan-order", params=params, signed=True
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
async def cancel_plan_orders_in_batch(
|
|
855
|
+
self,
|
|
856
|
+
symbol_list: list[str],
|
|
857
|
+
) -> dict:
|
|
858
|
+
"""Пакетная отмена плановых ордеров по списку символов.
|
|
859
|
+
|
|
860
|
+
https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
|
|
861
|
+
"""
|
|
862
|
+
data = {"symbolList": symbol_list}
|
|
863
|
+
|
|
864
|
+
return await self._make_request(
|
|
865
|
+
"POST", "/api/v2/spot/trade/batch-cancel-plan-order", data=data, signed=True
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
# topic: account
|
|
869
|
+
|
|
870
|
+
async def get_account_information(self) -> dict:
|
|
871
|
+
"""Получение информации об аккаунте.
|
|
872
|
+
|
|
873
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Info
|
|
874
|
+
"""
|
|
875
|
+
return await self._make_request("GET", "/api/v2/spot/account/info", signed=True)
|
|
876
|
+
|
|
877
|
+
async def get_account_assets(
|
|
878
|
+
self,
|
|
879
|
+
coin: str | None = None,
|
|
880
|
+
asset_type: str | None = None,
|
|
881
|
+
) -> dict:
|
|
882
|
+
"""Получение списка активов на спотовом аккаунте.
|
|
883
|
+
|
|
884
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Assets
|
|
885
|
+
"""
|
|
886
|
+
params = {"coin": coin, "assetType": asset_type}
|
|
887
|
+
|
|
888
|
+
return await self._make_request(
|
|
889
|
+
"GET", "/api/v2/spot/account/assets", signed=True, params=params
|
|
890
|
+
)
|
|
891
|
+
|
|
892
|
+
async def get_sub_account_assets(
|
|
893
|
+
self,
|
|
894
|
+
id_less_than: str | None = None,
|
|
895
|
+
limit: int | None = None,
|
|
896
|
+
) -> dict:
|
|
897
|
+
"""Получение списка активов на спотовом аккаунте.
|
|
898
|
+
|
|
899
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Assets
|
|
900
|
+
"""
|
|
901
|
+
params = {"idLessThan": id_less_than, "limit": limit}
|
|
902
|
+
|
|
903
|
+
return await self._make_request(
|
|
904
|
+
"GET", "/api/v2/spot/account/subaccount-assets", signed=True, params=params
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
async def modify_deposit_account(
|
|
908
|
+
self,
|
|
909
|
+
account_type: str,
|
|
910
|
+
coin: str,
|
|
911
|
+
) -> dict:
|
|
912
|
+
"""Изменение типа авто-трансфера депозита на спотовом аккаунте.
|
|
913
|
+
|
|
914
|
+
https://www.bitget.com/api-doc/spot/account/Modify-Deposit-Account
|
|
915
|
+
"""
|
|
916
|
+
params = {"accountType": account_type, "coin": coin}
|
|
917
|
+
|
|
918
|
+
return await self._make_request(
|
|
919
|
+
"POST", "/api/v2/spot/wallet/modify-deposit-account", signed=True, params=params
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
async def get_account_billd(
|
|
923
|
+
self,
|
|
924
|
+
coin: str | None = None,
|
|
925
|
+
group_type: str | None = None,
|
|
926
|
+
businessType: str | None = None,
|
|
927
|
+
start_time: str | None = None,
|
|
928
|
+
end_time: str | None = None,
|
|
929
|
+
limit: int | None = None,
|
|
930
|
+
id_less_than: str | None = None,
|
|
931
|
+
) -> dict:
|
|
932
|
+
"""Возвращает счета аккаунта.
|
|
933
|
+
|
|
934
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
|
935
|
+
"""
|
|
936
|
+
params = {
|
|
937
|
+
"coin": coin,
|
|
938
|
+
"groupType": group_type,
|
|
939
|
+
"businessType": businessType,
|
|
940
|
+
"startTime": start_time,
|
|
941
|
+
"endTime": end_time,
|
|
942
|
+
"limit": limit,
|
|
943
|
+
"idLessThan": id_less_than,
|
|
944
|
+
}
|
|
945
|
+
return await self._make_request(
|
|
946
|
+
"GET", "/api/v2/spot/account/bills", signed=True, params=params
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
async def transfer(
|
|
950
|
+
self,
|
|
951
|
+
from_type: str,
|
|
952
|
+
to_type: str,
|
|
953
|
+
amount: str | float,
|
|
954
|
+
coin: str,
|
|
955
|
+
symbol: str,
|
|
956
|
+
client_oid: str | None = None,
|
|
957
|
+
) -> dict:
|
|
958
|
+
"""Совершает перевод между типами аккаунтов внутри биржи.
|
|
959
|
+
|
|
960
|
+
https://www.bitget.com/api-doc/spot/account/Wallet-Transfer
|
|
961
|
+
"""
|
|
962
|
+
params = {
|
|
963
|
+
"fromType": from_type,
|
|
964
|
+
"toType": to_type,
|
|
965
|
+
"amount": amount,
|
|
966
|
+
"coin": coin,
|
|
967
|
+
"symbol": symbol,
|
|
968
|
+
"clientOid": client_oid,
|
|
969
|
+
}
|
|
970
|
+
return await self._make_request(
|
|
971
|
+
"POST", "/api/v2/spot/wallet/transfer", signed=True, params=params
|
|
972
|
+
)
|
|
973
|
+
|
|
974
|
+
async def get_transferable_coin_list(
|
|
975
|
+
self,
|
|
976
|
+
from_type: str,
|
|
977
|
+
to_type: str,
|
|
978
|
+
) -> dict:
|
|
979
|
+
"""Получить список монет, которые можно переводить между аккаунтами.
|
|
980
|
+
|
|
981
|
+
https://www.bitget.com/api-doc/spot/account/Get-Transfer-Coins
|
|
982
|
+
"""
|
|
983
|
+
params = {
|
|
984
|
+
"fromType": from_type,
|
|
985
|
+
"toType": to_type,
|
|
986
|
+
}
|
|
987
|
+
return await self._make_request(
|
|
988
|
+
"GET", "/api/v2/spot/wallet/transfer-coin-info", signed=True, params=params
|
|
989
|
+
)
|
|
990
|
+
|
|
991
|
+
async def sub_transfer(
|
|
992
|
+
self,
|
|
993
|
+
from_type: str,
|
|
994
|
+
to_type: str,
|
|
995
|
+
amount: float,
|
|
996
|
+
coin: str,
|
|
997
|
+
symbol: str | None = None,
|
|
998
|
+
client_oid: str | None = None,
|
|
999
|
+
from_user_id: str | None = None,
|
|
1000
|
+
to_user_id: str | None = None,
|
|
1001
|
+
) -> None:
|
|
1002
|
+
"""Перевод между саб-аккаунтами.
|
|
1003
|
+
|
|
1004
|
+
https://www.bitget.com/api-doc/spot/account/Sub-Transfer
|
|
1005
|
+
"""
|
|
1006
|
+
params = {
|
|
1007
|
+
"fromType": from_type,
|
|
1008
|
+
"toType": to_type,
|
|
1009
|
+
"amount": amount,
|
|
1010
|
+
"coin": coin,
|
|
1011
|
+
"symbol": symbol,
|
|
1012
|
+
"clientOid": client_oid,
|
|
1013
|
+
"fromUserId": from_user_id,
|
|
1014
|
+
"toUserId": to_user_id,
|
|
1015
|
+
}
|
|
1016
|
+
return await self._make_request(
|
|
1017
|
+
"POST", "/api/v2/spot/wallet/subaccount-transfer", signed=True, params=params
|
|
1018
|
+
)
|
|
1019
|
+
|
|
1020
|
+
async def withdraw(
|
|
1021
|
+
self,
|
|
1022
|
+
coin: str,
|
|
1023
|
+
transfer_type: str,
|
|
1024
|
+
address: str,
|
|
1025
|
+
chain: str | None = None,
|
|
1026
|
+
inner_to_type: str | None = None,
|
|
1027
|
+
area_code: str | None = None,
|
|
1028
|
+
tag: str | None = None,
|
|
1029
|
+
size: str | float | None = None,
|
|
1030
|
+
remark: str | None = None,
|
|
1031
|
+
client_oid: str | None = None,
|
|
1032
|
+
member_code: str | None = None,
|
|
1033
|
+
identity_type: str | None = None,
|
|
1034
|
+
company_name: str | None = None,
|
|
1035
|
+
first_name: str | None = None,
|
|
1036
|
+
last_name: str | None = None,
|
|
1037
|
+
) -> dict:
|
|
1038
|
+
"""Вывод средств с аккаунта.
|
|
1039
|
+
|
|
1040
|
+
https://www.bitget.com/api-doc/spot/account/Wallet-Withdrawal
|
|
1041
|
+
"""
|
|
1042
|
+
params = {
|
|
1043
|
+
"coin": coin,
|
|
1044
|
+
"transferType": transfer_type,
|
|
1045
|
+
"address": address,
|
|
1046
|
+
"chain": chain,
|
|
1047
|
+
"innerToType": inner_to_type,
|
|
1048
|
+
"areaCode": area_code,
|
|
1049
|
+
"tag": tag,
|
|
1050
|
+
"size": size,
|
|
1051
|
+
"remark": remark,
|
|
1052
|
+
"clientOid": client_oid,
|
|
1053
|
+
"memberCode": member_code,
|
|
1054
|
+
"identityType": identity_type,
|
|
1055
|
+
"companyName": company_name,
|
|
1056
|
+
"firstName": first_name,
|
|
1057
|
+
"lastName": last_name,
|
|
1058
|
+
}
|
|
1059
|
+
return await self._make_request("POST", "/api/v2/spot/wallet/withdrawal", params=params)
|
|
1060
|
+
|
|
1061
|
+
# https://www.bitget.com/api-doc/spot/account/Get-SubAccount-TransferRecords
|
|
1062
|
+
# https://www.bitget.com/api-doc/spot/account/Get-Account-TransferRecords
|
|
1063
|
+
# https://www.bitget.com/api-doc/spot/account/Switch-Deduct
|
|
1064
|
+
# https://www.bitget.com/api-doc/spot/account/Get-Deposit-Address
|
|
1065
|
+
# https://www.bitget.com/api-doc/spot/account/Get-SubAccount-Deposit-Address
|
|
1066
|
+
# https://www.bitget.com/api-doc/spot/account/Get-Deduct-Info
|
|
1067
|
+
# https://www.bitget.com/api-doc/spot/account/Cancel-Withdrawal
|
|
1068
|
+
# https://www.bitget.com/api-doc/spot/account/Get-SubAccount-Deposit-Record
|
|
1069
|
+
# https://www.bitget.com/api-doc/spot/account/Get-Withdraw-Record
|
|
1070
|
+
# https://www.bitget.com/api-doc/spot/account/Get-Deposit-Record
|
|
1071
|
+
# https://www.bitget.com/api-doc/spot/account/Upgrade_Account
|
|
1072
|
+
# https://www.bitget.com/api-doc/spot/account/Get_Upgrade_Status
|
|
1073
|
+
|
|
1074
|
+
async def futures_vip_fee_rate(self) -> dict:
|
|
1075
|
+
"""Получение VIP ставок комиссии на фьючерсном рынке.
|
|
1076
|
+
|
|
1077
|
+
https://www.bitget.com/api-doc/contract/market/Get-VIP-Fee-Rate
|
|
1078
|
+
"""
|
|
1079
|
+
return await self._make_request("GET", "/api/v2/mix/market/vip-fee-rate")
|
|
1080
|
+
|
|
1081
|
+
async def futures_interest_rate_history(self, coin: str) -> dict:
|
|
1082
|
+
"""Получение истории открытого интереса.
|
|
1083
|
+
|
|
1084
|
+
https://www.bitget.com/api-doc/contract/market/Get-Interest-Rate
|
|
1085
|
+
"""
|
|
1086
|
+
return await self._make_request("GET", "/api/v2/mix/market/union-interest-rate-history")
|
|
1087
|
+
|
|
1088
|
+
async def futures_interest_exchange_rate(self) -> dict:
|
|
1089
|
+
"""Получение тир листа и лимитов монет.
|
|
1090
|
+
|
|
1091
|
+
https://www.bitget.com/api-doc/contract/market/Get-Exchange-Rate
|
|
1092
|
+
"""
|
|
1093
|
+
return await self._make_request("GET", "/api/v2/mix/market/exchange-rate")
|
|
1094
|
+
|
|
1095
|
+
async def futures_discount_rate(self) -> dict:
|
|
1096
|
+
"""Получение списка скидок на фьючерсный рынок.
|
|
1097
|
+
|
|
1098
|
+
https://www.bitget.com/api-doc/contract/market/Get-Discount-Rate
|
|
1099
|
+
"""
|
|
1100
|
+
return await self._make_request("GET", "/api/v2/mix/market/discount-rate")
|
|
1101
|
+
|
|
1102
|
+
async def futures_get_merge_depth(
|
|
1103
|
+
self,
|
|
1104
|
+
symbol: str,
|
|
1105
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1106
|
+
precision: str | None = None,
|
|
1107
|
+
limit: str | None = None,
|
|
1108
|
+
) -> dict:
|
|
1109
|
+
"""Получить объединённые данные глубины рынка.
|
|
1110
|
+
|
|
1111
|
+
https://www.bitget.com/api-doc/contract/market/Get-Merge-Depth
|
|
1112
|
+
"""
|
|
1113
|
+
params = {
|
|
1114
|
+
"symbol": symbol,
|
|
1115
|
+
"productType": product_type,
|
|
1116
|
+
"precision": precision,
|
|
1117
|
+
"limit": limit,
|
|
1118
|
+
}
|
|
1119
|
+
return await self._make_request("GET", "/api/v2/mix/market/merge-depth", params=params)
|
|
1120
|
+
|
|
1121
|
+
async def futures_get_ticker(
|
|
1122
|
+
self,
|
|
1123
|
+
symbol: str,
|
|
1124
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1125
|
+
) -> dict:
|
|
1126
|
+
"""Получить данные тикера по инструменту.
|
|
1127
|
+
|
|
1128
|
+
https://www.bitget.com/api-doc/contract/market/Get-Ticker
|
|
1129
|
+
"""
|
|
1130
|
+
params = {
|
|
1131
|
+
"symbol": symbol,
|
|
1132
|
+
"productType": product_type,
|
|
1133
|
+
}
|
|
1134
|
+
return await self._make_request("GET", "/api/v2/mix/market/ticker", params=params)
|
|
1135
|
+
|
|
1136
|
+
async def futures_get_all_tickers(
|
|
1137
|
+
self,
|
|
1138
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1139
|
+
) -> dict:
|
|
1140
|
+
"""Получить данные всех тикеров по типу продукта.
|
|
1141
|
+
|
|
1142
|
+
https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
|
|
1143
|
+
"""
|
|
1144
|
+
params = {
|
|
1145
|
+
"productType": product_type,
|
|
1146
|
+
}
|
|
1147
|
+
return await self._make_request("GET", "/api/v2/mix/market/tickers", params=params)
|
|
1148
|
+
|
|
1149
|
+
async def futures_get_recent_fills(
|
|
1150
|
+
self,
|
|
1151
|
+
symbol: str,
|
|
1152
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1153
|
+
limit: int | None = 100,
|
|
1154
|
+
) -> dict:
|
|
1155
|
+
"""Получить последние сделки по тикеру.
|
|
1156
|
+
|
|
1157
|
+
https://www.bitget.com/api-doc/contract/market/Get-Recent-Fills
|
|
1158
|
+
"""
|
|
1159
|
+
params = {
|
|
1160
|
+
"symbol": symbol,
|
|
1161
|
+
"productType": product_type,
|
|
1162
|
+
"limit": limit,
|
|
1163
|
+
}
|
|
1164
|
+
return await self._make_request("GET", "/api/v2/mix/market/fills", params=params)
|
|
1165
|
+
|
|
1166
|
+
async def futures_get_fills_history(
|
|
1167
|
+
self,
|
|
1168
|
+
symbol: str,
|
|
1169
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1170
|
+
limit: int | None = 500,
|
|
1171
|
+
id_less_than: str | None = None,
|
|
1172
|
+
start_time: int | None = None,
|
|
1173
|
+
end_time: int | None = None,
|
|
1174
|
+
) -> dict:
|
|
1175
|
+
"""Получить историю сделок за последние 90 дней.
|
|
1176
|
+
|
|
1177
|
+
https://www.bitget.com/api-doc/contract/market/Get-Fills-History
|
|
1178
|
+
"""
|
|
1179
|
+
params = {
|
|
1180
|
+
"symbol": symbol,
|
|
1181
|
+
"productType": product_type,
|
|
1182
|
+
"limit": limit,
|
|
1183
|
+
"idLessThan": id_less_than,
|
|
1184
|
+
"startTime": start_time,
|
|
1185
|
+
"endTime": end_time,
|
|
1186
|
+
}
|
|
1187
|
+
return await self._make_request("GET", "/api/v2/mix/market/fills-history", params=params)
|
|
1188
|
+
|
|
1189
|
+
async def futures_get_candlestick_data(
|
|
1190
|
+
self,
|
|
1191
|
+
symbol: str,
|
|
1192
|
+
granularity: str,
|
|
1193
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1194
|
+
start_time: int | None = None,
|
|
1195
|
+
end_time: int | None = None,
|
|
1196
|
+
kline_type: str | None = "MARKET",
|
|
1197
|
+
limit: int | None = 100,
|
|
1198
|
+
) -> dict:
|
|
1199
|
+
"""Получить данные свечей по инструменту.
|
|
1200
|
+
|
|
1201
|
+
https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
|
|
1202
|
+
"""
|
|
1203
|
+
params = {
|
|
1204
|
+
"symbol": symbol,
|
|
1205
|
+
"productType": product_type,
|
|
1206
|
+
"granularity": granularity,
|
|
1207
|
+
"startTime": start_time,
|
|
1208
|
+
"endTime": end_time,
|
|
1209
|
+
"kLineType": kline_type,
|
|
1210
|
+
"limit": limit,
|
|
1211
|
+
}
|
|
1212
|
+
return await self._make_request("GET", "/api/v2/mix/market/candles", params=params)
|
|
1213
|
+
|
|
1214
|
+
async def futures_get_history_candlestick_data(
|
|
1215
|
+
self,
|
|
1216
|
+
symbol: str,
|
|
1217
|
+
granularity: str,
|
|
1218
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1219
|
+
start_time: int | None = None,
|
|
1220
|
+
end_time: int | None = None,
|
|
1221
|
+
limit: int | None = 100,
|
|
1222
|
+
) -> dict:
|
|
1223
|
+
"""Получить исторические свечи по инструменту.
|
|
1224
|
+
|
|
1225
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data
|
|
1226
|
+
"""
|
|
1227
|
+
params = {
|
|
1228
|
+
"symbol": symbol,
|
|
1229
|
+
"productType": product_type,
|
|
1230
|
+
"granularity": granularity,
|
|
1231
|
+
"startTime": start_time,
|
|
1232
|
+
"endTime": end_time,
|
|
1233
|
+
"limit": limit,
|
|
1234
|
+
}
|
|
1235
|
+
return await self._make_request("GET", "/api/v2/mix/market/history-candles", params=params)
|
|
1236
|
+
|
|
1237
|
+
async def futures_get_history_index_candlestick_data(
|
|
1238
|
+
self,
|
|
1239
|
+
symbol: str,
|
|
1240
|
+
granularity: str,
|
|
1241
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1242
|
+
start_time: int | None = None,
|
|
1243
|
+
end_time: int | None = None,
|
|
1244
|
+
limit: int | None = 100,
|
|
1245
|
+
) -> dict:
|
|
1246
|
+
"""Получить исторические свечи по индексу контракта.
|
|
1247
|
+
|
|
1248
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data
|
|
1249
|
+
"""
|
|
1250
|
+
params = {
|
|
1251
|
+
"symbol": symbol,
|
|
1252
|
+
"productType": product_type,
|
|
1253
|
+
"granularity": granularity,
|
|
1254
|
+
"startTime": start_time,
|
|
1255
|
+
"endTime": end_time,
|
|
1256
|
+
"limit": limit,
|
|
1257
|
+
}
|
|
1258
|
+
return await self._make_request(
|
|
1259
|
+
"GET", "/api/v2/mix/market/history-index-candles", params=params
|
|
1260
|
+
)
|
|
1261
|
+
|
|
1262
|
+
async def futures_get_history_mark_candlestick_data(
|
|
1263
|
+
self,
|
|
1264
|
+
symbol: str,
|
|
1265
|
+
granularity: str,
|
|
1266
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1267
|
+
start_time: int | None = None,
|
|
1268
|
+
end_time: int | None = None,
|
|
1269
|
+
limit: int | None = 100,
|
|
1270
|
+
) -> dict:
|
|
1271
|
+
"""Получить исторические свечи по mark price контракта.
|
|
1272
|
+
|
|
1273
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-Data
|
|
1274
|
+
"""
|
|
1275
|
+
params = {
|
|
1276
|
+
"symbol": symbol,
|
|
1277
|
+
"productType": product_type,
|
|
1278
|
+
"granularity": granularity,
|
|
1279
|
+
"startTime": start_time,
|
|
1280
|
+
"endTime": end_time,
|
|
1281
|
+
"limit": limit,
|
|
1282
|
+
}
|
|
1283
|
+
return await self._make_request(
|
|
1284
|
+
"GET", "/api/v2/mix/market/history-mark-candles", params=params
|
|
1285
|
+
)
|
|
1286
|
+
|
|
1287
|
+
async def futures_get_open_interest(
|
|
1288
|
+
self,
|
|
1289
|
+
symbol: str,
|
|
1290
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1291
|
+
) -> dict:
|
|
1292
|
+
"""Получить общий объем открытых позиций по паре.
|
|
1293
|
+
|
|
1294
|
+
https://www.bitget.com/api-doc/contract/market/Get-Open-Interest
|
|
1295
|
+
"""
|
|
1296
|
+
params = {
|
|
1297
|
+
"symbol": symbol,
|
|
1298
|
+
"productType": product_type,
|
|
1299
|
+
}
|
|
1300
|
+
return await self._make_request("GET", "/api/v2/mix/market/open-interest", params=params)
|
|
1301
|
+
|
|
1302
|
+
async def futures_get_next_funding_time(
|
|
1303
|
+
self,
|
|
1304
|
+
symbol: str,
|
|
1305
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1306
|
+
) -> dict:
|
|
1307
|
+
"""Получить время следующего расчета контракта.
|
|
1308
|
+
|
|
1309
|
+
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
|
|
1310
|
+
"""
|
|
1311
|
+
params = {
|
|
1312
|
+
"symbol": symbol,
|
|
1313
|
+
"productType": product_type,
|
|
1314
|
+
}
|
|
1315
|
+
return await self._make_request("GET", "/api/v2/mix/market/funding-time", params=params)
|
|
1316
|
+
|
|
1317
|
+
async def futures_get_symbol_price(
|
|
1318
|
+
self,
|
|
1319
|
+
symbol: str,
|
|
1320
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1321
|
+
) -> dict:
|
|
1322
|
+
"""Получить цены контракта (рыночную, индексную, марк).
|
|
1323
|
+
|
|
1324
|
+
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Price
|
|
1325
|
+
"""
|
|
1326
|
+
params = {
|
|
1327
|
+
"symbol": symbol,
|
|
1328
|
+
"productType": product_type,
|
|
1329
|
+
}
|
|
1330
|
+
return await self._make_request("GET", "/api/v2/mix/market/symbol-price", params=params)
|
|
1331
|
+
|
|
1332
|
+
async def futures_get_history_funding_rate(
|
|
1333
|
+
self,
|
|
1334
|
+
symbol: str,
|
|
1335
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1336
|
+
page_size: int | None = None,
|
|
1337
|
+
page_no: int | None = None,
|
|
1338
|
+
) -> dict:
|
|
1339
|
+
"""Получить историю ставок финансирования контракта.
|
|
1340
|
+
|
|
1341
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate
|
|
1342
|
+
"""
|
|
1343
|
+
params: dict[str, str | int] = {
|
|
1344
|
+
"symbol": symbol,
|
|
1345
|
+
"productType": product_type,
|
|
1346
|
+
}
|
|
1347
|
+
if page_size is not None:
|
|
1348
|
+
params["pageSize"] = page_size
|
|
1349
|
+
if page_no is not None:
|
|
1350
|
+
params["pageNo"] = page_no
|
|
1351
|
+
|
|
1352
|
+
return await self._make_request(
|
|
1353
|
+
"GET", "/api/v2/mix/market/history-fund-rate", params=params
|
|
1354
|
+
)
|
|
1355
|
+
|
|
1356
|
+
async def futures_get_current_funding_rate(
|
|
1357
|
+
self,
|
|
1358
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1359
|
+
symbol: str | None = None,
|
|
1360
|
+
) -> dict:
|
|
1361
|
+
"""Получить текущую ставку финансирования контракта.
|
|
1362
|
+
|
|
1363
|
+
https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
|
|
1364
|
+
"""
|
|
1365
|
+
params: dict[str, str] = {"productType": product_type}
|
|
1366
|
+
if symbol is not None:
|
|
1367
|
+
params["symbol"] = symbol
|
|
1368
|
+
|
|
1369
|
+
return await self._make_request(
|
|
1370
|
+
"GET", "/api/v2/mix/market/current-fund-rate", params=params
|
|
1371
|
+
)
|
|
1372
|
+
|
|
1373
|
+
async def futures_get_contract_oi_limit(
|
|
1374
|
+
self,
|
|
1375
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1376
|
+
symbol: str | None = None,
|
|
1377
|
+
) -> dict:
|
|
1378
|
+
"""Получить лимит открытого интереса контракта.
|
|
1379
|
+
|
|
1380
|
+
https://www.bitget.com/api-doc/contract/market/Get-Contracts-Oi
|
|
1381
|
+
"""
|
|
1382
|
+
params: dict[str, str] = {"productType": product_type}
|
|
1383
|
+
if symbol is not None:
|
|
1384
|
+
params["symbol"] = symbol
|
|
1385
|
+
|
|
1386
|
+
return await self._make_request("GET", "/api/v2/mix/market/oi-limit", params=params)
|
|
1387
|
+
|
|
1388
|
+
async def futures_get_contracts(
|
|
1389
|
+
self,
|
|
1390
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1391
|
+
symbol: str | None = None,
|
|
1392
|
+
) -> dict:
|
|
1393
|
+
"""Получить детали контрактов.
|
|
1394
|
+
|
|
1395
|
+
https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
|
1396
|
+
"""
|
|
1397
|
+
params: dict[str, str] = {"productType": product_type}
|
|
1398
|
+
if symbol is not None:
|
|
1399
|
+
params["symbol"] = symbol
|
|
1400
|
+
|
|
1401
|
+
return await self._make_request("GET", "/api/v2/mix/market/contracts", params=params)
|
|
1402
|
+
|
|
1403
|
+
# topic: futures account
|
|
1404
|
+
|
|
1405
|
+
async def futures_get_single_account(
|
|
1406
|
+
self,
|
|
1407
|
+
symbol: str,
|
|
1408
|
+
margin_coin: str,
|
|
1409
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1410
|
+
) -> dict:
|
|
1411
|
+
"""Получить данные по одному аккаунту фьючерсов.
|
|
1412
|
+
|
|
1413
|
+
https://www.bitget.com/api-doc/contract/account/Get-Single-Account
|
|
1414
|
+
"""
|
|
1415
|
+
params = {
|
|
1416
|
+
"symbol": symbol,
|
|
1417
|
+
"productType": product_type,
|
|
1418
|
+
"marginCoin": margin_coin,
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
return await self._make_request(
|
|
1422
|
+
"GET", "/api/v2/mix/account/account", signed=True, params=params
|
|
1423
|
+
)
|
|
1424
|
+
|
|
1425
|
+
async def futures_get_account_list(
|
|
1426
|
+
self,
|
|
1427
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1428
|
+
) -> dict:
|
|
1429
|
+
"""Получить список всех аккаунтов по типу продукта.
|
|
1430
|
+
|
|
1431
|
+
https://www.bitget.com/api-doc/contract/account/Get-Account-List
|
|
1432
|
+
"""
|
|
1433
|
+
params = {"productType": product_type}
|
|
1434
|
+
|
|
1435
|
+
return await self._make_request(
|
|
1436
|
+
"GET", "/api/v2/mix/account/accounts", signed=True, params=params
|
|
1437
|
+
)
|
|
1438
|
+
|
|
1439
|
+
async def futures_get_subaccount_assets(
|
|
1440
|
+
self,
|
|
1441
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1442
|
+
) -> dict:
|
|
1443
|
+
"""Получить информацию о контрактах всех суб-аккаунтов.
|
|
1444
|
+
|
|
1445
|
+
https://www.bitget.com/api-doc/contract/account/Get-Sub-Account-Contract-Assets
|
|
1446
|
+
"""
|
|
1447
|
+
params = {"productType": product_type}
|
|
1448
|
+
|
|
1449
|
+
return await self._make_request(
|
|
1450
|
+
"GET", "/api/v2/mix/account/sub-account-assets", signed=True, params=params
|
|
1451
|
+
)
|
|
1452
|
+
|
|
1453
|
+
async def futures_get_interest_history(
|
|
1454
|
+
self,
|
|
1455
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1456
|
+
coin: str | None = None,
|
|
1457
|
+
id_less_than: str | None = None,
|
|
1458
|
+
start_time: int | None = None,
|
|
1459
|
+
end_time: int | None = None,
|
|
1460
|
+
limit: int | None = None,
|
|
1461
|
+
) -> dict:
|
|
1462
|
+
"""Получить историю начисления процентов по USDT-M фьючерсам.
|
|
1463
|
+
|
|
1464
|
+
https://www.bitget.com/api-doc/contract/account/Interest-History
|
|
1465
|
+
"""
|
|
1466
|
+
params = {
|
|
1467
|
+
"productType": product_type,
|
|
1468
|
+
"coin": coin,
|
|
1469
|
+
"idLessThan": id_less_than,
|
|
1470
|
+
"startTime": start_time,
|
|
1471
|
+
"endTime": end_time,
|
|
1472
|
+
"limit": limit,
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
return await self._make_request(
|
|
1476
|
+
"GET", "/api/v2/mix/account/interest-history", signed=True, params=params
|
|
1477
|
+
)
|
|
1478
|
+
|
|
1479
|
+
async def futures_get_est_open_count(
|
|
1480
|
+
self,
|
|
1481
|
+
symbol: str,
|
|
1482
|
+
margin_coin: str,
|
|
1483
|
+
open_amount: float,
|
|
1484
|
+
open_price: float,
|
|
1485
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1486
|
+
leverage: int | None = 20,
|
|
1487
|
+
) -> dict:
|
|
1488
|
+
"""Получить расчетное количество открытых контрактов для пользователя.
|
|
1489
|
+
|
|
1490
|
+
https://www.bitget.com/api-doc/contract/account/Est-Open-Count
|
|
1491
|
+
"""
|
|
1492
|
+
params = {
|
|
1493
|
+
"productType": product_type,
|
|
1494
|
+
"symbol": symbol,
|
|
1495
|
+
"marginCoin": margin_coin,
|
|
1496
|
+
"openAmount": open_amount,
|
|
1497
|
+
"openPrice": open_price,
|
|
1498
|
+
"leverage": leverage,
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
return await self._make_request(
|
|
1502
|
+
"GET", "/api/v2/mix/account/open-count", signed=True, params=params
|
|
1503
|
+
)
|
|
1504
|
+
|
|
1505
|
+
async def futures_set_auto_margin(
|
|
1506
|
+
self,
|
|
1507
|
+
symbol: str,
|
|
1508
|
+
auto_margin: str,
|
|
1509
|
+
margin_coin: str,
|
|
1510
|
+
hold_side: str,
|
|
1511
|
+
) -> dict:
|
|
1512
|
+
"""Настроить автоматическое управление маржей для изолированной позиции.
|
|
1513
|
+
|
|
1514
|
+
https://www.bitget.com/api-doc/contract/account/Set-Auto-Margin
|
|
1515
|
+
"""
|
|
1516
|
+
data = {
|
|
1517
|
+
"symbol": symbol,
|
|
1518
|
+
"autoMargin": auto_margin,
|
|
1519
|
+
"marginCoin": margin_coin,
|
|
1520
|
+
"holdSide": hold_side,
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
return await self._make_request(
|
|
1524
|
+
"POST", "/api/v2/mix/account/set-auto-margin", signed=True, data=data
|
|
1525
|
+
)
|
|
1526
|
+
|
|
1527
|
+
async def futures_set_leverage(
|
|
1528
|
+
self,
|
|
1529
|
+
symbol: str,
|
|
1530
|
+
margin_coin: str,
|
|
1531
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1532
|
+
leverage: str | None = None,
|
|
1533
|
+
long_leverage: str | None = None,
|
|
1534
|
+
short_leverage: str | None = None,
|
|
1535
|
+
hold_side: str | None = None,
|
|
1536
|
+
) -> dict:
|
|
1537
|
+
"""Изменить плечо по указанной позиции.
|
|
1538
|
+
|
|
1539
|
+
https://www.bitget.com/api-doc/contract/account/Change-Leverage
|
|
1540
|
+
"""
|
|
1541
|
+
data = {
|
|
1542
|
+
"symbol": symbol,
|
|
1543
|
+
"productType": product_type,
|
|
1544
|
+
"marginCoin": margin_coin,
|
|
1545
|
+
"leverage": leverage,
|
|
1546
|
+
"longLeverage": long_leverage,
|
|
1547
|
+
"shortLeverage": short_leverage,
|
|
1548
|
+
"holdSide": hold_side,
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
return await self._make_request(
|
|
1552
|
+
"POST", "/api/v2/mix/account/set-leverage", signed=True, data=data
|
|
1553
|
+
)
|
|
1554
|
+
|
|
1555
|
+
async def futures_set_all_leverage(
|
|
1556
|
+
self,
|
|
1557
|
+
leverage: str,
|
|
1558
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1559
|
+
) -> dict:
|
|
1560
|
+
"""Изменить плечо для всех позиций указанного продукта.
|
|
1561
|
+
|
|
1562
|
+
https://www.bitget.com/api-doc/contract/account/Change-All-Leverage
|
|
1563
|
+
"""
|
|
1564
|
+
data = {
|
|
1565
|
+
"productType": product_type,
|
|
1566
|
+
"leverage": leverage,
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
return await self._make_request(
|
|
1570
|
+
"POST", "/api/v2/mix/account/set-all-leverage", signed=True, data=data
|
|
1571
|
+
)
|
|
1572
|
+
|
|
1573
|
+
async def futures_adjust_margin(
|
|
1574
|
+
self,
|
|
1575
|
+
symbol: str,
|
|
1576
|
+
margin_coin: str,
|
|
1577
|
+
hold_side: str,
|
|
1578
|
+
amount: str,
|
|
1579
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1580
|
+
) -> dict:
|
|
1581
|
+
"""Добавить или уменьшить маржу для позиции (только для изолированной маржи).
|
|
1582
|
+
|
|
1583
|
+
https://www.bitget.com/api-doc/contract/account/Change-Margin
|
|
1584
|
+
"""
|
|
1585
|
+
data = {
|
|
1586
|
+
"symbol": symbol,
|
|
1587
|
+
"productType": product_type,
|
|
1588
|
+
"marginCoin": margin_coin,
|
|
1589
|
+
"holdSide": hold_side,
|
|
1590
|
+
"amount": amount,
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
return await self._make_request(
|
|
1594
|
+
"POST", "/api/v2/mix/account/set-margin", signed=True, data=data
|
|
1595
|
+
)
|
|
1596
|
+
|
|
1597
|
+
async def futures_set_asset_mode(
|
|
1598
|
+
self,
|
|
1599
|
+
asset_mode: str,
|
|
1600
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1601
|
+
) -> dict:
|
|
1602
|
+
"""Установить режим управления активами для USDT-M фьючерсов.
|
|
1603
|
+
|
|
1604
|
+
https://www.bitget.com/api-doc/contract/account/Set-Asset-Mode
|
|
1605
|
+
"""
|
|
1606
|
+
data = {
|
|
1607
|
+
"productType": product_type,
|
|
1608
|
+
"assetMode": asset_mode,
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
return await self._make_request(
|
|
1612
|
+
"POST", "/api/v2/mix/account/set-asset-mode", signed=True, data=data
|
|
1613
|
+
)
|
|
1614
|
+
|
|
1615
|
+
async def futures_set_margin_mode(
|
|
1616
|
+
self,
|
|
1617
|
+
symbol: str,
|
|
1618
|
+
margin_coin: str,
|
|
1619
|
+
margin_mode: str,
|
|
1620
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1621
|
+
) -> dict:
|
|
1622
|
+
"""Изменить режим маржи для позиции (изолированная/кросс).
|
|
1623
|
+
|
|
1624
|
+
https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode
|
|
1625
|
+
"""
|
|
1626
|
+
data = {
|
|
1627
|
+
"symbol": symbol,
|
|
1628
|
+
"productType": product_type,
|
|
1629
|
+
"marginCoin": margin_coin,
|
|
1630
|
+
"marginMode": margin_mode,
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
return await self._make_request(
|
|
1634
|
+
"POST", "/api/v2/mix/account/set-margin-mode", signed=True, data=data
|
|
1635
|
+
)
|
|
1636
|
+
|
|
1637
|
+
async def futures_union_convert(
|
|
1638
|
+
self,
|
|
1639
|
+
coin: str,
|
|
1640
|
+
amount: str,
|
|
1641
|
+
) -> dict:
|
|
1642
|
+
"""Конвертация активов в режиме объединенной маржи.
|
|
1643
|
+
|
|
1644
|
+
https://www.bitget.com/api-doc/contract/account/Union-Convert
|
|
1645
|
+
"""
|
|
1646
|
+
data = {"coin": coin, "amount": amount}
|
|
1647
|
+
|
|
1648
|
+
return await self._make_request(
|
|
1649
|
+
"POST", "/api/v2/mix/account/union-convert", signed=True, data=data
|
|
1650
|
+
)
|
|
1651
|
+
|
|
1652
|
+
async def futures_change_position_mode(
|
|
1653
|
+
self,
|
|
1654
|
+
pos_mode: str,
|
|
1655
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1656
|
+
) -> dict:
|
|
1657
|
+
"""Изменить режим позиций: одинарный или хедж.
|
|
1658
|
+
|
|
1659
|
+
https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
|
|
1660
|
+
"""
|
|
1661
|
+
params = {
|
|
1662
|
+
"productType": product_type,
|
|
1663
|
+
"posMode": pos_mode,
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
return await self._make_request(
|
|
1667
|
+
"POST", "/api/v2/mix/account/set-position-mode", signed=True, params=params
|
|
1668
|
+
)
|
|
1669
|
+
|
|
1670
|
+
async def futures_get_account_bill(
|
|
1671
|
+
self,
|
|
1672
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1673
|
+
coin: str | None = None,
|
|
1674
|
+
business_type: str | None = None,
|
|
1675
|
+
only_funding: str | None = None,
|
|
1676
|
+
id_less_than: str | None = None,
|
|
1677
|
+
start_time: int | None = None,
|
|
1678
|
+
end_time: int | None = None,
|
|
1679
|
+
limit: int | None = None,
|
|
1680
|
+
) -> dict:
|
|
1681
|
+
"""Получить выписки по счёту за последние 90 дней.
|
|
1682
|
+
|
|
1683
|
+
https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
|
1684
|
+
"""
|
|
1685
|
+
params = {
|
|
1686
|
+
"productType": product_type,
|
|
1687
|
+
"coin": coin,
|
|
1688
|
+
"businessType": business_type,
|
|
1689
|
+
"onlyFunding": only_funding,
|
|
1690
|
+
"idLessThan": id_less_than,
|
|
1691
|
+
"startTime": start_time,
|
|
1692
|
+
"endTime": end_time,
|
|
1693
|
+
"limit": limit,
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
return await self._make_request(
|
|
1697
|
+
"GET", "/api/v2/mix/account/bill", signed=True, params=params
|
|
1698
|
+
)
|
|
1699
|
+
|
|
1700
|
+
async def futures_union_transfer_limits(self, coin: str) -> dict:
|
|
1701
|
+
"""Получить лимиты перевода для валюты union margin.
|
|
1702
|
+
|
|
1703
|
+
https://www.bitget.com/api-doc/contract/account/Get-Union-Transfer-Limits
|
|
1704
|
+
"""
|
|
1705
|
+
params = {"coin": coin}
|
|
1706
|
+
return await self._make_request(
|
|
1707
|
+
"GET", "/api/v2/mix/account/transfer-limits", signed=True, params=params
|
|
1708
|
+
)
|
|
1709
|
+
|
|
1710
|
+
async def futures_union_config(self) -> dict:
|
|
1711
|
+
"""Получить параметры конфигурации union margin.
|
|
1712
|
+
|
|
1713
|
+
https://www.bitget.com/api-doc/contract/account/Get-Union-Config
|
|
1714
|
+
"""
|
|
1715
|
+
return await self._make_request("GET", "/api/v2/mix/account/union-config", signed=True)
|
|
1716
|
+
|
|
1717
|
+
async def futures_switch_union_usdt(self) -> dict:
|
|
1718
|
+
"""Получить квоту USDT для переключения с union margin на single margin.
|
|
1719
|
+
|
|
1720
|
+
https://www.bitget.com/api-doc/contract/account/Get-Switch-Union-USDT
|
|
1721
|
+
"""
|
|
1722
|
+
return await self._make_request("GET", "/api/v2/mix/account/switch-union-usdt", signed=True)
|
|
1723
|
+
|
|
1724
|
+
# topic: futures position
|
|
1725
|
+
|
|
1726
|
+
async def futures_get_position_tier(
|
|
1727
|
+
self,
|
|
1728
|
+
symbol: str,
|
|
1729
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1730
|
+
) -> dict:
|
|
1731
|
+
"""Получить конфигурацию уровней позиций для определённой торговой пары.
|
|
1732
|
+
|
|
1733
|
+
https://www.bitget.com/api-doc/contract/position/Get-Query-Position-Lever
|
|
1734
|
+
"""
|
|
1735
|
+
params = {
|
|
1736
|
+
"symbol": symbol,
|
|
1737
|
+
"productType": product_type,
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
return await self._make_request(
|
|
1741
|
+
"GET", "/api/v2/mix/market/query-position-lever", signed=True, params=params
|
|
1742
|
+
)
|
|
1743
|
+
|
|
1744
|
+
async def futures_get_single_position(
|
|
1745
|
+
self,
|
|
1746
|
+
symbol: str,
|
|
1747
|
+
margin_coin: str,
|
|
1748
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1749
|
+
) -> dict:
|
|
1750
|
+
"""Получить информацию о позиции по одной торговой паре, включая предполагаемую цену ликвидации.
|
|
1751
|
+
|
|
1752
|
+
https://www.bitget.com/api-doc/contract/position/get-single-position
|
|
1753
|
+
"""
|
|
1754
|
+
params = {
|
|
1755
|
+
"symbol": symbol,
|
|
1756
|
+
"productType": product_type,
|
|
1757
|
+
"marginCoin": margin_coin,
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
return await self._make_request(
|
|
1761
|
+
"GET", "/api/v2/mix/position/single-position", signed=True, params=params
|
|
1762
|
+
)
|
|
1763
|
+
|
|
1764
|
+
async def futures_get_all_positions(
|
|
1765
|
+
self,
|
|
1766
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1767
|
+
margin_coin: str | None = None,
|
|
1768
|
+
) -> dict:
|
|
1769
|
+
"""Получить информацию обо всех текущих позициях по типу продукта.
|
|
1770
|
+
|
|
1771
|
+
https://www.bitget.com/api-doc/contract/position/get-all-position
|
|
1772
|
+
"""
|
|
1773
|
+
params = {
|
|
1774
|
+
"productType": product_type,
|
|
1775
|
+
"marginCoin": margin_coin,
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
return await self._make_request(
|
|
1779
|
+
"GET", "/api/v2/mix/position/all-position", signed=True, params=params
|
|
1780
|
+
)
|
|
1781
|
+
|
|
1782
|
+
async def futures_get_adl_rank(
|
|
1783
|
+
self,
|
|
1784
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1785
|
+
) -> dict:
|
|
1786
|
+
"""Получить ADL ранг по позиции аккаунта.
|
|
1787
|
+
|
|
1788
|
+
https://www.bitget.com/api-doc/contract/position/Get-Position-Adl
|
|
1789
|
+
"""
|
|
1790
|
+
params = {"productType": product_type}
|
|
1791
|
+
|
|
1792
|
+
return await self._make_request(
|
|
1793
|
+
"GET", "/api/v2/mix/position/adlRank", signed=True, params=params
|
|
1794
|
+
)
|
|
1795
|
+
|
|
1796
|
+
async def futures_get_historical_positions(
|
|
1797
|
+
self,
|
|
1798
|
+
symbol: str | None = None,
|
|
1799
|
+
product_type: str | None = None,
|
|
1800
|
+
id_less_than: str | None = None,
|
|
1801
|
+
start_time: int | None = None,
|
|
1802
|
+
end_time: int | None = None,
|
|
1803
|
+
limit: int | None = None,
|
|
1804
|
+
) -> dict:
|
|
1805
|
+
"""Получить историю позиций (данные за последние 3 месяца).
|
|
1806
|
+
|
|
1807
|
+
https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
|
1808
|
+
"""
|
|
1809
|
+
params = {
|
|
1810
|
+
"symbol": symbol,
|
|
1811
|
+
"productType": product_type,
|
|
1812
|
+
"idLessThan": id_less_than,
|
|
1813
|
+
"startTime": start_time,
|
|
1814
|
+
"endTime": end_time,
|
|
1815
|
+
"limit": limit,
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
return await self._make_request(
|
|
1819
|
+
"GET", "/api/v2/mix/position/history-position", signed=True, params=params
|
|
1820
|
+
)
|
|
1821
|
+
|
|
1822
|
+
# topic: futures trade
|
|
1823
|
+
|
|
1824
|
+
async def futures_place_order(
|
|
1825
|
+
self,
|
|
1826
|
+
symbol: str,
|
|
1827
|
+
margin_mode: str,
|
|
1828
|
+
margin_coin: str,
|
|
1829
|
+
size: str,
|
|
1830
|
+
side: str,
|
|
1831
|
+
order_type: str,
|
|
1832
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1833
|
+
price: str | None = None,
|
|
1834
|
+
trade_side: str | None = None,
|
|
1835
|
+
force: str | None = "gtc",
|
|
1836
|
+
client_oid: str | None = None,
|
|
1837
|
+
reduce_only: str | None = "NO",
|
|
1838
|
+
preset_stop_surplus_price: str | None = None,
|
|
1839
|
+
preset_stop_loss_price: str | None = None,
|
|
1840
|
+
preset_stop_surplus_execute_price: str | None = None,
|
|
1841
|
+
preset_stop_loss_execute_price: str | None = None,
|
|
1842
|
+
stp_mode: str | None = "none",
|
|
1843
|
+
) -> dict:
|
|
1844
|
+
"""Разместить ордер на фьючерсном рынке.
|
|
1845
|
+
|
|
1846
|
+
https://www.bitget.com/api-doc/contract/trade/Place-Order
|
|
1847
|
+
"""
|
|
1848
|
+
data = {
|
|
1849
|
+
"symbol": symbol,
|
|
1850
|
+
"productType": product_type,
|
|
1851
|
+
"marginMode": margin_mode,
|
|
1852
|
+
"marginCoin": margin_coin,
|
|
1853
|
+
"size": size,
|
|
1854
|
+
"price": price,
|
|
1855
|
+
"side": side,
|
|
1856
|
+
"tradeSide": trade_side,
|
|
1857
|
+
"orderType": order_type,
|
|
1858
|
+
"force": force,
|
|
1859
|
+
"clientOid": client_oid,
|
|
1860
|
+
"reduceOnly": reduce_only,
|
|
1861
|
+
"presetStopSurplusPrice": preset_stop_surplus_price,
|
|
1862
|
+
"presetStopLossPrice": preset_stop_loss_price,
|
|
1863
|
+
"presetStopSurplusExecutePrice": preset_stop_surplus_execute_price,
|
|
1864
|
+
"presetStopLossExecutePrice": preset_stop_loss_execute_price,
|
|
1865
|
+
"stpMode": stp_mode,
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
return await self._make_request(
|
|
1869
|
+
"POST", "/api/v2/mix/order/place-order", signed=True, data=data
|
|
1870
|
+
)
|
|
1871
|
+
|
|
1872
|
+
async def futures_reversal(
|
|
1873
|
+
self,
|
|
1874
|
+
symbol: str,
|
|
1875
|
+
margin_coin: str,
|
|
1876
|
+
side: str,
|
|
1877
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1878
|
+
size: str | None = None,
|
|
1879
|
+
trade_side: str | None = None,
|
|
1880
|
+
client_oid: str | None = None,
|
|
1881
|
+
) -> dict:
|
|
1882
|
+
"""Реверс позиции: закрыть текущую и открыть противоположную.
|
|
1883
|
+
|
|
1884
|
+
https://www.bitget.com/api-doc/contract/trade/Reversal
|
|
1885
|
+
"""
|
|
1886
|
+
data = {
|
|
1887
|
+
"symbol": symbol,
|
|
1888
|
+
"marginCoin": margin_coin,
|
|
1889
|
+
"productType": product_type,
|
|
1890
|
+
"size": size,
|
|
1891
|
+
"side": side,
|
|
1892
|
+
"tradeSide": trade_side,
|
|
1893
|
+
"clientOid": client_oid,
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
return await self._make_request(
|
|
1897
|
+
"POST", "/api/v2/mix/order/click-backhand", signed=True, data=data
|
|
1898
|
+
)
|
|
1899
|
+
|
|
1900
|
+
async def futures_batch_place_order(
|
|
1901
|
+
self,
|
|
1902
|
+
symbol: str,
|
|
1903
|
+
margin_mode: str,
|
|
1904
|
+
margin_coin: str,
|
|
1905
|
+
order_list: list[dict],
|
|
1906
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1907
|
+
) -> dict:
|
|
1908
|
+
"""Разместить пакет ордеров с поддержкой TP/SL.
|
|
1909
|
+
|
|
1910
|
+
https://www.bitget.com/api-doc/contract/trade/Batch-Order
|
|
1911
|
+
"""
|
|
1912
|
+
data = {
|
|
1913
|
+
"symbol": symbol,
|
|
1914
|
+
"productType": product_type,
|
|
1915
|
+
"marginMode": margin_mode,
|
|
1916
|
+
"marginCoin": margin_coin,
|
|
1917
|
+
"orderList": order_list,
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
return await self._make_request(
|
|
1921
|
+
"POST", "/api/v2/mix/order/batch-place-order", signed=True, data=data
|
|
1922
|
+
)
|
|
1923
|
+
|
|
1924
|
+
async def futures_modify_order(
|
|
1925
|
+
self,
|
|
1926
|
+
symbol: str,
|
|
1927
|
+
margin_coin: str,
|
|
1928
|
+
new_client_oid: str,
|
|
1929
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1930
|
+
order_id: str | None = None,
|
|
1931
|
+
client_oid: str | None = None,
|
|
1932
|
+
new_size: str | None = None,
|
|
1933
|
+
new_price: str | None = None,
|
|
1934
|
+
new_preset_stop_surplus_price: str | None = None,
|
|
1935
|
+
new_preset_stop_loss_price: str | None = None,
|
|
1936
|
+
) -> dict:
|
|
1937
|
+
"""Модифицировать существующий ордер: цену, размер и/или TP/SL.
|
|
1938
|
+
|
|
1939
|
+
https://www.bitget.com/api-doc/contract/trade/Modify-Order
|
|
1940
|
+
"""
|
|
1941
|
+
data = {
|
|
1942
|
+
"orderId": order_id,
|
|
1943
|
+
"clientOid": client_oid,
|
|
1944
|
+
"symbol": symbol,
|
|
1945
|
+
"productType": product_type,
|
|
1946
|
+
"marginCoin": margin_coin,
|
|
1947
|
+
"newClientOid": new_client_oid,
|
|
1948
|
+
"newSize": new_size,
|
|
1949
|
+
"newPrice": new_price,
|
|
1950
|
+
"newPresetStopSurplusPrice": new_preset_stop_surplus_price,
|
|
1951
|
+
"newPresetStopLossPrice": new_preset_stop_loss_price,
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
return await self._make_request(
|
|
1955
|
+
"POST", "/api/v2/mix/order/modify-order", signed=True, data=data
|
|
1956
|
+
)
|
|
1957
|
+
|
|
1958
|
+
async def futures_cancel_order(
|
|
1959
|
+
self,
|
|
1960
|
+
symbol: str,
|
|
1961
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1962
|
+
margin_coin: str | None = None,
|
|
1963
|
+
order_id: str | None = None,
|
|
1964
|
+
client_oid: str | None = None,
|
|
1965
|
+
) -> dict:
|
|
1966
|
+
"""Отменить ожидающий ордер.
|
|
1967
|
+
|
|
1968
|
+
https://www.bitget.com/api-doc/contract/trade/Cancel-Order
|
|
1969
|
+
"""
|
|
1970
|
+
data = {
|
|
1971
|
+
"symbol": symbol,
|
|
1972
|
+
"productType": product_type,
|
|
1973
|
+
"marginCoin": margin_coin,
|
|
1974
|
+
"orderId": order_id,
|
|
1975
|
+
"clientOid": client_oid,
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
return await self._make_request(
|
|
1979
|
+
"POST", "/api/v2/mix/order/cancel-order", signed=True, data=data
|
|
1980
|
+
)
|
|
1981
|
+
|
|
1982
|
+
async def futures_batch_cancel_orders(
|
|
1983
|
+
self,
|
|
1984
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
1985
|
+
order_id_list: list[dict] | None = None,
|
|
1986
|
+
symbol: str | None = None,
|
|
1987
|
+
margin_coin: str | None = None,
|
|
1988
|
+
) -> dict:
|
|
1989
|
+
"""Пакетная отмена ордеров по продукту и торговой паре.
|
|
1990
|
+
|
|
1991
|
+
https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
|
|
1992
|
+
"""
|
|
1993
|
+
data = {
|
|
1994
|
+
"productType": product_type,
|
|
1995
|
+
"orderIdList": order_id_list,
|
|
1996
|
+
"symbol": symbol,
|
|
1997
|
+
"marginCoin": margin_coin,
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
return await self._make_request(
|
|
2001
|
+
"POST", "/api/v2/mix/order/batch-cancel-orders", signed=True, data=data
|
|
2002
|
+
)
|
|
2003
|
+
|
|
2004
|
+
async def futures_flash_close_position(
|
|
2005
|
+
self,
|
|
2006
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2007
|
+
symbol: str | None = None,
|
|
2008
|
+
hold_side: str | None = None,
|
|
2009
|
+
) -> dict:
|
|
2010
|
+
"""Закрыть позицию по рыночной цене.
|
|
2011
|
+
|
|
2012
|
+
https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
|
|
2013
|
+
"""
|
|
2014
|
+
data = {
|
|
2015
|
+
"symbol": symbol,
|
|
2016
|
+
"holdSide": hold_side,
|
|
2017
|
+
"productType": product_type,
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
return await self._make_request(
|
|
2021
|
+
"POST", "/api/v2/mix/order/close-positions", signed=True, data=data
|
|
2022
|
+
)
|
|
2023
|
+
|
|
2024
|
+
async def futures_get_order_detail(
|
|
2025
|
+
self,
|
|
2026
|
+
symbol: str,
|
|
2027
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2028
|
+
order_id: str | None = None,
|
|
2029
|
+
client_oid: str | None = None,
|
|
2030
|
+
) -> dict:
|
|
2031
|
+
"""Получить детали ордера.
|
|
2032
|
+
|
|
2033
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
|
|
2034
|
+
"""
|
|
2035
|
+
data = {
|
|
2036
|
+
"symbol": symbol,
|
|
2037
|
+
"productType": product_type,
|
|
2038
|
+
"orderId": order_id,
|
|
2039
|
+
"clientOid": client_oid,
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
return await self._make_request("GET", "/api/v2/mix/order/detail", signed=True, params=data)
|
|
2043
|
+
|
|
2044
|
+
async def futures_get_order_fills(
|
|
2045
|
+
self,
|
|
2046
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2047
|
+
order_id: str | None = None,
|
|
2048
|
+
symbol: str | None = None,
|
|
2049
|
+
id_less_than: str | None = None,
|
|
2050
|
+
start_time: int | None = None,
|
|
2051
|
+
end_time: int | None = None,
|
|
2052
|
+
limit: int | None = 100,
|
|
2053
|
+
) -> dict:
|
|
2054
|
+
"""Получить детали исполнения ордера.
|
|
2055
|
+
|
|
2056
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Order-Fills
|
|
2057
|
+
"""
|
|
2058
|
+
params = {
|
|
2059
|
+
"productType": product_type,
|
|
2060
|
+
"orderId": order_id,
|
|
2061
|
+
"symbol": symbol,
|
|
2062
|
+
"idLessThan": id_less_than,
|
|
2063
|
+
"startTime": start_time,
|
|
2064
|
+
"endTime": end_time,
|
|
2065
|
+
"limit": limit,
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
return await self._make_request(
|
|
2069
|
+
"GET", "/api/v2/mix/order/fills", signed=True, params=params
|
|
2070
|
+
)
|
|
2071
|
+
|
|
2072
|
+
async def futures_get_fill_history(
|
|
2073
|
+
self,
|
|
2074
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2075
|
+
order_id: str | None = None,
|
|
2076
|
+
client_oid: str | None = None,
|
|
2077
|
+
symbol: str | None = None,
|
|
2078
|
+
start_time: int | None = None,
|
|
2079
|
+
end_time: int | None = None,
|
|
2080
|
+
id_less_than: str | None = None,
|
|
2081
|
+
limit: int | None = 100,
|
|
2082
|
+
) -> dict:
|
|
2083
|
+
"""Получить историю исполнения ордеров.
|
|
2084
|
+
|
|
2085
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Fill-History
|
|
2086
|
+
"""
|
|
2087
|
+
params = {
|
|
2088
|
+
"productType": product_type,
|
|
2089
|
+
"orderId": order_id,
|
|
2090
|
+
"clientOid": client_oid,
|
|
2091
|
+
"symbol": symbol,
|
|
2092
|
+
"startTime": start_time,
|
|
2093
|
+
"endTime": end_time,
|
|
2094
|
+
"idLessThan": id_less_than,
|
|
2095
|
+
"limit": limit,
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
return await self._make_request(
|
|
2099
|
+
"GET", "/api/v2/mix/order/fill-history", signed=True, params=params
|
|
2100
|
+
)
|
|
2101
|
+
|
|
2102
|
+
async def futures_get_orders_pending(
|
|
2103
|
+
self,
|
|
2104
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2105
|
+
order_id: str | None = None,
|
|
2106
|
+
client_oid: str | None = None,
|
|
2107
|
+
symbol: str | None = None,
|
|
2108
|
+
status: str | None = None,
|
|
2109
|
+
id_less_than: str | None = None,
|
|
2110
|
+
start_time: int | None = None,
|
|
2111
|
+
end_time: int | None = None,
|
|
2112
|
+
limit: int | None = 100,
|
|
2113
|
+
) -> dict:
|
|
2114
|
+
"""Получить все текущие ордера (pending).
|
|
2115
|
+
|
|
2116
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Orders-Pending
|
|
2117
|
+
"""
|
|
2118
|
+
params = {
|
|
2119
|
+
"productType": product_type,
|
|
2120
|
+
"orderId": order_id,
|
|
2121
|
+
"clientOid": client_oid,
|
|
2122
|
+
"symbol": symbol,
|
|
2123
|
+
"status": status,
|
|
2124
|
+
"idLessThan": id_less_than,
|
|
2125
|
+
"startTime": start_time,
|
|
2126
|
+
"endTime": end_time,
|
|
2127
|
+
"limit": limit,
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
return await self._make_request(
|
|
2131
|
+
"GET", "/api/v2/mix/order/orders-pending", signed=True, params=params
|
|
2132
|
+
)
|
|
2133
|
+
|
|
2134
|
+
async def futures_get_orders_history(
|
|
2135
|
+
self,
|
|
2136
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2137
|
+
order_id: str | None = None,
|
|
2138
|
+
client_oid: str | None = None,
|
|
2139
|
+
symbol: str | None = None,
|
|
2140
|
+
id_less_than: str | None = None,
|
|
2141
|
+
order_source: str | None = None,
|
|
2142
|
+
start_time: int | None = None,
|
|
2143
|
+
end_time: int | None = None,
|
|
2144
|
+
limit: int | None = 100,
|
|
2145
|
+
) -> dict:
|
|
2146
|
+
"""Получить историю ордеров (до 90 дней).
|
|
2147
|
+
|
|
2148
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
|
2149
|
+
"""
|
|
2150
|
+
params = {
|
|
2151
|
+
"productType": product_type,
|
|
2152
|
+
"orderId": order_id,
|
|
2153
|
+
"clientOid": client_oid,
|
|
2154
|
+
"symbol": symbol,
|
|
2155
|
+
"idLessThan": id_less_than,
|
|
2156
|
+
"orderSource": order_source,
|
|
2157
|
+
"startTime": start_time,
|
|
2158
|
+
"endTime": end_time,
|
|
2159
|
+
"limit": limit,
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
return await self._make_request(
|
|
2163
|
+
"GET", "/api/v2/mix/order/orders-history", signed=True, params=params
|
|
2164
|
+
)
|
|
2165
|
+
|
|
2166
|
+
async def futures_cancel_all_orders(
|
|
2167
|
+
self,
|
|
2168
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2169
|
+
margin_coin: str | None = None,
|
|
2170
|
+
request_time: int | None = None,
|
|
2171
|
+
receive_window: int | None = None,
|
|
2172
|
+
) -> dict:
|
|
2173
|
+
"""Отменить все ордера.
|
|
2174
|
+
|
|
2175
|
+
https://www.bitget.com/api-doc/contract/trade/Cancel-All-Orders
|
|
2176
|
+
"""
|
|
2177
|
+
data = {
|
|
2178
|
+
"productType": product_type,
|
|
2179
|
+
"marginCoin": margin_coin,
|
|
2180
|
+
"requestTime": request_time,
|
|
2181
|
+
"receiveWindow": receive_window,
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
return await self._make_request(
|
|
2185
|
+
"POST", "/api/v2/mix/order/cancel-all-orders", signed=True, data=data
|
|
2186
|
+
)
|
|
2187
|
+
|
|
2188
|
+
# topic: futures trigger order
|
|
2189
|
+
|
|
2190
|
+
async def futures_get_plan_sub_orders(
|
|
2191
|
+
self,
|
|
2192
|
+
plan_order_id: str,
|
|
2193
|
+
plan_type: str,
|
|
2194
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2195
|
+
) -> dict:
|
|
2196
|
+
"""Получить исполненные ордера триггерного плана.
|
|
2197
|
+
|
|
2198
|
+
https://www.bitget.com/api-doc/contract/plan/Plan-Sub-Orders
|
|
2199
|
+
"""
|
|
2200
|
+
params = {
|
|
2201
|
+
"planOrderId": plan_order_id,
|
|
2202
|
+
"productType": product_type,
|
|
2203
|
+
"planType": plan_type,
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
return await self._make_request(
|
|
2207
|
+
"GET", "/api/v2/mix/order/plan-sub-order", signed=True, params=params
|
|
2208
|
+
)
|
|
2209
|
+
|
|
2210
|
+
async def futures_place_tpsl_order(
|
|
2211
|
+
self,
|
|
2212
|
+
margin_coin: str,
|
|
2213
|
+
symbol: str,
|
|
2214
|
+
plan_type: str,
|
|
2215
|
+
trigger_price: str,
|
|
2216
|
+
hold_side: str,
|
|
2217
|
+
size: str,
|
|
2218
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2219
|
+
trigger_type: str | None = None,
|
|
2220
|
+
execute_price: str | None = None,
|
|
2221
|
+
range_rate: str | None = None,
|
|
2222
|
+
client_oid: str | None = None,
|
|
2223
|
+
stp_mode: str | None = None,
|
|
2224
|
+
) -> dict:
|
|
2225
|
+
"""Разместить TP/SL ордер (take-profit / stop-loss / trailing).
|
|
2226
|
+
|
|
2227
|
+
https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order
|
|
2228
|
+
"""
|
|
2229
|
+
data = {
|
|
2230
|
+
"marginCoin": margin_coin,
|
|
2231
|
+
"productType": product_type,
|
|
2232
|
+
"symbol": symbol,
|
|
2233
|
+
"planType": plan_type,
|
|
2234
|
+
"triggerPrice": trigger_price,
|
|
2235
|
+
"triggerType": trigger_type,
|
|
2236
|
+
"executePrice": execute_price,
|
|
2237
|
+
"holdSide": hold_side,
|
|
2238
|
+
"size": size,
|
|
2239
|
+
"rangeRate": range_rate,
|
|
2240
|
+
"clientOid": client_oid,
|
|
2241
|
+
"stpMode": stp_mode,
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
return await self._make_request(
|
|
2245
|
+
"POST", "/api/v2/mix/order/place-tpsl-order", signed=True, data=data
|
|
2246
|
+
)
|
|
2247
|
+
|
|
2248
|
+
async def futures_place_pos_tpsl_order(
|
|
2249
|
+
self,
|
|
2250
|
+
margin_coin: str,
|
|
2251
|
+
symbol: str,
|
|
2252
|
+
hold_side: str,
|
|
2253
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2254
|
+
stop_surplus_trigger_price: str | None = None,
|
|
2255
|
+
stop_surplus_size: str | None = None,
|
|
2256
|
+
stop_surplus_trigger_type: str | None = None,
|
|
2257
|
+
stop_surplus_execute_price: str | None = None,
|
|
2258
|
+
stop_loss_trigger_price: str | None = None,
|
|
2259
|
+
stop_loss_size: str | None = None,
|
|
2260
|
+
stop_loss_trigger_type: str | None = None,
|
|
2261
|
+
stop_loss_execute_price: str | None = None,
|
|
2262
|
+
stp_mode: str | None = None,
|
|
2263
|
+
stop_surplus_client_oid: str | None = None,
|
|
2264
|
+
stop_loss_client_oid: str | None = None,
|
|
2265
|
+
) -> dict:
|
|
2266
|
+
"""Разместить одновременные TP/SL ордера для позиции.
|
|
2267
|
+
|
|
2268
|
+
https://www.bitget.com/api-doc/contract/plan/Place-Pos-Tpsl-Order
|
|
2269
|
+
"""
|
|
2270
|
+
data = {
|
|
2271
|
+
"marginCoin": margin_coin,
|
|
2272
|
+
"productType": product_type,
|
|
2273
|
+
"symbol": symbol,
|
|
2274
|
+
"holdSide": hold_side,
|
|
2275
|
+
"stopSurplusTriggerPrice": stop_surplus_trigger_price,
|
|
2276
|
+
"stopSurplusSize": stop_surplus_size,
|
|
2277
|
+
"stopSurplusTriggerType": stop_surplus_trigger_type,
|
|
2278
|
+
"stopSurplusExecutePrice": stop_surplus_execute_price,
|
|
2279
|
+
"stopLossTriggerPrice": stop_loss_trigger_price,
|
|
2280
|
+
"stopLossSize": stop_loss_size,
|
|
2281
|
+
"stopLossTriggerType": stop_loss_trigger_type,
|
|
2282
|
+
"stopLossExecutePrice": stop_loss_execute_price,
|
|
2283
|
+
"stpMode": stp_mode,
|
|
2284
|
+
"stopSurplusClientOid": stop_surplus_client_oid,
|
|
2285
|
+
"stopLossClientOid": stop_loss_client_oid,
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
return await self._make_request(
|
|
2289
|
+
"POST", "/api/v2/mix/order/place-pos-tpsl", signed=True, data=data
|
|
2290
|
+
)
|
|
2291
|
+
|
|
2292
|
+
async def futures_place_plan_order(
|
|
2293
|
+
self,
|
|
2294
|
+
plan_type: str,
|
|
2295
|
+
symbol: str,
|
|
2296
|
+
margin_mode: str,
|
|
2297
|
+
margin_coin: str,
|
|
2298
|
+
size: str,
|
|
2299
|
+
side: str,
|
|
2300
|
+
order_type: str,
|
|
2301
|
+
trigger_price: str,
|
|
2302
|
+
trigger_type: str,
|
|
2303
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2304
|
+
trade_side: str | None = None,
|
|
2305
|
+
price: str | None = None,
|
|
2306
|
+
callback_ratio: str | None = None,
|
|
2307
|
+
client_oid: str | None = None,
|
|
2308
|
+
reduce_only: str | None = None,
|
|
2309
|
+
stop_surplus_trigger_price: str | None = None,
|
|
2310
|
+
stop_surplus_execute_price: str | None = None,
|
|
2311
|
+
stop_surplus_trigger_type: str | None = None,
|
|
2312
|
+
stop_loss_trigger_price: str | None = None,
|
|
2313
|
+
stop_loss_execute_price: str | None = None,
|
|
2314
|
+
stop_loss_trigger_type: str | None = None,
|
|
2315
|
+
stp_mode: str | None = None,
|
|
2316
|
+
) -> dict:
|
|
2317
|
+
"""Разместить триггерный или трейлинг ордер с функцией TP/SL.
|
|
2318
|
+
|
|
2319
|
+
https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
|
|
2320
|
+
"""
|
|
2321
|
+
data = {
|
|
2322
|
+
"planType": plan_type,
|
|
2323
|
+
"symbol": symbol,
|
|
2324
|
+
"productType": product_type,
|
|
2325
|
+
"marginMode": margin_mode,
|
|
2326
|
+
"marginCoin": margin_coin,
|
|
2327
|
+
"size": size,
|
|
2328
|
+
"side": side,
|
|
2329
|
+
"orderType": order_type,
|
|
2330
|
+
"triggerPrice": trigger_price,
|
|
2331
|
+
"triggerType": trigger_type,
|
|
2332
|
+
"tradeSide": trade_side,
|
|
2333
|
+
"price": price,
|
|
2334
|
+
"callbackRatio": callback_ratio,
|
|
2335
|
+
"clientOid": client_oid,
|
|
2336
|
+
"reduceOnly": reduce_only,
|
|
2337
|
+
"stopSurplusTriggerPrice": stop_surplus_trigger_price,
|
|
2338
|
+
"stopSurplusExecutePrice": stop_surplus_execute_price,
|
|
2339
|
+
"stopSurplusTriggerType": stop_surplus_trigger_type,
|
|
2340
|
+
"stopLossTriggerPrice": stop_loss_trigger_price,
|
|
2341
|
+
"stopLossExecutePrice": stop_loss_execute_price,
|
|
2342
|
+
"stopLossTriggerType": stop_loss_trigger_type,
|
|
2343
|
+
"stpMode": stp_mode,
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
return await self._make_request(
|
|
2347
|
+
"POST", "/api/v2/mix/order/place-plan-order", signed=True, data=data
|
|
2348
|
+
)
|
|
2349
|
+
|
|
2350
|
+
async def futures_modify_tpsl_order(
|
|
2351
|
+
self,
|
|
2352
|
+
margin_coin: str,
|
|
2353
|
+
symbol: str,
|
|
2354
|
+
trigger_price: str,
|
|
2355
|
+
size: str,
|
|
2356
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2357
|
+
order_id: str | None = None,
|
|
2358
|
+
client_oid: str | None = None,
|
|
2359
|
+
trigger_type: str | None = None,
|
|
2360
|
+
execute_price: str | None = None,
|
|
2361
|
+
range_rate: str | None = None,
|
|
2362
|
+
) -> dict:
|
|
2363
|
+
"""Изменить TP/SL ордер.
|
|
2364
|
+
|
|
2365
|
+
https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
|
|
2366
|
+
"""
|
|
2367
|
+
data = {
|
|
2368
|
+
"orderId": order_id,
|
|
2369
|
+
"clientOid": client_oid,
|
|
2370
|
+
"marginCoin": margin_coin,
|
|
2371
|
+
"productType": product_type,
|
|
2372
|
+
"symbol": symbol,
|
|
2373
|
+
"triggerPrice": trigger_price,
|
|
2374
|
+
"triggerType": trigger_type,
|
|
2375
|
+
"executePrice": execute_price,
|
|
2376
|
+
"size": size,
|
|
2377
|
+
"rangeRate": range_rate,
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
return await self._make_request(
|
|
2381
|
+
"POST", "/api/v2/mix/order/modify-tpsl-order", signed=True, data=data
|
|
2382
|
+
)
|
|
2383
|
+
|
|
2384
|
+
async def futures_modify_plan_order(
|
|
2385
|
+
self,
|
|
2386
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2387
|
+
order_id: str | None = None,
|
|
2388
|
+
client_oid: str | None = None,
|
|
2389
|
+
new_size: str | None = None,
|
|
2390
|
+
new_price: str | None = None,
|
|
2391
|
+
new_callback_ratio: str | None = None,
|
|
2392
|
+
new_trigger_price: str | None = None,
|
|
2393
|
+
new_trigger_type: str | None = None,
|
|
2394
|
+
new_stop_surplus_trigger_price: str | None = None,
|
|
2395
|
+
new_stop_surplus_execute_price: str | None = None,
|
|
2396
|
+
new_stop_surplus_trigger_type: str | None = None,
|
|
2397
|
+
new_stop_loss_trigger_price: str | None = None,
|
|
2398
|
+
new_stop_loss_execute_price: str | None = None,
|
|
2399
|
+
new_stop_loss_trigger_type: str | None = None,
|
|
2400
|
+
) -> dict:
|
|
2401
|
+
"""Изменить триггерный или трейлинг ордер, включая TP/SL.
|
|
2402
|
+
|
|
2403
|
+
https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order
|
|
2404
|
+
"""
|
|
2405
|
+
data = {
|
|
2406
|
+
"orderId": order_id,
|
|
2407
|
+
"clientOid": client_oid,
|
|
2408
|
+
"productType": product_type,
|
|
2409
|
+
"newSize": new_size,
|
|
2410
|
+
"newPrice": new_price,
|
|
2411
|
+
"newCallbackRatio": new_callback_ratio,
|
|
2412
|
+
"newTriggerPrice": new_trigger_price,
|
|
2413
|
+
"newTriggerType": new_trigger_type,
|
|
2414
|
+
"newStopSurplusTriggerPrice": new_stop_surplus_trigger_price,
|
|
2415
|
+
"newStopSurplusExecutePrice": new_stop_surplus_execute_price,
|
|
2416
|
+
"newStopSurplusTriggerType": new_stop_surplus_trigger_type,
|
|
2417
|
+
"newStopLossTriggerPrice": new_stop_loss_trigger_price,
|
|
2418
|
+
"newStopLossExecutePrice": new_stop_loss_execute_price,
|
|
2419
|
+
"newStopLossTriggerType": new_stop_loss_trigger_type,
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
return await self._make_request(
|
|
2423
|
+
"POST", "/api/v2/mix/order/modify-plan-order", signed=True, data=data
|
|
2424
|
+
)
|
|
2425
|
+
|
|
2426
|
+
async def futures_get_pending_plan_orders(
|
|
2427
|
+
self,
|
|
2428
|
+
plan_type: str,
|
|
2429
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2430
|
+
order_id: str | None = None,
|
|
2431
|
+
client_oid: str | None = None,
|
|
2432
|
+
symbol: str | None = None,
|
|
2433
|
+
id_less_than: str | None = None,
|
|
2434
|
+
start_time: str | None = None,
|
|
2435
|
+
end_time: str | None = None,
|
|
2436
|
+
limit: str | None = None,
|
|
2437
|
+
) -> dict:
|
|
2438
|
+
"""Получить текущие активные триггерные ордера.
|
|
2439
|
+
|
|
2440
|
+
https://www.bitget.com/api-doc/contract/plan/get-orders-plan-pending
|
|
2441
|
+
"""
|
|
2442
|
+
params = {
|
|
2443
|
+
"orderId": order_id,
|
|
2444
|
+
"clientOid": client_oid,
|
|
2445
|
+
"symbol": symbol,
|
|
2446
|
+
"planType": plan_type,
|
|
2447
|
+
"productType": product_type,
|
|
2448
|
+
"idLessThan": id_less_than,
|
|
2449
|
+
"startTime": start_time,
|
|
2450
|
+
"endTime": end_time,
|
|
2451
|
+
"limit": limit,
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
return await self._make_request(
|
|
2455
|
+
"GET", "/api/v2/mix/order/orders-plan-pending", signed=True, params=params
|
|
2456
|
+
)
|
|
2457
|
+
|
|
2458
|
+
async def futures_cancel_plan_orders(
|
|
2459
|
+
self,
|
|
2460
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2461
|
+
order_id_list: list[dict[str, str]] | None = None,
|
|
2462
|
+
symbol: str | None = None,
|
|
2463
|
+
margin_coin: str | None = None,
|
|
2464
|
+
plan_type: str | None = None,
|
|
2465
|
+
) -> dict:
|
|
2466
|
+
"""Отменить триггерные ордера по productType, symbol и/или списку orderId.
|
|
2467
|
+
|
|
2468
|
+
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
|
2469
|
+
"""
|
|
2470
|
+
data = {
|
|
2471
|
+
"orderIdList": order_id_list,
|
|
2472
|
+
"symbol": symbol,
|
|
2473
|
+
"productType": product_type,
|
|
2474
|
+
"marginCoin": margin_coin,
|
|
2475
|
+
"planType": plan_type,
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
return await self._make_request(
|
|
2479
|
+
"POST", "/api/v2/mix/order/cancel-plan-order", signed=True, data=data
|
|
2480
|
+
)
|
|
2481
|
+
|
|
2482
|
+
async def futures_get_plan_orders_history(
|
|
2483
|
+
self,
|
|
2484
|
+
plan_type: str,
|
|
2485
|
+
product_type: Literal["USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES"] = "USDT-FUTURES",
|
|
2486
|
+
order_id: str | None = None,
|
|
2487
|
+
client_oid: str | None = None,
|
|
2488
|
+
plan_status: str | None = None,
|
|
2489
|
+
symbol: str | None = None,
|
|
2490
|
+
id_less_than: str | None = None,
|
|
2491
|
+
start_time: str | None = None,
|
|
2492
|
+
end_time: str | None = None,
|
|
2493
|
+
limit: str | None = None,
|
|
2494
|
+
) -> dict:
|
|
2495
|
+
"""Получить историю триггерных ордеров.
|
|
2496
|
+
|
|
2497
|
+
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
|
2498
|
+
"""
|
|
2499
|
+
params = {
|
|
2500
|
+
"orderId": order_id,
|
|
2501
|
+
"clientOid": client_oid,
|
|
2502
|
+
"planType": plan_type,
|
|
2503
|
+
"planStatus": plan_status,
|
|
2504
|
+
"symbol": symbol,
|
|
2505
|
+
"productType": product_type,
|
|
2506
|
+
"idLessThan": id_less_than,
|
|
2507
|
+
"startTime": start_time,
|
|
2508
|
+
"endTime": end_time,
|
|
2509
|
+
"limit": limit,
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
return await self._make_request(
|
|
2513
|
+
"GET", "/api/v2/mix/order/orders-plan-history", signed=True, params=params
|
|
2514
|
+
)
|