Skip to content

Commit

Permalink
define candle eq
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-kleiner committed Jun 16, 2018
1 parent f0623f7 commit 7689bee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions binance_db/candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<Candle(pair={}, open_time={}, open={}, close={})>".format(
self.pair, date, self.open_price, self.close_price)

@staticmethod
def to_date(timestamp):
return datetime.utcfromtimestamp(timestamp / 1000)
Expand Down

0 comments on commit 7689bee

Please sign in to comment.