def identifier(self) -> TradeID: """Formulates a unique identifier for the trade to become the DB primary key """ string = (str(self.location) + str(self.timestamp) + str(self.trade_type) + self.pair + str(self.amount) + str(self.rate) + self.link) return TradeID(hash_id(string))
def identifier(self) -> TradeID: """Formulates a unique identifier for the trade to become the DB primary key """ string = (str(self.location) + str(self.timestamp) + str(self.trade_type) + self.base_asset.identifier + self.quote_asset.identifier + str(self.amount) + str(self.rate) + (self.link if self.link else '')) return TradeID(hash_id(string))
def hash_id(hashable: str) -> TradeID: id_bytes = sha3(hashable.encode()) return TradeID(id_bytes.hex())