Bitcoin Forum
June 17, 2024, 10:53:43 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Coding -- how to convert Trading History to OHLCV Format?  (Read 72 times)
d-angel2001 (OP)
Newbie
*
Offline Offline

Activity: 137
Merit: 0


View Profile
May 31, 2021, 01:36:47 PM
 #1

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.

d-angel2001 (OP)
Newbie
*
Offline Offline

Activity: 137
Merit: 0


View Profile
May 31, 2021, 01:42:22 PM
 #2

Ok, here's my current progress.

I've been trying to understand the data-invertal for data1m. I thought there might be a constant interval the entries are created for. But so far I can't find the scheme comparing the timestamps (which are the long numbers on position #1 in first data-entry).

I really hope someone knows more about that and can explain me how to compute it myself or at least which intervals the data is based on if it may be such simple and there is no more compution for some kind of data calculations between 1m and 1h and so on.
NaramediaID
Full Member
***
Offline Offline

Activity: 251
Merit: 102


Coffee, Coding, Crypto


View Profile
June 01, 2021, 05:22:48 AM
 #3

Ok, here's my current progress.

I've been trying to understand the data-invertal for data1m. I thought there might be a constant interval the entries are created for. But so far I can't find the scheme comparing the timestamps (which are the long numbers on position #1 in first data-entry).

I really hope someone knows more about that and can explain me how to compute it myself or at least which intervals the data is based on if it may be such simple and there is no more compution for some kind of data calculations between 1m and 1h and so on.

Can you share your current code?
Just to make it easier to see the problem
d-angel2001 (OP)
Newbie
*
Offline Offline

Activity: 137
Merit: 0


View Profile
June 01, 2021, 10:21:15 AM
 #4

Can you share your current code?
Just to make it easier to see the problem

Hi, I'm currently in conception and have no code. Before starting with code I'm trying to figure out how OHLCV data is being generated. I already know how it would be possible to convert OHLCV into historic ticker data (like this format: https://cex.io/api/trade_history/ATOM/EUR containing array of amount, time, order-type and price). But to create OHLCV for todays trades I would require to understand when the "snapshots" for OHLCV are created or if the entries are an agregation of multiple trades done for a given time-frame.

It doesn't make any sense to start any coding without concept here.
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6898


bitcoincleanup.com / bitmixlist.org


View Profile WWW
June 01, 2021, 11:28:13 AM
 #5

How are you going to get today's OHLCV data when the close/high/low prices aren't even known for sure yet?

What is the timeframe of trading data you are trying to get? Is it like 5m, 30m, a day, or something else?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!