Skip to content

Commit c8d51ee

Browse files
committed
add etp/margin rest api
1 parent 9d90577 commit c8d51ee

3 files changed

Lines changed: 143 additions & 0 deletions

File tree

huobi/spot/rest/etp.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from huobi.utils.http import get, post
2+
from huobi.host import HOST_SPOT
3+
import json
4+
5+
6+
class Etp:
7+
def __init__(self, access_key: str, secret_key: str, host=HOST_SPOT):
8+
self.__access_key = access_key
9+
self.__secret_key = secret_key
10+
self.__host = host
11+
12+
def order(self, params: dict) -> json:
13+
path = "/v2/etp/creation"
14+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
15+
16+
def redeem(self, params: dict) -> json:
17+
path = "/v2/etp/redemption"
18+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
19+
20+
def get_transactions(self, params: dict) -> json:
21+
path = "/v2/etp/transactions"
22+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
23+
24+
def get_transaction_by_id(self, params: dict) -> json:
25+
path = "/v2/etp/transaction"
26+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
27+
28+
def get_rebalance(self, params: dict) -> json:
29+
path = "/v2/etp/rebalance"
30+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
31+
32+
def cancel(self, params: dict) -> json:
33+
transact_id = params['transactId']
34+
path = "/v2/etp/{}/cancel".format(transact_id)
35+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
36+
37+
def batch_cancel(self, params: dict) -> json:
38+
path = "/v2/etp/batch-cancel"
39+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
40+
41+
def get_hold_limit(self, params: dict) -> json:
42+
path = "/v2/etp/limit"
43+
return get(self.__host, path, params, self.__access_key, self.__secret_key)

huobi/spot/rest/margin_account.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from huobi.utils.http import get, post
2+
from huobi.host import HOST_SPOT
3+
import json
4+
5+
6+
class MarginAccount:
7+
def __init__(self, access_key: str, secret_key: str, host=HOST_SPOT):
8+
self.__access_key = access_key
9+
self.__secret_key = secret_key
10+
self.__host = host
11+
12+
def repay(self, params: dict) -> json:
13+
path = "/v2/account/repayment"
14+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
15+
16+
def isolated_transfer_in(self, params: dict) -> json:
17+
path = "/v1/dw/transfer-in/margin"
18+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
19+
20+
def isolated_transfer_out(self, params: dict) -> json:
21+
path = "/v1/dw/transfer-out/margin"
22+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
23+
24+
def isolated_get_loan_info(self, params: dict = None) -> json:
25+
path = "/v1/margin/loan-info"
26+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
27+
28+
def isolated_orders(self, params: dict) -> json:
29+
path = "/v1/margin/orders"
30+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
31+
32+
def isolated_repay(self, params: dict) -> json:
33+
order_id = params['order-id']
34+
path = "/v1/margin/orders/{}/repay".format(order_id)
35+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
36+
37+
def isolated_get_order_info(self, params: dict) -> json:
38+
path = "/v1/margin/loan-orders"
39+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
40+
41+
def isolated_get_balance(self, params: dict = None) -> json:
42+
path = "/v1/margin/accounts/balance"
43+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
44+
45+
def cross_transfer_in(self, params: dict) -> json:
46+
path = "/v1/cross-margin/transfer-in"
47+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
48+
49+
def cross_transfer_out(self, params: dict) -> json:
50+
path = "/v1/cross-margin/transfer-out"
51+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
52+
53+
def cross_get_loan_info(self) -> json:
54+
path = "/v1/cross-margin/loan-info"
55+
return get(self.__host, path, None, self.__access_key, self.__secret_key)
56+
57+
def cross_get_hold_limit(self, params: dict) -> json:
58+
path = "/v2/margin/limit"
59+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
60+
61+
def cross_orders(self, params: dict) -> json:
62+
path = "/v1/cross-margin/orders"
63+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
64+
65+
def cross_repay(self, params: dict) -> json:
66+
order_id = params['order-id']
67+
path = "/v1/cross-margin/orders/{order-id}/repay".format(order_id)
68+
return post(self.__host, path, self.__access_key, self.__secret_key, params)
69+
70+
def cross_get_order_info(self, params: dict) -> json:
71+
path = "/v1/cross-margin/loan-orders"
72+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
73+
74+
def cross_get_balance(self, params: dict = None) -> json:
75+
path = "/v1/cross-margin/accounts/balance"
76+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
77+
78+
def get_repayment(self, params: dict = None) -> json:
79+
path = "/v2/account/repayment"
80+
return get(self.__host, path, params, self.__access_key, self.__secret_key)
81+
82+

huobi/spot/rest/stable_coin.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from huobi.utils.http import get, post
2+
from huobi.host import HOST_SPOT
3+
import json
4+
5+
6+
class StableCoin:
7+
def __init__(self, access_key: str, secret_key: str, host=HOST_SPOT):
8+
self.__access_key = access_key
9+
self.__secret_key = secret_key
10+
self.__host = host
11+
12+
def get_quote(self, params: dict) -> json:
13+
path = "/v1/stable-coin/quote"
14+
return get(self.__host, path, params)
15+
16+
def exchange(self, params: dict) -> json:
17+
path = "/v1/stable-coin/exchang"
18+
return post(self.__host, path, self.__access_key, self.__secret_key, params)

0 commit comments

Comments
 (0)