deltadefi 0.1.1__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of deltadefi might be problematic. Click here for more details.
- {deltadefi-0.1.1 → deltadefi-1.0.0}/PKG-INFO +1 -1
- {deltadefi-0.1.1 → deltadefi-1.0.0}/coverage.xml +202 -175
- {deltadefi-0.1.1 → deltadefi-1.0.0}/pyproject.toml +2 -1
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/clients/accounts.py +55 -15
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/clients/client.py +30 -11
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/clients/markets.py +16 -10
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/clients/orders.py +53 -5
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/clients/websocket.py +13 -8
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/responses/responses.py +10 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/uv.lock +15 -1
- {deltadefi-0.1.1 → deltadefi-1.0.0}/.env.example +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/.github/workflows/publish.yml +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/.gitignore +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/.pre-commit-config.yaml +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/Makefile +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/README.md +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/examples/websocket_example.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/api.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/api_resources/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/api_resources/auth.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/api_resources/validation.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/clients/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/constants/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/constants/constants.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/error.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/models/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/models/models.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/responses/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/responses/accounts.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/utils/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/src/deltadefi/utils/helpers.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/tests/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/tests/clients/__init__.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/tests/clients/test_accounts.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/tests/clients/test_order.py +0 -0
- {deltadefi-0.1.1 → deltadefi-1.0.0}/tests/clients/test_sign.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" ?>
|
|
2
|
-
<coverage version="7.10.6" timestamp="
|
|
2
|
+
<coverage version="7.10.6" timestamp="1762773626765" lines-valid="648" lines-covered="294" line-rate="0.4537" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
|
|
3
3
|
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.10.6 -->
|
|
4
4
|
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
|
|
5
5
|
<sources>
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
</class>
|
|
160
160
|
</classes>
|
|
161
161
|
</package>
|
|
162
|
-
<package name="src.deltadefi.clients" line-rate="0.
|
|
162
|
+
<package name="src.deltadefi.clients" line-rate="0.2485" branch-rate="0" complexity="0">
|
|
163
163
|
<classes>
|
|
164
164
|
<class name="__init__.py" filename="src/deltadefi/clients/__init__.py" complexity="0" line-rate="1" branch-rate="0">
|
|
165
165
|
<methods/>
|
|
@@ -168,76 +168,77 @@
|
|
|
168
168
|
<line number="3" hits="1"/>
|
|
169
169
|
</lines>
|
|
170
170
|
</class>
|
|
171
|
-
<class name="accounts.py" filename="src/deltadefi/clients/accounts.py" complexity="0" line-rate="0.
|
|
171
|
+
<class name="accounts.py" filename="src/deltadefi/clients/accounts.py" complexity="0" line-rate="0.3538" branch-rate="0">
|
|
172
172
|
<methods/>
|
|
173
173
|
<lines>
|
|
174
|
-
<line number="
|
|
175
|
-
<line number="
|
|
174
|
+
<line number="2" hits="1"/>
|
|
175
|
+
<line number="4" hits="1"/>
|
|
176
176
|
<line number="6" hits="1"/>
|
|
177
177
|
<line number="7" hits="1"/>
|
|
178
|
-
<line number="
|
|
179
|
-
<line number="
|
|
180
|
-
<line number="
|
|
181
|
-
<line number="
|
|
182
|
-
<line number="
|
|
183
|
-
<line number="35" hits="
|
|
184
|
-
<line number="
|
|
185
|
-
<line number="
|
|
178
|
+
<line number="8" hits="1"/>
|
|
179
|
+
<line number="18" hits="1"/>
|
|
180
|
+
<line number="25" hits="1"/>
|
|
181
|
+
<line number="28" hits="1"/>
|
|
182
|
+
<line number="33" hits="1"/>
|
|
183
|
+
<line number="35" hits="1"/>
|
|
184
|
+
<line number="36" hits="0"/>
|
|
185
|
+
<line number="38" hits="1"/>
|
|
186
186
|
<line number="46" hits="0"/>
|
|
187
|
-
<line number="
|
|
188
|
-
<line number="
|
|
189
|
-
<line number="
|
|
190
|
-
<line number="
|
|
191
|
-
<line number="66" hits="
|
|
192
|
-
<line number="
|
|
193
|
-
<line number="
|
|
194
|
-
<line number="76" hits="0"/>
|
|
195
|
-
<line number="77" hits="0"/>
|
|
187
|
+
<line number="47" hits="0"/>
|
|
188
|
+
<line number="52" hits="1"/>
|
|
189
|
+
<line number="60" hits="0"/>
|
|
190
|
+
<line number="61" hits="0"/>
|
|
191
|
+
<line number="66" hits="1"/>
|
|
192
|
+
<line number="73" hits="0"/>
|
|
193
|
+
<line number="74" hits="0"/>
|
|
196
194
|
<line number="79" hits="1"/>
|
|
197
|
-
<line number="
|
|
198
|
-
<line number="
|
|
199
|
-
<line number="
|
|
200
|
-
<line number="
|
|
201
|
-
<line number="
|
|
195
|
+
<line number="86" hits="0"/>
|
|
196
|
+
<line number="87" hits="0"/>
|
|
197
|
+
<line number="92" hits="1"/>
|
|
198
|
+
<line number="107" hits="0"/>
|
|
199
|
+
<line number="108" hits="0"/>
|
|
202
200
|
<line number="110" hits="0"/>
|
|
203
|
-
<line number="
|
|
204
|
-
<line number="
|
|
205
|
-
<line number="
|
|
206
|
-
<line number="
|
|
207
|
-
<line number="
|
|
208
|
-
<line number="
|
|
209
|
-
<line number="138" hits="0"/>
|
|
201
|
+
<line number="111" hits="0"/>
|
|
202
|
+
<line number="116" hits="1"/>
|
|
203
|
+
<line number="126" hits="0"/>
|
|
204
|
+
<line number="128" hits="0"/>
|
|
205
|
+
<line number="129" hits="0"/>
|
|
206
|
+
<line number="134" hits="1"/>
|
|
210
207
|
<line number="141" hits="0"/>
|
|
211
|
-
<line number="
|
|
212
|
-
<line number="
|
|
213
|
-
<line number="
|
|
208
|
+
<line number="142" hits="0"/>
|
|
209
|
+
<line number="147" hits="1"/>
|
|
210
|
+
<line number="160" hits="0"/>
|
|
214
211
|
<line number="163" hits="0"/>
|
|
215
|
-
<line number="
|
|
216
|
-
<line number="
|
|
217
|
-
<line number="
|
|
218
|
-
<line number="
|
|
219
|
-
<line number="
|
|
220
|
-
<line number="185" hits="0"/>
|
|
212
|
+
<line number="169" hits="0"/>
|
|
213
|
+
<line number="170" hits="0"/>
|
|
214
|
+
<line number="175" hits="1"/>
|
|
215
|
+
<line number="188" hits="0"/>
|
|
216
|
+
<line number="189" hits="0"/>
|
|
221
217
|
<line number="191" hits="0"/>
|
|
222
218
|
<line number="192" hits="0"/>
|
|
223
|
-
<line number="
|
|
224
|
-
<line number="207" hits="0"/>
|
|
225
|
-
<line number="208" hits="0"/>
|
|
219
|
+
<line number="197" hits="1"/>
|
|
226
220
|
<line number="210" hits="0"/>
|
|
227
|
-
<line number="
|
|
228
|
-
<line number="
|
|
229
|
-
<line number="
|
|
230
|
-
<line number="
|
|
231
|
-
<line number="
|
|
232
|
-
<line number="
|
|
233
|
-
<line number="
|
|
234
|
-
<line number="
|
|
235
|
-
<line number="
|
|
236
|
-
<line number="
|
|
237
|
-
<line number="
|
|
221
|
+
<line number="213" hits="0"/>
|
|
222
|
+
<line number="219" hits="0"/>
|
|
223
|
+
<line number="220" hits="0"/>
|
|
224
|
+
<line number="225" hits="1"/>
|
|
225
|
+
<line number="238" hits="0"/>
|
|
226
|
+
<line number="239" hits="0"/>
|
|
227
|
+
<line number="241" hits="0"/>
|
|
228
|
+
<line number="242" hits="0"/>
|
|
229
|
+
<line number="247" hits="1"/>
|
|
230
|
+
<line number="260" hits="0"/>
|
|
231
|
+
<line number="261" hits="0"/>
|
|
232
|
+
<line number="263" hits="0"/>
|
|
233
|
+
<line number="264" hits="0"/>
|
|
234
|
+
<line number="269" hits="1"/>
|
|
235
|
+
<line number="282" hits="0"/>
|
|
236
|
+
<line number="283" hits="0"/>
|
|
237
|
+
<line number="285" hits="0"/>
|
|
238
|
+
<line number="286" hits="0"/>
|
|
238
239
|
</lines>
|
|
239
240
|
</class>
|
|
240
|
-
<class name="client.py" filename="src/deltadefi/clients/client.py" complexity="0" line-rate="0.
|
|
241
|
+
<class name="client.py" filename="src/deltadefi/clients/client.py" complexity="0" line-rate="0.2407" branch-rate="0">
|
|
241
242
|
<methods/>
|
|
242
243
|
<lines>
|
|
243
244
|
<line number="1" hits="1"/>
|
|
@@ -249,40 +250,51 @@
|
|
|
249
250
|
<line number="8" hits="1"/>
|
|
250
251
|
<line number="11" hits="1"/>
|
|
251
252
|
<line number="16" hits="1"/>
|
|
252
|
-
<line number="31" hits="0"/>
|
|
253
253
|
<line number="32" hits="0"/>
|
|
254
254
|
<line number="33" hits="0"/>
|
|
255
|
+
<line number="34" hits="0"/>
|
|
255
256
|
<line number="35" hits="0"/>
|
|
256
|
-
<line number="
|
|
257
|
+
<line number="37" hits="0"/>
|
|
257
258
|
<line number="38" hits="0"/>
|
|
258
259
|
<line number="39" hits="0"/>
|
|
259
260
|
<line number="41" hits="0"/>
|
|
260
261
|
<line number="42" hits="0"/>
|
|
261
262
|
<line number="44" hits="0"/>
|
|
262
263
|
<line number="45" hits="0"/>
|
|
263
|
-
<line number="
|
|
264
|
-
<line number="
|
|
264
|
+
<line number="47" hits="0"/>
|
|
265
|
+
<line number="48" hits="0"/>
|
|
265
266
|
<line number="50" hits="0"/>
|
|
266
|
-
<line number="
|
|
267
|
-
<line number="
|
|
268
|
-
<line number="
|
|
269
|
-
<line number="
|
|
270
|
-
<line number="
|
|
271
|
-
<line number="
|
|
272
|
-
<line number="
|
|
267
|
+
<line number="51" hits="0"/>
|
|
268
|
+
<line number="52" hits="0"/>
|
|
269
|
+
<line number="53" hits="0"/>
|
|
270
|
+
<line number="55" hits="1"/>
|
|
271
|
+
<line number="65" hits="0"/>
|
|
272
|
+
<line number="66" hits="0"/>
|
|
273
|
+
<line number="67" hits="0"/>
|
|
274
|
+
<line number="69" hits="1"/>
|
|
275
|
+
<line number="90" hits="0"/>
|
|
276
|
+
<line number="91" hits="0"/>
|
|
273
277
|
<line number="93" hits="0"/>
|
|
274
|
-
<line number="94" hits="0"/>
|
|
275
278
|
<line number="96" hits="0"/>
|
|
276
|
-
<line number="
|
|
279
|
+
<line number="97" hits="0"/>
|
|
277
280
|
<line number="100" hits="0"/>
|
|
278
|
-
<line number="
|
|
279
|
-
<line number="
|
|
281
|
+
<line number="102" hits="1"/>
|
|
282
|
+
<line number="109" hits="0"/>
|
|
283
|
+
<line number="110" hits="0"/>
|
|
280
284
|
<line number="112" hits="0"/>
|
|
281
285
|
<line number="113" hits="0"/>
|
|
286
|
+
<line number="114" hits="0"/>
|
|
282
287
|
<line number="115" hits="0"/>
|
|
283
|
-
<line number="
|
|
284
|
-
<line number="
|
|
285
|
-
<line number="
|
|
288
|
+
<line number="117" hits="1"/>
|
|
289
|
+
<line number="121" hits="0"/>
|
|
290
|
+
<line number="122" hits="0"/>
|
|
291
|
+
<line number="124" hits="0"/>
|
|
292
|
+
<line number="126" hits="0"/>
|
|
293
|
+
<line number="127" hits="0"/>
|
|
294
|
+
<line number="128" hits="0"/>
|
|
295
|
+
<line number="129" hits="0"/>
|
|
296
|
+
<line number="131" hits="0"/>
|
|
297
|
+
<line number="134" hits="0"/>
|
|
286
298
|
</lines>
|
|
287
299
|
</class>
|
|
288
300
|
<class name="markets.py" filename="src/deltadefi/clients/markets.py" complexity="0" line-rate="0.5294" branch-rate="0">
|
|
@@ -301,46 +313,55 @@
|
|
|
301
313
|
<line number="29" hits="0"/>
|
|
302
314
|
<line number="30" hits="0"/>
|
|
303
315
|
<line number="31" hits="0"/>
|
|
304
|
-
<line number="
|
|
305
|
-
<line number="
|
|
306
|
-
<line number="
|
|
307
|
-
<line number="
|
|
316
|
+
<line number="36" hits="1"/>
|
|
317
|
+
<line number="53" hits="0"/>
|
|
318
|
+
<line number="61" hits="0"/>
|
|
319
|
+
<line number="62" hits="0"/>
|
|
308
320
|
</lines>
|
|
309
321
|
</class>
|
|
310
|
-
<class name="orders.py" filename="src/deltadefi/clients/orders.py" complexity="0" line-rate="0.
|
|
322
|
+
<class name="orders.py" filename="src/deltadefi/clients/orders.py" complexity="0" line-rate="0.35" branch-rate="0">
|
|
311
323
|
<methods/>
|
|
312
324
|
<lines>
|
|
313
325
|
<line number="1" hits="1"/>
|
|
314
|
-
<line number="2" hits="1"/>
|
|
315
326
|
<line number="3" hits="1"/>
|
|
316
|
-
<line number="
|
|
317
|
-
<line number="
|
|
318
|
-
<line number="
|
|
319
|
-
<line number="
|
|
320
|
-
<line number="
|
|
321
|
-
<line number="
|
|
322
|
-
<line number="
|
|
323
|
-
<line number="
|
|
324
|
-
<line number="
|
|
325
|
-
<line number="55" hits="0"/>
|
|
327
|
+
<line number="4" hits="1"/>
|
|
328
|
+
<line number="5" hits="1"/>
|
|
329
|
+
<line number="12" hits="1"/>
|
|
330
|
+
<line number="15" hits="1"/>
|
|
331
|
+
<line number="20" hits="1"/>
|
|
332
|
+
<line number="22" hits="1"/>
|
|
333
|
+
<line number="23" hits="0"/>
|
|
334
|
+
<line number="25" hits="1"/>
|
|
335
|
+
<line number="47" hits="0"/>
|
|
326
336
|
<line number="56" hits="0"/>
|
|
337
|
+
<line number="57" hits="0"/>
|
|
338
|
+
<line number="59" hits="0"/>
|
|
327
339
|
<line number="60" hits="0"/>
|
|
328
|
-
<line number="
|
|
329
|
-
<line number="
|
|
330
|
-
<line number="
|
|
331
|
-
<line number="
|
|
332
|
-
<line number="
|
|
333
|
-
<line number="
|
|
334
|
-
<line number="
|
|
335
|
-
<line number="
|
|
336
|
-
<line number="
|
|
337
|
-
<line number="
|
|
338
|
-
<line number="
|
|
339
|
-
<line number="
|
|
340
|
-
<line number="
|
|
341
|
-
<line number="
|
|
342
|
-
<line number="
|
|
343
|
-
<line number="
|
|
340
|
+
<line number="64" hits="0"/>
|
|
341
|
+
<line number="72" hits="0"/>
|
|
342
|
+
<line number="73" hits="0"/>
|
|
343
|
+
<line number="78" hits="1"/>
|
|
344
|
+
<line number="91" hits="0"/>
|
|
345
|
+
<line number="93" hits="0"/>
|
|
346
|
+
<line number="94" hits="0"/>
|
|
347
|
+
<line number="99" hits="1"/>
|
|
348
|
+
<line number="109" hits="0"/>
|
|
349
|
+
<line number="110" hits="0"/>
|
|
350
|
+
<line number="115" hits="1"/>
|
|
351
|
+
<line number="128" hits="0"/>
|
|
352
|
+
<line number="129" hits="0"/>
|
|
353
|
+
<line number="131" hits="0"/>
|
|
354
|
+
<line number="132" hits="0"/>
|
|
355
|
+
<line number="137" hits="1"/>
|
|
356
|
+
<line number="144" hits="0"/>
|
|
357
|
+
<line number="145" hits="0"/>
|
|
358
|
+
<line number="147" hits="0"/>
|
|
359
|
+
<line number="148" hits="0"/>
|
|
360
|
+
<line number="150" hits="1"/>
|
|
361
|
+
<line number="159" hits="0"/>
|
|
362
|
+
<line number="160" hits="0"/>
|
|
363
|
+
<line number="162" hits="0"/>
|
|
364
|
+
<line number="163" hits="0"/>
|
|
344
365
|
</lines>
|
|
345
366
|
</class>
|
|
346
367
|
<class name="websocket.py" filename="src/deltadefi/clients/websocket.py" complexity="0" line-rate="0.141" branch-rate="0">
|
|
@@ -405,103 +426,103 @@
|
|
|
405
426
|
<line number="120" hits="0"/>
|
|
406
427
|
<line number="122" hits="1"/>
|
|
407
428
|
<line number="124" hits="0"/>
|
|
408
|
-
<line number="
|
|
409
|
-
<line number="
|
|
410
|
-
<line number="
|
|
411
|
-
<line number="
|
|
412
|
-
<line number="133" hits="0"/>
|
|
429
|
+
<line number="126" hits="0"/>
|
|
430
|
+
<line number="129" hits="0"/>
|
|
431
|
+
<line number="132" hits="0"/>
|
|
432
|
+
<line number="134" hits="0"/>
|
|
413
433
|
<line number="135" hits="0"/>
|
|
414
434
|
<line number="137" hits="0"/>
|
|
415
|
-
<line number="
|
|
416
|
-
<line number="
|
|
435
|
+
<line number="139" hits="0"/>
|
|
436
|
+
<line number="141" hits="0"/>
|
|
417
437
|
<line number="142" hits="0"/>
|
|
418
|
-
<line number="
|
|
419
|
-
<line number="
|
|
438
|
+
<line number="144" hits="0"/>
|
|
439
|
+
<line number="146" hits="0"/>
|
|
420
440
|
<line number="147" hits="0"/>
|
|
421
441
|
<line number="149" hits="0"/>
|
|
422
|
-
<line number="
|
|
423
|
-
<line number="
|
|
424
|
-
<line number="
|
|
442
|
+
<line number="151" hits="0"/>
|
|
443
|
+
<line number="153" hits="0"/>
|
|
444
|
+
<line number="154" hits="0"/>
|
|
445
|
+
<line number="156" hits="0"/>
|
|
425
446
|
<line number="159" hits="0"/>
|
|
426
|
-
<line number="
|
|
427
|
-
<line number="
|
|
428
|
-
<line number="
|
|
429
|
-
<line number="
|
|
430
|
-
<line number="173" hits="0"/>
|
|
431
|
-
<line number="174" hits="0"/>
|
|
447
|
+
<line number="163" hits="0"/>
|
|
448
|
+
<line number="169" hits="0"/>
|
|
449
|
+
<line number="170" hits="0"/>
|
|
450
|
+
<line number="172" hits="0"/>
|
|
432
451
|
<line number="175" hits="0"/>
|
|
433
|
-
<line number="
|
|
434
|
-
<line number="178" hits="
|
|
435
|
-
<line number="
|
|
452
|
+
<line number="177" hits="0"/>
|
|
453
|
+
<line number="178" hits="0"/>
|
|
454
|
+
<line number="181" hits="0"/>
|
|
455
|
+
<line number="182" hits="0"/>
|
|
436
456
|
<line number="183" hits="0"/>
|
|
437
|
-
<line number="185" hits="
|
|
438
|
-
<line number="
|
|
439
|
-
<line number="189" hits="0"/>
|
|
457
|
+
<line number="185" hits="1"/>
|
|
458
|
+
<line number="187" hits="0"/>
|
|
440
459
|
<line number="190" hits="0"/>
|
|
441
|
-
<line number="
|
|
442
|
-
<line number="193" hits="0"/>
|
|
460
|
+
<line number="192" hits="0"/>
|
|
443
461
|
<line number="195" hits="0"/>
|
|
444
|
-
<line number="
|
|
462
|
+
<line number="196" hits="0"/>
|
|
445
463
|
<line number="198" hits="0"/>
|
|
446
|
-
<line number="199" hits="0"/>
|
|
447
464
|
<line number="200" hits="0"/>
|
|
448
|
-
<line number="202" hits="
|
|
465
|
+
<line number="202" hits="0"/>
|
|
466
|
+
<line number="203" hits="0"/>
|
|
449
467
|
<line number="204" hits="0"/>
|
|
450
468
|
<line number="205" hits="0"/>
|
|
469
|
+
<line number="207" hits="1"/>
|
|
451
470
|
<line number="209" hits="0"/>
|
|
452
471
|
<line number="210" hits="0"/>
|
|
453
|
-
<line number="
|
|
454
|
-
<line number="
|
|
455
|
-
<line number="
|
|
456
|
-
<line number="
|
|
457
|
-
<line number="
|
|
458
|
-
<line number="
|
|
459
|
-
<line number="
|
|
460
|
-
<line number="
|
|
472
|
+
<line number="214" hits="0"/>
|
|
473
|
+
<line number="215" hits="0"/>
|
|
474
|
+
<line number="216" hits="0"/>
|
|
475
|
+
<line number="217" hits="0"/>
|
|
476
|
+
<line number="218" hits="0"/>
|
|
477
|
+
<line number="220" hits="1"/>
|
|
478
|
+
<line number="228" hits="0"/>
|
|
479
|
+
<line number="230" hits="1"/>
|
|
480
|
+
<line number="237" hits="0"/>
|
|
461
481
|
<line number="238" hits="0"/>
|
|
462
|
-
<line number="239" hits="0"/>
|
|
463
|
-
<line number="242" hits="0"/>
|
|
464
482
|
<line number="243" hits="0"/>
|
|
465
|
-
<line number="
|
|
483
|
+
<line number="244" hits="0"/>
|
|
484
|
+
<line number="247" hits="0"/>
|
|
485
|
+
<line number="248" hits="0"/>
|
|
466
486
|
<line number="251" hits="0"/>
|
|
467
|
-
<line number="
|
|
468
|
-
<line number="
|
|
469
|
-
<line number="
|
|
487
|
+
<line number="256" hits="0"/>
|
|
488
|
+
<line number="258" hits="1"/>
|
|
489
|
+
<line number="265" hits="0"/>
|
|
470
490
|
<line number="266" hits="0"/>
|
|
471
|
-
<line number="267" hits="0"/>
|
|
472
|
-
<line number="270" hits="0"/>
|
|
473
491
|
<line number="271" hits="0"/>
|
|
474
|
-
<line number="
|
|
492
|
+
<line number="272" hits="0"/>
|
|
493
|
+
<line number="275" hits="0"/>
|
|
494
|
+
<line number="276" hits="0"/>
|
|
475
495
|
<line number="279" hits="0"/>
|
|
476
|
-
<line number="
|
|
477
|
-
<line number="
|
|
478
|
-
<line number="
|
|
496
|
+
<line number="284" hits="0"/>
|
|
497
|
+
<line number="286" hits="1"/>
|
|
498
|
+
<line number="293" hits="0"/>
|
|
479
499
|
<line number="294" hits="0"/>
|
|
480
|
-
<line number="295" hits="0"/>
|
|
481
|
-
<line number="298" hits="0"/>
|
|
482
500
|
<line number="299" hits="0"/>
|
|
483
|
-
<line number="
|
|
501
|
+
<line number="300" hits="0"/>
|
|
502
|
+
<line number="303" hits="0"/>
|
|
503
|
+
<line number="304" hits="0"/>
|
|
484
504
|
<line number="307" hits="0"/>
|
|
485
|
-
<line number="
|
|
486
|
-
<line number="314" hits="
|
|
487
|
-
<line number="
|
|
505
|
+
<line number="312" hits="0"/>
|
|
506
|
+
<line number="314" hits="1"/>
|
|
507
|
+
<line number="319" hits="0"/>
|
|
488
508
|
<line number="320" hits="0"/>
|
|
489
|
-
<line number="321" hits="0"/>
|
|
490
|
-
<line number="324" hits="0"/>
|
|
491
509
|
<line number="325" hits="0"/>
|
|
492
|
-
<line number="
|
|
510
|
+
<line number="326" hits="0"/>
|
|
493
511
|
<line number="329" hits="0"/>
|
|
494
|
-
<line number="
|
|
495
|
-
<line number="
|
|
496
|
-
<line number="
|
|
497
|
-
<line number="
|
|
498
|
-
<line number="
|
|
499
|
-
<line number="
|
|
500
|
-
<line number="
|
|
501
|
-
<line number="
|
|
502
|
-
<line number="
|
|
512
|
+
<line number="330" hits="0"/>
|
|
513
|
+
<line number="333" hits="0"/>
|
|
514
|
+
<line number="334" hits="0"/>
|
|
515
|
+
<line number="336" hits="1"/>
|
|
516
|
+
<line number="343" hits="0"/>
|
|
517
|
+
<line number="344" hits="0"/>
|
|
518
|
+
<line number="346" hits="0"/>
|
|
519
|
+
<line number="347" hits="0"/>
|
|
520
|
+
<line number="353" hits="0"/>
|
|
503
521
|
<line number="354" hits="0"/>
|
|
504
522
|
<line number="355" hits="0"/>
|
|
523
|
+
<line number="357" hits="1"/>
|
|
524
|
+
<line number="359" hits="0"/>
|
|
525
|
+
<line number="360" hits="0"/>
|
|
505
526
|
</lines>
|
|
506
527
|
</class>
|
|
507
528
|
</classes>
|
|
@@ -719,6 +740,12 @@
|
|
|
719
740
|
<line number="61" hits="1"/>
|
|
720
741
|
<line number="62" hits="1"/>
|
|
721
742
|
<line number="63" hits="1"/>
|
|
743
|
+
<line number="66" hits="1"/>
|
|
744
|
+
<line number="67" hits="1"/>
|
|
745
|
+
<line number="68" hits="1"/>
|
|
746
|
+
<line number="71" hits="1"/>
|
|
747
|
+
<line number="72" hits="1"/>
|
|
748
|
+
<line number="73" hits="1"/>
|
|
722
749
|
</lines>
|
|
723
750
|
</class>
|
|
724
751
|
</classes>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "deltadefi"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "1.0.0"
|
|
4
4
|
description = "Python SDK for DeltaDeFi protocol."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">3.11,<4.0.0"
|
|
@@ -44,6 +44,7 @@ dev = [
|
|
|
44
44
|
"twine>=5.0.0",
|
|
45
45
|
"build>=1.3.0",
|
|
46
46
|
"pre-commit>=4.3.0",
|
|
47
|
+
"types-requests>=2.32.4.20250913",
|
|
47
48
|
]
|
|
48
49
|
|
|
49
50
|
docs = [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
+
from typing import cast
|
|
2
3
|
|
|
3
4
|
from sidan_gin import Asset, UTxO
|
|
4
5
|
|
|
@@ -43,7 +44,10 @@ class Accounts(API):
|
|
|
43
44
|
"""
|
|
44
45
|
|
|
45
46
|
url_path = "/operation-key"
|
|
46
|
-
return
|
|
47
|
+
return cast(
|
|
48
|
+
"GetOperationKeyResponse",
|
|
49
|
+
self.send_request("GET", self.group_url_path + url_path, kwargs),
|
|
50
|
+
)
|
|
47
51
|
|
|
48
52
|
def create_new_api_key(self, **kwargs) -> CreateNewAPIKeyResponse:
|
|
49
53
|
"""
|
|
@@ -54,7 +58,10 @@ class Accounts(API):
|
|
|
54
58
|
"""
|
|
55
59
|
|
|
56
60
|
url_path = "/new-api-key"
|
|
57
|
-
return
|
|
61
|
+
return cast(
|
|
62
|
+
"CreateNewAPIKeyResponse",
|
|
63
|
+
self.send_request("GET", self.group_url_path + url_path, kwargs),
|
|
64
|
+
)
|
|
58
65
|
|
|
59
66
|
def get_deposit_records(self, **kwargs) -> GetDepositRecordsResponse:
|
|
60
67
|
"""
|
|
@@ -64,7 +71,10 @@ class Accounts(API):
|
|
|
64
71
|
A GetDepositRecordsResponse object containing the deposit records.
|
|
65
72
|
"""
|
|
66
73
|
url_path = "/deposit-records"
|
|
67
|
-
return
|
|
74
|
+
return cast(
|
|
75
|
+
"GetDepositRecordsResponse",
|
|
76
|
+
self.send_request("GET", self.group_url_path + url_path, kwargs),
|
|
77
|
+
)
|
|
68
78
|
|
|
69
79
|
def get_withdrawal_records(self, **kwargs) -> GetWithdrawalRecordsResponse:
|
|
70
80
|
"""
|
|
@@ -74,7 +84,10 @@ class Accounts(API):
|
|
|
74
84
|
A GetWithdrawalRecordsResponse object containing the withdrawal records.
|
|
75
85
|
"""
|
|
76
86
|
url_path = "/withdrawal-records"
|
|
77
|
-
return
|
|
87
|
+
return cast(
|
|
88
|
+
"GetWithdrawalRecordsResponse",
|
|
89
|
+
self.send_request("GET", self.group_url_path + url_path, kwargs),
|
|
90
|
+
)
|
|
78
91
|
|
|
79
92
|
def get_order_records(
|
|
80
93
|
self, status: OrderStatusType, **kwargs
|
|
@@ -95,7 +108,10 @@ class Accounts(API):
|
|
|
95
108
|
payload = {"status": status, **kwargs}
|
|
96
109
|
|
|
97
110
|
url_path = "/order-records"
|
|
98
|
-
return
|
|
111
|
+
return cast(
|
|
112
|
+
"GetOrderRecordsResponse",
|
|
113
|
+
self.send_request("GET", self.group_url_path + url_path, payload),
|
|
114
|
+
)
|
|
99
115
|
|
|
100
116
|
def get_order_record(self, order_id: str, **kwargs) -> GetOrderRecordResponse:
|
|
101
117
|
"""
|
|
@@ -110,7 +126,10 @@ class Accounts(API):
|
|
|
110
126
|
check_required_parameter(order_id, "order_id")
|
|
111
127
|
|
|
112
128
|
url_path = f"/order/{order_id}"
|
|
113
|
-
return
|
|
129
|
+
return cast(
|
|
130
|
+
"GetOrderRecordResponse",
|
|
131
|
+
self.send_request("GET", self.group_url_path + url_path, kwargs),
|
|
132
|
+
)
|
|
114
133
|
|
|
115
134
|
def get_account_balance(self, **kwargs) -> GetAccountBalanceResponse:
|
|
116
135
|
"""
|
|
@@ -120,7 +139,10 @@ class Accounts(API):
|
|
|
120
139
|
A GetAccountBalanceResponse object containing the account balance.
|
|
121
140
|
"""
|
|
122
141
|
url_path = "/balance"
|
|
123
|
-
return
|
|
142
|
+
return cast(
|
|
143
|
+
"GetAccountBalanceResponse",
|
|
144
|
+
self.send_request("GET", self.group_url_path + url_path, kwargs),
|
|
145
|
+
)
|
|
124
146
|
|
|
125
147
|
def build_deposit_transaction(
|
|
126
148
|
self, deposit_amount: list[Asset], input_utxos: list[UTxO], **kwargs
|
|
@@ -145,7 +167,10 @@ class Accounts(API):
|
|
|
145
167
|
}
|
|
146
168
|
|
|
147
169
|
url_path = "/deposit/build"
|
|
148
|
-
return
|
|
170
|
+
return cast(
|
|
171
|
+
"BuildDepositTransactionResponse",
|
|
172
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
173
|
+
)
|
|
149
174
|
|
|
150
175
|
def build_withdrawal_transaction(
|
|
151
176
|
self, withdrawal_amount: list[Asset], **kwargs
|
|
@@ -164,7 +189,10 @@ class Accounts(API):
|
|
|
164
189
|
payload = {"withdrawal_amount": withdrawal_amount, **kwargs}
|
|
165
190
|
|
|
166
191
|
url_path = "/withdrawal/build"
|
|
167
|
-
return
|
|
192
|
+
return cast(
|
|
193
|
+
"BuildWithdrawalTransactionResponse",
|
|
194
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
195
|
+
)
|
|
168
196
|
|
|
169
197
|
def build_transferal_transaction(
|
|
170
198
|
self, transferal_amount: list[Asset], to_address: str, **kwargs
|
|
@@ -179,8 +207,8 @@ class Accounts(API):
|
|
|
179
207
|
A BuildTransferalTransactionResponse object containing the built transferal transaction.
|
|
180
208
|
"""
|
|
181
209
|
|
|
182
|
-
|
|
183
|
-
transferal_amount, "transferal_amount", to_address, "to_address"
|
|
210
|
+
check_required_parameters(
|
|
211
|
+
[[transferal_amount, "transferal_amount"], [to_address, "to_address"]]
|
|
184
212
|
)
|
|
185
213
|
payload = {
|
|
186
214
|
"transferal_amount": transferal_amount,
|
|
@@ -189,7 +217,10 @@ class Accounts(API):
|
|
|
189
217
|
}
|
|
190
218
|
|
|
191
219
|
url_path = "/transferal/build"
|
|
192
|
-
return
|
|
220
|
+
return cast(
|
|
221
|
+
"BuildTransferalTransactionResponse",
|
|
222
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
223
|
+
)
|
|
193
224
|
|
|
194
225
|
def submit_deposit_transaction(
|
|
195
226
|
self, signed_tx: str, **kwargs
|
|
@@ -208,7 +239,10 @@ class Accounts(API):
|
|
|
208
239
|
payload = {"signed_tx": signed_tx, **kwargs}
|
|
209
240
|
|
|
210
241
|
url_path = "/deposit/submit"
|
|
211
|
-
return
|
|
242
|
+
return cast(
|
|
243
|
+
"SubmitDepositTransactionResponse",
|
|
244
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
245
|
+
)
|
|
212
246
|
|
|
213
247
|
def submit_withdrawal_transaction(
|
|
214
248
|
self, signed_tx: str, **kwargs
|
|
@@ -227,7 +261,10 @@ class Accounts(API):
|
|
|
227
261
|
payload = {"signed_tx": signed_tx, **kwargs}
|
|
228
262
|
|
|
229
263
|
url_path = "/withdrawal/submit"
|
|
230
|
-
return
|
|
264
|
+
return cast(
|
|
265
|
+
"SubmitWithdrawalTransactionResponse",
|
|
266
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
267
|
+
)
|
|
231
268
|
|
|
232
269
|
def submit_transferal_transaction(
|
|
233
270
|
self, signed_tx: str, **kwargs
|
|
@@ -246,4 +283,7 @@ class Accounts(API):
|
|
|
246
283
|
payload = {"signed_tx": signed_tx, **kwargs}
|
|
247
284
|
|
|
248
285
|
url_path = "/transferal/submit"
|
|
249
|
-
return
|
|
286
|
+
return cast(
|
|
287
|
+
"SubmitTransferalTransactionResponse",
|
|
288
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
289
|
+
)
|
|
@@ -18,6 +18,7 @@ class ApiClient:
|
|
|
18
18
|
network: str = "preprod",
|
|
19
19
|
api_key: str | None = None,
|
|
20
20
|
base_url: str | None = None,
|
|
21
|
+
ws_url: str | None = None,
|
|
21
22
|
master_wallet: Wallet | None = None,
|
|
22
23
|
):
|
|
23
24
|
"""
|
|
@@ -30,30 +31,26 @@ class ApiClient:
|
|
|
30
31
|
"""
|
|
31
32
|
if network == "mainnet":
|
|
32
33
|
self.network_id = 1
|
|
33
|
-
self.base_url = "https://api
|
|
34
|
+
self.base_url = "https://api.deltadefi.io"
|
|
35
|
+
self.ws_url = "wss://stream.deltadefi.io"
|
|
34
36
|
else:
|
|
35
37
|
self.network_id = 0
|
|
36
38
|
self.base_url = "https://api-staging.deltadefi.io"
|
|
39
|
+
self.ws_url = "wss://stream-staging.deltadefi.io"
|
|
37
40
|
|
|
38
41
|
if base_url:
|
|
39
42
|
self.base_url = base_url
|
|
40
43
|
|
|
44
|
+
if ws_url:
|
|
45
|
+
self.ws_url = ws_url
|
|
46
|
+
|
|
41
47
|
self.api_key = api_key
|
|
42
48
|
self.master_wallet = master_wallet
|
|
43
49
|
|
|
44
50
|
self.accounts = Accounts(base_url=self.base_url, api_key=api_key)
|
|
45
51
|
self.orders = Order(base_url=self.base_url, api_key=api_key)
|
|
46
52
|
self.markets = Market(base_url=self.base_url, api_key=api_key)
|
|
47
|
-
|
|
48
|
-
# Initialize WebSocket client with correct stream URL
|
|
49
|
-
if network == "mainnet":
|
|
50
|
-
ws_base_url = (
|
|
51
|
-
"wss://stream.deltadefi.io" # TODO: Update when mainnet is available
|
|
52
|
-
)
|
|
53
|
-
else:
|
|
54
|
-
ws_base_url = "wss://stream-staging.deltadefi.io"
|
|
55
|
-
|
|
56
|
-
self.websocket = WebSocketClient(base_url=ws_base_url, api_key=api_key)
|
|
53
|
+
self.websocket = WebSocketClient(base_url=self.ws_url, api_key=api_key)
|
|
57
54
|
|
|
58
55
|
def load_operation_key(self, password: str):
|
|
59
56
|
"""
|
|
@@ -116,3 +113,25 @@ class ApiClient:
|
|
|
116
113
|
signed_tx = self.operation_wallet.sign_tx(build_res["tx_hex"])
|
|
117
114
|
self.orders.submit_cancel_order_transaction(signed_tx, **kwargs)
|
|
118
115
|
return {"message": "Order cancelled successfully", "order_id": order_id}
|
|
116
|
+
|
|
117
|
+
def cancel_all_orders(self, **kwargs):
|
|
118
|
+
"""
|
|
119
|
+
Cancel all open orders for the account.
|
|
120
|
+
"""
|
|
121
|
+
if not hasattr(self, "operation_wallet") or self.operation_wallet is None:
|
|
122
|
+
raise ValueError("Operation wallet is not initialized")
|
|
123
|
+
|
|
124
|
+
build_res = self.orders.build_cancel_all_orders_transaction()
|
|
125
|
+
|
|
126
|
+
signed_txs: list[str] = []
|
|
127
|
+
for tx_hex in build_res["tx_hexes"]:
|
|
128
|
+
signed_tx = self.operation_wallet.sign_tx(tx_hex)
|
|
129
|
+
signed_txs.append(signed_tx)
|
|
130
|
+
|
|
131
|
+
submit_res = self.orders.submit_cancel_all_orders_transaction(
|
|
132
|
+
signed_txs, **kwargs
|
|
133
|
+
)
|
|
134
|
+
return {
|
|
135
|
+
"message": "All orders cancelled successfully",
|
|
136
|
+
"cancelled_order_ids": submit_res["cancelled_order_ids"],
|
|
137
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Literal
|
|
1
|
+
from typing import Literal, cast
|
|
2
2
|
|
|
3
3
|
from deltadefi.api import API
|
|
4
4
|
from deltadefi.responses import GetAggregatedPriceResponse, GetMarketPriceResponse
|
|
@@ -28,7 +28,10 @@ class Market(API):
|
|
|
28
28
|
check_required_parameter(symbol, "symbol")
|
|
29
29
|
payload = {"symbol": symbol, **kwargs}
|
|
30
30
|
url_path = "/market-price"
|
|
31
|
-
return
|
|
31
|
+
return cast(
|
|
32
|
+
"GetMarketPriceResponse",
|
|
33
|
+
self.send_request("GET", self.group_url_path + url_path, payload),
|
|
34
|
+
)
|
|
32
35
|
|
|
33
36
|
def get_aggregated_price(
|
|
34
37
|
self,
|
|
@@ -56,12 +59,15 @@ class Market(API):
|
|
|
56
59
|
]
|
|
57
60
|
)
|
|
58
61
|
url_path = f"/graph/{symbol}"
|
|
59
|
-
return
|
|
60
|
-
"
|
|
61
|
-
self.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
return cast(
|
|
63
|
+
"GetAggregatedPriceResponse",
|
|
64
|
+
self.send_request(
|
|
65
|
+
"GET",
|
|
66
|
+
self.group_url_path + url_path,
|
|
67
|
+
{
|
|
68
|
+
"interval": interval,
|
|
69
|
+
"start": start,
|
|
70
|
+
"end": end,
|
|
71
|
+
},
|
|
72
|
+
),
|
|
67
73
|
)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
from typing import cast
|
|
2
|
+
|
|
1
3
|
from deltadefi.api import API
|
|
2
4
|
from deltadefi.models.models import OrderSide, OrderType
|
|
3
5
|
from deltadefi.responses import (
|
|
6
|
+
BuildCancelAllOrdersTransactionResponse,
|
|
4
7
|
BuildCancelOrderTransactionResponse,
|
|
5
8
|
BuildPlaceOrderTransactionResponse,
|
|
9
|
+
SubmitCancelAllOrdersTransactionResponse,
|
|
6
10
|
SubmitPlaceOrderTransactionResponse,
|
|
7
11
|
)
|
|
8
12
|
from deltadefi.utils import check_required_parameter, check_required_parameters
|
|
@@ -66,7 +70,10 @@ class Order(API):
|
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
url_path = "/build"
|
|
69
|
-
return
|
|
73
|
+
return cast(
|
|
74
|
+
"BuildPlaceOrderTransactionResponse",
|
|
75
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
76
|
+
)
|
|
70
77
|
|
|
71
78
|
def build_cancel_order_transaction(
|
|
72
79
|
self, order_id: str, **kwargs
|
|
@@ -84,7 +91,26 @@ class Order(API):
|
|
|
84
91
|
check_required_parameter(order_id, "order_id")
|
|
85
92
|
|
|
86
93
|
url_path = f"/{order_id}/build"
|
|
87
|
-
return
|
|
94
|
+
return cast(
|
|
95
|
+
"BuildCancelOrderTransactionResponse",
|
|
96
|
+
self.send_request("DELETE", self.group_url_path + url_path, **kwargs),
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def build_cancel_all_orders_transaction(
|
|
100
|
+
self, **kwargs
|
|
101
|
+
) -> BuildCancelAllOrdersTransactionResponse:
|
|
102
|
+
"""
|
|
103
|
+
Build a cancel all orders transaction.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
A BuildCancelAllOrdersTransactionResponse object containing the built cancel all orders transaction.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
url_path = "/cancel-all/build"
|
|
110
|
+
return cast(
|
|
111
|
+
"BuildCancelAllOrdersTransactionResponse",
|
|
112
|
+
self.send_request("DELETE", self.group_url_path + url_path, **kwargs),
|
|
113
|
+
)
|
|
88
114
|
|
|
89
115
|
def submit_place_order_transaction(
|
|
90
116
|
self, order_id: str, signed_tx: str, **kwargs
|
|
@@ -93,7 +119,8 @@ class Order(API):
|
|
|
93
119
|
Submit a place order transaction.
|
|
94
120
|
|
|
95
121
|
Args:
|
|
96
|
-
|
|
122
|
+
order_id: The ID of the order to be placed.
|
|
123
|
+
signed_tx: The signed transaction hex string for placing the order.
|
|
97
124
|
|
|
98
125
|
Returns:
|
|
99
126
|
A SubmitPlaceOrderTransactionResponse object containing the submitted order transaction.
|
|
@@ -102,17 +129,38 @@ class Order(API):
|
|
|
102
129
|
payload = {"order_id": order_id, "signed_tx": signed_tx, **kwargs}
|
|
103
130
|
|
|
104
131
|
url_path = "/submit"
|
|
105
|
-
return
|
|
132
|
+
return cast(
|
|
133
|
+
"SubmitPlaceOrderTransactionResponse",
|
|
134
|
+
self.send_request("POST", self.group_url_path + url_path, payload),
|
|
135
|
+
)
|
|
106
136
|
|
|
107
137
|
def submit_cancel_order_transaction(self, signed_tx: str, **kwargs):
|
|
108
138
|
"""
|
|
109
139
|
Submit a cancel order transaction.
|
|
110
140
|
|
|
111
141
|
Args:
|
|
112
|
-
|
|
142
|
+
signed_tx: The signed transaction hex string for canceling the order.
|
|
113
143
|
"""
|
|
114
144
|
check_required_parameter(signed_tx, "signed_tx")
|
|
115
145
|
payload = {"signed_tx": signed_tx, **kwargs}
|
|
116
146
|
|
|
117
147
|
path_url = "/submit"
|
|
118
148
|
return self.send_request("DELETE", self.group_url_path + path_url, payload)
|
|
149
|
+
|
|
150
|
+
def submit_cancel_all_orders_transaction(
|
|
151
|
+
self, signed_txs: list[str], **kwargs
|
|
152
|
+
) -> SubmitCancelAllOrdersTransactionResponse:
|
|
153
|
+
"""
|
|
154
|
+
Submit a cancel all orders transaction.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
signed_txs: A list of signed transaction hex strings for canceling all orders.
|
|
158
|
+
"""
|
|
159
|
+
check_required_parameter(signed_txs, "signed_txs")
|
|
160
|
+
payload = {"signed_txs": signed_txs, **kwargs}
|
|
161
|
+
|
|
162
|
+
path_url = "/cancel-all/submit"
|
|
163
|
+
return cast(
|
|
164
|
+
"SubmitCancelAllOrdersTransactionResponse",
|
|
165
|
+
self.send_request("DELETE", self.group_url_path + path_url, payload),
|
|
166
|
+
)
|
|
@@ -47,7 +47,7 @@ class WebSocketClient:
|
|
|
47
47
|
self.ping_interval = ping_interval
|
|
48
48
|
self.ping_timeout = ping_timeout
|
|
49
49
|
|
|
50
|
-
self.websocket: websockets.
|
|
50
|
+
self.websocket: websockets.WebSocketClientProtocol | None = None
|
|
51
51
|
self.subscriptions: dict[str, dict[str, Any]] = {}
|
|
52
52
|
self.message_handlers: dict[str, Callable] = {}
|
|
53
53
|
self.is_connected = False
|
|
@@ -119,10 +119,14 @@ class WebSocketClient:
|
|
|
119
119
|
except Exception as e:
|
|
120
120
|
self.logger.error(f"Error in message listener: {e}")
|
|
121
121
|
|
|
122
|
-
async def _handle_message(self, message: str) -> None:
|
|
122
|
+
async def _handle_message(self, message: str | bytes) -> None:
|
|
123
123
|
"""Handle incoming WebSocket message."""
|
|
124
124
|
try:
|
|
125
|
-
|
|
125
|
+
# Convert bytes to string if needed
|
|
126
|
+
message_str = (
|
|
127
|
+
message.decode("utf-8") if isinstance(message, bytes) else message
|
|
128
|
+
)
|
|
129
|
+
data = json.loads(message_str)
|
|
126
130
|
|
|
127
131
|
# Determine message type based on structure
|
|
128
132
|
if isinstance(data, list) and len(data) > 0 and "timestamp" in data[0]:
|
|
@@ -171,7 +175,10 @@ class WebSocketClient:
|
|
|
171
175
|
self.logger.debug(f"Unknown message format: {data}")
|
|
172
176
|
|
|
173
177
|
except json.JSONDecodeError:
|
|
174
|
-
|
|
178
|
+
message_repr = (
|
|
179
|
+
message.decode("utf-8") if isinstance(message, bytes) else message
|
|
180
|
+
)
|
|
181
|
+
self.logger.error(f"Failed to parse message: {message_repr}")
|
|
175
182
|
except Exception as e:
|
|
176
183
|
self.logger.error(f"Error handling message: {e}")
|
|
177
184
|
|
|
@@ -187,10 +194,8 @@ class WebSocketClient:
|
|
|
187
194
|
# In a more complex implementation, you'd want to handle multiple concurrent subscriptions
|
|
188
195
|
if self.subscriptions:
|
|
189
196
|
first_sub = next(iter(self.subscriptions.values()))
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
else:
|
|
193
|
-
await self.connect()
|
|
197
|
+
# Always use the stored endpoint for reconnection
|
|
198
|
+
await self.connect(first_sub["endpoint"])
|
|
194
199
|
else:
|
|
195
200
|
await self.connect()
|
|
196
201
|
|
|
@@ -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]
|
|
@@ -435,7 +435,7 @@ wheels = [
|
|
|
435
435
|
|
|
436
436
|
[[package]]
|
|
437
437
|
name = "deltadefi"
|
|
438
|
-
version = "0.
|
|
438
|
+
version = "1.0.0"
|
|
439
439
|
source = { editable = "." }
|
|
440
440
|
dependencies = [
|
|
441
441
|
{ name = "certifi" },
|
|
@@ -459,6 +459,7 @@ dev = [
|
|
|
459
459
|
{ name = "pytest-xdist" },
|
|
460
460
|
{ name = "ruff" },
|
|
461
461
|
{ name = "twine" },
|
|
462
|
+
{ name = "types-requests" },
|
|
462
463
|
]
|
|
463
464
|
docs = [
|
|
464
465
|
{ name = "sphinx" },
|
|
@@ -489,6 +490,7 @@ dev = [
|
|
|
489
490
|
{ name = "pytest-xdist", specifier = ">=3.5.0" },
|
|
490
491
|
{ name = "ruff", specifier = ">=0.12.10" },
|
|
491
492
|
{ name = "twine", specifier = ">=5.0.0" },
|
|
493
|
+
{ name = "types-requests", specifier = ">=2.32.4.20250913" },
|
|
492
494
|
]
|
|
493
495
|
docs = [
|
|
494
496
|
{ name = "sphinx", specifier = ">=5.0.0" },
|
|
@@ -1737,6 +1739,18 @@ wheels = [
|
|
|
1737
1739
|
{ url = "https://files.pythonhosted.org/packages/1b/a9/e3aee762739c1d7528da1c3e06d518503f8b6c439c35549b53735ba52ead/typeguard-4.4.4-py3-none-any.whl", hash = "sha256:b5f562281b6bfa1f5492470464730ef001646128b180769880468bd84b68b09e", size = 34874, upload-time = "2025-06-18T09:56:05.999Z" },
|
|
1738
1740
|
]
|
|
1739
1741
|
|
|
1742
|
+
[[package]]
|
|
1743
|
+
name = "types-requests"
|
|
1744
|
+
version = "2.32.4.20250913"
|
|
1745
|
+
source = { registry = "https://pypi.org/simple" }
|
|
1746
|
+
dependencies = [
|
|
1747
|
+
{ name = "urllib3" },
|
|
1748
|
+
]
|
|
1749
|
+
sdist = { url = "https://files.pythonhosted.org/packages/36/27/489922f4505975b11de2b5ad07b4fe1dca0bca9be81a703f26c5f3acfce5/types_requests-2.32.4.20250913.tar.gz", hash = "sha256:abd6d4f9ce3a9383f269775a9835a4c24e5cd6b9f647d64f88aa4613c33def5d", size = 23113, upload-time = "2025-09-13T02:40:02.309Z" }
|
|
1750
|
+
wheels = [
|
|
1751
|
+
{ url = "https://files.pythonhosted.org/packages/2a/20/9a227ea57c1285986c4cf78400d0a91615d25b24e257fd9e2969606bdfae/types_requests-2.32.4.20250913-py3-none-any.whl", hash = "sha256:78c9c1fffebbe0fa487a418e0fa5252017e9c60d1a2da394077f1780f655d7e1", size = 20658, upload-time = "2025-09-13T02:40:01.115Z" },
|
|
1752
|
+
]
|
|
1753
|
+
|
|
1740
1754
|
[[package]]
|
|
1741
1755
|
name = "typing-extensions"
|
|
1742
1756
|
version = "4.15.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|