Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyongguiokcoin committed Jul 19, 2021
1 parent f4a34a6 commit e5b023e
Show file tree
Hide file tree
Showing 368 changed files with 106,896 additions and 40 deletions.
3 changes: 3 additions & 0 deletions okex-python-sdk-api/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions okex-python-sdk-api/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions okex-python-sdk-api/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions okex-python-sdk-api/.idea/okex-python-sdk-api.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions okex-python-sdk-api/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 53 additions & 22 deletions okex-python-sdk-api/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import okex.option_api as option
import okex.system_api as system
import okex.information_api as information
import okex.oracle_api as oracle
import json
import datetime

Expand Down Expand Up @@ -34,7 +35,9 @@ def get_timestamp():
# 单一币种账户信息
# result = accountAPI.get_currency('')
# 资金划转
# result = accountAPI.coin_transfer(currency='', amount='', account_from='', account_to='', type='', sub_account='', instrument_id='', to_instrument_id='')
# result = accountAPI.coin_transfer(currency='', amount='', account_from='', account_to='', type='',to_instrument_id='')
# 资金划转状态查询
# result = accountAPI.get_state(transfer_id='')
# 提币
# result = accountAPI.coin_withdraw(currency='', amount='', destination='', to_address='', trade_pwd='', fee='')
# 账单流水查询
Expand All @@ -57,14 +60,18 @@ def get_timestamp():
# result = accountAPI.get_currencies()
# 提币手续费
# result = accountAPI.get_coin_fee('')
# 获取用户ID
# result = accountAPI.get_uid('')
# 余币宝申购赎回
# result = accountAPI.purchase_redempt(currency='',amount='',side='')

# spot api test
# 币币API
spotAPI = spot.SpotAPI(api_key, secret_key, passphrase, False)
# 币币账户信息
# result = spotAPI.get_account_info()
# 单一币种账户信息
# result = spotAPI.get_coin_account_info('')
# result = spotAPI.get_coin_account_info('BTC')
# 账单流水查询
# result = spotAPI.get_ledger_record(currency='', after='', before='', limit='', type='')
# 下单
Expand All @@ -81,6 +88,13 @@ def get_timestamp():
# {'instrument_id': '', 'order_ids': ['', '']},
# {'instrument_id': '', 'order_ids': ['', '']}
# ])
#修改订单
# result = spotAPI.amend_order(instrument_id='', cancel_on_fail='')
#批量修改订单
# result = spotAPI.amend_batch_orders([
# {'instrument_id': '', 'cancel_on_fail': '','order_id':'','new_size':''},
# {'instrument_id': '', 'cancel_on_fail': '','order_id':'','new_size':''}
# ])
# 获取订单列表
# result = spotAPI.get_orders_list(instrument_id='', state='', after='', before='', limit='')
# 获取所有未成交订单
Expand All @@ -107,10 +121,10 @@ def get_timestamp():
# result = spotAPI.get_specific_ticker('')
# 公共-获取成交数据
# result = spotAPI.get_deal(instrument_id='', limit='')
# 公共-获取K线数据
# 公共-获取K线数据q
# result = spotAPI.get_kline(instrument_id='', start='', end='', granularity='')
# 公共-获取历史K线数据
# result = spotAPI.get_history_kline(instrument_id='', start='', end='', granularity='')
# result = spotAPI.get_history_kline(instrument_id='')

# level api test
# 币币杠杆API
Expand All @@ -120,7 +134,7 @@ def get_timestamp():
# 单一币对账户信息
# result = levelAPI.get_specific_account('')
# 账单流水查询
# result = levelAPI.get_ledger_record(instrument_id='', after='', before='', limit='', type='')
# result = levelAPI.get_ledger_record(instrument_id='',type='')
# 杠杆配置信息
# result = levelAPI.get_config_info()
# 某个杠杆配置信息
Expand All @@ -134,12 +148,19 @@ def get_timestamp():
# 还币
# result = levelAPI.repayment_coin(instrument_id='', currency='', amount='', borrow_id='', client_oid='')
# 下单
# result = levelAPI.take_order(instrument_id='', side='', margin_trading='', client_oid='', type='', order_type='0', price='', size='', notional='')
# result = levelAPI.take_order(instrument_id='', side='', margin_trading='2', type='', order_type='', price='', size='')
# 批量下单
# result = levelAPI.take_orders([
# {'instrument_id': '', 'side': '', 'price': '', 'size': '', 'margin_trading': '2'},
# {'instrument_id': '', 'side': '', 'price': '', 'size': '', 'margin_trading': '2'}
# ])
#改单
# result=levelAPI.amend_order(instrument_id='',cancel_on_fail='',order_id='',client_oid='',request_id='',new_size='',new_price='')
#批量改
# result = levelAPI.amend_batch_orders(instrument_id='DOGE-USDT', amend_data=[
# {'cancel_on_fail': '', 'order_id': '', 'new_size': '',},
# {'cancel_on_fail': '', 'order_id': '', 'new_size': '',}
# ])
# 撤销指定订单
# result = levelAPI.revoke_order(instrument_id='', order_id='', client_oid='')
# 批量撤销订单
Expand All @@ -159,6 +180,8 @@ def get_timestamp():
# result = levelAPI.get_leverage('')
# 设置杠杆倍数
# result = levelAPI.set_leverage(instrument_id='', leverage='')
# 币币杠杆行情
# result = levelAPI.set_leverage(instrument_id='', leverage='')
# 公共-获取标记价格
# result = levelAPI.get_mark_price('')

