Spaces:
Runtime error
Runtime error
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ccxt
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import time
|
| 4 |
+
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',
|
| 12 |
+
'LTC/USDT', 'SHIB/USDT', 'UNI/USDT', 'ATOM/USDT', 'XLM/USDT', 'ETC/USDT',
|
| 13 |
+
'FIL/USDT', 'HBAR/USDT', 'APT/USDT', 'NEAR/USDT', 'VET/USDT', 'QNT/USDT',
|
| 14 |
+
'AAVE/USDT', 'ALGO/USDT', 'GRT/USDT', 'FTM/USDT', 'SAND/USDT', 'MANA/USDT'
|
| 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)
|