def add_order(r: redis.client.Redis, order: Order): if order.side == "Buy": topic_name = redis_buy_prices_name else: topic_name = redis_sell_prices_name r.zadd(topic_name, {order.order_id: order.price}) r.hset(redis_order_sizes_name, key=order.order_id, value=order.size) r.hset(redis_account_names_name, key=order.order_id, value=order.username)
def initialize_db(redis_instance: redis.client.Redis, cfg_keys: List[str], default_value: int, hashset_name: str) -> None: for key in cfg_keys: redis_instance.hset(hashset_name, key, default_value)