def conventDataForSave(self,dat): # {'timestamp': '2018-03-14T15:17:00.000Z', 'symbol': 'XBTUSD', 'open': 8707.5, 'high': 8720, 'low': 8706, 'close': 8716.5, 'trades': 357, 'volume': 1488175, 'vwap': 8710.0427, 'lastSize': 500, 'turnover': 17086355694, 'homeNotional': 170.86355693999997, 'foreignNotional': 1488175}, outs = [] for d in dat: utctime = d['timestamp'] timest = timetool.utcStrTimeToTime(utctime) timeint = int(timest) ltimeStr = timetool.timestamp2datetime(timeint,True) opentmp = d['open'] hithtmp = d['high'] lowtmp = d['low'] closetmp = d['close'] volumetmp = d['volume'] symboltmp = d['symbol'] outs.append([timeint,opentmp,hithtmp,lowtmp,closetmp,volumetmp,symboltmp,str(ltimeStr)]) return outs
def timeconvent(self,utcstrtime): timest = timetool.utcStrTimeToTime(utcstrtime) timeint = int(timest) ltimeStr = str(timetool.timestamp2datetime(timeint,True)) return timeint,ltimeStr
from magetool import pathtool ndir = pathtool.cur_file_dir() pdir = pathtool.GetParentPath(ndir) ppdir = pathtool.GetParentPath(pdir) + os.sep + 'util' print(ppdir) # print(ppdir) sys.path.append(ppdir) import apikeytool if __name__ == '__main__': # a = ['a','b','c'] # x = ','.join(a) # a = ' 345 abc jjj ' # x = ' '.join(a.split()) # print x # a = str(int(time.time() - 100*60*60)*1000) # print(a) # d = {0.1:1,0.2:3} # dks = d.keys() # print(d) # d.pop(dks[0]) # print(d) # print(d.keys()) a = [3, 4, 2, 1, 5] print(a.index(4)) print(round(100)) out = timetool.timestamp2datetime(1530933567.0, True) print(out)