python-okx 0.3.1__tar.gz → 0.3.2__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.
Files changed (37) hide show
  1. {python-okx-0.3.1 → python-okx-0.3.2}/PKG-INFO +2 -1
  2. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Account.py +122 -43
  3. python-okx-0.3.2/okx/SimpleEarnFixed.py +91 -0
  4. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Trade.py +5 -8
  5. python-okx-0.3.2/okx/TradingData.py +55 -0
  6. {python-okx-0.3.1 → python-okx-0.3.2}/okx/__init__.py +1 -1
  7. {python-okx-0.3.1 → python-okx-0.3.2}/okx/consts.py +19 -7
  8. {python-okx-0.3.1 → python-okx-0.3.2}/okx/okxclient.py +5 -2
  9. {python-okx-0.3.1 → python-okx-0.3.2}/okx/utils.py +6 -4
  10. {python-okx-0.3.1 → python-okx-0.3.2}/python_okx.egg-info/PKG-INFO +2 -1
  11. {python-okx-0.3.1 → python-okx-0.3.2}/python_okx.egg-info/SOURCES.txt +1 -0
  12. {python-okx-0.3.1 → python-okx-0.3.2}/python_okx.egg-info/requires.txt +1 -0
  13. {python-okx-0.3.1 → python-okx-0.3.2}/setup.py +1 -0
  14. python-okx-0.3.1/okx/TradingData.py +0 -113
  15. {python-okx-0.3.1 → python-okx-0.3.2}/README.md +0 -0
  16. {python-okx-0.3.1 → python-okx-0.3.2}/okx/BlockTrading.py +0 -0
  17. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Convert.py +0 -0
  18. {python-okx-0.3.1 → python-okx-0.3.2}/okx/CopyTrading.py +0 -0
  19. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Earning.py +0 -0
  20. {python-okx-0.3.1 → python-okx-0.3.2}/okx/FDBroker.py +0 -0
  21. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Funding.py +0 -0
  22. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Grid.py +0 -0
  23. {python-okx-0.3.1 → python-okx-0.3.2}/okx/MarketData.py +0 -0
  24. {python-okx-0.3.1 → python-okx-0.3.2}/okx/NDBroker.py +0 -0
  25. {python-okx-0.3.1 → python-okx-0.3.2}/okx/PublicData.py +0 -0
  26. {python-okx-0.3.1 → python-okx-0.3.2}/okx/SpreadTrading.py +0 -0
  27. {python-okx-0.3.1 → python-okx-0.3.2}/okx/Status.py +0 -0
  28. {python-okx-0.3.1 → python-okx-0.3.2}/okx/SubAccount.py +0 -0
  29. {python-okx-0.3.1 → python-okx-0.3.2}/okx/exceptions.py +0 -0
  30. {python-okx-0.3.1 → python-okx-0.3.2}/okx/websocket/WebSocketFactory.py +0 -0
  31. {python-okx-0.3.1 → python-okx-0.3.2}/okx/websocket/WsPrivateAsync.py +0 -0
  32. {python-okx-0.3.1 → python-okx-0.3.2}/okx/websocket/WsPublicAsync.py +0 -0
  33. {python-okx-0.3.1 → python-okx-0.3.2}/okx/websocket/WsUtils.py +0 -0
  34. {python-okx-0.3.1 → python-okx-0.3.2}/okx/websocket/__init__.py +0 -0
  35. {python-okx-0.3.1 → python-okx-0.3.2}/python_okx.egg-info/dependency_links.txt +0 -0
  36. {python-okx-0.3.1 → python-okx-0.3.2}/python_okx.egg-info/top_level.txt +0 -0
  37. {python-okx-0.3.1 → python-okx-0.3.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-okx
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Python SDK for OKX
5
5
  Home-page: https://okx.com/docs-v5/
6
6
  Author: okxv5api
@@ -12,6 +12,7 @@ Description-Content-Type: text/markdown
12
12
  Requires-Dist: importlib-metadata
13
13
  Requires-Dist: httpx[http2]
14
14
  Requires-Dist: keyring
15
+ Requires-Dist: loguru
15
16
  Requires-Dist: requests
16
17
  Requires-Dist: Twisted
17
18
  Requires-Dist: pyOpenSSL
@@ -1,10 +1,11 @@
1
- from .okxclient import OkxClient
2
1
  from .consts import *
2
+ from .okxclient import OkxClient
3
3
 
4
4
 
5
5
  class AccountAPI(OkxClient):
6
6
 
7
- def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None):
7
+ def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1',
8
+ domain='https://www.okx.com', debug=True, proxy=None):
8
9
  OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
9
10
 
10
11
  # Get Positions
@@ -26,7 +27,8 @@ class AccountAPI(OkxClient):
26
27
  params = {'instType': instType, 'instId': instId}
27
28
  return self._request_with_params(GET, POSITION_INFO, params)
28
29
 
29
- def position_builder(self,inclRealPosAndEq=False, spotOffsetType=None, greeksType=None, simPos=None, simAsset=None):
30
+ def position_builder(self, inclRealPosAndEq=False, spotOffsetType=None, greeksType=None, simPos=None,
31
+ simAsset=None):
30
32
  params = {}
31
33
  if inclRealPosAndEq is not None:
32
34
  params['inclRealPosAndEq'] = inclRealPosAndEq
@@ -42,16 +44,17 @@ class AccountAPI(OkxClient):
42
44
 
43
45
  # Get Bills Details (recent 7 days)
44
46
  def get_account_bills(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='',
45
- limit=''):
47
+ limit=''):
46
48
  params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type,
47
49
  'subType': subType, 'after': after, 'before': before, 'limit': limit}
48
50
  return self._request_with_params(GET, BILLS_DETAIL, params)
49
51
 
50
52
  # Get Bills Details (recent 3 months)
51
- def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='',
52
- limit='',begin='',end=''):
53
+ def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='',
54
+ before='',
55
+ limit='', begin='', end=''):
53
56
  params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type,
54
- 'subType': subType, 'after': after, 'before': before, 'limit': limit,'begin':begin,'end':end}
57
+ 'subType': subType, 'after': after, 'before': before, 'limit': limit, 'begin': begin, 'end': end}
55
58
  return self._request_with_params(GET, BILLS_ARCHIVE, params)
56
59
 
57
60
  # Get Account Configuration
@@ -80,18 +83,19 @@ class AccountAPI(OkxClient):
80
83
  return self._request_with_params(GET, MAX_AVAIL_SIZE, params)
81
84
 
82
85
  # Increase / Decrease margin
83
- def adjustment_margin(self, instId, posSide, type, amt,loanTrans=''):
84
- params = {'instId': instId, 'posSide': posSide, 'type': type, 'amt': amt,'loanTrans':loanTrans}
86
+ def adjustment_margin(self, instId, posSide, type, amt, loanTrans=''):
87
+ params = {'instId': instId, 'posSide': posSide, 'type': type, 'amt': amt, 'loanTrans': loanTrans}
85
88
  return self._request_with_params(POST, ADJUSTMENT_MARGIN, params)
86
89
 
87
90
  # Get Leverage
88
91
  def get_leverage(self, instId, mgnMode):
89
92
  params = {'instId': instId, 'mgnMode': mgnMode}
90
93
  return self._request_with_params(GET, GET_LEVERAGE, params)
94
+
91
95
  # Get instruments
92
- def get_instruments(self, instType='', ugly = '',instFamily='',instId=''):
96
+ def get_instruments(self, instType='', ugly='', instFamily='', instId=''):
93
97
  params = {'instType': instType, 'ugly': ugly, 'instFamily': instFamily, 'instId': instId}
94
- return self._request_with_params(GET,GET_INSTRUMENTS,params)
98
+ return self._request_with_params(GET, GET_INSTRUMENTS, params)
95
99
 
96
100
  # Get the maximum loan of isolated MARGIN
97
101
  def get_max_loan(self, instId, mgnMode, mgnCcy):
@@ -99,8 +103,8 @@ class AccountAPI(OkxClient):
99
103
  return self._request_with_params(GET, MAX_LOAN, params)
100
104
 
101
105
  # Get Fee Rates
102
- def get_fee_rates(self, instType, instId='', uly='', category='',instFamily = ''):
103
- params = {'instType': instType, 'instId': instId, 'uly': uly, 'category': category,'instFamily':instFamily}
106
+ def get_fee_rates(self, instType, instId='', uly='', category='', instFamily=''):
107
+ params = {'instType': instType, 'instId': instId, 'uly': uly, 'category': category, 'instFamily': instFamily}
104
108
  return self._request_with_params(GET, FEE_RATES, params)
105
109
 
106
110
  # Get interest-accrued
@@ -119,8 +123,8 @@ class AccountAPI(OkxClient):
119
123
  return self._request_with_params(POST, SET_GREEKS, params)
120
124
 
121
125
  # Set Isolated Mode
122
- def set_isolated_mode(self, isoMode,type):
123
- params = {'isoMode': isoMode, 'type':type}
126
+ def set_isolated_mode(self, isoMode, type):
127
+ params = {'isoMode': isoMode, 'type': type}
124
128
  return self._request_with_params(POST, ISOLATED_MODE, params)
125
129
 
126
130
  # Get Maximum Withdrawals
@@ -135,11 +139,11 @@ class AccountAPI(OkxClient):
135
139
 
136
140
  # Get borrow repay history
137
141
  def get_borrow_repay_history(self, ccy='', after='', before='', limit=''):
138
- params = {'ccy': ccy, 'after': after, 'before': before, 'limit':limit}
142
+ params = {'ccy': ccy, 'after': after, 'before': before, 'limit': limit}
139
143
  return self._request_with_params(GET, BORROW_REPAY_HISTORY, params)
140
144
 
141
145
  # Get Obtain borrowing rate and limit
142
- def get_interest_limits(self, type='',ccy=''):
146
+ def get_interest_limits(self, type='', ccy=''):
143
147
  params = {'type': type, 'ccy': ccy}
