growthex commited on
Commit
138f2ed
·
verified ·
1 Parent(s): d4dac02

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +83 -58
main.py CHANGED
@@ -5,7 +5,6 @@ from datetime import datetime
5
  import sys
6
 
7
  # --- কনফিগারেশন ---
8
- # ফেমাস ৩০টি কয়েন (MEXC)
9
  COINS = [
10
  'BTC/USDT', 'ETH/USDT', 'SOL/USDT', 'BNB/USDT', 'XRP/USDT', 'DOGE/USDT',
11
  'ADA/USDT', 'AVAX/USDT', 'TRX/USDT', 'DOT/USDT', 'LINK/USDT', 'MATIC/USDT',
@@ -15,84 +14,110 @@ COINS = [
15
  ]
16
 
17
  TIMEFRAME = '15m'
18
- ATR_PERIOD = 14
19
- WICK_DEPTH = 0.4 # ATR এর ৪০% নিচে এন্ট্রি
20
 
21
- # পাবলিক কানেকশন (API Key লাগবে না)
22
  exchange = ccxt.mexc({
23
  'enableRateLimit': True,
24
  'options': {'defaultType': 'swap'}
25
  })
26
 
27
- def fetch_data(symbol):
 
 
 
 
 
 
 
 
 
 
28
  try:
29
- ohlcv = exchange.fetch_ohlcv(symbol, TIMEFRAME, limit=20)
 
30
  df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
31
  order_book = exchange.fetch_order_book(symbol, limit=50)
32
- return df, order_book
33
- except Exception as e:
34
- return None, None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
- def calculate_logic(df, order_book):
37
- # ATR ক্যালকুলেশন
38
- df['tr'] = df[['high', 'low', 'close']].max(axis=1) - df[['high', 'low', 'close']].min(axis=1)
39
- atr = df['tr'].rolling(window=ATR_PERIOD).mean().iloc[-1]
40
-
41
- # ইমব্যালেন্স (Godzilla Formula)
42
- bids = order_book['bids']
43
- asks = order_book['asks']
44
- bid_vol = sum([b[1] for b in bids])
45
- ask_vol = sum([a[1] for a in asks])
46
-
47
- imbalance = (bid_vol - ask_vol) / (bid_vol + ask_vol)
48
-
49
- return atr, imbalance
50
 
51
  def scan_market():
52
- # লগ প্রিন্ট করা হচ্ছে
53
- print(f"\n--- 🚀 SCANNING TOP 30 COINS [{datetime.now().strftime('%H:%M:%S')}] ---")
54
- sys.stdout.flush() # লগ যাতে সাথে সাথে দেখায়
55
 
56
  for symbol in COINS:
57
- df, order_book = fetch_data(symbol)
58
 
59
- if df is not None:
60
- current_price = order_book['bids'][0][0]
61
- atr, imbalance = calculate_logic(df, order_book)
62
 
63
- # --- Wick Sniper Strategy ---
64
-
65
- # ১. বায়ার স্ট্রং (BUY SIGNAL)
66
- if imbalance > 0.15:
67
- limit_buy_price = current_price - (atr * WICK_DEPTH)
68
- stop_loss = limit_buy_price - (atr * 0.5)
69
- take_profit = limit_buy_price + (atr * 1.0)
70
 
71
- print(f"✅ {symbol} | Imbalance: {imbalance:.2f} (BUYERS STRONG)")
72
- print(f" 👉 Current: {current_price}")
73
- print(f" 🎯 LIMIT BUY ORDER: {limit_buy_price:.4f}")
74
- print(f" 🛑 SL: {stop_loss:.4f} | 💰 TP: {take_profit:.4f}")
75
- print("-" * 40)
76
-
77
- # ২. সেলার স্ট্রং (SELL SIGNAL)
78
- elif imbalance < -0.15:
79
- limit_sell_price = current_price + (atr * WICK_DEPTH)
80
- stop_loss = limit_sell_price + (atr * 0.5)
81
- take_profit = limit_sell_price - (atr * 1.0)
82
 
83
- print(f"🔻 {symbol} | Imbalance: {imbalance:.2f} (SELLERS STRONG)")
84
- print(f" 👉 Current: {current_price}")
85
- print(f" 🎯 LIMIT SELL ORDER: {limit_sell_price:.4f}")
86
- print(f" 🛑 SL: {stop_loss:.4f} | 💰 TP: {take_profit:.4f}")
87
- print("-" * 40)
88
-
89
- sys.stdout.flush() # ফোর্স লগ প্রিন্ট
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
- time.sleep(0.5)
92
 
93
  if __name__ == "__main__":
94
- print("Bot is starting...")
95
  while True:
96
  scan_market()
97
- print("\n... Cooling down for 60 seconds ...")
98
  time.sleep(60)
 
5
  import sys
6
 
7
  # --- কনফিগারেশন ---
 
8
  COINS = [
9
  'BTC/USDT', 'ETH/USDT', 'SOL/USDT', 'BNB/USDT', 'XRP/USDT', 'DOGE/USDT',
10
  'ADA/USDT', 'AVAX/USDT', 'TRX/USDT', 'DOT/USDT', 'LINK/USDT', 'MATIC/USDT',
 
14
  ]
15
 
16
  TIMEFRAME = '15m'
17
+ ATR_PERIOD = 14
18
+ RSI_PERIOD = 14
19
 
20
+ # পাবলিক কানেকশন
21
  exchange = ccxt.mexc({
22
  'enableRateLimit': True,
23
  'options': {'defaultType': 'swap'}
24
  })
25
 
26
+ def calculate_rsi(df, period=14):
27
+ """RSI ক্যালকুলেশন করার ম্যানুয়াল ফাংশন"""
28
+ delta = df['close'].diff()
29
+ gain = (delta.where(delta > 0, 0)).rolling(window=period).mean()
30
+ loss = (-delta.where(delta < 0, 0)).rolling(window=period).mean()
31
+
32
+ rs = gain / loss
33
+ rsi = 100 - (100 / (1 + rs))
34
+ return rsi.iloc[-1] # বর্তমান RSI রিটার্ন করবে
35
+
36
+ def fetch_and_analyze(symbol):
37
  try:
38
+ # ডাটা আনা
39
+ ohlcv = exchange.fetch_ohlcv(symbol, TIMEFRAME, limit=50)
40
  df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
41
  order_book = exchange.fetch_order_book(symbol, limit=50)
42
+
43
+ # ১. ATR (Volatility)
44
+ df['tr'] = df[['high', 'low', 'close']].max(axis=1) - df[['high', 'low', 'close']].min(axis=1)
45
+ atr = df['tr'].rolling(window=ATR_PERIOD).mean().iloc[-1]
46
+
47
+ # ২. RSI (Momentum)
48
+ rsi = calculate_rsi(df, RSI_PERIOD)
49
+
50
+ # ৩. Imbalance (Ostad's Formula)
51
+ bid_vol = sum([b[1] for b in order_book['bids']])
52
+ ask_vol = sum([a[1] for a in order_book['asks']])
53
+ imbalance = (bid_vol - ask_vol) / (bid_vol + ask_vol)
54
+
55
+ # ৪. ক্যান্ডেল শেইপ (Hammer Logic Check)
56
+ # বর্তমান ক্যান্ডেলের ওপেন এবং বর্তমান দামের পার্থক্য
57
+ current_candle_open = df['open'].iloc[-1]
58
+ current_price = order_book['bids'][0][0]
59
+
60
+ # Wick তৈরি হচ্ছে কিনা? (দাম ওপেনের নিচে থাকতে হবে)
61
+ is_wick_forming = current_price < current_candle_open
62
+
63
+ return {
64
+ 'symbol': symbol,
65
+ 'price': current_price,
66
+ 'atr': atr,
67
+ 'rsi': rsi,
68
+ 'imbalance': imbalance,
69
+ 'is_wick_forming': is_wick_forming
70
+ }
71
 
72
+ except Exception as e:
73
+ return None
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  def scan_market():
76
+ print(f"\n--- 🛡️ INTELLIGENT SCANNER [RSI + WICK + IMBALANCE] [{datetime.now().strftime('%H:%M:%S')}] ---")
77
+ sys.stdout.flush()
 
78
 
79
  for symbol in COINS:
80
+ data = fetch_and_analyze(symbol)
81
 
82
+ if data:
83
+ # --- SUPER SNIPER STRATEGY ---
 
84
 
85
+ # শর্ত ১: BUY সেটআপ (Hammer Wick Catching)
86
+ # লজিক: বায়ার বেশি + RSI কম (Oversold) + দাম কমছে (Wick তৈরি হচ্ছে)
87
+ if data['imbalance'] > 0.15 and data['rsi'] < 45 and data['is_wick_forming']:
 
 
 
 
88
 
89
+ limit_buy = data['price'] - (data['atr'] * 0.3) # Wick এর একটু নিচে
90
+ sl = limit_buy - (data['atr'] * 0.6)
91
+ tp = limit_buy + (data['atr'] * 1.2)
 
 
 
 
 
 
 
 
92
 
93
+ print(f"✅ {symbol} | 🔥 STRONG BUY ZONE")
94
+ print(f" 📊 Logic: Imbalance({data['imbalance']:.2f}) + RSI({data['rsi']:.1f}) + Wick Forming")
95
+ print(f" 👉 Current: {data['price']}")
96
+ print(f" 🎯 LIMIT BUY: {limit_buy:.4f}")
97
+ print(f" 🛑 SL: {sl:.4f} | 💰 TP: {tp:.4f}")
98
+ print("-" * 45)
99
+ sys.stdout.flush()
100
+
101
+ # শর্ত ২: SELL সেটআপ (Shooting Star Wick Catching)
102
+ elif data['imbalance'] < -0.15 and data['rsi'] > 55 and (data['price'] > data['price']): # Price > Open
103
+
104
+ limit_sell = data['price'] + (data['atr'] * 0.3)
105
+ sl = limit_sell + (data['atr'] * 0.6)
106
+ tp = limit_sell - (data['atr'] * 1.2)
107
+
108
+ print(f"🔻 {symbol} | ❄️ STRONG SELL ZONE")
109
+ print(f" 📊 Logic: Imbalance({data['imbalance']:.2f}) + RSI({data['rsi']:.1f}) + Wick Forming")
110
+ print(f" 👉 Current: {data['price']}")
111
+ print(f" 🎯 LIMIT SELL: {limit_sell:.4f}")
112
+ print(f" 🛑 SL: {sl:.4f} | 💰 TP: {tp:.4f}")
113
+ print("-" * 45)
114
+ sys.stdout.flush()
115
 
116
+ time.sleep(0.5)
117
 
118
  if __name__ == "__main__":
119
+ print("Bot starting with RSI & Hammer Logic...")
120
  while True:
121
  scan_market()
122
+ print("\n... Waiting 60 seconds ...")
123
  time.sleep(60)