|
import requests |
|
import random |
|
import streamlit as st |
|
|
|
|
|
proxy_list = [ |
|
'185.46.97.75:1080', |
|
'89.104.71.70:1080', |
|
'81.200.241.173:1080', |
|
'46.241.57.29:1080', |
|
'5.183.70.46:1080' |
|
] |
|
|
|
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.") |
|
|