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

fetch_ohlcv since problem #379

Closed
werewere opened this issue Oct 23, 2017 · 8 comments
Closed

fetch_ohlcv since problem #379

werewere opened this issue Oct 23, 2017 · 8 comments
Assignees
Labels

Comments

@werewere
Copy link

werewere commented Oct 23, 2017

Hi, I'm not sure if this is a bug or a feature; the following code won't work:

since=int(datetime.datetime.strptime('2017-10-23 00:00:00', '%Y-%m-%d %H:%M:%S').strftime("%s"))
ohlc=polo.fetch_ohlcv("ETH/BTC", '5m', since)

It is needed to do the following:

since=int(datetime.datetime.strptime('2017-10-23 00:00:00', '%Y-%m-%d %H:%M:%S').strftime("%s"))
since *=1000
ohlc=polo.fetch_ohlcv("ETH/BTC", '5m', since)

I found this because checking the ccxt source code, I saw that (in Poloniex at least) the start time was calculated doing:

'start': int(since / 1000),

May be this is due to an old problem in Poloniex (I'm just guessing) and then Poloniex fixed the problem but the ccxt code still has the old workaround?. Anyway, this is not a problem, I can just multiply, but I'm not sure if I'm missing something.

@kroitor kroitor self-assigned this Oct 23, 2017
@kroitor
Copy link
Member

kroitor commented Oct 23, 2017

Hi, @werewere !

Nope, it's not a bug, the library works with all timestamps as milliseconds, everywhere. So, yes, you can just do ohlc=polo.fetch_ohlcv("ETH/BTC", '5m', since * 1000).

Milliseconds are chosen for portability and cross-exchange compatibility, don't forget that Poloniex is not the only exchange that implements the since param and fetch_ohlcv. There are other exchanges as well, and most of the time a common subset of milliseconds-range covers all needs for all exchanges, whereas seconds-based ranges are sometimes not sufficiently precise.

I hope this reply answers your question, I'd close this issue for now.

Thx!

@kroitor kroitor closed this as completed Oct 23, 2017
@werewere
Copy link
Author

Yeah, I use also Bitfinex but as it is not fully supported yet for OHLCV, I was doing tests with Poloniex.

Anyway, understood, thanks! :)

@kroitor
Copy link
Member

kroitor commented Oct 23, 2017

@werewere bitfinex v2 already supports OHLCV btw ;) And, hopefully, both of Bitfinex v1 and v2 will support it soon ;)

@werewere
Copy link
Author

Oh, it is true! I didn't realized that I should use bitfinex2, indeed it has OHLCV! You made my day :)

kroitor added a commit that referenced this issue Oct 23, 2017
@kroitor
Copy link
Member

kroitor commented Oct 23, 2017

@werewere as of version 1.9.237 you can use Bitfinex v1 to fetch_ohlcv() as well ;) Cheers!

@xgdgsc
Copy link
Contributor

xgdgsc commented Nov 19, 2017

Has the since API changed? bar_list=bitmex.fetch_ohlcv('XBTZ17', '1m', since='2017-11-08 00:01:44') works in version '1.9.39' but not in version '1.10.171'.

@kroitor
Copy link
Member

kroitor commented Nov 19, 2017

@xgdgsc it accepts an integer number of milliseconds for consistency across the majority of exchanges, so you can call it like so:

bar_list=bitmex.fetch_ohlcv('XBTZ17', '1m', since=bitmex.parse8601('2017-11-08 00:01:44'))

@xgdgsc
Copy link
Contributor

xgdgsc commented Nov 19, 2017

OK. Thanks.

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

3 participants