From f1252983e41c135b3a232ab608b504de408fe9a2 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 6 Jun 2023 17:24:21 -0400 Subject: [PATCH] kucoin: support start and end dt based bars queries --- piker/brokers/kucoin.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/piker/brokers/kucoin.py b/piker/brokers/kucoin.py index e3ef599e..eebbc5f7 100755 --- a/piker/brokers/kucoin.py +++ b/piker/brokers/kucoin.py @@ -460,12 +460,22 @@ class Client: ''' # Generate generic end and start time if values not passed # Currently gives us 12hrs of data - if end_dt is None: + if ( + end_dt is None + and start_dt is None + ): end_dt = pendulum.now('UTC').add(minutes=1) + start_dt = end_dt.start_of('minute').subtract(minutes=limit) - if start_dt is None: - start_dt = end_dt.start_of( - 'minute').subtract(minutes=limit) + if ( + start_dt + and end_dt is None + ): + # just set end to limit's worth in future + end_dt = start_dt.start_of('minute').add(minutes=limit) + + else: + start_dt = end_dt.start_of('minute').subtract(minutes=limit) start_dt = int(start_dt.timestamp()) end_dt = int(end_dt.timestamp())