Merge pull request #303 from pikers/drop_arrow_add_predulum

Drop `arrow` add `pendulum`
no_orderid_in_error
goodboy 2022-04-16 14:00:03 -04:00 committed by GitHub
commit 3ac9c55535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 20 deletions

View File

@ -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(

View File

@ -1519,13 +1519,13 @@ async def get_bars(
('history', hist_ev),
# ('live', live_ev),
]:
with trio.move_on_after(22) as cs:
await ev.wait()
log.info(f"{name} DATA RESET")
# with trio.move_on_after(22) as cs:
await ev.wait()
log.info(f"{name} DATA RESET")
if cs.cancelled_caught:
log.warning("reset hack failed on first try?")
# await tractor.breakpoint()
# if cs.cancelled_caught:
# log.warning("reset hack failed on first try?")
# await tractor.breakpoint()
fails += 1
continue
@ -1583,7 +1583,7 @@ async def backfill_bars(
# on that until we have the `marketstore` daemon in place in which
# case the shm size will be driven by user config and available sys
# memory.
count: int = 16,
count: int = 100,
task_status: TaskStatus[trio.CancelScope] = trio.TASK_STATUS_IGNORED,

View File

@ -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))

View File

@ -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)

View File

@ -60,7 +60,7 @@ setup(
'ib_insync',
# numerics
'arrow', # better datetimes
'pendulum', # easier datetimes
'bidict', # 2 way map
'cython',
'numpy',