コード例 #1
0
ファイル: gen30min.py プロジェクト: Rick962/T_Code
            data = i["data"]
            item = json.loads(data)
            code = item['code']
            name = item['name']
            #if code == 'bsv_usdt' or 'dash_usdt' or 'trx_usdt':
            #    pass

            timestamp = int(str(item['timestamp'])[0:10])
            datetime = time.strftime("%Y-%m-%d %H:%M:00", time.localtime(timestamp))
            index = int(time.strftime("%M", time.localtime(int(timestamp))))
            new_time_index = index - index % 30
            datetimes = time.strftime("%Y-%m-%d %H:" + str(new_time_index) + ":00", time.localtime(timestamp))
            time_stamp = int(time.mktime(time.strptime(datetimes, "%Y-%m-%d %H:%M:%S")))
            code = item['code']

            if coinMap.get(code)['old_time_index'] is None:
                coinMap.get(code)['openprice'] = item['close']
                coinMap.get(code)['closePrice'] = item['close']
                coinMap.get(code)['highprice'] = item['close']
                coinMap.get(code)['lowprice'] = item['close']
                coinMap.get(code)['volume'] = item['volume']
            else:
                if coinMap.get(code)['old_time_index'] != new_time_index:
                    volumes = int(item['volume'] - coinMap.get(code)['volume'])
                    if volumes < 0:
                        #volumes = int(item['volume'])
                        volumes = abs(int(coinMap.get(code)['volume']/48)) 
                    timestamp = timestamp - 1800
                    datetime = time.strftime("%Y-%m-%d %H:%M:00", time.localtime(timestamp))
                    #name = code.upper()
                    pid = coinPid.get(name)
コード例 #2
0
ファイル: gen1min.py プロジェクト: Rick962/T_Code
                                     time.localtime(timestamp))
            timestamp1 = int(
                time.mktime(time.strptime(datetime, "%Y-%m-%d %H:%M:%S")))
            new_time_index = int(
                time.strftime("%M", time.localtime(int(timestamp))))

            # index = int(time.strftime("%M", time.localtime(int(timestamp))))
            # new_time_index = index - index % 5

            code = str(item['code'])
            name = str(item['name'])
            #print(code, type(code))
            # print(sub_timestamp)
            # indextime = str(new_time_index - new_time_index % 15)
            # print(code)
            if (coinMap.get(code)).get('old_time_index') is None:
                coinMap.get(code)['openprice'] = item['close']
                coinMap.get(code)['closePrice'] = item['close']
                coinMap.get(code)['highprice'] = item['close']
                coinMap.get(code)['lowprice'] = item['close']
                coinMap.get(code)['volume'] = item['volume']
            else:
                if coinMap.get(code)['old_time_index'] != new_time_index:
                    volumes = int(item['volume'] - coinMap.get(code)['volume'])
                    if volumes < 0:
                        volumes = int(item['volume'])
                    #name = code.upper()
                    pid = coinPid.get(name)
                    timestamp = timestamp - 60
                    datetime = time.strftime("%Y-%m-%d %H:%M:00",
                                             time.localtime(timestamp))