python-okx 0.2.6__py3-none-any.whl → 0.3.3__py3-none-any.whl
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.
- okx/Account.py +140 -43
- okx/BlockTrading.py +4 -4
- okx/Convert.py +4 -4
- okx/CopyTrading.py +7 -5
- okx/Earning.py +4 -4
- okx/FDBroker.py +4 -4
- okx/Funding.py +11 -6
- okx/Grid.py +4 -4
- okx/MarketData.py +4 -4
- okx/NDBroker.py +4 -4
- okx/PublicData.py +4 -4
- okx/SimpleEarnFixed.py +91 -0
- okx/SpreadTrading.py +4 -4
- okx/Status.py +4 -4
- okx/SubAccount.py +4 -4
- okx/Trade.py +50 -40
- okx/TradingData.py +4 -4
- okx/__init__.py +1 -1
- okx/consts.py +24 -3
- okx/{client.py → okxclient.py} +20 -10
- okx/utils.py +6 -4
- {python_okx-0.2.6.dist-info → python_okx-0.3.3.dist-info}/METADATA +2 -1
- python_okx-0.3.3.dist-info/RECORD +31 -0
- {python_okx-0.2.6.dist-info → python_okx-0.3.3.dist-info}/WHEEL +1 -1
- okx/websocket/WsClientFactory.py +0 -49
- okx/websocket/WsClientProtocol.py +0 -46
- okx/websocket/WsConnectManager.py +0 -136
- okx/websocket/WsLoginFactory.py +0 -59
- okx/websocket/WsPprivateAsync.py +0 -77
- okx/websocket/WsPrivate.py +0 -30
- okx/websocket/WsPublic.py +0 -20
- python_okx-0.2.6.dist-info/RECORD +0 -37
- {python_okx-0.2.6.dist-info → python_okx-0.3.3.dist-info}/top_level.txt +0 -0
okx/Account.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
from .client import Client
|
|
2
1
|
from .consts import *
|
|
2
|
+
from .okxclient import OkxClient
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class AccountAPI(
|
|
5
|
+
class AccountAPI(OkxClient):
|
|
6
6
|
|
|
7
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
8
|
-
|
|
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)
|
|
9
10
|
|
|
10
11
|
# Get Positions
|
|
11
12
|
def get_position_risk(self, instType=''):
|
|
@@ -26,18 +27,34 @@ class AccountAPI(Client):
|
|
|
26
27
|
params = {'instType': instType, 'instId': instId}
|
|
27
28
|
return self._request_with_params(GET, POSITION_INFO, params)
|
|
28
29
|
|
|
30
|
+
def position_builder(self, inclRealPosAndEq=False, spotOffsetType=None, greeksType=None, simPos=None,
|
|
31
|
+
simAsset=None):
|
|
32
|
+
params = {}
|
|
33
|
+
if inclRealPosAndEq is not None:
|
|
34
|
+
params['inclRealPosAndEq'] = inclRealPosAndEq
|
|
35
|
+
if spotOffsetType is not None:
|
|
36
|
+
params['spotOffsetType'] = spotOffsetType
|
|
37
|
+
if greeksType is not None:
|
|
38
|
+
params['greksType'] = greeksType
|
|
39
|
+
if simPos is not None:
|
|
40
|
+
params['simPos'] = simPos
|
|
41
|
+
if simAsset is not None:
|
|
42
|
+
params['simAsset'] = simAsset
|
|
43
|
+
return self._request_with_params(POST, POSITION_BUILDER, params)
|
|
44
|
+
|
|
29
45
|
# Get Bills Details (recent 7 days)
|
|
30
46
|
def get_account_bills(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='',
|
|
31
|
-
|
|
47
|
+
limit=''):
|
|
32
48
|
params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type,
|
|
33
49
|
'subType': subType, 'after': after, 'before': before, 'limit': limit}
|
|
34
50
|
return self._request_with_params(GET, BILLS_DETAIL, params)
|
|
35
51
|
|
|
36
52
|
# Get Bills Details (recent 3 months)
|
|
37
|
-
def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='',
|
|
38
|
-
|
|
53
|
+
def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='',
|
|
54
|
+
before='',
|
|
55
|
+
limit='', begin='', end=''):
|
|
39
56
|
params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type,
|
|
40
|
-
'subType': subType, 'after': after, 'before': before, 'limit': limit}
|
|
57
|
+
'subType': subType, 'after': after, 'before': before, 'limit': limit, 'begin': begin, 'end': end}
|
|
41
58
|
return self._request_with_params(GET, BILLS_ARCHIVE, params)
|
|
42
59
|
|
|
43
60
|
# Get Account Configuration
|
|
@@ -66,8 +83,8 @@ class AccountAPI(Client):
|
|
|
66
83
|
return self._request_with_params(GET, MAX_AVAIL_SIZE, params)
|
|
67
84
|
|
|
68
85
|
# Increase / Decrease margin
|
|
69
|
-
def adjustment_margin(self, instId, posSide, type, amt,loanTrans=''):
|
|
70
|
-
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}
|
|
71
88
|
return self._request_with_params(POST, ADJUSTMENT_MARGIN, params)
|
|
72
89
|
|
|
73
90
|
# Get Leverage
|
|
@@ -75,14 +92,19 @@ class AccountAPI(Client):
|
|
|
75
92
|
params = {'instId': instId, 'mgnMode': mgnMode}
|
|
76
93
|
return self._request_with_params(GET, GET_LEVERAGE, params)
|
|
77
94
|
|
|
95
|
+
# Get instruments
|
|
96
|
+
def get_instruments(self, instType='', ugly='', instFamily='', instId=''):
|
|
97
|
+
params = {'instType': instType, 'ugly': ugly, 'instFamily': instFamily, 'instId': instId}
|
|
98
|
+
return self._request_with_params(GET, GET_INSTRUMENTS, params)
|
|
99
|
+
|
|
78
100
|
# Get the maximum loan of isolated MARGIN
|
|
79
|
-
def get_max_loan(self, instId, mgnMode, mgnCcy):
|
|
101
|
+
def get_max_loan(self, instId, mgnMode, mgnCcy=''):
|
|
80
102
|
params = {'instId': instId, 'mgnMode': mgnMode, 'mgnCcy': mgnCcy}
|
|
81
103
|
return self._request_with_params(GET, MAX_LOAN, params)
|
|
82
104
|
|
|
83
105
|
# Get Fee Rates
|
|
84
|
-
def get_fee_rates(self, instType, instId='', uly='', category='',instFamily
|
|
85
|
-
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}
|
|
86
108
|
return self._request_with_params(GET, FEE_RATES, params)
|
|
87
109
|
|
|
88
110
|
# Get interest-accrued
|
|
@@ -101,8 +123,8 @@ class AccountAPI(Client):
|
|
|
101
123
|
return self._request_with_params(POST, SET_GREEKS, params)
|
|
102
124
|
|
|
103
125
|
# Set Isolated Mode
|
|
104
|
-
def set_isolated_mode(self, isoMode,type):
|
|
105
|
-
params = {'isoMode': isoMode, 'type':type}
|
|
126
|
+
def set_isolated_mode(self, isoMode, type):
|
|
127
|
+
params = {'isoMode': isoMode, 'type': type}
|
|
106
128
|
return self._request_with_params(POST, ISOLATED_MODE, params)
|
|
107
129
|
|
|
108
130
|
# Get Maximum Withdrawals
|
|
@@ -117,11 +139,11 @@ class AccountAPI(Client):
|
|
|
117
139
|
|
|
118
140
|
# Get borrow repay history
|
|
119
141
|
def get_borrow_repay_history(self, ccy='', after='', before='', limit=''):
|
|
120
|
-
params = {'ccy': ccy, 'after': after, 'before': before, 'limit':limit}
|
|
142
|
+
params = {'ccy': ccy, 'after': after, 'before': before, 'limit': limit}
|
|
121
143
|
return self._request_with_params(GET, BORROW_REPAY_HISTORY, params)
|
|
122
144
|
|
|
123
145
|
# Get Obtain borrowing rate and limit
|
|
124
|
-
def get_interest_limits(self, type='',ccy=''):
|
|
146
|
+
def get_interest_limits(self, type='', ccy=''):
|
|
125
147
|
params = {'type': type, 'ccy': ccy}
|
|
126
148
|
return self._request_with_params(GET, INTEREST_LIMITS, params)
|
|
127
149
|
|
|
@@ -135,57 +157,58 @@ class AccountAPI(Client):
|
|
|
135
157
|
params = {'ccy': ccy}
|
|
136
158
|
return self._request_with_params(GET, GREEKS, params)
|
|
137
159
|
|
|
138
|
-
#GET /api/v5/account/risk-state
|
|
160
|
+
# GET /api/v5/account/risk-state
|
|
139
161
|
def get_account_position_risk(self):
|
|
140
162
|
return self._request_without_params(GET, ACCOUNT_RISK)
|
|
141
163
|
|
|
142
|
-
#GET /api/v5/account/positions-history
|
|
143
|
-
def get_positions_history(self,instType
|
|
164
|
+
# GET /api/v5/account/positions-history
|
|
165
|
+
def get_positions_history(self, instType='', instId='', mgnMode='', type='', posId='', after='', before='',
|
|
166
|
+
limit=''):
|
|
144
167
|
params = {
|
|
145
|
-
'instType':instType,
|
|
146
|
-
'instId':instId,
|
|
147
|
-
'mgnMode':mgnMode,
|
|
148
|
-
'type':type,
|
|
149
|
-
'posId':posId,
|
|
150
|
-
'after':after,
|
|
151
|
-
'before':before,
|
|
152
|
-
'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
|
|
153
176
|
}
|
|
154
|
-
return self._request_with_params(GET,POSITIONS_HISTORY,params)
|
|
177
|
+
return self._request_with_params(GET, POSITIONS_HISTORY, params)
|
|
155
178
|
|
|
156
|
-
#GET /api/v5/account/position-tiers
|
|
157
|
-
def get_account_position_tiers(self,instType
|
|
179
|
+
# GET /api/v5/account/position-tiers
|
|
180
|
+
def get_account_position_tiers(self, instType='', uly='', instFamily=''):
|
|
158
181
|
params = {
|
|
159
|
-
'instType':instType,
|
|
160
|
-
'uly':uly,
|
|
161
|
-
'instFamily':instFamily
|
|
182
|
+
'instType': instType,
|
|
183
|
+
'uly': uly,
|
|
184
|
+
'instFamily': instFamily
|
|
162
185
|
}
|
|
163
|
-
return self._request_with_params(GET,GET_PM_LIMIT,params)
|
|
186
|
+
return self._request_with_params(GET, GET_PM_LIMIT, params)
|
|
164
187
|
|
|
165
|
-
|
|
188
|
+
# - Get VIP interest accrued data
|
|
166
189
|
def get_VIP_interest_accrued_data(self, ccy='', ordId='', after='', before='', limit=''):
|
|
167
190
|
params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit}
|
|
168
191
|
return self._request_with_params(GET, GET_VIP_INTEREST_ACCRUED_DATA, params)
|
|
169
192
|
|
|
170
|
-
|
|
193
|
+
# - Get VIP interest deducted data
|
|
171
194
|
def get_VIP_interest_deducted_data(self, ccy='', ordId='', after='', before='', limit=''):
|
|
172
195
|
params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit}
|
|
173
196
|
return self._request_with_params(GET, GET_VIP_INTEREST_DEDUCTED_DATA, params)
|
|
174
197
|
|
|
175
198
|
# - Get VIP loan order list
|
|
176
|
-
def get_VIP_loan_order_list(self, ordId='',state='', ccy='', after='', before='', limit=''):
|
|
177
|
-
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}
|
|
178
201
|
return self._request_with_params(GET, GET_VIP_LOAN_ORDER_LIST, params)
|
|
179
202
|
|
|
180
|
-
|
|
203
|
+
# - Get VIP loan order detail
|
|
181
204
|
def get_VIP_loan_order_detail(self, ccy='', ordId='', after='', before='', limit=''):
|
|
182
205
|
params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit}
|
|
183
206
|
return self._request_with_params(GET, GET_VIP_LOAN_ORDER_DETAIL, params)
|
|
184
207
|
|
|
185
|
-
|
|
208
|
+
# - Set risk offset type
|
|
186
209
|
def set_risk_offset_typel(self, type=''):
|
|
187
210
|
params = {'type': type}
|
|
188
|
-
return self._request_with_params(POST, SET_RISK_OFFSET_TYPE,params)
|
|
211
|
+
return self._request_with_params(POST, SET_RISK_OFFSET_TYPE, params)
|
|
189
212
|
|
|
190
213
|
# - Set auto loan
|
|
191
214
|
def set_auto_loan(self, autoLoan=''):
|
|
@@ -194,6 +217,80 @@ class AccountAPI(Client):
|
|
|
194
217
|
}
|
|
195
218
|
return self._request_with_params(POST, SET_AUTO_LOAN, params)
|
|
196
219
|
|
|
197
|
-
|
|
220
|
+
# - Activate option
|
|
198
221
|
def activate_option(self):
|
|
199
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)
|
okx/BlockTrading.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class BlockTradingAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class BlockTradingAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def counterparties(self):
|
|
10
10
|
params = {}
|
okx/Convert.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class ConvertAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class ConvertAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def get_currencies(self):
|
|
10
10
|
params = {}
|
okx/CopyTrading.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class CopyTradingAPI(
|
|
5
|
+
class CopyTradingAPI(OkxClient):
|
|
6
6
|
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1',
|
|
7
|
-
domain='https://www.okx.com', debug=True):
|
|
8
|
-
|
|
7
|
+
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,
|
|
9
|
+
proxy=proxy)
|
|
9
10
|
|
|
10
11
|
# Get existing leading positions
|
|
11
12
|
def get_existing_leading_positions(self, instId=''):
|
|
@@ -25,7 +26,8 @@ class CopyTradingAPI(Client):
|
|
|
25
26
|
return self._request_with_params(GET, GET_LEADING_POSITIONS_HISTORY, params)
|
|
26
27
|
|
|
27
28
|
# Place leading stop order
|
|
28
|
-
def place_leading_stop_order(self, subPosId='', tpTriggerPx='', slTriggerPx='', tpTriggerPxType='',
|
|
29
|
+
def place_leading_stop_order(self, subPosId='', tpTriggerPx='', slTriggerPx='', tpTriggerPxType='',
|
|
30
|
+
slTriggerPxType=''):
|
|
29
31
|
params = {
|
|
30
32
|
'subPosId': subPosId,
|
|
31
33
|
'tpTriggerPx': tpTriggerPx,
|
okx/Earning.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class EarningAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class EarningAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def get_offers(self,productId = '',protocolType = '',ccy = ''):
|
|
10
10
|
params = {
|
okx/FDBroker.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class FDBrokerAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class FDBrokerAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def generate_rebate_details_download_link(self, begin ='', end = ''):
|
|
10
10
|
params = {'begin': begin, 'end': end}
|
okx/Funding.py
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class FundingAPI(
|
|
5
|
+
class FundingAPI(OkxClient):
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
9
|
-
|
|
8
|
+
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):
|
|
9
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
10
|
+
|
|
11
|
+
# Get Non Tradable Assets
|
|
12
|
+
def get_non_tradable_assets(self, ccy: str = ''):
|
|
13
|
+
params = {'ccy': ccy}
|
|
14
|
+
return self._request_with_params(GET, NON_TRADABLE_ASSETS, params)
|
|
10
15
|
|
|
11
16
|
# Get Deposit Address
|
|
12
17
|
def get_deposit_address(self, ccy):
|
|
@@ -39,12 +44,12 @@ class FundingAPI(Client):
|
|
|
39
44
|
def get_deposit_history(self, ccy='', state='', after='', before='', limit='', txId='', depId='', fromWdId=''):
|
|
40
45
|
params = {'ccy': ccy, 'state': state, 'after': after, 'before': before, 'limit': limit, 'txId': txId,
|
|
41
46
|
'depId': depId, 'fromWdId': fromWdId}
|
|
42
|
-
return self._request_with_params(GET,
|
|
47
|
+
return self._request_with_params(GET, DEPOSIT_HISTORY, params)
|
|
43
48
|
|
|
44
49
|
# Get Withdrawal History
|
|
45
50
|
def get_withdrawal_history(self, ccy='', wdId='', state='', after='', before='', limit='',txId=''):
|
|
46
51
|
params = {'ccy': ccy, 'wdId': wdId, 'state': state, 'after': after, 'before': before, 'limit': limit,'txId':txId}
|
|
47
|
-
return self._request_with_params(GET,
|
|
52
|
+
return self._request_with_params(GET, WITHDRAWAL_HISTORY, params)
|
|
48
53
|
|
|
49
54
|
# Get Currencies
|
|
50
55
|
def get_currencies(self, ccy=''):
|
okx/Grid.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class GridAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class GridAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def grid_order_algo(self, instId='', algoOrdType='', maxPx='', minPx='', gridNum='', runType='', tpTriggerPx='',
|
|
10
10
|
slTriggerPx='', tag='', quoteSz='', baseSz='', sz='', direction='', lever='', basePos=''):
|
okx/MarketData.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class MarketAPI(
|
|
5
|
+
class MarketAPI(OkxClient):
|
|
6
6
|
|
|
7
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
8
|
-
|
|
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
9
|
|
|
10
10
|
|
|
11
11
|
# Get Tickers
|
okx/NDBroker.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
|
-
class NDBrokerAPI(
|
|
4
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
5
|
-
|
|
3
|
+
class NDBrokerAPI(OkxClient):
|
|
4
|
+
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):
|
|
5
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
6
6
|
|
|
7
7
|
#GET /api/v5/broker/nd/info
|
|
8
8
|
def get_broker_info(self):
|
okx/PublicData.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class PublicAPI(
|
|
5
|
+
class PublicAPI(OkxClient):
|
|
6
6
|
|
|
7
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
8
|
-
|
|
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
9
|
|
|
10
10
|
# Get Instruments
|
|
11
11
|
def get_instruments(self, instType, uly='', instId='',instFamily = ''):
|
okx/SimpleEarnFixed.py
ADDED
|
@@ -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
|
+
|
okx/SpreadTrading.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class SpreadTradingAPI(
|
|
5
|
+
class SpreadTradingAPI(OkxClient):
|
|
6
6
|
|
|
7
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
8
|
-
|
|
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
9
|
|
|
10
10
|
# Place Order
|
|
11
11
|
def place_order(self, sprdId='', clOrdId='', tag='', side='', ordType='', sz='', px=''):
|
okx/Status.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class StatusAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class StatusAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def status(self, state=''):
|
|
10
10
|
params = {'state': state}
|
okx/SubAccount.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .okxclient import OkxClient
|
|
2
2
|
from .consts import *
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class SubAccountAPI(
|
|
6
|
-
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=
|
|
7
|
-
|
|
5
|
+
class SubAccountAPI(OkxClient):
|
|
6
|
+
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
|
+
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
|
8
8
|
|
|
9
9
|
def get_account_balance(self, subAcct):
|
|
10
10
|
params = {"subAcct": subAcct}
|