-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
60 lines (45 loc) · 1.78 KB
/
main.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
from FairMarketValue.cryptocompare_interface import CryptoCompareInterface
from Binance.binance_logger import BinanceLogger
import time
import os, sys
LOGS_DIR = 'logs'
class Main:
def __init__(self):
self.fmv = CryptoCompareInterface()
self.binance = BinanceLogger(self.fmv)
def run_state(self):
# Cache old log files, get start IDS for this pull
self._cache_old_logs()
# Log the exchanges
self._run_binance_logger()
# self._run_binance_logger()
# Upload logs to google
# self._upload_to_google()
def _run_binance_logger(self):
self.binance.main()
# self.binance.test("EDO")
def _run_kucoin_logger(self):
pass
def _upload_to_google(self):
print("Preparing to upload to google drive...")
print("Upload complete.")
def _cache_old_logs(self):
# Move old logs to cached folder, so they overwritten
print("Preparing to cache old logs, if any...")
if os.path.isdir(LOGS_DIR):
for file in os.listdir(LOGS_DIR):
date = file.split('_')
new_folder = os.path.join(os.getcwd(), "cached_logs_" + date[0] + "_" + date[1] + "_" + date[2])
new_filename = os.path.join( new_folder, file)
old_filename = os.path.join(os.getcwd(), os.path.join(LOGS_DIR, file))
print("Old file: " + str(old_filename))
print("New file: " + str(new_filename))
# Make sure the dir is there
if not os.path.isdir(new_folder):
os.mkdir(new_folder)
# Move files
os.rename(old_filename, new_filename)
print("Caching complete.")
if __name__ == "__main__":
m = Main()
m.run_state()