As many have already known, TV implements an indicator called volume profile, however this indicator is only available in the payment options, I would like to be able to implement it in my app, however, I am still not sure which endpoints to use, according to the description. TV’s volume profile highlights the most traded prices during a certain time interval, reviewing the api documentation I found the following endpoints that could possibly help me implement this indicator
GET /api/v3/trades
GET /api/v3/historicalTrades
GET /api/v3/aggTrades
And to keep the data updated I suppose you could use the following streams
< symbol >@aggTrade
< symbol >@trade
Assuming the implementation is similar to the order book, what would be the correct way to implement this indicator?
Hi.
To get the volume profile, I believe kline or ticker data may be more helpful since what you need is the total number. Please take a look at the attribute ‘v’ or ‘q’ in the attached document link.
Also, you may want to collect the past data. Instead of querying from API, to download the csv file might be a faster approach.
I took the liberty of making this image to explain the difference between volume and volume profile, since from the answer you are giving me it seems that it is not clear what I want to implement
Just a quick try. I downloaded the aggregated trades and processed in Julia
using CSV, PlotlyJS, DataFrames, Pipe
file = "c:/temp/delete/LUNAUSDT-aggTrades-2021-11-05.csv"
data = CSV.File(file, header=[:TradeId, :Price, :Quantity, :FirstTradeId, :LastTradeId, :TimeStamp, :WasMaker, :WasBestPriceMatch]) |> DataFrame
minprice = minimum(data.Price)
maxprice = maximum(data.Price)
steps = 50
step = (maxprice-minprice) / steps
# this adds new column. It takes one value from vector 'data.Price' after
# another and calls the lambda function on it (the body is 'floor((price - minprice) / step')
data.Bin = (price -> floor((price - minprice) / step)).(data.Price)
# group by bins, for each bin compute sum over Quantity
volume = @pipe groupby(data, :Bin) |>
combine(_, :Quantity => sum => :Quantity) |>
sort(_, :Bin)
#plotting
traces=[
bar(;x = volume.Bin, y = volume.Quantity)
]
PlotlyJS.plot(traces, Layout(title = "Volume", yaxis=attr(title="Traded amount")))