Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

I don't receive any response bei webSocketClient onUserDataUpdateEvent!! #438

Open
saeid1 opened this issue Mar 11, 2023 · 0 comments
Open

Comments

@saeid1
Copy link

saeid1 commented Mar 11, 2023

can some body help me?
I post a new order, change balances and ... but it's not append?

`package com.binance.api.examples;

import com.binance.api.client.BinanceApiClientFactory;
import com.binance.api.client.BinanceApiRestClient;
import com.binance.api.client.BinanceApiWebSocketClient;
import com.binance.api.client.domain.account.AssetBalance;
import com.binance.api.client.domain.account.Order;
import com.binance.api.client.domain.account.request.OrderRequest;
import com.binance.api.client.domain.event.AccountUpdateEvent;
import com.binance.api.client.domain.event.OrderTradeUpdateEvent;
import com.binance.api.client.domain.event.UserDataUpdateEvent.UserDataUpdateEventType;

import java.util.List;

/**

  • User data stream endpoints examples.

  • It illustrates how to create a stream to obtain updates on a user account,

  • as well as update on trades/orders on a user account.
    */
    public class UserDataStreamExample {

    public static void main(String[] args) {
    BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("*****",
    "****");
    BinanceApiRestClient client = factory.newRestClient();

     // First, we obtain a listenKey which is required to interact with the user data stream
     String listenKey = client.startUserDataStream();
    
     // Then, we open a new web socket client, and provide a callback that is called on every update
     BinanceApiWebSocketClient webSocketClient = factory.newWebSocketClient();
    
     // Listen for changes in the account
     webSocketClient.onUserDataUpdateEvent(listenKey, response -> {
         if (response.getEventType() == UserDataUpdateEventType.ACCOUNT_POSITION_UPDATE) {
             AccountUpdateEvent accountUpdateEvent = response.getOutboundAccountPositionUpdateEvent();
             // Print new balances of every available asset
             System.out.println(accountUpdateEvent.getBalances());
         } else {
             OrderTradeUpdateEvent orderTradeUpdateEvent = response.getOrderTradeUpdateEvent();
             // Print details about an order/trade
             System.out.println(orderTradeUpdateEvent);
    
             // Print original quantity
             System.out.println(orderTradeUpdateEvent.getOriginalQuantity());
    
             // Or price
             System.out.println(orderTradeUpdateEvent.getPrice());
         }
     });
     System.out.println("Waiting for events...");
    

    }
    }
    `

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant