File size: 3,225 Bytes
23553f6
a614e6a
23553f6
 
f4953e9
a614e6a
 
 
 
 
 
 
 
 
f4953e9
 
 
 
 
 
 
 
 
 
 
 
a614e6a
23553f6
 
 
 
a614e6a
c0526fa
a614e6a
f4953e9
 
 
23553f6
 
f4953e9
 
23553f6
 
 
 
 
 
 
 
 
a614e6a
c0526fa
a614e6a
f4953e9
 
 
23553f6
 
f4953e9
23553f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4953e9
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import requests
import random
import streamlit as st

# Proxy listesi (SOCKS5) - En hızlı proxy'leri ekledik
proxy_list = [
    '185.46.97.75:1080',  # 20 ms, Rusya
    '89.104.71.70:1080',  # 40 ms, Rusya
    '81.200.241.173:1080', # 100 ms, Rusya
    '46.241.57.29:1080',   # 260 ms, Rusya
    '5.183.70.46:1080'     # 220 ms, Rusya
]

def get_proxy():
    """Rastgele çalışan bir proxy döndür."""
    for _ in range(len(proxy_list)):
        proxy = random.choice(proxy_list)
        try:
            response = requests.get('https://httpbin.org/ip', proxies={'http': f'socks5h://{proxy}', 'https': f'socks5h://{proxy}'}, timeout=10)
            if response.status_code == 200:
                st.write(f"Proxy bağlantısı başarılı: {proxy}")
                return {'http': f'socks5h://{proxy}', 'https': f'socks5h://{proxy}'}
        except Exception as e:
            st.error(f"Proxy çalışmıyor: {proxy} Hata: {e}")
    st.error("Uygun bir proxy bulunamadı. Proxy listesini kontrol edin.")
    return None

def get_binance_price(symbol):
    try:
        url = f"https://api.binance.com/api/v3/depth?symbol={symbol}&limit=5"
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
        }
        proxies = get_proxy()
        if not proxies:
            return None, None
        response = requests.get(url, headers=headers, proxies=proxies, timeout=30)
        response.raise_for_status()
        order_book = response.json()
        best_bid_price = float(order_book['bids'][0][0])
        best_ask_price = float(order_book['asks'][0][0])
        return best_bid_price, best_ask_price
    except Exception as e:
        st.error(f"Binance fiyat çekme hatası ({symbol}): {e}")
        return None, None

def get_okx_price(symbol):
    try:
        url = f"https://www.okx.com/api/v5/market/books?instId={symbol}&sz=5"
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
        }
        proxies = get_proxy()
        if not proxies:
            return None
        response = requests.get(url, headers=headers, proxies=proxies, timeout=30)
        response.raise_for_status()
        order_book = response.json()['data'][0]
        best_bid_price = float(order_book['bids'][0][0])
        return best_bid_price
    except Exception as e:
        st.error(f"OKX fiyat çekme hatası ({symbol}): {e}")
        return None

st.title("OKX ve Binance Arbitraj Fırsatları")
user_try_amount = st.number_input("İşlem yapmak istediğiniz TRY miktarını girin:", min_value=1, step=1)

if st.button("Hesapla"):
    st.write("Fiyatlar çekiliyor...")

    binance_fdusd_try_bid, binance_fdusd_try_ask = get_binance_price("FDUSDTRY")
    binance_fdusd_usdt_bid, _ = get_binance_price("FDUSDUSDT")
    okx_usdt_try = get_okx_price("USDT-TRY")

    if binance_fdusd_try_bid and binance_fdusd_try_ask and binance_fdusd_usdt_bid and okx_usdt_try:
        st.success("Fiyatlar başarıyla çekildi!")
    else:
        st.error("Bazı fiyatlar alınamadı, lütfen daha sonra tekrar deneyin.")