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ip", "install", pkg, "-q"])
|
| 5 |
+
|
| 6 |
+
for pkg in ["requests","pandas","numpy","plotly","xgboost","scikit-learn","ta"]:
|
| 7 |
+
try:
|
| 8 |
+
install(pkg)
|
| 9 |
+
except Exception as e:
|
| 10 |
+
print(f"Warning: {pkg}: {e}")
|
| 11 |
+
|
| 12 |
+
import gradio as gr
|
| 13 |
+
import requests
|
| 14 |
+
import pandas as pd
|
| 15 |
+
import numpy as np
|
| 16 |
+
import plotly.graph_objects as go
|
| 17 |
+
from plotly.subplots import make_subplots
|
| 18 |
+
import warnings
|
| 19 |
+
warnings.filterwarnings("ignore")
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
from xgboost import XGBClassifier
|
| 23 |
+
XGB_AVAILABLE = True
|
| 24 |
+
except ImportError:
|
| 25 |
+
XGB_AVAILABLE = False
|
| 26 |
+
|
| 27 |
+
from sklearn.preprocessing import StandardScaler
|
| 28 |
+
|
| 29 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 30 |
+
# DATA FETCHING
|
| 31 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 32 |
+
|
| 33 |
+
SYMBOLS = [
|
| 34 |
+
"BTCUSDT","ETHUSDT","SOLUSDT","BNBUSDT","XRPUSDT",
|
| 35 |
+
"ADAUSDT","DOGEUSDT","AVAXUSDT","DOTUSDT","MATICUSDT",
|
| 36 |
+
"LINKUSDT","LTCUSDT","UNIUSDT","ATOMUSDT","NEARUSDT",
|
| 37 |
+
]
|
| 38 |
+
INTERVALS = ["5m","15m","1h","4h","1d"]
|
| 39 |
+
|
| 40 |
+
def fetch_klines(symbol, interval, limit=300):
|
| 41 |
+
url = "https://api.binance.com/api/v3/klines"
|
| 42 |
+
r = requests.get(url, params={"symbol":symbol,"interval":interval,"limit":limit}, timeout=10)
|
| 43 |
+
r.raise_for_status()
|
| 44 |
+
df = pd.DataFrame(r.json(), columns=[
|
| 45 |
+
"open_time","open","high","low","close","volume",
|
| 46 |
+
"close_time","quote_vol","trades","taker_buy_base","taker_buy_quote","ignore"
|
| 47 |
+
])
|
| 48 |
+
for c in ["open","high","low","close","volume"]:
|
| 49 |
+
df[c] = df[c].astype(float)
|
| 50 |
+
df["open_time"] = pd.to_datetime(df["open_time"], unit="ms")
|
| 51 |
+
df.set_index("open_time", inplace=True)
|
| 52 |
+
return df[["open","high","low","close","volume"]]
|
| 53 |
+
|
| 54 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 55 |
+
# INDICATORS
|
| 56 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 57 |
+
|
| 58 |
+
def ema(s, n): return s.ewm(span=n, adjust=False).mean()
|
| 59 |
+
def rsi(s, n=14):
|
| 60 |
+
d=s.diff(); g=d.clip(lower=0).rolling(n).mean(); l=(-d.clip(upper=0)).rolling(n).mean()
|
| 61 |
+
return 100-(100/(1+g/l.replace(0,np.nan)))
|
| 62 |
+
def macd(s):
|
| 63 |
+
ml=s.ewm(span=12,adjust=False).mean()-s.ewm(span=26,adjust=False).mean()
|
| 64 |
+
sig=ml.ewm(span=9,adjust=False).mean(); return ml,sig,ml-sig
|
| 65 |
+
def atr(df,n=14):
|
| 66 |
+
tr=pd.concat([df.high-df.low,(df.high-df.close.shift()).abs(),(df.low-df.close.shift()).abs()],axis=1).max(axis=1)
|
| 67 |
+
return tr.rolling(n).mean()
|
| 68 |
+
def vwap(df):
|
| 69 |
+
tp=(df.high+df.low+df.close)/3; return (tp*df.volume).cumsum()/df.volume.cumsum()
|
| 70 |
+
|
| 71 |
+
def add_indicators(df):
|
| 72 |
+
df=df.copy()
|
| 73 |
+
df["ema20"]=ema(df.close,20); df["ema50"]=ema(df.close,50); df["ema200"]=ema(df.close,200)
|
| 74 |
+
df["rsi"]=rsi(df.close)
|
| 75 |
+
df["macd"],df["macd_sig"],df["macd_hist"]=macd(df.close)
|
| 76 |
+
df["atr"]=atr(df); df["vwap"]=vwap(df)
|
| 77 |
+
df["vol_ma"]=df.volume.rolling(20).mean()
|
| 78 |
+
df["vol_ratio"]=df.volume/df.vol_ma.replace(0,np.nan)
|
| 79 |
+
return df.dropna()
|
| 80 |
+
|
| 81 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 82 |
+
# SIGNAL LOGIC
|
| 83 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 84 |
+
|
| 85 |
+
def generate_signal(df):
|
| 86 |
+
l,p=df.iloc[-1],df.iloc[-2]
|
| 87 |
+
bc=[l.ema20>l.ema50, l.ema50>l.ema200, l.rsi>50,
|
| 88 |
+
(l.macd>l.macd_sig)and(p.macd<=p.macd_sig), l.close>l.vwap]
|
| 89 |
+
sc=[l.ema20<l.ema50, l.ema50<l.ema200, l.rsi<50,
|
| 90 |
+
(l.macd<l.macd_sig)and(p.macd>=p.macd_sig), l.close<l.vwap]
|
| 91 |
+
bs,ss=sum(bc),sum(sc)
|
| 92 |
+
px,at=l.close,l.atr
|
| 93 |
+
if bs>=3:
|
| 94 |
+
return "AL π", int(bs/5*100), round(px-1.5*at,4), round(px+3*at,4)
|
| 95 |
+
elif ss>=3:
|
| 96 |
+
return "SAT π", int(ss/5*100), round(px+1.5*at,4), round(px-3*at,4)
|
| 97 |
+
else:
|
| 98 |
+
return "BEKLE β³", 30, round(px-1.5*at,4), round(px+1.5*at,4)
|
| 99 |
+
|
| 100 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 101 |
+
# AI MODEL
|
| 102 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 103 |
+
|
| 104 |
+
FCOLS=["r1","r3","r5","e2050","e50200","rsi_n","macd_n","mhist_n","vwap_d","atr_n","volr"]
|
| 105 |
+
|
| 106 |
+
def featurize(df):
|
| 107 |
+
d=df.copy()
|
| 108 |
+
d["r1"]=d.close.pct_change(1); d["r3"]=d.close.pct_change(3); d["r5"]=d.close.pct_change(5)
|
| 109 |
+
d["e2050"]=(d.ema20-d.ema50)/d.close; d["e50200"]=(d.ema50-d.ema200)/d.close
|
| 110 |
+
d["rsi_n"]=d.rsi/100; d["macd_n"]=d.macd/d.close; d["mhist_n"]=d.macd_hist/d.close
|
| 111 |
+
d["vwap_d"]=(d.close-d.vwap)/d.close; d["atr_n"]=d.atr/d.close; d["volr"]=d.vol_ratio.clip(0,5)
|
| 112 |
+
return d.dropna()
|
| 113 |
+
|
| 114 |
+
def train_ai(df):
|
| 115 |
+
fd=featurize(df)
|
| 116 |
+
if len(fd)<60 or not XGB_AVAILABLE:
|
| 117 |
+
return 50
|
| 118 |
+
fd["tgt"]=(fd.close.shift(-3)>fd.close).astype(int)
|
| 119 |
+
fd=fd.dropna()
|
| 120 |
+
if len(fd)<40:
|
| 121 |
+
return 50
|
| 122 |
+
X=fd[FCOLS].values; y=fd["tgt"].values
|
| 123 |
+
sc=StandardScaler(); Xs=sc.fit_transform(X)
|
| 124 |
+
sp=int(len(Xs)*0.8)
|
| 125 |
+
try:
|
| 126 |
+
m=XGBClassifier(n_estimators=50,max_depth=3,learning_rate=0.1,
|
| 127 |
+
eval_metric="logloss",verbosity=0,n_jobs=1)
|
| 128 |
+
m.fit(Xs[:sp],y[:sp])
|
| 129 |
+
lf=featurize(df.tail(50)).tail(1)[FCOLS].values
|
| 130 |
+
return int(m.predict_proba(sc.transform(lf))[0][1]*100)
|
| 131 |
+
except:
|
| 132 |
+
return 50
|
| 133 |
+
|
| 134 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 135 |
+
# CHART
|
| 136 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 137 |
+
|
| 138 |
+
def build_chart(df, symbol, signal, sl, tp):
|
| 139 |
+
p=df.tail(120).copy()
|
| 140 |
+
fig=make_subplots(rows=3,cols=1,shared_xaxes=True,row_heights=[0.6,0.2,0.2],
|
| 141 |
+
vertical_spacing=0.03)
|
| 142 |
+
fig.add_trace(go.Candlestick(x=p.index,open=p.open,high=p.high,low=p.low,close=p.close,
|
| 143 |
+
name="Fiyat",increasing_line_color="#00e676",decreasing_line_color="#ff5252",
|
| 144 |
+
increasing_fillcolor="#00e676",decreasing_fillcolor="#ff5252"),row=1,col=1)
|
| 145 |
+
for n,c,w in [(20,"#64b5f6",1.5),(50,"#ffb74d",1.5),(200,"#ce93d8",2)]:
|
| 146 |
+
fig.add_trace(go.Scatter(x=p.index,y=p[f"ema{n}"],name=f"EMA{n}",
|
| 147 |
+
line=dict(color=c,width=w)),row=1,col=1)
|
| 148 |
+
fig.add_trace(go.Scatter(x=p.index,y=p.vwap,name="VWAP",
|
| 149 |
+
line=dict(color="#f48fb1",width=1.5,dash="dot")),row=1,col=1)
|
| 150 |
+
# Signal marker
|
| 151 |
+
li,lc=p.index[-1],p.close.iloc[-1]
|
| 152 |
+
if "AL" in signal:
|
| 153 |
+
fig.add_annotation(x=li,y=lc*0.994,text="β² AL",showarrow=False,
|
| 154 |
+
font=dict(color="#00e676",size=16),row=1,col=1)
|
| 155 |
+
elif "SAT" in signal:
|
| 156 |
+
fig.add_annotation(x=li,y=lc*1.006,text="βΌ SAT",showarrow=False,
|
| 157 |
+
font=dict(color="#ff5252",size=16),row=1,col=1)
|
| 158 |
+
fig.add_hline(y=sl,line_dash="dash",line_color="#ff5252",
|
| 159 |
+
annotation_text=f"SL {sl:,.4f}",row=1,col=1)
|
| 160 |
+
fig.add_hline(y=tp,line_dash="dash",line_color="#00e676",
|
| 161 |
+
annotation_text=f"TP {tp:,.4f}",row=1,col=1)
|
| 162 |
+
# RSI
|
| 163 |
+
fig.add_trace(go.Scatter(x=p.index,y=p.rsi,name="RSI",
|
| 164 |
+
line=dict(color="#80cbc4",width=1.5)),row=2,col=1)
|
| 165 |
+
for yv,col in [(70,"#ff5252"),(50,"#666"),(30,"#00e676")]:
|
| 166 |
+
fig.add_hline(y=yv,line_dash="dot",line_color=col,row=2,col=1)
|
| 167 |
+
# MACD
|
| 168 |
+
clrs=["#00e676" if v>=0 else "#ff5252" for v in p.macd_hist]
|
| 169 |
+
fig.add_trace(go.Bar(x=p.index,y=p.macd_hist,name="Hist",
|
| 170 |
+
marker_color=clrs,opacity=0.7),row=3,col=1)
|
| 171 |
+
fig.add_trace(go.Scatter(x=p.index,y=p.macd,name="MACD",
|
| 172 |
+
line=dict(color="#64b5f6",width=1.2)),row=3,col=1)
|
| 173 |
+
fig.add_trace(go.Scatter(x=p.index,y=p.macd_sig,name="Sinyal",
|
| 174 |
+
line=dict(color="#ffb74d",width=1.2)),row=3,col=1)
|
| 175 |
+
fig.update_layout(
|
| 176 |
+
title=dict(text=f"<b>{symbol}</b> β Teknik Analiz",
|
| 177 |
+
font=dict(color="#e0e0e0",size=16,family="Courier New, monospace")),
|
| 178 |
+
paper_bgcolor="#0d0d0d",plot_bgcolor="#111111",
|
| 179 |
+
font=dict(color="#b0b0b0",family="Courier New, monospace"),
|
| 180 |
+
xaxis_rangeslider_visible=False,height=720,
|
| 181 |
+
legend=dict(bgcolor="rgba(20,20,20,0.8)",bordercolor="#333",borderwidth=1,font=dict(size=10)),
|
| 182 |
+
margin=dict(l=50,r=60,t=55,b=20),
|
| 183 |
+
)
|
| 184 |
+
for i in range(1,4):
|
| 185 |
+
fig.update_xaxes(gridcolor="#1e1e1e",zeroline=False,row=i,col=1)
|
| 186 |
+
fig.update_yaxes(gridcolor="#1e1e1e",zeroline=False,row=i,col=1)
|
| 187 |
+
return fig
|
| 188 |
+
|
| 189 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 190 |
+
# MAIN
|
| 191 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 192 |
+
|
| 193 |
+
def analyze(symbol, interval):
|
| 194 |
+
try:
|
| 195 |
+
df_raw = fetch_klines(symbol, interval, 300)
|
| 196 |
+
except Exception as e:
|
| 197 |
+
return None, f"<p style='color:#ff5252'>β Veri alΔ±namadΔ±: {e}</p>"
|
| 198 |
+
|
| 199 |
+
df = add_indicators(df_raw)
|
| 200 |
+
if len(df) < 50:
|
| 201 |
+
return None, "<p style='color:#ff5252'>β Yeterli veri yok.</p>"
|
| 202 |
+
|
| 203 |
+
signal, tech_conf, sl, tp = generate_signal(df)
|
| 204 |
+
ai_conf = train_ai(df)
|
| 205 |
+
final = int(0.5*tech_conf + 0.5*ai_conf)
|
| 206 |
+
|
| 207 |
+
price = df.close.iloc[-1]
|
| 208 |
+
rsi_v = df.rsi.iloc[-1]
|
| 209 |
+
atr_v = df.atr.iloc[-1]
|
| 210 |
+
rr = round(abs(tp-price)/abs(sl-price),2) if abs(sl-price)>0 else 0
|
| 211 |
+
|
| 212 |
+
if "AL" in signal: dir_txt,dir_col = "π’ YUKARI","#00e676"
|
| 213 |
+
elif "SAT" in signal: dir_txt,dir_col = "π΄ AΕAΔI","#ff5252"
|
| 214 |
+
else: dir_txt,dir_col = "π‘ YATAY","#ffb74d"
|
| 215 |
+
|
| 216 |
+
bar_color = "#238636" if final>=60 else ("#f0883e" if final>=40 else "#da3633")
|
| 217 |
+
|
| 218 |
+
html = f"""
|
| 219 |
+
<div style="background:linear-gradient(135deg,#0d1117,#161b22);border:1px solid #30363d;
|
| 220 |
+
border-radius:12px;padding:20px;font-family:'Courier New',monospace;color:#e6edf3;">
|
| 221 |
+
<h2 style="margin:0 0 16px;color:#58a6ff;font-size:1em;letter-spacing:2px;">
|
| 222 |
+
β‘ SΔ°NYAL β {symbol} / {interval}
|
| 223 |
+
</h2>
|
| 224 |
+
<table style="width:100%;border-collapse:collapse;">
|
| 225 |
+
<tr><td style="padding:7px 12px;color:#8b949e;width:42%">π Sinyal</td>
|
| 226 |
+
<td style="padding:7px 12px;font-size:1.15em;font-weight:bold">{signal}</td></tr>
|
| 227 |
+
<tr style="background:rgba(255,255,255,.03)">
|
| 228 |
+
<td style="padding:7px 12px;color:#8b949e">π GΓΌven</td>
|
| 229 |
+
<td style="padding:7px 12px">
|
| 230 |
+
<div style="background:#21262d;border-radius:6px;overflow:hidden;height:18px">
|
| 231 |
+
<div style="background:linear-gradient(90deg,{bar_color},{bar_color}cc);width:{final}%;
|
| 232 |
+
height:100%;display:flex;align-items:center;justify-content:center;
|
| 233 |
+
font-size:11px;font-weight:bold">{final}%</div>
|
| 234 |
+
</div>
|
| 235 |
+
</td>
|
| 236 |
+
</tr>
|
| 237 |
+
<tr><td style="padding:7px 12px;color:#8b949e">π¬ Teknik / π€ AI</td>
|
| 238 |
+
<td style="padding:7px 12px">{tech_conf}% / {ai_conf}%</td></tr>
|
| 239 |
+
<tr style="background:rgba(255,255,255,.03)">
|
| 240 |
+
<td style="padding:7px 12px;color:#8b949e">π YΓΆn</td>
|
| 241 |
+
<td style="padding:7px 12px;color:{dir_col};font-weight:bold">{dir_txt}</td></tr>
|
| 242 |
+
<tr><td style="padding:7px 12px;color:#8b949e">π° Fiyat</td>
|
| 243 |
+
<td style="padding:7px 12px">${price:,.4f}</td></tr>
|
| 244 |
+
<tr style="background:rgba(255,255,255,.03)">
|
| 245 |
+
<td style="padding:7px 12px;color:#ff5252">π Stop Loss</td>
|
| 246 |
+
<td style="padding:7px 12px;color:#ff5252;font-weight:bold">${sl:,.4f}</td></tr>
|
| 247 |
+
<tr><td style="padding:7px 12px;color:#00e676">β
Take Profit</td>
|
| 248 |
+
<td style="padding:7px 12px;color:#00e676;font-weight:bold">${tp:,.4f}</td></tr>
|
| 249 |
+
<tr style="background:rgba(255,255,255,.03)">
|
| 250 |
+
<td style="padding:7px 12px;color:#8b949e">βοΈ Risk/ΓdΓΌl</td>
|
| 251 |
+
<td style="padding:7px 12px">{rr}x</td></tr>
|
| 252 |
+
<tr><td style="padding:7px 12px;color:#8b949e">π RSI</td>
|
| 253 |
+
<td style="padding:7px 12px">{rsi_v:.1f}</td></tr>
|
| 254 |
+
<tr style="background:rgba(255,255,255,.03)">
|
| 255 |
+
<td style="padding:7px 12px;color:#8b949e">π ATR</td>
|
| 256 |
+
<td style="padding:7px 12px">${atr_v:,.4f}</td></tr>
|
| 257 |
+
</table>
|
| 258 |
+
<p style="margin:14px 0 0;font-size:.7em;color:#484f58;text-align:center">
|
| 259 |
+
β οΈ EΔitim amaΓ§lΔ±dΔ±r β finansal tavsiye deΔildir. DYOR.
|
| 260 |
+
</p>
|
| 261 |
+
</div>"""
|
| 262 |
+
|
| 263 |
+
fig = build_chart(df, symbol, signal, sl, tp)
|
| 264 |
+
return fig, html
|
| 265 |
+
|
| 266 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 267 |
+
# GRADIO UI
|
| 268 |
+
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 269 |
+
|
| 270 |
+
CSS = """
|
| 271 |
+
.gradio-container { background:#0a0a0f !important; }
|
| 272 |
+
footer { display:none !important; }
|
| 273 |
+
"""
|
| 274 |
+
|
| 275 |
+
HEADER = """
|
| 276 |
+
<div style="background:linear-gradient(135deg,#0d0d1a,#0a0a0f,#1a0a1a);
|
| 277 |
+
border:1px solid #1e1e3f;border-radius:16px;padding:28px 32px;
|
| 278 |
+
text-align:center;font-family:'Courier New',monospace;margin-bottom:4px;position:relative;">
|
| 279 |
+
<div style="position:absolute;top:0;left:0;right:0;height:2px;
|
| 280 |
+
background:linear-gradient(90deg,transparent,#7b68ee,#00e5ff,#7b68ee,transparent)"></div>
|
| 281 |
+
<h1 style="margin:0 0 6px;font-size:1.9em;letter-spacing:4px;
|
| 282 |
+
background:linear-gradient(90deg,#7b68ee,#00e5ff,#7b68ee);
|
| 283 |
+
-webkit-background-clip:text;-webkit-text-fill-color:transparent;
|
| 284 |
+
background-clip:text;text-transform:uppercase">β‘ CRYPTO SIGNAL PRO</h1>
|
| 285 |
+
<p style="margin:0;color:#444;letter-spacing:3px;font-size:.72em;text-transform:uppercase">
|
| 286 |
+
AI-Powered Technical Analysis & Trading Signals</p>
|
| 287 |
+
<div style="display:flex;justify-content:center;gap:20px;margin-top:12px;
|
| 288 |
+
font-size:.68em;color:#333;letter-spacing:2px">
|
| 289 |
+
<span>EMA Β· RSI Β· MACD</span><span style="color:#222">|</span>
|
| 290 |
+
<span>VWAP Β· ATR Β· Volume</span><span style="color:#222">|</span>
|
| 291 |
+
<span>XGBoost AI</span>
|
| 292 |
+
</div>
|
| 293 |
+
</div>"""
|
| 294 |
+
|
| 295 |
+
def run(symbol, interval):
|
| 296 |
+
return analyze(symbol, interval)
|
| 297 |
+
|
| 298 |
+
with gr.Blocks(css=CSS, title="β‘ Crypto Signal Pro") as demo:
|
| 299 |
+
gr.HTML(HEADER)
|
| 300 |
+
with gr.Row():
|
| 301 |
+
sym = gr.Dropdown(choices=SYMBOLS, value="BTCUSDT", label="π Parite", scale=2)
|
| 302 |
+
ivl = gr.Dropdown(choices=INTERVALS, value="1h", label="β± Zaman Dilimi", scale=1)
|
| 303 |
+
btn = gr.Button("π ANALΔ°Z ET", variant="primary", scale=1)
|
| 304 |
+
with gr.Row():
|
| 305 |
+
chart = gr.Plot(label="Grafik")
|
| 306 |
+
info = gr.HTML(label="Sinyal Γzeti")
|
| 307 |
+
btn.click(fn=run, inputs=[sym, ivl], outputs=[chart, info])
|
| 308 |
+
gr.HTML("""<p style="text-align:center;color:#2a2a2a;font-size:.65em;
|
| 309 |
+
font-family:'Courier New',monospace;padding:12px;letter-spacing:1px">
|
| 310 |
+
CRYPTO SIGNAL PRO Β· Binance API Β· XGBoost AI Β· Plotly</p>""")
|
| 311 |
+
|
| 312 |
+
if __name__ == "__main__":
|
| 313 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements-22.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests
|
| 2 |
+
pandas
|
| 3 |
+
numpy
|
| 4 |
+
plotly
|
| 5 |
+
xgboost
|
| 6 |
+
scikit-learn
|
| 7 |
+
ta
|