File size: 970 Bytes
db0a14e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

import os
import clickhouse_connect
from dotenv import load_dotenv

load_dotenv()

def check_max_trades():
    try:
        client = clickhouse_connect.get_client(
            host=os.getenv("CLICKHOUSE_HOST"),
            port=int(os.getenv("CLICKHOUSE_HTTP_PORT")),
            secure=False
        )
        
        print("Connected to ClickHouse.")
        
        # 1. Find the token with the most trades
        print("Querying max trade count per token (this might take a moment)...")
        query = """
        SELECT base_address, count(*) as c 
        FROM trades 
        GROUP BY base_address 
        ORDER BY c DESC 
        LIMIT 5
        """
        result = client.query(query)
        
        print("Top 5 Tokens by Trade Count:")
        for row in result.result_rows:
            print(f"Token: {row[0]}, Count: {row[1]}")
            
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    check_max_trades()