Closed ahab1b closed 6 years ago
sorry i cant reproduce this error, can you please try the following:
steps
git clone https://github.com/jaggedsoft/php-binance-api.git
cd php-binance-api/examples
php candles.php
result
dave@dave-laptop:/smb/synology/BinanceBot/crypto/php-binance-api/examples$ php candles.php
Array
(
[1528851300000] => Array
(
[open] => 0.00154180
[high] => 0.00154370
[low] => 0.00154120
[close] => 0.00154290
[volume] => 8.16483513
[openTime] => 1528851300000
[closeTime] => 1528851359999
[assetVolume] => 5292.92000000
[baseVolume] => 8.16483513
[trades] => 39
[assetBuyVolume] => 4079.65000000
[takerBuyVolume] => 6.29422942
[ignored] => 0
)
..................
....
...
...
Thanks Dave
This returns an array of elements indexed by their timestamp If you want to just get the last item in the array you can do it like this:
$ticks = $api->candlesticks("BNBBTC", "5m");
$tick = array_pop($ticks); // Get last item from array
print_r($tick);
echo $tick['openTime'];
[1528913400000] => Array ( [open] => 0.00228180 [high] => 0.00229310 [low] => 0.00228110 [close] => 0.00228730 [volume] => 9.91950284 [openTime] => 1528913400000 [closeTime] => 1528913699999 [assetVolume] => 4337.50000000 [baseVolume] => 9.91950284 [trades] => 280 [assetBuyVolume] => 1761.48000000 [takerBuyVolume] => 4.02521672 [ignored] => 0 )
) @dmzoneill This works in git. but the other issue I opened still shows that error.
This is working now via the browser. I removed require 'vendor/autoload.php'; and ran it through a manual installation require 'Binance/api/php-binance-api.php'; and the data now displays.
@jaggedsoft I would want all candlesticks to display and not the last item so I can code a trading strategy. how can I get data from the beginning of the today 00:00 up to now? as an example by using the start time and end time parameters
$startTime = strtotime("midnight");
$ticks = $api->candlesticks("BNBBTC", "5m", "{$startTime}000");
foreach ( $ticks as $timestamp => $tick ) {
echo $tick['openTime'], PHP_EOL;
}
Platform:
php version:
when I run the below code from the candlestick example, I get the above error. Also, I can see the candlesticks function does take the start time and end time parameters. In what format would you specify the start time and end time? some other examples show the time intervals which looks to be in unix time.
code //Periods: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M $ticks = $api->candlesticks("BNBBTC", "5m"); print_r($ticks);
thank you