⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
home
/
erol
/
View File Name :
checksymbol.py
import decimal import math import time from binance.client import Client from binance.um_futures import UMFutures import pymysql from requests.exceptions import ConnectTimeout from binance.exceptions import BinanceAPIException from datetime import datetime, timedelta import subprocess import argparse parser = argparse.ArgumentParser() parser.add_argument("-symbol", help="Sembol Giriniz", required=True) args = parser.parse_args() symbol = args.symbol def update_redis(symbol): islem.execute("update symbols set L_roi=0, S_roi=0 where symbol=%s",symbol) baglanti.commit() def basamaksay(number): decimal_part = str(number).rstrip("0").split(".")[1] return len(decimal_part) if decimal_part else 0 def tpkontrol(symbol): script_path = "tpkontrol.py" process_name = f"python3.11 {script_path} -symbol {symbol}" process_exists = subprocess.run(["pgrep", "-f", process_name], capture_output=True, text=True).returncode == 0 if not process_exists: try: subprocess.Popen(["python3.11", script_path, "-symbol", symbol]) #print(f"{process_name} sembolüyle çalışan süreç başlatıldı.") except subprocess.CalledProcessError as e: print(f"Hata: {e}") return def limit_al(symbol,yon): script_path = "limital.py" process_name = f"python3.11 {script_path} -symbol {symbol} -yon {yon}" process_exists = subprocess.run(["pgrep", "-f", process_name], capture_output=True, text=True).returncode == 0 if not process_exists: try: subprocess.Popen(["python3.11", script_path, "-symbol", symbol,"-yon",yon]) #print(f"{process_name} sembolüyle çalışan süreç başlatıldı.") except subprocess.CalledProcessError as e: print(f"Hata: {e}") return def eksikapat(um_futures_client,symbol,data,yon): order_long = um_futures_client.new_order( symbol=symbol, side="SELL" if yon == 'LONG' else "BUY", positionSide="LONG" if yon == 'LONG' else "SHORT", quantity=float(data['positionAmt']) if yon == 'LONG' else (float(data['positionAmt'])*-1), type=Client.ORDER_TYPE_MARKET ) um_futures_client.cancel_open_orders(symbol=symbol) if yon=='LONG': islem.execute("update symbols set p_long=0, longsay=0, shortsay=0 where symbol=%s",symbol) baglanti.commit() else: islem.execute("update symbols set p_short=0, longsay=0, shortsay=0 where symbol=%s",symbol) baglanti.commit() return def yuvarla(fiyat,basamak): return "{:.{}f}".format(math.ceil(fiyat), basamak) def pozisyon_ac(um_futures_client,symbol,data): update_redis(symbol) kaldirac =float(data['leverage']) quantity = yuvarla((((float(data['margin']) * kaldirac ) / float(data['price']))),int(data['qp'])) order_long = um_futures_client.new_order( symbol=symbol, side="BUY", positionSide="LONG", quantity=quantity, type=Client.ORDER_TYPE_MARKET ) order_short = um_futures_client.new_order( symbol=symbol, side="SELL", positionSide="SHORT", quantity=quantity, type=Client.ORDER_TYPE_MARKET ) islem.execute("update symbols set p_long=1, p_short=1 where symbol=%s",symbol) baglanti.commit() time.sleep(1) def ceretae_um_futures_client(ayar): return UMFutures(ayar["binanceapikey"], ayar["binancesecretkey"],base_url="https://testnet.binancefuture.com") try: baglanti = pymysql.connect( host='127.0.0.1', db='newcoin', user='root', password='Ua04420076*', port=3306, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor ) with baglanti.cursor() as islem: try: islem.execute("select * from settings where id=1") ayar=islem.fetchone() baglanti.commit() um_futures_client = ceretae_um_futures_client(ayar) while True: resp = um_futures_client.account() long_posizyon = list(filter(lambda order: float(order['positionAmt']) != 0 and order["positionSide"] == "LONG" and order['symbol']==symbol, resp['positions'])) sort_posizyon = list(filter(lambda order: float(order['positionAmt']) != 0 and order["positionSide"] == "SHORT" and order['symbol']==symbol, resp['positions'])) long_posizyon=long_posizyon[0] if len(long_posizyon)>0 else long_posizyon sort_posizyon=sort_posizyon[0] if len(sort_posizyon)>0 else sort_posizyon try: islem.execute("select * from symbols where symbol=%s and isActive=1",symbol) data=islem.fetchone() if data: if data['isFollow']==1: if not long_posizyon and not sort_posizyon: closedDateTime=datetime.strptime(str(data['closedDateTime']), '%Y-%m-%d %H:%M:%S') fark=datetime.now() - closedDateTime if fark >= timedelta(seconds=float(data['waitTime'])): pozisyon_ac(um_futures_client,symbol,data) if long_posizyon and sort_posizyon: acikemirler = um_futures_client.get_orders(symbol=symbol) long_orders = list(filter(lambda order: order["positionSide"] == "LONG" and order['symbol']==symbol, acikemirler)) short_orders = list(filter(lambda order: order["positionSide"] == "SHORT" and order['symbol']==symbol, acikemirler)) if len(long_orders)<6: limit_al(symbol,"LONG") if len(short_orders)<6: limit_al(symbol,"SHORT") hedef=float(long_posizyon['positionAmt'])*(float(data['tp'])/100) if float(long_posizyon['unrealizedProfit']) >= 0 else (float(sort_posizyon['positionAmt'])*-1)*(float(data['tp'])/100) yon="LONG" if float(long_posizyon['unrealizedProfit']) >= 0 else "SHORT" print("kar-zarar:",float(long_posizyon['unrealizedProfit'])+float(sort_posizyon['unrealizedProfit']),"hedef:",float(data['hedef']) + hedef) if float(long_posizyon['unrealizedProfit'])+float(sort_posizyon['unrealizedProfit']) >= float(data['hedef']) + hedef: eksikapat(um_futures_client,symbol,long_posizyon if yon == 'LONG' else sort_posizyon,yon) elif (long_posizyon and not sort_posizyon) or (not long_posizyon and sort_posizyon): tpkontrol(symbol) break except (ConnectTimeout, ConnectionError, TimeoutError, BinanceAPIException) as e: print(f"Hata oluştu: {e}") um_futures_client = ceretae_um_futures_client(ayar) except Exception as e: print(f"Bilinmeyen bir hata oluştu: {e}") except Exception as e: print(f"Bilinmeyen bir hata oluştu: {e}") except KeyboardInterrupt: print("Ctrl+C'ye basıldı, program kapatılmayacak.") while True: pass finally: if 'baglanti' in locals(): baglanti.close()