Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptopia OHLCV candletimestamp incoherencies with other exchanges #3034

Closed
davemg3 opened this issue Jun 4, 2018 · 3 comments
Closed

Cryptopia OHLCV candletimestamp incoherencies with other exchanges #3034

davemg3 opened this issue Jun 4, 2018 · 3 comments
Assignees
Labels

Comments

@davemg3
Copy link

davemg3 commented Jun 4, 2018

The Structure of OHLCV returned by CCXT is :

 [
        1504541580000, // UTC timestamp in milliseconds, integer
        4235.4,        // (O)pen price, float
        4240.6,        // (H)ighest price, float
        4230.0,        // (L)owest price, float
        4230.7,        // (C)losing price, float
        37.72941911    // (V)olume (in terms of the base currency), float
    ],

Lets say it is now Monday, June 4, 2018 12:30:00 AM

Usually OHLCV returned from exchanges by CCXT on a timeframe 1h will be of type ....Monday, June 4, 2018 11:00:00 AM,.... Monday, June 4, 2018 12:00:00 AM, ....whatever the time it is fetched.
But some Exchanges as Cryptopia will return for example: time 1528115400305 which is Monday, June 4, 2018 12:30:41.305 AM, Monday, June 4, 2018 12:30:41.305 AM...
which corresponds to the time of fetching on Cryptopia server minus 1h, 2h ... depending of candle.

What is the range of such candle (beginning?end time?) ? Can we format the result as other exchanges i.e array of result at 11:00:00, 12:00:00...?

@davemg3 davemg3 changed the title Cryptopia OHLCV candletimestamp incohencies with other exchanges Cryptopia OHLCV candletimestamp incoherencies with other exchanges Jun 4, 2018
@kroitor kroitor self-assigned this Jun 5, 2018
@kroitor
Copy link
Member

kroitor commented Jun 5, 2018

This is partially explained here: #2805

In short, we don't merge sparse timestamps for now due to differences in business days across various countries and timezones. So, you will have to adjust the timestamps according to your purposes.

All timestamps are now in UTC, so aligning to 1h-boundaries or 2h-boundaries with basic arithmetic should not be very difficult. This is currently a responsibility of the user.

https://github.com/ccxt/ccxt/blob/master/examples/py/normalize-sparse-candle-timestamps.py

# -*- coding: utf-8 -*-

import os
import sys
import datetime
from pprint import pprint
import ccxt

exchange = ccxt.cryptopia({ 'enableRateLimit': True })

symbol = 'ETH/BTC'
timeframe = '1h'

candles = exchange.fetch_ohlcv(symbol, timeframe)

# timeframe duration in seconds
duration = exchange.parse_timeframe (timeframe)

# timeframe duration in milliseconds
duration *= 1000

pprint([[
    exchange.iso8601 (int(round(candle[0] / duration)) * duration),
    candle[1],  # o
    candle[2],  # h
    candle[3],  # l
    candle[4],  # c
    candle[5]   # v
] for candle in candles])

Hope this answers your question.

@davemg3
Copy link
Author

davemg3 commented Jun 7, 2018

@kroitor , I am not sure to get it. From you code I understand that if:

  • It is now 13h10 and I call all

1h candles since=11h

  • Result : Cryptopia exchange send me candles with timestamps :

11h10 , 12h10 and 13h10

So these candles can be considered and timestamped as the candles of ranges

11h , 12h and 13h

Thanks to clarify (cause my fear was that were approximately candles from11h10 to 12h09, from12h10 to 13h09...etc..)
Rgds

@davemg3
Copy link
Author

davemg3 commented Jun 12, 2018

Hi @kroitor ,

After testing,
if it is 12h when fetching OHLCV with parameters: 1h candles since=11h, for example , results are different depending of the minutes of fetching time as per image.
So it is not possible to consider and round a timestamp of ''11h32'' or ''11h46'' sent by Cryptopia as if it was a ''11h'' timestamp.
So i am confused by your previous feedback. Can you clarify?

In my picture,exch_timestamp is the timestamp sent by Cryptopia and fetch_Stamp the time when the http call is done...
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants