Skip to content

Commit 81a9ad3

Browse files
author
Christophe Pardon
committed
ooo
1 parent 8004ca7 commit 81a9ad3

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

app.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,29 @@
99
from s3FileUtils import S3FileUtils
1010

1111
ordersDataFileName = 'data/ordersData.txt'
12-
configFileName = 'data/configTradingViewBot.txt'
12+
configFileName = 'data/config.txt'
1313

1414
processingAlert = False
1515

1616
config = {}
1717
users = []
1818
ordersData = []
19+
1920
saveToS3 = False
21+
initS3 = False
2022
if os.getenv('save-to-s3', None) == "1":
21-
print("Load from s3")
23+
print("Load orders from s3")
2224
saveToS3 = True
23-
s3 = S3FileUtils()
25+
initS3 = True
26+
27+
configFromS3 = False
28+
if os.getenv('config-from-s3', None) == "1":
29+
print("Load config from s3")
30+
configFromS3 = True
31+
initS3
32+
33+
if initS3:
34+
s3 = S3FileUtils()
2435

2536
def getSymbolRightPart(symbol):
2637
if '/' in symbol:
@@ -30,7 +41,12 @@ def getSymbolRightPart(symbol):
3041

3142
def loadConfig():
3243
global config
33-
config = FileUtils.loadJsonFromFile(configFileName)
44+
global configFromS3
45+
46+
if saveToS3:
47+
config = s3.loadJsonFromFile('config.txt')
48+
else:
49+
config = FileUtils.loadJsonFromFile(configFileName)
3450

3551
def loadUsers():
3652
global users
@@ -44,6 +60,7 @@ def loadUsers():
4460
user.email = mail
4561

4662
for exchangeId in config["exchanges"]:
63+
print("Try to create exchange " + exchangeId)
4764
if user.hasExchange(exchangeId) == False:
4865
key = os.getenv(str(i) + "-" + exchangeId + "-key")
4966
if key is not None:

data/configTradingViewBot.txt data/config.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"exchanges": ["kucoin", "bittrex"],
2+
"exchanges": ["kucoin", "bittrex", "binance", "binanceusdm"],
33
"options" : {
44
"sendMail" : true,
55
"cancelBuyAfterMinutes": 60

s3FileUtils.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def saveJsonToFile(self, fileName, data):
1111
obj = self.s3.put_object(Body=str(json.dumps(data)), Bucket=os.getenv('s3-bucket'),Key=fileName)
1212

1313
def loadJsonFromFile(self, fileName):
14-
data = {}
1514
result = self.s3.get_object(Bucket=os.getenv('s3-bucket'), Key=fileName)
1615
str = result["Body"].read().decode()
1716
return json.loads(str)

0 commit comments

Comments
 (0)