deltadefi 0.0.6__tar.gz → 0.0.8__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.0.6 → deltadefi-0.0.8}/PKG-INFO +13 -2
- {deltadefi-0.0.6 → deltadefi-0.0.8}/README.md +10 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/pyproject.toml +3 -2
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/clients/accounts.py +12 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/clients/clients.py +29 -11
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/clients/order.py +5 -1
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/responses/accounts.py +14 -8
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/responses/responses.py +10 -10
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/__init__.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/api.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/api_resources/__init__.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/api_resources/auth.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/api_resources/validation.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/clients/__init__.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/clients/app.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/clients/market.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/constants/__init__.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/constants/constants.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/error.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/lib/__init__.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/lib/utils.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/models/__init__.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/models/models.py +0 -0
- {deltadefi-0.0.6 → deltadefi-0.0.8}/src/deltadefi/responses/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: deltadefi
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: Python SDK for DeltaDeFi protocol.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: cardano
|
|
@@ -16,10 +16,11 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Requires-Dist: certifi (==2024.8.30)
|
|
18
18
|
Requires-Dist: charset-normalizer (==3.4.0)
|
|
19
|
+
Requires-Dist: dotenv (>=0.9.9,<0.10.0)
|
|
19
20
|
Requires-Dist: idna (==3.10)
|
|
20
21
|
Requires-Dist: pycardano (>=0.12.3,<0.13.0)
|
|
21
22
|
Requires-Dist: requests (>=2.25,<3.0)
|
|
22
|
-
Requires-Dist: sidan-gin (==0.1.
|
|
23
|
+
Requires-Dist: sidan-gin (==0.1.6)
|
|
23
24
|
Requires-Dist: urllib3 (==2.2.3)
|
|
24
25
|
Project-URL: Documentation, https://github.com/deltadefi-protocol/python-sdk
|
|
25
26
|
Project-URL: Homepage, https://github.com/deltadefi-protocol/python-sdk
|
|
@@ -101,6 +102,16 @@ submit_order_response = api.order.submit_place_order_transaction(signed_tx="<sig
|
|
|
101
102
|
print(submit_order_response)
|
|
102
103
|
```
|
|
103
104
|
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
### Tests
|
|
108
|
+
|
|
109
|
+
Testing sdk:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
DELTADEFI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx make test
|
|
113
|
+
```
|
|
114
|
+
|
|
104
115
|
## License
|
|
105
116
|
|
|
106
117
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
|
|
@@ -74,6 +74,16 @@ submit_order_response = api.order.submit_place_order_transaction(signed_tx="<sig
|
|
|
74
74
|
print(submit_order_response)
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
### Tests
|
|
80
|
+
|
|
81
|
+
Testing sdk:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
DELTADEFI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx make test
|
|
85
|
+
```
|
|
86
|
+
|
|
77
87
|
## License
|
|
78
88
|
|
|
79
89
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "deltadefi"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.8"
|
|
4
4
|
classifiers = [
|
|
5
5
|
"Intended Audience :: Developers",
|
|
6
6
|
"License :: OSI Approved :: Apache Software License",
|
|
@@ -18,13 +18,14 @@ license = "Apache-2.0"
|
|
|
18
18
|
|
|
19
19
|
[tool.poetry.dependencies]
|
|
20
20
|
python = ">3.11,<4.0.0"
|
|
21
|
-
sidan-gin = "0.1.
|
|
21
|
+
sidan-gin = "0.1.6"
|
|
22
22
|
requests = "^2.25"
|
|
23
23
|
certifi = "2024.8.30"
|
|
24
24
|
charset-normalizer = "3.4.0"
|
|
25
25
|
idna = "3.10"
|
|
26
26
|
urllib3 = "2.2.3"
|
|
27
27
|
pycardano = "^0.12.3"
|
|
28
|
+
dotenv = "^0.9.9"
|
|
28
29
|
|
|
29
30
|
[tool.poetry.group.dev.dependencies]
|
|
30
31
|
pytest = "^8.2.0"
|
|
@@ -16,6 +16,7 @@ from deltadefi.responses import (
|
|
|
16
16
|
SubmitDepositTransactionResponse,
|
|
17
17
|
SubmitWithdrawalTransactionResponse,
|
|
18
18
|
)
|
|
19
|
+
from deltadefi.responses.accounts import GetOperationKeyResponse
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class Accounts(API):
|
|
@@ -28,6 +29,17 @@ class Accounts(API):
|
|
|
28
29
|
def __init__(self, api_key=None, base_url=None, **kwargs):
|
|
29
30
|
super().__init__(api_key=api_key, base_url=base_url, **kwargs)
|
|
30
31
|
|
|
32
|
+
def get_operation_key(self, **kwargs) -> GetOperationKeyResponse:
|
|
33
|
+
"""
|
|
34
|
+
Get the encrypted operation key.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
A GetOperationKeyResponse object containing the encrypted operation key and its hash.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
url_path = "/operation-key"
|
|
41
|
+
return self.send_request("GET", self.group_url_path + url_path, kwargs)
|
|
42
|
+
|
|
31
43
|
def create_new_api_key(self, **kwargs) -> CreateNewAPIKeyResponse:
|
|
32
44
|
"""
|
|
33
45
|
Create a new API key.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# flake8: noqa: E501
|
|
2
|
-
from sidan_gin import
|
|
2
|
+
from sidan_gin import Wallet
|
|
3
3
|
|
|
4
4
|
from deltadefi.clients.accounts import Accounts
|
|
5
5
|
from deltadefi.clients.app import App
|
|
6
6
|
from deltadefi.clients.market import Market
|
|
7
7
|
from deltadefi.clients.order import Order
|
|
8
|
+
from deltadefi.models.models import OrderSide, OrderType
|
|
8
9
|
from deltadefi.responses import PostOrderResponse
|
|
9
10
|
|
|
10
11
|
|
|
@@ -17,7 +18,7 @@ class ApiClient:
|
|
|
17
18
|
self,
|
|
18
19
|
network: str = "preprod",
|
|
19
20
|
api_key: str = None,
|
|
20
|
-
wallet:
|
|
21
|
+
wallet: Wallet = None,
|
|
21
22
|
base_url: str = None,
|
|
22
23
|
):
|
|
23
24
|
"""
|
|
@@ -25,31 +26,39 @@ class ApiClient:
|
|
|
25
26
|
|
|
26
27
|
Args:
|
|
27
28
|
config: An instance of ApiConfig containing the API configuration.
|
|
28
|
-
wallet: An instance of
|
|
29
|
+
wallet: An instance of Wallet for signing transactions.
|
|
29
30
|
base_url: Optional; The base URL for the API. Defaults to "https://api-dev.deltadefi.io".
|
|
30
31
|
"""
|
|
31
32
|
if network == "mainnet":
|
|
32
33
|
self.network_id = 1
|
|
33
|
-
base_url = "https://api-dev.deltadefi.io" # TODO: input production link once available
|
|
34
|
+
self.base_url = "https://api-dev.deltadefi.io" # TODO: input production link once available
|
|
34
35
|
else:
|
|
35
36
|
self.network_id = 0
|
|
36
|
-
base_url = "https://api-
|
|
37
|
+
self.base_url = "https://api-staging.deltadefi.io"
|
|
38
|
+
|
|
39
|
+
if base_url:
|
|
40
|
+
self.base_url = base_url
|
|
37
41
|
|
|
38
42
|
self.api_key = api_key
|
|
39
43
|
self.wallet = wallet
|
|
40
|
-
self.base_url = base_url
|
|
41
44
|
|
|
42
45
|
self.accounts = Accounts(base_url=base_url, api_key=api_key)
|
|
43
46
|
self.app = App(base_url=base_url, api_key=api_key)
|
|
44
47
|
self.order = Order(base_url=base_url, api_key=api_key)
|
|
45
48
|
self.market = Market(base_url=base_url, api_key=api_key)
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
def post_order(
|
|
51
|
+
self, symbol: str, side: OrderSide, type: OrderType, quantity: int, **kwargs
|
|
52
|
+
) -> PostOrderResponse:
|
|
48
53
|
"""
|
|
49
|
-
Post an order to the DeltaDeFi API.
|
|
54
|
+
Post an order to the DeltaDeFi API. It includes building the transaction, signing it with the wallet, and submitting it.
|
|
50
55
|
|
|
51
56
|
Args:
|
|
52
|
-
|
|
57
|
+
symbol: The trading pair symbol (e.g., "BTC-USD").
|
|
58
|
+
side: The side of the order (e.g., "buy" or "sell").
|
|
59
|
+
type: The type of the order (e.g., "limit" or "market").
|
|
60
|
+
quantity: The quantity of the asset to be traded.
|
|
61
|
+
**kwargs: Additional parameters for the order, such as price, limit_slippage, etc.
|
|
53
62
|
|
|
54
63
|
Returns:
|
|
55
64
|
A PostOrderResponse object containing the response from the API.
|
|
@@ -57,10 +66,19 @@ class ApiClient:
|
|
|
57
66
|
Raises:
|
|
58
67
|
ValueError: If the wallet is not initialized.
|
|
59
68
|
"""
|
|
69
|
+
print(
|
|
70
|
+
f"post_order: symbol={symbol}, side={side}, type={type}, quantity={quantity}, kwargs={kwargs}"
|
|
71
|
+
)
|
|
60
72
|
if not hasattr(self, "wallet") or self.wallet is None:
|
|
61
73
|
raise ValueError("Wallet is not initialized")
|
|
62
74
|
|
|
63
|
-
build_res =
|
|
75
|
+
build_res = self.order.build_place_order_transaction(
|
|
76
|
+
symbol, side, type, quantity, **kwargs
|
|
77
|
+
)
|
|
78
|
+
print(f"build_res: {build_res}")
|
|
64
79
|
signed_tx = self.wallet.sign_tx(build_res["tx_hex"])
|
|
65
|
-
submit_res =
|
|
80
|
+
submit_res = self.order.submit_place_order_transaction(
|
|
81
|
+
build_res["order_id"], signed_tx, **kwargs
|
|
82
|
+
)
|
|
83
|
+
print(f"submit_res: {submit_res}")
|
|
66
84
|
return submit_res
|
|
@@ -31,7 +31,11 @@ class Order(API):
|
|
|
31
31
|
Build a place order transaction.
|
|
32
32
|
|
|
33
33
|
Args:
|
|
34
|
-
|
|
34
|
+
symbol: The trading pair symbol (e.g., "BTC-USD").
|
|
35
|
+
side: The side of the order (e.g., "buy" or "sell").
|
|
36
|
+
type: The type of the order (e.g., "limit" or "market").
|
|
37
|
+
quantity: The quantity of the asset to be traded.
|
|
38
|
+
**kwargs: Additional parameters for the order, such as price, limit_slippage, etc.
|
|
35
39
|
|
|
36
40
|
Returns:
|
|
37
41
|
A BuildPlaceOrderTransactionResponse object containing the built order transaction.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from typing import List
|
|
2
|
+
from typing import List, TypedDict
|
|
3
3
|
|
|
4
4
|
from deltadefi.models.models import (
|
|
5
5
|
AssetBalance,
|
|
@@ -10,17 +10,23 @@ from deltadefi.models.models import (
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
13
|
-
class CreateNewAPIKeyResponse:
|
|
13
|
+
class CreateNewAPIKeyResponse(TypedDict):
|
|
14
14
|
api_key: str
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@dataclass
|
|
18
|
-
class
|
|
18
|
+
class GetOperationKeyResponse(TypedDict):
|
|
19
|
+
encrypted_operation_key: str
|
|
20
|
+
operation_key_hash: str
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class BuildDepositTransactionResponse(TypedDict):
|
|
19
25
|
tx_hex: str
|
|
20
26
|
|
|
21
27
|
|
|
22
28
|
@dataclass
|
|
23
|
-
class SubmitDepositTransactionResponse:
|
|
29
|
+
class SubmitDepositTransactionResponse(TypedDict):
|
|
24
30
|
tx_hash: str
|
|
25
31
|
|
|
26
32
|
|
|
@@ -35,22 +41,22 @@ class GetWithdrawalRecordsResponse(List[WithdrawalRecord]):
|
|
|
35
41
|
|
|
36
42
|
|
|
37
43
|
@dataclass
|
|
38
|
-
class GetOrderRecordResponse:
|
|
44
|
+
class GetOrderRecordResponse(TypedDict):
|
|
39
45
|
orders: List[OrderJSON]
|
|
40
46
|
|
|
41
47
|
|
|
42
48
|
@dataclass
|
|
43
|
-
class BuildWithdrawalTransactionResponse:
|
|
49
|
+
class BuildWithdrawalTransactionResponse(TypedDict):
|
|
44
50
|
tx_hex: str
|
|
45
51
|
|
|
46
52
|
|
|
47
53
|
@dataclass
|
|
48
|
-
class SubmitWithdrawalTransactionResponse:
|
|
54
|
+
class SubmitWithdrawalTransactionResponse(TypedDict):
|
|
49
55
|
tx_hash: str
|
|
50
56
|
|
|
51
57
|
|
|
52
58
|
@dataclass
|
|
53
|
-
class GetAccountInfoResponse:
|
|
59
|
+
class GetAccountInfoResponse(TypedDict):
|
|
54
60
|
api_key: str
|
|
55
61
|
api_limit: int
|
|
56
62
|
created_at: str
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from typing import List
|
|
2
|
+
from typing import List, TypedDict
|
|
3
3
|
|
|
4
4
|
from deltadefi.models import OrderJSON
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
@dataclass
|
|
8
|
-
class GetTermsAndConditionResponse:
|
|
8
|
+
class GetTermsAndConditionResponse(TypedDict):
|
|
9
9
|
value: str
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
13
|
-
class MarketDepth:
|
|
13
|
+
class MarketDepth(TypedDict):
|
|
14
14
|
price: float
|
|
15
15
|
quantity: float
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@dataclass
|
|
19
|
-
class GetMarketDepthResponse:
|
|
19
|
+
class GetMarketDepthResponse(TypedDict):
|
|
20
20
|
bids: List[MarketDepth]
|
|
21
21
|
asks: List[MarketDepth]
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@dataclass
|
|
25
|
-
class GetMarketPriceResponse:
|
|
25
|
+
class GetMarketPriceResponse(TypedDict):
|
|
26
26
|
price: float
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@dataclass
|
|
30
|
-
class Trade:
|
|
30
|
+
class Trade(TypedDict):
|
|
31
31
|
time: str
|
|
32
32
|
symbol: str
|
|
33
33
|
open: float
|
|
@@ -43,13 +43,13 @@ class GetAggregatedPriceResponse(List[Trade]):
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
@dataclass
|
|
46
|
-
class BuildPlaceOrderTransactionResponse:
|
|
46
|
+
class BuildPlaceOrderTransactionResponse(TypedDict):
|
|
47
47
|
order_id: str
|
|
48
48
|
tx_hex: str
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
@dataclass
|
|
52
|
-
class SubmitPlaceOrderTransactionResponse:
|
|
52
|
+
class SubmitPlaceOrderTransactionResponse(TypedDict):
|
|
53
53
|
order: OrderJSON
|
|
54
54
|
|
|
55
55
|
|
|
@@ -59,10 +59,10 @@ class PostOrderResponse(SubmitPlaceOrderTransactionResponse):
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
@dataclass
|
|
62
|
-
class BuildCancelOrderTransactionResponse:
|
|
62
|
+
class BuildCancelOrderTransactionResponse(TypedDict):
|
|
63
63
|
tx_hex: str
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
@dataclass
|
|
67
|
-
class SubmitCancelOrderTransactionResponse:
|
|
67
|
+
class SubmitCancelOrderTransactionResponse(TypedDict):
|
|
68
68
|
tx_hash: str
|
|
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
|