Compare commits

..

7 Commits

Author SHA1 Message Date
200e20c343 Auto update price data 2025-07-27 23:11:06 +08:00
525f83c503 Auto update price data 2025-07-27 22:41:09 +08:00
47feeda357 Auto update price data 2025-07-27 22:20:49 +08:00
e44ff195b6 删除 price.csv 2025-07-27 21:26:06 +08:00
44a1c8452e 更新 price.json 2025-07-27 21:12:34 +08:00
97ecd1168c 更新 price.json 2025-07-27 21:07:33 +08:00
df3ba6c97f 添加 price.json 2025-07-27 21:05:21 +08:00
7 changed files with 1 additions and 2227 deletions

View File

@@ -1,109 +0,0 @@
datetime,roundIndex,raisedAmount,raiseGoalAmount,tokensSoldAmount,tokensGoalAmount
2025-07-28 21:16:22,78,2643289,2673289,260626055,261446400
2025-07-28 21:18:45,78,2643289,2673289,260626055,261446400
2025-07-28 22:18:51,78,2643289,2673289,260626055,261446400
2025-07-28 23:18:56,78,2643289,2673289,260626055,261446400
2025-07-29 00:18:57,78,2643289,2673289,260626055,261446400
2025-07-29 01:18:59,78,2643289,2673289,260626055,261446400
2025-07-29 02:19:08,79,2674014,2704014,261534771,262346899
2025-07-29 03:19:16,79,2674014,2704014,261534771,262346899
2025-07-29 04:19:22,79,2674014,2704014,261534771,262346899
2025-07-29 05:19:23,79,2674014,2704014,261534771,262346899
2025-07-29 06:19:26,79,2674014,2704014,261534771,262346899
2025-07-29 07:19:31,79,2674014,2704014,261534771,262346899
2025-07-29 08:19:32,79,2674014,2704014,261534771,262346899
2025-07-29 09:19:42,79,2674014,2704014,261534771,262346899
2025-07-29 10:19:49,79,2674014,2704014,261534771,262346899
2025-07-29 11:19:53,79,2674014,2704014,261534771,262346899
2025-07-29 12:19:58,79,2674014,2704014,261534771,262346899
2025-07-29 13:20:01,80,2713194,2743194,262695735,263499809
2025-07-29 14:20:08,80,2713194,2743194,262695735,263499809
2025-07-29 15:20:19,80,2713194,2743194,262695735,263499809
2025-07-29 16:20:20,80,2713194,2743194,262695735,263499809
2025-07-29 17:20:28,80,2713194,2743194,262695735,263499809
2025-07-29 18:20:35,80,2713194,2743194,262695735,263499809
2025-07-29 19:20:43,80,2713194,2743194,262695735,263499809
2025-07-29 20:20:51,81,2744582,2774582,263591753,264387931
2025-07-29 21:20:51,81,2744582,2774582,263591753,264387931
2025-07-29 22:20:59,81,2744582,2774582,263591753,264387931
2025-07-29 23:21:04,81,2744582,2774582,263591753,264387931
2025-07-30 00:21:12,82,2776266,2806266,264507318,265295547
2025-07-30 01:21:12,82,2776266,2806266,264507318,265295547
2025-07-30 02:21:18,82,2776266,2806266,264507318,265295547
2025-07-30 03:21:21,82,2776266,2806266,264507318,265295547
2025-07-30 04:21:41,83,2817387,2847387,265713201,266493638
2025-07-30 05:21:43,83,2817387,2847387,265713201,266493638
2025-07-30 06:21:44,83,2817387,2847387,265713201,266493638
2025-07-30 07:21:45,83,2817387,2847387,265713201,266493638
2025-07-30 08:21:55,84,2853494,2883494,266749481,267522279
2025-07-30 09:21:57,84,2853494,2883494,266749481,267522279
2025-07-30 10:21:57,84,2853494,2883494,266749481,267522279
2025-07-30 11:21:58,84,2853494,2883494,266749481,267522279
2025-07-30 12:22:01,84,2853494,2883494,266749481,267522279
2025-07-30 13:22:11,84,2853494,2883494,266749481,267522279
2025-07-30 14:22:14,84,2853494,2883494,266749481,267522279
2025-07-30 15:22:20,84,2853494,2883494,266749481,267522279
2025-07-30 15:44:41,84,2853494,2883494,266749481,267522279
2025-07-30 16:44:41,85,2888447,2918447,267717971,268483082
2025-07-30 17:44:47,85,2888447,2918447,267717971,268483082
2025-07-30 18:44:50,85,2888447,2918447,267717971,268483082
2025-07-30 19:44:56,85,2888447,2918447,267717971,268483082
2025-07-30 20:44:57,85,2888447,2918447,267717971,268483082
2025-07-30 21:45:05,85,2888447,2918447,267717971,268483082
2025-07-30 22:45:12,85,2888447,2918447,267717971,268483082
2025-07-30 23:45:14,85,2888447,2918447,267717971,268483082
2025-07-31 00:45:24,85,2932388,2962388,267717971,269715348
2025-07-31 01:45:29,85,2932388,2962388,267717971,269715348
2025-07-31 02:45:38,85,2932388,2962388,267717971,269715348
2025-07-31 03:45:42,86,2963854,2993854,268573164,269323164
2025-07-31 04:45:51,86,2963854,2993854,268573164,269323164
2025-07-31 05:45:54,86,2963854,2993854,268573164,269323164
2025-07-31 06:46:02,86,2963854,2993854,268573164,269323164
2025-07-31 07:46:07,86,2963854,2993854,268573164,269323164
2025-07-31 08:46:17,87,3007192,3037192,269778365,270520939
2025-07-31 09:46:18,87,3007192,3037192,269778365,270520939
2025-07-31 10:46:21,88,3040098,3070098,270693231,271428525
2025-07-31 11:46:30,88,3040098,3070098,270693231,271428525
2025-07-31 12:46:36,88,3040098,3070098,270693231,271428525
2025-07-31 13:46:44,88,3040098,3070098,270693231,271428525
2025-07-31 14:46:54,88,3040098,3070098,270693231,271428525
2025-07-31 15:46:59,88,3040098,3070098,270693231,271428525
2025-07-31 16:47:05,89,3070067,3100067,271482785,272210764
2025-07-31 17:47:05,89,3070067,3100067,271482785,272210764
2025-07-31 18:47:12,89,3070067,3100067,271482785,272210764
2025-07-31 19:47:18,89,3070067,3100067,271482785,272210764
2025-07-31 20:47:24,89,3070067,3100067,271482785,272210764
2025-07-31 21:47:31,89,3070067,3100067,271482785,272210764
2025-07-31 22:47:36,90,3100506,3130506,272290845,273011652
2025-07-31 23:47:40,90,3100506,3130506,272290845,273011652
2025-08-01 00:47:48,90,3100506,3130506,272290845,273011652
2025-08-01 01:47:49,90,3100506,3130506,272290845,273011652
2025-08-01 02:47:50,90,3100506,3130506,272290845,273011652
2025-08-01 03:47:59,90,3100506,3130506,272290845,273011652
2025-08-01 04:48:02,90,3100506,3130506,272290845,273011652
2025-08-01 05:48:11,91,3130931,3160931,273081312,273794918
2025-08-01 06:48:16,91,3130931,3160931,273081312,273794918
2025-08-01 07:48:20,91,3130931,3160931,273081312,273794918
2025-08-01 08:48:25,91,3130931,3160931,273081312,273794918
2025-08-01 09:48:33,91,3130931,3160931,273081312,273794918
2025-08-01 10:48:44,91,3130931,3160931,273081312,273794918
2025-08-01 11:48:46,91,3130931,3160931,273081312,273794918
2025-08-01 12:48:55,92,3164943,3194943,273983137,274689684
2025-08-01 13:49:08,92,3164943,3194943,273983137,274689684
2025-08-01 14:49:09,92,3164943,3194943,273983137,274689684
2025-08-01 15:49:13,92,3164943,3194943,273983137,274689684
2025-08-01 16:49:15,92,3164943,3194943,273983137,274689684
2025-08-01 17:49:15,92,3164943,3194943,273983137,274689684
2025-08-01 18:49:22,93,3198424,3228424,274866179,275565643
2025-08-01 19:49:28,93,3198424,3228424,274866179,275565643
2025-08-01 20:49:36,93,3198424,3228424,274866179,275565643
2025-08-01 21:49:43,93,3198424,3228424,274866179,275565643
2025-08-01 22:49:46,93,3198424,3228424,274866179,275565643
2025-08-01 23:49:51,93,3198424,3228424,274866179,275565643
2025-08-02 00:50:00,93,3198424,3228424,274866179,275565643
2025-08-02 01:50:00,93,3198424,3228424,274866179,275565643
2025-08-02 02:50:11,93,3198424,3228424,274866179,275565643
2025-08-02 03:50:13,93,3198424,3228424,274866179,275565643
2025-08-02 04:50:16,93,3198424,3228424,274866179,275565643
2025-08-02 05:50:19,93,3198424,3228424,274866179,275565643
2025-08-02 06:50:27,93,3198424,3228424,274866179,275565643
1 datetime roundIndex raisedAmount raiseGoalAmount tokensSoldAmount tokensGoalAmount
2 2025-07-28 21:16:22 78 2643289 2673289 260626055 261446400
3 2025-07-28 21:18:45 78 2643289 2673289 260626055 261446400
4 2025-07-28 22:18:51 78 2643289 2673289 260626055 261446400
5 2025-07-28 23:18:56 78 2643289 2673289 260626055 261446400
6 2025-07-29 00:18:57 78 2643289 2673289 260626055 261446400
7 2025-07-29 01:18:59 78 2643289 2673289 260626055 261446400
8 2025-07-29 02:19:08 79 2674014 2704014 261534771 262346899
9 2025-07-29 03:19:16 79 2674014 2704014 261534771 262346899
10 2025-07-29 04:19:22 79 2674014 2704014 261534771 262346899
11 2025-07-29 05:19:23 79 2674014 2704014 261534771 262346899
12 2025-07-29 06:19:26 79 2674014 2704014 261534771 262346899
13 2025-07-29 07:19:31 79 2674014 2704014 261534771 262346899
14 2025-07-29 08:19:32 79 2674014 2704014 261534771 262346899
15 2025-07-29 09:19:42 79 2674014 2704014 261534771 262346899
16 2025-07-29 10:19:49 79 2674014 2704014 261534771 262346899
17 2025-07-29 11:19:53 79 2674014 2704014 261534771 262346899
18 2025-07-29 12:19:58 79 2674014 2704014 261534771 262346899
19 2025-07-29 13:20:01 80 2713194 2743194 262695735 263499809
20 2025-07-29 14:20:08 80 2713194 2743194 262695735 263499809
21 2025-07-29 15:20:19 80 2713194 2743194 262695735 263499809
22 2025-07-29 16:20:20 80 2713194 2743194 262695735 263499809
23 2025-07-29 17:20:28 80 2713194 2743194 262695735 263499809
24 2025-07-29 18:20:35 80 2713194 2743194 262695735 263499809
25 2025-07-29 19:20:43 80 2713194 2743194 262695735 263499809
26 2025-07-29 20:20:51 81 2744582 2774582 263591753 264387931
27 2025-07-29 21:20:51 81 2744582 2774582 263591753 264387931
28 2025-07-29 22:20:59 81 2744582 2774582 263591753 264387931
29 2025-07-29 23:21:04 81 2744582 2774582 263591753 264387931
30 2025-07-30 00:21:12 82 2776266 2806266 264507318 265295547
31 2025-07-30 01:21:12 82 2776266 2806266 264507318 265295547
32 2025-07-30 02:21:18 82 2776266 2806266 264507318 265295547
33 2025-07-30 03:21:21 82 2776266 2806266 264507318 265295547
34 2025-07-30 04:21:41 83 2817387 2847387 265713201 266493638
35 2025-07-30 05:21:43 83 2817387 2847387 265713201 266493638
36 2025-07-30 06:21:44 83 2817387 2847387 265713201 266493638
37 2025-07-30 07:21:45 83 2817387 2847387 265713201 266493638
38 2025-07-30 08:21:55 84 2853494 2883494 266749481 267522279
39 2025-07-30 09:21:57 84 2853494 2883494 266749481 267522279
40 2025-07-30 10:21:57 84 2853494 2883494 266749481 267522279
41 2025-07-30 11:21:58 84 2853494 2883494 266749481 267522279
42 2025-07-30 12:22:01 84 2853494 2883494 266749481 267522279
43 2025-07-30 13:22:11 84 2853494 2883494 266749481 267522279
44 2025-07-30 14:22:14 84 2853494 2883494 266749481 267522279
45 2025-07-30 15:22:20 84 2853494 2883494 266749481 267522279
46 2025-07-30 15:44:41 84 2853494 2883494 266749481 267522279
47 2025-07-30 16:44:41 85 2888447 2918447 267717971 268483082
48 2025-07-30 17:44:47 85 2888447 2918447 267717971 268483082
49 2025-07-30 18:44:50 85 2888447 2918447 267717971 268483082
50 2025-07-30 19:44:56 85 2888447 2918447 267717971 268483082
51 2025-07-30 20:44:57 85 2888447 2918447 267717971 268483082
52 2025-07-30 21:45:05 85 2888447 2918447 267717971 268483082
53 2025-07-30 22:45:12 85 2888447 2918447 267717971 268483082
54 2025-07-30 23:45:14 85 2888447 2918447 267717971 268483082
55 2025-07-31 00:45:24 85 2932388 2962388 267717971 269715348
56 2025-07-31 01:45:29 85 2932388 2962388 267717971 269715348
57 2025-07-31 02:45:38 85 2932388 2962388 267717971 269715348
58 2025-07-31 03:45:42 86 2963854 2993854 268573164 269323164
59 2025-07-31 04:45:51 86 2963854 2993854 268573164 269323164
60 2025-07-31 05:45:54 86 2963854 2993854 268573164 269323164
61 2025-07-31 06:46:02 86 2963854 2993854 268573164 269323164
62 2025-07-31 07:46:07 86 2963854 2993854 268573164 269323164
63 2025-07-31 08:46:17 87 3007192 3037192 269778365 270520939
64 2025-07-31 09:46:18 87 3007192 3037192 269778365 270520939
65 2025-07-31 10:46:21 88 3040098 3070098 270693231 271428525
66 2025-07-31 11:46:30 88 3040098 3070098 270693231 271428525
67 2025-07-31 12:46:36 88 3040098 3070098 270693231 271428525
68 2025-07-31 13:46:44 88 3040098 3070098 270693231 271428525
69 2025-07-31 14:46:54 88 3040098 3070098 270693231 271428525
70 2025-07-31 15:46:59 88 3040098 3070098 270693231 271428525
71 2025-07-31 16:47:05 89 3070067 3100067 271482785 272210764
72 2025-07-31 17:47:05 89 3070067 3100067 271482785 272210764
73 2025-07-31 18:47:12 89 3070067 3100067 271482785 272210764
74 2025-07-31 19:47:18 89 3070067 3100067 271482785 272210764
75 2025-07-31 20:47:24 89 3070067 3100067 271482785 272210764
76 2025-07-31 21:47:31 89 3070067 3100067 271482785 272210764
77 2025-07-31 22:47:36 90 3100506 3130506 272290845 273011652
78 2025-07-31 23:47:40 90 3100506 3130506 272290845 273011652
79 2025-08-01 00:47:48 90 3100506 3130506 272290845 273011652
80 2025-08-01 01:47:49 90 3100506 3130506 272290845 273011652
81 2025-08-01 02:47:50 90 3100506 3130506 272290845 273011652
82 2025-08-01 03:47:59 90 3100506 3130506 272290845 273011652
83 2025-08-01 04:48:02 90 3100506 3130506 272290845 273011652
84 2025-08-01 05:48:11 91 3130931 3160931 273081312 273794918
85 2025-08-01 06:48:16 91 3130931 3160931 273081312 273794918
86 2025-08-01 07:48:20 91 3130931 3160931 273081312 273794918
87 2025-08-01 08:48:25 91 3130931 3160931 273081312 273794918
88 2025-08-01 09:48:33 91 3130931 3160931 273081312 273794918
89 2025-08-01 10:48:44 91 3130931 3160931 273081312 273794918
90 2025-08-01 11:48:46 91 3130931 3160931 273081312 273794918
91 2025-08-01 12:48:55 92 3164943 3194943 273983137 274689684
92 2025-08-01 13:49:08 92 3164943 3194943 273983137 274689684
93 2025-08-01 14:49:09 92 3164943 3194943 273983137 274689684
94 2025-08-01 15:49:13 92 3164943 3194943 273983137 274689684
95 2025-08-01 16:49:15 92 3164943 3194943 273983137 274689684
96 2025-08-01 17:49:15 92 3164943 3194943 273983137 274689684
97 2025-08-01 18:49:22 93 3198424 3228424 274866179 275565643
98 2025-08-01 19:49:28 93 3198424 3228424 274866179 275565643
99 2025-08-01 20:49:36 93 3198424 3228424 274866179 275565643
100 2025-08-01 21:49:43 93 3198424 3228424 274866179 275565643
101 2025-08-01 22:49:46 93 3198424 3228424 274866179 275565643
102 2025-08-01 23:49:51 93 3198424 3228424 274866179 275565643
103 2025-08-02 00:50:00 93 3198424 3228424 274866179 275565643
104 2025-08-02 01:50:00 93 3198424 3228424 274866179 275565643
105 2025-08-02 02:50:11 93 3198424 3228424 274866179 275565643
106 2025-08-02 03:50:13 93 3198424 3228424 274866179 275565643
107 2025-08-02 04:50:16 93 3198424 3228424 274866179 275565643
108 2025-08-02 05:50:19 93 3198424 3228424 274866179 275565643
109 2025-08-02 06:50:27 93 3198424 3228424 274866179 275565643

