def _convert_detail_trades(tradelist): # need to process the 'time' and 'type' keys on each trade. # 'time': string like "01:28:35" # 'type': buy/sell in chinese now_localized = datetime.datetime.now(tz=pytz.timezone('Asia/Hong_Kong')) for trade in tradelist: if trade['type'] == u'\u4e70\u5165': # buy trade['type'] = True elif trade['type'] == u'\u5356\u51fa': # sell trade['type'] = False partial_dt = datetime.datetime.strptime(trade['time'], '%H:%M:%S') time_localized = now_localized.replace(hour=partial_dt.hour, minute=partial_dt.minute, second=partial_dt.second, microsecond=0) trade['time'] = calendar.timegm(time_localized.utctimetuple()) #trade['time'] = _hktime_to_timestamp(trade['time']) return simpleschema.remap(tradelist, [{ 'time': 'timestamp', 'type': 'direction' }])
def process(data): new = data[_convert_pair(pair)] return simpleschema.remap( new, { 'buy': 'bid', 'sell': 'ask', 'updated': 'timestamp', 'vol': 'volume', 'vol_cur': 'basis_volume', 'avg': 'mid' })
def orderchange(self, event): change = event.data if event.name == 'order_created': kind = 'created' elif event.name == 'order_deleted': kind = 'deleted' elif event.name == 'order_changed': kind = 'changed' else: return change['change'] = kind change['order_type'] = 'ask' if bool(int(change['order_type'])) else 'bid' return simpleschema.remap(change, {'datetime': 'timestamp', 'order_type': 'direction'})
def orderchange(self, event): change = event.data if event.name == 'order_created': kind = 'created' elif event.name == 'order_deleted': kind = 'deleted' elif event.name == 'order_changed': kind = 'changed' else: return change['change'] = kind change['order_type'] = 'ask' if bool(int( change['order_type'])) else 'bid' return simpleschema.remap(change, { 'datetime': 'timestamp', 'order_type': 'direction' })
def _convert_detail_trades(tradelist): # need to process the 'time' and 'type' keys on each trade. # 'time': string like "01:28:35" # 'type': buy/sell in chinese now_localized = datetime.datetime.now(tz=pytz.timezone("Asia/Hong_Kong")) for trade in tradelist: if trade["type"] == u"\u4e70\u5165": # buy trade["type"] = True elif trade["type"] == u"\u5356\u51fa": # sell trade["type"] = False partial_dt = datetime.datetime.strptime(trade["time"], "%H:%M:%S") time_localized = now_localized.replace( hour=partial_dt.hour, minute=partial_dt.minute, second=partial_dt.second, microsecond=0 ) trade["time"] = calendar.timegm(time_localized.utctimetuple()) # trade['time'] = _hktime_to_timestamp(trade['time']) return simpleschema.remap(tradelist, [{"time": "timestamp", "type": "direction"}])
def process(data): new = data[_convert_pair(pair)] for trade in new: trade['direction'] = bool(trade.pop('type') == 'bid') return simpleschema.remap(new, [{'tid': 'id'}])
def process(data): new = data[_convert_pair(pair)] return simpleschema.remap(new, {'buy': 'bid', 'sell': 'ask', 'updated': 'timestamp', 'vol': 'volume', 'vol_cur': 'basis_volume', 'avg': 'mid'})
def process(data): new = data[_convert_pair(pair)] for trade in new: trade['direction'] = bool(trade.pop('type') == 'bid') return simpleschema.remap(new, [{'tid': 'id'}])