From 7689beed9c56774ba187705e69879118558547d1 Mon Sep 17 00:00:00 2001 From: Sam Kleiner Date: Sat, 16 Jun 2018 18:37:12 -0400 Subject: [PATCH] define candle eq --- binance_db/candle.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/binance_db/candle.py b/binance_db/candle.py index bb19b31..7dac931 100644 --- a/binance_db/candle.py +++ b/binance_db/candle.py @@ -35,12 +35,17 @@ def __init__(self, pair, kline): self.trades = kline[rest.TRADES] self.tbbav = float(kline[rest.TBBAV]) self.tbqav = float(kline[rest.TBQAV]) - + + def __eq__(self, other): + if other == None: + return False + return self.pair == other.pair and self.close_time == other.close_time + def __repr__(self): date = self.open_time.strftime('%Y-%m-%d %H:%M:%S') return "".format( self.pair, date, self.open_price, self.close_price) - + @staticmethod def to_date(timestamp): return datetime.utcfromtimestamp(timestamp / 1000)