144
148
  return self._request_with_params(GET, INTEREST_LIMITS, params)
145
149
 
@@ -153,57 +157,58 @@ class AccountAPI(OkxClient):
153
157
  params = {'ccy': ccy}
154
158
  return self._request_with_params(GET, GREEKS, params)
155
159
 
156
- #GET /api/v5/account/risk-state
160
+ # GET /api/v5/account/risk-state
157
161
  def get_account_position_risk(self):
158
162
  return self._request_without_params(GET, ACCOUNT_RISK)
159
163
 
160
- #GET /api/v5/account/positions-history
161
- def get_positions_history(self,instType = '', instId = '',mgnMode = '',type = '',posId = '',after = '',before ='',limit = ''):
164
+ # GET /api/v5/account/positions-history
165
+ def get_positions_history(self, instType='', instId='', mgnMode='', type='', posId='', after='', before='',
166
+ limit=''):
162
167
  params = {
163
- 'instType':instType,
164
- 'instId':instId,
165
- 'mgnMode':mgnMode,
166
- 'type':type,
167
- 'posId':posId,
168
- 'after':after,
169
- 'before':before,
170
- 'limit':limit
168
+ 'instType': instType,
169
+ 'instId': instId,
170
+ 'mgnMode': mgnMode,
171
+ 'type': type,
172
+ 'posId': posId,
173
+ 'after': after,
174
+ 'before': before,
175
+ 'limit': limit
171
176
  }
172
- return self._request_with_params(GET,POSITIONS_HISTORY,params)
177
+ return self._request_with_params(GET, POSITIONS_HISTORY, params)
173
178
 
174
- #GET /api/v5/account/position-tiers
175
- def get_account_position_tiers(self,instType = '', uly = '',instFamily = ''):
179
+ # GET /api/v5/account/position-tiers
180
+ def get_account_position_tiers(self, instType='', uly='', instFamily=''):
176
181
  params = {
177
- 'instType':instType,
178
- 'uly':uly,
179
- 'instFamily':instFamily
182
+ 'instType': instType,
183
+ 'uly': uly,
184
+ 'instFamily': instFamily
180
185
  }
181
- return self._request_with_params(GET,GET_PM_LIMIT,params)
186
+ return self._request_with_params(GET, GET_PM_LIMIT, params)
182
187
 
183
- #- Get VIP interest accrued data
188
+ # - Get VIP interest accrued data
184
189
  def get_VIP_interest_accrued_data(self, ccy='', ordId='', after='', before='', limit=''):
185
190
  params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit}
186
191
  return self._request_with_params(GET, GET_VIP_INTEREST_ACCRUED_DATA, params)
187
192
 
188
- #- Get VIP interest deducted data
193
+ # - Get VIP interest deducted data
189
194
  def get_VIP_interest_deducted_data(self, ccy='', ordId='', after='', before='', limit=''):
190
195
  params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit}
191
196
  return self._request_with_params(GET, GET_VIP_INTEREST_DEDUCTED_DATA, params)
192
197
 
193
198
  # - Get VIP loan order list
194
- def get_VIP_loan_order_list(self, ordId='',state='', ccy='', after='', before='', limit=''):
195
- params = {'ordId': ordId, 'state': state, 'ccy': ccy,'after': after, 'before': before, 'limit': limit}
199
+ def get_VIP_loan_order_list(self, ordId='', state='', ccy='', after='', before='', limit=''):
200
+ params = {'ordId': ordId, 'state': state, 'ccy': ccy, 'after': after, 'before': before, 'limit': limit}
196
201
  return self._request_with_params(GET, GET_VIP_LOAN_ORDER_LIST, params)
197
202
 
198
- #- Get VIP loan order detail
203
+ # - Get VIP loan order detail
199
204
  def get_VIP_loan_order_detail(self, ccy='', ordId='', after='', before='', limit=''):
200
205
  params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit}
201
206
  return self._request_with_params(GET, GET_VIP_LOAN_ORDER_DETAIL, params)
202
207
 
203
- #- Set risk offset type
208
+ # - Set risk offset type
204
209
  def set_risk_offset_typel(self, type=''):
205
210
  params = {'type': type}
206
- return self._request_with_params(POST, SET_RISK_OFFSET_TYPE,params)
211
+ return self._request_with_params(POST, SET_RISK_OFFSET_TYPE, params)
207
212
 
208
213
  # - Set auto loan
209
214
  def set_auto_loan(self, autoLoan=''):
@@ -212,6 +217,80 @@ class AccountAPI(OkxClient):
212
217
  }
213
218
  return self._request_with_params(POST, SET_AUTO_LOAN, params)
214
219
 
215
- #- Activate option
220
+ # - Activate option
216
221
  def activate_option(self):
217
222
  return self._request_without_params(POST, ACTIVSTE_OPTION)
223
+
224
+ def get_fix_loan_borrowing_limit(self):
225
+ return self._request_without_params(GET, BORROWING_LIMIT)
226
+
227
+ def get_fix_loan_borrowing_quote(self, type=None, ccy=None, amt=None, maxRate=None, term=None, ordId=None):
228
+ params = {}
229
+ if type is not None:
230
+ params['type'] = type
231
+ if ccy is not None:
232
+ params['ccy'] =ccy
233
+ if amt is not None:
234
+ params['amt'] = amt
235
+ if maxRate is not None:
236
+ params['maxRate'] = maxRate
237
+ if term is not None:
238
+ params['term'] = term
239
+ if ordId is not None:
240
+ params['ordId'] = ordId
241
+ return self._request_with_params(GET, BORROWING_QUOTE, params)
242
+
243
+ def place_fix_loan_borrowing_order(self, ccy=None, amt=None, maxRate=None, term=None, reborrow=False, reborrowRate=None):
244
+ params = {}
245
+ if ccy is not None:
246
+ params['ccy'] =ccy
247
+ if amt is not None:
248
+ params['amt'] = amt
249
+ if maxRate is not None:
250
+ params['maxRate'] = maxRate
251
+ if term is not None:
252
+ params['term'] = term
253
+ if reborrow is not None:
254
+ params['reborrow'] = reborrow
255
+ if reborrowRate is not None:
256
+ params['reborrowRate'] = reborrowRate
257
+ return self._request_with_params(POST, PLACE_BORROWING_ORDER, params)
258
+
259
+ def amend_fix_loan_borrowing_order(self, ordId=None, reborrow=None, renewMaxRate=None):
260
+ params = {}
261
+ if ordId is not None:
262
+ params['ordId'] = ordId
263
+ if reborrow is not None:
264
+ params['reborrow'] = reborrow
265
+ if renewMaxRate is not None:
266
+ params['renewMaxRate'] = renewMaxRate
267
+ return self._request_with_params(POST, AMEND_BORROWING_ORDER, params)
268
+
269
+ def fix_loan_manual_reborrow(self, ordId=None, maxRate=None):
270
+ params = {}
271
+ if ordId is not None:
272
+ params['ordId'] = ordId
273
+ if maxRate is not None:
274
+ params['maxRate'] = maxRate
275
+ return self._request_with_params(POST, MANUAL_REBORROW, params)
276
+
277
+ def repay_fix_loan_borrowing_order(self, ordId=None):
278
+ params = {}
279
+ if ordId is not None:
280
+ params['ordId'] = ordId
281
+ return self._request_with_params(POST, REPAY_BORROWING_ORDER, params)
282
+ def get_fix_loan_borrowing_orders_list(self, ordId=None, ccy=None, state=None, after=None, before=None, limit=None):
283
+ params = {}
284
+ if ordId is not None:
285
+ params['ordId'] = ordId
286
+ if ccy is not None:
287
+ params['ccy'] =ccy
288
+ if state is not None:
289
+ params['state'] = state
290
+ if after is not None:
291
+ params['after'] = after
292
+ if before is not None:
293
+ params['before'] = before
294
+ if limit is not None:
295
+ params['limit'] = limit
296
+ return self._request_with_params(GET, BORROWING_ORDERS_LIST, params)
@@ -0,0 +1,91 @@
1
+ from okx.consts import GET, LENDING_OFFERS, LENDING_APY_HISTORY, PENDING_LENDING_VOLUME, PLACE_LENDING_ORDER, POST, \
2
+ AMEND_LENDING_ORDER, LENDING_ORDERS_LIST, LENDING_SUB_ORDERS
3
+ from okx.okxclient import OkxClient
4
+
5
+
6
+ class SimpleEarnFixedAPI(OkxClient):
7
+ def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1',
8
+ domain='https://www.okx.com', debug=True, proxy=None):
9
+ OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
10
+
11
+ def get_lending_offers(self, ccy=None, term=None):
12
+ params = {}
13
+ if ccy is not None:
14
+ params['ccy'] = ccy
15
+ if term is not None:
16
+ params['term'] = term
17
+ return self._request_with_params(GET, LENDING_OFFERS, params)
18
+
19
+ def get_lending_apy_history(self, ccy=None, term=None):
20
+ params = {}
21
+ if ccy is not None:
22
+ params['ccy'] = ccy
23
+ if term is not None:
24
+ params['term'] = term
25
+ return self._request_with_params(GET, LENDING_APY_HISTORY, params)
26
+
27
+ def get_pending_lending_volume(self, ccy=None, term=None):
28
+ params = {}
29
+ if ccy is not None:
30
+ params['ccy'] = ccy
31
+ if term is not None:
32
+ params['term'] = term
33
+ return self._request_with_params(GET, PENDING_LENDING_VOLUME, params)
34
+
35
+ def place_lending_order(self, ccy=None, amt=None, rate=None, term=None, autoRenewal=False):
36
+ params = {}
37
+ if ccy is not None:
38
+ params['ccy'] = ccy
39
+ if amt is not None:
40
+ params['amt'] = amt
41
+ if rate is not None:
42
+ params['rate'] = rate
43
+ if term is not None:
44
+ params['term'] = term
45
+ if autoRenewal:
46
+ params['autoRenewal'] = autoRenewal
47
+ return self._request_with_params(POST, PLACE_LENDING_ORDER, params)
48
+ def amend_lending_order(self, ordId=None, changeAmt=None, rate=None,autoRenewal=False):
49
+ params = {}
50
+ if ordId is not None:
51
+ params['ordId'] = ordId
52
+ if changeAmt is not None:
53
+ params['amt'] = changeAmt
54
+ if rate is not None:
55
+ params['rate'] = rate
56
+ params['autoRenewal'] = autoRenewal
57
+ return self._request_with_params(POST, AMEND_LENDING_ORDER, params)
58
+
59
+ def get_lending_orders_list(self, ordId = None,ccy=None, state=None, after=None,before=None,limit=None):
60
+ params = {}
61
+ if ordId is not None:
62
+ params['ordId'] = ordId
63
+ if ccy is not None:
64
+ params['ccy'] = ccy
65
+ if state is not None:
66
+ params['state'] = state
67
+ if after is not None:
68
+ params['after'] = after
69
+ if before is not None:
70
+ params['before'] = before
71
+ if limit:
72
+ params['limit'] = limit
73
+ return self._request_with_params(GET, LENDING_ORDERS_LIST, params)
74
+
75
+ def get_lending_sub_orders(self, ordId = None, state=None, after=None,before=None,limit=None):
76
+ params = {}
77
+ if ordId is not None:
78
+ params['ordId'] = ordId
79
+ if state is not None:
80
+ params['state'] = state
81
+ if after is not None:
82
+ params['after'] = after
83
+ if before is not None:
84
+ params['before'] = before
85
+ if limit:
86
+ params['limit'] = limit
87
+ return self._request_with_params(GET, LENDING_SUB_ORDERS, params)
88
+
89
+
90
+
91
+
@@ -1,5 +1,7 @@
1
- from .consts import *
1
+ import json
2
+
2
3
  from .okxclient import OkxClient
4
+ from .consts import *
3
5
 
4
6
 
5
7
  class TradeAPI(OkxClient):
@@ -84,10 +86,9 @@ class TradeAPI(OkxClient):
84
86
  return self._request_with_params(GET, ORDERS_HISTORY_ARCHIVE, params)
85
87
 
86
88
  # Get Transaction Details
87
- def get_fills(self, instType='', uly='', instId='', ordId='', after='', before='', limit='', instFamily='',
88
- begin='', end=''):
89
+ def get_fills(self, instType='', uly='', instId='', ordId='', after='', before='', limit='', instFamily='',begin='',end=''):
89
90
  params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordId': ordId, 'after': after, 'before': before,
90
- 'limit': limit, 'instFamily': instFamily, 'begin': begin, 'end': end}
91
+ 'limit': limit, 'instFamily': instFamily,'begin': begin, 'end' :end}
91
92
  return self._request_with_params(GET, ORDER_FILLS, params)
92
93
 
93
94
  # Place Algo Order
@@ -190,7 +191,3 @@ class TradeAPI(OkxClient):
190
191
  'newSlTriggerPx': newSlTriggerPx, 'newSlOrdPx': newSlOrdPx,
191
192
  'newTpTriggerPxType': newTpTriggerPxType, 'newSlTriggerPxType': newSlTriggerPxType}
192
193
  return self._request_with_params(POST, AMEND_ALGO_ORDER, params)
193
-
194
- def cancel_all_after(self, timeOut='', tag=''):
195
- params = {'timeOut': timeOut, 'tag': tag}
196
- return self._request_with_params(POST, CANCEL_ALL_AFTER, params)
@@ -0,0 +1,55 @@
1
+ from .okxclient import OkxClient
2
+ from .consts import *
3
+
4
+
5
+ class TradingDataAPI(OkxClient):
6
+
7
+ def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
8
+ OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
9
+
10
+
11
+ def get_support_coin(self):
12
+ return self._request_without_params(GET, SUPPORT_COIN)
13
+
14
+ def get_taker_volume(self, ccy, instType, begin='', end='', period=''):
15
+ params = {'ccy': ccy, 'instType': instType, 'begin': begin, 'end': end, 'period': period}
16
+ return self._request_with_params(GET, TAKER_VOLUME, params)
17
+
18
+ def get_margin_lending_ratio(self, ccy, begin='', end='', period=''):
19
+ params = {'ccy': ccy, 'begin': begin, 'end': end, 'period': period}
20
+ return self._request_with_params(GET, MARGIN_LENDING_RATIO, params)
21
+
22
+ def get_long_short_ratio(self, ccy, begin='', end='', period=''):
23
+ params = {'ccy': ccy, 'begin': begin, 'end': end, 'period': period}
24
+ return self._request_with_params(GET, LONG_SHORT_RATIO, params)
25
+
26
+ def get_contracts_interest_volume(self, ccy, begin='', end='', period=''):
27
+ params = {'ccy': ccy, 'begin': begin, 'end': end, 'period': period}
28
+ return self._request_with_params(GET, CONTRACTS_INTEREST_VOLUME, params)
29
+
30
+ def get_options_interest_volume(self, ccy, period=''):
31
+ params = {'ccy': ccy, 'period': period}
32
+ return self._request_with_params(GET, OPTIONS_INTEREST_VOLUME, params)
33
+
34
+ def get_put_call_ratio(self, ccy, period=''):
35
+ params = {'ccy': ccy, 'period': period}
36
+ return self._request_with_params(GET, PUT_CALL_RATIO, params)
37
+
38
+ def get_interest_volume_expiry(self, ccy, period=''):
39
+ params = {'ccy': ccy, 'period': period}
40
+ return self._request_with_params(GET, OPEN_INTEREST_VOLUME_EXPIRY, params)
41
+
42
+ def get_interest_volume_strike(self, ccy, expTime, period=''):
43
+ params = {'ccy': ccy, 'expTime': expTime, 'period': period}
44
+ return self._request_with_params(GET, INTEREST_VOLUME_STRIKE, params)
45
+
46
+ def get_taker_block_volume(self, ccy, period=''):
47
+ params = {'ccy': ccy, 'period': period}
48
+ return self._request_with_params(GET, TAKER_FLOW, params)
49
+
50
+
51
+
52
+
53
+
54
+
55
+
@@ -2,4 +2,4 @@
2
2
  Python SDK for the OKX API v5
