1
- from binance .lib .utils import check_required_parameter
1
+ from binance .lib .utils import check_required_parameters , check_required_parameter
2
2
3
3
4
4
def loan_history (self , asset : str , ** kwargs ):
@@ -24,3 +24,164 @@ def loan_history(self, asset: str, **kwargs):
24
24
25
25
payload = {"asset" : asset , ** kwargs }
26
26
return self .sign_request ("GET" , "/sapi/v1/loan/income" , payload )
27
+
28
+
29
+ def loan_borrow (self , loanCoin : str , collateralCoin : str , loanTerm : int , ** kwargs ):
30
+ """Crypto Loan Borrow (TRADE)
31
+
32
+ POST /sapi/v1/loan/borrow
33
+
34
+ https://binance-docs.github.io/apidocs/spot/en/#borrow-crypto-loan-borrow-trade
35
+
36
+ Args:
37
+ loanCoin (str)
38
+ collateralCoin (str)
39
+ loanTerm (int): 7/14/30/90/180 days
40
+ Keyword Args:
41
+ loanAmount (float, optional): Mandatory when collateralAmount is empty
42
+ collateralAmount (float, optional): Mandatory when loanAmount is empty
43
+ recvWindow (int, optional): The value cannot be greater than 60000
44
+ """
45
+
46
+ check_required_parameters (
47
+ [
48
+ [loanCoin , "loanCoin" ],
49
+ [collateralCoin , "collateralCoin" ],
50
+ [loanTerm , "loanTerm" ],
51
+ ]
52
+ )
53
+
54
+ payload = {
55
+ "loanCoin" : loanCoin ,
56
+ "collateralCoin" : collateralCoin ,
57
+ "loanTerm" : loanTerm ,
58
+ ** kwargs ,
59
+ }
60
+ return self .sign_request ("POST" , "/sapi/v1/loan/borrow" , payload )
61
+
62
+
63
+ def loan_borrow_history (self , ** kwargs ):
64
+ """Get Loan Borrow History (USER_DATA)
65
+
66
+ GET /sapi/v1/loan/borrow/history
67
+
68
+ https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-borrow-history-user_data
69
+
70
+ Keyword Args:
71
+ orderId (int, optional): orderId in POST /sapi/v1/loan/borrow
72
+ loanCoin (str, optional)
73
+ collateralCoin (str, optional)
74
+ startTime (int, optional)
75
+ endTime (int, optional)
76
+ current (int, optional): Current querying page. Start from 1; default: 1; max: 1000.
77
+ limit (int, optional): Default: 10; max: 100
78
+ recvWindow (int, optional): The value cannot be greater than 60000
79
+ """
80
+
81
+ return self .sign_request ("GET" , "/sapi/v1/loan/borrow/history" , kwargs )
82
+
83
+
84
+ def loan_ongoing_orders (self , ** kwargs ):
85
+ """Get Loan Ongoing Orders (USER_DATA)
86
+
87
+ GET /sapi/v1/loan/ongoing/orders
88
+
89
+ https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-ongoing-orders-user_data
90
+
91
+ Keyword Args:
92
+ orderId (int, optional): orderId in POST /sapi/v1/loan/borrow
93
+ loanCoin (str, optional)
94
+ collateralCoin (str, optional)
95
+ current (int, optional): Current querying page. Start from 1; default: 1; max: 1000
96
+ limit (int, optional): Default: 10; max: 100
97
+ recvWindow (int, optional): The value cannot be greater than 60000
98
+ """
99
+
100
+ return self .sign_request ("GET" , "/sapi/v1/loan/ongoing/orders" , kwargs )
101
+
102
+
103
+ def loan_repay (self , orderId : int , amount : float , ** kwargs ):
104
+ """Crypto Loan Repay (TRADE)
105
+
106
+ POST /sapi/v1/loan/repay
107
+
108
+ https://binance-docs.github.io/apidocs/spot/en/#repay-crypto-loan-repay-trade
109
+
110
+ Args:
111
+ orderId (int)
112
+ amount (float)
113
+ Keyword Args:
114
+ type (int, optional): Default: 1. 1 for "repay with borrowed coin"; 2 for "repay with collateral"
115
+ collateralReturn (boolean, optional): Default: TRUE. TRUE: Return extra collateral to spot account; FALSE: Keep extra collateral in the order.
116
+ recvWindow (int, optional): The value cannot be greater than 60000
117
+ """
118
+
119
+ check_required_parameters ([[orderId , "orderId" ], [amount , "amount" ]])
120
+
121
+ payload = {"orderId" : orderId , "amount" : amount , ** kwargs }
122
+ return self .sign_request ("POST" , "/sapi/v1/loan/repay" , payload )
123
+
124
+
125
+ def loan_repay_history (self , ** kwargs ):
126
+ """Get Loan Repayment History (USER_DATA)
127
+
128
+ GET /sapi/v1/loan/repay/history
129
+
130
+ https://binance-docs.github.io/apidocs/spot/en/#repay-get-loan-repayment-history-user_data
131
+
132
+ Keyword Args:
133
+ orderId (int, optional)
134
+ loanCoin (str, optional)
135
+ collateralCoin (str, optional)
136
+ startTime (int, optional)
137
+ endTime (int, optional)
138
+ current (int, optional): Current querying page. Start from 1; default: 1; max: 1000.
139
+ limit (int, optional): Default: 10; max: 100
140
+ recvWindow (int, optional): The value cannot be greater than 60000
141
+ """
142
+
143
+ return self .sign_request ("GET" , "/sapi/v1/loan/repay/history" , kwargs )
144
+
145
+
146
+ def loan_adjust_ltv (self , orderId : int , amount : float , direction : str , ** kwargs ):
147
+ """Crypto Loan Adjust LTV (TRADE)
148
+
149
+ POST /sapi/v1/loan/adjust/ltv
150
+
151
+ https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-crypto-loan-adjust-ltv-trade
152
+
153
+ Args:
154
+ orderId (int)
155
+ amount (float)
156
+ direction (str): "ADDITIONAL", "REDUCED"
157
+ Keyword Args:
158
+ recvWindow (int, optional): The value cannot be greater than 60000
159
+ """
160
+
161
+ check_required_parameters (
162
+ [[orderId , "orderId" ], [amount , "amount" ], [direction , "direction" ]]
163
+ )
164
+
165
+ payload = {"orderId" : orderId , "amount" : amount , "direction" : direction , ** kwargs }
166
+ return self .sign_request ("POST" , "/sapi/v1/loan/adjust/ltv" , payload )
167
+
168
+
169
+ def loan_adjust_ltv_history (self , ** kwargs ):
170
+ """Get Loan LTV Adjustment History (USER_DATA)
171
+
172
+ GET /sapi/v1/loan/ltv/adjustment/history
173
+
174
+ https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-get-loan-ltv-adjustment-history-user_data
175
+
176
+ Keyword Args:
177
+ orderId (int, optional)
178
+ loanCoin (str, optional)
179
+ collateralCoin (str, optional)
180
+ startTime (int, optional)
181
+ endTime (int, optional)
182
+ current (int, optional): Current querying page. Start from 1; default: 1; max: 1000
183
+ limit (int, optional): Default: 10; max: 100
184
+ recvWindow (int, optional): The value cannot be greater than 60000
185
+ """
186
+
187
+ return self .sign_request ("GET" , "/sapi/v1/loan/ltv/adjustment/history" , kwargs )
0 commit comments