View File

@@ -1,56 +0,0 @@
import csv
from datetime import datetime
import requests
PHASE_URL = "https://backend.dexrp.io/general/phase"
GENERAL_URL = "https://backend.dexrp.io/general"
def fetch_data(url):
try:
response = requests.get(url)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Error fetching data: {e}")
return None
def save_to_csv(filename, data):
try:
with open(filename, "a", newline="") as f:
writer = csv.writer(f)
if f.tell() == 0: # Write header if file is empty
writer.writerow(["datetime"] + list(data.keys()))
writer.writerow(
[datetime.now().strftime("%Y-%m-%d %H:%M:%S")] + list(data.values())
)
except Exception as e:
print(f"Error saving to {filename}: {e}")
def job():
# Phase data
phase_data = fetch_data(PHASE_URL)
if phase_data:
filtered_phase = {
"raised": phase_data.get("raised"),
"goal": phase_data.get("goal"),
}
save_to_csv("phase.csv", filtered_phase)
# General data
general_data = fetch_data(GENERAL_URL)
if general_data:
filtered_general = {
"roundIndex": general_data.get("roundIndex"),
"raisedAmount": general_data.get("raisedAmount"),
"raiseGoalAmount": general_data.get("raiseGoalAmount"),
"tokensSoldAmount": general_data.get("tokensSoldAmount"),
"tokensGoalAmount": general_data.get("tokensGoalAmount"),
}
save_to_csv("general.csv", filtered_general)
if __name__ == "__main__":
job()

