Post
Topic
Board Trading Discussion
Topic OP
Coding -- how to convert Trading History to OHLCV Format?
by
d-angel2001
on 31/05/2021, 13:36:47 UTC
Hello to all coders,

I'm trying to make a trading bot using php which also uses some indicators for custom strategies. I would like to know how to calculate/compute a OHLCV Data-Array from today current History. I'm using CEX.io API for my first trials as some time ago I already was using it and I think the functions provided should be adoptable to other exchanges as well.


I'm currently trying to understand this:

I've already studied what OHLCV data represents:
https://www.kaiko.com/collections/ohlcv

CEX.io API has API method for OHLCV, but only historical (only until yesterday, but no live data for today)

This are the API Requests I'm trying to use:
https://cex.io/rest-api#historical-1m-ohlcv-chart
https://cex.io/rest-api#trade-history

OHLCV Feed Result for yesterday
https://cex.io/api/ohlcv/hd/20210530/ATOM/EUR

Current Feed Result for TradeHistory
https://cex.io/api/trade_history/ATOM/EUR


I would like to record all trade-data history and append today's recent trade history as OHLCV on top. I think the trade-history feed has all data required, but I don't know how to compute reduced f.e. data1m array from trade-history data.

Does anyone how such chart-data is generated? Thanks in advice.