Beispiel #1
0
 def deals_spot_withdraw(self, symbol, chargefee, trade_pwd,
                         withdraw_address, withdraw_amount, target):
     """
     Withdraw currencies for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param chargefee: Double, Internet >=0, BTC in [0.0001,0.01], LTC in [0.001,0.2], ETH in [0.01], 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 ETH>=0.01
     :param target: String, Domestic:"okcn", International:"okcom", OKEX:"okex", External:"address"
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     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(
         OKCOIN_RESOURCE_TEMPLATE.format('withdraw'), self.__api_key,
         self.__secret_key)
Beispiel #2
0
 def deals_spot_userinfo(self):
     """
     Get information of users for spot
     :return: POST response
     """
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('userinfo'), self.__api_key,
         self.__secret_key)
Beispiel #3
0
 def deals_spot_borrow_order_info(self, borrow_id):
     """
     Get information of borrow order for spot
     :param borrow_id: String
     :return: POST response
     """
     self.rest_interface.add_param_to_body('borrow_id', borrow_id, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('borrow_order_info'),
         self.__api_key, self.__secret_key)
Beispiel #4
0
 def market_spot_ticker(self, symbol):
     """
     Get information for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :return: GET response
     """
     self.rest_interface.add_param_to_query('symbol', symbol,
                                            OKRestBase.SpotSymbols)
     return self.rest_interface.get(
         OKCOIN_RESOURCE_TEMPLATE.format('ticker'))
Beispiel #5
0
 def deals_spot_repayment(self, borrow_id):
     """
     Pay off for spot
     :param borrow_id: String
     :return: POST response
     """
     self.rest_interface.add_param_to_body('borrow_id', borrow_id, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('repayment'), self.__api_key,
         self.__secret_key)
Beispiel #6
0
 def deals_spot_borrows_info(self, symbol):
     """
     Get information of users' borrows for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('borrows_info'), self.__api_key,
         self.__secret_key)
Beispiel #7
0
 def deals_spot_lend_depth(self, symbol):
     """
     Get top ten lend depth for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('lend_depth'), self.__api_key,
         self.__secret_key)
Beispiel #8
0
 def deals_spot_order_info(self, symbol, order_id):
     """
     Get information of order for users for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param order_id: Long, -1 for uncompleted orders otherwise a certain order ID
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('order_id', order_id, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('order_info'), self.__api_key,
         self.__secret_key)
Beispiel #9
0
 def deals_spot_cancel_borrow(self, symbol, borrow_id):
     """
     Cancel borrow for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param borrow_id: Long
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('borrow_id', borrow_id, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('cancel_borrow'), self.__api_key,
         self.__secret_key)
Beispiel #10
0
 def market_spot_trades(self, symbol, since=0):
     """
     Get information of trades' records for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param since: Long, get data after this trade ID except this ID and no more than 600
     :return: GET response
     """
     self.rest_interface.add_param_to_query('symbol', symbol,
                                            OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_query('since', since,
                                            tuple(range(1, sys.maxsize)))
     return self.rest_interface.get(
         OKCOIN_RESOURCE_TEMPLATE.format('trades'))
Beispiel #11
0
 def deals_spot_cancel_order(self, symbol, order_id):
     """
     Cancel order for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :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.SpotSymbols)
     self.rest_interface.add_param_to_body('order_id', order_id, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('cancel_order'), self.__api_key,
         self.__secret_key)
Beispiel #12
0
 def deals_spot_trade_history(self, symbol, since):
     """
     Get information of history trades for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param since: Long, get 600 items of data from this trade id
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('since', since, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('trade_history'), self.__api_key,
         self.__secret_key)
Beispiel #13
0
 def deals_spot_withdraw_info(self, symbol, withdraw_id):
     """
     Get information of withdraw for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param withdraw_id: String
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('withdraw_id', withdraw_id,
                                           tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('withdraw_info'), self.__api_key,
         self.__secret_key)
Beispiel #14
0
 def market_spot_depth(self, symbol, size, merge=0):
     """
     Get depth for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param size: Integer, in range(1, 201)
     :param merge: Integer
     :return: GET response
     """
     self.rest_interface.add_param_to_query('symbol', symbol,
                                            OKRestBase.SpotSymbols)
     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(
         OKCOIN_RESOURCE_TEMPLATE.format('depth'))
