Exemplo n.º 1
0
def on_message(self, evt):
    data = inflate(evt)
    print(data)
    data = str(data, "utf-8")
    json_dict = json.loads(data)
    channel = json_dict[0]['channel']
    if channel == 'ok_sub_spotcny_btc_ticker':
        insert_data('btc_cny', json_dict[0]['data']['last'])
Exemplo n.º 2
0
def getData():    
	try:         
		table = 'btc_this_future_ticker'
		url = 'https://www.okcoin.com/api/v1/future_ticker.do?symbol=btc_usd&contract_type=this_week' ;
		data      = urllib2.urlopen(url).read() 
		json_dict = json.loads(data)        
		insert_data(table,json_dict.get('ticker').get('last'))
		return json_dict.get('ticker').get('last')  
	except Exception, e:
		# print e
		getData()  
Exemplo n.º 3
0
def getData():    
	try:         
		table     = 'btc_future_index'
		url       = 'https://www.okcoin.com/api/v1/future_index.do?symbol=btc_usd' 
		data      = urllib2.urlopen(url).read() 
		json_dict = json.loads(data)        
		insert_data(table,json_dict.get('future_index'))
		return json_dict.get('future_index')    
	except Exception, e:
		# print e
		getData()  
Exemplo n.º 4
0
def getData():
    try:
        table = 'btc_exchange_rate'
        url = 'https://www.okcoin.com/api/v1/exchange_rate.do'
        data = urllib2.urlopen(url).read()
        json_dict = json.loads(data)
        insert_data(table, json_dict.get('rate'))
        return json_dict.get('rate')
    except Exception, e:
        # print e
        getData()
Exemplo n.º 5
0
def getData():
    try:
        table = 'ltc_usd'
        url = 'https://www.okcoin.com/api/v1/ticker.do?symbol=ltc_usd'
        data = urllib2.urlopen(url).read()
        json_dict = json.loads(data)
        insert_data(table, json_dict.get('ticker').get('last'))
        return json_dict.get('ticker').get('last')
    except Exception, e:
        # print e
        getData()
Exemplo n.º 6
0
def on_message(self,evt):
    data = inflate(evt)  
    print(data)
    data = str(data, "utf-8")
    json_dict = json.loads(data)
    channel = json_dict[0]['channel']
    if channel == 'ok_sub_spotusd_btc_ticker':
        insert_data('btc_usd',json_dict[0]['data']['last'])
    if channel == 'ok_sub_futureusd_btc_ticker_this_week':
        insert_data('btc_this_future_ticker',json_dict[0]['data']['last'])
    if channel == 'ok_sub_futureusd_btc_ticker_next_week':
        insert_data('btc_next_future_ticker',json_dict[0]['data']['last'])
    if channel == 'ok_sub_futureusd_btc_ticker_quarter':
        insert_data('btc_quarter_future_ticker',json_dict[0]['data']['last'])
    if channel == 'ok_sub_futureusd_btc_index':
        insert_data('btc_future_index',json_dict[0]['data']['futureIndex'])