-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared_data.py
More file actions
45 lines (36 loc) · 1.35 KB
/
Copy pathshared_data.py
File metadata and controls
45 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# class AsyncDict:
# def __init__(self, loop=None):
# self.loop = loop or asyncio.get_event_loop()
# self.data = {}
# def set(self, key, value):
# self.data[key] = value
# def get(self, key):
# return self.data.get(key)
# def delete(self, key):
# del self.data[key]
# class OrderBookStorage(AsyncDict):
# _instance = None
# def __new__(cls, *args, **kwargs):
# if not cls._instance:
# print("Initialized order book")
# cls._instance = super(OrderBookStorage, cls).__new__(cls)
# cls._instance.data = {}
# else:
# print(f"""Found existing instance,
# with data: {cls._instance.data.keys()}""")
# return cls._instance
# def store_order_book(self, pair, order_books):
# if not self.data.get(pair):
# self.set(pair, order_books)
# else:
# self.update_existing_order_book(pair, order_books)
# def update_existing_order_book(self, pair, order_books):
# if not self.data.get(pair):
# self.set(pair, order_books)
# return
# else:
# # Do not use
# self.set(pair, OrderBookMerger.merge_order_books(
# [order_books, order_books]))
# def get_order_book(self, pair):
# return self.get(pair)