Dumb.io commited on
Commit
f03804c
·
1 Parent(s): 262d0f9

Initial commit: Add Gate.io market making dashboard

Browse files
Files changed (3) hide show
  1. .gitignore +4 -0
  2. gate_tracker.py +167 -0
  3. requirements.txt +9 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .env
2
+ __pycache__/
3
+ *.pyc
4
+ .DS_Store
gate_tracker.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import ccxt
3
+ import pandas as pd
4
+ import numpy as np
5
+ import time
6
+ from datetime import datetime
7
+ import os
8
+ from dotenv import load_dotenv
9
+
10
+ # Load environment variables
11
+ load_dotenv()
12
+
13
+ # Must be the first Streamlit command
14
+ st.set_page_config(layout="wide")
15
+
16
+ # Custom CSS for neumorphic orange and black theme
17
+ st.markdown("""
18
+ <style>
19
+ .stApp {
20
+ background-color: #1a1a1a;
21
+ color: #ff8c00;
22
+ }
23
+ .stDataFrame {
24
+ background-color: #2a2a2a;
25
+ border-radius: 10px;
26
+ box-shadow: 5px 5px 10px #000000, -5px -5px 10px #3a3a3a;
27
+ padding: 10px;
28
+ }
29
+ .stDataFrame td {
30
+ background-color: #2a2a2a;
31
+ color: #ff8c00;
32
+ }
33
+ .stDataFrame th {
34
+ background-color: #1a1a1a;
35
+ color: #ff8c00;
36
+ }
37
+ .stTitle {
38
+ color: #ff8c00;
39
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
40
+ }
41
+ .stMarkdown {
42
+ color: #ff8c00;
43
+ }
44
+ .stSlider > div > div > div {
45
+ background-color: #ff8c00;
46
+ }
47
+ </style>
48
+ """, unsafe_allow_html=True)
49
+
50
+ # Initialize Gate.io Futures
51
+ exchange = ccxt.gateio({
52
+ 'options': {'defaultType': 'swap'},
53
+ 'enableRateLimit': True
54
+ })
55
+
56
+ st.title("Gate.io Futures Live Data")
57
+
58
+ # Position Control Parameters
59
+ col1, col2, col3 = st.columns(3)
60
+
61
+ with col1:
62
+ min_spread = st.slider("Minimum Spread %", 0.3, 5.0, 0.5, 0.1)
63
+ min_volume = st.slider("Minimum 24h Volume (USDT)", 100000, 1000000, 200000, 10000)
64
+
65
+ with col2:
66
+ max_positions = st.slider("Max Active Positions", 1, 10, 3, 1)
67
+ dca_multiplier = st.slider("DCA Size Multiplier", 1.0, 5.0, 2.0, 0.5)
68
+
69
+ with col3:
70
+ hedge_ratio = st.slider("Hedge Ratio", 0.5, 2.0, 1.0, 0.1)
71
+ leverage = st.slider("Leverage", 1, 10, 3, 1)
72
+
73
+ def fetch_market_data():
74
+ try:
75
+ markets = exchange.load_markets()
76
+ usdt_pairs = [symbol for symbol in markets.keys()
77
+ if "/USDT" in symbol and markets[symbol].get("type") == "swap"]
78
+
79
+ data = []
80
+ for symbol in usdt_pairs:
81
+ try:
82
+ ticker = exchange.fetch_ticker(symbol)
83
+ price = ticker['last']
84
+ volume_24h = ticker['quoteVolume']
85
+
86
+ orderbook = exchange.fetch_order_book(symbol)
87
+ if orderbook['asks'] and orderbook['bids']:
88
+ spread = orderbook['asks'][0][0] - orderbook['bids'][0][0]
89
+ spread_pct = (spread / price) * 100
90
+
91
+ # Calculate liquidity metrics
92
+ bid_depth = sum(bid[1] for bid in orderbook['bids'][:5])
93
+ ask_depth = sum(ask[1] for ask in orderbook['asks'][:5])
94
+ total_depth = bid_depth + ask_depth
95
+
96
+ # Calculate volatility
97
+ ohlcv = exchange.fetch_ohlcv(symbol, timeframe='1h', limit=24)
98
+ if len(ohlcv) > 0:
99
+ prices = [x[4] for x in ohlcv] # Close prices
100
+ volatility = np.std(prices) / np.mean(prices) * 100
101
+ else:
102
+ volatility = 0
103
+
104
+ # Calculate market making score (0-100)
105
+ spread_score = max(0, 100 - (spread_pct * 20)) # Lower spread = higher score
106
+ volume_score = min(100, volume_24h / min_volume * 100) # Higher volume = higher score
107
+ depth_score = min(100, total_depth / 100) # Higher depth = higher score
108
+ volatility_score = max(0, 100 - (volatility * 10)) # Lower volatility = higher score
109
+
110
+ mm_score = (spread_score + volume_score + depth_score + volatility_score) / 4
111
+
112
+ if volume_24h >= min_volume and spread_pct >= min_spread:
113
+ data.append({
114
+ 'Symbol': symbol,
115
+ 'Price': price,
116
+ 'Spread %': spread_pct,
117
+ '24h Volume (USDT)': volume_24h,
118
+ 'Total Depth': total_depth,
119
+ 'Volatility %': volatility,
120
+ 'MM Score': mm_score
121
+ })
122
+ except:
123
+ continue
124
+
125
+ if not data:
126
+ return None
127
+
128
+ df = pd.DataFrame(data)
129
+ df = df.dropna()
130
+ return df
131
+
132
+ except:
133
+ return None
134
+
135
+ # Create containers for tables
136
+ spread_container = st.empty()
137
+ position_container = st.empty()
138
+
139
+ while True:
140
+ try:
141
+ df = fetch_market_data()
142
+
143
+ if df is not None and not df.empty:
144
+ # Sort by market making score (highest first)
145
+ df_sorted = df.sort_values(by='MM Score', ascending=False)
146
+
147
+ # Update spread data
148
+ with spread_container.container():
149
+ st.markdown("### 📈 Best Market Making Opportunities")
150
+ st.dataframe(
151
+ df_sorted[['Symbol', 'Price', 'Spread %', '24h Volume (USDT)', 'MM Score']].head(33),
152
+ use_container_width=True
153
+ )
154
+
155
+ # Update position data
156
+ with position_container.container():
157
+ st.markdown("### 💰 Active Positions")
158
+ st.dataframe(
159
+ df_sorted[['Symbol', 'Price', 'Spread %', 'Total Depth', 'Volatility %']].head(max_positions),
160
+ use_container_width=True
161
+ )
162
+
163
+ time.sleep(3) # Update every 3 seconds
164
+
165
+ except:
166
+ time.sleep(3)
167
+ continue
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ requests
2
+ ccxt==4.4.72
3
+ websockets
4
+ numpy==2.2.4
5
+ asyncio
6
+ pandas==2.2.3
7
+ nest_asyncio
8
+ streamlit==1.44.1
9
+ rich==14.0.0