⚝
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 :
~
/
home
/
python
/
Edit File: ana.py
import decimal import math import time from binance.client import Client from binance.enums import * from requests.exceptions import ConnectTimeout import pymysql def pozisyonac(ayar,client,symbol,positionSide,ters): try: position_side = 'BUY' if positionSide == 'LONG' else 'SELL' exchange_info = client.futures_exchange_info() symbol_info = next(filter(lambda x: x['symbol'] == symbol, exchange_info['symbols']), None) miktar=float(ayar['tersmargine']) if ters==True else float(ayar['margine']) decimal_part = abs(decimal.Decimal(str(symbol_info['quantityPrecision'])).as_tuple().exponent) entry_price = float(client.get_symbol_ticker(symbol=symbol)['price']) quantity = "{:.{}f}".format(math.ceil((float(miktar) * 20) / entry_price), decimal_part) order = client.futures_create_order( symbol=symbol, side=position_side, positionSide=positionSide, quantity=quantity, type=ORDER_TYPE_MARKET ) except ConnectTimeout: print("Bağlantı zaman aşımı hatası. Yeniden deneyin.") return def close_positions_with_high_roi(ayar): while True: #pozisyonlar=[] client = Client(ayar['binanceapikey'], ayar['binancesecretkey']) apositions = client.futures_position_information() positions = [position for position in apositions if (float(position['positionAmt']) > 0 and position['positionSide'] == 'LONG') or (float(position['positionAmt']) < 0 and position['positionSide'] == 'SHORT')] pozisyonlar=[position['symbol'] for position in positions] islem.execute('SELECT * from coinlist where isActive=1') listem=islem.fetchall() baglanti.commit() if listem: for item in listem: if item['symbol'] not in pozisyonlar: pozisyonac(ayar,client,item['symbol'],'LONG',False) for position in positions: position_size = float(position['positionAmt']) if position['positionSide']=='LONG' else float(position['positionAmt'])*-1 unrealized_profit = float(position['unRealizedProfit']) notional = float(position['notional']) leverage = int(position['leverage']) roi = (unrealized_profit / (notional / leverage)) * 100 current_roi = round(roi, 2) if position['positionSide']=='LONG' else round(roi, 2)*-1 dbquery=[pos for pos in listem if pos['symbol']==position['symbol']] if dbquery is not None: say = [p for p in positions if p['symbol']==position['symbol']] if len(say) > 1: continue if position['positionSide']=='LONG': if current_roi > float(dbquery[0]['highroi']): islem.execute('UPDATE coinlist set highroi=%s where id=%s',(current_roi,dbquery[0]['id'])) baglanti.commit() high_roi=current_roi else: high_roi=float(dbquery[0]['highroi']) target_roi=high_roi - float(ayar['tp']) elif position['positionSide']=='SHORT': if current_roi > float(dbquery[0]['deeproi']): islem.execute('UPDATE coinlist set deeproi=%s where id=%s',(current_roi,dbquery[0]['id'])) baglanti.commit() deep_roi=current_roi else: deep_roi=float(dbquery[0]['deeproi']) target_roi=deep_roi - float(ayar['tp']) if current_roi <= float(ayar['terslimit']): yon='LONG' if position['positionSide']=='SHORT' else 'LONG' pozisyonac(ayar,client,position['symbol'],yon,True) if current_roi <= target_roi and current_roi >=int(ayar['hedef']): p_side='SELL' if position['positionSide']=='LONG' else 'BUY' client.futures_create_order( symbol=position['symbol'], side=p_side, positionSide=position['positionSide'], quantity=position_size, type=ORDER_TYPE_MARKET, ) islem.execute('update coinlist set highroi=0,deeproi=0 where symbol=%s',position['symbol']) baglanti.commit() yon='LONG' if position['positionSide']=='SHORT' else 'SHORT' pozisyonac(ayar,client,position['symbol'],yon,False) print(f"Yüksek ROI ({current_roi}%) ile {position['symbol']} paritesindeki {position['positionSide']} pozisyon kapatıldı.") client.close_connection() time.sleep(1) # Saniyede bir kontrol etmek için 1 saniye bekle try: baglanti = pymysql.connect( host='127.0.0.1', db='coinbot', user='root', password='Ua04420076*', port=3306, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor ) with baglanti.cursor() as islem: islem.execute('SELECT * from settings where id=1') ayar=islem.fetchone() baglanti.commit() close_positions_with_high_roi(ayar) finally: # Veritabanı bağlantısını kapat if 'baglanti' in locals(): baglanti.close() # Programı sonlandır #sys.exit()
Simpan