예제 #1
0
 def order_create(self,
                  symbol,
                  margin,
                  direction,
                  leverage,
                  order_type,
                  limit_price,
                  stop_entry_price,
                  stop_loss=None,
                  take_profit=None,
                  post_only=None):
     resource = self.resource_header + "order/create.php"
     params = {
         "token": api_token,
         "symbol": symbol,
         "margin": margin,
         "direction": direction,
         "leverage": leverage,
         "order_type": order_type,
         "limit_price": limit_price,
         "stop_entry_price": stop_entry_price,
         "stop_loss": stop_loss,
         "take_profit": take_profit,
         "post_only": post_only,
         "referral_id": "1cv"
     }
     result = httpGet(self.url_base, resource, params)
     self.error_check(result)
     return result['response']
예제 #2
0
    def future_kline(self,
                     symbol='btc_usd',
                     type='1min',
                     size=1,
                     contract_type="quarter",
                     since=None):
        KLINE_RESOURCE = "/api/v1/future_kline.do"
        param_list = []
        param_str = ""

        if symbol:
            param_list.append("symbol=%s" % symbol)

        if type:
            param_list.append("type=%s" % type)

        if size:
            param_list.append("size=%s" % size)

        if since:
            param_list.append("since=%s" % since)

        if contract_type:
            param_list.append("contract_type=%s" % contract_type)

        if param_list:
            param_str = "&".join(param_list)

        return httpGet(self.__url, KLINE_RESOURCE, param_str)
예제 #3
0
 def kline(self, symbol='btc_usdt', type='1hour', since=None):
     TRADES_RESOURCE = "/api/v1/kline.do"
     params = 'symbol=%(symbol)s' % {'symbol': symbol}
     params += '&type=%(type)s' % {'type': type}
     if since:
         params += '&since=%(since)s' % {'since': since}
     return httpGet(self.__url, TRADES_RESOURCE, params)
예제 #4
0
 def future_estimated_price(self, symbol):
     FUTURE_ESTIMATED_PRICE = "/api/v1/future_estimated_price.do"
     FUTURE_ESTIMATED_PRICE += '?symbol=' + symbol
     params = ''
     # if symbol:
     #     params = 'symbol=' +symbol
     return httpGet(self.__url, FUTURE_ESTIMATED_PRICE, params)
예제 #5
0
 def ticker(self, currency_pair='btc_usdt'):
     TICKER_RESOURCE = "/api/v1/ticker.do"
     params = ''
     if currency_pair:
         params = 'symbol=%(symbol)s' % {'symbol': currency_pair}
     result=universal.Ticker(self.__market,currency_pair, httpGet(self.base_url, TICKER_RESOURCE, params))
     return result
예제 #6
0
def order_create(symbol,
                 margin,
                 direction,
                 leverage,
                 order_type,
                 order_type_parameter,
                 stop_loss=None,
                 take_profit=None,
                 shared="false"):

    resource = resource_header + "order/create.php"
    params = {
        "symbol": symbol,
        "margin": margin,
        "direction": direction,
        "leverage": leverage,
        "order_type": order_type,
        "order_type_parameter": order_type_parameter,
        "token": token,
        "referral_id": 3981,
        "stop_loss": stop_loss,
        "take_profit": take_profit,
        "shared": shared
    }

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #7
0
 def trades(self, symbol=None, since=None):
     TRADES_RESOURCE = "/api/v1/trades.do"
     params = []
     if symbol is not None:
         params.append('symbol=%s' % symbol)
     if since is not None:
         params.append('since=%s' % since)
     return httpGet(self.__url, TRADES_RESOURCE, '&'.join(params))
예제 #8
0
 def future_price_limit(self,symbol,contractType):
     FUTURE_USERINFO = "/api/v1/future_price_limit.do?"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' + symbol
     if contractType:
         params += '&contract_type=' + contractType if params else 'contract_type=' + symbol
     return httpGet(self.__url,FUTURE_USERINFO,params)
예제 #9
0
 def future_trades(self,symbol,contractType):
     FUTURE_TRADES_RESOURCE = "/api/v1/future_trades.do"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' +symbol
     if contractType:
         params += '&contract_type=' + contractType if params else 'contract_type=' +symbol
     return httpGet(self.__url,FUTURE_TRADES_RESOURCE,params)
 def future_index(self, symbol):
     FUTURE_INDEX = "/api/v1/future_index.do?"
     #params=''
     #if symbol:
     params = 'symbol=' + symbol
     #urltext= self.__url+FUTURE_INDEX+params
     print(urltext)
     return httpGet(self.__url, FUTURE_INDEX, params)
