jaggedsoft / php-binance-api

PHP Binance API is an asynchronous PHP library for the Binance API designed to be easy to use. https://github.com/binance-exchange/php-binance-api
MIT License
605 stars 497 forks source link

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

Open oliver809 opened 2 years ago

oliver809 commented 2 years ago

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 commented 1 year ago

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

Sun-277 commented 9 months ago

Same problem