+ @classmethod
+ def retrieve_cryptoportfolio(cls):
+ if dbs.redis_connected():
+ repartition = dbs.redis.get("/cryptoportfolio/repartition/latest")
+ date = dbs.redis.get("/cryptoportfolio/repartition/date")
+ if date is not None and repartition is not None:
+ date = datetime.datetime.strptime(date.decode(), "%Y-%m-%d")
+ repartition = json.loads(repartition, parse_int=D, parse_float=D)
+ repartition = { k: { date: v } for k, v in repartition.items() }
+
+ cls.data.set("")
+ cls.last_date.set(date)
+ cls.liquidities.set(repartition)
+
+ @classmethod
+ def store_cryptoportfolio(cls):
+ if dbs.redis_connected():
+ hash_ = {}
+ for liquidity, repartitions in cls.liquidities.items():
+ hash_[liquidity] = repartitions[cls.last_date.get()]
+ dump = json.dumps(hash_)
+ key = "/cryptoportfolio/repartition/latest"
+ dbs.redis.set(key, dump)
+ key = "/cryptoportfolio/repartition/date"
+ dbs.redis.set(key, cls.last_date.date().isoformat())
+