Giter Club home page Giter Club logo

Comments (10)

jaggedsoft avatar jaggedsoft commented on May 29, 2024

Yes available as of a week or two ago you can do this:

$prevDay = $api->prevDay("BNBBTC");
print_r($prevDay);
echo "BNB price change since yesterday: ".$prevDay['priceChangePercent']."%".PHP_EOL;
echo "BNB volume: {$prevDay['quoteVolume']} BTC";
Array
(
    [symbol] => BNBBTC
    [priceChange] => 0.00000288
    [priceChangePercent] => 0.908
    [weightedAvgPrice] => 0.00031564
    [prevClosePrice] => 0.00031715
    [lastPrice] => 0.00032005
    [lastQty] => 34.00000000
    [bidPrice] => 0.00031999
    [bidQty] => 50.00000000
    [askPrice] => 0.00032109
    [askQty] => 20.00000000
    [openPrice] => 0.00031717
    [highPrice] => 0.00032700
    [lowPrice] => 0.00030110
    [volume] => 2985069.00000000
    [quoteVolume] => 942.20144118
    [openTime] => 1513752888817
    [closeTime] => 1513839288817
    [firstId] => 2851228
    [lastId] => 2900234
    [count] => 49007
)
BNB price change since yesterday: 0.908%
BNB volume: 942.20144118 BTC

from php-binance-api.

ph3l1x avatar ph3l1x commented on May 29, 2024

That is what Quote Volume is? I see that but it doesn't seem to match up with what I am seeing from the binance exchange. I am looking at VXG where current volume is 459607 but quote volume is showing 27266.37230013 Maybe i don't quite understand.

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 29, 2024

Quote volume is supposed to be in the base pair, so in this case BTC. If you were getting quoteVolume on the ETH side, it would tell you how much volume worth of ETH

The easiest solution is probably to take the volume number, and multiply this by the btc price. This would give you the current BTC value for that asset no matter what pair you're on

$ticker = $api->prices();

$btcvolume = $ticker['BNBBTC'] * $prevDay['volume'];
echo "Volume in BTC: {$btcvolume}".PHP_EOL;

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 29, 2024

Complete example

$ticker = $api->prices();
print_r($ticker); // List prices of all symbols
echo "Price of BNB: {$ticker['BNBBTC']} BTC.".PHP_EOL;

$prevDay = $api->prevDay('BNBBTC');
print_r($prevDay);
echo "BNB price change since yesterday: ".$prevDay['priceChangePercent']."%".PHP_EOL;
echo "BNB volume: {$prevDay['quoteVolume']} BTC".PHP_EOL;
$btcvolume = $ticker['BNBBTC'] * $prevDay['volume'];
echo "Volume in BTC: {$btcvolume}".PHP_EOL;

from php-binance-api.

ph3l1x avatar ph3l1x commented on May 29, 2024

Thanks for your example. However, I am not sure this is what I am looking for. I am trying to get the Volume of a specific ticker for the given moment... So say right now current volume is.... My goal is trying to find tickers that currently have a spike in volume.. Hopefully this makes sense.

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 29, 2024

This is one way to check the volume over the past 5 minutes
You can make your own alert if it increases +10% or more

// Periods: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
binance.websockets.candlesticks(['BNBBTC'], "5m", function(candlesticks) {
	let { e:eventType, E:eventTime, s:symbol, k:ticks } = candlesticks;
	let { o:open, h:high, l:low, c:close, v:volume, n:trades, i:interval, x:isFinal, q:quoteVolume, V:buyVolume, Q:quoteBuyVolume } = ticks;
	/*console.log(symbol+" "+interval+" candlestick update");
	console.log("open: "+open);
	console.log("high: "+high);
	console.log("low: "+low);
	console.log("close: "+close);*/
	console.log(symbol+" "+interval+" volume: "+volume);
});

from php-binance-api.

ph3l1x avatar ph3l1x commented on May 29, 2024

Any chance to show this with php?

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 29, 2024

Oops

$api->chart(["BNBBTC","BTCUSDT"], "5m", function($api, $symbol, $chart) {
        echo "{$symbol} chart update\n";
	$last_update = array_pop($chart);
	print_r($last_update);
	$volume = $last_update['volume'];
	echo "{$symbol} volume: {$volume}\n";
});

For this to work with more than one symbol, make sure you are using the latest version

from php-binance-api.

ph3l1x avatar ph3l1x commented on May 29, 2024

Is there a way to get this data without using websockets? This script I am using isn't async. I am just trying to find a way to get this value. I think I would have to re-write my entire script to get data from this..

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 29, 2024
//Periods: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
$ticks = $api->candlesticks("BNBBTC", "5m");
$last_update = array_pop($ticks);
print_r($last_update);
$volume = $last_update['volume'];
echo "volume: {$volume}\n";

from php-binance-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.