deltadefi 0.1.0__py3-none-any.whl → 0.1.3__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.
Potentially problematic release.
This version of deltadefi might be problematic. Click here for more details.
- deltadefi/api.py +1 -1
- deltadefi/clients/accounts.py +1 -1
- deltadefi/clients/markets.py +1 -1
- deltadefi/clients/orders.py +34 -3
- deltadefi/clients/websocket.py +2 -4
- deltadefi/responses/responses.py +10 -0
- deltadefi/utils/__init__.py +2 -0
- deltadefi/utils/helpers.py +46 -0
- {deltadefi-0.1.0.dist-info → deltadefi-0.1.3.dist-info}/METADATA +1 -1
- {deltadefi-0.1.0.dist-info → deltadefi-0.1.3.dist-info}/RECORD +11 -9
- {deltadefi-0.1.0.dist-info → deltadefi-0.1.3.dist-info}/WHEEL +0 -0
deltadefi/api.py
CHANGED
deltadefi/clients/accounts.py
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from sidan_gin import Asset, UTxO
|
|
4
4
|
|
|
5
5
|
from deltadefi.api import API
|
|
6
|
-
from deltadefi.lib.utils import check_required_parameter, check_required_parameters
|
|
7
6
|
from deltadefi.models.models import OrderStatusType
|
|
8
7
|
from deltadefi.responses import (
|
|
9
8
|
BuildDepositTransactionResponse,
|
|
@@ -22,6 +21,7 @@ from deltadefi.responses.accounts import (
|
|
|
22
21
|
GetOrderRecordsResponse,
|
|
23
22
|
SubmitTransferalTransactionResponse,
|
|
24
23
|
)
|
|
24
|
+
from deltadefi.utils import check_required_parameter, check_required_parameters
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class Accounts(API):
|
deltadefi/clients/markets.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from typing import Literal
|
|
2
2
|
|
|
3
3
|
from deltadefi.api import API
|
|
4
|
-
from deltadefi.lib.utils import check_required_parameter, check_required_parameters
|
|
5
4
|
from deltadefi.responses import GetAggregatedPriceResponse, GetMarketPriceResponse
|
|
5
|
+
from deltadefi.utils import check_required_parameter, check_required_parameters
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Market(API):
|
deltadefi/clients/orders.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
from deltadefi.api import API
|
|
2
|
-
from deltadefi.lib.utils import check_required_parameter, check_required_parameters
|
|
3
2
|
from deltadefi.models.models import OrderSide, OrderType
|
|
4
3
|
from deltadefi.responses import (
|
|
4
|
+
BuildCancelAllOrdersTransactionResponse,
|
|
5
5
|
BuildCancelOrderTransactionResponse,
|
|
6
6
|
BuildPlaceOrderTransactionResponse,
|
|
7
|
+
SubmitCancelAllOrdersTransactionResponse,
|
|
7
8
|
SubmitPlaceOrderTransactionResponse,
|
|
8
9
|
)
|
|
10
|
+
from deltadefi.utils import check_required_parameter, check_required_parameters
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class Order(API):
|
|
@@ -86,6 +88,19 @@ class Order(API):
|
|
|
86
88
|
url_path = f"/{order_id}/build"
|
|
87
89
|
return self.send_request("DELETE", self.group_url_path + url_path, **kwargs)
|
|
88
90
|
|
|
91
|
+
def build_cancel_all_orders_transaction(
|
|
92
|
+
self, **kwargs
|
|
93
|
+
) -> BuildCancelAllOrdersTransactionResponse:
|
|
94
|
+
"""
|
|
95
|
+
Build a cancel all orders transaction.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
A BuildCancelAllOrdersTransactionResponse object containing the built cancel all orders transaction.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
url_path = "/cancel-all/build"
|
|
102
|
+
return self.send_request("DELETE", self.group_url_path + url_path, **kwargs)
|
|
103
|
+
|
|
89
104
|
def submit_place_order_transaction(
|
|
90
105
|
self, order_id: str, signed_tx: str, **kwargs
|
|
91
106
|
) -> SubmitPlaceOrderTransactionResponse:
|
|
@@ -93,7 +108,8 @@ class Order(API):
|
|
|
93
108
|
Submit a place order transaction.
|
|
94
109
|
|
|
95
110
|
Args:
|
|
96
|
-
|
|
111
|
+
order_id: The ID of the order to be placed.
|
|
112
|
+
signed_tx: The signed transaction hex string for placing the order.
|
|
97
113
|
|
|
98
114
|
Returns:
|
|
99
115
|
A SubmitPlaceOrderTransactionResponse object containing the submitted order transaction.
|
|
@@ -109,10 +125,25 @@ class Order(API):
|
|
|
109
125
|
Submit a cancel order transaction.
|
|
110
126
|
|
|
111
127
|
Args:
|
|
112
|
-
|
|
128
|
+
signed_tx: The signed transaction hex string for canceling the order.
|
|
113
129
|
"""
|
|
114
130
|
check_required_parameter(signed_tx, "signed_tx")
|
|
115
131
|
payload = {"signed_tx": signed_tx, **kwargs}
|
|
116
132
|
|
|
117
133
|
path_url = "/submit"
|
|
118
134
|
return self.send_request("DELETE", self.group_url_path + path_url, payload)
|
|
135
|
+
|
|
136
|
+
def submit_cancel_all_orders_transaction(
|
|
137
|
+
self, signed_txs: list[str], **kwargs
|
|
138
|
+
) -> SubmitCancelAllOrdersTransactionResponse:
|
|
139
|
+
"""
|
|
140
|
+
Submit a cancel all orders transaction.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
signed_txs: A list of signed transaction hex strings for canceling all orders.
|
|
144
|
+
"""
|
|
145
|
+
check_required_parameter(signed_txs, "signed_txs")
|
|
146
|
+
payload = {"signed_txs": signed_txs, **kwargs}
|
|
147
|
+
|
|
148
|
+
path_url = "/cancel-all/submit"
|
|
149
|
+
return self.send_request("DELETE", self.group_url_path + path_url, payload)
|
deltadefi/clients/websocket.py
CHANGED
|
@@ -187,10 +187,8 @@ class WebSocketClient:
|
|
|
187
187
|
# In a more complex implementation, you'd want to handle multiple concurrent subscriptions
|
|
188
188
|
if self.subscriptions:
|
|
189
189
|
first_sub = next(iter(self.subscriptions.values()))
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
else:
|
|
193
|
-
await self.connect()
|
|
190
|
+
# Always use the stored endpoint for reconnection
|
|
191
|
+
await self.connect(first_sub["endpoint"])
|
|
194
192
|
else:
|
|
195
193
|
await self.connect()
|
|
196
194
|
|
deltadefi/responses/responses.py
CHANGED
|
@@ -61,3 +61,13 @@ class PostOrderResponse(SubmitPlaceOrderTransactionResponse):
|
|
|
61
61
|
@dataclass
|
|
62
62
|
class BuildCancelOrderTransactionResponse(TypedDict):
|
|
63
63
|
tx_hex: str
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass
|
|
67
|
+
class BuildCancelAllOrdersTransactionResponse(TypedDict):
|
|
68
|
+
tx_hexes: list[str]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass
|
|
72
|
+
class SubmitCancelAllOrdersTransactionResponse(TypedDict):
|
|
73
|
+
cancelled_order_ids: list[str]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from urllib.parse import urlencode
|
|
2
|
+
|
|
3
|
+
from deltadefi.error import (
|
|
4
|
+
ParameterRequiredError,
|
|
5
|
+
ParameterTypeError,
|
|
6
|
+
ParameterValueError,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def clean_none_value(d) -> dict:
|
|
11
|
+
out = {}
|
|
12
|
+
for k in d:
|
|
13
|
+
if d[k] is not None:
|
|
14
|
+
out[k] = d[k]
|
|
15
|
+
return out
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def check_required_parameter(value, name):
|
|
19
|
+
if not value and value != 0:
|
|
20
|
+
raise ParameterRequiredError([name])
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def check_required_parameters(params):
|
|
24
|
+
"""Validate multiple parameters
|
|
25
|
+
params = [
|
|
26
|
+
['btcusdt', 'symbol'],
|
|
27
|
+
[10, 'price']
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
for p in params:
|
|
32
|
+
check_required_parameter(p[0], p[1])
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def check_enum_parameter(value, enum_class):
|
|
36
|
+
if value not in {item.value for item in enum_class}:
|
|
37
|
+
raise ParameterValueError([value])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def check_type_parameter(value, name, data_type):
|
|
41
|
+
if value is not None and not isinstance(value, data_type):
|
|
42
|
+
raise ParameterTypeError([name, data_type])
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def encoded_string(query):
|
|
46
|
+
return urlencode(query, True).replace("%40", "@")
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
deltadefi/__init__.py,sha256=pKZHfRdXT3f3kncxAKamtk5V3EDQB8Ocy8xBmjhsJ4A,63
|
|
2
|
-
deltadefi/api.py,sha256=
|
|
2
|
+
deltadefi/api.py,sha256=jnTK7g1WHIDPbrYQWYdMfT0sgWcUgGKRn_uHVNBI-CY,2720
|
|
3
3
|
deltadefi/error.py,sha256=zDMx5ukb5zs0AOeGAHjXiIMDZ0LbEcaGyVi45WFJfmI,1658
|
|
4
4
|
deltadefi/api_resources/__init__.py,sha256=_SGHTpaQTIBvh9Rm868IT5pXpvvGBPqz3bxkY6YapZ4,61
|
|
5
5
|
deltadefi/api_resources/auth.py,sha256=4QCEI4P4UlQPQYctqY9Oat4hn7lsI95QihHTD_0PZKg,245
|
|
6
6
|
deltadefi/api_resources/validation.py,sha256=vz-hovpLy9SMOIFGcBHC8vWZH8CJRlQP8rcbbTSM-PM,1375
|
|
7
7
|
deltadefi/clients/__init__.py,sha256=4hyPuk6_bcJGXUElOvkgZ7ARlQ6QwKLp-nFgCXTbFVI,76
|
|
8
|
-
deltadefi/clients/accounts.py,sha256=
|
|
8
|
+
deltadefi/clients/accounts.py,sha256=sfdPh8CWsein1UAn8h-Y0JB_zMvr95FZx2QuaL6Tico,8407
|
|
9
9
|
deltadefi/clients/client.py,sha256=2hLOsxqBc8eu_6ovuYLRoK2popdI1_t3pGcEP8Keu9A,4619
|
|
10
|
-
deltadefi/clients/markets.py,sha256
|
|
11
|
-
deltadefi/clients/orders.py,sha256
|
|
12
|
-
deltadefi/clients/websocket.py,sha256=
|
|
10
|
+
deltadefi/clients/markets.py,sha256=--wMUFYkZryZjj8wO-rxxJhHEbM3UmcPpubrHU92Bdk,1985
|
|
11
|
+
deltadefi/clients/orders.py,sha256=-VZppN4dJitzRkkNCWy9PWLdwGUpnYBNhugaUZIr1PU,5010
|
|
12
|
+
deltadefi/clients/websocket.py,sha256=o6BEd_KVPmSLpMhAC7j98ACqJuMYPxjcLt57EXzoeqw,12370
|
|
13
13
|
deltadefi/constants/__init__.py,sha256=7LkrzfLTJsCCUl5IgZYrl-AbY_cf1fftcLklgnBYDTs,40
|
|
14
14
|
deltadefi/constants/constants.py,sha256=4bkY4kfNcsgoCe1xU8n2We7w-vxZXyzVw5rQvAsx4j8,168
|
|
15
15
|
deltadefi/models/__init__.py,sha256=oDJj6Y4gXN6C7Oz_t2fq8hej-D0G9OqfXjL4Jaeq8z8,37
|
|
16
16
|
deltadefi/models/models.py,sha256=kiRpCdzUh3WmyuFOaxlZ1rjsQ2cxLWjVFBCqsHXMtBc,1633
|
|
17
17
|
deltadefi/responses/__init__.py,sha256=JKSIUQu6qI_XhbAR2mVMCKNvR6x_vFZdyLGOuQTVrVY,64
|
|
18
18
|
deltadefi/responses/accounts.py,sha256=o-It4vyNsiDeCmHa-XQl77KuCVtJi7qlPdn059fgwcI,1590
|
|
19
|
-
deltadefi/responses/responses.py,sha256=
|
|
20
|
-
deltadefi
|
|
21
|
-
deltadefi
|
|
22
|
-
deltadefi-0.1.
|
|
19
|
+
deltadefi/responses/responses.py,sha256=BqutIkilVCibcxH_10FwN-dY3p3g9XFDOp9NYPbuLPw,1214
|
|
20
|
+
deltadefi/utils/__init__.py,sha256=krFwciyC3ArJ1j96b5IOVMqKfiFjnKtgQvYPsw3A-MU,38
|
|
21
|
+
deltadefi/utils/helpers.py,sha256=S90RpdkKJS-khuwk8B0vhOdTQXuUkutZ0RZLybeF550,1025
|
|
22
|
+
deltadefi-0.1.3.dist-info/METADATA,sha256=Z9x_HjX5QSutdHYw5AIvIlTW3LoNMpciyPbAzEHxXY4,3075
|
|
23
|
+
deltadefi-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
24
|
+
deltadefi-0.1.3.dist-info/RECORD,,
|
|
File without changes
|