Skip to content

Commit

Permalink
Realtime chart data, user balances, trade history
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Eyrick authored Oct 23, 2017
1 parent 459c2e0 commit 24487f0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions php-binance-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,16 @@ public function chart($symbols, $interval = "30m", $callback) {
}
}

// Keep-alive function for userDataStream
public function keepAlive() {
$loop = \React\EventLoop\Factory::create();
$loop->addPeriodicTimer(30, function() {
$listenKey = $this->options['listenKey'];
$this->apiRequest("v1/userDataStream?listenKey={$listenKey}", "PUT");
});
$loop->run();
}

// Issues userDataStream token and keepalive, subscribes to userData WebSocket
public function userData(&$balance_callback, &$execution_callback = false) {
$response = $this->apiRequest("v1/userDataStream", "POST");
Expand All @@ -475,10 +485,5 @@ public function userData(&$balance_callback, &$execution_callback = false) {
}, function($e) {
echo "userData: Could not connect: {$e->getMessage()}".PHP_EOL;
});
/*$loop = \React\EventLoop\Factory::create();
$loop->addPeriodicTimer(30, function() use ($listenKey) {
$this->apiRequest("v1/userDataStream?listenKey={$listenKey}", "PUT");
});
$loop->run();*/
}
}

0 comments on commit 24487f0

Please sign in to comment.