240
main.py
View File

@@ -1,240 +0,0 @@
"""DEXRP价格数据收集与分析模块自动获取交易数据并生成每日统计"""
import json
import time
import subprocess
from datetime import datetime
from collections import defaultdict
import logging
from pathlib import Path
import requests
# 配置常量
API_URL = "https://backend.dexrp.io/vending/last" # DEXRP API地址
JSON_FILE = "price.json" # 价格数据存储文件
HASH_FILE = "processed.json" # 已处理交易哈希记录文件
LOG_DIR = "logs"
LOG_FILE_FORMAT = "%Y-%m-%d.log"
# 全局变量
SEEN_TXHASHES = set() # 内存中的已处理交易哈希集合
GIT_INTERVAL = 3600 # Git提交间隔(秒)
FETCH_INTERVAL = 10 # API轮询间隔(秒)
LOGGER = None # 添加全局logger变量
def setup_logging():
"""配置日志记录"""
global LOGGER # 声明使用全局logger
Path(LOG_DIR).mkdir(exist_ok=True)
log_file = Path("output.log")
logging.basicConfig(
level=logging.WARNING, # 只记录WARNING及以上级别
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler(log_file, encoding="utf-8"),
],
)
LOGGER = logging.getLogger(__name__) # 赋值给全局logger
return LOGGER
def fetch_latest_transactions():
"""从API获取最新交易数据并过滤已处理记录"""
try:
response = requests.get(API_URL, timeout=10)
response.raise_for_status()
transactions = response.json()
# transactions = json.loads(
# open("D:/DOWNLOADS/last.json", "r", encoding="utf-8").read()
# )
return [tx for tx in transactions if tx["transactionHash"] not in SEEN_TXHASHES]
except requests.RequestException as e:
LOGGER.error("API请求失败: %s", e)
return None
def calculate_daily_stats(transactions):
"""计算每日统计数据(开盘价、收盘价、最高价、最低价、交易量)"""
daily_data = defaultdict(
lambda: {
"open": None,
"close": None,
"high": float("-inf"),
"low": float("inf"),
"tokensSold": 0,
}
)
for tx in transactions:
# 使用本地时区转换时间戳
date = datetime.fromtimestamp(tx["blockTimestamp"]).strftime("%Y-%m-%d")
price = tx.get("price", 0)
tokens_sold = tx.get("tokensSold", 0)
if daily_data[date]["open"] is None:
daily_data[date]["open"] = price
daily_data[date]["close"] = price
daily_data[date]["high"] = max(daily_data[date]["high"], price)
daily_data[date]["low"] = min(daily_data[date]["low"], price)
daily_data[date]["tokensSold"] += tokens_sold
return [
{
"date": date,
"open": data["open"],
"close": data["close"],
"high": data["high"],
"low": data["low"],
"tokensSold": data["tokensSold"],
}
for date, data in daily_data.items()
]
def update_json_file(new_data):
"""Update JSON file with new transaction data."""
try:
LOGGER.info("开始更新JSON文件收到%d条新交易数据", len(new_data))
# 读取现有数据,如果文件不存在则初始化为空数组
try:
with open(JSON_FILE, "r", encoding="utf-8") as file:
existing_data = json.load(file)
except FileNotFoundError:
existing_data = []
# 确保existing_data是列表
if not isinstance(existing_data, list):
existing_data = []
# 计算每日统计数据
processed_data = calculate_daily_stats(new_data)
# 合并数据而不是追加
existing_dates = {item["date"]: item for item in existing_data}
for new_item in processed_data:
date = new_item["date"]
if date in existing_dates:
# 合并相同日期的记录
existing_item = existing_dates[date]
existing_item["close"] = new_item["close"]
existing_item["high"] = max(existing_item["high"], new_item["high"])
existing_item["low"] = min(existing_item["low"], new_item["low"])
existing_item["tokensSold"] += new_item["tokensSold"]
else:
existing_data.append(new_item)
existing_dates[date] = new_item
# 写回文件
with open(JSON_FILE, "w", encoding="utf-8") as file:
json.dump(existing_data, file, indent=4, ensure_ascii=False)
LOGGER.info(
"成功更新%s,合并%d条记录,总计%d条记录",
JSON_FILE,
len(processed_data),
len(existing_data),
)
except (FileNotFoundError, json.JSONDecodeError, IOError) as e:
LOGGER.error("更新JSON文件时发生错误: %s,跳过本次更新", e)
def git_commit_and_push():
"""自动提交并推送数据更新到Git仓库"""
try:
subprocess.run(["git", "add", "."], check=True)
subprocess.run(
[
"git",
"commit",
"--no-verify",
"--no-gpg-sign",
"-m",
f"Auto update at {datetime.now()}",
],
check=True,
)
subprocess.run(["git", "push"], check=True)
LOGGER.info("Git提交成功")
except subprocess.CalledProcessError as e:
LOGGER.error("Git操作失败: %s", e)
def general_info():
"""获取general信息"""
LOGGER.info("获取general信息")
try:
process = subprocess.Popen(["python3", "general.py"])
process.wait()
except subprocess.CalledProcessError as e:
LOGGER.error("获取general信息失败: %s", e)
def load_processed_hashes():
"""Load processed transaction hashes from file."""
try:
with open(HASH_FILE, "r", encoding="utf-8") as file:
return set(json.load(file))
except (FileNotFoundError, json.JSONDecodeError):
return set()
def save_processed_hashes():
"""Save processed transaction hashes to file."""
try:
# 读取现有数据
try:
with open(HASH_FILE, "r", encoding="utf-8") as file:
existing_data = json.load(file)
except (FileNotFoundError, json.JSONDecodeError):
existing_data = []
# 合并新哈希并去重,保持原有顺序
new_hashes = [h for h in SEEN_TXHASHES if h not in existing_data]
updated_data = existing_data + new_hashes
# 写回文件
with open(HASH_FILE, "w", encoding="utf-8") as file:
json.dump(updated_data, file, indent=4, ensure_ascii=False)
LOGGER.info(
"成功更新%s,新增%d条哈希,总计%d条记录",
HASH_FILE,
len(new_hashes),
len(updated_data),
)
except IOError as e:
LOGGER.error("保存已处理交易哈希时发生错误: %s", e)
def main():
"""主循环,定期获取数据并更新"""
global SEEN_TXHASHES, LOGGER # 添加logger到全局声明
setup_logging() # 初始化logger
LOGGER.info("程序启动")
SEEN_TXHASHES = load_processed_hashes()
last_git_time = 0
while True:
setup_logging()
try:
if new_transactions := fetch_latest_transactions():
LOGGER.info("获取到%d条新交易", len(new_transactions))
SEEN_TXHASHES.update(tx["transactionHash"] for tx in new_transactions)
save_processed_hashes()
update_json_file(new_transactions)
current_time = time.time()
if current_time - last_git_time >= GIT_INTERVAL:
general_info()
git_commit_and_push()
last_git_time = current_time
time.sleep(FETCH_INTERVAL)
except Exception as e:
LOGGER.error("错误: %s,继续运行...", e)
continue
if __name__ == "__main__":
main()

View File

@@ -1,53 +0,0 @@
2025-07-30 16:26:59,241 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-30 17:08:16,183 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-30 18:00:37,882 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-30 18:14:15,919 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-30 18:57:54,190 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-30 19:06:30,949 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-30 21:31:43,708 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-30 22:05:35,881 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-30 22:53:45,933 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 01:33:49,358 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 02:21:44,755 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 02:44:44,487 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 03:07:42,037 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 03:12:08,688 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 06:31:35,322 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 09:10:02,769 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 11:08:50,444 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 12:01:13,608 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 13:57:56,038 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 18:07:59,044 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 18:32:27,451 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-07-31 18:41:48,088 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 19:56:08,758 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 20:51:30,511 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-07-31 22:13:08,469 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 01:08:19,856 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 01:26:33,619 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 01:29:52,217 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 01:59:45,843 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 02:18:36,149 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 03:28:19,305 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 04:02:04,163 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 04:12:27,719 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 04:56:19,457 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 05:00:23,419 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 05:31:00,950 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 07:13:03,748 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 07:31:16,546 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 07:56:25,597 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 09:04:27,566 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 09:52:30,350 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 13:47:34,344 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 14:44:01,207 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 17:04:00,712 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 18:19:51,535 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 21:41:31,288 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 21:56:00,077 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-01 23:09:57,968 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-01 23:45:06,164 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)
2025-08-02 03:19:01,398 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-02 03:29:19,678 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-02 06:20:19,726 - ERROR - API请求失败: 500 Server Error: Internal Server Error for url: https://backend.dexrp.io/vending/last
2025-08-02 06:45:07,612 - ERROR - API请求失败: HTTPSConnectionPool(host='backend.dexrp.io', port=443): Read timed out. (read timeout=10)

108
phase.csv
View File

@@ -1,108 +0,0 @@
datetime,raised,goal
2025-07-28 21:18:45,2650422,2673289
2025-07-28 22:18:50,2659808,2673289
2025-07-28 23:18:56,2664836,2673289
2025-07-29 00:18:57,2667681,2673289
2025-07-29 01:18:59,2671583,2673289
2025-07-29 02:19:08,2674014,2704014
2025-07-29 03:19:16,2675925,2704014
2025-07-29 04:19:22,2677924,2704014
2025-07-29 05:19:23,2680198,2704014
2025-07-29 06:19:25,2681135,2704014
2025-07-29 07:19:30,2683214,2704014
2025-07-29 08:19:32,2686597,2704014
2025-07-29 09:19:41,2687706,2704014
2025-07-29 10:19:48,2692883,2704014
2025-07-29 11:19:53,2701794,2704014
2025-07-29 12:19:57,2713194,2704014
2025-07-29 13:20:01,2715258,2743194
2025-07-29 14:20:08,2717611,2743194
2025-07-29 15:20:19,2718279,2743194
2025-07-29 16:20:19,2722522,2743194
2025-07-29 17:20:28,2727797,2743194
2025-07-29 18:20:35,2730601,2743194
2025-07-29 19:20:43,2737798,2743194
2025-07-29 20:20:51,2747457,2774582
2025-07-29 21:20:51,2749383,2774582
2025-07-29 22:20:59,2765992,2774582
2025-07-29 23:21:04,2771198,2774582
2025-07-30 00:21:12,2780516,2806266
2025-07-30 01:21:12,2788003,2806266
2025-07-30 02:21:18,2792997,2806266
2025-07-30 03:21:20,2794519,2806266
2025-07-30 04:21:40,2817687,2847387
2025-07-30 05:21:42,2825111,2847387
2025-07-30 06:21:44,2828586,2847387
2025-07-30 07:21:45,2838822,2847387
2025-07-30 08:21:54,2859846,2883494
2025-07-30 09:21:56,2870182,2883494
2025-07-30 10:21:57,2876086,2883494
2025-07-30 11:21:58,2878111,2883494
2025-07-30 12:22:01,2881929,2883494
2025-07-30 13:22:10,2884374,2883494
2025-07-30 14:22:14,2884774,2883494
2025-07-30 15:22:20,2888167,2883494
2025-07-30 15:44:40,2888343,2883494
2025-07-30 16:44:41,2888447,2918447
2025-07-30 17:44:47,2893375,2918447
2025-07-30 18:44:49,2896499,2918447
2025-07-30 19:44:56,2902843,2918447
2025-07-30 20:44:57,2915558,2918447
2025-07-30 21:45:05,2932078,2918447
2025-07-30 22:45:12,2932388,2918447
2025-07-30 23:45:14,2932388,2918447
2025-07-31 00:45:24,2951737,2962388
2025-07-31 01:45:29,2958290,2962388
2025-07-31 02:45:37,2963854,2962388
2025-07-31 03:45:42,2970307,2993854
2025-07-31 04:45:51,2972355,2993854
2025-07-31 05:45:53,2980249,2993854
2025-07-31 06:46:01,2985523,2993854
2025-07-31 07:46:06,2989332,2993854
2025-07-31 08:46:16,3008901,3037192
2025-07-31 09:46:18,3033675,3037192
2025-07-31 10:46:20,3043430,3070098
2025-07-31 11:46:30,3051541,3070098
2025-07-31 12:46:36,3059309,3070098
2025-07-31 13:46:44,3062896,3070098
2025-07-31 14:46:53,3068408,3070098
2025-07-31 15:46:58,3069261,3070098
2025-07-31 16:47:04,3075352,3100067
2025-07-31 17:47:05,3076792,3100067
2025-07-31 18:47:12,3089267,3100067
2025-07-31 19:47:18,3090758,3100067
2025-07-31 20:47:23,3096627,3100067
2025-07-31 21:47:30,3099064,3100067
2025-07-31 22:47:36,3101120,3130506
2025-07-31 23:47:39,3105800,3130506
2025-08-01 00:47:47,3111062,3130506
2025-08-01 01:47:49,3117826,3130506
2025-08-01 02:47:49,3126379,3130506
2025-08-01 03:47:58,3127390,3130506
2025-08-01 04:48:01,3128035,3130506
2025-08-01 05:48:11,3130931,3160931
2025-08-01 06:48:15,3132720,3160931
2025-08-01 07:48:19,3134702,3160931
2025-08-01 08:48:25,3136575,3160931
2025-08-01 09:48:33,3141283,3160931
2025-08-01 10:48:44,3151789,3160931
2025-08-01 11:48:45,3152681,3160931
2025-08-01 12:48:54,3164943,3194943
2025-08-01 13:49:08,3168685,3194943
2025-08-01 14:49:08,3170083,3194943
2025-08-01 15:49:13,3186783,3194943
2025-08-01 16:49:15,3190301,3194943
2025-08-01 17:49:15,3192437,3194943
2025-08-01 18:49:22,3198424,3228424
2025-08-01 19:49:28,3206169,3228424
2025-08-01 20:49:36,3207959,3228424
2025-08-01 21:49:43,3213442,3228424
2025-08-01 22:49:45,3215515,3228424
2025-08-01 23:49:51,3220797,3228424
2025-08-02 00:49:59,3223937,3228424
2025-08-02 01:50:00,3225006,3228424
2025-08-02 02:50:11,3229111,3228424
2025-08-02 03:50:13,3230643,3228424
2025-08-02 04:50:16,3233085,3228424
2025-08-02 05:50:19,3238659,3228424
2025-08-02 06:50:26,3248066,3228424
1 datetime raised goal
2 2025-07-28 21:18:45 2650422 2673289
3 2025-07-28 22:18:50 2659808 2673289
4 2025-07-28 23:18:56 2664836 2673289
5 2025-07-29 00:18:57 2667681 2673289
6 2025-07-29 01:18:59 2671583 2673289
7 2025-07-29 02:19:08 2674014 2704014
8 2025-07-29 03:19:16 2675925 2704014
9 2025-07-29 04:19:22 2677924 2704014
10 2025-07-29 05:19:23 2680198 2704014
11 2025-07-29 06:19:25 2681135 2704014
12 2025-07-29 07:19:30 2683214 2704014
13 2025-07-29 08:19:32 2686597 2704014
14 2025-07-29 09:19:41 2687706 2704014
15 2025-07-29 10:19:48 2692883 2704014
16 2025-07-29 11:19:53 2701794 2704014
17 2025-07-29 12:19:57 2713194 2704014
18 2025-07-29 13:20:01 2715258 2743194
19 2025-07-29 14:20:08 2717611 2743194
20 2025-07-29 15:20:19 2718279 2743194
21 2025-07-29 16:20:19 2722522 2743194
22 2025-07-29 17:20:28 2727797 2743194
23 2025-07-29 18:20:35 2730601 2743194
24 2025-07-29 19:20:43 2737798 2743194
25 2025-07-29 20:20:51 2747457 2774582
26 2025-07-29 21:20:51 2749383 2774582
27 2025-07-29 22:20:59 2765992 2774582
28 2025-07-29 23:21:04 2771198 2774582
29 2025-07-30 00:21:12 2780516 2806266
30 2025-07-30 01:21:12 2788003 2806266
31 2025-07-30 02:21:18 2792997 2806266
32 2025-07-30 03:21:20 2794519 2806266
33 2025-07-30 04:21:40 2817687 2847387
34 2025-07-30 05:21:42 2825111 2847387
35 2025-07-30 06:21:44 2828586 2847387
36 2025-07-30 07:21:45 2838822 2847387
37 2025-07-30 08:21:54 2859846 2883494
38 2025-07-30 09:21:56 2870182 2883494
39 2025-07-30 10:21:57 2876086 2883494
40 2025-07-30 11:21:58 2878111 2883494
41 2025-07-30 12:22:01 2881929 2883494
42 2025-07-30 13:22:10 2884374 2883494
43 2025-07-30 14:22:14 2884774 2883494
44 2025-07-30 15:22:20 2888167 2883494
45 2025-07-30 15:44:40 2888343 2883494
46 2025-07-30 16:44:41 2888447 2918447
47 2025-07-30 17:44:47 2893375 2918447
48 2025-07-30 18:44:49 2896499 2918447
49 2025-07-30 19:44:56 2902843 2918447
50 2025-07-30 20:44:57 2915558 2918447
51 2025-07-30 21:45:05 2932078 2918447
52 2025-07-30 22:45:12 2932388 2918447
53 2025-07-30 23:45:14 2932388 2918447
54 2025-07-31 00:45:24 2951737 2962388
55 2025-07-31 01:45:29 2958290 2962388
56 2025-07-31 02:45:37 2963854 2962388
57 2025-07-31 03:45:42 2970307 2993854
58 2025-07-31 04:45:51 2972355 2993854
59 2025-07-31 05:45:53 2980249 2993854
60 2025-07-31 06:46:01 2985523 2993854
61 2025-07-31 07:46:06 2989332 2993854
62 2025-07-31 08:46:16 3008901 3037192
63 2025-07-31 09:46:18 3033675 3037192
64 2025-07-31 10:46:20 3043430 3070098
65 2025-07-31 11:46:30 3051541 3070098
66 2025-07-31 12:46:36 3059309 3070098
67 2025-07-31 13:46:44 3062896 3070098
68 2025-07-31 14:46:53 3068408 3070098
69 2025-07-31 15:46:58 3069261 3070098
70 2025-07-31 16:47:04 3075352 3100067
71 2025-07-31 17:47:05 3076792 3100067
72 2025-07-31 18:47:12 3089267 3100067
73 2025-07-31 19:47:18 3090758 3100067
74 2025-07-31 20:47:23 3096627 3100067
75 2025-07-31 21:47:30 3099064 3100067
76 2025-07-31 22:47:36 3101120 3130506
77 2025-07-31 23:47:39 3105800 3130506
78 2025-08-01 00:47:47 3111062 3130506
79 2025-08-01 01:47:49 3117826 3130506
80 2025-08-01 02:47:49 3126379 3130506
81 2025-08-01 03:47:58 3127390 3130506
82 2025-08-01 04:48:01 3128035 3130506
83 2025-08-01 05:48:11 3130931 3160931
84 2025-08-01 06:48:15 3132720 3160931
85 2025-08-01 07:48:19 3134702 3160931
86 2025-08-01 08:48:25 3136575 3160931
87 2025-08-01 09:48:33 3141283 3160931
88 2025-08-01 10:48:44 3151789 3160931
89 2025-08-01 11:48:45 3152681 3160931
90 2025-08-01 12:48:54 3164943 3194943
91 2025-08-01 13:49:08 3168685 3194943
92 2025-08-01 14:49:08 3170083 3194943
93 2025-08-01 15:49:13 3186783 3194943
94 2025-08-01 16:49:15 3190301 3194943
95 2025-08-01 17:49:15 3192437 3194943
96 2025-08-01 18:49:22 3198424 3228424
97 2025-08-01 19:49:28 3206169 3228424
98 2025-08-01 20:49:36 3207959 3228424
99 2025-08-01 21:49:43 3213442 3228424
100 2025-08-01 22:49:45 3215515 3228424
101 2025-08-01 23:49:51 3220797 3228424
102 2025-08-02 00:49:59 3223937 3228424
103 2025-08-02 01:50:00 3225006 3228424
104 2025-08-02 02:50:11 3229111 3228424
105 2025-08-02 03:50:13 3230643 3228424
106 2025-08-02 04:50:16 3233085 3228424
107 2025-08-02 05:50:19 3238659 3228424
108 2025-08-02 06:50:26 3248066 3228424

