Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsdFuturesApi.SubscribeToUserDataUpdatesAsync #1382

Open
wnazato opened this issue Jun 9, 2024 · 3 comments
Open

UsdFuturesApi.SubscribeToUserDataUpdatesAsync #1382

wnazato opened this issue Jun 9, 2024 · 3 comments

Comments

@wnazato
Copy link

wnazato commented Jun 9, 2024

Hello Everyone,
can you check if i'm missing something on subscribe user data, i can see the subscrition live, but do not get any event:
`
var startOkay = await _binanceSocketClient.SpotApi.Account.StartUserStreamAsync();
var key = startOkay.Data.Result;
var OrderSubscriptionResult = await _binanceSocketClient.UsdFuturesApi.SubscribeToUserDataUpdatesAsync(key,
onLeverageUpdate: (data) =>
{
Console.WriteLine("onLeverageUpdate");
},
onMarginUpdate: (data) =>
{
Console.WriteLine(data.OriginalData);
},
onAccountUpdate: (data) =>
{
Console.WriteLine(data.OriginalData);
},
onOrderUpdate: (data) =>
{
Console.WriteLine(data.OriginalData);
},
onListenKeyExpired: (data) =>
{
Console.WriteLine(data.OriginalData);
},
onStrategyUpdate: (data) =>
{
Console.WriteLine(data.OriginalData);
},
onGridUpdate: (data) =>
{
Console.WriteLine(data.OriginalData);
},
onConditionalOrderTriggerRejectUpdate: (data) =>
{
Console.WriteLine(data.OriginalData);
}
);

//My DI
builder.Services.AddBinance(restOptions => {
restOptions.Environment = BinanceEnvironment.Testnet;
restOptions.ApiCredentials = new ApiCredentials("MyKey", "MySecret");
},

socketOptions => {
socketOptions.Environment = BinanceEnvironment.Testnet;
socketOptions.ApiCredentials = new ApiCredentials("MyKey", "MySecret");
});`

@JKorf
Copy link
Owner

JKorf commented Jun 10, 2024

Hi, I don't immediately see anything wrong. You should probably check startOkay.Success / startOkay.Error. And you're connecting to the test net, which is a different environment than the live/production environment. So it will only push events when something changes on the test net

@wnazato
Copy link
Author

wnazato commented Jun 10, 2024

i tried to push the BinanceEnvironment.Live too, but didn't triggered maybe the key provided by var startOkay = await _binanceSocketClient.SpotApi.Account.StartUserStreamAsync(); don't work for the UsdFuturesApi, and i couldn't find the StartUserStream for this namespasce.

@SamMikkalson
Copy link

I had to grab the key from the BinanceRestClient

var client2 = new BinanceRestClient(options =>
{
options.ApiCredentials = new ApiCredentials(key, secret);
});
var startOkay = client2.UsdFuturesApi.Account.StartUserStreamAsync().GetAwaiter().GetResult();
if (!startOkay.Success)
{
// messageBoxService.ShowMessage($"Error starting user stream: {startOkay.Error.Message}", "error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
string listenKey = startOkay.Data;

this worked for me.

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

No branches or pull requests

3 participants