• 17-10-2023, 20:28:23
    #1
    pip install binance-connector << bu kütüphaneyi kurmanız gerekmektedir.

    binance örnek bir kod verilmiştir herhangi zararlarınızda siz sorumlusunuz


    from binance.spot import Spot
    
    # Binance Spot API'sini kullanmak için Spot sınıfını içe aktarın.
    client = Spot(api_key='<api_key>', api_secret='<api_secret>')
    
    # Strateji parametreleri
    symbol = 'BTCUSDT'  # İşlem yapılacak çift
    quantity = 0.01  # İşlem miktarı
    buy_price = 9500  # Alış fiyatı
    sell_price = 10500  # Satış fiyatı
    stop_loss_price = 9000  # Zarar durdurma fiyatı
    take_profit_price = 11000  # Kar al fiyatı
    
    # Başlangıçta alış emrini gir
    buy_order_params = {
        'symbol': symbol,
        'side': 'BUY',
        'type': 'LIMIT',
        'timeInForce': 'GTC',
        'quantity': quantity,
        'price': buy_price
    }
    buy_order = client.new_order(**buy_order_params)
    
    # Alış emri başarıyla girildiyse, zarar durdurma ve kar al emirlerini ayarla
    if 'orderId' in buy_order:
        stop_loss_order_params = {
            'symbol': symbol,
            'side': 'SELL',
            'type': 'STOP_LIMIT',
            'timeInForce': 'GTC',
            'quantity': quantity,
            'price': stop_loss_price,
            'stopPrice': stop_loss_price
        }
        take_profit_order_params = {
            'symbol': symbol,
            'side': 'SELL',
            'type': 'LIMIT',
            'timeInForce': 'GTC',
            'quantity': quantity,
            'price': take_profit_price
        }
    
        # Zarar durdurma ve kar al emirlerini gir
        stop_loss_order = client.new_order(**stop_loss_order_params)
        take_profit_order = client.new_order(**take_profit_order_params)
    
        if 'orderId' in stop_loss_order and 'orderId' in take_profit_order:
            print("Başarıyla alış, zarar durdurma ve kar al emirleri girildi.")
        else:
            print("Hata oluştu. Emirler girilemedi.")
    else:
        print("Hata oluştu. Alış emri girilemedi.")
  • 17-10-2023, 20:36:56
    #2
    Siz mi yazdınız hocam ? Daha kapsamlı olanı var mı acaba