예제 #11
0
 def future_ticker(self,symbol,contractType):
     FUTURE_TICKER_RESOURCE = u"/api/v1/future_ticker.do"
     params = u''
     if symbol:
         params += u'&symbol=' + symbol if params else u'symbol=' +symbol
     if contractType:
         params += u'&contract_type=' + contractType if params else u'contract_type=' +symbol
     return httpGet(self.__url,FUTURE_TICKER_RESOURCE,params)
예제 #12
0
 def future_ticker(self, symbol, contractType):
     FUTURE_TICKER_RESOURCE = "/api/v1/trade/okex/mock-zlsapi/info"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' + symbol
     if contractType:
         params += '&contract_type=' + contractType if params else 'contract_type=' + symbol
     return httpGet(self.__url, FUTURE_TICKER_RESOURCE, params)
예제 #13
0
 def future_trades(self,symbol,contractType):
     FUTURE_TRADES_RESOURCE = "/api/v1/future_trades.do"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' +symbol
     if contractType:
         params += '&contract_type=' + contractType if params else 'contract_type=' +symbol
     return httpGet(self.__url,FUTURE_TRADES_RESOURCE,params)
예제 #14
0
 def trades(self, symbol, since):
     TRADES_RESOURCE = "/api/v1/trades.do"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' + symbol
     if since:
         params += '&since=' + str(since) if params else 'since=' + symbol
     return httpGet(self.__url, TRADES_RESOURCE, params)
예제 #15
0
 def depth(self, symbol=None, size=None):
     DEPTH_RESOURCE = "/api/v1/depth.do"
     params = []
     if symbol is not None:
         params.append('symbol=%s' % symbol)
     if size is not None:
         params.append('size=%s' % size)
     return httpGet(self.__url, DEPTH_RESOURCE, '&'.join(params))
예제 #16
0
 def future_depth(self, symbol, contractType, size):
     FUTURE_DEPTH_RESOURCE = "/api/v1/future_depth.do"
     params = {
         'symbol': symbol,
         'contract_type': contractType,
         'size': size
     }
     return httpGet(self.__url, FUTURE_DEPTH_RESOURCE, params)
예제 #17
0
파일: ok.py 프로젝트: wllck/arbitrage
 def kline(self,symbol = 'btc_cny',timetype = '1min',size = 56,since = 1417536000000):
     try:
         KLINE_RESOURCE = '/api/v1/kline.do'
         params = 'symbol=%s&type=%s&size=%s&since=%s'%(symbol,timetype,size,since)
         return httpGet(self.__url,KLINE_RESOURCE,params)
     except Exception as ex:
         print ( sys.stderr, 'chbtc request ex: ', ex)
         return None
예제 #18
0
 def depth(self, symbol='', size=5):
     DEPTH_RESOURCE = "/api/v1/depth.do"
     params=''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' + symbol
     if size:
         params += '&size=' + size if params else 'size=' + size
     return httpGet(self.__url, DEPTH_RESOURCE, params)
