Beispiel #1
0
 def balances(self):
     USERINFO_RESOURCE = "/api/v1/userinfo.do"
     params = {}
     params['api_key'] = self.account.api_key
     params['sign'] = buildMySign(params, self.account.secret_key)
     result = httpPost(self.base_url, USERINFO_RESOURCE, params)
     result = universal.BalanceInfo(self.__market, result)
     return result
Beispiel #2
0
 def trade_history(self, currency_pair, since):
     TRADE_HISTORY_RESOURCE = "/api/v1/trade_history.do"
     params = {
         'api_key': self.account.api_key,
         'symbol': currency_pair,
         'since': since,
     }
     params['sign'] = buildMySign(params, self.account.secret_key)
     return httpPost(self.base_url, TRADE_HISTORY_RESOURCE, params)
Beispiel #3
0
 def orderinfo(self, symbol, orderId):
     ORDER_INFO_RESOURCE = "/api/v1/order_info.do"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'order_id': orderId
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, ORDER_INFO_RESOURCE, params)
Beispiel #4
0
 def cancelOrder(self, symbol, orderId):
     CANCEL_ORDER_RESOURCE = "/api/v1/cancel_order.do"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'order_id': orderId
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, CANCEL_ORDER_RESOURCE, params)
Beispiel #5
0
 def cancel_order(self, currency_pair, order_id):
     CANCEL_ORDER_RESOURCE = "/api/v1/cancel_order.do"
     params = {
         'api_key': self.account.api_key,
         'symbol': currency_pair,
         'order_id': order_id
     }
     params['sign'] = buildMySign(params, self.account.secret_key)
     return httpPost(self.base_url, CANCEL_ORDER_RESOURCE, params)
Beispiel #6
0
 def future_position(self, symbol, contractType):
     FUTURE_POSITION = "/api/v1/future_position.do?"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'contract_type': contractType
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_POSITION, params)
Beispiel #7
0
 def future_cancel(self, symbol, contractType, orderId):
     FUTURE_CANCEL = "/api/v1/future_cancel.do?"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'contract_type': contractType,
         'order_id': orderId
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_CANCEL, params)
Beispiel #8
0
 def future_position_4fix(self, symbol, contractType, type1):
     FUTURE_POSITION_4FIX = "/api/v1/future_position_4fix.do?"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'contract_type': contractType,
         'type': type1
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_POSITION_4FIX, params)
Beispiel #9
0
 def batchTrade(self, symbol, tradeType, orders_data):
     BATCH_TRADE_RESOURCE = "/api/v1/batch_trade.do"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'type': tradeType,
         'orders_data': orders_data
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, BATCH_TRADE_RESOURCE, params)
Beispiel #10
0
 def batch_trade(self, currency_pair, type, orders_data):
     BATCH_TRADE_RESOURCE = "/api/v1/batch_trade.do"
     params = {
         'api_key': self.account.api_key,
         'symbol': currency_pair,
         'type': type,
         'orders_data': orders_data
     }
     params['sign'] = buildMySign(params, self.account.secret_key)
     return httpPost(self.base_url, BATCH_TRADE_RESOURCE, params)
Beispiel #11
0
 def future_batchTrade(self, symbol, contractType, orders_data, leverRate):
     FUTURE_BATCH_TRADE = "/api/v1/future_batch_trade.do?"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'contract_type': contractType,
         'orders_data': orders_data,
         'lever_rate': leverRate
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_BATCH_TRADE, params)
Beispiel #12
0
 def trade_list(self, currency_pair, current_page=1, page_length=200):
     ORDER_HISTORY_RESOURCE = "/api/v1/order_history.do"
     params = {
         'api_key': self.account.api_key,
         'symbol': currency_pair,
         'status': 1,
         'current_page': current_page,
         'page_length': page_length
     }
     params['sign'] = buildMySign(params, self.account.secret_key)
     return httpPost(self.base_url, ORDER_HISTORY_RESOURCE, params)