3
3
 
4
4
  """
5
- __version__="0.3.1"
5
+ __version__="0.3.2"
@@ -55,6 +55,13 @@ SET_AUTO_LOAN = '/api/v5/account/set-auto-loan'
55
55
  ACTIVSTE_OPTION = '/api/v5/account/activate-option'
56
56
  POSITION_BUILDER = '/api/v5/account/position-builder'
57
57
  GET_INSTRUMENTS = '/api/v5/account/instruments'
58
+ BORROWING_LIMIT = '/api/v5/account/fixed-loan/borrowing-limit'
59
+ BORROWING_QUOTE = '/api/v5/account/fixed-loan/borrowing-quote'
60
+ PLACE_BORROWING_ORDER= '/api/v5/account/fixed-loan/borrowing-order'
61
+ AMEND_BORROWING_ORDER='/api/v5/account/fixed-loan/amend-borrowing-order'
62
+ MANUAL_REBORROW = '/api/v5/account/fixed-loan/manual-reborrow'
63
+ REPAY_BORROWING_ORDER='/api/v5/account/fixed-loan/repay-borrowing-order'
64
+ BORROWING_ORDERS_LIST='/api/v5/account/fixed-loan/borrowing-orders-list'
58
65
 
59
66
  # funding-complete-testcomplete
60
67
  NON_TRADABLE_ASSETS = '/api/v5/asset/non-tradable-assets'
@@ -137,12 +144,6 @@ PUT_CALL_RATIO = '/api/v5/rubik/stat/option/open-interest-volume-ratio'
137
144
  OPEN_INTEREST_VOLUME_EXPIRY = '/api/v5/rubik/stat/option/open-interest-volume-expiry'
138
145
  INTEREST_VOLUME_STRIKE = '/api/v5/rubik/stat/option/open-interest-volume-strike'
139
146
  TAKER_FLOW = '/api/v5/rubik/stat/option/taker-block-volume'
140
- OPEN_INTEREST_HISTORY = '/api/v5/rubik/stat/contracts/open-interest-history'
141
- LONG_SHORT_ACCOUNT_RATIO_CONTRACT_TOP_TRADER = '/api/v5/rubik/stat/contracts/long-short-account-ratio-contract-top-trader'
142
- LONG_SHORT_POSITION_RATIO_CONTRACT_TOP_TRADER = '/api/v5/rubik/stat/contracts/long-short-position-ratio-contract-top-trader'
143
- LONG_SHORT_ACCOUNT_RATIO_CONTRACT = '/api/v5/rubik/stat/contracts/long-short-account-ratio-contract'
144
- TAKER_VOLUME_CONTRACT = '/api/v5/rubik/stat/taker-volume-contract'
145
-
146
147
 
147
148
  # TRADE-Complete
148
149
  PLACR_ORDER = '/api/v5/trade/order'
@@ -172,7 +173,7 @@ CONVERT_EASY_HISTORY = '/api/v5/trade/easy-convert-history'
172
173
  ONE_CLICK_REPAY_SUPPORT = '/api/v5/trade/one-click-repay-currency-list'
173
174
  ONE_CLICK_REPAY = '/api/v5/trade/one-click-repay'
174
175
  ONE_CLICK_REPAY_HISTORY = '/api/v5/trade/one-click-repay-history'
175
- CANCEL_ALL_AFTER = '/api/v5/trade/cancel-all-after'
176
+
176
177
 
177
178
  # SubAccount-complete-testwriteComplete
178
179
  BALANCE = '/api/v5/account/subaccount/balances'
@@ -298,3 +299,14 @@ SPREAD_GET_SPREADS = '/api/v5/sprd/spreads'
298
299
  SPREAD_GET_ORDER_BOOK = '/api/v5/sprd/books'
299
300
  SPREAD_GET_TICKER = '/api/v5/sprd/ticker'
300
301
  SPREAD_GET_PUBLIC_TRADES = '/api/v5/sprd/public-trades'
302
+
303
+ # Simple earn fixed
304
+ LENDING_OFFERS = '/api/v5/finance/fixed-loan/lending-offers'
305
+ LENDING_APY_HISTORY='/api/v5/finance/fixed-loan/lending-apy-history'
306
+ PENDING_LENDING_VOLUME = '/api/v5/finance/fixed-loan/pending-lending-volume'
307
+ PLACE_LENDING_ORDER= '/api/v5/finance/fixed-loan/lending-order'
308
+ AMEND_LENDING_ORDER='/api/v5/finance/fixed-loan/amend-lending-order'
309
+ LENDING_ORDERS_LIST='/api/v5/finance/fixed-loan/lending-orders-list'
310
+ LENDING_SUB_ORDERS='/api/v5/finance/fixed-loan/lending-sub-orders'
311
+
312
+
@@ -6,6 +6,8 @@ import httpx
6
6
  from httpx import Client
7
7
  from datetime import datetime, timezone
8
8
 
9
+ from loguru import logger
10
+
9
11
  from . import consts as c, utils, exceptions
10
12
 
11
13
 
@@ -37,8 +39,9 @@ class OkxClient(Client):
37
39
  header = utils.get_header_no_sign(self.flag, self.debug)
38
40
  response = None
39
41
  if self.debug == True:
40
- print('domain:',self.domain)
41
- print('url:',request_path)
42
+ logger.debug(f'domain: {self.domain}')
43
+ logger.debug(f'url: {request_path}')
44
+ logger.debug(f'body:{body}')
42
45
  if method == c.GET:
43
46
  response = self.get(request_path, headers=header)
44
47
  elif method == c.POST:
@@ -1,6 +1,9 @@
1
1
  import hmac
2
2
  import base64
3
3
  import datetime
4
+
5
+ from loguru import logger
6
+
4
7
  from . import consts as c
5
8
 
6
9
 
@@ -12,7 +15,7 @@ def sign(message, secretKey):
12
15
 
13
16
  def pre_hash(timestamp, method, request_path, body,debug = True):
14
17
  if debug == True:
15
- print('body: ',body)
18
+ logger.debug(f'body: {body}')
16
19
  return str(timestamp) + str.upper(method) + request_path + body
17
20
 
18
21
 
@@ -25,7 +28,7 @@ def get_header(api_key, sign, timestamp, passphrase, flag,debug = True):
25
28
  header[c.OK_ACCESS_PASSPHRASE] = passphrase
26
29
  header['x-simulated-trading'] = flag
27
30
  if debug == True:
28
- print('header: ',header)
31
+ logger.debug(f'header: {header}')
29
32
  return header
30
33
 
31
34
  def get_header_no_sign(flag,debug = True):
@@ -33,7 +36,7 @@ def get_header_no_sign(flag,debug = True):
33
36
  header[c.CONTENT_TYPE] = c.APPLICATION_JSON
34
37
  header['x-simulated-trading'] = flag
35
38
  if debug == True:
36
- print('header: ',header)
39
+ logger.debug(f'header: {header}')
37
40
  return header
38
41
 
39
42
  def parse_params_to_str(params):
@@ -42,7 +45,6 @@ def parse_params_to_str(params):
42
45
  if(value != ''):
43
46
  url = url + str(key) + '=' + str(value) + '&'
44
47
  url = url[0:-1]
45
- #print('url:',url)
46
48
  return url
47
49
 
48
50
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-okx
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Python SDK for OKX
5
5
  Home-page: https://okx.com/docs-v5/
6
6
  Author: okxv5api
@@ -12,6 +12,7 @@ Description-Content-Type: text/markdown
12
12
  Requires-Dist: importlib-metadata
13
13
  Requires-Dist: httpx[http2]
14
14
  Requires-Dist: keyring
15
+ Requires-Dist: loguru
15
16
  Requires-Dist: requests
16
17
  Requires-Dist: Twisted
17
18
  Requires-Dist: pyOpenSSL
@@ -11,6 +11,7 @@ okx/Grid.py
11
11
  okx/MarketData.py
12
12
  okx/NDBroker.py
13
13
  okx/PublicData.py
14
+ okx/SimpleEarnFixed.py
14
15
  okx/SpreadTrading.py
15
16
  okx/Status.py
16
17
  okx/SubAccount.py
@@ -1,6 +1,7 @@
1
1
  importlib-metadata
2
2
  httpx[http2]
3
3
  keyring
4
+ loguru
4
5
  requests
5
6
  Twisted
6
7
  pyOpenSSL
@@ -22,6 +22,7 @@ setuptools.setup(
22
22
  "importlib-metadata",
23
23
  "httpx[http2]",
24
24
  "keyring",
25
+ "loguru",
25
26
  "requests",
26
27
  "Twisted",
27
28
  "pyOpenSSL"
@@ -1,113 +0,0 @@
1
- from .consts import *
2
- from .okxclient import OkxClient
3
-
4
-
5
- class TradingDataAPI(OkxClient):
6
-
7
- def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1',
8
- domain='https://www.okx.com', debug=True, proxy=None):
9
- OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
10
-
11
- def get_support_coin(self):
12
- return self._request_without_params(GET, SUPPORT_COIN)
13
-
14
- def get_taker_volume(self, ccy, instType, begin='', end='', period=''):
15
- params = {'ccy': ccy, 'instType': instType, 'begin': begin, 'end': end, 'period': period}
16
- return self._request_with_params(GET, TAKER_VOLUME, params)
17
-
18
- def get_margin_lending_ratio(self, ccy, begin='', end='', period=''):
19
- params = {'ccy': ccy, 'begin': begin, 'end': end, 'period': period}
20
- return self._request_with_params(GET, MARGIN_LENDING_RATIO, params)
21
-
22
- def get_long_short_ratio(self, ccy, begin='', end='', period=''):
23
- params = {'ccy': ccy, 'begin': begin, 'end': end, 'period': period}
24
- return self._request_with_params(GET, LONG_SHORT_RATIO, params)
25
-
26
- def get_contracts_interest_volume(self, ccy, begin='', end='', period=''):
27
- params = {'ccy': ccy, 'begin': begin, 'end': end, 'period': period}
28
- return self._request_with_params(GET, CONTRACTS_INTEREST_VOLUME, params)
29
-
30
- def get_options_interest_volume(self, ccy, period=''):
31
- params = {'ccy': ccy, 'period': period}
32
- return self._request_with_params(GET, OPTIONS_INTEREST_VOLUME, params)
33
-
34
- def get_put_call_ratio(self, ccy, period=''):
35
- params = {'ccy': ccy, 'period': period}
36
- return self._request_with_params(GET, PUT_CALL_RATIO, params)
37
-
38
- def get_interest_volume_expiry(self, ccy, period=''):
39
- params = {'ccy': ccy, 'period': period}
40
- return self._request_with_params(GET, OPEN_INTEREST_VOLUME_EXPIRY, params)
41
-
42
- def get_interest_volume_strike(self, ccy, expTime, period=''):
43
- params = {'ccy': ccy, 'expTime': expTime, 'period': period}
44
- return self._request_with_params(GET, INTEREST_VOLUME_STRIKE, params)
45
-
46
- def get_taker_block_volume(self, ccy, period=''):
47
- params = {'ccy': ccy, 'period': period}
48
- return self._request_with_params(GET, TAKER_FLOW, params)
49
-
50
- def get_open_interest_history(self, instId='', period=None, end=None, begin=None, limit=None):
51
- params = {'instId': instId}
52
- if period is not None:
53
- params['period'] = period
54
- if end is not None:
55
- params['end'] = end
56
- if begin is not None:
57
- params['begin'] = begin
58
- if limit is not None:
59
- params['limit'] = limit
60
- return self._request_with_params(GET, OPEN_INTEREST_HISTORY, params)
61
-
62
- def get_top_trader_long_short_account_ratio(self, instId='', period=None, end=None, begin=None,
63
- limit=None):
64
- params = {'instId': instId}
65
- if period is not None:
66
- params['period'] = period
67
- if end is not None:
68
- params['end'] = end
69
- if begin is not None:
70
- params['begin'] = begin
71
- if limit is not None:
72
- params['limit'] = limit
73
- return self._request_with_params(GET, LONG_SHORT_ACCOUNT_RATIO_CONTRACT_TOP_TRADER, params)
74
-
75
- def get_top_trader_long_short_position_ratio(self, instId='', period=None, end=None, begin=None,
76
- limit=None):
77
- params = {'instId': instId}
78
- if period is not None:
79
- params['period'] = period
80
- if end is not None:
81
- params['end'] = end
82
- if begin is not None:
83
- params['begin'] = begin
84
- if limit is not None:
85
- params['limit'] = limit
86
- return self._request_with_params(GET, LONG_SHORT_POSITION_RATIO_CONTRACT_TOP_TRADER, params)
87
-
88
- def get_contract_long_short_ratio(self, instId='', period=None, end=None, begin=None,
89
- limit=None):
90
- params = {'instId': instId}
91
- if period is not None:
92
- params['period'] = period
93
- if end is not None:
94
- params['end'] = end
95
- if begin is not None:
96
- params['begin'] = begin
97
- if limit is not None:
98
- params['limit'] = limit
99
- return self._request_with_params(GET, LONG_SHORT_ACCOUNT_RATIO_CONTRACT, params)
100
-
101
- def get_contract_taker_volume(self, instId='', period=None, unit=None, end=None, begin=None, limit=None):
102
- params = {'instId': instId}
103
- if period is not None:
104
- params['period'] = period
105
- if end is not None:
106
- params['end'] = end
107
- if begin is not None:
108
- params['begin'] = begin
109
- if limit is not None:
110
- params['limit'] = limit
111
- if unit is not None:
112
- params['unit'] = unit
113
- return self._request_with_params(GET, TAKER_VOLUME_CONTRACT, params)
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