Port to `pendulum` equivalent apis throughout
parent
d334e61b1f
commit
72ec34ffd2
|
@ -27,7 +27,7 @@ import time
|
|||
|
||||
import trio
|
||||
from trio_typing import TaskStatus
|
||||
import arrow
|
||||
import pendulum
|
||||
import asks
|
||||
from fuzzywuzzy import process as fuzzy
|
||||
import numpy as np
|
||||
|
@ -132,7 +132,7 @@ class OHLC:
|
|||
bar_wap: float = 0.0
|
||||
|
||||
|
||||
# convert arrow timestamp to unixtime in miliseconds
|
||||
# convert datetime obj timestamp to unixtime in milliseconds
|
||||
def binance_timestamp(when):
|
||||
return int((when.timestamp() * 1000) + (when.microsecond / 1000))
|
||||
|
||||
|
@ -230,11 +230,11 @@ class Client:
|
|||
|
||||
if start_time is None:
|
||||
start_time = binance_timestamp(
|
||||
arrow.utcnow().floor('minute').shift(minutes=-limit)
|
||||
pendulum.now('UTC').start_of('minute').subtract(minutes=limit)
|
||||
)
|
||||
|
||||
if end_time is None:
|
||||
end_time = binance_timestamp(arrow.utcnow())
|
||||
end_time = binance_timestamp(pendulum.now('UTC'))
|
||||
|
||||
# https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
|
||||
bars = await self._api(
|
||||
|
|
|
@ -25,7 +25,7 @@ import time
|
|||
|
||||
from trio_typing import TaskStatus
|
||||
import trio
|
||||
import arrow
|
||||
import pendulum
|
||||
import asks
|
||||
from fuzzywuzzy import process as fuzzy
|
||||
import numpy as np
|
||||
|
@ -401,8 +401,8 @@ class Client:
|
|||
as_np: bool = True,
|
||||
) -> dict:
|
||||
if since is None:
|
||||
since = arrow.utcnow().floor('minute').shift(
|
||||
minutes=-count).timestamp()
|
||||
since = pendulum.now('UTC').start_of('minute').subtract(
|
||||
minutes=count).timestamp()
|
||||
|
||||
# UTC 2017-07-02 12:53:20 is oldest seconds value
|
||||
since = str(max(1499000000, since))
|
||||
|
|
|
@ -19,7 +19,6 @@ Questrade API backend.
|
|||
"""
|
||||
from __future__ import annotations
|
||||
import inspect
|
||||
import contextlib
|
||||
import time
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
|
@ -32,7 +31,7 @@ from typing import (
|
|||
Callable,
|
||||
)
|
||||
|
||||
import arrow
|
||||
import pendulum
|
||||
import trio
|
||||
import tractor
|
||||
from async_generator import asynccontextmanager
|
||||
|
@ -46,7 +45,6 @@ from .._cacheables import open_cached_client, async_lifo_cache
|
|||
from .. import config
|
||||
from ._util import resproc, BrokerError, SymbolNotFound
|
||||
from ..log import get_logger, colorize_json, get_console_log
|
||||
from . import get_brokermod
|
||||
|
||||
|
||||
log = get_logger(__name__)
|
||||
|
@ -601,12 +599,16 @@ class Client:
|
|||
sid = sids[symbol]
|
||||
|
||||
# get last market open end time
|
||||
est_end = now = arrow.utcnow().to('US/Eastern').floor('minute')
|
||||
est_end = now = pendulum.now('UTC').in_timezoe(
|
||||
'America/New_York').start_of('minute')
|
||||
|
||||
# on non-paid feeds we can't retreive the first 15 mins
|
||||
wd = now.isoweekday()
|
||||
if wd > 5:
|
||||
quotes = await self.quote([symbol])
|
||||
est_end = arrow.get(quotes[0]['lastTradeTime'])
|
||||
est_end = pendulum.parse(
|
||||
quotes[0]['lastTradeTime']
|
||||
)
|
||||
if est_end.hour == 0:
|
||||
# XXX don't bother figuring out extended hours for now
|
||||
est_end = est_end.replace(hour=17)
|
||||
|
|
Loading…
Reference in New Issue