Beispiel #13
0
 def orderHistory(self, symbol, status, currentPage, pageLength):
     ORDER_HISTORY_RESOURCE = "/api/v1/order_history.do"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'status': status,
         'current_page': currentPage,
         'page_length': pageLength
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, ORDER_HISTORY_RESOURCE, params)
Beispiel #14
0
 def get_all_currencies(self):
     import json
     USERINFO_RESOURCE = "/api/v1/userinfo.do"
     params = {}
     params['api_key'] = self.account.api_key
     params['sign'] = buildMySign(params, self.account.secret_key)
     result = json.loads(httpPost(self.base_url, USERINFO_RESOURCE, params))
     result = result["info"]["funds"]["free"]
     result = dict(result).keys()
     currencies = []
     for item in result:
         currencies.append(item)
     return currencies
Beispiel #15
0
    def trade(self, symbol, tradeType, price='', amount=''):
        TRADE_RESOURCE = "/api/v1/trade.do"
        params = {
            'api_key': self.__apikey,
            'symbol': symbol,
            'type': tradeType
        }
        if price:
            params['price'] = price
        if amount:
            params['amount'] = amount

        params['sign'] = buildMySign(params, self.__secretkey)
        return httpPost(self.__url, TRADE_RESOURCE, params)
Beispiel #16
0
 def future_orderinfo(self, symbol, contractType, orderId, status,
                      currentPage, pageLength):
     FUTURE_ORDERINFO = "/api/v1/future_order_info.do?"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'contract_type': contractType,
         'order_id': orderId,
         'status': status,
         'current_page': currentPage,
         'page_length': pageLength
     }
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_ORDERINFO, params)
Beispiel #17
0
 def order_list(self, currency_pair, current_page=1, page_length=200):
     ORDER_HISTORY_RESOURCE = "/api/v1/order_history.do"
     params = {
         'api_key': self.account.api_key,
         'symbol': currency_pair,
         'status': 0,
         'current_page': current_page,
         'page_length': page_length
     }
     params['sign'] = buildMySign(params, self.account.secret_key)
     result = httpPost(self.base_url, ORDER_HISTORY_RESOURCE, params)
     result = universal.SubmittedOrderList(currency_pair, self.__market,
                                           result)
     return result
Beispiel #18
0
 def future_trade(self,
                  symbol,
                  contractType,
                  price='',
                  amount='',
                  tradeType='',
                  matchPrice='',
                  leverRate=''):
     FUTURE_TRADE = "/api/v1/future_trade.do?"
     params = {
         'api_key': self.__apikey,
         'symbol': symbol,
         'contract_type': contractType,
         'amount': amount,
         'type': tradeType,
         'match_price': matchPrice,
         'lever_rate': leverRate
     }
     if price:
         params['price'] = price
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_TRADE, params)
Beispiel #19
0
    def submit_order(self,
                     type="buy",
                     currency_pair='btc_usdt',
                     price='',
                     amount=''):
        if type == 1 or type == "1" or type.lower() == "buy":
            type = "buy"
        else:
            type = "sell"
        TRADE_RESOURCE = "/api/v1/trade.do"
        params = {
            'api_key': self.account.api_key,
            'symbol': currency_pair,
            'type': type
        }
        if price:
            params['price'] = price
        if amount:
            params['amount'] = amount

        params['sign'] = buildMySign(params, self.account.secret_key)
        return httpPost(self.base_url, TRADE_RESOURCE, params)
Beispiel #20
0
 def userinfo(self):
     USERINFO_RESOURCE = "/api/v1/userinfo.do"
     params = {}
     params['api_key'] = self.__apikey
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, USERINFO_RESOURCE, params)
Beispiel #21
0
 def future_userinfo(self):
     FUTURE_USERINFO = "/api/v1/future_userinfo.do?"
     params = {}
     params['api_key'] = self.__apikey
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_USERINFO, params)
Beispiel #22
0
 def future_userinfo_4fix(self):
     FUTURE_INFO_4FIX = "/api/v1/future_userinfo_4fix.do?"
     params = {'api_key': self.__apikey}
     params['sign'] = buildMySign(params, self.__secretkey)
     return httpPost(self.__url, FUTURE_INFO_4FIX, params)