예제 #1
0
    def future_kline(self,symbol,type_,contract_type,size,since):
        """
        获取OKEx合约K线信息
        参数名	参数类型	必填	描述
            
        :param symbol: String	是	btc_usd ltc_usd eth_usd etc_usd bch_usd
        :param type: String	是	1min/3min/5min/15min/30min/1day/3day/1week/1hour/2hour/4hour/6hour/12hour
        :param contract_type: String	是	合约类型: this_week:当周 next_week:下周 quarter:季度
        :param size: Integer	否(默认0)	指定获取数据的条数
        :param since: 否(默认0)	时间戳(eg:1417536000000)。 返回该时间戳以后的数据
        :return: [
    1440308760000,	时间戳
    233.38,		开
    233.38,		高
    233.27,		低
    233.37,		收
    186,		交易量
    79.70234956		交易量转化BTC或LTC数量
]
        """
        FUTURE_KLINE_RESOURCE = "/api/v1/future_kline.do"
        params = ''
        if symbol:
            params += '&symbol=' + symbol if params else 'symbol=' +symbol
        if tpye_:
            params += '&type=' + type_ if params else 'type=' + type_
        if contract_type:
            params += '&contract_type=' + contract_type if params else 'contract_type=' +contract_type
        if size:
            params += '&size=' + size if params else 'size=' + size
        if since:
            params += '&since=' + since if params else 'since=' + since

        return httpGet(self.__url, FUTURE_KLINE_RESOURCE, params)
예제 #2
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)
예제 #3
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)
예제 #4
0
    def kline(self, symbol, type_, size_=None, since=None):
        """
        获取OKEx币币K线数据(每个周期数据条数2000左右)
        :param symbol:币对如ltc_btc
        :param type_: 1min/3min/5min/15min/30min/1day/3day/1week/1hour/2hour/4hour/6hour/12hour
        :param size_: 默认全部
        :param since: 时间戳,返回该时间戳以后的数据(例如1417536000000)
        :return:
        """
        KLINE_RESOURCE = "/api/v1/kline.do"

        params = 'symbol={}&type={}'.format(symbol, type_)

        if size_ is not None and isinstance(size_, int):
            params = params + '&size={}'.format(size_)

        if since is not None and isinstance(since, int):
            params = params + '&since={}'.format(since)
        return httpGet(self.__url, KLINE_RESOURCE, params)
예제 #5
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)
예제 #6
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)
예제 #7
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)
예제 #8
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)
예제 #9
0
 def exchange_rate(self):
     EXCHANGE_RATE = "/api/v1/exchange_rate.do"
     return httpGet(self.__url,EXCHANGE_RATE,'')
예제 #10
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)