-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
61 lines (48 loc) · 1.47 KB
/
utils.py
File metadata and controls
61 lines (48 loc) · 1.47 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import datetime
from blessed import Terminal
term = Terminal()
def print_to_terminal(x, y, message, end='\n'):
print(term.move_xy(x, y) + message, end=end)
def current_time():
now = datetime.datetime.now()
return now.strftime('%H:%M:%S')
class Messages:
@classmethod
def current_price(cls, height, currency, price):
print_to_terminal(
x=0, y=height+1,
message=f'> Current {currency} price: ${price} \r',
end=""
)
@classmethod
def next_purchase(cls, height, frequency):
print_to_terminal(
x=0, y=height + 3,
message=f'> Next purchase attempt in {frequency} (s) \r',
end=""
)
@classmethod
def available_balance(cls, height, available_balance):
print_to_terminal(
x=0, y=height + 5,
message=f'> Available USD balance: $ {available_balance}. \r',
end=""
)
@classmethod
def buy(cls, height, response):
if not response:
message = f"Last purchase made at {current_time()}"
else:
message = f"Purchase failed: '{response}'"
print_to_terminal(
x=0, y=height + 7,
message=f'*** {message} \r',
end=""
)
@classmethod
def not_dipping(cls, height):
print_to_terminal(
x=0, y=height + 7,
message=f'*** Waiting for dip to start buying! \r',
end=""
)