GoshawkVortexAI commited on
Commit
6aed91a
·
verified ·
1 Parent(s): 454b27c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import feedparser
2
  from transformers import pipeline
3
 
4
- # DistilBERT modelini yükle (CPU üzerinde)
5
- model = pipeline("sentiment-analysis", model="distilbert-base-uncased", device=-1)
6
 
7
  # Bitcoin haberleri için RSS feed URL'si
8
  rss_url = "https://news.google.com/rss/search?q=Bitcoin&hl=en-US&gl=US&ceid=US:en"
@@ -18,23 +18,24 @@ for entry in feed.entries:
18
  title = entry.title
19
  sentiment = model(title)[0]
20
 
21
- # Etiketi puana çevir
22
  label = sentiment['label'].upper()
 
 
23
  if label == "POSITIVE":
24
- score = 1
25
  elif label == "NEGATIVE":
26
- score = -1
27
  else:
28
- score = 0
29
 
30
- total_score += score
31
  count += 1
32
 
33
  # Ortalama skor hesapla
34
  average_score = total_score / count if count > 0 else 0
35
 
36
  # Long / Short / Neutral kararı
37
- threshold = 0.1
38
  if average_score > threshold:
39
  signal = "LONG 🟢"
40
  elif average_score < -threshold:
 
1
  import feedparser
2
  from transformers import pipeline
3
 
4
+ # FinBERT modelini yükle (CPU kullanmak için device=-1)
5
+ model = pipeline("sentiment-analysis", model="yiyanghkust/finbert-tone", device=-1)
6
 
7
  # Bitcoin haberleri için RSS feed URL'si
8
  rss_url = "https://news.google.com/rss/search?q=Bitcoin&hl=en-US&gl=US&ceid=US:en"
 
18
  title = entry.title
19
  sentiment = model(title)[0]
20
 
21
+ # Etiketi puana çevir (POSITIVE = +1, NEGATIVE = -1, NEUTRAL = 0)
22
  label = sentiment['label'].upper()
23
+ score = sentiment['score'] # güven skorunu ağırlık olarak kullan
24
+
25
  if label == "POSITIVE":
26
+ total_score += score # ağırlıklı pozitif
27
  elif label == "NEGATIVE":
28
+ total_score -= score # ağırlıklı negatif
29
  else:
30
+ total_score += 0 # nötr = 0
31
 
 
32
  count += 1
33
 
34
  # Ortalama skor hesapla
35
  average_score = total_score / count if count > 0 else 0
36
 
37
  # Long / Short / Neutral kararı
38
+ threshold = 0.05 # küçük değişimleri nötr say
39
  if average_score > threshold:
40
  signal = "LONG 🟢"
41
  elif average_score < -threshold: