Compare commits
220 Commits
47feeda357
...
main
Author | SHA1 | Date | |
---|---|---|---|
1a5073fff2 | |||
c4a3d40ed9 | |||
71a2861bd1 | |||
87ce2b8061 | |||
23071350dd | |||
1ff38309ba | |||
496d279459 | |||
f36b97524e | |||
008058cd26 | |||
e0e1a2f505 | |||
5f386174f3 | |||
a88575bf4c | |||
a9b29d0008 | |||
5386e686fc | |||
e6f3d0408d | |||
a4e1243125 | |||
36cbb1bb0d | |||
ea723f2fff | |||
c445aaf94a | |||
a45ae35a1b | |||
75f8124ac5 | |||
2758697d32 | |||
4a09e8a6b2 | |||
f2981f1bbf | |||
d4734d0aed | |||
dc61188881 | |||
080c99bb47 | |||
2b47f6e5e6 | |||
b1f5346fa1 | |||
824334da46 | |||
9ce60cb550 | |||
1e59142e20 | |||
22e55a1567 | |||
395db13f30 | |||
9a0ea28506 | |||
c77c361b8b | |||
55ee428661 | |||
bcfc180ae3 | |||
197dbc88ba | |||
552d98889f | |||
50f41f735a | |||
c0d85038f2 | |||
e3819eff1b | |||
72922a0d09 | |||
e7a7ccd2a5 | |||
68cf878e04 | |||
fb245ce808 | |||
5f71cf49e1 | |||
911764f97e | |||
a521d99ea7 | |||
ac7fe06da9 | |||
0b9acba474 | |||
5cda70a552 | |||
2769233db1 | |||
8d5fcc195b | |||
2febce944f | |||
a4c833e25b | |||
dbe9ebecb6 | |||
de7c1d7d38 | |||
5c51ce164b | |||
bda904b712 | |||
b790492740 | |||
ac2d269336 | |||
09ec233165 | |||
ee802d07e7
|
|||
1b7110a166 | |||
9be5fb5f1b | |||
5c0851cea1 | |||
779b92cd71 | |||
0700685901 | |||
6f4a67a02e | |||
8312c5775e | |||
1bc8bd698b | |||
175470ab6e | |||
34e4285394 | |||
60c4300cb1 | |||
a93d3dfa7c | |||
b74cf94e6f | |||
58cd01543b | |||
f1ba382d4a | |||
c0c886c630 | |||
5b06033bb5 | |||
991942f044 | |||
0877d1feba | |||
a99e5b075f | |||
6b0b104051 | |||
bd0fdaa17a | |||
7c5773bff6 | |||
b4ee5fea6f | |||
6fb10ee371 | |||
6a13c44ebc | |||
f58529362a | |||
55b8079454 | |||
1cf5f42199 | |||
16082bafb4 | |||
b88a006f0e | |||
7a834a9d8b | |||
4f2a5a8316 | |||
b1a544e316 | |||
a2b41dfd8c | |||
ac636dba8c | |||
f0315a5ecb | |||
21046689cb | |||
5fd598de58 | |||
9d6b7b4d2f | |||
b98888fcfe | |||
f62d2cc9e7 | |||
9c1d64efb4 | |||
04b141dccd | |||
afba0eb384
|
|||
3dee6a37eb
|
|||
3d9dc5d7fc | |||
b36a4f1ba7 | |||
f77d2563bb
|
|||
ef5ccf74df
|
|||
d47faec554 | |||
bd5979bd29
|
|||
3ba6ef1fd5 | |||
066f5e943d | |||
06d135d5e8
|
|||
b7e510246d
|
|||
2f08d1906b | |||
312596895e
|
|||
4d0a93f720 | |||
03437b147a | |||
e953ee65e3 | |||
0c8cd60cc1 | |||
a2c0b39721 | |||
30c02abbee | |||
cc1e4d6309 | |||
33216ec2b3 | |||
431946df0c | |||
04e30f1657 | |||
fc72d604d4 | |||
1108516a67 | |||
09c19c2c60 | |||
6992b0e556 | |||
2e9f868186 | |||
7e247e52a6 | |||
acf5f26884 | |||
91640d5f52 | |||
17180dba80 | |||
84db2761d4 | |||
456d40cbe0 | |||
62fc19ab0e | |||
90f55547a4 | |||
50c4221e1b | |||
a72e37e5a2 | |||
66606937eb | |||
0c49efbf12 | |||
f999ed05bb | |||
ad4f5c2afc | |||
9d10f31f13 | |||
4abda9764c | |||
d8c3e04ee4 | |||
299e3d5930 | |||
502ba815e0 | |||
967e7e998f | |||
a8dcd7bba2 | |||
8d884ac008 | |||
75fc8ec946 | |||
c680b6c237 | |||
c0604fcce6 | |||
c62bd69b28 | |||
774e04450a | |||
a40789374f | |||
d6fd23358a | |||
bdd853248f | |||
6fcb711a15 | |||
ea7c019f17 | |||
0c909d9b7d | |||
9acec913fa | |||
540da52511 | |||
d2bc99a1d6 | |||
4287b45f0a | |||
438e0d5550 | |||
63c3eca577 | |||
fc2b4ec315 | |||
4fd5bc763e | |||
198dc92682 | |||
d0d71cb82c | |||
95a49b9e43 | |||
c6a672d783 | |||
3d9cf05f93 | |||
8779f1405e | |||
5eb720a147 | |||
9d32ee0635 | |||
aa6339b390 | |||
02768ba1bc | |||
6a4f3eb5a1 | |||
828adbd57f | |||
cb133d7fc0 | |||
527913bd3c | |||
e0824570ff | |||
384d315d3d | |||
64f2f6e962 | |||
4c9aef6515 | |||
3b06d68c80 | |||
b85c5b482f | |||
666937483b | |||
3dcfddf56a | |||
2fed40b16a | |||
be1b6ba805 | |||
dc97160eff | |||
dafa2a1537 | |||
fb3bc8627e | |||
9854de5ba4 | |||
173bfa677c | |||
e1a0c0ea0f | |||
b34d7834ae | |||
ab11737bbb | |||
da77ecb5f3 | |||
e18647872a | |||
f9f1c20658 | |||
2fdbb94c28
|
|||
2e9bd0af69 | |||
f9a17a95e9 | |||
a49e3c55df | |||
eec1b7c481 | |||
dbdf8af9aa
|
109
general.csv
Normal file
109
general.csv
Normal file
@@ -0,0 +1,109 @@
|
||||
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
|
|
56
general.py
Normal file
56
general.py
Normal file
@@ -0,0 +1,56 @@
|
||||
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
Normal file
240
main.py
Normal file
@@ -0,0 +1,240 @@
|
||||
"""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()
|
53
output.log
Normal file
53
output.log
Normal file
@@ -0,0 +1,53 @@
|
||||
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
Normal file
108
phase.csv
Normal file
@@ -0,0 +1,108 @@
|
||||
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,2 +0,0 @@
|
||||
日期,当日最高,当日最低,报价,成交量
|
||||
20250727,0.03515,0.03515,0.03515,0
|
|
58
price.json
Normal file
58
price.json
Normal file
@@ -0,0 +1,58 @@
|
||||
[
|
||||
{
|
||||
"date": "2025-07-27",
|
||||
"open": 0.03515,
|
||||
"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
|
||||
}
|
||||
]
|
1612
processed.json
Normal file
1612
processed.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user