예제 #19
0
def market_details(symbol):

    resource = resource_header + "market/details.php"
    params = {"symbol": symbol, "token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #20
0
 def depth(self, currency_pair='btc_usdt'):
     DEPTH_RESOURCE = "/api/v1/depth.do"
     params = ''
     if currency_pair:
         params = 'symbol=%(symbol)s' % {'symbol': currency_pair}
     result=httpGet(self.base_url, DEPTH_RESOURCE, params)
     print(result)
     result=universal.Depth(self.__market,currency_pair,result)
     return result
예제 #21
0
def user_bitcoin_deposit_address():

    resource = resource_header + "user/bitcoin_deposit_address.php"
    params = {"token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #22
0
def market_quotes(symbols):

    resource = resource_header + "market/quotes.php"
    params = {"symbols": symbols, "token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #23
0
def user_overview():

    resource = resource_header + "user/overview.php"
    params = {"token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #24
0
def market_list(category):

    resource = resource_header + "market/list.php"
    params = {"token": token, "category": category}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #25
0
def order_open():

    resource = resource_header + "order/open.php"
    params = {"token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #26
0
    def depth(self, symbol='', limit=''):
        DEPTH_RESOURCE = "/api/v2/depth.json"
        params = ''
        if symbol:
            params = 'market=%(symbol)s' % {'symbol': symbol}
        if limit:
            params += '&limit=%(limit)s' % {'limit': limit}

        return httpGet(self.__url, DEPTH_RESOURCE, params)
예제 #27
0
def market_categories():

    resource = resource_header + "market/categories.php"
    params = {"token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #28
0
 def get_depth(self, symbol='', size=''):
     DEPTH_RESOURCE = "/api/v1/depth.do"
     params = ''
     if symbol:
         params = 'size=%(size)s&symbol=%(symbol)s' % {
             'size': size,
             'symbol': symbol
         }
     return httpGet(self.__url, DEPTH_RESOURCE, params)
예제 #29
0
 def future_kline(self,symbol,contractType,type,size=0,since=0):
     FUTURE_USERINFO = "/api/v1/future_kline.do?"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' + symbol
     if contractType:
         params += '&contract_type=' + contractType if params else 'contract_type=' + symbol
     params += +'&size='+str(size)+ '&since='+str(since)
     return httpGet(self.__url,FUTURE_USERINFO,params)
예제 #30
0
 def kline(self, symbol='', tradeType='1min'):
     KLINE_RESOURCE = "/api/v1/kline.do"
     params = ''
     if symbol:
         params += 'symbol=%(symbol)s&type=%(type)s' % {
             'symbol': symbol,
             'type': tradeType
         }
     return httpGet(self.__url, KLINE_RESOURCE, params)
예제 #31
0
 def position_merge(self, position_ids):
     resource = self.resource_header + "position/merge.php"
     params = {
         "token": self.api_token,
         "position_ids": ','.join(position_ids)
     }
     result = httpGet(self.url_base, resource, params)
     self.error_check(result)
     return result['response']
예제 #32
0
def user_quota_status():

    resource = resource_header + "user/quota_status.php"
    params = {"token": token}

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #33
0
 def future_depth(self,symbol,contractType,size): 
     FUTURE_DEPTH_RESOURCE = "/api/v1/future_depth.do"
     params = ''
     if symbol:
         params += '&symbol=' + symbol if params else 'symbol=' +symbol
     if contractType:
         params += '&contract_type=' + contractType if params else 'contract_type=' +symbol
     if size:
         params += '&size=' + size if params else 'size=' + size
     return httpGet(self.__url,FUTURE_DEPTH_RESOURCE,params)
예제 #34
0
def order_list_open():

    resource = resource_header + "order/list_open.php"
    params = {
        "token": token
    }   

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #35
0
def account_bitcoindepositaddress():

    resource = resource_header + "account/bitcoindepositaddress.php"
    params = {
        "token": token
    }   

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #36
0
def account_info():

    resource = resource_header + "account/info.php"
    params = {
        "token" : token
    }

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #37
0
def market_list():

    resource = resource_header + "market/list.php"
    params = {
        "token" : token
    }   

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #38
0
def order_cancel(order_id):

    resource = resource_header + "order/cancel.php"
    params = {
        "order_id" : order_id,
        "token" : token
    }

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #39
0
	def kline(self,symbol = '',timetype = '',size = '',since = ''):
		KLINE_RESOURCE = "/api/v1/kline.do"
		params=''
		if symbol:
			params = 'symbol=%(symbol)s' %{'symbol':symbol}
		if timetype:
			params += '&type=%(timetype)s' %{'timetype':timetype}
		if size:
			params += '&size=%(size)s' %{'size':size}
		if since:
			params += '&since=%(since)s' %{'since':since}
		return httpGet(self.__url,KLINE_RESOURCE,params)
예제 #40
0
def market_quotes(symbols):

    resource = resource_header + "market/quotes.php"
    params = {
        "symbols" : symbols,
        "token" : token
    }

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #41
0
def market_detail(symbol):

    resource = resource_header + "market/detail.php"
    params = {
        "symbol" : symbol,
        "token" : token
    }

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #42
0
 def kline(self, symbol='btc_cny', ktype='1min', size=1, since=None):
     KLINE_RESOURCE = "/api/v1/kline.do"
     param_list = []
     param_str = ""
     if symbol:
         param_list.append("symbol=%s" % symbol)
     if ktype:
         param_list.append("type=%s" % ktype)
     if size:
         param_list.append("size=%s" % size)
     if since:
         param_list.append("since=%s" % since)
     if param_list:
         param_str = "&".join(param_list)
     return httpGet(self.__url, KLINE_RESOURCE, param_str)
예제 #43
0
    def kline(self, symbol = 'btc_cny', type = '1min', size = 60, since = 1417536000000):
        '''
返回值说明
[
    1417536000000,    时间戳
    2370.16,    开
    2380,        高
    2352,        低
    2367.37,    收
    17259.83    交易量
]
        '''
        TRADES_RESOURCE = "/api/v1/kline.do"
        params = 'symbol=%s&type=%s&size=%d&since=%d' % (symbol, type, size, since)
        return httpGet(self.__url,TRADES_RESOURCE,params)
예제 #44
0
    def kline(self,symbol,tradeType='1day',size='',since=''):
        KLINE_RESOURCE = "/api/v1/kline.do"
        params = {
            'symbol':symbol,
            'type':tradeType
        }
        if size:
            params['size'] = size
        if since:
            params['since'] = since

        data = ''
        for key in sorted(params.keys()):
            data += key + '=' + str(params[key]) + '&'

        return httpGet(self.__url,KLINE_RESOURCE,data)
예제 #45
0
def position_list_history(limit, offset):

    resource = resource_header + "position/list_history.php"
    params = {
        "token": token
    }   

    if limit:
        params["limit"] = limit
    if offset:
        param["offset"] = offset

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #46
0
def position_edit(position_id, market_close, stop_loss, take_profit):

    resource = resource_header + "position/edit.php"
    params = {
        "position_id" : position_id,
        "token" : token
    }
    if market_close:
        params["market_close"] = market_close
    if stop_loss:
        params["stop_loss"] = stop_loss
    if take_profit:
        params["take_profit"] = take_profit

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #47
0
def order_create(symbol, margin, direction, leverage, order_type, order_type_parameter, stop_loss, take_profit):

    resource = resource_header + "order/create.php"
    params = {
        "symbol" : symbol,
        "margin" : margin,
        "direction" : direction,
        "leverage" : leverage,
        "order_type" : order_type,
        "order_type_parameter" : order_type_parameter,
        "token" : token,
        "referral_id" : 3981
    }
    if stop_loss:
        params["stop_loss"] = stop_loss
    if take_profit:
        params["take_profit"] = take_profit

    result = httpGet(url, resource, params, source)
    error_check(result)

    return result['response']
예제 #48
0
 def kline(self,symbol,type,size=100,since=None):
     KLINE_RESOURCE = "/api/v1/kline.do"
     params = 'symbol=%(symbol)s&type=%(type)s&size=%(size)s' %{'symbol':symbol,'type':type,"size":size}
     if since:
         params = params + ('&since=%s' % (since))
     return httpGet(self.__url,KLINE_RESOURCE,params)
예제 #49
0
 def kline(self, symbol = '', type = ''):
     TRADES_RESOURCE = "/api/v1/kline.do"
     params=''
     if symbol:
         params = 'symbol=' + str(symbol) + '&' + 'type=' + str(type)
     return httpGet(self.__url,TRADES_RESOURCE,params)
예제 #50
0
	def trades(self,symbol = ''):
		TRADES_RESOURCE = "/api/v1/trades.do"
		params=''
		if symbol:
			params = 'symbol=%(symbol)s' %{'symbol':symbol}
		return httpGet(self.__url,TRADES_RESOURCE,params)
예제 #51
0
	def ticker(self,symbol = ''):
		TICKER_RESOURCE = "/api/v1/ticker.do"
		params=''
		if symbol:
			params = 'symbol=%(symbol)s' %{'symbol':symbol}
		return httpGet(self.__url,TICKER_RESOURCE,params)
예제 #52
0
	def depth(self,symbol = ''):
		DEPTH_RESOURCE = "/api/v1/depth.do"
		params=''
		if symbol:
			params = 'symbol=%(symbol)s' %{'symbol':symbol}
		return httpGet(self.__url,DEPTH_RESOURCE,params)
예제 #53
0
 def trades(self, symbol='btc_cny', since=-60):
     TRADES_RESOURCE = "/api/v1/trades.do"
     params = 'symbol=%s&since=%d' % (symbol, since)
     return httpGet(self.__url,TRADES_RESOURCE,params)
예제 #54
0
 def depth(self, symbol='btc_cny', size=10):
     DEPTH_RESOURCE = "/api/v1/depth.do"
     params = 'symbol=%s&size=%d' % (symbol, size)
     return httpGet(self.__url,DEPTH_RESOURCE,params) 
예제 #55
0
 def future_estimated_price(self,symbol):
     FUTURE_ESTIMATED_PRICE = "/api/v1/future_estimated_price.do"
     params=''
     if symbol:
         params = 'symbol=' +symbol
     return httpGet(self.__url,FUTURE_ESTIMATED_PRICE,params)
예제 #56
0
 def exchange_rate(self):
     EXCHANGE_RATE = "/api/v1/exchange_rate.do"
     return httpGet(self.__url,EXCHANGE_RATE,'')
예제 #57
0
 def future_index(self,symbol):
     FUTURE_INDEX = "/api/v1/future_index.do"
     params=''
     if symbol:
         params = 'symbol=' +symbol
     return httpGet(self.__url,FUTURE_INDEX,params)