From c2a02e7074dd0084188be3f7d1c2bbddde1c98c2 Mon Sep 17 00:00:00 2001 From: fredfortier Date: Mon, 23 Oct 2017 20:29:48 -0400 Subject: [PATCH] Fixed hash method to create sid numbers --- catalyst/assets/_assets.pyx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/catalyst/assets/_assets.pyx b/catalyst/assets/_assets.pyx index 986d2174..bd67526e 100644 --- a/catalyst/assets/_assets.pyx +++ b/catalyst/assets/_assets.pyx @@ -17,6 +17,8 @@ """ Cythonized Asset object. """ +import hashlib + cimport cython from cpython.number cimport PyNumber_Index from cpython.object cimport ( @@ -501,7 +503,11 @@ cdef class TradingPair(Asset): if sid == 0 or sid is None: try: - sid = abs(hash(symbol)) % (10 ** 4) + # sid = abs(hash(symbol)) % (10 ** 4) + # TODO: try to encode the symbol in the main scope + sid = int( + hashlib.sha256(symbol.encode('utf-8')).hexdigest(), 16 + ) % 10 ** 6 except Exception as e: raise SidHashError(symbol=symbol)