View File

@@ -5,54 +5,6 @@
"close": 0.03515,
"high": 0.03515,
"low": 0.03515,
"tokensSold": 218034
},
{
"date": "2025-07-28",
"open": 0.03515,
"close": 0.03657,
"high": 0.03657,
"low": 0.03515,
"tokensSold": 2502385.528208562
},
{
"date": "2025-07-29",
"open": 0.03657,
"close": 0.03768,
"high": 0.03768,
"low": 0.03621,
"tokensSold": 3445850.2247805195
},
{
"date": "2025-07-30",
"open": 0.03806,
"close": 0.0396,
"high": 0.0396,
"low": 0.03768,
"tokensSold": 5135569.699422795
},
{
"date": "2025-07-31",
"open": 0.0396,
"close": 0.04162,
"high": 0.04162,
"low": 0.0396,
"tokensSold": 4346084.258559157
},
{
"date": "2025-08-01",
"open": 0.04162,
"close": 0.04289,
"high": 0.04289,
"low": 0.04162,
"tokensSold": 3003581.3554545348
},
{
"date": "2025-08-02",
"open": 0.04289,
"close": 0.04289,
"high": 0.04289,
"low": 0.04289,
"tokensSold": 664989.501277051
"tokensSold": 129209
}
]

File diff suppressed because it is too large Load Diff