Expand All @@ -183,18 +206,18 @@ def get_timestamp():
# 账单流水查询
# result = futureAPI.get_ledger(underlying='', after='', before='', limit='', type='')
# 下单
# result = futureAPI.take_order(instrument_id='', type='', price='', size='', client_oid='', order_type='0', match_price='0')
# result = futureAPI.take_order(instrument_id='', type='', price='', size='',order_type='')
# 批量下单
# result = futureAPI.take_orders('', [
# {'client_oid': '', 'type': '', 'price': '', 'size': '', 'match_price': '0'},
# {'client_oid': '', 'type': '', 'price': '', 'size': '', 'match_price': '0'}
# ])
# 撤销指定订单
# result = futureAPI.revoke_order(instrument_id='', order_id='', client_oid='')
# result = futureAPI.revoke_order(instrument_id='', order_id='')
# 批量撤销订单
# result = futureAPI.revoke_orders(instrument_id='', order_ids=['', ''])
# 修改订单
# result = futureAPI.amend_order(instrument_id='', cancel_on_fail='', order_id='', client_oid='', request_id='', new_size='', new_price='')
# result = futureAPI.amend_order(instrument_id='', cancel_on_fail='',order_id='',new_size='')
# 批量修改订单
# result = futureAPI.amend_batch_orders(instrument_id='', amend_data=[
# {'cancel_on_fail': '', 'order_id': '', 'client_oid': '', 'request_id': '', 'new_size': '', 'new_price': ''},
Expand All @@ -203,11 +226,11 @@ def get_timestamp():
# 获取订单列表
# result = futureAPI.get_order_list(instrument_id='', state='', after='', before='', limit='')
# 获取订单信息
# result = futureAPI.get_order_info(instrument_id='', order_id='', client_oid='')
# result = futureAPI.get_order_info(instrument_id='', order_id='')
# 获取成交明细
# result = futureAPI.get_fills(instrument_id='', order_id='', after='', before='', limit='')
# 设置合约币种账户模式
# result = futureAPI.set_margin_mode(underlying='', margin_mode='')
# result = futureAPI.set_margin_mode(margin_mode='crossed',underlying='DOT-USDT',)
# 市价全平
# result = futureAPI.close_position(instrument_id='', direction='')
# 撤销所有平仓挂单
Expand Down Expand Up @@ -237,7 +260,7 @@ def get_timestamp():
# 公共-获取成交数据
# result = futureAPI.get_trades(instrument_id='', after='', before='', limit='')
# 公共-获取K线数据
# result = futureAPI.get_kline(instrument_id='', start='', end='', granularity='')
# result = futureAPI.get_kline(instrument_id='', start='', granularity='')
# 公共-获取指数信息
# result = futureAPI.get_index('')
# 公共-获取法币汇率
Expand Down Expand Up @@ -267,15 +290,15 @@ def get_timestamp():
# 所有币种合约账户信息
# result = swapAPI.get_accounts()
# 单个币种合约账户信息
# result = swapAPI.get_coin_account('')
# result = swapAPI.get_coin_account('LEND-USDT-SWAP')
# 获取某个合约的用户配置
# result = swapAPI.get_settings('')
# 设定某个合约的杠杆
# result = swapAPI.set_leverage(instrument_id='', leverage='', side='')
# result = swapAPI.set_leverage(instrument_id='DOT-USDT-SWAP', leverage='2', side='1')
# 账单流水查询
# result = swapAPI.get_ledger(instrument_id='', after='', before='', limit='', type='')
# 下单
# result = swapAPI.take_order(instrument_id='', type='', price='', size='', client_oid='', order_type='0', match_price='0')
# result = swapAPI.take_order(instrument_id='', type='', price='', size='',order_type='', match_price='')
# 批量下单
# result = swapAPI.take_orders('', [
# {'client_oid': '', 'type': '', 'price': '', 'size': ''},
Expand All @@ -293,21 +316,21 @@ def get_timestamp():
# {'cancel_on_fail': '', 'order_id': '', 'client_oid': '', 'request_id': '', 'new_size': '', 'new_price': ''}
# ])
# 获取所有订单列表
# result = swapAPI.get_order_list(instrument_id='', state='', after='', before='', limit='')
# result = swapAPI.get_order_list(instrument_id='TRX-USDT', state='1', after='', before='', limit='')
# 获取订单信息
# result = swapAPI.get_order_info(instrument_id='', order_id='', client_oid='')
# 获取成交明细
# result = swapAPI.get_fills(instrument_id='', order_id='', after='', before='', limit='')
# 获取合约挂单冻结数量
# result = swapAPI.get_holds_amount('')
# 委托策略下单
# result = swapAPI.take_order_algo(instrument_id='', type='', order_type='', size='', trigger_price='', algo_price='', algo_type='')
# result = swapAPI.take_order_algo(instrument_id='', type='', order_type='', size='',tp_trigger_type='',tp_trigger_price='',sl_trigger_price='',sl_trigger_type='')
# 委托策略撤单
# result = swapAPI.cancel_algos(instrument_id='', algo_ids=[''], order_type='')
# 获取委托单列表
# result = swapAPI.get_order_algos(instrument_id='', order_type='', status='', algo_id='', before='', after='', limit='')
# 获取账户手续费费率
# result = swapAPI.get_trade_fee()
# result = swapAPI.get_trade_fee(category='1')
# 市价全平
# result = swapAPI.close_position(instrument_id='', direction='')
# 撤销所有平仓挂单
Expand All @@ -323,7 +346,7 @@ def get_timestamp():
# 公共-获取成交数据
# result = swapAPI.get_trades(instrument_id='', after='', before='', limit='')
# 公共-获取K线数据
# result = swapAPI.get_kline(instrument_id='', start='', end='', granularity='')
# result = swapAPI.get_kline(instrument_id='')
# 公共-获取指数信息
# result = swapAPI.get_index('')
# 公共-获取法币汇率
Expand All @@ -335,7 +358,7 @@ def get_timestamp():
# 公共-获取强平单
# result = swapAPI.get_liquidation(instrument_id='', status='', froms='', to='', limit='')
# 公共-获取合约资金费率
# result = swapAPI.get_funding_time('')
# result = swapAPI.get_funding_time('BTC-USD-SWAP')
# 公共-获取合约标记价格
# result = swapAPI.get_mark_price('')
# 公共-获取合约历史资金费率
Expand All @@ -359,6 +382,8 @@ def get_timestamp():
# ])
# 撤单
# result = optionAPI.revoke_order(underlying='', order_id='', client_oid='')
# 撤销全部订单
# result = optionAPI.cancel_all(underlying='')
# 批量撤单
# result = optionAPI.revoke_orders(underlying='', order_ids=['', ''], client_oids=['', ''])
# 修改订单
Expand All @@ -378,6 +403,8 @@ def get_timestamp():
# result = optionAPI.get_ledger(underlying='', after='', before='', limit='')
# 获取手续费费率
# result = optionAPI.get_trade_fee()
# 设置希腊字母
# result = optionAPI.set_greeks(greeks_type='')
# 公共-获取标的指数
# result = optionAPI.get_index()
# 公共-获取期权合约
Expand All @@ -401,7 +428,7 @@ def get_timestamp():
# 合约交易数据API
informationAPI = information.InformationAPI(api_key, secret_key, passphrase, False)
# 公共-多空持仓人数比
# result = informationAPI.get_long_short_ratio(currency='', start='', end='', granularity='')
# result = informationAPI.get_long_short_ratio(currency='',start='',end='',granularity='')
# 公共-持仓总量及交易量
# result = informationAPI.get_volume(currency='', start='', end='', granularity='')
# 公共-主动买入卖出情况
Expand All @@ -421,7 +448,11 @@ def get_timestamp():
# 获取系统升级状态
system = system.SystemAPI(api_key, secret_key, passphrase, False)
# 公共-获取系统升级状态
# result = system.get_system_status('')
result = system.get_system_status('')

