From 2131c6bf93a19a3a68052252efeda12da6b3cbb3 Mon Sep 17 00:00:00 2001 From: "Gavin.Chan" Date: Tue, 23 Jan 2018 23:25:10 +0000 Subject: [PATCH] Resolve UTC issue in candles --- .gitignore | 1 + libcryptomarket/core/candle.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0ca54ed..8282dcf 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ target/ # Others .editorconfig .github/ +.idea/ diff --git a/libcryptomarket/core/candle.py b/libcryptomarket/core/candle.py index 1915508..3d04c15 100644 --- a/libcryptomarket/core/candle.py +++ b/libcryptomarket/core/candle.py @@ -19,8 +19,8 @@ def candles(source, symbol, start_time, end_time, frequency): data = source.public_get_returnchartdata(params={ "currencyPair": symbol, - "start": start_time.timestamp(), - "end": end_time.timestamp(), + "start": round(start_time.timestamp()), + "end": round(end_time.timestamp()), "period": frequency }) @@ -31,7 +31,7 @@ def candles(source, symbol, start_time, end_time, frequency): }) data.loc[:, 'start_time'] = data['start_time'].apply( - pd.Timestamp.fromtimestamp) + lambda x : pd.Timestamp.fromtimestamp(x).tz_localize('UTC')) data['end_time'] = data['start_time'] + pd.DateOffset( seconds=frequency)