go-binance icon indicating copy to clipboard operation
go-binance copied to clipboard

how to get specific time price

Open aligurelli opened this issue 3 years ago • 3 comments

is there a way to get spesific time price?

aligurelli avatar Apr 18 '21 02:04 aligurelli

@aligurelli can you add more context to your question?

en0ma avatar Apr 22 '21 08:04 en0ma

We would like to get the price of any PAIR at a specific timestamp.

In short, how we can get the price of the BNBBUSD at this timestamp : 1619692794756

SegFault42 avatar Apr 29 '21 14:04 SegFault42

symbol := "BNBUSDT"
ts := int64(1619692794756)
trades,_ := client.NewAggTradesService().
	Symbol(symbol).
	StartTime(ts).EndTime(ts + time.Hour.Milliseconds()).
	Do(context.Background())
price := trades[0].Price
fmt.Println(price)

onix3 avatar Apr 29 '21 19:04 onix3