Skip to content

Commit

Permalink
[ISSUES-84] remove timezone code
Browse files Browse the repository at this point in the history
  • Loading branch information
brayden-jo committed Jun 14, 2022
1 parent 3c962ac commit 4c4c723
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyupbit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .errors import *
from .websocket_api import WebSocketManager

__version__ = "0.2.30"
__version__ = "0.2.31"
15 changes: 9 additions & 6 deletions pyupbit/quotation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_ohlcv(ticker="KRW-BTC", interval="day", count=200, to=None,
elif isinstance(to, pd._libs.tslibs.timestamps.Timestamp):
to = to.to_pydatetime()

to = to.astimezone(datetime.timezone.utc)
#to = to.astimezone(datetime.timezone.utc)

dfs = []
count = max(count, 1)
Expand All @@ -107,7 +107,8 @@ def get_ohlcv(ticker="KRW-BTC", interval="day", count=200, to=None,
for x in contents:
dt = datetime.datetime.strptime(
x['candle_date_time_kst'], "%Y-%m-%dT%H:%M:%S")
dt_list.append(dt.astimezone())
#dt_list.append(dt.astimezone())
dt_list.append(dt)

df = pd.DataFrame(contents,
columns=[
Expand Down Expand Up @@ -153,15 +154,15 @@ def get_ohlcv_from(ticker="KRW-BTC", interval="day", fromDatetime=None,
fromDatetime = pd.to_datetime(fromDatetime).to_pydatetime()
elif isinstance(fromDatetime, pd._libs.tslibs.timestamps.Timestamp):
fromDatetime = fromDatetime.to_pydatetime()
fromDatetime = fromDatetime.astimezone(datetime.timezone.utc)
#fromDatetime = fromDatetime.astimezone(datetime.timezone.utc)

if to is None:
to = datetime.datetime.now()
elif isinstance(to, str):
to = pd.to_datetime(to).to_pydatetime()
elif isinstance(to, pd._libs.tslibs.timestamps.Timestamp):
to = to.to_pydatetime()
to = to.astimezone(datetime.timezone.utc)
#to = to.astimezone(datetime.timezone.utc)

dfs = []
while to > fromDatetime:
Expand All @@ -176,7 +177,8 @@ def get_ohlcv_from(ticker="KRW-BTC", interval="day", fromDatetime=None,
for x in contents:
dt = datetime.datetime.strptime(
x['candle_date_time_kst'], "%Y-%m-%dT%H:%M:%S")
dt_list.append(dt.astimezone())
#dt_list.append(dt.astimezone())
dt_list.append(dt)
# set timezone for time comparison
# timezone will be removed before DataFrame returned

Expand All @@ -196,7 +198,7 @@ def get_ohlcv_from(ticker="KRW-BTC", interval="day", fromDatetime=None,

to = datetime.datetime.strptime(
contents[-1]['candle_date_time_utc'], "%Y-%m-%dT%H:%M:%S")
to = to.replace(tzinfo=datetime.timezone.utc)
#to = to.replace(tzinfo=datetime.timezone.utc)
# to compare fromTs and to, set tzinfo

if to > fromDatetime:
Expand Down Expand Up @@ -325,6 +327,7 @@ def get_orderbook(ticker="KRW-BTC", limit_info=False):
# print(get_ohlcv("KRW-BTC", interval="day", count=5))
# print(get_ohlcv("KRW-BTC", interval="day", to="2020-01-01 00:00:00"))
df = get_ohlcv('KRW-XRP', interval='minute5', count=1000)
print(type(df.index))
print(df)

# to = datetime.datetime.strptime("2020-01-01", "%Y-%m-%d")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setuptools.setup(
name='pyupbit',
version='0.2.30',
version='0.2.31',
author='Jonghun Yoo, Brayden Jo',
author_email=author_email,
description='python wrapper for Upbit API',
Expand Down

0 comments on commit 4c4c723

Please sign in to comment.