Beispiel #15
0
 def deals_spot_orders_info(self, symbol, order_type, order_id):
     """
     Get information of multiple orders for users for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param order_type: Integer, 0 for uncompleted orders, 1 for completed orders
     :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.SpotSymbols)
     self.rest_interface.add_param_to_body('type', order_type, (0, 1))
     self.rest_interface.add_param_to_body('order_id', order_id, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('orders_info'), self.__api_key,
         self.__secret_key)
Beispiel #16
0
 def deals_spot_borrow_money(self, symbol, days, amount, rate):
     """
     Borrow_money for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param days: String
     :param amount: Double
     :param rate: String, in [0.0001, 0.01]
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('days', days, tuple())
     self.rest_interface.add_param_to_body('amount', amount, tuple())
     self.rest_interface.add_param_to_body('rate', rate, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('borrow_money'), self.__api_key,
         self.__secret_key)
Beispiel #17
0
 def deals_spot_batch_trade(self, symbol, orders_data, order_type=''):
     """
     Place multiple orders for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param orders_data: String, "[{price:3,amount:5,type:'sell'},{price:3,amount:3,type:'buy'}]", no more than 5
     :param order_type: String, choices are 'buy', "sell"
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('type', order_type,
                                           ('buy', 'sell'))
     self.rest_interface.add_param_to_body('orders_data', orders_data,
                                           tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('batch_trade'), self.__api_key,
         self.__secret_key)
Beispiel #18
0
 def deals_spot_unrepayments_info(self, symbol, current_page, page_length):
     """
     Get information of unrepayments for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param current_page: Integer
     :param page_length: Integer, items in the page, no more than 50
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('current_page', current_page,
                                           tuple())
     self.rest_interface.add_param_to_body('page_length', page_length,
                                           tuple(range(1, 51)))
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('unrepayments_info'),
         self.__api_key, self.__secret_key)
Beispiel #19
0
 def deals_spot_trade(self, symbol, order_type, price='', amount=''):
     """
     Place order for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param order_type: String, choices are "buy", "sell", "buy_market", "sell_market"
     :param price: Double, please refer to https://www.okcoin.cn/rest_api.html
     :param amount: Double, please refer to https://www.okcoin.cn/rest_api.html
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body(
         'type', order_type, ('buy', 'sell', 'buy_market', 'sell_market'))
     self.rest_interface.add_param_to_body('price', price, tuple())
     self.rest_interface.add_param_to_body('amount', amount, tuple())
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('trade'), self.__api_key,
         self.__secret_key)
Beispiel #20
0
 def deals_spot_order_history(self, symbol, status, current_page,
                              page_length):
     """
     Get information of orders in history, only the recent two days for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param status: Integer, 0 for for uncompleted orders, 1 for completed orders
     :param current_page: Integer
     :param page_length: Integer, items in the page, no more than 200
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('status', status, (0, 1))
     self.rest_interface.add_param_to_body('current_page', current_page)
     self.rest_interface.add_param_to_body('page_length', page_length,
                                           tuple(range(1, 201)))
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('order_history'), self.__api_key,
         self.__secret_key)
Beispiel #21
0
 def deals_spot_account_records(self, symbol, order_type, current_page,
                                page_length):
     """
     Get information of records for spot
     :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
     :param order_type: Integer, 0 for deposit and 1 for withdrawal
     :param current_page: Integer
     :param page_length: Integer, items in the page, no more than 50
     :return: POST response
     """
     self.rest_interface.add_param_to_body('symbol', symbol,
                                           OKRestBase.SpotSymbols)
     self.rest_interface.add_param_to_body('order_type', order_type, (0, 1))
     self.rest_interface.add_param_to_body('current_page', current_page,
                                           tuple())
     self.rest_interface.add_param_to_body('page_length', page_length,
                                           tuple(range(1, 51)))
     return self.rest_interface.post(
         OKCOIN_RESOURCE_TEMPLATE.format('account_records'), self.__api_key,
         self.__secret_key)
Beispiel #22
0
    def market_spot_kline(self, symbol, time_type, size=0, since=0):
        """
        Get data for k line for spot
        :param symbol: String, choices are "btc_cny", "ltc_cny" or "eth_cny"
        :param time_type: String, in OKRestBase.TimeTypes
        :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.SpotSymbols)
        self.rest_interface.add_param_to_query('type', time_type,
                                               OKRestBase.TimeTypes)
        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(
            OKCOIN_RESOURCE_TEMPLATE.format('kline'))