-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathredisCommands.py
38 lines (32 loc) · 1.09 KB
/
redisCommands.py
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
import redis
from walrus import Database # A subclass of the redis-py Redis client.
import redisCommands as rd
import pandas as pd
import threading
import concurrent.futures
from datetime import datetime
class ExecutablePrice:
bids: list
asks: list
#We don't need this because walrus package time-series stream automatically appends a timestamp!
#timestamp: str
#constructor
#def __init__(self):
# self.timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
class xMsg:
price: list
amount: list
timestamp: datetime
#We don't need this because walrus package time-series stream automatically appends a timestamp!
#timestamp: str
#constructor
#def __init__(self):
# self.timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
def startRedis(host='localhost', port=6379, db=0):
return(redis.StrictRedis(host=host, port=port, db=db))
def xstream(timeseries=True, name=None):
db = Database()
if timeseries:
return(db.time_series('ExecutablePrice', ['xbid', 'xask']))
else:
return(db.Stream(name))