remove use_server_time param
This commit is contained in:
parent
7d43159161
commit
0df40584c2
|
|
@ -4,7 +4,7 @@ from .consts import *
|
|||
|
||||
class AccountAPI(OkxClient):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
# Get Positions
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class BlockTradingAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def counterparties(self):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class ConvertAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def get_currencies(self):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class EarningAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def get_offers(self,productId = '',protocolType = '',ccy = ''):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class FDBrokerAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def generate_rebate_details_download_link(self, begin ='', end = ''):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from .consts import *
|
|||
class FundingAPI(OkxClient):
|
||||
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
# Get Deposit Address
|
||||
|
|
@ -39,12 +39,12 @@ class FundingAPI(OkxClient):
|
|||
def get_deposit_history(self, ccy='', state='', after='', before='', limit='', txId='', depId='', fromWdId=''):
|
||||
params = {'ccy': ccy, 'state': state, 'after': after, 'before': before, 'limit': limit, 'txId': txId,
|
||||
'depId': depId, 'fromWdId': fromWdId}
|
||||
return self._request_with_params(GET, DEPOSIT_HISTORIY, params)
|
||||
return self._request_with_params(GET, DEPOSIT_HISTORY, params)
|
||||
|
||||
# Get Withdrawal History
|
||||
def get_withdrawal_history(self, ccy='', wdId='', state='', after='', before='', limit='',txId=''):
|
||||
params = {'ccy': ccy, 'wdId': wdId, 'state': state, 'after': after, 'before': before, 'limit': limit,'txId':txId}
|
||||
return self._request_with_params(GET, WITHDRAWAL_HISTORIY, params)
|
||||
return self._request_with_params(GET, WITHDRAWAL_HISTORY, params)
|
||||
|
||||
# Get Currencies
|
||||
def get_currencies(self, ccy=''):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class GridAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def grid_order_algo(self, instId='', algoOrdType='', maxPx='', minPx='', gridNum='', runType='', tpTriggerPx='',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from .consts import *
|
|||
|
||||
class MarketAPI(OkxClient):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from .okxclient import OkxClient
|
||||
from .consts import *
|
||||
class NDBrokerAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
#GET /api/v5/broker/nd/info
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from .consts import *
|
|||
|
||||
class PublicAPI(OkxClient):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
# Get Instruments
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from .consts import *
|
|||
|
||||
class SpreadTradingAPI(OkxClient):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
# Place Order
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class StatusAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def status(self, state=''):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .consts import *
|
|||
|
||||
|
||||
class SubAccountAPI(OkxClient):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
def get_account_balance(self, subAcct):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from .consts import *
|
|||
|
||||
class TradeAPI(OkxClient):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1',
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ class TradeAPI(OkxClient):
|
|||
def amend_order(self, instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newTpTriggerPx='',
|
||||
newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='',
|
||||
attachAlgoOrds=''):
|
||||
params = {'instId': instId, 'cxlOnFailc': cxlOnFail, 'ordId': ordId, 'clOrdId': clOrdId, 'reqId': reqId,
|
||||
params = {'instId': instId, 'cxlOnFail': cxlOnFail, 'ordId': ordId, 'clOrdId': clOrdId, 'reqId': reqId,
|
||||
'newSz': newSz, 'newPx': newPx, 'newTpTriggerPx': newTpTriggerPx, 'newTpOrdPx': newTpOrdPx,
|
||||
'newSlTriggerPx': newSlTriggerPx, 'newSlOrdPx': newSlOrdPx, 'newTpTriggerPxType': newTpTriggerPxType,
|
||||
'newSlTriggerPxType': newSlTriggerPxType}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from .consts import *
|
|||
|
||||
class TradingDataAPI(OkxClient):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
|
||||
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):
|
||||
OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
Python SDK for the OKX API v5
|
||||
|
||||
"""
|
||||
__version__="0.2.8"
|
||||
__version__="0.2.9"
|
||||
|
|
@ -61,14 +61,14 @@ GET_BALANCES = '/api/v5/asset/balances'
|
|||
FUNDS_TRANSFER = '/api/v5/asset/transfer'
|
||||
TRANSFER_STATE = '/api/v5/asset/transfer-state'
|
||||
WITHDRAWAL_COIN = '/api/v5/asset/withdrawal'
|
||||
DEPOSIT_HISTORIY = '/api/v5/asset/deposit-history'
|
||||
DEPOSIT_HISTORY = '/api/v5/asset/deposit-history'
|
||||
CURRENCY_INFO = '/api/v5/asset/currencies'
|
||||
PURCHASE_REDEMPT = '/api/v5/asset/purchase_redempt'
|
||||
BILLS_INFO = '/api/v5/asset/bills'
|
||||
DEPOSIT_LIGHTNING = '/api/v5/asset/deposit-lightning'
|
||||
WITHDRAWAL_LIGHTNING = '/api/v5/asset/withdrawal-lightning'
|
||||
CANCEL_WITHDRAWAL = '/api/v5/asset/cancel-withdrawal' #need add
|
||||
WITHDRAWAL_HISTORIY = '/api/v5/asset/withdrawal-history'
|
||||
WITHDRAWAL_HISTORY = '/api/v5/asset/withdrawal-history'
|
||||
CONVERT_DUST_ASSETS = '/api/v5/asset/convert-dust-assets' #need add
|
||||
ASSET_VALUATION = '/api/v5/asset/asset-valuation' #need add
|
||||
SET_LENDING_RATE = '/api/v5/asset/set-lending-rate'
|
||||
|
|
|
|||
|
|
@ -1,22 +1,26 @@
|
|||
import json
|
||||
import warnings
|
||||
|
||||
import httpx
|
||||
from httpx import Client
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from . import consts as c, utils, exceptions
|
||||
|
||||
|
||||
class OkxClient(Client):
|
||||
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1',base_api=c.API_URL, debug='True', proxy=None):
|
||||
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1',base_api=c.API_URL, debug='True', proxy=None):
|
||||
super().__init__(base_url=base_api, http2=True, proxy=proxy)
|
||||
self.API_KEY = api_key
|
||||
self.API_SECRET_KEY = api_secret_key
|
||||
self.PASSPHRASE = passphrase
|
||||
self.use_server_time = use_server_time
|
||||
self.use_server_time = False
|
||||
self.flag = flag
|
||||
self.domain = base_api
|
||||
self.debug = debug
|
||||
if use_server_time is not None:
|
||||
warnings.warn("use_server_time parameter is deprecated. Please remove it.", DeprecationWarning)
|
||||
|
||||
def _request(self, method, request_path, params):
|
||||
if method == c.GET:
|
||||
|
|
@ -50,6 +54,7 @@ class OkxClient(Client):
|
|||
request_path = c.API_URL + c.SERVER_TIMESTAMP_URL
|
||||
response = self.get(request_path)
|
||||
if response.status_code == 200:
|
||||
return response.json()['data'][0]['ts']
|
||||
ts = datetime.fromtimestamp(int(response.json()['data'][0]['ts']) / 1000.0, tz=timezone.utc)
|
||||
return ts.isoformat(timespec='milliseconds').replace('+00:00', 'Z')
|
||||
else:
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class AccountTest(unittest.TestCase):
|
|||
# def test_get_pm_limit(self):
|
||||
# print(self.AccountAPI.get_pm_limit("SWAP","BTC-USDT"))
|
||||
# positions-history
|
||||
# def test_get_positions_history(self):
|
||||
# print(self.AccountAPI.get_positions_history())
|
||||
def test_get_positions_history(self):
|
||||
print(self.AccountAPI.get_positions_history())
|
||||
# def test_positions_builder(self):
|
||||
# print("Both real and virtual positions and assets are calculated")
|
||||
# sim_pos = [{'instId': 'BTC-USDT-SWAP', 'pos': '10'}, {'instId': 'BTC-USDT-SWAP', 'pos': '10'}]
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ class FundingTest(unittest.TestCase):
|
|||
print(self.FundingAPI.get_lending_rate_summary('BTC'))
|
||||
"""
|
||||
|
||||
def test_get_non_tradable_assets(self):
|
||||
print(self.FundingAPI.get_non_tradable_assets())
|
||||
# def test_get_lending_summary(self):
|
||||
# print(self.FundingAPI.get_lending_rate_summary('BTC'))
|
||||
# def test_get_lending_rate_history(self):
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ class TradeTest(unittest.TestCase):
|
|||
# print(self.tradeApi.get_oneclick_repay_list('cross'))
|
||||
# def test_oneclick_repay(self):
|
||||
# print(self.tradeApi.oneclick_repay(['BTC'],'USDT'))
|
||||
# """
|
||||
# 485903392536264704
|
||||
# 485936482235191296
|
||||
# def test_oneclick_repay_history(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue