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+
0 commit comments