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

How to create User Data Stream for multiple binance accounts using php-binance-api #487

Open
oliver809 opened this issue Sep 15, 2022 · 2 comments

Comments

@oliver809
Copy link

I have tried to use the below code in foreach loop to set userData websocket to grab new orders and order updates for multiple accounts. but i can only create userdata webocket for first account in the foreach loop as it start $loop->run for the first account and never return back to the foreach loop. Please suggest/help me how can i set the UserData websocket for remaining accounts. here is the code i am using:

$balance_update = function($api, $balances) {
print_r($balances);
echo "Balance update".PHP_EOL;
};

$order_update = function($api, $report) {
echo "Order update".PHP_EOL;
print_r($report);
$price = $report['price'];
$quantity = $report['quantity'];
$symbol = $report['symbol'];
$side = $report['side'];
$orderType = $report['orderType'];
$orderId = $report['orderId'];
$orderStatus = $report['orderStatus'];
$executionType = $report['orderStatus'];
if ( $executionType == "NEW" ) {
if ( $executionType == "REJECTED" ) {
echo "Order Failed! Reason: {$report['rejectReason']}".PHP_EOL;
}
echo "{$symbol} {$side} {$orderType} ORDER #{$orderId} ({$orderStatus})".PHP_EOL;
echo "..price: {$price}, quantity: {$quantity}".PHP_EOL;
return;
}
//NEW, CANCELED, REPLACED, REJECTED, TRADE, EXPIRED
echo "{$symbol} {$side} {$executionType} {$orderType} ORDER #{$orderId}".PHP_EOL;
};
$api->userData($balance_update, $order_update);

@imyuvii
Copy link

imyuvii commented Feb 8, 2023

The same issue I have, @oliver809 Please let me know if you have found any solution for this

@Sun-277
Copy link

Sun-277 commented Jan 31, 2024

Same problem

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