-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patharcticWatch.py
84 lines (70 loc) · 2.53 KB
/
arcticWatch.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from arctic import Arctic
from asciichartpy import plot
from colorama import init, Fore, Back, Style
import pandas as pd
import time
import os
from datetime import timedelta
import datetime as dt
import argparse
def updateChart(exchange, symbol, tf, height):
store = Arctic('localhost')
library = store[exchange.upper()]
startDate = pd.to_datetime('today') - timedelta(days=5)
endDate = startDate + timedelta(days=7)
startDate = startDate.strftime("%Y-%m-%d")
endDate = endDate.strftime("%Y-%m-%d")
readStr = 'trades-' + str(symbol)
item = library.read(readStr, chunk_range=pd.date_range(startDate,
endDate)).copy()
df = item.price.resample(tf).agg({'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last'})
df = df.fillna(method='ffill')
chart = plot(df.close.tail(60), { 'height': height})
priceStr = str(item.price.iat[-1])
if(item.price.iat[-1] < item.price.iat[-2]):
priceStr = Fore.RED + priceStr
else:
priceStr = Fore.GREEN + priceStr
priceStr = priceStr + Style.RESET_ALL
exchangeStr = exchange
if(exchangeStr=="Bitfinex"):
exchangeStr = Fore.GREEN + exchangeStr
elif(exchangeStr=="Coinbase"):
exchangeStr = Fore.BLUE + exchangeStr
exchangeStr = exchangeStr + Style.RESET_ALL
exchangeStr = exchange
if(exchangeStr=="Bitfinex"):
exchangeStr = Fore.GREEN + exchangeStr
elif(exchangeStr=="Coinbase"):
exchangeStr = Fore.BLUE + exchangeStr
exchangeStr = exchangeStr + Style.RESET_ALL
os.system('clear')
print(f'Exchange: {exchangeStr}')
print(f'Symbol: {symbol}')
print(f'Timeframe: {tf}')
print(f'Price: {priceStr}')
print(f'{chart}')
time.sleep(15)
def main():
init()
parser = argparse.ArgumentParser()
parser.add_argument("--exchange", default='Bitfinex', help="Example: Bitfinex")
parser.add_argument("--symbol", default='BTC-USD', help="Example: BTC-USD")
parser.add_argument("--tf", default='1Min', help="Examples: 1Min, 15Min, 1H")
parser.add_argument("--height", default=6, type=int, help="Chart Size")
args = parser.parse_args()
if args.exchange:
pass
if args.symbol:
pass
if args.tf:
pass
if args.height:
pass
while True:
updateChart(args.exchange, args.symbol, args.tf, args.height)
if __name__== "__main__":
main()