def market_future_kline(self, symbol, time_type, contract_type, size=0, since=0): """ Get data for k line for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param time_type: String, in OKRestBase.TimeTypes :param contract_type: String, choices are "this_week", "next_week", "quarter" :param size: Integer :param since: Long, get data after this time stamp :return: GET response """ self.rest_interface.add_param_to_query('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_query('type', time_type, OKRestBase.TimeTypes) self.rest_interface.add_param_to_query('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_query('size', size, tuple(range(1, sys.maxsize))) self.rest_interface.add_param_to_query( 'since', since, tuple(range(1, int(time.time())))) return self.rest_interface.get( OKEX_RESOURCE_TEMPLATE.format('future_kline'))
def deals_future_order_info(self, symbol, contract_type, status, order_id, current_page='0', page_length='0'): """ Get information of order for users for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param status: String, '1' for for uncompleted orders, ''2' for completed orders :param order_id: Long, -1 for uncompleted orders otherwise a certain order ID :param current_page: Integer :param page_length: Integer, items in each page, no more than 50 :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_body('status', status, ('1', '2')) self.rest_interface.add_param_to_body('order_id', order_id, ()) self.rest_interface.add_param_to_body( 'current_page', current_page, tuple(map(str, range(1, sys.maxsize)))) self.rest_interface.add_param_to_body('page_length', page_length, tuple(map(str, range(1, 51)))) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_order_info'), self.__api_key, self.__secret_key)
def market_exchange_rate(self): """ Get exchange rate of USD to RMB :return: GET response """ return self.rest_interface.get( OKEX_RESOURCE_TEMPLATE.format('exchange_rate'))
def deals_future_withdraw(self, symbol, chargefee, trade_pwd, withdraw_address, withdraw_amount, target): """ Withdraw currencies for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param chargefee: Double, Internet >=0, BTC in [0.0001,0.01], LTC in [0.001,0.2], Internal: 0 :param trade_pwd: String :param withdraw_address: String, Authorized address, E-mail or telephone number :param withdraw_amount: Double, BTC>=0.01 LTC>=0.1 :param target: String, Domestic:"okcn", International:"okcom", OKEX:"okex", External:"address" :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('chargefee', chargefee, tuple()) self.rest_interface.add_param_to_body('trade_pwd', trade_pwd, tuple()) self.rest_interface.add_param_to_body('withdraw_address', withdraw_address, tuple()) self.rest_interface.add_param_to_body('withdraw_amount', withdraw_amount, tuple()) self.rest_interface.add_param_to_body( 'target', target, ('okcn', 'okcom', 'okex', 'address')) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('withdraw'), self.__api_key, self.__secret_key)
def deals_future_trade(self, symbol, contract_type, price, amount, trade_type, match_price='', lever_rate=''): """ Place order for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param price: String :param amount: String :param trade_type: String, choices are '1', '2', '3', '4' :param match_price: String, choices are '0', '1', when it's '1', price makes no sense :param lever_rate: String, choices are "10", "20", by default is "10" :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_body('price', price, ()) self.rest_interface.add_param_to_body('amount', amount, ()) self.rest_interface.add_param_to_body('type', trade_type, ('1', '2', '3', '4')) self.rest_interface.add_param_to_body('match_price', match_price, ('0', '1')) self.rest_interface.add_param_to_body('lever_rate', lever_rate, ('10', '20')) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_trade'), self.__api_key, self.__secret_key)
def deals_future_explosive(self, symbol, contract_type, status, current_page='0', page_number='0', page_length='0'): """ Get explosive for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param status: String, '0' for completed in recent seven days, '1' for uncompleted in recent seven days :param current_page: Integer :param page_number: Integer :param page_length: Integer, items in each page, no more than 50 :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_body('status', status, ('0', '1')) self.rest_interface.add_param_to_body( 'current_page', current_page, tuple(map(str, range(1, sys.maxsize)))) self.rest_interface.add_param_to_body( 'page_number', page_number, tuple(map(str, range(1, sys.maxsize)))) self.rest_interface.add_param_to_body('page_length', page_length, tuple(map(str, range(1, 51)))) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_explosive'), self.__api_key, self.__secret_key)
def deals_future_userinfo_4fix(self): """ Get 4fix userinfo for future :return: POST response """ return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_userinfo_4fix'), self.__api_key, self.__secret_key)
def market_future_index(self, symbol): """ Get information of trades' index for future :param symbol: String, choices are "btc_usd", "ltc_usd" :return: GET response """ self.rest_interface.add_param_to_query('symbol', symbol, OKRestBase.FutureSymbols) return self.rest_interface.get( OKEX_RESOURCE_TEMPLATE.format('future_index'))
def market_future_estimated_price(self, symbol): """ Get estimated price for future :param symbol: String, choices are "btc_usd", "ltc_usd" :return: GET response """ self.rest_interface.add_param_to_query('symbol', symbol, OKRestBase.FutureSymbols) return self.rest_interface.get( OKEX_RESOURCE_TEMPLATE.format('future_estimated_price'))
def market_future_trades(self, symbol, contract_type): """ Get information of trades' records for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :return: GET response """ self.rest_interface.add_param_to_query('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_query('contract_type', contract_type, OKRestBase.FutureContractTypes) return self.rest_interface.get( OKEX_RESOURCE_TEMPLATE.format('future_trades'))
def deals_future_withdraw_info(self, symbol, withdraw_id): """ Get information of withdraw for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param withdraw_id: String :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('withdraw_id', withdraw_id, tuple()) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('withdraw_info'), self.__api_key, self.__secret_key)
def deals_future_position(self, symbol, contract_type): """ Get information of users for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_position'), self.__api_key, self.__secret_key)
def deals_future_trades_history(self, symbol, date, since): """ Get information of history trades for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param date: String, like "yyyy-MM-dd" :param since: Long, get items of data from this trade id :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('date', date, ()) self.rest_interface.add_param_to_body('since', since, ()) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_trades_history'), self.__api_key, self.__secret_key)
def deals_future_orders_info(self, symbol, contract_type, order_id): """ Get information of multiple orders for users for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param order_id: String, IDs for orders are separated by ',' and no more than 50 orders at one time :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_body('order_id', order_id, ()) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_orders_info'), self.__api_key, self.__secret_key)
def deals_future_cancel(self, symbol, contract_type, order_id): """ Cancel order for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param order_id: String, multiple order IDs is separated by ',' but no more than 3 :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_body('order_id', order_id, ()) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_cancel'), self.__api_key, self.__secret_key)
def market_future_depth(self, symbol, contract_type, size, merge=0): """ Get depth for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param size: Integer, in range(1, 201) :param merge: Integer :return: GET response """ self.rest_interface.add_param_to_query('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_query('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_query('size', size, tuple(range(1, 201))) self.rest_interface.add_param_to_query('merge', merge, (1, )) return self.rest_interface.get( OKEX_RESOURCE_TEMPLATE.format('future_depth'))
def deals_future_batch_trade(self, symbol, contract_type, orders_data, lever_rate=''): """ Place multiple orders for future :param symbol: String, choices are "btc_usd", "ltc_usd" :param contract_type: String, choices are "this_week", "next_week", "quarter" :param orders_data: String, "[{price:3,amount:5,type:'sell'},{price:3,amount:3,type:'buy'}]", no more than 5 :param lever_rate: String, choices are "10", "20", by default is "10" :return: POST response """ self.rest_interface.add_param_to_body('symbol', symbol, OKRestBase.FutureSymbols) self.rest_interface.add_param_to_body('contract_type', contract_type, OKRestBase.FutureContractTypes) self.rest_interface.add_param_to_body('orders_data', orders_data, ()) self.rest_interface.add_param_to_body('lever_rate', lever_rate, ('10', '20')) return self.rest_interface.post( OKEX_RESOURCE_TEMPLATE.format('future_batch_trade'), self.__api_key, self.__secret_key)