#oracle
#公共-Oracle
oracle = oracle.OracleAPI(api_key, secret_key, passphrase, False)
# result = oracle.oracle()

print(time + json.dumps(result))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 18 additions & 2 deletions okex-python-sdk-api/okex/account_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_currency(self, currency):
# coin withdraw
def coin_withdraw(self, currency, amount, destination, to_address, trade_pwd, fee):
params = {'currency': currency, 'amount': amount, 'destination': destination, 'to_address': to_address, 'trade_pwd': trade_pwd, 'fee': fee}
return self._request_with_params(POST, COIN_WITHDRAW, params)
return self._request_with_params('POST', COIN_WITHDRAW, params)

# query the fee of coin withdraw
def get_coin_fee(self, currency=''):
Expand All @@ -31,6 +31,16 @@ def get_coin_fee(self, currency=''):
params['currency'] = currency
return self._request_with_params(GET, COIN_FEE, params)

# get uid
def get_uid(self, uid=''):
params = {'uid':uid}
return self._request_with_params(GET, GET_UID, params)

# purchase redempt
def purchase_redempt(self,currency,amount,side):
params = {'currency': currency, 'amount': amount, 'side': side}
return self._request_with_params('POST', PURCHASE_REDEMPT,params)

# query all recently coin withdraw record
def get_coins_withdraw_record(self):
return self._request_without_params(GET, COINS_WITHDRAW_RECORD)
Expand Down Expand Up @@ -87,7 +97,7 @@ def get_top_up_record(self, currency, after='', before='', limit=''):
return self._request_without_params(GET, COIN_TOP_UP_RECORD + str(currency))

# coin transfer
def coin_transfer(self, currency, amount, account_from, account_to, type='', sub_account='', instrument_id='', to_instrument_id=''):
def coin_transfer(self, currency, amount,account_from, account_to, type='', sub_account='', instrument_id='', to_instrument_id=''):
params = {'currency': currency, 'amount': amount, 'from': account_from, 'to': account_to}
if type:
params['type'] = type
Expand All @@ -98,3 +108,9 @@ def coin_transfer(self, currency, amount, account_from, account_to, type='', sub
if to_instrument_id:
params['to_instrument_id'] = to_instrument_id
return self._request_with_params('POST', COIN_TRANSFER, params)

# state
def get_state(self, transfer_id):
params = {'transfer_id':transfer_id}
return self._request_with_params('GET', GET_STATE, params)

2 changes: 1 addition & 1 deletion okex-python-sdk-api/okex/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _request(self, method, request_path, params, cursor=False):
self.first = False

print("url:", url)
# print("headers:", header)
print("headers:", header)
print("body:", body)

# send request
Expand Down
Loading

0 comments on commit e5b023e

Please sign in to comment.